@tanstack/react-table 8.0.13 → 8.0.14
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 +15 -21
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +567 -671
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +579 -686
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +19 -19
- package/build/types/index.d.ts +6 -15
- package/build/umd/index.development.js +580 -689
- 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.tsx +19 -43
|
@@ -36,7 +36,9 @@ function _interopNamespace(e) {
|
|
|
36
36
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
37
37
|
|
|
38
38
|
//
|
|
39
|
-
|
|
39
|
+
function flexRender(Comp, props) {
|
|
40
|
+
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
|
|
41
|
+
}
|
|
40
42
|
|
|
41
43
|
function isReactComponent(component) {
|
|
42
44
|
return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
|
|
@@ -53,31 +55,25 @@ function isExoticComponent(component) {
|
|
|
53
55
|
return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
render
|
|
58
|
-
}); // const useIsomorphicLayoutEffect =
|
|
59
|
-
// typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect
|
|
60
|
-
|
|
61
|
-
function useTableInstance(table, options) {
|
|
58
|
+
function useReactTable(options) {
|
|
62
59
|
// Compose in the generic options to the user options
|
|
63
|
-
const resolvedOptions = {
|
|
60
|
+
const resolvedOptions = {
|
|
64
61
|
state: {},
|
|
65
62
|
// Dummy state
|
|
66
63
|
onStateChange: () => {},
|
|
67
64
|
// noop
|
|
68
|
-
render,
|
|
69
65
|
renderFallbackValue: null,
|
|
70
66
|
...options
|
|
71
|
-
}; // Create a new table
|
|
67
|
+
}; // Create a new table and store it in state
|
|
72
68
|
|
|
73
|
-
const [
|
|
74
|
-
current: index.
|
|
75
|
-
})); // By default, manage table state here using the
|
|
69
|
+
const [tableRef] = React__namespace.useState(() => ({
|
|
70
|
+
current: index.createTable(resolvedOptions)
|
|
71
|
+
})); // By default, manage table state here using the table's initial state
|
|
76
72
|
|
|
77
|
-
const [state, setState] = React__namespace.useState(() =>
|
|
73
|
+
const [state, setState] = React__namespace.useState(() => tableRef.current.initialState); // Compose the default state above with any user state. This will allow the user
|
|
78
74
|
// to only control a subset of the state if desired.
|
|
79
75
|
|
|
80
|
-
|
|
76
|
+
tableRef.current.setOptions(prev => ({ ...prev,
|
|
81
77
|
...options,
|
|
82
78
|
state: { ...state,
|
|
83
79
|
...options.state
|
|
@@ -89,7 +85,7 @@ function useTableInstance(table, options) {
|
|
|
89
85
|
options.onStateChange == null ? void 0 : options.onStateChange(updater);
|
|
90
86
|
}
|
|
91
87
|
}));
|
|
92
|
-
return
|
|
88
|
+
return tableRef.current;
|
|
93
89
|
}
|
|
94
90
|
|
|
95
91
|
exports.ColumnSizing = index.ColumnSizing;
|
|
@@ -107,8 +103,7 @@ exports.aggregationFns = index.aggregationFns;
|
|
|
107
103
|
exports.buildHeaderGroups = index.buildHeaderGroups;
|
|
108
104
|
exports.createColumn = index.createColumn;
|
|
109
105
|
exports.createRow = index.createRow;
|
|
110
|
-
exports.
|
|
111
|
-
exports.createTableInstance = index.createTableInstance;
|
|
106
|
+
exports.createTable = index.createTable;
|
|
112
107
|
exports.defaultColumnSizing = index.defaultColumnSizing;
|
|
113
108
|
exports.expandRows = index.expandRows;
|
|
114
109
|
exports.filterFns = index.filterFns;
|
|
@@ -134,7 +129,6 @@ exports.reSplitAlphaNumeric = index.reSplitAlphaNumeric;
|
|
|
134
129
|
exports.selectRowsFn = index.selectRowsFn;
|
|
135
130
|
exports.shouldAutoRemoveFilter = index.shouldAutoRemoveFilter;
|
|
136
131
|
exports.sortingFns = index.sortingFns;
|
|
137
|
-
exports.
|
|
138
|
-
exports.
|
|
139
|
-
exports.useTableInstance = useTableInstance;
|
|
132
|
+
exports.flexRender = flexRender;
|
|
133
|
+
exports.useReactTable = useReactTable;
|
|
140
134
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n createTable,\n TableOptions,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.FunctionComponent<TProps>\n | React.Component<TProps>\n\n//\n\nexport function flexRender<TProps extends object>(\n Comp: Renderable<TProps>,\n props: TProps\n): React.ReactNode | JSX.Element {\n return !Comp ? null : isReactComponent(Comp) ? <Comp {...props} /> : Comp\n}\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 function useReactTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\n // Compose in the generic options to the user options\n const resolvedOptions: TableOptionsResolved<TData> = {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n ...options,\n }\n\n // Create a new table and store it in state\n const [tableRef] = React.useState(() => ({\n current: createTable<TData>(resolvedOptions),\n }))\n\n // By default, manage table state here using the table's initial state\n const [state, setState] = React.useState(() => tableRef.current.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 tableRef.current.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 return tableRef.current\n}\n"],"names":["flexRender","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","useReactTable","options","resolvedOptions","state","onStateChange","renderFallbackValue","tableRef","useState","current","createTable","setState","initialState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA;AAEO,SAASA,UAAT,CACLC,IADK,EAELC,KAFK,EAG0B;AAC/B,EAAA,OAAO,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CAAhB,gBAAyBG,+BAAC,IAAD,EAAUF,KAAV,CAAzB,GAA+CD,IAArE,CAAA;AACD,CAAA;;AAED,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,IACA,CAAC,MAAM;AACL,IAAA,MAAMG,KAAK,GAAGC,MAAM,CAACC,cAAP,CAAsBL,SAAtB,CAAd,CAAA;IACA,OAAOG,KAAK,CAACG,SAAN,IAAmBH,KAAK,CAACG,SAAN,CAAgBR,gBA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