@tanstack/react-table 8.0.0-alpha.7 → 8.0.0-alpha.8
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 +19 -11
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +9 -23
- package/build/cjs/createTable.js.map +1 -1
- package/build/esm/index.js +28 -34
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +245 -231
- package/build/types/core.d.ts +3 -2
- package/build/umd/index.development.js +31 -38
- 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 +7 -1
- package/src/core.tsx +16 -11
- package/src/createTable.tsx +9 -29
package/build/types/core.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export declare type CoreOptions<TData, TValue, TFilterFns, TSortingFns, TAggrega
|
|
|
14
14
|
autoResetAll?: boolean;
|
|
15
15
|
};
|
|
16
16
|
export declare type TableCore<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> = {
|
|
17
|
-
|
|
17
|
+
subscribe: (cb: () => void) => () => void;
|
|
18
|
+
notify: () => void;
|
|
18
19
|
initialState: TableState;
|
|
19
20
|
internalState: TableState;
|
|
20
21
|
reset: () => void;
|
|
@@ -106,4 +107,4 @@ export declare type CoreColumn<TData, TValue, TFilterFns, TSortingFns, TAggregat
|
|
|
106
107
|
getFlatColumns: () => Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[];
|
|
107
108
|
getLeafColumns: () => Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[];
|
|
108
109
|
};
|
|
109
|
-
export declare function createTableInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>(options: Options<TData, TValue, TFilterFns, TSortingFns, TAggregationFns
|
|
110
|
+
export declare function createTableInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>(options: Options<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>): ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>;
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactTable = {}, global.React));
|
|
15
|
-
})(this, (function (exports, React) { 'use strict';
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-sync-external-store/shim')) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-sync-external-store/shim'], factory) :
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactTable = {}, global.React, global.shim));
|
|
15
|
+
})(this, (function (exports, React, shim) { 'use strict';
|
|
16
16
|
|
|
17
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
18
|
|
|
@@ -4201,7 +4201,7 @@
|
|
|
4201
4201
|
});
|
|
4202
4202
|
|
|
4203
4203
|
var features = [Visibility, Ordering, Pinning, Headers, Filters, Sorting, Grouping, Expanding, ColumnSizing, Pagination, RowSelection];
|
|
4204
|
-
function createTableInstance(options
|
|
4204
|
+
function createTableInstance(options) {
|
|
4205
4205
|
var _options$initialState;
|
|
4206
4206
|
|
|
4207
4207
|
if (options.debug) {
|
|
@@ -4209,6 +4209,7 @@
|
|
|
4209
4209
|
}
|
|
4210
4210
|
|
|
4211
4211
|
var instance = {};
|
|
4212
|
+
var listeners = [];
|
|
4212
4213
|
var defaultOptions = features.reduce(function (obj, feature) {
|
|
4213
4214
|
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
|
|
4214
4215
|
}, {});
|
|
@@ -4226,10 +4227,23 @@
|
|
|
4226
4227
|
return Object.assign(obj, feature.getInitialState == null ? void 0 : feature.getInitialState());
|
|
4227
4228
|
}, {}), (_options$initialState = options.initialState) != null ? _options$initialState : {});
|
|
4228
4229
|
|
|
4229
|
-
var finalInstance = _extends({}, instance,
|
|
4230
|
+
var finalInstance = _extends({}, instance, {
|
|
4231
|
+
subscribe: function subscribe(cb) {
|
|
4232
|
+
listeners.push(cb);
|
|
4233
|
+
return function () {
|
|
4234
|
+
listeners = listeners.filter(function (l) {
|
|
4235
|
+
return l !== cb;
|
|
4236
|
+
});
|
|
4237
|
+
};
|
|
4238
|
+
},
|
|
4239
|
+
notify: function notify() {
|
|
4240
|
+
listeners.forEach(function (l) {
|
|
4241
|
+
return l();
|
|
4242
|
+
});
|
|
4243
|
+
}
|
|
4244
|
+
}, features.reduce(function (obj, feature) {
|
|
4230
4245
|
return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance));
|
|
4231
4246
|
}, {}), {
|
|
4232
|
-
rerender: rerender,
|
|
4233
4247
|
initialState: initialState,
|
|
4234
4248
|
internalState: initialState,
|
|
4235
4249
|
reset: function reset() {
|
|
@@ -4246,11 +4260,7 @@
|
|
|
4246
4260
|
|
|
4247
4261
|
return state;
|
|
4248
4262
|
},
|
|
4249
|
-
setState: function setState(updater
|
|
4250
|
-
if (shouldRerender === void 0) {
|
|
4251
|
-
shouldRerender = true;
|
|
4252
|
-
}
|
|
4253
|
-
|
|
4263
|
+
setState: function setState(updater) {
|
|
4254
4264
|
var onStateChange = instance.options.onStateChange;
|
|
4255
4265
|
var internalState = instance.internalState;
|
|
4256
4266
|
var newState = functionalUpdate(updater, internalState);
|
|
@@ -4261,9 +4271,7 @@
|
|
|
4261
4271
|
return;
|
|
4262
4272
|
}
|
|
4263
4273
|
|
|
4264
|
-
|
|
4265
|
-
instance.rerender();
|
|
4266
|
-
}
|
|
4274
|
+
instance.notify();
|
|
4267
4275
|
},
|
|
4268
4276
|
getDefaultColumn: memo(function () {
|
|
4269
4277
|
return [instance.options.defaultColumn];
|
|
@@ -4766,31 +4774,16 @@
|
|
|
4766
4774
|
throw new Error('Invalid accessor');
|
|
4767
4775
|
},
|
|
4768
4776
|
useTable: function useTable(options) {
|
|
4769
|
-
var
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
var isMountedRef = React__namespace.useRef(false);
|
|
4774
|
-
var rerender = React__namespace.useCallback(function () {
|
|
4775
|
-
if (!isMountedRef.current) {
|
|
4776
|
-
return;
|
|
4777
|
-
}
|
|
4777
|
+
var _React$useState = React__namespace.useState(function () {
|
|
4778
|
+
return createTableInstance(options);
|
|
4779
|
+
}),
|
|
4780
|
+
instance = _React$useState[0];
|
|
4778
4781
|
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
React__namespace.useLayoutEffect(function () {
|
|
4782
|
-
isMountedRef.current = true;
|
|
4783
|
-
return function () {
|
|
4784
|
-
isMountedRef.current = false;
|
|
4785
|
-
};
|
|
4782
|
+
shim.useSyncExternalStore(instance.subscribe, function () {
|
|
4783
|
+
return instance.internalState;
|
|
4786
4784
|
});
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
instanceRef.current = createTableInstance(options, rerender);
|
|
4790
|
-
}
|
|
4791
|
-
|
|
4792
|
-
instanceRef.current.updateOptions(options);
|
|
4793
|
-
return instanceRef.current;
|
|
4785
|
+
instance.updateOptions(options);
|
|
4786
|
+
return instance;
|
|
4794
4787
|
},
|
|
4795
4788
|
types: undefined
|
|
4796
4789
|
};
|