@tanstack/react-table 8.0.0-alpha.65 → 8.0.0-alpha.69
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/react-table/src/index.js +133 -0
- package/build/cjs/react-table/src/index.js.map +1 -0
- package/build/cjs/table-core/build/esm/index.js +4033 -0
- package/build/cjs/table-core/build/esm/index.js.map +1 -0
- package/build/esm/index.js +4005 -52
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -38
- package/build/umd/index.development.js +4036 -59
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +11 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +10 -12
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -34
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/index.js +0 -113
- package/build/cjs/index.js.map +0 -1
package/src/index.tsx
CHANGED
|
@@ -60,8 +60,8 @@ function isExoticComponent(component: any) {
|
|
|
60
60
|
|
|
61
61
|
export const createTable = createTableFactory({ render })
|
|
62
62
|
|
|
63
|
-
const useIsomorphicLayoutEffect =
|
|
64
|
-
|
|
63
|
+
// const useIsomorphicLayoutEffect =
|
|
64
|
+
// typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect
|
|
65
65
|
|
|
66
66
|
export type UseTableInstanceOptions<TGenerics extends ReactTableGenerics> =
|
|
67
67
|
PartialKeys<
|
|
@@ -83,16 +83,18 @@ export function useTableInstance<TGenerics extends ReactTableGenerics>(
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Create a new table instance and store it in state
|
|
86
|
-
const [
|
|
87
|
-
createTableInstance<TGenerics>(resolvedOptions)
|
|
88
|
-
)
|
|
86
|
+
const [instanceRef] = React.useState(() => ({
|
|
87
|
+
current: createTableInstance<TGenerics>(resolvedOptions),
|
|
88
|
+
}))
|
|
89
89
|
|
|
90
90
|
// By default, manage table state here using the instance's initial state
|
|
91
|
-
const [state, setState] = React.useState(
|
|
91
|
+
const [state, setState] = React.useState(
|
|
92
|
+
() => instanceRef.current.initialState
|
|
93
|
+
)
|
|
92
94
|
|
|
93
95
|
// Compose the default state above with any user state. This will allow the user
|
|
94
96
|
// to only control a subset of the state if desired.
|
|
95
|
-
|
|
97
|
+
instanceRef.current.setOptions(prev => ({
|
|
96
98
|
...prev,
|
|
97
99
|
...options,
|
|
98
100
|
state: {
|
|
@@ -107,9 +109,5 @@ export function useTableInstance<TGenerics extends ReactTableGenerics>(
|
|
|
107
109
|
},
|
|
108
110
|
}))
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
// instance.willUpdate()
|
|
112
|
-
// })
|
|
113
|
-
|
|
114
|
-
return instance
|
|
112
|
+
return instanceRef.current
|
|
115
113
|
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-table
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function _extends() {
|
|
16
|
-
_extends = Object.assign || function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
|
|
20
|
-
for (var key in source) {
|
|
21
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
-
target[key] = source[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return _extends.apply(this, arguments);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports["extends"] = _extends;
|
|
34
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/cjs/index.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-table
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
16
|
-
var React = require('react');
|
|
17
|
-
var tableCore = require('@tanstack/table-core');
|
|
18
|
-
|
|
19
|
-
function _interopNamespace(e) {
|
|
20
|
-
if (e && e.__esModule) return e;
|
|
21
|
-
var n = Object.create(null);
|
|
22
|
-
if (e) {
|
|
23
|
-
Object.keys(e).forEach(function (k) {
|
|
24
|
-
if (k !== 'default') {
|
|
25
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
26
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () { return e[k]; }
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
n["default"] = e;
|
|
34
|
-
return Object.freeze(n);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
var render = function render(Comp, props) {
|
|
41
|
-
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function isReactComponent(component) {
|
|
45
|
-
return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function isClassComponent(component) {
|
|
49
|
-
return typeof component === 'function' && function () {
|
|
50
|
-
var proto = Object.getPrototypeOf(component);
|
|
51
|
-
return proto.prototype && proto.prototype.isReactComponent;
|
|
52
|
-
}();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function isExoticComponent(component) {
|
|
56
|
-
return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
var createTable = tableCore.createTableFactory({
|
|
60
|
-
render: render
|
|
61
|
-
});
|
|
62
|
-
function useTableInstance(table, options) {
|
|
63
|
-
// Compose in the generic options to the user options
|
|
64
|
-
var resolvedOptions = _rollupPluginBabelHelpers["extends"]({}, table.options, {
|
|
65
|
-
state: {},
|
|
66
|
-
// Dummy state
|
|
67
|
-
onStateChange: function onStateChange() {},
|
|
68
|
-
// noop
|
|
69
|
-
render: render
|
|
70
|
-
}, options); // Create a new table instance and store it in state
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var _React$useState = React__namespace.useState(function () {
|
|
74
|
-
return tableCore.createTableInstance(resolvedOptions);
|
|
75
|
-
}),
|
|
76
|
-
instance = _React$useState[0]; // By default, manage table state here using the instance's initial state
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var _React$useState2 = React__namespace.useState(function () {
|
|
80
|
-
return instance.initialState;
|
|
81
|
-
}),
|
|
82
|
-
state = _React$useState2[0],
|
|
83
|
-
setState = _React$useState2[1]; // Compose the default state above with any user state. This will allow the user
|
|
84
|
-
// to only control a subset of the state if desired.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
instance.setOptions(function (prev) {
|
|
88
|
-
return _rollupPluginBabelHelpers["extends"]({}, prev, options, {
|
|
89
|
-
state: _rollupPluginBabelHelpers["extends"]({}, state, options.state),
|
|
90
|
-
// Similarly, we'll maintain both our internal state and any user-provided
|
|
91
|
-
// state.
|
|
92
|
-
onStateChange: function onStateChange(updater) {
|
|
93
|
-
setState(updater);
|
|
94
|
-
options.onStateChange == null ? void 0 : options.onStateChange(updater);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}); // useIsomorphicLayoutEffect(() => {
|
|
98
|
-
// instance.willUpdate()
|
|
99
|
-
// })
|
|
100
|
-
|
|
101
|
-
return instance;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
exports.createTable = createTable;
|
|
105
|
-
exports.render = render;
|
|
106
|
-
exports.useTableInstance = useTableInstance;
|
|
107
|
-
Object.keys(tableCore).forEach(function (k) {
|
|
108
|
-
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
get: function () { return tableCore[k]; }
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=index.js.map
|
package/build/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n createTableInstance,\n TableOptions,\n TableInstance,\n Table,\n TableGenerics,\n createTableFactory,\n Overwrite,\n PartialKeys,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.FunctionComponent<TProps>\n | React.Component<TProps>\n\nexport type Render = <TProps extends {}>(\n Comp: Renderable<TProps>,\n props: TProps\n) => React.ReactNode | JSX.Element\n\nexport type ReactTableGenerics = Overwrite<\n TableGenerics,\n { Renderer: Render; Rendered: ReturnType<Render> }\n>\n\n//\n\nexport const render: Render = (Comp, props) =>\n !Comp ? null : isReactComponent(Comp) ? <Comp {...props} /> : Comp\n\nfunction isReactComponent(component: unknown): component is React.FC {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\nexport const createTable = createTableFactory({ render })\n\nconst useIsomorphicLayoutEffect =\n typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nexport type UseTableInstanceOptions<TGenerics extends ReactTableGenerics> =\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n\nexport function useTableInstance<TGenerics extends ReactTableGenerics>(\n table: Table<TGenerics>,\n options: UseTableInstanceOptions<TGenerics>\n): TableInstance<TGenerics> {\n // Compose in the generic options to the user options\n const resolvedOptions: TableOptions<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...options,\n }\n\n // Create a new table instance and store it in state\n const [instance] = React.useState(() =>\n createTableInstance<TGenerics>(resolvedOptions)\n )\n\n // By default, manage table state here using the instance's initial state\n const [state, setState] = React.useState(() => instance.initialState)\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n instance.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state,\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater)\n options.onStateChange?.(updater)\n },\n }))\n\n // useIsomorphicLayoutEffect(() => {\n // instance.willUpdate()\n // })\n\n return instance\n}\n"],"names":["render","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","_extends","state","onStateChange","useState","createTableInstance","instance","initialState","setState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA;AAEO,IAAMA,MAAc,GAAG,SAAjBA,MAAiB,CAACC,IAAD,EAAOC,KAAP,EAAA;AAAA,EAAA,OAC5B,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CAAhB,gBAAyBG,+BAAC,IAAD,EAAUF,KAAV,CAAzB,GAA+CD,IADlC,CAAA;AAAA,EAAvB;;AAGP,SAASE,gBAAT,CAA0BE,SAA1B,EAAqE;AACnE,EAAA,OACEC,gBAAgB,CAACD,SAAD,CAAhB,IACA,OAAOA,SAAP,KAAqB,UADrB,IAEAE,iBAAiB,CAACF,SAAD,CAHnB,CAAA;AAKD,CAAA;;AAED,SAASC,gBAAT,CAA0BD,SAA1B,EAA0C;AACxC,EAAA,OACE,OAAOA,SAAP,KAAqB,UAArB,IACC,YAAM;AACL,IAAA,IAAMG,KAAK,GAAGC,MAAM,CAACC,cAAP,CAAsBL,SAAtB,CAAd,CAAA;AACA,IAAOG,OAAAA,KAAK,CAACG,SAAN,IAAmBH,KAAK,CAACG,SAAN,CAAgBR,gBAA1C,CAAA;AACD,GAHD,EAFF,CAAA;AAOD,CAAA;;AAED,SAASI,iBAAT,CAA2BF,SAA3B,EAA2C;AACzC,EACE,OAAA,OAAOA,SAAP,KAAqB,QAArB,IACA,OAAOA,SAAS,CAACO,QAAjB,KAA8B,QAD9B,IAEA,CAAC,YAAD,EAAe,mBAAf,CAAA,CAAoCC,QAApC,CAA6CR,SAAS,CAACO,QAAV,CAAmBE,WAAhE,CAHF,CAAA;AAKD,CAAA;;AAEYC,IAAAA,WAAW,GAAGC,4BAAkB,CAAC;AAAEhB,EAAAA,MAAM,EAANA,MAAAA;AAAF,CAAD,EAAtC;AAWA,SAASiB,gBAAT,CACLC,KADK,EAELC,OAFK,EAGqB;AAC1B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