@tanstack/react-table 8.5.13 → 8.5.16

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,25 +36,22 @@ function _interopNamespace(e) {
36
36
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
37
37
 
38
38
  //
39
+
39
40
  function flexRender(Comp, props) {
40
41
  return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
41
42
  }
42
-
43
43
  function isReactComponent(component) {
44
44
  return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
45
45
  }
46
-
47
46
  function isClassComponent(component) {
48
47
  return typeof component === 'function' && (() => {
49
48
  const proto = Object.getPrototypeOf(component);
50
49
  return proto.prototype && proto.prototype.isReactComponent;
51
50
  })();
52
51
  }
53
-
54
52
  function isExoticComponent(component) {
55
53
  return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
56
54
  }
57
-
58
55
  function useReactTable(options) {
59
56
  // Compose in the generic options to the user options
60
57
  const resolvedOptions = {
@@ -64,18 +61,23 @@ function useReactTable(options) {
64
61
  // noop
65
62
  renderFallbackValue: null,
66
63
  ...options
67
- }; // Create a new table and store it in state
64
+ };
68
65
 
66
+ // Create a new table and store it in state
69
67
  const [tableRef] = React__namespace.useState(() => ({
70
68
  current: index.createTable(resolvedOptions)
71
- })); // By default, manage table state here using the table's initial state
69
+ }));
72
70
 
73
- const [state, setState] = React__namespace.useState(() => tableRef.current.initialState); // Compose the default state above with any user state. This will allow the user
74
- // to only control a subset of the state if desired.
71
+ // By default, manage table state here using the table's initial state
72
+ const [state, setState] = React__namespace.useState(() => tableRef.current.initialState);
75
73
 
76
- tableRef.current.setOptions(prev => ({ ...prev,
74
+ // Compose the default state above with any user state. This will allow the user
75
+ // to only control a subset of the state if desired.
76
+ tableRef.current.setOptions(prev => ({
77
+ ...prev,
77
78
  ...options,
78
- state: { ...state,
79
+ state: {
80
+ ...state,
79
81
  ...options.state
80
82
  },
81
83
  // Similarly, we'll maintain both our internal state and any user-provided
@@ -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 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,CACLC,IADK,EAELC,KAFK,EAG0B;AAC/B,EAAA,OAAO,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAASF,IAAT,CAAhB,gBACpBG,+BAAC,IAAD,EAAUF,KAAV,CADoB,GAGpBD,IAHF,CAAA;AAKD,CAAA;;AAED,SAASE,gBAAT,CACEE,SADF,EAE4C;AAC1C,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,UAAU,CACxBC,IAAwB,EACxBC,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