@tanstack/table-core
Advanced tools
Comparing version 8.0.0-alpha.55 to 8.0.0-alpha.57
@@ -17,2 +17,5 @@ /** | ||
var utils = require('./utils.js'); | ||
var Columns = require('./features/Columns.js'); | ||
var Rows = require('./features/Rows.js'); | ||
var Cells = require('./features/Cells.js'); | ||
var ColumnSizing = require('./features/ColumnSizing.js'); | ||
@@ -31,3 +34,2 @@ var Expanding = require('./features/Expanding.js'); | ||
var features = [Headers.Headers, Visibility.Visibility, Ordering.Ordering, Pinning.Pinning, Filters.Filters, Sorting.Sorting, Grouping.Grouping, Expanding.Expanding, Pagination.Pagination, RowSelection.RowSelection, ColumnSizing.ColumnSizing]; | ||
function createTableInstance(options) { | ||
@@ -41,3 +43,5 @@ var _options$initialState; | ||
var instance = {}; | ||
var defaultOptions = features.reduce(function (obj, feature) { | ||
instance._features = [Columns.Columns, Rows.Rows, Cells.Cells, Headers.Headers, Visibility.Visibility, Ordering.Ordering, Pinning.Pinning, Filters.Filters, Sorting.Sorting, Grouping.Grouping, Expanding.Expanding, Pagination.Pagination, RowSelection.RowSelection, ColumnSizing.ColumnSizing]; | ||
var defaultOptions = instance._features.reduce(function (obj, feature) { | ||
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance)); | ||
@@ -55,3 +59,3 @@ }, {}); | ||
var initialState = _rollupPluginBabelHelpers["extends"]({}, coreInitialState, features.reduce(function (obj, feature) { | ||
var initialState = _rollupPluginBabelHelpers["extends"]({}, coreInitialState, instance._features.reduce(function (obj, feature) { | ||
return Object.assign(obj, feature.getInitialState == null ? void 0 : feature.getInitialState()); | ||
@@ -63,4 +67,4 @@ }, {}), (_options$initialState = options.initialState) != null ? _options$initialState : {}); | ||
var finalInstance = _rollupPluginBabelHelpers["extends"]({}, instance, features.reduce(function (obj, feature) { | ||
return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance)); | ||
var finalInstance = _rollupPluginBabelHelpers["extends"]({}, instance, instance._features.reduce(function (obj, feature) { | ||
return Object.assign(obj, feature.createInstance == null ? void 0 : feature.createInstance(instance)); | ||
}, {}), { | ||
@@ -109,7 +113,2 @@ queue: function queue(cb) { | ||
}, | ||
getRowId: function getRowId(row, index, parent) { | ||
var _instance$options$get; | ||
return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index); | ||
}, | ||
getState: function getState() { | ||
@@ -121,324 +120,2 @@ return instance.options.state; | ||
}, | ||
getDefaultColumn: utils.memo(function () { | ||
return [instance.options.defaultColumn]; | ||
}, function (defaultColumn) { | ||
var _defaultColumn; | ||
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {}; | ||
return _rollupPluginBabelHelpers["extends"]({ | ||
header: function header(props) { | ||
return props.header.column.id; | ||
}, | ||
footer: function footer(props) { | ||
return props.header.column.id; | ||
}, | ||
cell: function cell(_ref) { | ||
var _ref$value = _ref.value, | ||
value = _ref$value === void 0 ? '' : _ref$value; | ||
return typeof value === 'boolean' ? value.toString() : value; | ||
} | ||
}, features.reduce(function (obj, feature) { | ||
return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn()); | ||
}, {}), defaultColumn); | ||
}, { | ||
debug: function debug() { | ||
var _instance$options$deb; | ||
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns; | ||
}, | ||
key: 'getDefaultColumn' | ||
}), | ||
getColumnDefs: function getColumnDefs() { | ||
return instance.options.columns; | ||
}, | ||
createColumn: function createColumn(columnDef, depth, parent) { | ||
var _ref2, _columnDef$id; | ||
var defaultColumn = instance.getDefaultColumn(); | ||
var id = (_ref2 = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref2 : typeof columnDef.header === 'string' ? columnDef.header : undefined; | ||
var accessorFn; | ||
if (columnDef.accessorFn) { | ||
accessorFn = columnDef.accessorFn; | ||
} else if (columnDef.accessorKey) { | ||
accessorFn = function accessorFn(originalRow) { | ||
return originalRow[columnDef.accessorKey]; | ||
}; | ||
} | ||
if (!id) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header"); | ||
} | ||
throw new Error(); | ||
} | ||
var column = _rollupPluginBabelHelpers["extends"]({}, defaultColumn, columnDef, { | ||
id: "" + id, | ||
accessorFn: accessorFn, | ||
parent: parent, | ||
depth: depth, | ||
columnDef: columnDef, | ||
columnDefType: columnDef.columnDefType, | ||
columns: [], | ||
getWidth: function getWidth() { | ||
return instance.getColumnWidth(column.id); | ||
}, | ||
getFlatColumns: utils.memo(function () { | ||
return [true]; | ||
}, function () { | ||
var _column$columns; | ||
return [column].concat((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(function (d) { | ||
return d.getFlatColumns(); | ||
})); | ||
}, { | ||
key: 'column.getFlatColumns', | ||
debug: function debug() { | ||
var _instance$options$deb2; | ||
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns; | ||
} | ||
}), | ||
getLeafColumns: utils.memo(function () { | ||
return [instance._getOrderColumnsFn()]; | ||
}, function (orderColumns) { | ||
var _column$columns2; | ||
if ((_column$columns2 = column.columns) != null && _column$columns2.length) { | ||
var leafColumns = column.columns.flatMap(function (column) { | ||
return column.getLeafColumns(); | ||
}); | ||
return orderColumns(leafColumns); | ||
} | ||
return [column]; | ||
}, { | ||
key: 'column.getLeafColumns', | ||
debug: function debug() { | ||
var _instance$options$deb3; | ||
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns; | ||
} | ||
}) | ||
}); | ||
column = features.reduce(function (obj, feature) { | ||
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance)); | ||
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here. | ||
return column; | ||
}, | ||
getAllColumns: utils.memo(function () { | ||
return [instance.getColumnDefs()]; | ||
}, function (columnDefs) { | ||
var recurseColumns = function recurseColumns(columnDefs, parent, depth) { | ||
if (depth === void 0) { | ||
depth = 0; | ||
} | ||
return columnDefs.map(function (columnDef) { | ||
var column = instance.createColumn(columnDef, depth, parent); | ||
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : []; | ||
return column; | ||
}); | ||
}; | ||
return recurseColumns(columnDefs); | ||
}, { | ||
key: 'getAllColumns', | ||
debug: function debug() { | ||
var _instance$options$deb4; | ||
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns; | ||
} | ||
}), | ||
getAllFlatColumns: utils.memo(function () { | ||
return [instance.getAllColumns()]; | ||
}, function (allColumns) { | ||
return allColumns.flatMap(function (column) { | ||
return column.getFlatColumns(); | ||
}); | ||
}, { | ||
key: 'getAllFlatColumns', | ||
debug: function debug() { | ||
var _instance$options$deb5; | ||
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns; | ||
} | ||
}), | ||
getAllFlatColumnsById: utils.memo(function () { | ||
return [instance.getAllFlatColumns()]; | ||
}, function (flatColumns) { | ||
return flatColumns.reduce(function (acc, column) { | ||
acc[column.id] = column; | ||
return acc; | ||
}, {}); | ||
}, { | ||
key: 'getAllFlatColumnsById', | ||
debug: function debug() { | ||
var _instance$options$deb6; | ||
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns; | ||
} | ||
}), | ||
getAllLeafColumns: utils.memo(function () { | ||
return [instance.getAllColumns(), instance._getOrderColumnsFn()]; | ||
}, function (allColumns, orderColumns) { | ||
var leafColumns = allColumns.flatMap(function (column) { | ||
return column.getLeafColumns(); | ||
}); | ||
return orderColumns(leafColumns); | ||
}, { | ||
key: 'getAllLeafColumns', | ||
debug: function debug() { | ||
var _instance$options$deb7; | ||
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns; | ||
} | ||
}), | ||
getColumn: function getColumn(columnId) { | ||
var column = instance.getAllFlatColumnsById()[columnId]; | ||
if (!column) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn("[Table] Column with id " + columnId + " does not exist."); | ||
} | ||
throw new Error(); | ||
} | ||
return column; | ||
}, | ||
createCell: function createCell(row, column, value) { | ||
var cell = { | ||
id: row.id + "_" + column.id, | ||
rowId: row.id, | ||
columnId: column.id, | ||
row: row, | ||
column: column, | ||
value: value, | ||
getCellProps: function getCellProps(userProps) { | ||
return instance.getCellProps(row.id, column.id, userProps); | ||
}, | ||
renderCell: function renderCell() { | ||
return column.cell ? instance.render(column.cell, { | ||
instance: instance, | ||
column: column, | ||
row: row, | ||
cell: cell, | ||
value: value | ||
}) : null; | ||
} | ||
}; | ||
features.forEach(function (feature) { | ||
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance)); | ||
}, {}); | ||
return cell; | ||
}, | ||
createRow: function createRow(id, original, rowIndex, depth, values) { | ||
var row = { | ||
id: id, | ||
index: rowIndex, | ||
original: original, | ||
depth: depth, | ||
values: values, | ||
subRows: [], | ||
getLeafRows: function getLeafRows() { | ||
return utils.flattenBy(row.subRows, function (d) { | ||
return d.subRows; | ||
}); | ||
}, | ||
getRowProps: function getRowProps(userProps) { | ||
return instance.getRowProps(row.id, userProps); | ||
}, | ||
getAllCells: undefined, | ||
getAllCellsByColumnId: undefined | ||
}; | ||
row.getAllCells = utils.memo(function () { | ||
return [instance.getAllLeafColumns()]; | ||
}, function (leafColumns) { | ||
return leafColumns.map(function (column) { | ||
return instance.createCell(row, column, row.values[column.id]); | ||
}); | ||
}, { | ||
key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '', | ||
debug: function debug() { | ||
var _instance$options$deb8; | ||
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugRows; | ||
} | ||
}); | ||
row.getAllCellsByColumnId = utils.memo(function () { | ||
return [row.getAllCells()]; | ||
}, function (allCells) { | ||
return allCells.reduce(function (acc, cell) { | ||
acc[cell.columnId] = cell; | ||
return acc; | ||
}, {}); | ||
}, { | ||
key: 'row.getAllCellsByColumnId', | ||
debug: function debug() { | ||
var _instance$options$deb9; | ||
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugRows; | ||
} | ||
}); | ||
for (var i = 0; i < features.length; i++) { | ||
var feature = features[i]; | ||
Object.assign(row, feature.createRow == null ? void 0 : feature.createRow(row, instance)); | ||
} | ||
return row; | ||
}, | ||
getCoreRowModel: function getCoreRowModel() { | ||
if (!instance._getCoreRowModel) { | ||
instance._getCoreRowModel = instance.options.getCoreRowModel(instance); | ||
} | ||
return instance._getCoreRowModel(); | ||
}, | ||
// The final calls start at the bottom of the model, | ||
// expanded rows, which then work their way up | ||
getRowModel: function getRowModel() { | ||
return instance.getPaginationRowModel(); | ||
}, | ||
getRow: function getRow(id) { | ||
var row = instance.getRowModel().rowsById[id]; | ||
if (!row) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error("getRow expected an ID, but got " + id); | ||
} | ||
throw new Error(); | ||
} | ||
return row; | ||
}, | ||
getCell: function getCell(rowId, columnId) { | ||
var row = instance.getRow(rowId); | ||
if (!row) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error("[Table] could not find row with id " + rowId); | ||
} | ||
throw new Error(); | ||
} | ||
var cell = row.getAllCellsByColumnId()[columnId]; | ||
if (!cell) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId); | ||
} | ||
throw new Error(); | ||
} | ||
return cell; | ||
}, | ||
getTableProps: function getTableProps(userProps) { | ||
@@ -454,54 +131,2 @@ return utils.propGetter({ | ||
}, | ||
getRowProps: function getRowProps(rowId, userProps) { | ||
var row = instance.getRow(rowId); | ||
if (!row) { | ||
return; | ||
} | ||
return utils.propGetter({ | ||
key: row.id, | ||
role: 'row' | ||
}, userProps); | ||
}, | ||
getCellProps: function getCellProps(rowId, columnId, userProps) { | ||
var cell = instance.getCell(rowId, columnId); | ||
if (!cell) { | ||
return; | ||
} | ||
return utils.propGetter({ | ||
key: cell.id, | ||
role: 'gridcell' | ||
}, userProps); | ||
}, | ||
getTableWidth: function getTableWidth() { | ||
var _instance$getHeaderGr, _instance$getHeaderGr2; | ||
return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce(function (sum, header) { | ||
return sum + header.getWidth(); | ||
}, 0)) != null ? _instance$getHeaderGr : 0; | ||
}, | ||
getLeftTableWidth: function getLeftTableWidth() { | ||
var _instance$getLeftHead, _instance$getLeftHead2; | ||
return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce(function (sum, header) { | ||
return sum + header.getWidth(); | ||
}, 0)) != null ? _instance$getLeftHead : 0; | ||
}, | ||
getCenterTableWidth: function getCenterTableWidth() { | ||
var _instance$getCenterHe, _instance$getCenterHe2; | ||
return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce(function (sum, header) { | ||
return sum + header.getWidth(); | ||
}, 0)) != null ? _instance$getCenterHe : 0; | ||
}, | ||
getRightTableWidth: function getRightTableWidth() { | ||
var _instance$getRightHea, _instance$getRightHea2; | ||
return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce(function (sum, header) { | ||
return sum + header.getWidth(); | ||
}, 0)) != null ? _instance$getRightHea : 0; | ||
}, | ||
getOverallProgress: function getOverallProgress() { | ||
@@ -508,0 +133,0 @@ var _instance$getState = instance.getState(), |
@@ -20,5 +20,5 @@ /** | ||
var defaultColumnSizing = { | ||
width: 150, | ||
minWidth: 20, | ||
maxWidth: Number.MAX_SAFE_INTEGER | ||
size: 150, | ||
minSize: 20, | ||
maxSize: Number.MAX_SAFE_INTEGER | ||
}; | ||
@@ -49,6 +49,41 @@ var ColumnSizing = { | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createColumn: function createColumn(column, instance) { | ||
return { | ||
getColumnWidth: function getColumnWidth(columnId) { | ||
var _column$minWidth, _ref, _column$maxWidth; | ||
getSize: function getSize() { | ||
return instance.getColumnSize(column.id); | ||
}, | ||
getStart: function getStart(position) { | ||
return instance.getColumnStart(column.id, position); | ||
}, | ||
getIsResizing: function getIsResizing() { | ||
return instance.getColumnIsResizing(column.id); | ||
}, | ||
getCanResize: function getCanResize() { | ||
return instance.getColumnCanResize(column.id); | ||
}, | ||
resetSize: function resetSize() { | ||
return instance.resetColumnSize(column.id); | ||
} | ||
}; | ||
}, | ||
createHeader: function createHeader(header, instance) { | ||
return { | ||
getIsResizing: function getIsResizing() { | ||
return instance.getColumnIsResizing(header.column.id); | ||
}, | ||
getCanResize: function getCanResize() { | ||
return instance.getColumnCanResize(header.column.id); | ||
}, | ||
resetSize: function resetSize() { | ||
return instance.resetColumnSize(header.column.id); | ||
}, | ||
getResizerProps: function getResizerProps(userProps) { | ||
return instance.getHeaderResizerProps(header.id, userProps); | ||
} | ||
}; | ||
}, | ||
createInstance: function createInstance(instance) { | ||
return { | ||
getColumnSize: function getColumnSize(columnId) { | ||
var _column$minSize, _ref, _column$maxSize; | ||
@@ -62,4 +97,23 @@ var column = instance.getColumn(columnId); | ||
var columnSize = instance.getState().columnSizing[column.id]; | ||
return Math.min(Math.max((_column$minWidth = column.minWidth) != null ? _column$minWidth : defaultColumnSizing.minWidth, (_ref = columnSize != null ? columnSize : column.width) != null ? _ref : defaultColumnSizing.width), (_column$maxWidth = column.maxWidth) != null ? _column$maxWidth : defaultColumnSizing.maxWidth); | ||
return Math.min(Math.max((_column$minSize = column.minSize) != null ? _column$minSize : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.size) != null ? _ref : defaultColumnSizing.size), (_column$maxSize = column.maxSize) != null ? _column$maxSize : defaultColumnSizing.maxSize); | ||
}, | ||
getColumnStart: function getColumnStart(columnId, position) { | ||
var column = instance.getColumn(columnId); | ||
if (!column) { | ||
throw new Error(); | ||
} | ||
var columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns(); | ||
var index = columns.findIndex(function (d) { | ||
return d.id === columnId; | ||
}); | ||
if (index > 0) { | ||
var prevSiblingColumn = columns[index - 1]; | ||
return instance.getColumnStart(prevSiblingColumn.id, position) + prevSiblingColumn.getSize(); | ||
} | ||
return 0; | ||
}, | ||
setColumnSizing: function setColumnSizing(updater) { | ||
@@ -145,6 +199,6 @@ return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater); | ||
var header = headerId ? instance.getHeader(headerId) : undefined; | ||
var startSize = header ? header.getWidth() : column.getWidth(); | ||
var startSize = header ? header.getSize() : column.getSize(); | ||
var columnSizingStart = header ? header.getLeafHeaders().map(function (d) { | ||
return [d.column.id, d.getWidth()]; | ||
}) : [[column.id, column.getWidth()]]; | ||
return [d.column.id, d.getSize()]; | ||
}) : [[column.id, column.getSize()]]; | ||
var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX; | ||
@@ -165,4 +219,4 @@ | ||
var columnId = _ref5[0], | ||
headerWidth = _ref5[1]; | ||
newColumnSizing[columnId] = Math.round(Math.max(headerWidth + headerWidth * deltaPercentage, 0) * 100) / 100; | ||
headerSize = _ref5[1]; | ||
newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100; | ||
}); | ||
@@ -270,31 +324,30 @@ return _rollupPluginBabelHelpers["extends"]({}, old, { | ||
return utils.propGetter(initialProps, userProps); | ||
} | ||
}; | ||
}, | ||
createColumn: function createColumn(column, instance) { | ||
return { | ||
getIsResizing: function getIsResizing() { | ||
return instance.getColumnIsResizing(column.id); | ||
}, | ||
getCanResize: function getCanResize() { | ||
return instance.getColumnCanResize(column.id); | ||
getTotalSize: function getTotalSize() { | ||
var _instance$getHeaderGr, _instance$getHeaderGr2; | ||
return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce(function (sum, header) { | ||
return sum + header.getSize(); | ||
}, 0)) != null ? _instance$getHeaderGr : 0; | ||
}, | ||
resetSize: function resetSize() { | ||
return instance.resetColumnSize(column.id); | ||
} | ||
}; | ||
}, | ||
createHeader: function createHeader(header, instance) { | ||
return { | ||
getIsResizing: function getIsResizing() { | ||
return instance.getColumnIsResizing(header.column.id); | ||
getLeftTotalSize: function getLeftTotalSize() { | ||
var _instance$getLeftHead, _instance$getLeftHead2; | ||
return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce(function (sum, header) { | ||
return sum + header.getSize(); | ||
}, 0)) != null ? _instance$getLeftHead : 0; | ||
}, | ||
getCanResize: function getCanResize() { | ||
return instance.getColumnCanResize(header.column.id); | ||
getCenterTotalSize: function getCenterTotalSize() { | ||
var _instance$getCenterHe, _instance$getCenterHe2; | ||
return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce(function (sum, header) { | ||
return sum + header.getSize(); | ||
}, 0)) != null ? _instance$getCenterHe : 0; | ||
}, | ||
resetSize: function resetSize() { | ||
return instance.resetColumnSize(header.column.id); | ||
}, | ||
getResizerProps: function getResizerProps(userProps) { | ||
return instance.getHeaderResizerProps(header.id, userProps); | ||
getRightTotalSize: function getRightTotalSize() { | ||
var _instance$getRightHea, _instance$getRightHea2; | ||
return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce(function (sum, header) { | ||
return sum + header.getSize(); | ||
}, 0)) != null ? _instance$getRightHea : 0; | ||
} | ||
@@ -301,0 +354,0 @@ }; |
@@ -33,3 +33,3 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createInstance: function createInstance(instance) { | ||
var registered = false; | ||
@@ -36,0 +36,0 @@ return { |
@@ -125,3 +125,3 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createInstance: function createInstance(instance) { | ||
var registered = false; | ||
@@ -128,0 +128,0 @@ return { |
@@ -57,3 +57,3 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createInstance: function createInstance(instance) { | ||
var registered = false; | ||
@@ -60,0 +60,0 @@ return { |
@@ -16,91 +16,7 @@ /** | ||
var utils = require('../utils.js'); | ||
var ColumnSizing = require('./ColumnSizing.js'); | ||
// | ||
var Headers = { | ||
createRow: function createRow(row, instance) { | ||
createInstance: function createInstance(instance) { | ||
return { | ||
_getAllVisibleCells: utils.memo(function () { | ||
return [row.getAllCells().filter(function (cell) { | ||
return cell.column.getIsVisible(); | ||
}).map(function (d) { | ||
return d.id; | ||
}).join('_')]; | ||
}, function (_) { | ||
return row.getAllCells().filter(function (cell) { | ||
return cell.column.getIsVisible(); | ||
}); | ||
}, { | ||
key: 'row._getAllVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb; | ||
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows; | ||
} | ||
}), | ||
getVisibleCells: utils.memo(function () { | ||
return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()]; | ||
}, function (left, center, right) { | ||
return [].concat(left, center, right); | ||
}, { | ||
key: 'row.getVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb2; | ||
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows; | ||
} | ||
}), | ||
getCenterVisibleCells: utils.memo(function () { | ||
return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right]; | ||
}, function (allCells, left, right) { | ||
var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []); | ||
return allCells.filter(function (d) { | ||
return !leftAndRight.includes(d.columnId); | ||
}); | ||
}, { | ||
key: 'row.getCenterVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb3; | ||
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows; | ||
} | ||
}), | ||
getLeftVisibleCells: utils.memo(function () { | ||
return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,]; | ||
}, function (allCells, left) { | ||
var cells = (left != null ? left : []).map(function (columnId) { | ||
return allCells.find(function (cell) { | ||
return cell.columnId === columnId; | ||
}); | ||
}).filter(Boolean); | ||
return cells; | ||
}, { | ||
key: 'row.getLeftVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb4; | ||
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugRows; | ||
} | ||
}), | ||
getRightVisibleCells: utils.memo(function () { | ||
return [row._getAllVisibleCells(), instance.getState().columnPinning.right]; | ||
}, function (allCells, right) { | ||
var cells = (right != null ? right : []).map(function (columnId) { | ||
return allCells.find(function (cell) { | ||
return cell.columnId === columnId; | ||
}); | ||
}).filter(Boolean); | ||
return cells; | ||
}, { | ||
key: 'row.getRightVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb5; | ||
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugRows; | ||
} | ||
}) | ||
}; | ||
}, | ||
getInstance: function getInstance(instance) { | ||
return { | ||
createHeader: function createHeader(column, options) { | ||
@@ -113,2 +29,3 @@ var _options$id; | ||
column: column, | ||
index: options.index, | ||
isPlaceholder: options.isPlaceholder, | ||
@@ -120,3 +37,4 @@ placeholderId: options.placeholderId, | ||
rowSpan: 0, | ||
getWidth: function getWidth() { | ||
headerGroup: null, | ||
getSize: function getSize() { | ||
var sum = 0; | ||
@@ -128,5 +46,5 @@ | ||
} else { | ||
var _header$column$getWid; | ||
var _header$column$getSiz; | ||
sum += (_header$column$getWid = header.column.getWidth()) != null ? _header$column$getWid : 0; | ||
sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0; | ||
} | ||
@@ -138,2 +56,10 @@ }; | ||
}, | ||
getStart: function getStart() { | ||
if (header.index > 0) { | ||
var prevSiblingHeader = header.headerGroup.headers[header.index - 1]; | ||
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize(); | ||
} | ||
return 0; | ||
}, | ||
getLeafHeaders: function getLeafHeaders() { | ||
@@ -173,5 +99,9 @@ var leafHeaders = []; | ||
} | ||
}; // Yes, we have to convert instance to unknown, because we know more than the compiler here. | ||
}; | ||
return Object.assign(header, ColumnSizing.ColumnSizing.createHeader(header, instance)); | ||
instance._features.forEach(function (feature) { | ||
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance)); | ||
}); | ||
return header; | ||
}, | ||
@@ -196,5 +126,5 @@ // Header Groups | ||
debug: function debug() { | ||
var _instance$options$deb6; | ||
var _instance$options$deb; | ||
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders; | ||
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders; | ||
} | ||
@@ -212,5 +142,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb7; | ||
var _instance$options$deb2; | ||
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders; | ||
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders; | ||
} | ||
@@ -228,5 +158,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb8; | ||
var _instance$options$deb3; | ||
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders; | ||
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders; | ||
} | ||
@@ -244,5 +174,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb9; | ||
var _instance$options$deb4; | ||
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders; | ||
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders; | ||
} | ||
@@ -258,5 +188,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb10; | ||
var _instance$options$deb5; | ||
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders; | ||
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders; | ||
} | ||
@@ -271,5 +201,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb11; | ||
var _instance$options$deb6; | ||
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders; | ||
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders; | ||
} | ||
@@ -284,5 +214,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb12; | ||
var _instance$options$deb7; | ||
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders; | ||
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders; | ||
} | ||
@@ -297,5 +227,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb13; | ||
var _instance$options$deb8; | ||
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders; | ||
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders; | ||
} | ||
@@ -313,5 +243,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb14; | ||
var _instance$options$deb9; | ||
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders; | ||
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders; | ||
} | ||
@@ -328,5 +258,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb15; | ||
var _instance$options$deb10; | ||
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders; | ||
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders; | ||
} | ||
@@ -343,5 +273,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb16; | ||
var _instance$options$deb11; | ||
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders; | ||
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders; | ||
} | ||
@@ -358,5 +288,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb17; | ||
var _instance$options$deb12; | ||
return (_instance$options$deb17 = instance.options.debugAll) != null ? _instance$options$deb17 : instance.options.debugHeaders; | ||
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders; | ||
} | ||
@@ -376,5 +306,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb18; | ||
var _instance$options$deb13; | ||
return (_instance$options$deb18 = instance.options.debugAll) != null ? _instance$options$deb18 : instance.options.debugHeaders; | ||
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders; | ||
} | ||
@@ -393,5 +323,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb19; | ||
var _instance$options$deb14; | ||
return (_instance$options$deb19 = instance.options.debugAll) != null ? _instance$options$deb19 : instance.options.debugHeaders; | ||
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders; | ||
} | ||
@@ -410,5 +340,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb20; | ||
var _instance$options$deb15; | ||
return (_instance$options$deb20 = instance.options.debugAll) != null ? _instance$options$deb20 : instance.options.debugHeaders; | ||
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders; | ||
} | ||
@@ -427,5 +357,5 @@ }), | ||
debug: function debug() { | ||
var _instance$options$deb21; | ||
var _instance$options$deb16; | ||
return (_instance$options$deb21 = instance.options.debugAll) != null ? _instance$options$deb21 : instance.options.debugHeaders; | ||
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders; | ||
} | ||
@@ -501,11 +431,2 @@ }), | ||
return utils.propGetter(initialProps, userProps); | ||
}, | ||
getTotalWidth: function getTotalWidth() { | ||
var width = 0; | ||
instance.getVisibleLeafColumns().forEach(function (column) { | ||
var _column$getWidth; | ||
width += (_column$getWidth = column.getWidth()) != null ? _column$getWidth : 0; | ||
}); | ||
return width; | ||
} | ||
@@ -559,7 +480,7 @@ }; | ||
var parentHeaders = []; // Scan each column for parents | ||
var pendingParentHeaders = []; // Scan each column for parents | ||
headersToGroup.forEach(function (headerToGroup) { | ||
// What is the latest (last) parent column? | ||
var latestParentHeader = [].concat(parentHeaders).reverse()[0]; | ||
var latestPendingParentHeader = [].concat(pendingParentHeaders).reverse()[0]; | ||
var isLeafHeader = headerToGroup.column.depth === headerGroup.depth; | ||
@@ -578,22 +499,25 @@ var column; | ||
var header = instance.createHeader(column, { | ||
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'), | ||
isPlaceholder: isPlaceholder, | ||
placeholderId: isPlaceholder ? "" + parentHeaders.filter(function (d) { | ||
return d.column === column; | ||
}).length : undefined, | ||
depth: depth | ||
}); | ||
if (!latestParentHeader || latestParentHeader.column !== header.column) { | ||
header.subHeaders.push(headerToGroup); | ||
parentHeaders.push(header); | ||
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) { | ||
// This column is repeated. Add it as a sub header to the next batch | ||
latestPendingParentHeader.subHeaders.push(headerToGroup); | ||
} else { | ||
latestParentHeader.subHeaders.push(headerToGroup); | ||
} // if (!headerToGroup.isPlaceholder) { | ||
// headerToGroup.column.header = headerToGroup; | ||
// } | ||
// This is a new header. Let's create it | ||
var header = instance.createHeader(column, { | ||
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'), | ||
isPlaceholder: isPlaceholder, | ||
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(function (d) { | ||
return d.column === column; | ||
}).length : undefined, | ||
depth: depth, | ||
index: pendingParentHeaders.length | ||
}); // Add the headerToGroup as a subHeader of the new header | ||
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped | ||
// in the next batch | ||
pendingParentHeaders.push(header); | ||
} | ||
headerGroup.headers.push(headerToGroup); | ||
headerToGroup.headerGroup = headerGroup; | ||
}); | ||
@@ -603,9 +527,10 @@ headerGroups.push(headerGroup); | ||
if (depth > 0) { | ||
createHeaderGroup(parentHeaders, depth - 1); | ||
createHeaderGroup(pendingParentHeaders, depth - 1); | ||
} | ||
}; | ||
var bottomHeaders = columnsToGroup.map(function (column) { | ||
var bottomHeaders = columnsToGroup.map(function (column, index) { | ||
return instance.createHeader(column, { | ||
depth: maxDepth | ||
depth: maxDepth, | ||
index: index | ||
}); | ||
@@ -612,0 +537,0 @@ }); |
@@ -30,3 +30,3 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createInstance: function createInstance(instance) { | ||
return { | ||
@@ -33,0 +33,0 @@ setColumnOrder: function setColumnOrder(updater) { |
@@ -35,3 +35,3 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createInstance: function createInstance(instance) { | ||
var registered = false; | ||
@@ -38,0 +38,0 @@ return { |
@@ -15,2 +15,3 @@ /** | ||
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js'); | ||
var utils = require('../utils.js'); | ||
@@ -49,4 +50,126 @@ | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createRow: function createRow(row, instance) { | ||
return { | ||
getCenterVisibleCells: utils.memo(function () { | ||
return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right]; | ||
}, function (allCells, left, right) { | ||
var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []); | ||
return allCells.filter(function (d) { | ||
return !leftAndRight.includes(d.columnId); | ||
}); | ||
}, { | ||
key: 'row.getCenterVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb; | ||
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows; | ||
} | ||
}), | ||
getLeftVisibleCells: utils.memo(function () { | ||
return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,]; | ||
}, function (allCells, left) { | ||
var cells = (left != null ? left : []).map(function (columnId) { | ||
return allCells.find(function (cell) { | ||
return cell.columnId === columnId; | ||
}); | ||
}).filter(Boolean).map(function (d) { | ||
return _rollupPluginBabelHelpers["extends"]({}, d, { | ||
position: 'left' | ||
}); | ||
}); | ||
return cells; | ||
}, { | ||
key: 'row.getLeftVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb2; | ||
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows; | ||
} | ||
}), | ||
getRightVisibleCells: utils.memo(function () { | ||
return [row._getAllVisibleCells(), instance.getState().columnPinning.right]; | ||
}, function (allCells, right) { | ||
var cells = (right != null ? right : []).map(function (columnId) { | ||
return allCells.find(function (cell) { | ||
return cell.columnId === columnId; | ||
}); | ||
}).filter(Boolean).map(function (d) { | ||
return _rollupPluginBabelHelpers["extends"]({}, d, { | ||
position: 'left' | ||
}); | ||
}); | ||
return cells; | ||
}, { | ||
key: 'row.getRightVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb3; | ||
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows; | ||
} | ||
}) | ||
}; | ||
}, | ||
createCell: function createCell(cell, instance) { | ||
return { | ||
getCenterVisibleCells: utils.memo(function () { | ||
return [cell.row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right]; | ||
}, function (allCells, left, right) { | ||
var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []); | ||
return allCells.filter(function (d) { | ||
return !leftAndRight.includes(d.columnId); | ||
}); | ||
}, { | ||
key: 'row.getCenterVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb4; | ||
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugRows; | ||
} | ||
}), | ||
getLeftVisibleCells: utils.memo(function () { | ||
return [cell.row._getAllVisibleCells(), instance.getState().columnPinning.left,,]; | ||
}, function (allCells, left) { | ||
var cells = (left != null ? left : []).map(function (columnId) { | ||
return allCells.find(function (cell) { | ||
return cell.columnId === columnId; | ||
}); | ||
}).filter(Boolean).map(function (d) { | ||
return _rollupPluginBabelHelpers["extends"]({}, d, { | ||
position: 'left' | ||
}); | ||
}); | ||
return cells; | ||
}, { | ||
key: 'row.getLeftVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb5; | ||
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugRows; | ||
} | ||
}), | ||
getRightVisibleCells: utils.memo(function () { | ||
return [cell.row._getAllVisibleCells(), instance.getState().columnPinning.right]; | ||
}, function (allCells, right) { | ||
var cells = (right != null ? right : []).map(function (columnId) { | ||
return allCells.find(function (cell) { | ||
return cell.columnId === columnId; | ||
}); | ||
}).filter(Boolean).map(function (d) { | ||
return _rollupPluginBabelHelpers["extends"]({}, d, { | ||
position: 'left' | ||
}); | ||
}); | ||
return cells; | ||
}, { | ||
key: 'row.getRightVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb6; | ||
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugRows; | ||
} | ||
}) | ||
}; | ||
}, | ||
createInstance: function createInstance(instance) { | ||
return { | ||
setColumnPinning: function setColumnPinning(updater) { | ||
@@ -150,3 +273,50 @@ return instance.options.onColumnPinningChange == null ? void 0 : instance.options.onColumnPinningChange(updater); | ||
return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length)); | ||
} | ||
}, | ||
getLeftLeafColumns: utils.memo(function () { | ||
return [instance.getAllLeafColumns(), instance.getState().columnPinning.left]; | ||
}, function (allColumns, left) { | ||
return (left != null ? left : []).map(function (columnId) { | ||
return allColumns.find(function (column) { | ||
return column.id === columnId; | ||
}); | ||
}).filter(Boolean); | ||
}, { | ||
key: 'getLeftLeafColumns', | ||
debug: function debug() { | ||
var _instance$options$deb7; | ||
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns; | ||
} | ||
}), | ||
getRightLeafColumns: utils.memo(function () { | ||
return [instance.getAllLeafColumns(), instance.getState().columnPinning.right]; | ||
}, function (allColumns, right) { | ||
return (right != null ? right : []).map(function (columnId) { | ||
return allColumns.find(function (column) { | ||
return column.id === columnId; | ||
}); | ||
}).filter(Boolean); | ||
}, { | ||
key: 'getRightLeafColumns', | ||
debug: function debug() { | ||
var _instance$options$deb8; | ||
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugColumns; | ||
} | ||
}), | ||
getCenterLeafColumns: utils.memo(function () { | ||
return [instance.getAllLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right]; | ||
}, function (allColumns, left, right) { | ||
var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []); | ||
return allColumns.filter(function (d) { | ||
return !leftAndRight.includes(d.id); | ||
}); | ||
}, { | ||
key: 'getCenterLeafColumns', | ||
debug: function debug() { | ||
var _instance$options$deb9; | ||
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugColumns; | ||
} | ||
}) | ||
}; | ||
@@ -153,0 +323,0 @@ } |
@@ -37,3 +37,3 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createInstance: function createInstance(instance) { | ||
var registered = false; // const pageRows = instance.getPageRows() | ||
@@ -40,0 +40,0 @@ |
@@ -66,3 +66,3 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createInstance: function createInstance(instance) { | ||
var registered = false; | ||
@@ -69,0 +69,0 @@ return { |
@@ -59,40 +59,74 @@ /** | ||
}, | ||
getInstance: function getInstance(instance) { | ||
createRow: function createRow(row, instance) { | ||
return { | ||
getVisibleFlatColumns: utils.memo(function () { | ||
return [instance.getAllFlatColumns(), instance.getAllFlatColumns().filter(function (d) { | ||
return d.getIsVisible == null ? void 0 : d.getIsVisible(); | ||
_getAllVisibleCells: utils.memo(function () { | ||
return [row.getAllCells().filter(function (cell) { | ||
return cell.column.getIsVisible(); | ||
}).map(function (d) { | ||
return d.id; | ||
}).join('_')]; | ||
}, function (allFlatColumns) { | ||
return allFlatColumns.filter(function (d) { | ||
return d.getIsVisible == null ? void 0 : d.getIsVisible(); | ||
}, function (_) { | ||
return row.getAllCells().filter(function (cell) { | ||
return cell.column.getIsVisible(); | ||
}); | ||
}, { | ||
key: 'getVisibleFlatColumns', | ||
key: 'row._getAllVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb; | ||
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns; | ||
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows; | ||
} | ||
}), | ||
getVisibleLeafColumns: utils.memo(function () { | ||
return [instance.getAllLeafColumns(), instance.getAllLeafColumns().filter(function (d) { | ||
return d.getIsVisible == null ? void 0 : d.getIsVisible(); | ||
getVisibleCells: utils.memo(function () { | ||
return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()]; | ||
}, function (left, center, right) { | ||
return [].concat(left, center, right); | ||
}, { | ||
key: 'row.getVisibleCells', | ||
debug: function debug() { | ||
var _instance$options$deb2; | ||
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows; | ||
} | ||
}) | ||
}; | ||
}, | ||
createInstance: function createInstance(instance) { | ||
var makeVisibleColumnsMethod = function makeVisibleColumnsMethod(key, getColumns) { | ||
return utils.memo(function () { | ||
return [getColumns(), getColumns().filter(function (d) { | ||
return d.getIsVisible(); | ||
}).map(function (d) { | ||
return d.id; | ||
}).join('_')]; | ||
}, function (allFlatColumns) { | ||
return allFlatColumns.filter(function (d) { | ||
}, function (columns) { | ||
return columns.filter(function (d) { | ||
return d.getIsVisible == null ? void 0 : d.getIsVisible(); | ||
}); | ||
}, { | ||
key: 'getVisibleLeafColumns', | ||
key: key, | ||
debug: function debug() { | ||
var _instance$options$deb2; | ||
var _instance$options$deb3; | ||
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns; | ||
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns; | ||
} | ||
}); | ||
}; | ||
return { | ||
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', function () { | ||
return instance.getAllFlatColumns(); | ||
}), | ||
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', function () { | ||
return instance.getAllLeafColumns(); | ||
}), | ||
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', function () { | ||
return instance.getLeftLeafColumns(); | ||
}), | ||
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', function () { | ||
return instance.getRightLeafColumns(); | ||
}), | ||
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', function () { | ||
return instance.getCenterLeafColumns(); | ||
}), | ||
setColumnVisibility: function setColumnVisibility(updater) { | ||
@@ -99,0 +133,0 @@ return instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater); |
@@ -10,3 +10,3 @@ { | ||
{ | ||
"uid": "413f-58", | ||
"uid": "cd4a-64", | ||
"name": "\u0000rollupPluginBabelHelpers.js" | ||
@@ -18,3 +18,3 @@ }, | ||
{ | ||
"uid": "413f-60", | ||
"uid": "cd4a-66", | ||
"name": "utils.ts" | ||
@@ -26,43 +26,55 @@ }, | ||
{ | ||
"uid": "413f-62", | ||
"uid": "cd4a-68", | ||
"name": "Columns.ts" | ||
}, | ||
{ | ||
"uid": "cd4a-70", | ||
"name": "Rows.ts" | ||
}, | ||
{ | ||
"uid": "cd4a-72", | ||
"name": "Cells.ts" | ||
}, | ||
{ | ||
"uid": "cd4a-74", | ||
"name": "ColumnSizing.ts" | ||
}, | ||
{ | ||
"uid": "413f-64", | ||
"uid": "cd4a-76", | ||
"name": "Expanding.ts" | ||
}, | ||
{ | ||
"uid": "413f-68", | ||
"uid": "cd4a-80", | ||
"name": "Filters.ts" | ||
}, | ||
{ | ||
"uid": "413f-72", | ||
"uid": "cd4a-84", | ||
"name": "Grouping.ts" | ||
}, | ||
{ | ||
"uid": "413f-74", | ||
"uid": "cd4a-86", | ||
"name": "Ordering.ts" | ||
}, | ||
{ | ||
"uid": "413f-76", | ||
"uid": "cd4a-88", | ||
"name": "Pagination.ts" | ||
}, | ||
{ | ||
"uid": "413f-78", | ||
"uid": "cd4a-90", | ||
"name": "Pinning.ts" | ||
}, | ||
{ | ||
"uid": "413f-80", | ||
"uid": "cd4a-92", | ||
"name": "RowSelection.ts" | ||
}, | ||
{ | ||
"uid": "413f-84", | ||
"uid": "cd4a-96", | ||
"name": "Sorting.ts" | ||
}, | ||
{ | ||
"uid": "413f-86", | ||
"uid": "cd4a-98", | ||
"name": "Visibility.ts" | ||
}, | ||
{ | ||
"uid": "413f-88", | ||
"uid": "cd4a-100", | ||
"name": "Headers.ts" | ||
@@ -73,19 +85,19 @@ } | ||
{ | ||
"uid": "413f-66", | ||
"uid": "cd4a-78", | ||
"name": "filterFns.ts" | ||
}, | ||
{ | ||
"uid": "413f-70", | ||
"uid": "cd4a-82", | ||
"name": "aggregationFns.ts" | ||
}, | ||
{ | ||
"uid": "413f-82", | ||
"uid": "cd4a-94", | ||
"name": "sortingFns.ts" | ||
}, | ||
{ | ||
"uid": "413f-90", | ||
"uid": "cd4a-102", | ||
"name": "core.ts" | ||
}, | ||
{ | ||
"uid": "413f-92", | ||
"uid": "cd4a-104", | ||
"name": "createTable.ts" | ||
@@ -97,35 +109,35 @@ }, | ||
{ | ||
"uid": "413f-94", | ||
"uid": "cd4a-106", | ||
"name": "getCoreRowModelSync.ts" | ||
}, | ||
{ | ||
"uid": "413f-96", | ||
"uid": "cd4a-108", | ||
"name": "getCoreRowModelAsync.ts" | ||
}, | ||
{ | ||
"uid": "413f-98", | ||
"uid": "cd4a-110", | ||
"name": "filterRowsUtils.ts" | ||
}, | ||
{ | ||
"uid": "413f-100", | ||
"uid": "cd4a-112", | ||
"name": "getColumnFilteredRowModelSync.ts" | ||
}, | ||
{ | ||
"uid": "413f-102", | ||
"uid": "cd4a-114", | ||
"name": "getGlobalFilteredRowModelSync.ts" | ||
}, | ||
{ | ||
"uid": "413f-104", | ||
"uid": "cd4a-116", | ||
"name": "getSortedRowModelSync.ts" | ||
}, | ||
{ | ||
"uid": "413f-106", | ||
"uid": "cd4a-118", | ||
"name": "getGroupedRowModel.ts" | ||
}, | ||
{ | ||
"uid": "413f-108", | ||
"uid": "cd4a-120", | ||
"name": "getExpandedRowModel.ts" | ||
}, | ||
{ | ||
"uid": "413f-110", | ||
"uid": "cd4a-122", | ||
"name": "getPaginationRowModel.ts" | ||
@@ -136,3 +148,3 @@ } | ||
{ | ||
"uid": "413f-112", | ||
"uid": "cd4a-124", | ||
"name": "index.ts" | ||
@@ -148,176 +160,194 @@ } | ||
"nodeParts": { | ||
"413f-58": { | ||
"cd4a-64": { | ||
"renderedLength": 2695, | ||
"gzipLength": 1065, | ||
"brotliLength": 0, | ||
"mainUid": "413f-57" | ||
"mainUid": "cd4a-63" | ||
}, | ||
"413f-60": { | ||
"cd4a-66": { | ||
"renderedLength": 7940, | ||
"gzipLength": 2088, | ||
"brotliLength": 0, | ||
"mainUid": "413f-59" | ||
"mainUid": "cd4a-65" | ||
}, | ||
"413f-62": { | ||
"renderedLength": 11541, | ||
"gzipLength": 2257, | ||
"cd4a-68": { | ||
"renderedLength": 7169, | ||
"gzipLength": 1386, | ||
"brotliLength": 0, | ||
"mainUid": "413f-61" | ||
"mainUid": "cd4a-67" | ||
}, | ||
"413f-64": { | ||
"renderedLength": 7548, | ||
"gzipLength": 1589, | ||
"cd4a-70": { | ||
"renderedLength": 2426, | ||
"gzipLength": 757, | ||
"brotliLength": 0, | ||
"mainUid": "413f-63" | ||
"mainUid": "cd4a-69" | ||
}, | ||
"413f-66": { | ||
"cd4a-72": { | ||
"renderedLength": 2873, | ||
"gzipLength": 729, | ||
"brotliLength": 0, | ||
"mainUid": "cd4a-71" | ||
}, | ||
"cd4a-74": { | ||
"renderedLength": 14092, | ||
"gzipLength": 2621, | ||
"brotliLength": 0, | ||
"mainUid": "cd4a-73" | ||
}, | ||
"cd4a-76": { | ||
"renderedLength": 7554, | ||
"gzipLength": 1588, | ||
"brotliLength": 0, | ||
"mainUid": "cd4a-75" | ||
}, | ||
"cd4a-78": { | ||
"renderedLength": 4435, | ||
"gzipLength": 783, | ||
"brotliLength": 0, | ||
"mainUid": "413f-65" | ||
"mainUid": "cd4a-77" | ||
}, | ||
"413f-68": { | ||
"renderedLength": 13865, | ||
"gzipLength": 2490, | ||
"cd4a-80": { | ||
"renderedLength": 13871, | ||
"gzipLength": 2489, | ||
"brotliLength": 0, | ||
"mainUid": "413f-67" | ||
"mainUid": "cd4a-79" | ||
}, | ||
"413f-70": { | ||
"cd4a-82": { | ||
"renderedLength": 2672, | ||
"gzipLength": 771, | ||
"brotliLength": 0, | ||
"mainUid": "413f-69" | ||
"mainUid": "cd4a-81" | ||
}, | ||
"413f-72": { | ||
"renderedLength": 7982, | ||
"gzipLength": 1693, | ||
"cd4a-84": { | ||
"renderedLength": 7988, | ||
"gzipLength": 1689, | ||
"brotliLength": 0, | ||
"mainUid": "413f-71" | ||
"mainUid": "cd4a-83" | ||
}, | ||
"413f-74": { | ||
"renderedLength": 2580, | ||
"gzipLength": 791, | ||
"cd4a-86": { | ||
"renderedLength": 2586, | ||
"gzipLength": 794, | ||
"brotliLength": 0, | ||
"mainUid": "413f-73" | ||
"mainUid": "cd4a-85" | ||
}, | ||
"413f-76": { | ||
"renderedLength": 5911, | ||
"gzipLength": 1220, | ||
"cd4a-88": { | ||
"renderedLength": 5917, | ||
"gzipLength": 1224, | ||
"brotliLength": 0, | ||
"mainUid": "413f-75" | ||
"mainUid": "cd4a-87" | ||
}, | ||
"413f-78": { | ||
"renderedLength": 5780, | ||
"gzipLength": 1073, | ||
"cd4a-90": { | ||
"renderedLength": 12828, | ||
"gzipLength": 1658, | ||
"brotliLength": 0, | ||
"mainUid": "413f-77" | ||
"mainUid": "cd4a-89" | ||
}, | ||
"413f-80": { | ||
"renderedLength": 18123, | ||
"gzipLength": 3035, | ||
"cd4a-92": { | ||
"renderedLength": 18129, | ||
"gzipLength": 3040, | ||
"brotliLength": 0, | ||
"mainUid": "413f-79" | ||
"mainUid": "cd4a-91" | ||
}, | ||
"413f-82": { | ||
"cd4a-94": { | ||
"renderedLength": 2753, | ||
"gzipLength": 846, | ||
"brotliLength": 0, | ||
"mainUid": "413f-81" | ||
"mainUid": "cd4a-93" | ||
}, | ||
"413f-84": { | ||
"renderedLength": 11775, | ||
"gzipLength": 2476, | ||
"cd4a-96": { | ||
"renderedLength": 11781, | ||
"gzipLength": 2475, | ||
"brotliLength": 0, | ||
"mainUid": "413f-83" | ||
"mainUid": "cd4a-95" | ||
}, | ||
"413f-86": { | ||
"renderedLength": 6302, | ||
"gzipLength": 1207, | ||
"cd4a-98": { | ||
"renderedLength": 7610, | ||
"gzipLength": 1432, | ||
"brotliLength": 0, | ||
"mainUid": "413f-85" | ||
"mainUid": "cd4a-97" | ||
}, | ||
"413f-88": { | ||
"renderedLength": 23655, | ||
"gzipLength": 3372, | ||
"cd4a-100": { | ||
"renderedLength": 20680, | ||
"gzipLength": 3127, | ||
"brotliLength": 0, | ||
"mainUid": "413f-87" | ||
"mainUid": "cd4a-99" | ||
}, | ||
"413f-90": { | ||
"renderedLength": 16752, | ||
"gzipLength": 3192, | ||
"cd4a-102": { | ||
"renderedLength": 3724, | ||
"gzipLength": 981, | ||
"brotliLength": 0, | ||
"mainUid": "413f-89" | ||
"mainUid": "cd4a-101" | ||
}, | ||
"413f-92": { | ||
"cd4a-104": { | ||
"renderedLength": 1895, | ||
"gzipLength": 565, | ||
"brotliLength": 0, | ||
"mainUid": "413f-91" | ||
"mainUid": "cd4a-103" | ||
}, | ||
"413f-94": { | ||
"cd4a-106": { | ||
"renderedLength": 2462, | ||
"gzipLength": 797, | ||
"brotliLength": 0, | ||
"mainUid": "413f-93" | ||
"mainUid": "cd4a-105" | ||
}, | ||
"413f-96": { | ||
"cd4a-108": { | ||
"renderedLength": 3559, | ||
"gzipLength": 1014, | ||
"brotliLength": 0, | ||
"mainUid": "413f-95" | ||
"mainUid": "cd4a-107" | ||
}, | ||
"413f-98": { | ||
"cd4a-110": { | ||
"renderedLength": 2457, | ||
"gzipLength": 568, | ||
"brotliLength": 0, | ||
"mainUid": "413f-97" | ||
"mainUid": "cd4a-109" | ||
}, | ||
"413f-100": { | ||
"cd4a-112": { | ||
"renderedLength": 3130, | ||
"gzipLength": 892, | ||
"brotliLength": 0, | ||
"mainUid": "413f-99" | ||
"mainUid": "cd4a-111" | ||
}, | ||
"413f-102": { | ||
"cd4a-114": { | ||
"renderedLength": 2469, | ||
"gzipLength": 693, | ||
"brotliLength": 0, | ||
"mainUid": "413f-101" | ||
"mainUid": "cd4a-113" | ||
}, | ||
"413f-104": { | ||
"cd4a-116": { | ||
"renderedLength": 3437, | ||
"gzipLength": 1020, | ||
"brotliLength": 0, | ||
"mainUid": "413f-103" | ||
"mainUid": "cd4a-115" | ||
}, | ||
"413f-106": { | ||
"cd4a-118": { | ||
"renderedLength": 5782, | ||
"gzipLength": 1525, | ||
"brotliLength": 0, | ||
"mainUid": "413f-105" | ||
"mainUid": "cd4a-117" | ||
}, | ||
"413f-108": { | ||
"cd4a-120": { | ||
"renderedLength": 1385, | ||
"gzipLength": 494, | ||
"brotliLength": 0, | ||
"mainUid": "413f-107" | ||
"mainUid": "cd4a-119" | ||
}, | ||
"413f-110": { | ||
"cd4a-122": { | ||
"renderedLength": 1254, | ||
"gzipLength": 407, | ||
"brotliLength": 0, | ||
"mainUid": "413f-109" | ||
"mainUid": "cd4a-121" | ||
}, | ||
"413f-112": { | ||
"cd4a-124": { | ||
"renderedLength": 0, | ||
"gzipLength": 0, | ||
"brotliLength": 0, | ||
"mainUid": "413f-111" | ||
"mainUid": "cd4a-123" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"413f-57": { | ||
"cd4a-63": { | ||
"id": "\u0000rollupPluginBabelHelpers.js", | ||
"moduleParts": { | ||
"index.production.js": "413f-58" | ||
"index.production.js": "cd4a-64" | ||
}, | ||
@@ -327,44 +357,50 @@ "imported": [], | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
}, | ||
{ | ||
"uid": "413f-91" | ||
"uid": "cd4a-103" | ||
}, | ||
{ | ||
"uid": "413f-61" | ||
"uid": "cd4a-73" | ||
}, | ||
{ | ||
"uid": "413f-63" | ||
"uid": "cd4a-75" | ||
}, | ||
{ | ||
"uid": "413f-75" | ||
"uid": "cd4a-87" | ||
}, | ||
{ | ||
"uid": "413f-79" | ||
"uid": "cd4a-89" | ||
}, | ||
{ | ||
"uid": "413f-83" | ||
"uid": "cd4a-91" | ||
}, | ||
{ | ||
"uid": "413f-85" | ||
"uid": "cd4a-95" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-97" | ||
}, | ||
{ | ||
"uid": "413f-95" | ||
"uid": "cd4a-65" | ||
}, | ||
{ | ||
"uid": "413f-69" | ||
"uid": "cd4a-107" | ||
}, | ||
{ | ||
"uid": "cd4a-67" | ||
}, | ||
{ | ||
"uid": "cd4a-81" | ||
} | ||
] | ||
}, | ||
"413f-59": { | ||
"cd4a-65": { | ||
"id": "/packages/table-core/src/utils.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-60" | ||
"index.production.js": "cd4a-66" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
} | ||
@@ -374,77 +410,86 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
}, | ||
{ | ||
"uid": "413f-61" | ||
"uid": "cd4a-73" | ||
}, | ||
{ | ||
"uid": "413f-63" | ||
"uid": "cd4a-75" | ||
}, | ||
{ | ||
"uid": "413f-67" | ||
"uid": "cd4a-79" | ||
}, | ||
{ | ||
"uid": "413f-71" | ||
"uid": "cd4a-83" | ||
}, | ||
{ | ||
"uid": "413f-87" | ||
"uid": "cd4a-99" | ||
}, | ||
{ | ||
"uid": "413f-73" | ||
"uid": "cd4a-85" | ||
}, | ||
{ | ||
"uid": "413f-75" | ||
"uid": "cd4a-87" | ||
}, | ||
{ | ||
"uid": "413f-77" | ||
"uid": "cd4a-89" | ||
}, | ||
{ | ||
"uid": "413f-79" | ||
"uid": "cd4a-91" | ||
}, | ||
{ | ||
"uid": "413f-83" | ||
"uid": "cd4a-95" | ||
}, | ||
{ | ||
"uid": "413f-85" | ||
"uid": "cd4a-97" | ||
}, | ||
{ | ||
"uid": "413f-93" | ||
"uid": "cd4a-105" | ||
}, | ||
{ | ||
"uid": "413f-95" | ||
"uid": "cd4a-107" | ||
}, | ||
{ | ||
"uid": "413f-99" | ||
"uid": "cd4a-111" | ||
}, | ||
{ | ||
"uid": "413f-101" | ||
"uid": "cd4a-113" | ||
}, | ||
{ | ||
"uid": "413f-103" | ||
"uid": "cd4a-115" | ||
}, | ||
{ | ||
"uid": "413f-105" | ||
"uid": "cd4a-117" | ||
}, | ||
{ | ||
"uid": "413f-107" | ||
"uid": "cd4a-119" | ||
}, | ||
{ | ||
"uid": "413f-109" | ||
"uid": "cd4a-121" | ||
}, | ||
{ | ||
"uid": "cd4a-67" | ||
}, | ||
{ | ||
"uid": "cd4a-69" | ||
}, | ||
{ | ||
"uid": "cd4a-71" | ||
} | ||
] | ||
}, | ||
"413f-61": { | ||
"id": "/packages/table-core/src/features/ColumnSizing.ts", | ||
"cd4a-67": { | ||
"id": "/packages/table-core/src/features/Columns.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-62" | ||
"index.production.js": "cd4a-68" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -454,23 +499,71 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"cd4a-69": { | ||
"id": "/packages/table-core/src/features/Rows.ts", | ||
"moduleParts": { | ||
"index.production.js": "cd4a-70" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "cd4a-65" | ||
} | ||
], | ||
"importedBy": [ | ||
{ | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"cd4a-71": { | ||
"id": "/packages/table-core/src/features/Cells.ts", | ||
"moduleParts": { | ||
"index.production.js": "cd4a-72" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "cd4a-65" | ||
} | ||
], | ||
"importedBy": [ | ||
{ | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"cd4a-73": { | ||
"id": "/packages/table-core/src/features/ColumnSizing.ts", | ||
"moduleParts": { | ||
"index.production.js": "cd4a-74" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-65" | ||
} | ||
], | ||
"importedBy": [ | ||
{ | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-87" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-63": { | ||
"cd4a-75": { | ||
"id": "/packages/table-core/src/features/Expanding.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-64" | ||
"index.production.js": "cd4a-76" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -480,13 +573,13 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-65": { | ||
"cd4a-77": { | ||
"id": "/packages/table-core/src/filterFns.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-66" | ||
"index.production.js": "cd4a-78" | ||
}, | ||
@@ -496,17 +589,17 @@ "imported": [], | ||
{ | ||
"uid": "413f-67" | ||
"uid": "cd4a-79" | ||
} | ||
] | ||
}, | ||
"413f-67": { | ||
"cd4a-79": { | ||
"id": "/packages/table-core/src/features/Filters.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-68" | ||
"index.production.js": "cd4a-80" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-65" | ||
"uid": "cd4a-77" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -516,17 +609,17 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-69": { | ||
"cd4a-81": { | ||
"id": "/packages/table-core/src/aggregationFns.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-70" | ||
"index.production.js": "cd4a-82" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
} | ||
@@ -536,20 +629,20 @@ ], | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
}, | ||
{ | ||
"uid": "413f-71" | ||
"uid": "cd4a-83" | ||
} | ||
] | ||
}, | ||
"413f-71": { | ||
"cd4a-83": { | ||
"id": "/packages/table-core/src/features/Grouping.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-72" | ||
"index.production.js": "cd4a-84" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-69" | ||
"uid": "cd4a-81" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -559,23 +652,23 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
}, | ||
{ | ||
"uid": "413f-73" | ||
"uid": "cd4a-85" | ||
} | ||
] | ||
}, | ||
"413f-73": { | ||
"cd4a-85": { | ||
"id": "/packages/table-core/src/features/Ordering.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-74" | ||
"index.production.js": "cd4a-86" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
}, | ||
{ | ||
"uid": "413f-71" | ||
"uid": "cd4a-83" | ||
} | ||
@@ -585,20 +678,20 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-75": { | ||
"cd4a-87": { | ||
"id": "/packages/table-core/src/features/Pagination.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-76" | ||
"index.production.js": "cd4a-88" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -608,17 +701,20 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-77": { | ||
"cd4a-89": { | ||
"id": "/packages/table-core/src/features/Pinning.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-78" | ||
"index.production.js": "cd4a-90" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "cd4a-65" | ||
} | ||
@@ -628,20 +724,20 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-79": { | ||
"cd4a-91": { | ||
"id": "/packages/table-core/src/features/RowSelection.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-80" | ||
"index.production.js": "cd4a-92" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -651,13 +747,13 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-81": { | ||
"cd4a-93": { | ||
"id": "/packages/table-core/src/sortingFns.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-82" | ||
"index.production.js": "cd4a-94" | ||
}, | ||
@@ -667,20 +763,20 @@ "imported": [], | ||
{ | ||
"uid": "413f-83" | ||
"uid": "cd4a-95" | ||
} | ||
] | ||
}, | ||
"413f-83": { | ||
"cd4a-95": { | ||
"id": "/packages/table-core/src/features/Sorting.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-84" | ||
"index.production.js": "cd4a-96" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-81" | ||
"uid": "cd4a-93" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -690,20 +786,20 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-85": { | ||
"cd4a-97": { | ||
"id": "/packages/table-core/src/features/Visibility.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-86" | ||
"index.production.js": "cd4a-98" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -713,20 +809,17 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-87": { | ||
"cd4a-99": { | ||
"id": "/packages/table-core/src/features/Headers.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-88" | ||
"index.production.js": "cd4a-100" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
}, | ||
{ | ||
"uid": "413f-61" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -736,56 +829,65 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
} | ||
] | ||
}, | ||
"413f-89": { | ||
"cd4a-101": { | ||
"id": "/packages/table-core/src/core.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-90" | ||
"index.production.js": "cd4a-102" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
}, | ||
{ | ||
"uid": "413f-61" | ||
"uid": "cd4a-67" | ||
}, | ||
{ | ||
"uid": "413f-63" | ||
"uid": "cd4a-69" | ||
}, | ||
{ | ||
"uid": "413f-67" | ||
"uid": "cd4a-71" | ||
}, | ||
{ | ||
"uid": "413f-71" | ||
"uid": "cd4a-73" | ||
}, | ||
{ | ||
"uid": "413f-73" | ||
"uid": "cd4a-75" | ||
}, | ||
{ | ||
"uid": "413f-75" | ||
"uid": "cd4a-79" | ||
}, | ||
{ | ||
"uid": "413f-77" | ||
"uid": "cd4a-83" | ||
}, | ||
{ | ||
"uid": "413f-79" | ||
"uid": "cd4a-85" | ||
}, | ||
{ | ||
"uid": "413f-83" | ||
"uid": "cd4a-87" | ||
}, | ||
{ | ||
"uid": "413f-85" | ||
"uid": "cd4a-89" | ||
}, | ||
{ | ||
"uid": "413f-87" | ||
"uid": "cd4a-91" | ||
}, | ||
{ | ||
"uid": "413f-69" | ||
"uid": "cd4a-95" | ||
}, | ||
{ | ||
"uid": "cd4a-97" | ||
}, | ||
{ | ||
"uid": "cd4a-99" | ||
}, | ||
{ | ||
"uid": "cd4a-81" | ||
} | ||
@@ -795,14 +897,14 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-91": { | ||
"cd4a-103": { | ||
"id": "/packages/table-core/src/createTable.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-92" | ||
"index.production.js": "cd4a-104" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
} | ||
@@ -812,14 +914,14 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-93": { | ||
"cd4a-105": { | ||
"id": "/packages/table-core/src/utils/getCoreRowModelSync.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-94" | ||
"index.production.js": "cd4a-106" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -829,17 +931,17 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-95": { | ||
"cd4a-107": { | ||
"id": "/packages/table-core/src/utils/getCoreRowModelAsync.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-96" | ||
"index.production.js": "cd4a-108" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-57" | ||
"uid": "cd4a-63" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -849,10 +951,10 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-97": { | ||
"cd4a-109": { | ||
"id": "/packages/table-core/src/utils/filterRowsUtils.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-98" | ||
"index.production.js": "cd4a-110" | ||
}, | ||
@@ -862,20 +964,20 @@ "imported": [], | ||
{ | ||
"uid": "413f-99" | ||
"uid": "cd4a-111" | ||
}, | ||
{ | ||
"uid": "413f-101" | ||
"uid": "cd4a-113" | ||
} | ||
] | ||
}, | ||
"413f-99": { | ||
"cd4a-111": { | ||
"id": "/packages/table-core/src/utils/getColumnFilteredRowModelSync.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-100" | ||
"index.production.js": "cd4a-112" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
}, | ||
{ | ||
"uid": "413f-97" | ||
"uid": "cd4a-109" | ||
} | ||
@@ -885,17 +987,17 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-101": { | ||
"cd4a-113": { | ||
"id": "/packages/table-core/src/utils/getGlobalFilteredRowModelSync.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-102" | ||
"index.production.js": "cd4a-114" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
}, | ||
{ | ||
"uid": "413f-97" | ||
"uid": "cd4a-109" | ||
} | ||
@@ -905,14 +1007,14 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-103": { | ||
"cd4a-115": { | ||
"id": "/packages/table-core/src/utils/getSortedRowModelSync.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-104" | ||
"index.production.js": "cd4a-116" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -922,14 +1024,14 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-105": { | ||
"cd4a-117": { | ||
"id": "/packages/table-core/src/utils/getGroupedRowModel.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-106" | ||
"index.production.js": "cd4a-118" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -939,14 +1041,14 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-107": { | ||
"cd4a-119": { | ||
"id": "/packages/table-core/src/utils/getExpandedRowModel.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-108" | ||
"index.production.js": "cd4a-120" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
} | ||
@@ -956,20 +1058,20 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
}, | ||
{ | ||
"uid": "413f-109" | ||
"uid": "cd4a-121" | ||
} | ||
] | ||
}, | ||
"413f-109": { | ||
"cd4a-121": { | ||
"id": "/packages/table-core/src/utils/getPaginationRowModel.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-110" | ||
"index.production.js": "cd4a-122" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
}, | ||
{ | ||
"uid": "413f-107" | ||
"uid": "cd4a-119" | ||
} | ||
@@ -979,80 +1081,80 @@ ], | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
] | ||
}, | ||
"413f-111": { | ||
"cd4a-123": { | ||
"id": "/packages/table-core/src/index.ts", | ||
"moduleParts": { | ||
"index.production.js": "413f-112" | ||
"index.production.js": "cd4a-124" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "413f-89" | ||
"uid": "cd4a-101" | ||
}, | ||
{ | ||
"uid": "413f-113" | ||
"uid": "cd4a-125" | ||
}, | ||
{ | ||
"uid": "413f-91" | ||
"uid": "cd4a-103" | ||
}, | ||
{ | ||
"uid": "413f-61" | ||
"uid": "cd4a-73" | ||
}, | ||
{ | ||
"uid": "413f-63" | ||
"uid": "cd4a-75" | ||
}, | ||
{ | ||
"uid": "413f-67" | ||
"uid": "cd4a-79" | ||
}, | ||
{ | ||
"uid": "413f-71" | ||
"uid": "cd4a-83" | ||
}, | ||
{ | ||
"uid": "413f-87" | ||
"uid": "cd4a-99" | ||
}, | ||
{ | ||
"uid": "413f-73" | ||
"uid": "cd4a-85" | ||
}, | ||
{ | ||
"uid": "413f-75" | ||
"uid": "cd4a-87" | ||
}, | ||
{ | ||
"uid": "413f-77" | ||
"uid": "cd4a-89" | ||
}, | ||
{ | ||
"uid": "413f-79" | ||
"uid": "cd4a-91" | ||
}, | ||
{ | ||
"uid": "413f-83" | ||
"uid": "cd4a-95" | ||
}, | ||
{ | ||
"uid": "413f-85" | ||
"uid": "cd4a-97" | ||
}, | ||
{ | ||
"uid": "413f-59" | ||
"uid": "cd4a-65" | ||
}, | ||
{ | ||
"uid": "413f-93" | ||
"uid": "cd4a-105" | ||
}, | ||
{ | ||
"uid": "413f-95" | ||
"uid": "cd4a-107" | ||
}, | ||
{ | ||
"uid": "413f-99" | ||
"uid": "cd4a-111" | ||
}, | ||
{ | ||
"uid": "413f-101" | ||
"uid": "cd4a-113" | ||
}, | ||
{ | ||
"uid": "413f-103" | ||
"uid": "cd4a-115" | ||
}, | ||
{ | ||
"uid": "413f-105" | ||
"uid": "cd4a-117" | ||
}, | ||
{ | ||
"uid": "413f-107" | ||
"uid": "cd4a-119" | ||
}, | ||
{ | ||
"uid": "413f-109" | ||
"uid": "cd4a-121" | ||
} | ||
@@ -1063,3 +1165,3 @@ ], | ||
}, | ||
"413f-113": { | ||
"cd4a-125": { | ||
"id": "/packages/table-core/src/types.ts", | ||
@@ -1070,3 +1172,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "413f-111" | ||
"uid": "cd4a-123" | ||
} | ||
@@ -1073,0 +1175,0 @@ ] |
import { RequiredKeys } from './utils'; | ||
import { Updater, PropGetterValue, Options, TableState, ColumnDef, Row, Column, Cell, Header, AccessorFn, TableProps, TableBodyProps, PropGetter, Getter, RowProps, CellProps, TableInstance, RowValues, Renderable, UseRenderer, RowModel, TableFeature, TableGenerics } from './types'; | ||
import { Updater, Options, TableState, TableProps, TableBodyProps, PropGetter, TableInstance, Renderable, UseRenderer, TableFeature, TableGenerics } from './types'; | ||
export declare type CoreTableState = { | ||
@@ -8,7 +8,5 @@ coreProgress: number; | ||
data: TGenerics['Row'][]; | ||
columns: ColumnDef<TGenerics>[]; | ||
state: Partial<TableState>; | ||
onStateChange: (updater: Updater<TableState>) => void; | ||
render: TGenerics['Render']; | ||
getCoreRowModel: (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics>; | ||
debugAll?: boolean; | ||
@@ -19,6 +17,3 @@ debugTable?: boolean; | ||
debugRows?: boolean; | ||
defaultColumn?: Partial<ColumnDef<TGenerics>>; | ||
initialState?: Partial<TableState>; | ||
getSubRows?: (originalRow: TGenerics['Row'], index: number) => TGenerics['Row'][]; | ||
getRowId?: (originalRow: TGenerics['Row'], index: number, parent?: Row<TGenerics>) => string; | ||
autoResetAll?: boolean; | ||
@@ -35,82 +30,10 @@ mergeOptions?: (defaultOptions: TableFeature, options: Partial<Options<TGenerics>>) => Options<TGenerics>; | ||
willUpdate: () => void; | ||
getRowId: (_: TGenerics['Row'], index: number, parent?: Row<TGenerics>) => string; | ||
getState: () => TableState; | ||
setState: (updater: Updater<TableState>) => void; | ||
getDefaultColumn: () => Partial<ColumnDef<TGenerics>>; | ||
getColumnDefs: () => ColumnDef<TGenerics>[]; | ||
createColumn: (columnDef: ColumnDef<TGenerics>, depth: number, parent?: Column<TGenerics>) => Column<TGenerics>; | ||
getAllColumns: () => Column<TGenerics>[]; | ||
getAllFlatColumns: () => Column<TGenerics>[]; | ||
getAllFlatColumnsById: () => Record<string, Column<TGenerics>>; | ||
getAllLeafColumns: () => Column<TGenerics>[]; | ||
getColumn: (columnId: string) => Column<TGenerics>; | ||
getTotalWidth: () => number; | ||
createCell: (row: Row<TGenerics>, column: Column<TGenerics>, value: any) => Cell<TGenerics>; | ||
createRow: (id: string, original: TGenerics['Row'] | undefined, rowIndex: number, depth: number, values: Record<string, any>) => Row<TGenerics>; | ||
getCoreRowModel: () => RowModel<TGenerics>; | ||
_getCoreRowModel?: () => RowModel<TGenerics>; | ||
getRowModel: () => RowModel<TGenerics>; | ||
getRow: (id: string) => Row<TGenerics>; | ||
getCell: (rowId: string, columnId: string) => Cell<TGenerics>; | ||
getTableProps: PropGetter<TableProps>; | ||
getTableBodyProps: PropGetter<TableBodyProps>; | ||
getRowProps: <TGetter extends Getter<RowProps>>(rowId: string, userProps?: TGetter) => undefined | PropGetterValue<RowProps, TGetter>; | ||
getCellProps: <TGetter extends Getter<CellProps>>(rowId: string, columnId: string, userProps?: TGetter) => undefined | PropGetterValue<CellProps, TGetter>; | ||
getTableWidth: () => number; | ||
getLeftTableWidth: () => number; | ||
getCenterTableWidth: () => number; | ||
getRightTableWidth: () => number; | ||
render: <TProps>(template: Renderable<TGenerics, TProps>, props: TProps) => string | null | ReturnType<UseRenderer<TGenerics>>; | ||
getOverallProgress: () => number; | ||
_features: readonly TableFeature[]; | ||
}; | ||
export declare type CoreRow<TGenerics extends TableGenerics> = { | ||
id: string; | ||
index: number; | ||
original?: TGenerics['Row']; | ||
depth: number; | ||
values: RowValues; | ||
subRows: Row<TGenerics>[]; | ||
getLeafRows: () => Row<TGenerics>[]; | ||
getRowProps: PropGetter<RowProps>; | ||
originalSubRows?: TGenerics['Row'][]; | ||
getAllCells: () => Cell<TGenerics>[]; | ||
getAllCellsByColumnId: () => Record<string, Cell<TGenerics>>; | ||
}; | ||
export declare type CoreColumnDef<TGenerics extends TableGenerics> = { | ||
id: string; | ||
accessorKey?: string & keyof TGenerics['Row']; | ||
accessorFn?: AccessorFn<TGenerics['Row']>; | ||
columns?: ColumnDef<TGenerics>[]; | ||
header?: Renderable<TGenerics, { | ||
instance: TableInstance<TGenerics>; | ||
header: Header<TGenerics>; | ||
column: Column<TGenerics>; | ||
}>; | ||
footer?: Renderable<TGenerics, { | ||
instance: TableInstance<TGenerics>; | ||
header: Header<TGenerics>; | ||
column: Column<TGenerics>; | ||
}>; | ||
cell?: Renderable<TGenerics, { | ||
instance: TableInstance<TGenerics>; | ||
row: Row<TGenerics>; | ||
column: Column<TGenerics>; | ||
cell: Cell<TGenerics>; | ||
value: TGenerics['Value']; | ||
}>; | ||
meta?: TGenerics['ColumnMeta']; | ||
}; | ||
export declare type CoreColumnDefType = 'data' | 'display' | 'group'; | ||
export declare type CoreColumn<TGenerics extends TableGenerics> = { | ||
id: string; | ||
depth: number; | ||
accessorFn?: AccessorFn<TGenerics['Row']>; | ||
columnDef: ColumnDef<TGenerics>; | ||
columnDefType: CoreColumnDefType; | ||
getWidth: () => number; | ||
columns: Column<TGenerics>[]; | ||
parent?: Column<TGenerics>; | ||
getFlatColumns: () => Column<TGenerics>[]; | ||
getLeafColumns: () => Column<TGenerics>[]; | ||
}; | ||
export declare function createTableInstance<TGenerics extends TableGenerics>(options: Options<TGenerics>): TableInstance<TGenerics>; |
import { Column, Getter, Header, OnChangeFn, TableGenerics, PropGetterValue, TableInstance, Updater } from '../types'; | ||
import { ColumnPinningPosition } from './Pinning'; | ||
export declare type ColumnSizingTableState = { | ||
columnSizing: ColumnSizing; | ||
columnSizing: ColumnSizingState; | ||
columnSizingInfo: ColumnSizingInfoState; | ||
}; | ||
export declare type ColumnSizing = Record<string, number>; | ||
export declare type ColumnSizingState = Record<string, number>; | ||
export declare type ColumnSizingInfoState = { | ||
@@ -19,3 +20,3 @@ startOffset: null | number; | ||
columnResizeMode?: ColumnResizeMode; | ||
onColumnSizingChange?: OnChangeFn<ColumnSizing>; | ||
onColumnSizingChange?: OnChangeFn<ColumnSizingState>; | ||
onColumnSizingInfoChange?: OnChangeFn<ColumnSizingInfoState>; | ||
@@ -25,3 +26,3 @@ }; | ||
columnResizeMode: ColumnResizeMode; | ||
onColumnSizingChange: OnChangeFn<ColumnSizing>; | ||
onColumnSizingChange: OnChangeFn<ColumnSizingState>; | ||
onColumnSizingInfoChange: OnChangeFn<ColumnSizingInfoState>; | ||
@@ -37,4 +38,5 @@ }; | ||
export declare type ColumnSizingInstance<TGenerics extends TableGenerics> = { | ||
getColumnWidth: (columnId: string) => number; | ||
setColumnSizing: (updater: Updater<ColumnSizing>) => void; | ||
getColumnSize: (columnId: string) => number; | ||
getColumnStart: (columnId: string, position?: ColumnPinningPosition) => number; | ||
setColumnSizing: (updater: Updater<ColumnSizingState>) => void; | ||
setColumnSizingInfo: (updater: Updater<ColumnSizingInfoState>) => void; | ||
@@ -50,2 +52,6 @@ resetColumnSizing: () => void; | ||
getHeaderIsResizing: (headerId: string) => boolean; | ||
getTotalSize: () => number; | ||
getLeftTotalSize: () => number; | ||
getCenterTotalSize: () => number; | ||
getRightTotalSize: () => number; | ||
}; | ||
@@ -55,7 +61,9 @@ export declare type ColumnSizingColumnDef = { | ||
defaultCanResize?: boolean; | ||
width?: number; | ||
minWidth?: number; | ||
maxWidth?: number; | ||
size?: number; | ||
minSize?: number; | ||
maxSize?: number; | ||
}; | ||
export declare type ColumnSizingColumn<TGenerics extends TableGenerics> = { | ||
getSize: () => number; | ||
getStart: (position?: ColumnPinningPosition) => number; | ||
getCanResize: () => boolean; | ||
@@ -72,5 +80,5 @@ getIsResizing: () => boolean; | ||
export declare const defaultColumnSizing: { | ||
width: number; | ||
minWidth: number; | ||
maxWidth: number; | ||
size: number; | ||
minSize: number; | ||
maxSize: number; | ||
}; | ||
@@ -81,6 +89,6 @@ export declare const ColumnSizing: { | ||
getDefaultOptions: <TGenerics extends TableGenerics>(instance: TableInstance<TGenerics>) => ColumnSizingDefaultOptions; | ||
getInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => ColumnSizingInstance<TGenerics_1>; | ||
createColumn: <TGenerics_2 extends TableGenerics>(column: Column<TGenerics_2>, instance: TableInstance<TGenerics_2>) => ColumnSizingColumn<TGenerics_2>; | ||
createHeader: <TGenerics_3 extends TableGenerics>(header: Header<TGenerics_3>, instance: TableInstance<TGenerics_3>) => ColumnSizingHeader<TGenerics_3>; | ||
createColumn: <TGenerics_1 extends TableGenerics>(column: Column<TGenerics_1>, instance: TableInstance<TGenerics_1>) => ColumnSizingColumn<TGenerics_1>; | ||
createHeader: <TGenerics_2 extends TableGenerics>(header: Header<TGenerics_2>, instance: TableInstance<TGenerics_2>) => ColumnSizingHeader<TGenerics_2>; | ||
createInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => ColumnSizingInstance<TGenerics_3>; | ||
}; | ||
export declare function passiveEventSupported(): boolean; |
@@ -50,4 +50,4 @@ import { RowModel } from '..'; | ||
getDefaultOptions: <TGenerics extends TableGenerics>(instance: TableInstance<TGenerics>) => ExpandedOptions<TGenerics>; | ||
getInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => ExpandedInstance<TGenerics_1>; | ||
createInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => ExpandedInstance<TGenerics_1>; | ||
createRow: <TGenerics_2 extends TableGenerics>(row: Row<TGenerics_2>, instance: TableInstance<TGenerics_2>) => ExpandedRow; | ||
}; |
@@ -91,4 +91,4 @@ import { RowModel } from '..'; | ||
createColumn: <TGenerics_2 extends TableGenerics>(column: Column<TGenerics_2>, instance: TableInstance<TGenerics_2>) => FiltersColumn<TGenerics_2>; | ||
getInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => FiltersInstance<TGenerics_3>; | ||
createInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => FiltersInstance<TGenerics_3>; | ||
}; | ||
export declare function shouldAutoRemoveFilter<TGenerics extends TableGenerics>(filterFn?: FilterFn<TGenerics>, value?: any, column?: Column<TGenerics>): boolean; |
@@ -88,3 +88,3 @@ import { RowModel } from '..'; | ||
createColumn: <TGenerics_2 extends TableGenerics>(column: Column<TGenerics_2>, instance: TableInstance<TGenerics_2>) => GroupingColumn<TGenerics_2>; | ||
getInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => GroupingInstance<TGenerics_3>; | ||
createInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => GroupingInstance<TGenerics_3>; | ||
createRow: <TGenerics_4 extends TableGenerics>(row: Row<TGenerics_4>, instance: TableInstance<TGenerics_4>) => GroupingRow; | ||
@@ -91,0 +91,0 @@ createCell: <TGenerics_5 extends TableGenerics>(cell: Cell<TGenerics_5>, column: Column<TGenerics_5>, row: Row<TGenerics_5>, instance: TableInstance<TGenerics_5>) => GroupingCell<TGenerics_5>; |
@@ -1,9 +0,2 @@ | ||
import { Cell, Column, FooterGroupProps, FooterProps, Getter, Header, HeaderGroup, HeaderGroupProps, HeaderProps, TableGenerics, PropGetterValue, TableInstance, Row } from '../types'; | ||
export declare type HeadersRow<TGenerics extends TableGenerics> = { | ||
_getAllVisibleCells: () => Cell<TGenerics>[]; | ||
getVisibleCells: () => Cell<TGenerics>[]; | ||
getLeftVisibleCells: () => Cell<TGenerics>[]; | ||
getCenterVisibleCells: () => Cell<TGenerics>[]; | ||
getRightVisibleCells: () => Cell<TGenerics>[]; | ||
}; | ||
import { Column, FooterGroupProps, FooterProps, Getter, Header, HeaderGroup, HeaderGroupProps, HeaderProps, TableGenerics, PropGetterValue, TableInstance } from '../types'; | ||
export declare type HeadersInstance<TGenerics extends TableGenerics> = { | ||
@@ -14,2 +7,3 @@ createHeader: (column: Column<TGenerics>, options: { | ||
placeholderId?: string; | ||
index: number; | ||
depth: number; | ||
@@ -38,8 +32,6 @@ }) => Header<TGenerics>; | ||
getFooterProps: <TGetter extends Getter<FooterProps>>(headerId: string, userProps?: TGetter) => undefined | PropGetterValue<FooterProps, TGetter>; | ||
getTotalWidth: () => number; | ||
}; | ||
export declare const Headers: { | ||
createRow: <TGenerics extends TableGenerics>(row: Row<TGenerics>, instance: TableInstance<TGenerics>) => HeadersRow<TGenerics>; | ||
getInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => HeadersInstance<TGenerics_1>; | ||
createInstance: <TGenerics extends TableGenerics>(instance: TableInstance<TGenerics>) => HeadersInstance<TGenerics>; | ||
}; | ||
export declare function buildHeaderGroups<TGenerics extends TableGenerics>(allColumns: Column<TGenerics>[], columnsToGroup: Column<TGenerics>[], instance: TableInstance<TGenerics>, headerFamily?: 'center' | 'left' | 'right'): HeaderGroup<TGenerics>[]; |
@@ -20,3 +20,3 @@ import { TableInstance, OnChangeFn, Updater, Column, TableGenerics } from '../types'; | ||
getDefaultOptions: <TGenerics extends TableGenerics>(instance: TableInstance<TGenerics>) => ColumnOrderDefaultOptions; | ||
getInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => ColumnOrderInstance<TGenerics_1>; | ||
createInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => ColumnOrderInstance<TGenerics_1>; | ||
}; |
@@ -41,3 +41,3 @@ import { OnChangeFn, TableGenerics, TableInstance, RowModel, Updater } from '../types'; | ||
getDefaultOptions: <TGenerics extends TableGenerics>(instance: TableInstance<TGenerics>) => PaginationDefaultOptions; | ||
getInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => PaginationInstance<TGenerics_1>; | ||
createInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => PaginationInstance<TGenerics_1>; | ||
}; |
@@ -1,3 +0,3 @@ | ||
import { OnChangeFn, Updater, TableInstance, Column, TableGenerics } from '../types'; | ||
declare type ColumnPinningPosition = false | 'left' | 'right'; | ||
import { OnChangeFn, Updater, TableInstance, Column, TableGenerics, Row, Cell } from '../types'; | ||
export declare type ColumnPinningPosition = false | 'left' | 'right'; | ||
export declare type ColumnPinningState = { | ||
@@ -27,2 +27,12 @@ left?: string[]; | ||
}; | ||
export declare type ColumnPinningRow<TGenerics extends TableGenerics> = { | ||
getLeftVisibleCells: () => Cell<TGenerics>[]; | ||
getCenterVisibleCells: () => Cell<TGenerics>[]; | ||
getRightVisibleCells: () => Cell<TGenerics>[]; | ||
}; | ||
export declare type ColumnPinningCell<TGenerics extends TableGenerics> = { | ||
getLeftVisibleCells: () => Cell<TGenerics>[]; | ||
getCenterVisibleCells: () => Cell<TGenerics>[]; | ||
getRightVisibleCells: () => Cell<TGenerics>[]; | ||
}; | ||
export declare type ColumnPinningInstance<TGenerics extends TableGenerics> = { | ||
@@ -36,2 +46,5 @@ setColumnPinning: (updater: Updater<ColumnPinningState>) => void; | ||
getIsSomeColumnsPinned: () => boolean; | ||
getLeftLeafColumns: () => Column<TGenerics>[]; | ||
getRightLeafColumns: () => Column<TGenerics>[]; | ||
getCenterLeafColumns: () => Column<TGenerics>[]; | ||
}; | ||
@@ -42,4 +55,5 @@ export declare const Pinning: { | ||
createColumn: <TGenerics_1 extends TableGenerics>(column: Column<TGenerics_1>, instance: TableInstance<TGenerics_1>) => ColumnPinningColumn; | ||
getInstance: <TGenerics_2 extends TableGenerics>(instance: TableInstance<TGenerics_2>) => ColumnPinningInstance<TGenerics_2>; | ||
createRow: <TGenerics_2 extends TableGenerics>(row: Row<TGenerics_2>, instance: TableInstance<TGenerics_2>) => ColumnPinningRow<TGenerics_2>; | ||
createCell: <TGenerics_3 extends TableGenerics>(cell: Cell<TGenerics_3>, instance: TableInstance<TGenerics_3>) => ColumnPinningCell<TGenerics_3>; | ||
createInstance: <TGenerics_4 extends TableGenerics>(instance: TableInstance<TGenerics_4>) => ColumnPinningInstance<TGenerics_4>; | ||
}; | ||
export {}; |
@@ -54,3 +54,3 @@ import { Getter, OnChangeFn, TableGenerics, PropGetterValue, TableInstance, Row, RowModel, Updater } from '../types'; | ||
getDefaultOptions: <TGenerics extends TableGenerics>(instance: TableInstance<TGenerics>) => RowSelectionOptions<TGenerics>; | ||
getInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => RowSelectionInstance<TGenerics_1>; | ||
createInstance: <TGenerics_1 extends TableGenerics>(instance: TableInstance<TGenerics_1>) => RowSelectionInstance<TGenerics_1>; | ||
createRow: <TGenerics_2 extends TableGenerics>(row: Row<TGenerics_2>, instance: TableInstance<TGenerics_2>) => RowSelectionRow; | ||
@@ -57,0 +57,0 @@ }; |
@@ -81,3 +81,3 @@ import { RowModel } from '..'; | ||
createColumn: <TGenerics_2 extends TableGenerics>(column: Column<TGenerics_2>, instance: TableInstance<TGenerics_2>) => SortingColumn<TGenerics_2>; | ||
getInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => SortingInstance<TGenerics_3>; | ||
createInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => SortingInstance<TGenerics_3>; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Cell, Column, Getter, OnChangeFn, TableGenerics, PropGetterValue, TableInstance, Updater } from '../types'; | ||
import { Cell, Column, Getter, OnChangeFn, TableGenerics, PropGetterValue, TableInstance, Updater, Row } from '../types'; | ||
export declare type VisibilityOptions = { | ||
@@ -16,2 +16,5 @@ onColumnVisibilityChange?: OnChangeFn<VisibilityState>; | ||
getVisibleLeafColumns: () => Column<TGenerics>[]; | ||
getLeftVisibleLeafColumns: () => Column<TGenerics>[]; | ||
getRightVisibleLeafColumns: () => Column<TGenerics>[]; | ||
getCenterVisibleLeafColumns: () => Column<TGenerics>[]; | ||
setColumnVisibility: (updater: Updater<VisibilityState>) => void; | ||
@@ -34,2 +37,3 @@ toggleColumnVisibility: (columnId: string, value?: boolean) => void; | ||
export declare type VisibilityRow<TGenerics extends TableGenerics> = { | ||
_getAllVisibleCells: () => Cell<TGenerics>[]; | ||
getVisibleCells: () => Cell<TGenerics>[]; | ||
@@ -50,4 +54,5 @@ }; | ||
createColumn: <TGenerics_1 extends TableGenerics>(column: Column<TGenerics_1>, instance: TableInstance<TGenerics_1>) => VisibilityColumn; | ||
getInstance: <TGenerics_2 extends TableGenerics>(instance: TableInstance<TGenerics_2>) => VisibilityInstance<TGenerics_2>; | ||
createRow: <TGenerics_2 extends TableGenerics>(row: Row<TGenerics_2>, instance: TableInstance<TGenerics_2>) => VisibilityRow<TGenerics_2>; | ||
createInstance: <TGenerics_3 extends TableGenerics>(instance: TableInstance<TGenerics_3>) => VisibilityInstance<TGenerics_3>; | ||
}; | ||
export {}; |
@@ -1,6 +0,7 @@ | ||
import { CoreColumn, CoreColumnDef, CoreOptions, CoreRow, CoreTableState, TableCore } from './core'; | ||
import { CoreOptions, CoreTableState, TableCore } from './core'; | ||
import { ColumnsOptions, CoreColumn, CoreColumnDef } from './features/Columns'; | ||
import { VisibilityInstance, VisibilityTableState, VisibilityColumn as ColumnVisibilityColumn, VisibilityOptions, VisibilityColumnDef, VisibilityRow } from './features/Visibility'; | ||
import { ColumnOrderInstance, ColumnOrderOptions, ColumnOrderTableState } from './features/Ordering'; | ||
import { ColumnPinningColumn, ColumnPinningColumnDef, ColumnPinningInstance, ColumnPinningOptions, ColumnPinningTableState } from './features/Pinning'; | ||
import { HeadersInstance, HeadersRow } from './features/Headers'; | ||
import { ColumnPinningColumn, ColumnPinningColumnDef, ColumnPinningInstance, ColumnPinningOptions, ColumnPinningRow, ColumnPinningTableState } from './features/Pinning'; | ||
import { HeadersInstance } from './features/Headers'; | ||
import { FiltersColumn, FiltersColumnDef, FiltersInstance, FiltersOptions, FiltersTableState } from './features/Filters'; | ||
@@ -14,2 +15,7 @@ import { SortingColumn, SortingColumnDef, SortingInstance, SortingOptions, SortingTableState } from './features/Sorting'; | ||
import { RowSelectionInstance, RowSelectionOptions, RowSelectionRow, RowSelectionTableState } from './features/RowSelection'; | ||
import { ColumnsInstance } from './features/Columns'; | ||
import { CellsInstance, CellsRow } from './features/Cells'; | ||
import { CoreRow, RowsInstance, RowsOptions } from './features/Rows'; | ||
export declare type Updater<T> = T | ((old: T) => T); | ||
export declare type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void; | ||
export declare type TableGenerics = { | ||
@@ -30,14 +36,13 @@ Row?: any; | ||
getInitialState?: () => any; | ||
getInstance?: (instance: any) => any; | ||
createInstance?: (instance: any) => any; | ||
getDefaultColumn?: () => any; | ||
createColumn?: (column: any, instance: any) => any; | ||
createHeader?: (column: any, instance: any) => any; | ||
createCell?: (cell: any, column: any, row: any, instance: any) => any; | ||
createRow?: (row: any, instance: any) => any; | ||
}; | ||
export declare type TableInstance<TGenerics extends TableGenerics> = TableCore<TGenerics> & VisibilityInstance<TGenerics> & ColumnOrderInstance<TGenerics> & ColumnPinningInstance<TGenerics> & HeadersInstance<TGenerics> & FiltersInstance<TGenerics> & SortingInstance<TGenerics> & GroupingInstance<TGenerics> & ColumnSizingInstance<TGenerics> & ExpandedInstance<TGenerics> & PaginationInstance<TGenerics> & RowSelectionInstance<TGenerics>; | ||
export declare type Options<TGenerics extends TableGenerics> = CoreOptions<TGenerics> & VisibilityOptions & ColumnOrderOptions & ColumnPinningOptions & FiltersOptions<TGenerics> & SortingOptions<TGenerics> & GroupingOptions<TGenerics> & ExpandedOptions<TGenerics> & ColumnSizingOptions & PaginationOptions<TGenerics> & RowSelectionOptions<TGenerics>; | ||
export declare type Updater<T> = T | ((old: T) => T); | ||
export declare type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void; | ||
export declare type TableInstance<TGenerics extends TableGenerics> = TableCore<TGenerics> & ColumnsInstance<TGenerics> & RowsInstance<TGenerics> & CellsInstance<TGenerics> & VisibilityInstance<TGenerics> & ColumnOrderInstance<TGenerics> & ColumnPinningInstance<TGenerics> & HeadersInstance<TGenerics> & FiltersInstance<TGenerics> & SortingInstance<TGenerics> & GroupingInstance<TGenerics> & ColumnSizingInstance<TGenerics> & ExpandedInstance<TGenerics> & PaginationInstance<TGenerics> & RowSelectionInstance<TGenerics>; | ||
export declare type Options<TGenerics extends TableGenerics> = CoreOptions<TGenerics> & ColumnsOptions<TGenerics> & RowsOptions<TGenerics> & VisibilityOptions & ColumnOrderOptions & ColumnPinningOptions & FiltersOptions<TGenerics> & SortingOptions<TGenerics> & GroupingOptions<TGenerics> & ExpandedOptions<TGenerics> & ColumnSizingOptions & PaginationOptions<TGenerics> & RowSelectionOptions<TGenerics>; | ||
export declare type TableState = CoreTableState & VisibilityTableState & ColumnOrderTableState & ColumnPinningTableState & FiltersTableState & SortingTableState & ExpandedTableState & GroupingTableState & ColumnSizingTableState & PaginationTableState & RowSelectionTableState; | ||
export declare type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> & VisibilityRow<TGenerics> & HeadersRow<TGenerics> & GroupingRow & RowSelectionRow & ExpandedRow; | ||
export declare type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> & CellsRow<TGenerics> & VisibilityRow<TGenerics> & ColumnPinningRow<TGenerics> & GroupingRow & RowSelectionRow & ExpandedRow; | ||
export declare type RowValues = { | ||
@@ -69,5 +74,8 @@ [key: string]: any; | ||
id: string; | ||
index: number; | ||
depth: number; | ||
column: Column<TGenerics>; | ||
getWidth: () => number; | ||
getStart: () => number; | ||
getSize: () => number; | ||
headerGroup: HeaderGroup<TGenerics>; | ||
subHeaders: Header<TGenerics>[]; | ||
@@ -74,0 +82,0 @@ colSpan?: number; |
@@ -9,3 +9,2 @@ import { Getter, NoInfer, PropGetterValue, TableState, Updater } from './types'; | ||
export declare type IfDefined<T, N> = 0 extends 1 & T ? N : T extends {} ? T : N; | ||
export declare type DataUpdateFunction<T> = (input: T) => T; | ||
export declare function functionalUpdate<T>(updater: Updater<T>, input: T): T; | ||
@@ -12,0 +11,0 @@ export declare function noop(): void; |
{ | ||
"name": "@tanstack/table-core", | ||
"author": "Tanner Linsley", | ||
"version": "8.0.0-alpha.55", | ||
"version": "8.0.0-alpha.57", | ||
"description": "Hooks for building lightweight, fast and extendable datagrids for React", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
578
src/core.ts
@@ -1,33 +0,14 @@ | ||
import { | ||
flattenBy, | ||
functionalUpdate, | ||
propGetter, | ||
memo, | ||
RequiredKeys, | ||
} from './utils' | ||
import { functionalUpdate, propGetter, RequiredKeys } from './utils' | ||
import { | ||
Updater, | ||
PropGetterValue, | ||
Options, | ||
TableState, | ||
ColumnDef, | ||
Row, | ||
Column, | ||
Cell, | ||
Header, | ||
AccessorFn, | ||
HeaderRenderProps, | ||
TableProps, | ||
TableBodyProps, | ||
PropGetter, | ||
Getter, | ||
RowProps, | ||
CellProps, | ||
TableInstance, | ||
RowValues, | ||
CoreCell, | ||
Renderable, | ||
UseRenderer, | ||
RowModel, | ||
TableFeature, | ||
@@ -37,2 +18,5 @@ TableGenerics, | ||
import { Columns } from './features/Columns' | ||
import { Rows } from './features/Rows' | ||
import { Cells } from './features/Cells' | ||
import { ColumnSizing } from './features/ColumnSizing' | ||
@@ -49,18 +33,5 @@ import { Expanding } from './features/Expanding' | ||
import { Headers } from './features/Headers' | ||
// | ||
import { mean } from './aggregationFns' | ||
const features: TableFeature[] = [ | ||
Headers, | ||
Visibility, | ||
Ordering, | ||
Pinning, | ||
Filters, | ||
Sorting, | ||
Grouping, | ||
Expanding, | ||
Pagination, | ||
RowSelection, | ||
ColumnSizing, | ||
] | ||
export type CoreTableState = { | ||
@@ -72,9 +43,5 @@ coreProgress: number | ||
data: TGenerics['Row'][] | ||
columns: ColumnDef<TGenerics>[] | ||
state: Partial<TableState> | ||
onStateChange: (updater: Updater<TableState>) => void | ||
render: TGenerics['Render'] | ||
getCoreRowModel: ( | ||
instance: TableInstance<TGenerics> | ||
) => () => RowModel<TGenerics> | ||
debugAll?: boolean | ||
@@ -85,13 +52,3 @@ debugTable?: boolean | ||
debugRows?: boolean | ||
defaultColumn?: Partial<ColumnDef<TGenerics>> | ||
initialState?: Partial<TableState> | ||
getSubRows?: ( | ||
originalRow: TGenerics['Row'], | ||
index: number | ||
) => TGenerics['Row'][] | ||
getRowId?: ( | ||
originalRow: TGenerics['Row'], | ||
index: number, | ||
parent?: Row<TGenerics> | ||
) => string | ||
autoResetAll?: boolean | ||
@@ -112,54 +69,6 @@ mergeOptions?: ( | ||
willUpdate: () => void | ||
getRowId: ( | ||
_: TGenerics['Row'], | ||
index: number, | ||
parent?: Row<TGenerics> | ||
) => string | ||
getState: () => TableState | ||
setState: (updater: Updater<TableState>) => void | ||
getDefaultColumn: () => Partial<ColumnDef<TGenerics>> | ||
getColumnDefs: () => ColumnDef<TGenerics>[] | ||
createColumn: ( | ||
columnDef: ColumnDef<TGenerics>, | ||
depth: number, | ||
parent?: Column<TGenerics> | ||
) => Column<TGenerics> | ||
getAllColumns: () => Column<TGenerics>[] | ||
getAllFlatColumns: () => Column<TGenerics>[] | ||
getAllFlatColumnsById: () => Record<string, Column<TGenerics>> | ||
getAllLeafColumns: () => Column<TGenerics>[] | ||
getColumn: (columnId: string) => Column<TGenerics> | ||
getTotalWidth: () => number | ||
createCell: ( | ||
row: Row<TGenerics>, | ||
column: Column<TGenerics>, | ||
value: any | ||
) => Cell<TGenerics> | ||
createRow: ( | ||
id: string, | ||
original: TGenerics['Row'] | undefined, | ||
rowIndex: number, | ||
depth: number, | ||
values: Record<string, any> | ||
) => Row<TGenerics> | ||
getCoreRowModel: () => RowModel<TGenerics> | ||
_getCoreRowModel?: () => RowModel<TGenerics> | ||
getRowModel: () => RowModel<TGenerics> | ||
getRow: (id: string) => Row<TGenerics> | ||
getCell: (rowId: string, columnId: string) => Cell<TGenerics> | ||
getTableProps: PropGetter<TableProps> | ||
getTableBodyProps: PropGetter<TableBodyProps> | ||
getRowProps: <TGetter extends Getter<RowProps>>( | ||
rowId: string, | ||
userProps?: TGetter | ||
) => undefined | PropGetterValue<RowProps, TGetter> | ||
getCellProps: <TGetter extends Getter<CellProps>>( | ||
rowId: string, | ||
columnId: string, | ||
userProps?: TGetter | ||
) => undefined | PropGetterValue<CellProps, TGetter> | ||
getTableWidth: () => number | ||
getLeftTableWidth: () => number | ||
getCenterTableWidth: () => number | ||
getRightTableWidth: () => number | ||
render: <TProps>( | ||
@@ -170,68 +79,5 @@ template: Renderable<TGenerics, TProps>, | ||
getOverallProgress: () => number | ||
_features: readonly TableFeature[] | ||
} | ||
export type CoreRow<TGenerics extends TableGenerics> = { | ||
id: string | ||
index: number | ||
original?: TGenerics['Row'] | ||
depth: number | ||
values: RowValues | ||
subRows: Row<TGenerics>[] | ||
getLeafRows: () => Row<TGenerics>[] | ||
getRowProps: PropGetter<RowProps> | ||
originalSubRows?: TGenerics['Row'][] | ||
getAllCells: () => Cell<TGenerics>[] | ||
getAllCellsByColumnId: () => Record<string, Cell<TGenerics>> | ||
} | ||
export type CoreColumnDef<TGenerics extends TableGenerics> = { | ||
id: string | ||
accessorKey?: string & keyof TGenerics['Row'] | ||
accessorFn?: AccessorFn<TGenerics['Row']> | ||
columns?: ColumnDef<TGenerics>[] | ||
header?: Renderable< | ||
TGenerics, | ||
{ | ||
instance: TableInstance<TGenerics> | ||
header: Header<TGenerics> | ||
column: Column<TGenerics> | ||
} | ||
> | ||
footer?: Renderable< | ||
TGenerics, | ||
{ | ||
instance: TableInstance<TGenerics> | ||
header: Header<TGenerics> | ||
column: Column<TGenerics> | ||
} | ||
> | ||
cell?: Renderable< | ||
TGenerics, | ||
{ | ||
instance: TableInstance<TGenerics> | ||
row: Row<TGenerics> | ||
column: Column<TGenerics> | ||
cell: Cell<TGenerics> | ||
value: TGenerics['Value'] | ||
} | ||
> | ||
meta?: TGenerics['ColumnMeta'] | ||
} | ||
// & GeneratedProperties<true> | ||
export type CoreColumnDefType = 'data' | 'display' | 'group' | ||
export type CoreColumn<TGenerics extends TableGenerics> = { | ||
id: string | ||
depth: number | ||
accessorFn?: AccessorFn<TGenerics['Row']> | ||
columnDef: ColumnDef<TGenerics> | ||
columnDefType: CoreColumnDefType | ||
getWidth: () => number | ||
columns: Column<TGenerics>[] | ||
parent?: Column<TGenerics> | ||
getFlatColumns: () => Column<TGenerics>[] | ||
getLeafColumns: () => Column<TGenerics>[] | ||
} | ||
export function createTableInstance<TGenerics extends TableGenerics>( | ||
@@ -246,3 +92,20 @@ options: Options<TGenerics> | ||
const defaultOptions = features.reduce((obj, feature) => { | ||
instance._features = [ | ||
Columns, | ||
Rows, | ||
Cells, | ||
Headers, | ||
Visibility, | ||
Ordering, | ||
Pinning, | ||
Filters, | ||
Sorting, | ||
Grouping, | ||
Expanding, | ||
Pagination, | ||
RowSelection, | ||
ColumnSizing, | ||
] as const | ||
const defaultOptions = instance._features.reduce((obj, feature) => { | ||
return Object.assign(obj, feature.getDefaultOptions?.(instance)) | ||
@@ -264,3 +127,3 @@ }, {}) | ||
...coreInitialState, | ||
...features.reduce((obj, feature) => { | ||
...instance._features.reduce((obj, feature) => { | ||
return Object.assign(obj, feature.getInitialState?.()) | ||
@@ -276,5 +139,5 @@ }, {}), | ||
...instance, | ||
...features.reduce((obj, feature) => { | ||
return Object.assign(obj, feature.getInstance?.(instance)) | ||
}, {}), | ||
...(instance._features.reduce((obj, feature) => { | ||
return Object.assign(obj, feature.createInstance?.(instance)) | ||
}, {}) as unknown as TableInstance<TGenerics>), | ||
queue: cb => { | ||
@@ -321,6 +184,2 @@ queued.push(cb) | ||
getRowId: (row: TGenerics['Row'], index: number, parent?: Row<TGenerics>) => | ||
instance.options.getRowId?.(row, index, parent) ?? | ||
`${parent ? [parent.id, index].join('.') : index}`, | ||
getState: () => { | ||
@@ -334,335 +193,2 @@ return instance.options.state as TableState | ||
getDefaultColumn: memo( | ||
() => [instance.options.defaultColumn], | ||
defaultColumn => { | ||
defaultColumn = (defaultColumn ?? {}) as Partial<ColumnDef<TGenerics>> | ||
return { | ||
header: (props: HeaderRenderProps<Header<TGenerics>>) => | ||
props.header.column.id, | ||
footer: (props: HeaderRenderProps<Header<TGenerics>>) => | ||
props.header.column.id, | ||
cell: ({ value = '' }: { value: any }): JSX.Element => | ||
typeof value === 'boolean' ? value.toString() : value, | ||
...features.reduce((obj, feature) => { | ||
return Object.assign(obj, feature.getDefaultColumn?.()) | ||
}, {}), | ||
...defaultColumn, | ||
} as Partial<ColumnDef<TGenerics>> | ||
}, | ||
{ | ||
debug: () => instance.options.debugAll ?? instance.options.debugColumns, | ||
key: 'getDefaultColumn', | ||
} | ||
), | ||
getColumnDefs: () => instance.options.columns, | ||
createColumn: ( | ||
columnDef: ColumnDef<TGenerics> & { columnDefType?: CoreColumnDefType }, | ||
depth: number, | ||
parent | ||
) => { | ||
const defaultColumn = instance.getDefaultColumn() | ||
let id = | ||
columnDef.id ?? | ||
columnDef.accessorKey ?? | ||
(typeof columnDef.header === 'string' ? columnDef.header : undefined) | ||
let accessorFn: AccessorFn<TGenerics['Row']> | undefined | ||
if (columnDef.accessorFn) { | ||
accessorFn = columnDef.accessorFn | ||
} else if (columnDef.accessorKey) { | ||
accessorFn = (originalRow?: TGenerics['Row']) => | ||
(originalRow as any)[columnDef.accessorKey] | ||
} | ||
if (!id) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error( | ||
columnDef.accessorFn | ||
? `Columns require an id when using an accessorFn` | ||
: `Columns require an id when using a non-string header` | ||
) | ||
} | ||
throw new Error() | ||
} | ||
let column: CoreColumn<TGenerics> = { | ||
...defaultColumn, | ||
...columnDef, | ||
id: `${id}`, | ||
accessorFn, | ||
parent: parent as any, | ||
depth, | ||
columnDef, | ||
columnDefType: columnDef.columnDefType as CoreColumnDefType, | ||
columns: [], | ||
getWidth: () => instance.getColumnWidth(column.id), | ||
getFlatColumns: memo( | ||
() => [true], | ||
() => { | ||
return [ | ||
column as Column<TGenerics>, | ||
...column.columns?.flatMap(d => d.getFlatColumns()), | ||
] | ||
}, | ||
{ | ||
key: 'column.getFlatColumns', | ||
debug: () => | ||
instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
getLeafColumns: memo( | ||
() => [instance._getOrderColumnsFn()], | ||
orderColumns => { | ||
if (column.columns?.length) { | ||
let leafColumns = column.columns.flatMap(column => | ||
column.getLeafColumns() | ||
) | ||
return orderColumns(leafColumns) | ||
} | ||
return [column as Column<TGenerics>] | ||
}, | ||
{ | ||
key: 'column.getLeafColumns', | ||
debug: () => | ||
instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
} | ||
column = features.reduce((obj, feature) => { | ||
return Object.assign(obj, feature.createColumn?.(column, instance)) | ||
}, column) | ||
// Yes, we have to convert instance to uknown, because we know more than the compiler here. | ||
return column as Column<TGenerics> | ||
}, | ||
getAllColumns: memo( | ||
() => [instance.getColumnDefs()], | ||
columnDefs => { | ||
const recurseColumns = ( | ||
columnDefs: ColumnDef<TGenerics>[], | ||
parent?: Column<TGenerics>, | ||
depth = 0 | ||
): Column<TGenerics>[] => { | ||
return columnDefs.map(columnDef => { | ||
const column = instance.createColumn(columnDef, depth, parent) | ||
column.columns = columnDef.columns | ||
? recurseColumns(columnDef.columns, column, depth + 1) | ||
: [] | ||
return column | ||
}) | ||
} | ||
return recurseColumns(columnDefs) | ||
}, | ||
{ | ||
key: 'getAllColumns', | ||
debug: () => instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
getAllFlatColumns: memo( | ||
() => [instance.getAllColumns()], | ||
allColumns => { | ||
return allColumns.flatMap(column => { | ||
return column.getFlatColumns() | ||
}) | ||
}, | ||
{ | ||
key: 'getAllFlatColumns', | ||
debug: () => instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
getAllFlatColumnsById: memo( | ||
() => [instance.getAllFlatColumns()], | ||
flatColumns => { | ||
return flatColumns.reduce((acc, column) => { | ||
acc[column.id] = column | ||
return acc | ||
}, {} as Record<string, Column<TGenerics>>) | ||
}, | ||
{ | ||
key: 'getAllFlatColumnsById', | ||
debug: () => instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
getAllLeafColumns: memo( | ||
() => [instance.getAllColumns(), instance._getOrderColumnsFn()], | ||
(allColumns, orderColumns) => { | ||
let leafColumns = allColumns.flatMap(column => column.getLeafColumns()) | ||
return orderColumns(leafColumns) | ||
}, | ||
{ | ||
key: 'getAllLeafColumns', | ||
debug: () => instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
getColumn: columnId => { | ||
const column = instance.getAllFlatColumnsById()[columnId] | ||
if (!column) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(`[Table] Column with id ${columnId} does not exist.`) | ||
} | ||
throw new Error() | ||
} | ||
return column | ||
}, | ||
createCell: (row, column, value) => { | ||
const cell: CoreCell<TGenerics> = { | ||
id: `${row.id}_${column.id}`, | ||
rowId: row.id, | ||
columnId: column.id, | ||
row, | ||
column, | ||
value, | ||
getCellProps: userProps => | ||
instance.getCellProps(row.id, column.id, userProps)!, | ||
renderCell: () => | ||
column.cell | ||
? instance.render(column.cell, { | ||
instance, | ||
column, | ||
row, | ||
cell: cell as Cell<TGenerics>, | ||
value, | ||
}) | ||
: null, | ||
} | ||
features.forEach(feature => { | ||
Object.assign( | ||
cell, | ||
feature.createCell?.( | ||
cell as Cell<TGenerics>, | ||
column, | ||
row as Row<TGenerics>, | ||
instance | ||
) | ||
) | ||
}, {}) | ||
return cell as Cell<TGenerics> | ||
}, | ||
createRow: (id, original, rowIndex, depth, values) => { | ||
let row: CoreRow<TGenerics> = { | ||
id, | ||
index: rowIndex, | ||
original, | ||
depth, | ||
values, | ||
subRows: [], | ||
getLeafRows: () => flattenBy(row.subRows, d => d.subRows), | ||
getRowProps: userProps => instance.getRowProps(row.id, userProps)!, | ||
getAllCells: undefined!, | ||
getAllCellsByColumnId: undefined!, | ||
} | ||
row.getAllCells = memo( | ||
() => [instance.getAllLeafColumns()], | ||
leafColumns => { | ||
return leafColumns.map(column => { | ||
return instance.createCell( | ||
row as Row<TGenerics>, | ||
column, | ||
row.values[column.id] | ||
) | ||
}) | ||
}, | ||
{ | ||
key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
) | ||
row.getAllCellsByColumnId = memo( | ||
() => [row.getAllCells()], | ||
allCells => { | ||
return allCells.reduce((acc, cell) => { | ||
acc[cell.columnId] = cell | ||
return acc | ||
}, {} as Record<string, Cell<TGenerics>>) | ||
}, | ||
{ | ||
key: 'row.getAllCellsByColumnId', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
) | ||
for (let i = 0; i < features.length; i++) { | ||
const feature = features[i] | ||
Object.assign(row, feature.createRow?.(row, instance)) | ||
} | ||
return row as Row<TGenerics> | ||
}, | ||
getCoreRowModel: () => { | ||
if (!instance._getCoreRowModel) { | ||
instance._getCoreRowModel = instance.options.getCoreRowModel(instance) | ||
} | ||
return instance._getCoreRowModel() | ||
}, | ||
// The final calls start at the bottom of the model, | ||
// expanded rows, which then work their way up | ||
getRowModel: () => { | ||
return instance.getPaginationRowModel() | ||
}, | ||
getRow: (id: string) => { | ||
const row = instance.getRowModel().rowsById[id] | ||
if (!row) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error(`getRow expected an ID, but got ${id}`) | ||
} | ||
throw new Error() | ||
} | ||
return row | ||
}, | ||
getCell: (rowId: string, columnId: string) => { | ||
const row = instance.getRow(rowId) | ||
if (!row) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error(`[Table] could not find row with id ${rowId}`) | ||
} | ||
throw new Error() | ||
} | ||
const cell = row.getAllCellsByColumnId()[columnId] | ||
if (!cell) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
throw new Error( | ||
`[Table] could not find cell ${columnId} in row ${rowId}` | ||
) | ||
} | ||
throw new Error() | ||
} | ||
return cell | ||
}, | ||
getTableProps: userProps => { | ||
@@ -686,50 +212,2 @@ return propGetter( | ||
getRowProps: (rowId, userProps) => { | ||
const row = instance.getRow(rowId) | ||
if (!row) { | ||
return | ||
} | ||
return propGetter( | ||
{ | ||
key: row.id, | ||
role: 'row', | ||
}, | ||
userProps | ||
) | ||
}, | ||
getCellProps: (rowId, columnId, userProps) => { | ||
const cell = instance.getCell(rowId, columnId) | ||
if (!cell) { | ||
return | ||
} | ||
return propGetter( | ||
{ | ||
key: cell.id, | ||
role: 'gridcell', | ||
}, | ||
userProps | ||
) | ||
}, | ||
getTableWidth: () => | ||
instance.getHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getWidth() | ||
}, 0) ?? 0, | ||
getLeftTableWidth: () => | ||
instance.getLeftHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getWidth() | ||
}, 0) ?? 0, | ||
getCenterTableWidth: () => | ||
instance.getCenterHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getWidth() | ||
}, 0) ?? 0, | ||
getRightTableWidth: () => | ||
instance.getRightHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getWidth() | ||
}, 0) ?? 0, | ||
getOverallProgress: () => { | ||
@@ -736,0 +214,0 @@ const { coreProgress, columnFiltersProgress, globalFilterProgress } = |
@@ -12,2 +12,3 @@ import { | ||
import { makeStateUpdater, propGetter } from '../utils' | ||
import { ColumnPinningPosition } from './Pinning' | ||
@@ -17,7 +18,7 @@ // | ||
export type ColumnSizingTableState = { | ||
columnSizing: ColumnSizing | ||
columnSizing: ColumnSizingState | ||
columnSizingInfo: ColumnSizingInfoState | ||
} | ||
export type ColumnSizing = Record<string, number> | ||
export type ColumnSizingState = Record<string, number> | ||
@@ -38,3 +39,3 @@ export type ColumnSizingInfoState = { | ||
columnResizeMode?: ColumnResizeMode | ||
onColumnSizingChange?: OnChangeFn<ColumnSizing> | ||
onColumnSizingChange?: OnChangeFn<ColumnSizingState> | ||
onColumnSizingInfoChange?: OnChangeFn<ColumnSizingInfoState> | ||
@@ -45,3 +46,3 @@ } | ||
columnResizeMode: ColumnResizeMode | ||
onColumnSizingChange: OnChangeFn<ColumnSizing> | ||
onColumnSizingChange: OnChangeFn<ColumnSizingState> | ||
onColumnSizingInfoChange: OnChangeFn<ColumnSizingInfoState> | ||
@@ -59,4 +60,5 @@ } | ||
export type ColumnSizingInstance<TGenerics extends TableGenerics> = { | ||
getColumnWidth: (columnId: string) => number | ||
setColumnSizing: (updater: Updater<ColumnSizing>) => void | ||
getColumnSize: (columnId: string) => number | ||
getColumnStart: (columnId: string, position?: ColumnPinningPosition) => number | ||
setColumnSizing: (updater: Updater<ColumnSizingState>) => void | ||
setColumnSizingInfo: (updater: Updater<ColumnSizingInfoState>) => void | ||
@@ -75,2 +77,6 @@ resetColumnSizing: () => void | ||
getHeaderIsResizing: (headerId: string) => boolean | ||
getTotalSize: () => number | ||
getLeftTotalSize: () => number | ||
getCenterTotalSize: () => number | ||
getRightTotalSize: () => number | ||
} | ||
@@ -81,8 +87,10 @@ | ||
defaultCanResize?: boolean | ||
width?: number | ||
minWidth?: number | ||
maxWidth?: number | ||
size?: number | ||
minSize?: number | ||
maxSize?: number | ||
} | ||
export type ColumnSizingColumn<TGenerics extends TableGenerics> = { | ||
getSize: () => number | ||
getStart: (position?: ColumnPinningPosition) => number | ||
getCanResize: () => boolean | ||
@@ -105,5 +113,5 @@ getIsResizing: () => boolean | ||
export const defaultColumnSizing = { | ||
width: 150, | ||
minWidth: 20, | ||
maxWidth: Number.MAX_SAFE_INTEGER, | ||
size: 150, | ||
minSize: 20, | ||
maxSize: Number.MAX_SAFE_INTEGER, | ||
} | ||
@@ -139,7 +147,33 @@ | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createColumn: <TGenerics extends TableGenerics>( | ||
column: Column<TGenerics>, | ||
instance: TableInstance<TGenerics> | ||
): ColumnSizingColumn<TGenerics> => { | ||
return { | ||
getSize: () => instance.getColumnSize(column.id), | ||
getStart: position => instance.getColumnStart(column.id, position), | ||
getIsResizing: () => instance.getColumnIsResizing(column.id), | ||
getCanResize: () => instance.getColumnCanResize(column.id), | ||
resetSize: () => instance.resetColumnSize(column.id), | ||
} | ||
}, | ||
createHeader: <TGenerics extends TableGenerics>( | ||
header: Header<TGenerics>, | ||
instance: TableInstance<TGenerics> | ||
): ColumnSizingHeader<TGenerics> => { | ||
return { | ||
getIsResizing: () => instance.getColumnIsResizing(header.column.id), | ||
getCanResize: () => instance.getColumnCanResize(header.column.id), | ||
resetSize: () => instance.resetColumnSize(header.column.id), | ||
getResizerProps: userProps => | ||
instance.getHeaderResizerProps(header.id, userProps), | ||
} | ||
}, | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
): ColumnSizingInstance<TGenerics> => { | ||
return { | ||
getColumnWidth: (columnId: string) => { | ||
getColumnSize: (columnId: string) => { | ||
const column = instance.getColumn(columnId) | ||
@@ -155,8 +189,34 @@ | ||
Math.max( | ||
column.minWidth ?? defaultColumnSizing.minWidth, | ||
columnSize ?? column.width ?? defaultColumnSizing.width | ||
column.minSize ?? defaultColumnSizing.minSize, | ||
columnSize ?? column.size ?? defaultColumnSizing.size | ||
), | ||
column.maxWidth ?? defaultColumnSizing.maxWidth | ||
column.maxSize ?? defaultColumnSizing.maxSize | ||
) | ||
}, | ||
getColumnStart: (columnId, position) => { | ||
const column = instance.getColumn(columnId) | ||
if (!column) { | ||
throw new Error() | ||
} | ||
const columns = !position | ||
? instance.getVisibleLeafColumns() | ||
: position === 'left' | ||
? instance.getLeftVisibleLeafColumns() | ||
: instance.getRightVisibleLeafColumns() | ||
const index = columns.findIndex(d => d.id === columnId) | ||
if (index > 0) { | ||
const prevSiblingColumn = columns[index - 1] | ||
return ( | ||
instance.getColumnStart(prevSiblingColumn.id, position) + | ||
prevSiblingColumn.getSize() | ||
) | ||
} | ||
return 0 | ||
}, | ||
setColumnSizing: updater => | ||
@@ -244,7 +304,7 @@ instance.options.onColumnSizingChange?.(updater), | ||
const startSize = header ? header.getWidth() : column.getWidth() | ||
const startSize = header ? header.getSize() : column.getSize() | ||
const columnSizingStart: [string, number][] = header | ||
? header.getLeafHeaders().map(d => [d.column.id, d.getWidth()]) | ||
: [[column.id, column.getWidth()]] | ||
? header.getLeafHeaders().map(d => [d.column.id, d.getSize()]) | ||
: [[column.id, column.getSize()]] | ||
@@ -263,3 +323,3 @@ const clientX = isTouchStartEvent(e) | ||
let newColumnSizing: ColumnSizing = {} | ||
let newColumnSizing: ColumnSizingState = {} | ||
@@ -273,7 +333,6 @@ instance.setColumnSizingInfo(old => { | ||
old.columnSizingStart.forEach(([columnId, headerWidth]) => { | ||
old.columnSizingStart.forEach(([columnId, headerSize]) => { | ||
newColumnSizing[columnId] = | ||
Math.round( | ||
Math.max(headerWidth + headerWidth * deltaPercentage, 0) * | ||
100 | ||
Math.max(headerSize + headerSize * deltaPercentage, 0) * 100 | ||
) / 100 | ||
@@ -403,28 +462,21 @@ }) | ||
}, | ||
} | ||
}, | ||
createColumn: <TGenerics extends TableGenerics>( | ||
column: Column<TGenerics>, | ||
instance: TableInstance<TGenerics> | ||
): ColumnSizingColumn<TGenerics> => { | ||
return { | ||
getIsResizing: () => instance.getColumnIsResizing(column.id), | ||
getCanResize: () => instance.getColumnCanResize(column.id), | ||
resetSize: () => instance.resetColumnSize(column.id), | ||
getTotalSize: () => | ||
instance.getHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getSize() | ||
}, 0) ?? 0, | ||
getLeftTotalSize: () => | ||
instance.getLeftHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getSize() | ||
}, 0) ?? 0, | ||
getCenterTotalSize: () => | ||
instance.getCenterHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getSize() | ||
}, 0) ?? 0, | ||
getRightTotalSize: () => | ||
instance.getRightHeaderGroups()[0]?.headers.reduce((sum, header) => { | ||
return sum + header.getSize() | ||
}, 0) ?? 0, | ||
} | ||
}, | ||
createHeader: <TGenerics extends TableGenerics>( | ||
header: Header<TGenerics>, | ||
instance: TableInstance<TGenerics> | ||
): ColumnSizingHeader<TGenerics> => { | ||
return { | ||
getIsResizing: () => instance.getColumnIsResizing(header.column.id), | ||
getCanResize: () => instance.getColumnCanResize(header.column.id), | ||
resetSize: () => instance.resetColumnSize(header.column.id), | ||
getResizerProps: userProps => | ||
instance.getHeaderResizerProps(header.id, userProps), | ||
} | ||
}, | ||
} | ||
@@ -431,0 +483,0 @@ |
@@ -91,3 +91,3 @@ import { RowModel } from '..' | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
@@ -94,0 +94,0 @@ ): ExpandedInstance<TGenerics> => { |
@@ -233,3 +233,3 @@ import { RowModel } from '..' | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
@@ -236,0 +236,0 @@ ): FiltersInstance<TGenerics> => { |
@@ -181,3 +181,3 @@ import { RowModel } from '..' | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
@@ -184,0 +184,0 @@ ): GroupingInstance<TGenerics> => { |
@@ -18,12 +18,3 @@ import { | ||
import { propGetter, memo } from '../utils' | ||
import { ColumnSizing } from './ColumnSizing' | ||
export type HeadersRow<TGenerics extends TableGenerics> = { | ||
_getAllVisibleCells: () => Cell<TGenerics>[] | ||
getVisibleCells: () => Cell<TGenerics>[] | ||
getLeftVisibleCells: () => Cell<TGenerics>[] | ||
getCenterVisibleCells: () => Cell<TGenerics>[] | ||
getRightVisibleCells: () => Cell<TGenerics>[] | ||
} | ||
export type HeadersInstance<TGenerics extends TableGenerics> = { | ||
@@ -36,2 +27,3 @@ createHeader: ( | ||
placeholderId?: string | ||
index: number | ||
depth: number | ||
@@ -78,3 +70,2 @@ } | ||
) => undefined | PropGetterValue<FooterProps, TGetter> | ||
getTotalWidth: () => number | ||
} | ||
@@ -85,91 +76,4 @@ | ||
export const Headers = { | ||
createRow: <TGenerics extends TableGenerics>( | ||
row: Row<TGenerics>, | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
): HeadersRow<TGenerics> => { | ||
return { | ||
_getAllVisibleCells: memo( | ||
() => [ | ||
row | ||
.getAllCells() | ||
.filter(cell => cell.column.getIsVisible()) | ||
.map(d => d.id) | ||
.join('_'), | ||
], | ||
_ => { | ||
return row.getAllCells().filter(cell => cell.column.getIsVisible()) | ||
}, | ||
{ | ||
key: 'row._getAllVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getVisibleCells: memo( | ||
() => [ | ||
row.getLeftVisibleCells(), | ||
row.getCenterVisibleCells(), | ||
row.getRightVisibleCells(), | ||
], | ||
(left, center, right) => [...left, ...center, ...right], | ||
{ | ||
key: 'row.getVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getCenterVisibleCells: memo( | ||
() => [ | ||
row._getAllVisibleCells(), | ||
instance.getState().columnPinning.left, | ||
instance.getState().columnPinning.right, | ||
], | ||
(allCells, left, right) => { | ||
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])] | ||
return allCells.filter(d => !leftAndRight.includes(d.columnId)) | ||
}, | ||
{ | ||
key: 'row.getCenterVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getLeftVisibleCells: memo( | ||
() => [ | ||
row._getAllVisibleCells(), | ||
instance.getState().columnPinning.left, | ||
, | ||
], | ||
(allCells, left) => { | ||
const cells = (left ?? []) | ||
.map(columnId => allCells.find(cell => cell.columnId === columnId)!) | ||
.filter(Boolean) | ||
return cells | ||
}, | ||
{ | ||
key: 'row.getLeftVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getRightVisibleCells: memo( | ||
() => [ | ||
row._getAllVisibleCells(), | ||
instance.getState().columnPinning.right, | ||
], | ||
(allCells, right) => { | ||
const cells = (right ?? []) | ||
.map(columnId => allCells.find(cell => cell.columnId === columnId)!) | ||
.filter(Boolean) | ||
return cells | ||
}, | ||
{ | ||
key: 'row.getRightVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
} | ||
}, | ||
getInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
): HeadersInstance<TGenerics> => { | ||
@@ -183,2 +87,3 @@ return { | ||
placeholderId?: string | ||
index: number | ||
depth: number | ||
@@ -192,2 +97,3 @@ } | ||
column, | ||
index: options.index, | ||
isPlaceholder: options.isPlaceholder, | ||
@@ -199,3 +105,4 @@ placeholderId: options.placeholderId, | ||
rowSpan: 0, | ||
getWidth: () => { | ||
headerGroup: null!, | ||
getSize: () => { | ||
let sum = 0 | ||
@@ -207,3 +114,3 @@ | ||
} else { | ||
sum += header.column.getWidth() ?? 0 | ||
sum += header.column.getSize() ?? 0 | ||
} | ||
@@ -216,2 +123,11 @@ } | ||
}, | ||
getStart: () => { | ||
if (header.index > 0) { | ||
const prevSiblingHeader = | ||
header.headerGroup.headers[header.index - 1] | ||
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize() | ||
} | ||
return 0 | ||
}, | ||
getLeafHeaders: (): Header<TGenerics>[] => { | ||
@@ -253,7 +169,7 @@ const leafHeaders: CoreHeader<TGenerics>[] = [] | ||
// Yes, we have to convert instance to unknown, because we know more than the compiler here. | ||
return Object.assign( | ||
header, | ||
ColumnSizing.createHeader(header as Header<TGenerics>, instance) | ||
) as Header<TGenerics> | ||
instance._features.forEach(feature => { | ||
Object.assign(header, feature.createHeader?.(header, instance)) | ||
}) | ||
return header as Header<TGenerics> | ||
}, | ||
@@ -605,12 +521,2 @@ | ||
}, | ||
getTotalWidth: () => { | ||
let width = 0 | ||
instance.getVisibleLeafColumns().forEach(column => { | ||
width += column.getWidth() ?? 0 | ||
}) | ||
return width | ||
}, | ||
} | ||
@@ -666,3 +572,3 @@ }, | ||
// The parent columns we're going to scan next | ||
const parentHeaders: Header<TGenerics>[] = [] | ||
const pendingParentHeaders: Header<TGenerics>[] = [] | ||
@@ -673,3 +579,3 @@ // Scan each column for parents | ||
const latestParentHeader = [...parentHeaders].reverse()[0] | ||
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0] | ||
@@ -690,25 +596,28 @@ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth | ||
const header = instance.createHeader(column, { | ||
id: [headerFamily, depth, column.id, headerToGroup?.id] | ||
.filter(Boolean) | ||
.join('_'), | ||
isPlaceholder, | ||
placeholderId: isPlaceholder | ||
? `${parentHeaders.filter(d => d.column === column).length}` | ||
: undefined, | ||
depth, | ||
}) | ||
if (latestPendingParentHeader?.column === column) { | ||
// This column is repeated. Add it as a sub header to the next batch | ||
latestPendingParentHeader.subHeaders.push(headerToGroup) | ||
} else { | ||
// This is a new header. Let's create it | ||
const header = instance.createHeader(column, { | ||
id: [headerFamily, depth, column.id, headerToGroup?.id] | ||
.filter(Boolean) | ||
.join('_'), | ||
isPlaceholder, | ||
placeholderId: isPlaceholder | ||
? `${pendingParentHeaders.filter(d => d.column === column).length}` | ||
: undefined, | ||
depth, | ||
index: pendingParentHeaders.length, | ||
}) | ||
if (!latestParentHeader || latestParentHeader.column !== header.column) { | ||
// Add the headerToGroup as a subHeader of the new header | ||
header.subHeaders.push(headerToGroup) | ||
parentHeaders.push(header) | ||
} else { | ||
latestParentHeader.subHeaders.push(headerToGroup) | ||
// Add the new header to the pendingParentHeaders to get grouped | ||
// in the next batch | ||
pendingParentHeaders.push(header) | ||
} | ||
// if (!headerToGroup.isPlaceholder) { | ||
// headerToGroup.column.header = headerToGroup; | ||
// } | ||
headerGroup.headers.push(headerToGroup) | ||
headerToGroup.headerGroup = headerGroup | ||
}) | ||
@@ -719,9 +628,10 @@ | ||
if (depth > 0) { | ||
createHeaderGroup(parentHeaders, depth - 1) | ||
createHeaderGroup(pendingParentHeaders, depth - 1) | ||
} | ||
} | ||
const bottomHeaders = columnsToGroup.map(column => | ||
const bottomHeaders = columnsToGroup.map((column, index) => | ||
instance.createHeader(column, { | ||
depth: maxDepth, | ||
index, | ||
}) | ||
@@ -728,0 +638,0 @@ ) |
@@ -52,3 +52,3 @@ import { makeStateUpdater, memo } from '../utils' | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
@@ -55,0 +55,0 @@ ): ColumnOrderInstance<TGenerics> => { |
@@ -75,3 +75,3 @@ import { | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
@@ -78,0 +78,0 @@ ): PaginationInstance<TGenerics> => { |
@@ -7,6 +7,8 @@ import { | ||
TableGenerics, | ||
Row, | ||
Cell, | ||
} from '../types' | ||
import { functionalUpdate, makeStateUpdater } from '../utils' | ||
import { functionalUpdate, makeStateUpdater, memo } from '../utils' | ||
type ColumnPinningPosition = false | 'left' | 'right' | ||
export type ColumnPinningPosition = false | 'left' | 'right' | ||
@@ -43,2 +45,14 @@ export type ColumnPinningState = { | ||
export type ColumnPinningRow<TGenerics extends TableGenerics> = { | ||
getLeftVisibleCells: () => Cell<TGenerics>[] | ||
getCenterVisibleCells: () => Cell<TGenerics>[] | ||
getRightVisibleCells: () => Cell<TGenerics>[] | ||
} | ||
export type ColumnPinningCell<TGenerics extends TableGenerics> = { | ||
getLeftVisibleCells: () => Cell<TGenerics>[] | ||
getCenterVisibleCells: () => Cell<TGenerics>[] | ||
getRightVisibleCells: () => Cell<TGenerics>[] | ||
} | ||
export type ColumnPinningInstance<TGenerics extends TableGenerics> = { | ||
@@ -52,2 +66,5 @@ setColumnPinning: (updater: Updater<ColumnPinningState>) => void | ||
getIsSomeColumnsPinned: () => boolean | ||
getLeftLeafColumns: () => Column<TGenerics>[] | ||
getRightLeafColumns: () => Column<TGenerics>[] | ||
getCenterLeafColumns: () => Column<TGenerics>[] | ||
} | ||
@@ -87,4 +104,126 @@ | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createRow: <TGenerics extends TableGenerics>( | ||
row: Row<TGenerics>, | ||
instance: TableInstance<TGenerics> | ||
): ColumnPinningRow<TGenerics> => { | ||
return { | ||
getCenterVisibleCells: memo( | ||
() => [ | ||
row._getAllVisibleCells(), | ||
instance.getState().columnPinning.left, | ||
instance.getState().columnPinning.right, | ||
], | ||
(allCells, left, right) => { | ||
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])] | ||
return allCells.filter(d => !leftAndRight.includes(d.columnId)) | ||
}, | ||
{ | ||
key: 'row.getCenterVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getLeftVisibleCells: memo( | ||
() => [ | ||
row._getAllVisibleCells(), | ||
instance.getState().columnPinning.left, | ||
, | ||
], | ||
(allCells, left) => { | ||
const cells = (left ?? []) | ||
.map(columnId => allCells.find(cell => cell.columnId === columnId)!) | ||
.filter(Boolean) | ||
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>)) | ||
return cells | ||
}, | ||
{ | ||
key: 'row.getLeftVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getRightVisibleCells: memo( | ||
() => [ | ||
row._getAllVisibleCells(), | ||
instance.getState().columnPinning.right, | ||
], | ||
(allCells, right) => { | ||
const cells = (right ?? []) | ||
.map(columnId => allCells.find(cell => cell.columnId === columnId)!) | ||
.filter(Boolean) | ||
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>)) | ||
return cells | ||
}, | ||
{ | ||
key: 'row.getRightVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
} | ||
}, | ||
createCell: <TGenerics extends TableGenerics>( | ||
cell: Cell<TGenerics>, | ||
instance: TableInstance<TGenerics> | ||
): ColumnPinningCell<TGenerics> => { | ||
return { | ||
getCenterVisibleCells: memo( | ||
() => [ | ||
cell.row._getAllVisibleCells(), | ||
instance.getState().columnPinning.left, | ||
instance.getState().columnPinning.right, | ||
], | ||
(allCells, left, right) => { | ||
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])] | ||
return allCells.filter(d => !leftAndRight.includes(d.columnId)) | ||
}, | ||
{ | ||
key: 'row.getCenterVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getLeftVisibleCells: memo( | ||
() => [ | ||
cell.row._getAllVisibleCells(), | ||
instance.getState().columnPinning.left, | ||
, | ||
], | ||
(allCells, left) => { | ||
const cells = (left ?? []) | ||
.map(columnId => allCells.find(cell => cell.columnId === columnId)!) | ||
.filter(Boolean) | ||
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>)) | ||
return cells | ||
}, | ||
{ | ||
key: 'row.getLeftVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getRightVisibleCells: memo( | ||
() => [ | ||
cell.row._getAllVisibleCells(), | ||
instance.getState().columnPinning.right, | ||
], | ||
(allCells, right) => { | ||
const cells = (right ?? []) | ||
.map(columnId => allCells.find(cell => cell.columnId === columnId)!) | ||
.filter(Boolean) | ||
.map(d => ({ ...d, position: 'left' } as Cell<TGenerics>)) | ||
return cells | ||
}, | ||
{ | ||
key: 'row.getRightVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
} | ||
}, | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
): ColumnPinningInstance<TGenerics> => { | ||
@@ -183,4 +322,56 @@ return { | ||
}, | ||
getLeftLeafColumns: memo( | ||
() => [ | ||
instance.getAllLeafColumns(), | ||
instance.getState().columnPinning.left, | ||
], | ||
(allColumns, left) => { | ||
return (left ?? []) | ||
.map(columnId => allColumns.find(column => column.id === columnId)!) | ||
.filter(Boolean) | ||
}, | ||
{ | ||
key: 'getLeftLeafColumns', | ||
debug: () => | ||
instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
getRightLeafColumns: memo( | ||
() => [ | ||
instance.getAllLeafColumns(), | ||
instance.getState().columnPinning.right, | ||
], | ||
(allColumns, right) => { | ||
return (right ?? []) | ||
.map(columnId => allColumns.find(column => column.id === columnId)!) | ||
.filter(Boolean) | ||
}, | ||
{ | ||
key: 'getRightLeafColumns', | ||
debug: () => | ||
instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
getCenterLeafColumns: memo( | ||
() => [ | ||
instance.getAllLeafColumns(), | ||
instance.getState().columnPinning.left, | ||
instance.getState().columnPinning.right, | ||
], | ||
(allColumns, left, right) => { | ||
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])] | ||
return allColumns.filter(d => !leftAndRight.includes(d.id)) | ||
}, | ||
{ | ||
key: 'getCenterLeafColumns', | ||
debug: () => | ||
instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
), | ||
} | ||
}, | ||
} |
@@ -123,3 +123,3 @@ import { | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
@@ -126,0 +126,0 @@ ): RowSelectionInstance<TGenerics> => { |
@@ -175,3 +175,3 @@ import { RowModel } from '..' | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
@@ -178,0 +178,0 @@ ): SortingInstance<TGenerics> => { |
@@ -10,2 +10,3 @@ import { | ||
Updater, | ||
Row, | ||
} from '../types' | ||
@@ -32,2 +33,5 @@ import { makeStateUpdater, memo, propGetter } from '../utils' | ||
getVisibleLeafColumns: () => Column<TGenerics>[] | ||
getLeftVisibleLeafColumns: () => Column<TGenerics>[] | ||
getRightVisibleLeafColumns: () => Column<TGenerics>[] | ||
getCenterVisibleLeafColumns: () => Column<TGenerics>[] | ||
setColumnVisibility: (updater: Updater<VisibilityState>) => void | ||
@@ -57,2 +61,3 @@ toggleColumnVisibility: (columnId: string, value?: boolean) => void | ||
export type VisibilityRow<TGenerics extends TableGenerics> = { | ||
_getAllVisibleCells: () => Cell<TGenerics>[] | ||
getVisibleCells: () => Cell<TGenerics>[] | ||
@@ -119,43 +124,85 @@ } | ||
getInstance: <TGenerics extends TableGenerics>( | ||
createRow: <TGenerics extends TableGenerics>( | ||
row: Row<TGenerics>, | ||
instance: TableInstance<TGenerics> | ||
): VisibilityInstance<TGenerics> => { | ||
): VisibilityRow<TGenerics> => { | ||
return { | ||
getVisibleFlatColumns: memo( | ||
_getAllVisibleCells: memo( | ||
() => [ | ||
instance.getAllFlatColumns(), | ||
instance | ||
.getAllFlatColumns() | ||
.filter(d => d.getIsVisible?.()) | ||
row | ||
.getAllCells() | ||
.filter(cell => cell.column.getIsVisible()) | ||
.map(d => d.id) | ||
.join('_'), | ||
], | ||
allFlatColumns => { | ||
return allFlatColumns.filter(d => d.getIsVisible?.()) | ||
_ => { | ||
return row.getAllCells().filter(cell => cell.column.getIsVisible()) | ||
}, | ||
{ | ||
key: 'getVisibleFlatColumns', | ||
debug: () => | ||
instance.options.debugAll ?? instance.options.debugColumns, | ||
key: 'row._getAllVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
getVisibleCells: memo( | ||
() => [ | ||
row.getLeftVisibleCells(), | ||
row.getCenterVisibleCells(), | ||
row.getRightVisibleCells(), | ||
], | ||
(left, center, right) => [...left, ...center, ...right], | ||
{ | ||
key: 'row.getVisibleCells', | ||
debug: () => instance.options.debugAll ?? instance.options.debugRows, | ||
} | ||
), | ||
} | ||
}, | ||
getVisibleLeafColumns: memo( | ||
createInstance: <TGenerics extends TableGenerics>( | ||
instance: TableInstance<TGenerics> | ||
): VisibilityInstance<TGenerics> => { | ||
const makeVisibleColumnsMethod = ( | ||
key: string, | ||
getColumns: () => Column<TGenerics>[] | ||
): (() => Column<TGenerics>[]) => { | ||
return memo( | ||
() => [ | ||
instance.getAllLeafColumns(), | ||
instance | ||
.getAllLeafColumns() | ||
.filter(d => d.getIsVisible?.()) | ||
getColumns(), | ||
getColumns() | ||
.filter(d => d.getIsVisible()) | ||
.map(d => d.id) | ||
.join('_'), | ||
], | ||
allFlatColumns => { | ||
return allFlatColumns.filter(d => d.getIsVisible?.()) | ||
columns => { | ||
return columns.filter(d => d.getIsVisible?.()) | ||
}, | ||
{ | ||
key: 'getVisibleLeafColumns', | ||
key, | ||
debug: () => | ||
instance.options.debugAll ?? instance.options.debugColumns, | ||
} | ||
) | ||
} | ||
return { | ||
getVisibleFlatColumns: makeVisibleColumnsMethod( | ||
'getVisibleFlatColumns', | ||
() => instance.getAllFlatColumns() | ||
), | ||
getVisibleLeafColumns: makeVisibleColumnsMethod( | ||
'getVisibleLeafColumns', | ||
() => instance.getAllLeafColumns() | ||
), | ||
getLeftVisibleLeafColumns: makeVisibleColumnsMethod( | ||
'getLeftVisibleLeafColumns', | ||
() => instance.getLeftLeafColumns() | ||
), | ||
getRightVisibleLeafColumns: makeVisibleColumnsMethod( | ||
'getRightVisibleLeafColumns', | ||
() => instance.getRightLeafColumns() | ||
), | ||
getCenterVisibleLeafColumns: makeVisibleColumnsMethod( | ||
'getCenterVisibleLeafColumns', | ||
() => instance.getCenterLeafColumns() | ||
), | ||
@@ -162,0 +209,0 @@ setColumnVisibility: updater => |
@@ -0,10 +1,4 @@ | ||
import { CoreOptions, CoreTableState, TableCore } from './core' | ||
import { ColumnsOptions, CoreColumn, CoreColumnDef } from './features/Columns' | ||
import { | ||
CoreColumn, | ||
CoreColumnDef, | ||
CoreOptions, | ||
CoreRow, | ||
CoreTableState, | ||
TableCore, | ||
} from './core' | ||
import { | ||
VisibilityInstance, | ||
@@ -27,5 +21,7 @@ VisibilityTableState, | ||
ColumnPinningOptions, | ||
ColumnPinningPosition, | ||
ColumnPinningRow, | ||
ColumnPinningTableState, | ||
} from './features/Pinning' | ||
import { HeadersInstance, HeadersRow } from './features/Headers' | ||
import { HeadersInstance } from './features/Headers' | ||
import { | ||
@@ -60,3 +56,3 @@ FiltersColumn, | ||
} from './features/Expanding' | ||
import { Overwrite, PartialKeys } from './utils' | ||
import { Overwrite } from './utils' | ||
import { | ||
@@ -81,3 +77,9 @@ ColumnSizingColumn, | ||
} from './features/RowSelection' | ||
import { ColumnsInstance } from './features/Columns' | ||
import { CellsInstance, CellsRow } from './features/Cells' | ||
import { CoreRow, RowsInstance, RowsOptions } from './features/Rows' | ||
export type Updater<T> = T | ((old: T) => T) | ||
export type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void | ||
export type TableGenerics = { | ||
@@ -102,5 +104,6 @@ Row?: any | ||
getInitialState?: () => any | ||
getInstance?: (instance: any) => any | ||
createInstance?: (instance: any) => any | ||
getDefaultColumn?: () => any | ||
createColumn?: (column: any, instance: any) => any | ||
createHeader?: (column: any, instance: any) => any | ||
createCell?: (cell: any, column: any, row: any, instance: any) => any | ||
@@ -112,2 +115,5 @@ createRow?: (row: any, instance: any) => any | ||
TableCore<TGenerics> & | ||
ColumnsInstance<TGenerics> & | ||
RowsInstance<TGenerics> & | ||
CellsInstance<TGenerics> & | ||
VisibilityInstance<TGenerics> & | ||
@@ -125,5 +131,5 @@ ColumnOrderInstance<TGenerics> & | ||
// | ||
export type Options<TGenerics extends TableGenerics> = CoreOptions<TGenerics> & | ||
ColumnsOptions<TGenerics> & | ||
RowsOptions<TGenerics> & | ||
VisibilityOptions & | ||
@@ -140,5 +146,2 @@ ColumnOrderOptions & | ||
export type Updater<T> = T | ((old: T) => T) | ||
export type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void | ||
export type TableState = CoreTableState & | ||
@@ -157,4 +160,5 @@ VisibilityTableState & | ||
export type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> & | ||
CellsRow<TGenerics> & | ||
VisibilityRow<TGenerics> & | ||
HeadersRow<TGenerics> & | ||
ColumnPinningRow<TGenerics> & | ||
GroupingRow & | ||
@@ -176,21 +180,2 @@ RowSelectionRow & | ||
// export type UserColumnDef<TGenerics extends TableGenerics> = Overwrite< | ||
// ColumnDef<TGenerics>, | ||
// GeneratedProperties<false> | ||
// > | ||
// type _GeneratedProperties = { | ||
// ['Column definitions should be generated with the table.createColumn() (and related) utilities']: false | ||
// } | ||
// export type GeneratedProperties<T> = T extends true | ||
// ? { | ||
// [TKey in keyof _GeneratedProperties]: true | ||
// } | ||
// : T extends false | ||
// ? { | ||
// [TKey in keyof _GeneratedProperties]?: false | ||
// } | ||
// : never | ||
export type Renderable<TGenerics extends TableGenerics, TProps> = | ||
@@ -237,5 +222,8 @@ | string | ||
id: string | ||
index: number | ||
depth: number | ||
column: Column<TGenerics> | ||
getWidth: () => number | ||
getStart: () => number | ||
getSize: () => number | ||
headerGroup: HeaderGroup<TGenerics> | ||
subHeaders: Header<TGenerics>[] | ||
@@ -242,0 +230,0 @@ colSpan?: number |
@@ -24,7 +24,5 @@ import { Getter, NoInfer, PropGetterValue, TableState, Updater } from './types' | ||
export type DataUpdateFunction<T> = (input: T) => T | ||
export function functionalUpdate<T>(updater: Updater<T>, input: T): T { | ||
return typeof updater === 'function' | ||
? (updater as DataUpdateFunction<T>)(input) | ||
? (updater as (input: T) => T)(input) | ||
: updater | ||
@@ -31,0 +29,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2646261
139
23857