@tanstack/svelte-table 8.0.0-alpha.79 → 8.0.0-alpha.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/svelte-table/src/index.js +5 -0
- package/build/cjs/svelte-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +94 -63
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +90 -64
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +38 -38
- package/build/types/index.d.ts +2 -2
- package/build/umd/index.development.js +94 -63
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +4 -13
|
@@ -128,10 +128,12 @@ exports.Pinning = index.Pinning;
|
|
|
128
128
|
exports.RowSelection = index.RowSelection;
|
|
129
129
|
exports.Sorting = index.Sorting;
|
|
130
130
|
exports.Visibility = index.Visibility;
|
|
131
|
+
exports.aggregationFns = index.aggregationFns;
|
|
131
132
|
exports.buildHeaderGroups = index.buildHeaderGroups;
|
|
132
133
|
exports.createTableFactory = index.createTableFactory;
|
|
133
134
|
exports.defaultColumnSizing = index.defaultColumnSizing;
|
|
134
135
|
exports.expandRows = index.expandRows;
|
|
136
|
+
exports.filterFns = index.filterFns;
|
|
135
137
|
exports.flattenBy = index.flattenBy;
|
|
136
138
|
exports.functionalUpdate = index.functionalUpdate;
|
|
137
139
|
exports.getCoreRowModel = index.getCoreRowModel;
|
|
@@ -146,12 +148,15 @@ exports.getSortedRowModel = index.getSortedRowModel;
|
|
|
146
148
|
exports.isFunction = index.isFunction;
|
|
147
149
|
exports.isRowSelected = index.isRowSelected;
|
|
148
150
|
exports.makeStateUpdater = index.makeStateUpdater;
|
|
151
|
+
exports.mean = index.mean;
|
|
149
152
|
exports.memo = index.memo;
|
|
150
153
|
exports.noop = index.noop;
|
|
151
154
|
exports.orderColumns = index.orderColumns;
|
|
152
155
|
exports.passiveEventSupported = index.passiveEventSupported;
|
|
156
|
+
exports.reSplitAlphaNumeric = index.reSplitAlphaNumeric;
|
|
153
157
|
exports.selectRowsFn = index.selectRowsFn;
|
|
154
158
|
exports.shouldAutoRemoveFilter = index.shouldAutoRemoveFilter;
|
|
159
|
+
exports.sortingFns = index.sortingFns;
|
|
155
160
|
exports.renderComponent = renderComponent.renderComponent;
|
|
156
161
|
exports.createTable = createTable;
|
|
157
162
|
exports.createTableInstance = createTableInstance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n createTableFactory,\n createTableInstance as coreCreateTableInstance,\n PartialKeys,\n Table,\n TableGenerics,\n TableOptions,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder.svelte'\nimport { SvelteComponent } from 'svelte/internal'\nimport { readable, writable, derived, Readable, get } from 'svelte/store'\nimport { renderComponent } from './render-component'\n\nexport { renderComponent } from './render-component'\n\nexport * from '@tanstack/table-core'\n\nfunction isSvelteServerComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$render === 'function' &&\n typeof component.render === 'function'\n )\n}\n\nfunction isSvelteClientComponent(component: any) {\n return component.prototype instanceof SvelteComponent\n}\n\nfunction isSvelteComponent(component: any) {\n if (typeof document === 'undefined') {\n return isSvelteServerComponent(component)\n } else {\n return isSvelteClientComponent(component)\n }\n}\n\nfunction wrapInPlaceholder(content: any) {\n return renderComponent(Placeholder, { content })\n}\n\nexport function render(component: any, props: any) {\n if (!component) return null\n\n if (isSvelteComponent(component)) {\n return renderComponent(component, props)\n }\n\n if (typeof component === 'function') {\n const result = component(props)\n\n if (isSvelteComponent(result)) {\n return result\n }\n\n return wrapInPlaceholder(result)\n }\n\n return wrapInPlaceholder(component)\n}\n\nexport const createTable = createTableFactory({ render })\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: ReadableOrVal
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n createTableFactory,\n createTableInstance as coreCreateTableInstance,\n PartialKeys,\n Table,\n TableGenerics,\n TableOptions,\n TableOptionsResolved,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder.svelte'\nimport { SvelteComponent } from 'svelte/internal'\nimport { readable, writable, derived, Readable, get } from 'svelte/store'\nimport { renderComponent } from './render-component'\n\nexport { renderComponent } from './render-component'\n\nexport * from '@tanstack/table-core'\n\nfunction isSvelteServerComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$render === 'function' &&\n typeof component.render === 'function'\n )\n}\n\nfunction isSvelteClientComponent(component: any) {\n return component.prototype instanceof SvelteComponent\n}\n\nfunction isSvelteComponent(component: any) {\n if (typeof document === 'undefined') {\n return isSvelteServerComponent(component)\n } else {\n return isSvelteClientComponent(component)\n }\n}\n\nfunction wrapInPlaceholder(content: any) {\n return renderComponent(Placeholder, { content })\n}\n\nexport function render(component: any, props: any) {\n if (!component) return null\n\n if (isSvelteComponent(component)) {\n return renderComponent(component, props)\n }\n\n if (typeof component === 'function') {\n const result = component(props)\n\n if (isSvelteComponent(result)) {\n return result\n }\n\n return wrapInPlaceholder(result)\n }\n\n return wrapInPlaceholder(component)\n}\n\nexport const createTable = createTableFactory({ render })\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: ReadableOrVal<TableOptions<TGenerics>>\n) {\n let optionsStore: Readable<TableOptions<TGenerics>>\n\n if ('subscribe' in options) {\n optionsStore = options\n } else {\n optionsStore = readable(options)\n }\n\n let resolvedOptions: TableOptionsResolved<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...get(optionsStore),\n }\n\n let instance = coreCreateTableInstance(resolvedOptions)\n\n let stateStore = writable(/** @type {number} */ instance.initialState)\n // combine stores\n let stateOptionsStore = derived([stateStore, optionsStore], s => s)\n const instanceReadable = readable(instance, function start(set) {\n const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {\n instance.setOptions(prev => {\n return {\n ...prev,\n ...options,\n state: { ...state, ...options.state },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n if (updater instanceof Function) {\n stateStore.update(updater)\n } else {\n stateStore.set(updater)\n }\n\n resolvedOptions.onStateChange?.(updater)\n },\n }\n })\n\n // it didn't seem to rerender without setting the instance\n set(instance)\n })\n\n return function stop() {\n unsubscribe()\n }\n })\n\n return instanceReadable\n}\n"],"names":["isSvelteServerComponent","component","$$render","render","isSvelteClientComponent","prototype","SvelteComponent","isSvelteComponent","document","wrapInPlaceholder","content","renderComponent","Placeholder","props","result","createTable","createTableFactory","createTableInstance","table","options","optionsStore","readable","resolvedOptions","state","onStateChange","get","instance","coreCreateTableInstance","stateStore","writable","initialState","stateOptionsStore","derived","s","instanceReadable","start","set","unsubscribe","subscribe","setOptions","prev","updater","Function","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,SAASA,uBAAT,CAAiCC,SAAjC,EAAiD;AAC/C,EAAA,OACE,OAAOA,SAAP,KAAqB,QAArB,IACA,OAAOA,SAAS,CAACC,QAAjB,KAA8B,UAD9B,IAEA,OAAOD,SAAS,CAACE,MAAjB,KAA4B,UAH9B,CAAA;AAKD,CAAA;;AAED,SAASC,uBAAT,CAAiCH,SAAjC,EAAiD;AAC/C,EAAA,OAAOA,SAAS,CAACI,SAAV,YAA+BC,wBAAtC,CAAA;AACD,CAAA;;AAED,SAASC,iBAAT,CAA2BN,SAA3B,EAA2C;AACzC,EAAA,IAAI,OAAOO,QAAP,KAAoB,WAAxB,EAAqC;AACnC,IAAOR,OAAAA,uBAAuB,CAACC,SAAD,CAA9B,CAAA;AACD,GAFD,MAEO;AACL,IAAOG,OAAAA,uBAAuB,CAACH,SAAD,CAA9B,CAAA;AACD,GAA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AP,CAAA;AAgBD,OAjBD,EADoE;;AAqBpEL,MAAAA,GAAG,CAACV,QAAD,CAAH,CAAA;AACD,KAtBmB,CAApB,CAAA;AAwBA,IAAO,OAAA,SAASkB,IAAT,GAAgB;AACrBP,MAAAA,WAAW,EAAA,CAAA;AACZ,KAFD,CAAA;AAGD,GA5BgC,CAAjC,CAAA;AA8BA,EAAA,OAAOH,gBAAP,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -103,7 +103,7 @@ function memo(getDeps, fn, opts) {
|
|
|
103
103
|
const Columns = {
|
|
104
104
|
createInstance: instance => {
|
|
105
105
|
return {
|
|
106
|
-
|
|
106
|
+
getDefaultColumnDef: memo(() => [instance.options.defaultColumnDef], defaultColumn => {
|
|
107
107
|
var _defaultColumn;
|
|
108
108
|
|
|
109
109
|
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
@@ -116,7 +116,7 @@ const Columns = {
|
|
|
116
116
|
return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
|
|
117
117
|
},
|
|
118
118
|
...instance._features.reduce((obj, feature) => {
|
|
119
|
-
return Object.assign(obj, feature.
|
|
119
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
120
120
|
}, {}),
|
|
121
121
|
...defaultColumn
|
|
122
122
|
};
|
|
@@ -126,13 +126,16 @@ const Columns = {
|
|
|
126
126
|
|
|
127
127
|
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
128
128
|
},
|
|
129
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
129
|
+
key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
|
|
130
130
|
}),
|
|
131
131
|
getColumnDefs: () => instance.options.columns,
|
|
132
132
|
createColumn: (columnDef, depth, parent) => {
|
|
133
133
|
var _ref, _columnDef$id;
|
|
134
134
|
|
|
135
|
-
const
|
|
135
|
+
const defaultColumnDef = instance.getDefaultColumnDef();
|
|
136
|
+
columnDef = { ...defaultColumnDef,
|
|
137
|
+
...columnDef
|
|
138
|
+
};
|
|
136
139
|
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
137
140
|
let accessorFn;
|
|
138
141
|
|
|
@@ -150,8 +153,7 @@ const Columns = {
|
|
|
150
153
|
throw new Error();
|
|
151
154
|
}
|
|
152
155
|
|
|
153
|
-
let column = { ...
|
|
154
|
-
...columnDef,
|
|
156
|
+
let column = { ...columnDef,
|
|
155
157
|
id: "" + id,
|
|
156
158
|
accessorFn,
|
|
157
159
|
parent: parent,
|
|
@@ -300,7 +302,7 @@ const Rows = {
|
|
|
300
302
|
const column = instance.getColumn(columnId);
|
|
301
303
|
|
|
302
304
|
if (!column.accessorFn) {
|
|
303
|
-
|
|
305
|
+
return undefined;
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
@@ -387,7 +389,7 @@ const Cells = {
|
|
|
387
389
|
row,
|
|
388
390
|
column,
|
|
389
391
|
getValue: () => row.getValue(columnId),
|
|
390
|
-
renderCell: () => column.cell ? instance._render(column.cell, {
|
|
392
|
+
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
391
393
|
instance,
|
|
392
394
|
column,
|
|
393
395
|
row,
|
|
@@ -446,7 +448,7 @@ const getDefaultColumnSizingInfoState = () => ({
|
|
|
446
448
|
});
|
|
447
449
|
|
|
448
450
|
const ColumnSizing = {
|
|
449
|
-
|
|
451
|
+
getDefaultColumnDef: () => {
|
|
450
452
|
return defaultColumnSizing;
|
|
451
453
|
},
|
|
452
454
|
getInitialState: state => {
|
|
@@ -466,10 +468,10 @@ const ColumnSizing = {
|
|
|
466
468
|
createColumn: (column, instance) => {
|
|
467
469
|
return {
|
|
468
470
|
getSize: () => {
|
|
469
|
-
var _column$
|
|
471
|
+
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
470
472
|
|
|
471
473
|
const columnSize = instance.getState().columnSizing[column.id];
|
|
472
|
-
return Math.min(Math.max((_column$
|
|
474
|
+
return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
|
|
473
475
|
},
|
|
474
476
|
getStart: position => {
|
|
475
477
|
const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
|
|
@@ -492,9 +494,9 @@ const ColumnSizing = {
|
|
|
492
494
|
});
|
|
493
495
|
},
|
|
494
496
|
getCanResize: () => {
|
|
495
|
-
var _column$
|
|
497
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
496
498
|
|
|
497
|
-
return ((_column$
|
|
499
|
+
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
|
|
498
500
|
},
|
|
499
501
|
getIsResizing: () => {
|
|
500
502
|
return instance.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
@@ -951,7 +953,7 @@ function testFalsey(val) {
|
|
|
951
953
|
|
|
952
954
|
//
|
|
953
955
|
const Filters = {
|
|
954
|
-
|
|
956
|
+
getDefaultColumnDef: () => {
|
|
955
957
|
return {
|
|
956
958
|
filterFn: 'auto'
|
|
957
959
|
};
|
|
@@ -994,6 +996,10 @@ const Filters = {
|
|
|
994
996
|
return filterFns.inNumberRange;
|
|
995
997
|
}
|
|
996
998
|
|
|
999
|
+
if (typeof value === 'boolean') {
|
|
1000
|
+
return filterFns.equals;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
997
1003
|
if (value !== null && typeof value === 'object') {
|
|
998
1004
|
return filterFns.equals;
|
|
999
1005
|
}
|
|
@@ -1011,14 +1017,14 @@ const Filters = {
|
|
|
1011
1017
|
return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
|
|
1012
1018
|
},
|
|
1013
1019
|
getCanFilter: () => {
|
|
1014
|
-
var _column$
|
|
1020
|
+
var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
|
|
1015
1021
|
|
|
1016
|
-
return ((_column$
|
|
1022
|
+
return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnFilters) != null ? _instance$options$ena : true) && ((_instance$options$ena2 = instance.options.enableFilters) != null ? _instance$options$ena2 : true) && !!column.accessorFn;
|
|
1017
1023
|
},
|
|
1018
1024
|
getCanGlobalFilter: () => {
|
|
1019
|
-
var _column$
|
|
1025
|
+
var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
|
|
1020
1026
|
|
|
1021
|
-
return ((_column$
|
|
1027
|
+
return ((_column$columnDef$ena2 = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena2 : true) && ((_instance$options$ena3 = instance.options.enableGlobalFilter) != null ? _instance$options$ena3 : true) && ((_instance$options$ena4 = instance.options.enableFilters) != null ? _instance$options$ena4 : true) && ((_instance$options$get = instance.options.getColumnCanGlobalFilter == null ? void 0 : instance.options.getColumnCanGlobalFilter(column)) != null ? _instance$options$get : true) && !!column.accessorFn;
|
|
1022
1028
|
},
|
|
1023
1029
|
getIsFiltered: () => column.getFilterIndex() > -1,
|
|
1024
1030
|
getFilterValue: () => {
|
|
@@ -1097,7 +1103,8 @@ const Filters = {
|
|
|
1097
1103
|
},
|
|
1098
1104
|
createRow: (row, instance) => {
|
|
1099
1105
|
return {
|
|
1100
|
-
|
|
1106
|
+
columnFilters: {},
|
|
1107
|
+
columnFiltersMeta: {},
|
|
1101
1108
|
subRowsByFacetId: {}
|
|
1102
1109
|
};
|
|
1103
1110
|
},
|
|
@@ -1295,7 +1302,7 @@ function count(getLeafValues) {
|
|
|
1295
1302
|
|
|
1296
1303
|
//
|
|
1297
1304
|
const Grouping = {
|
|
1298
|
-
|
|
1305
|
+
getDefaultColumnDef: () => {
|
|
1299
1306
|
return {
|
|
1300
1307
|
aggregationFn: 'auto'
|
|
1301
1308
|
};
|
|
@@ -1325,9 +1332,9 @@ const Grouping = {
|
|
|
1325
1332
|
});
|
|
1326
1333
|
},
|
|
1327
1334
|
getCanGroup: () => {
|
|
1328
|
-
var _ref, _ref2, _ref3, _column$
|
|
1335
|
+
var _ref, _ref2, _ref3, _column$columnDef$ena;
|
|
1329
1336
|
|
|
1330
|
-
return (_ref = (_ref2 = (_ref3 = (_column$
|
|
1337
|
+
return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
|
|
1331
1338
|
},
|
|
1332
1339
|
getIsGrouped: () => {
|
|
1333
1340
|
var _instance$getState$gr;
|
|
@@ -1411,9 +1418,9 @@ const Grouping = {
|
|
|
1411
1418
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
1412
1419
|
},
|
|
1413
1420
|
renderAggregatedCell: () => {
|
|
1414
|
-
var _column$
|
|
1421
|
+
var _column$columnDef$agg;
|
|
1415
1422
|
|
|
1416
|
-
const template = (_column$
|
|
1423
|
+
const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
|
|
1417
1424
|
return template ? instance._render(template, {
|
|
1418
1425
|
instance,
|
|
1419
1426
|
column,
|
|
@@ -1720,9 +1727,9 @@ const Pinning = {
|
|
|
1720
1727
|
getCanPin: () => {
|
|
1721
1728
|
const leafColumns = column.getLeafColumns();
|
|
1722
1729
|
return leafColumns.some(d => {
|
|
1723
|
-
var _d$
|
|
1730
|
+
var _d$columnDef$enablePi, _instance$options$ena;
|
|
1724
1731
|
|
|
1725
|
-
return ((_d$
|
|
1732
|
+
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
|
|
1726
1733
|
});
|
|
1727
1734
|
},
|
|
1728
1735
|
getIsPinned: () => {
|
|
@@ -1792,12 +1799,18 @@ const Pinning = {
|
|
|
1792
1799
|
|
|
1793
1800
|
return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
|
|
1794
1801
|
},
|
|
1795
|
-
getIsSomeColumnsPinned:
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1802
|
+
getIsSomeColumnsPinned: position => {
|
|
1803
|
+
var _pinningState$positio;
|
|
1804
|
+
|
|
1805
|
+
const pinningState = instance.getState().columnPinning;
|
|
1806
|
+
|
|
1807
|
+
if (!position) {
|
|
1808
|
+
var _pinningState$left, _pinningState$right;
|
|
1809
|
+
|
|
1810
|
+
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1801
1814
|
},
|
|
1802
1815
|
getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
|
|
1803
1816
|
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
@@ -2323,7 +2336,7 @@ const Sorting = {
|
|
|
2323
2336
|
...state
|
|
2324
2337
|
};
|
|
2325
2338
|
},
|
|
2326
|
-
|
|
2339
|
+
getDefaultColumnDef: () => {
|
|
2327
2340
|
return {
|
|
2328
2341
|
sortingFn: 'auto'
|
|
2329
2342
|
};
|
|
@@ -2339,7 +2352,7 @@ const Sorting = {
|
|
|
2339
2352
|
createColumn: (column, instance) => {
|
|
2340
2353
|
return {
|
|
2341
2354
|
getAutoSortingFn: () => {
|
|
2342
|
-
const firstRows = instance.getFilteredRowModel().flatRows.slice(
|
|
2355
|
+
const firstRows = instance.getFilteredRowModel().flatRows.slice(10);
|
|
2343
2356
|
let isString = false;
|
|
2344
2357
|
|
|
2345
2358
|
for (const row of firstRows) {
|
|
@@ -2383,7 +2396,7 @@ const Sorting = {
|
|
|
2383
2396
|
throw new Error();
|
|
2384
2397
|
}
|
|
2385
2398
|
|
|
2386
|
-
return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
|
|
2399
|
+
return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.columnDef.sortingFn]) != null ? _ref : sortingFns[column.columnDef.sortingFn];
|
|
2387
2400
|
},
|
|
2388
2401
|
toggleSorting: (desc, multi) => {
|
|
2389
2402
|
// if (column.columns.length) {
|
|
@@ -2395,7 +2408,7 @@ const Sorting = {
|
|
|
2395
2408
|
// return
|
|
2396
2409
|
// }
|
|
2397
2410
|
instance.setSorting(old => {
|
|
2398
|
-
var _ref2, _column$
|
|
2411
|
+
var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
|
|
2399
2412
|
|
|
2400
2413
|
// Find any existing sorting for this column
|
|
2401
2414
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
@@ -2422,7 +2435,7 @@ const Sorting = {
|
|
|
2422
2435
|
}
|
|
2423
2436
|
}
|
|
2424
2437
|
|
|
2425
|
-
const sortDescFirst = (_ref2 = (_column$
|
|
2438
|
+
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
|
|
2426
2439
|
|
|
2427
2440
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2428
2441
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
@@ -2466,14 +2479,14 @@ const Sorting = {
|
|
|
2466
2479
|
});
|
|
2467
2480
|
},
|
|
2468
2481
|
getCanSort: () => {
|
|
2469
|
-
var _column$
|
|
2482
|
+
var _column$columnDef$ena, _instance$options$ena3;
|
|
2470
2483
|
|
|
2471
|
-
return ((_column$
|
|
2484
|
+
return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
|
|
2472
2485
|
},
|
|
2473
2486
|
getCanMultiSort: () => {
|
|
2474
|
-
var _ref3, _column$
|
|
2487
|
+
var _ref3, _column$columnDef$ena2;
|
|
2475
2488
|
|
|
2476
|
-
return (_ref3 = (_column$
|
|
2489
|
+
return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
|
|
2477
2490
|
},
|
|
2478
2491
|
getIsSorted: () => {
|
|
2479
2492
|
var _instance$getState$so;
|
|
@@ -2537,7 +2550,7 @@ const Visibility = {
|
|
|
2537
2550
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2538
2551
|
};
|
|
2539
2552
|
},
|
|
2540
|
-
|
|
2553
|
+
getDefaultColumnDef: () => {
|
|
2541
2554
|
return {
|
|
2542
2555
|
defaultIsVisible: true
|
|
2543
2556
|
};
|
|
@@ -2557,9 +2570,9 @@ const Visibility = {
|
|
|
2557
2570
|
return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
|
|
2558
2571
|
},
|
|
2559
2572
|
getCanHide: () => {
|
|
2560
|
-
var _column$
|
|
2573
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
2561
2574
|
|
|
2562
|
-
return ((_column$
|
|
2575
|
+
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
|
|
2563
2576
|
},
|
|
2564
2577
|
getToggleVisibilityHandler: () => {
|
|
2565
2578
|
return e => {
|
|
@@ -2670,12 +2683,12 @@ const Headers = {
|
|
|
2670
2683
|
recurseHeader(header);
|
|
2671
2684
|
return leafHeaders;
|
|
2672
2685
|
},
|
|
2673
|
-
renderHeader: () => column.header ? instance._render(column.header, {
|
|
2686
|
+
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
2674
2687
|
instance,
|
|
2675
2688
|
header: header,
|
|
2676
2689
|
column
|
|
2677
2690
|
}) : null,
|
|
2678
|
-
renderFooter: () => column.footer ? instance._render(column.footer, {
|
|
2691
|
+
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
2679
2692
|
instance,
|
|
2680
2693
|
header: header,
|
|
2681
2694
|
column
|
|
@@ -3183,10 +3196,11 @@ function createTable(_, __, options) {
|
|
|
3183
3196
|
throw new Error('');
|
|
3184
3197
|
})()
|
|
3185
3198
|
},
|
|
3186
|
-
setGenerics: () => table,
|
|
3199
|
+
// setGenerics: () => table as any,
|
|
3187
3200
|
setRowType: () => table,
|
|
3188
3201
|
setTableMetaType: () => table,
|
|
3189
3202
|
setColumnMetaType: () => table,
|
|
3203
|
+
setFilterMetaType: () => table,
|
|
3190
3204
|
setOptions: newOptions => createTable(_, __, { ...options,
|
|
3191
3205
|
...newOptions
|
|
3192
3206
|
}),
|
|
@@ -3218,7 +3232,8 @@ function createTable(_, __, options) {
|
|
|
3218
3232
|
}
|
|
3219
3233
|
|
|
3220
3234
|
throw new Error('Invalid accessor');
|
|
3221
|
-
}
|
|
3235
|
+
},
|
|
3236
|
+
createOptions: options => options
|
|
3222
3237
|
};
|
|
3223
3238
|
return table;
|
|
3224
3239
|
}
|
|
@@ -3314,7 +3329,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3314
3329
|
|
|
3315
3330
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3316
3331
|
newRow = instance.createRow(row.id, row.original, row.index, row.depth);
|
|
3317
|
-
newRow.
|
|
3332
|
+
newRow.columnFilters = row.columnFilters;
|
|
3318
3333
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3319
3334
|
|
|
3320
3335
|
if (!newRow.subRows.length) {
|
|
@@ -3387,6 +3402,11 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
|
3387
3402
|
function getFilteredRowModel() {
|
|
3388
3403
|
return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
|
|
3389
3404
|
if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
3405
|
+
for (let i = 0; i < rowModel.flatRows.length; i++) {
|
|
3406
|
+
rowModel.flatRows[i].columnFilters = {};
|
|
3407
|
+
rowModel.flatRows[i].columnFiltersMeta = {};
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3390
3410
|
return rowModel;
|
|
3391
3411
|
}
|
|
3392
3412
|
|
|
@@ -3441,28 +3461,34 @@ function getFilteredRowModel() {
|
|
|
3441
3461
|
|
|
3442
3462
|
for (let j = 0; j < rowModel.flatRows.length; j++) {
|
|
3443
3463
|
const row = rowModel.flatRows[j];
|
|
3444
|
-
row.
|
|
3464
|
+
row.columnFilters = {};
|
|
3445
3465
|
|
|
3446
3466
|
if (resolvedColumnFilters.length) {
|
|
3447
3467
|
for (let i = 0; i < resolvedColumnFilters.length; i++) {
|
|
3448
|
-
currentColumnFilter = resolvedColumnFilters[i];
|
|
3468
|
+
currentColumnFilter = resolvedColumnFilters[i];
|
|
3469
|
+
const id = currentColumnFilter.id; // Tag the row with the column filter state
|
|
3449
3470
|
|
|
3450
|
-
row.
|
|
3471
|
+
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
|
|
3472
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
3473
|
+
});
|
|
3451
3474
|
}
|
|
3452
3475
|
}
|
|
3453
3476
|
|
|
3454
3477
|
if (resolvedGlobalFilters.length) {
|
|
3455
3478
|
for (let i = 0; i < resolvedGlobalFilters.length; i++) {
|
|
3456
|
-
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
3479
|
+
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
3480
|
+
const id = currentGlobalFilter.id; // Tag the row with the first truthy global filter state
|
|
3457
3481
|
|
|
3458
|
-
if (currentGlobalFilter.filterFn(row,
|
|
3459
|
-
row.
|
|
3482
|
+
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
|
|
3483
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
3484
|
+
})) {
|
|
3485
|
+
row.columnFilters.__global__ = true;
|
|
3460
3486
|
break;
|
|
3461
3487
|
}
|
|
3462
3488
|
}
|
|
3463
3489
|
|
|
3464
|
-
if (row.
|
|
3465
|
-
row.
|
|
3490
|
+
if (row.columnFilters.__global__ !== true) {
|
|
3491
|
+
row.columnFilters.__global__ = false;
|
|
3466
3492
|
}
|
|
3467
3493
|
}
|
|
3468
3494
|
}
|
|
@@ -3470,7 +3496,7 @@ function getFilteredRowModel() {
|
|
|
3470
3496
|
const filterRowsImpl = row => {
|
|
3471
3497
|
// Horizontally filter rows through each column
|
|
3472
3498
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
3473
|
-
if (row.
|
|
3499
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3474
3500
|
return false;
|
|
3475
3501
|
}
|
|
3476
3502
|
}
|
|
@@ -3504,7 +3530,7 @@ function getFacetedRowModel() {
|
|
|
3504
3530
|
const filterRowsImpl = row => {
|
|
3505
3531
|
// Horizontally filter rows through each column
|
|
3506
3532
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
3507
|
-
if (row.
|
|
3533
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3508
3534
|
return false;
|
|
3509
3535
|
}
|
|
3510
3536
|
}
|
|
@@ -3604,8 +3630,8 @@ function getSortedRowModel() {
|
|
|
3604
3630
|
availableSorting.forEach(sortEntry => {
|
|
3605
3631
|
const column = instance.getColumn(sortEntry.id);
|
|
3606
3632
|
columnInfoById[sortEntry.id] = {
|
|
3607
|
-
sortUndefined: column.sortUndefined,
|
|
3608
|
-
invertSorting: column.invertSorting,
|
|
3633
|
+
sortUndefined: column.columnDef.sortUndefined,
|
|
3634
|
+
invertSorting: column.columnDef.invertSorting,
|
|
3609
3635
|
sortingFn: column.getSortingFn()
|
|
3610
3636
|
};
|
|
3611
3637
|
});
|
|
@@ -3753,8 +3779,8 @@ function getGroupedRowModel() {
|
|
|
3753
3779
|
row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
|
|
3754
3780
|
let columnValue = row.getValue(columnId);
|
|
3755
3781
|
|
|
3756
|
-
if (!depth && column.aggregateValue) {
|
|
3757
|
-
columnValue = column.aggregateValue(columnValue);
|
|
3782
|
+
if (!depth && column.columnDef.aggregateValue) {
|
|
3783
|
+
columnValue = column.columnDef.aggregateValue(columnValue);
|
|
3758
3784
|
}
|
|
3759
3785
|
|
|
3760
3786
|
return columnValue;
|
|
@@ -3923,11 +3949,13 @@ exports.Pinning = Pinning;
|
|
|
3923
3949
|
exports.RowSelection = RowSelection;
|
|
3924
3950
|
exports.Sorting = Sorting;
|
|
3925
3951
|
exports.Visibility = Visibility;
|
|
3952
|
+
exports.aggregationFns = aggregationFns;
|
|
3926
3953
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
3927
3954
|
exports.createTableFactory = createTableFactory;
|
|
3928
3955
|
exports.createTableInstance = createTableInstance;
|
|
3929
3956
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
3930
3957
|
exports.expandRows = expandRows;
|
|
3958
|
+
exports.filterFns = filterFns;
|
|
3931
3959
|
exports.flattenBy = flattenBy;
|
|
3932
3960
|
exports.functionalUpdate = functionalUpdate;
|
|
3933
3961
|
exports.getCoreRowModel = getCoreRowModel;
|
|
@@ -3942,10 +3970,13 @@ exports.getSortedRowModel = getSortedRowModel;
|
|
|
3942
3970
|
exports.isFunction = isFunction;
|
|
3943
3971
|
exports.isRowSelected = isRowSelected;
|
|
3944
3972
|
exports.makeStateUpdater = makeStateUpdater;
|
|
3973
|
+
exports.mean = mean;
|
|
3945
3974
|
exports.memo = memo;
|
|
3946
3975
|
exports.noop = noop;
|
|
3947
3976
|
exports.orderColumns = orderColumns;
|
|
3948
3977
|
exports.passiveEventSupported = passiveEventSupported;
|
|
3978
|
+
exports.reSplitAlphaNumeric = reSplitAlphaNumeric;
|
|
3949
3979
|
exports.selectRowsFn = selectRowsFn;
|
|
3950
3980
|
exports.shouldAutoRemoveFilter = shouldAutoRemoveFilter;
|
|
3981
|
+
exports.sortingFns = sortingFns;
|
|
3951
3982
|
//# sourceMappingURL=index.js.map
|