@tanstack/table-core 8.0.0-alpha.13 → 8.0.0-alpha.18
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/core.js +17 -6
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +17 -9
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +2 -2
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +2 -2
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +6 -7
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +13 -2
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +4 -4
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +1 -4
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/types.js +0 -3
- package/build/cjs/types.js.map +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js +1 -1
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/paginateRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +0 -24
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +63 -55
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +270 -284
- package/build/types/core.d.ts +11 -9
- package/build/types/createTable.d.ts +24 -14
- package/build/types/features/ColumnSizing.d.ts +2 -3
- package/build/types/features/Filters.d.ts +4 -4
- package/build/types/features/Grouping.d.ts +11 -5
- package/build/types/features/RowSelection.d.ts +2 -3
- package/build/types/features/Visibility.d.ts +1 -0
- package/build/types/types.d.ts +14 -7
- package/build/types/utils/columnFilterRowsFn.d.ts +2 -2
- package/build/types/utils/expandRowsFn.d.ts +2 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +2 -2
- package/build/types/utils/groupRowsFn.d.ts +2 -2
- package/build/types/utils/paginateRowsFn.d.ts +2 -2
- package/build/types/utils/sortRowsFn.d.ts +2 -2
- package/build/types/utils.d.ts +4 -5
- package/build/umd/index.development.js +67 -64
- 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 +1 -1
- package/src/core.tsx +63 -35
- package/src/createTable.tsx +49 -31
- package/src/features/ColumnSizing.ts +8 -14
- package/src/features/Expanding.ts +2 -2
- package/src/features/Filters.ts +9 -9
- package/src/features/Grouping.ts +30 -7
- package/src/features/Headers.ts +15 -3
- package/src/features/RowSelection.ts +2 -2
- package/src/features/Visibility.ts +1 -0
- package/src/types.ts +28 -15
- package/src/utils/columnFilterRowsFn.ts +3 -5
- package/src/utils/expandRowsFn.ts +2 -2
- package/src/utils/globalFilterRowsFn.ts +2 -2
- package/src/utils/groupRowsFn.ts +4 -4
- package/src/utils/paginateRowsFn.ts +2 -2
- package/src/utils/sortRowsFn.ts +2 -2
- package/src/utils.tsx +6 -45
|
@@ -9,14 +9,10 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports
|
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports'
|
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TableCore = {}
|
|
15
|
-
})(this, (function (exports
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TableCore = {}));
|
|
15
|
+
})(this, (function (exports) { 'use strict';
|
|
20
16
|
|
|
21
17
|
function _extends() {
|
|
22
18
|
_extends = Object.assign || function (target) {
|
|
@@ -210,24 +206,6 @@
|
|
|
210
206
|
|
|
211
207
|
return result;
|
|
212
208
|
};
|
|
213
|
-
}
|
|
214
|
-
function flexRender(Comp, props) {
|
|
215
|
-
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default["default"].createElement(Comp, props) : Comp;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function isReactComponent(component) {
|
|
219
|
-
return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function isClassComponent(component) {
|
|
223
|
-
return typeof component === 'function' && function () {
|
|
224
|
-
var proto = Object.getPrototypeOf(component);
|
|
225
|
-
return proto.prototype && proto.prototype.isReactComponent;
|
|
226
|
-
}();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function isExoticComponent(component) {
|
|
230
|
-
return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
|
|
231
209
|
} // export function hashString(str: string, seed = 0): string {
|
|
232
210
|
// let h1 = 0xdeadbeef ^ seed,
|
|
233
211
|
// h2 = 0x41c6ce57 ^ seed
|
|
@@ -245,9 +223,6 @@
|
|
|
245
223
|
// return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
|
|
246
224
|
// }
|
|
247
225
|
|
|
248
|
-
// declare global {
|
|
249
|
-
// const "development" !== 'production': boolean
|
|
250
|
-
// }
|
|
251
226
|
//
|
|
252
227
|
var Please_use_the_create_table_column_utilities_to_define_columns = Symbol();
|
|
253
228
|
|
|
@@ -645,7 +620,6 @@
|
|
|
645
620
|
var initialProps = {
|
|
646
621
|
title: canGroup ? 'Toggle Grouping' : undefined,
|
|
647
622
|
onClick: canGroup ? function (e) {
|
|
648
|
-
e.persist();
|
|
649
623
|
column.toggleGrouping == null ? void 0 : column.toggleGrouping();
|
|
650
624
|
} : undefined
|
|
651
625
|
};
|
|
@@ -687,7 +661,7 @@
|
|
|
687
661
|
}
|
|
688
662
|
};
|
|
689
663
|
},
|
|
690
|
-
createCell: function createCell(cell, column, row,
|
|
664
|
+
createCell: function createCell(cell, column, row, instance) {
|
|
691
665
|
return {
|
|
692
666
|
getIsGrouped: function getIsGrouped() {
|
|
693
667
|
return column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
@@ -699,6 +673,18 @@
|
|
|
699
673
|
var _row$subRows;
|
|
700
674
|
|
|
701
675
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
676
|
+
},
|
|
677
|
+
renderAggregatedCell: function renderAggregatedCell() {
|
|
678
|
+
var _column$aggregatedCel;
|
|
679
|
+
|
|
680
|
+
var template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
|
|
681
|
+
return template ? instance.render(template, {
|
|
682
|
+
instance: instance,
|
|
683
|
+
column: column,
|
|
684
|
+
row: row,
|
|
685
|
+
cell: cell,
|
|
686
|
+
value: cell.value
|
|
687
|
+
}) : null;
|
|
702
688
|
}
|
|
703
689
|
};
|
|
704
690
|
},
|
|
@@ -1144,11 +1130,11 @@
|
|
|
1144
1130
|
draggable: false,
|
|
1145
1131
|
role: 'separator',
|
|
1146
1132
|
onMouseDown: function onMouseDown(e) {
|
|
1147
|
-
e.persist();
|
|
1133
|
+
e.persist == null ? void 0 : e.persist();
|
|
1148
1134
|
onResizeStart(e);
|
|
1149
1135
|
},
|
|
1150
1136
|
onTouchStart: function onTouchStart(e) {
|
|
1151
|
-
e.persist();
|
|
1137
|
+
e.persist == null ? void 0 : e.persist();
|
|
1152
1138
|
onResizeStart(e);
|
|
1153
1139
|
}
|
|
1154
1140
|
} : {};
|
|
@@ -1353,18 +1339,18 @@
|
|
|
1353
1339
|
return instance.getFooterProps(header.id, userProps);
|
|
1354
1340
|
},
|
|
1355
1341
|
renderHeader: function renderHeader() {
|
|
1356
|
-
return
|
|
1342
|
+
return column.header ? instance.render(column.header, {
|
|
1357
1343
|
instance: instance,
|
|
1358
1344
|
header: header,
|
|
1359
1345
|
column: column
|
|
1360
|
-
});
|
|
1346
|
+
}) : null;
|
|
1361
1347
|
},
|
|
1362
1348
|
renderFooter: function renderFooter() {
|
|
1363
|
-
return
|
|
1349
|
+
return column.footer ? instance.render(column.footer, {
|
|
1364
1350
|
instance: instance,
|
|
1365
1351
|
header: header,
|
|
1366
1352
|
column: column
|
|
1367
|
-
});
|
|
1353
|
+
}) : null;
|
|
1368
1354
|
}
|
|
1369
1355
|
}; // Yes, we have to convert instance to unknown, because we know more than the compiler here.
|
|
1370
1356
|
|
|
@@ -1983,12 +1969,12 @@
|
|
|
1983
1969
|
}
|
|
1984
1970
|
|
|
1985
1971
|
//
|
|
1986
|
-
function getDefaultColumn() {
|
|
1987
|
-
return {
|
|
1988
|
-
filterType: 'auto'
|
|
1989
|
-
};
|
|
1990
|
-
}
|
|
1991
1972
|
var Filters = {
|
|
1973
|
+
getDefaultColumn: function getDefaultColumn() {
|
|
1974
|
+
return {
|
|
1975
|
+
filterType: 'auto'
|
|
1976
|
+
};
|
|
1977
|
+
},
|
|
1992
1978
|
getInitialState: function getInitialState() {
|
|
1993
1979
|
return {
|
|
1994
1980
|
columnFilters: [],
|
|
@@ -2234,7 +2220,7 @@
|
|
|
2234
2220
|
|
|
2235
2221
|
if (!column) {
|
|
2236
2222
|
{
|
|
2237
|
-
console.warn("
|
|
2223
|
+
console.warn("Table: Could not find a column with id: " + columnId);
|
|
2238
2224
|
}
|
|
2239
2225
|
|
|
2240
2226
|
throw new Error();
|
|
@@ -2875,7 +2861,7 @@
|
|
|
2875
2861
|
|
|
2876
2862
|
if (!row) {
|
|
2877
2863
|
{
|
|
2878
|
-
console.warn("[
|
|
2864
|
+
console.warn("[Table] getIsRowExpanded: no row found with id " + rowId);
|
|
2879
2865
|
}
|
|
2880
2866
|
|
|
2881
2867
|
throw new Error();
|
|
@@ -2891,7 +2877,7 @@
|
|
|
2891
2877
|
|
|
2892
2878
|
if (!row) {
|
|
2893
2879
|
{
|
|
2894
|
-
console.warn("[
|
|
2880
|
+
console.warn("[Table] getRowCanExpand: no row found with id " + rowId);
|
|
2895
2881
|
}
|
|
2896
2882
|
|
|
2897
2883
|
throw new Error();
|
|
@@ -3685,7 +3671,7 @@
|
|
|
3685
3671
|
var _options$initialState;
|
|
3686
3672
|
|
|
3687
3673
|
if (options.debugAll || options.debugTable) {
|
|
3688
|
-
console.info('Creating
|
|
3674
|
+
console.info('Creating Table Instance...');
|
|
3689
3675
|
}
|
|
3690
3676
|
|
|
3691
3677
|
var instance = {};
|
|
@@ -3713,6 +3699,17 @@
|
|
|
3713
3699
|
setOptions: function setOptions(updater) {
|
|
3714
3700
|
instance.options = buildOptions(functionalUpdate(updater, instance.options));
|
|
3715
3701
|
},
|
|
3702
|
+
render: function render(template, props) {
|
|
3703
|
+
if (typeof instance.options.render === 'function') {
|
|
3704
|
+
return instance.options.render(template, props);
|
|
3705
|
+
}
|
|
3706
|
+
|
|
3707
|
+
if (typeof template === 'function') {
|
|
3708
|
+
return template(props);
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
return template;
|
|
3712
|
+
},
|
|
3716
3713
|
getRowId: function getRowId(_, index, parent) {
|
|
3717
3714
|
return "" + (parent ? [parent.id, index].join('.') : index);
|
|
3718
3715
|
},
|
|
@@ -3903,7 +3900,7 @@
|
|
|
3903
3900
|
|
|
3904
3901
|
if (!column) {
|
|
3905
3902
|
{
|
|
3906
|
-
console.warn("[
|
|
3903
|
+
console.warn("[Table] Column with id " + columnId + " does not exist.");
|
|
3907
3904
|
}
|
|
3908
3905
|
|
|
3909
3906
|
throw new Error();
|
|
@@ -3935,13 +3932,13 @@
|
|
|
3935
3932
|
return instance.getCellProps(row.id, column.id, userProps);
|
|
3936
3933
|
},
|
|
3937
3934
|
renderCell: function renderCell() {
|
|
3938
|
-
return
|
|
3935
|
+
return column.cell ? instance.render(column.cell, {
|
|
3939
3936
|
instance: instance,
|
|
3940
3937
|
column: column,
|
|
3941
3938
|
row: row,
|
|
3942
3939
|
cell: cell,
|
|
3943
3940
|
value: value
|
|
3944
|
-
});
|
|
3941
|
+
}) : null;
|
|
3945
3942
|
}
|
|
3946
3943
|
};
|
|
3947
3944
|
features.forEach(function (feature) {
|
|
@@ -4105,7 +4102,7 @@
|
|
|
4105
4102
|
|
|
4106
4103
|
if (!row) {
|
|
4107
4104
|
{
|
|
4108
|
-
throw new Error("[
|
|
4105
|
+
throw new Error("[Table] could not find row with id " + rowId);
|
|
4109
4106
|
}
|
|
4110
4107
|
}
|
|
4111
4108
|
|
|
@@ -4113,7 +4110,7 @@
|
|
|
4113
4110
|
|
|
4114
4111
|
if (!cell) {
|
|
4115
4112
|
{
|
|
4116
|
-
throw new Error("[
|
|
4113
|
+
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
|
|
4117
4114
|
}
|
|
4118
4115
|
}
|
|
4119
4116
|
|
|
@@ -4187,18 +4184,27 @@
|
|
|
4187
4184
|
return instance;
|
|
4188
4185
|
}
|
|
4189
4186
|
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4187
|
+
//
|
|
4188
|
+
function init(opts) {
|
|
4189
|
+
return {
|
|
4190
|
+
createTableFactory: function createTableFactory(options) {
|
|
4191
|
+
return function () {
|
|
4192
|
+
return _createTable(undefined, undefined, _extends({}, options, opts));
|
|
4193
|
+
};
|
|
4194
|
+
},
|
|
4195
|
+
createTable: function createTable() {
|
|
4196
|
+
return _createTable(undefined, undefined, opts);
|
|
4197
|
+
}
|
|
4193
4198
|
};
|
|
4194
4199
|
}
|
|
4195
|
-
function createTable() {
|
|
4196
|
-
return _createTable();
|
|
4197
|
-
}
|
|
4198
4200
|
|
|
4199
4201
|
function _createTable(_, __, __options) {
|
|
4200
4202
|
return {
|
|
4201
|
-
__options: __options
|
|
4203
|
+
__options: __options != null ? __options : {
|
|
4204
|
+
render: function render() {
|
|
4205
|
+
throw new Error();
|
|
4206
|
+
}
|
|
4207
|
+
},
|
|
4202
4208
|
createColumns: function createColumns(columns) {
|
|
4203
4209
|
return columns;
|
|
4204
4210
|
},
|
|
@@ -4248,7 +4254,7 @@
|
|
|
4248
4254
|
|
|
4249
4255
|
if (!column) {
|
|
4250
4256
|
{
|
|
4251
|
-
console.warn("
|
|
4257
|
+
console.warn("Table: Could not find a column with id: " + columnId);
|
|
4252
4258
|
}
|
|
4253
4259
|
|
|
4254
4260
|
throw new Error();
|
|
@@ -4551,7 +4557,7 @@
|
|
|
4551
4557
|
console.info({
|
|
4552
4558
|
column: column
|
|
4553
4559
|
});
|
|
4554
|
-
throw new Error("
|
|
4560
|
+
throw new Error("Table: Invalid column.aggregateType option for column listed above" );
|
|
4555
4561
|
} else {
|
|
4556
4562
|
values[column.id] = null;
|
|
4557
4563
|
}
|
|
@@ -4710,17 +4716,14 @@
|
|
|
4710
4716
|
exports.Visibility = Visibility;
|
|
4711
4717
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
4712
4718
|
exports.columnFilterRowsFn = columnFilterRowsFn;
|
|
4713
|
-
exports.createTable = createTable;
|
|
4714
|
-
exports.createTableFactory = createTableFactory;
|
|
4715
4719
|
exports.createTableInstance = createTableInstance;
|
|
4716
4720
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
4717
4721
|
exports.expandRowsFn = expandRowsFn;
|
|
4718
4722
|
exports.flattenBy = flattenBy;
|
|
4719
|
-
exports.flexRender = flexRender;
|
|
4720
4723
|
exports.functionalUpdate = functionalUpdate;
|
|
4721
|
-
exports.getDefaultColumn = getDefaultColumn;
|
|
4722
4724
|
exports.globalFilterRowsFn = globalFilterRowsFn;
|
|
4723
4725
|
exports.groupRowsFn = groupRowsFn;
|
|
4726
|
+
exports.init = init;
|
|
4724
4727
|
exports.isFunction = isFunction;
|
|
4725
4728
|
exports.isRowSelected = isRowSelected;
|
|
4726
4729
|
exports.makeStateUpdater = makeStateUpdater;
|