@tanstack/react-table 8.0.12 → 8.1.0

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.
@@ -36,7 +36,9 @@ function _interopNamespace(e) {
36
36
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
37
37
 
38
38
  //
39
- const render = (Comp, props) => !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
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
- const createTable = index.createTableFactory({
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 = { ...table.options,
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 instance and store it in state
67
+ }; // Create a new table and store it in state
72
68
 
73
- const [instanceRef] = React__namespace.useState(() => ({
74
- current: index.createTableInstance(resolvedOptions)
75
- })); // By default, manage table state here using the instance's initial state
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(() => instanceRef.current.initialState); // Compose the default state above with any user state. This will allow the user
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
- instanceRef.current.setOptions(prev => ({ ...prev,
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 instanceRef.current;
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.createTableFactory = index.createTableFactory;
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;
@@ -125,6 +120,7 @@ exports.getPaginationRowModel = index.getPaginationRowModel;
125
120
  exports.getSortedRowModel = index.getSortedRowModel;
126
121
  exports.isFunction = index.isFunction;
127
122
  exports.isRowSelected = index.isRowSelected;
123
+ exports.isSubRowSelected = index.isSubRowSelected;
128
124
  exports.makeStateUpdater = index.makeStateUpdater;
129
125
  exports.memo = index.memo;
130
126
  exports.noop = index.noop;
@@ -134,7 +130,6 @@ exports.reSplitAlphaNumeric = index.reSplitAlphaNumeric;
134
130
  exports.selectRowsFn = index.selectRowsFn;
135
131
  exports.shouldAutoRemoveFilter = index.shouldAutoRemoveFilter;
136
132
  exports.sortingFns = index.sortingFns;
137
- exports.createTable = createTable;
138
- exports.render = render;
139
- exports.useTableInstance = useTableInstance;
133
+ exports.flexRender = flexRender;
134
+ exports.useReactTable = useReactTable;
140
135
  //# 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 createTableInstance,\n TableOptions,\n TableInstance,\n Table,\n TableGenerics,\n createTableFactory,\n Overwrite,\n PartialKeys,\n TableOptionsResolved,\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\n// const useIsomorphicLayoutEffect =\n// typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nexport type UseTableInstanceOptions<TGenerics extends ReactTableGenerics> =\n TableOptions<TGenerics>\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: TableOptionsResolved<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n renderFallbackValue: null,\n ...options,\n }\n\n // Create a new table instance and store it in state\n const [instanceRef] = React.useState(() => ({\n current: createTableInstance<TGenerics>(resolvedOptions),\n }))\n\n // By default, manage table state here using the instance's initial state\n const [state, setState] = React.useState(\n () => instanceRef.current.initialState\n )\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 instanceRef.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 instanceRef.current\n}\n"],"names":["render","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","state","onStateChange","renderFallbackValue","instanceRef","useState","current","createTableInstance","setState","initialState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA;AAEO,MAAMA,MAAc,GAAG,CAACC,IAAD,EAAOC,KAAP,KAC5B,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CAAhB,gBAAyBG,gBAAA,CAAA,aAAA,CAAC,IAAD,EAAUF,KAAV,CAAzB,GAA+CD,KADzD;;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,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,gBAA1C,CAAA;AACD,GAHD,GAFF,CAAA;AAOD,CAAA;;AAED,SAASI,iBAAT,CAA2BF,SAA3B,EAA2C;EACzC,OACE,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O,CAACG,aAAR,CAAwBU,OAAxB,CAAA,CAAA;AACD,KAAA;AAZqC,GAAL,CAAnC,CAAA,CAAA;EAeA,OAAOR,WAAW,CAACE,OAAnB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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,gBAA1C,CAAA;AACD,GAHD,GAFF,CAAA;AAOD,CAAA;;AAED,SAASI,iBAAT,CAA2BF,SAA3B,EAA2C;EACzC,OACE,OAAOA,SAAP,KAAqB,QAArB,IACA,OAAOA,SAAS,CAACO,QAAjB,KAA8B,QAD9B,IAEA,CAAC,YAAD,EAAe,mBAAf,CAAA,CAAoCC,QAApC,CAA6CR,SAAS,CAACO,QAAV,CAAmBE,WA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