@tanstack/react-table 8.1.3 → 8.2.1

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.
@@ -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 createTable,\n TableOptions,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.ComponentType<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<TProps>(Comp) ? <Comp {...props} /> : Comp\n}\n\nfunction isReactComponent<TProps>(component: unknown): component is React.ComponentType<TProps> {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;AAEO,SAASA,UAAT,CACLC,IADK,EAELC,KAFK,EAG0B;AAC/B,EAAA,OAAO,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAASF,IAAT,CAAhB,gBAAiCG,+BAAC,IAAD,EAAUF,KAAV,CAAjC,GAAuDD,IAA7E,CAAA;AACD,CAAA;;AAED,SAASE,gBAAT,CAAkCE,SAAlC,EAAgG;AAC9F,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,WAAhE,CAHF,CAAA;AAKD,CAAA;;AAEM,SAASC,aAAT,CACLC,OADK,EAEL;AACA;AACA,EAAA,MAAMC,eAA4C,GAAG;AACnDC,IAAAA,KAAK,EAAE,EAD4C;AACxC;IACXC,aAAa,EAAE,MAAM,EAF8B;AAE1B;AACzBC,IAAAA,mBAAmB,EAAE,IAH8B;IAInD,GAAGJ,OAAAA;AAJgD,GAArD,CAFA;;AAUA,EAAA,MAAM,CAACK,QAAD,CAAA,GAAajB,gBAAK,CAACkB,QAAN,CAAe,OAAO;IACvCC,OAAO,EAAEC,iBAAW,CAAQP,eAAR,CAAA;GADY,CAAf,CAAnB,CAVA;;AAeA,EAAA,MAAM,CAACC,KAAD,EAAQO,QAAR,CAAA,GAAoBrB,gBAAK,CAACkB,QAAN,CAAe,MAAMD,QAAQ,CAACE,OAAT,CAAiBG,YAAtC,CAA1B,CAfA;AAkBA;;EACAL,QAAQ,CAACE,OAAT,CAAiBI,UAAjB,CAA4BC,IAAI,KAAK,EACnC,GAAGA,IADgC;AAEnC,IAAA,GAAGZ,OAFgC;IAGnCE,KAAK,EAAE,EACL,GAAGA,KADE;AAEL,MAAA,GAAGF,OAAO,CAACE,KAAAA;KALsB;AAOnC;AACA;IACAC,aAAa,EAAEU,OAAO,IAAI;MACxBJ,QAAQ,CAACI,OAAD,CAAR,CAAA;AACAb,MAAAA,OAAO,CAACG,aAAR,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAH,OAAO,CAACG,aAAR,CAAwBU,OAAxB,CAAA,CAAA;AACD,KAAA;AAZkC,GAAL,CAAhC,CAAA,CAAA;EAeA,OAAOR,QAAQ,CAACE,OAAhB,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 TableOptions,\n TableOptionsResolved,\n RowData,\n createTable,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> = React.ReactNode | React.ComponentType<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<TProps>(Comp) ? (\n <Comp {...props} />\n ) : (\n Comp\n )\n}\n\nfunction isReactComponent<TProps>(\n component: unknown\n): component is React.ComponentType<TProps> {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA;AAEO,SAASA,UAAT,C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CAAA;GADY,CAAf,CAAnB,CAVA;;AAeA,EAAA,MAAM,CAACC,KAAD,EAAQO,QAAR,CAAA,GAAoBrB,gBAAK,CAACkB,QAAN,CAAe,MAAMD,QAAQ,CAACE,OAAT,CAAiBG,YAAtC,CAA1B,CAfA;AAkBA;;EACAL,QAAQ,CAACE,OAAT,CAAiBI,UAAjB,CAA4BC,IAAI,KAAK,EACnC,GAAGA,IADgC;AAEnC,IAAA,GAAGZ,OAFgC;IAGnCE,KAAK,EAAE,EACL,GAAGA,KADE;AAEL,MAAA,GAAGF,OAAO,CAACE,KAAAA;KALsB;AAOnC;AACA;IACAC,aAAa,EAAEU,OAAO,IAAI;MACxBJ,QAAQ,CAACI,OAAD,CAAR,CAAA;AACAb,MAAAA,OAAO,CAACG,aAAR,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAH,OAAO,CAACG,aAAR,CAAwBU,OAAxB,CAAA,CAAA;AACD,KAAA;AAZkC,GAAL,CAAhC,CAAA,CAAA;EAeA,OAAOR,QAAQ,CAACE,OAAhB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -27,9 +27,9 @@ function functionalUpdate(updater, input) {
27
27
  }
28
28
  function noop() {//
29
29
  }
30
- function makeStateUpdater(key, table) {
30
+ function makeStateUpdater(key, instance) {
31
31
  return updater => {
32
- table.setState(old => {
32
+ instance.setState(old => {
33
33
  return { ...old,
34
34
  [key]: functionalUpdate(updater, old[key])
35
35
  };
@@ -2893,9 +2893,9 @@ function createTable(options) {
2893
2893
  header: props => props.header.column.id,
2894
2894
  footer: props => props.header.column.id,
2895
2895
  cell: props => {
2896
- var _toString, _props$renderValue;
2896
+ var _props$renderValue$to, _props$renderValue;
2897
2897
 
2898
- return (_toString = (_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _toString : null;
2898
+ return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
2899
2899
  },
2900
2900
  ...table._features.reduce((obj, feature) => {
2901
2901
  return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
@@ -3425,9 +3425,7 @@ function getFacetedMinMaxValues() {
3425
3425
  let facetedMinMaxValues = [firstValue, firstValue];
3426
3426
 
3427
3427
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3428
- var _facetedRowModel$flat2;
3429
-
3430
- const value = (_facetedRowModel$flat2 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId);
3428
+ const value = facetedRowModel.flatRows[i].getValue(columnId);
3431
3429
 
3432
3430
  if (value < facetedMinMaxValues[0]) {
3433
3431
  facetedMinMaxValues[0] = value;
@@ -3577,7 +3575,7 @@ function getGroupedRowModel() {
3577
3575
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3578
3576
 
3579
3577
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3580
- const row = createRow(table, id, undefined, index, depth);
3578
+ const row = createRow(table, id, leafRows[0].original, index, depth);
3581
3579
  Object.assign(row, {
3582
3580
  groupingColumnId: columnId,
3583
3581
  groupingValue,