@tanstack/react-table 9.0.0-alpha.4 → 9.0.0-alpha.40

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.
Files changed (65) hide show
  1. package/README.md +117 -0
  2. package/dist/FlexRender.cjs +61 -0
  3. package/dist/FlexRender.cjs.map +1 -0
  4. package/dist/FlexRender.d.cts +51 -0
  5. package/dist/FlexRender.d.ts +51 -0
  6. package/dist/FlexRender.js +58 -0
  7. package/dist/FlexRender.js.map +1 -0
  8. package/dist/Subscribe.cjs +14 -0
  9. package/dist/Subscribe.cjs.map +1 -0
  10. package/dist/Subscribe.d.cts +103 -0
  11. package/dist/Subscribe.d.ts +103 -0
  12. package/dist/Subscribe.js +13 -0
  13. package/dist/Subscribe.js.map +1 -0
  14. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  15. package/dist/createTableHook.cjs +313 -0
  16. package/dist/createTableHook.cjs.map +1 -0
  17. package/dist/createTableHook.d.cts +358 -0
  18. package/dist/createTableHook.d.ts +358 -0
  19. package/dist/createTableHook.js +311 -0
  20. package/dist/createTableHook.js.map +1 -0
  21. package/dist/flex-render.cjs +5 -0
  22. package/dist/flex-render.d.cts +2 -0
  23. package/dist/flex-render.d.ts +2 -0
  24. package/dist/flex-render.js +3 -0
  25. package/dist/index.cjs +18 -0
  26. package/dist/index.d.cts +6 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.js +8 -0
  29. package/dist/legacy.cjs +14 -0
  30. package/dist/legacy.d.cts +2 -0
  31. package/dist/legacy.d.ts +2 -0
  32. package/dist/legacy.js +3 -0
  33. package/dist/static-functions.cjs +9 -0
  34. package/dist/static-functions.d.cts +1 -0
  35. package/dist/static-functions.d.ts +1 -0
  36. package/dist/static-functions.js +3 -0
  37. package/dist/useLegacyTable.cjs +193 -0
  38. package/dist/useLegacyTable.cjs.map +1 -0
  39. package/dist/useLegacyTable.d.cts +234 -0
  40. package/dist/useLegacyTable.d.ts +234 -0
  41. package/dist/useLegacyTable.js +182 -0
  42. package/dist/useLegacyTable.js.map +1 -0
  43. package/dist/useTable.cjs +41 -0
  44. package/dist/useTable.cjs.map +1 -0
  45. package/dist/useTable.d.cts +92 -0
  46. package/dist/useTable.d.ts +92 -0
  47. package/dist/useTable.js +40 -0
  48. package/dist/useTable.js.map +1 -0
  49. package/package.json +37 -20
  50. package/src/FlexRender.tsx +147 -0
  51. package/src/Subscribe.ts +199 -0
  52. package/src/createTableHook.tsx +1118 -0
  53. package/src/flex-render.ts +1 -0
  54. package/src/index.ts +6 -0
  55. package/src/legacy.ts +3 -0
  56. package/src/static-functions.ts +1 -0
  57. package/src/useLegacyTable.ts +489 -0
  58. package/src/useTable.ts +160 -0
  59. package/dist/cjs/index.cjs +0 -78
  60. package/dist/cjs/index.cjs.map +0 -1
  61. package/dist/cjs/index.d.cts +0 -9
  62. package/dist/esm/index.d.ts +0 -9
  63. package/dist/esm/index.js +0 -55
  64. package/dist/esm/index.js.map +0 -1
  65. package/src/index.tsx +0 -94
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const React = require("react");
5
- const tableCore = require("@tanstack/table-core");
6
- function _interopNamespaceDefault(e) {
7
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
- if (e) {
9
- for (const k in e) {
10
- if (k !== "default") {
11
- const d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: () => e[k]
15
- });
16
- }
17
- }
18
- }
19
- n.default = e;
20
- return Object.freeze(n);
21
- }
22
- const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
23
- function flexRender(Comp, props) {
24
- return !Comp ? null : isReactComponent(Comp) ? /* @__PURE__ */ jsxRuntime.jsx(Comp, { ...props }) : Comp;
25
- }
26
- function isReactComponent(component) {
27
- return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
28
- }
29
- function isClassComponent(component) {
30
- return typeof component === "function" && (() => {
31
- const proto = Object.getPrototypeOf(component);
32
- return proto.prototype && proto.prototype.isReactComponent;
33
- })();
34
- }
35
- function isExoticComponent(component) {
36
- return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
37
- }
38
- function useReactTable(options) {
39
- const resolvedOptions = {
40
- state: {},
41
- // Dummy state
42
- onStateChange: () => {
43
- },
44
- // noop
45
- renderFallbackValue: null,
46
- ...options
47
- };
48
- const [tableRef] = React__namespace.useState(() => ({
49
- current: tableCore.createTable(resolvedOptions)
50
- }));
51
- const [state, setState] = React__namespace.useState(() => tableRef.current.initialState);
52
- tableRef.current.setOptions((prev) => ({
53
- ...prev,
54
- ...options,
55
- state: {
56
- ...state,
57
- ...options.state
58
- },
59
- // Similarly, we'll maintain both our internal state and any user-provided
60
- // state.
61
- onStateChange: (updater) => {
62
- var _a;
63
- setState(updater);
64
- (_a = options.onStateChange) == null ? void 0 : _a.call(options, updater);
65
- }
66
- }));
67
- return tableRef.current;
68
- }
69
- exports.flexRender = flexRender;
70
- exports.useReactTable = useReactTable;
71
- Object.keys(tableCore).forEach((k) => {
72
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
73
- Object.defineProperty(exports, k, {
74
- enumerable: true,
75
- get: () => tableCore[k]
76
- });
77
- });
78
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","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\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\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":["jsx","React","createTable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBgB,SAAA,WACd,MACA,OAC+B;AACxB,SAAA,CAAC,OAAO,OAAO,iBAAyB,IAAI,IAChDA,+BAAA,MAAA,EAAM,GAAG,MAAO,CAAA,IAEjB;AAEJ;AAEA,SAAS,iBACP,WAC0C;AAC1C,SACE,iBAAiB,SAAS,KAC1B,OAAO,cAAc,cACrB,kBAAkB,SAAS;AAE/B;AAEA,SAAS,iBAAiB,WAAgB;AAEtC,SAAA,OAAO,cAAc,eACpB,MAAM;AACC,UAAA,QAAQ,OAAO,eAAe,SAAS;AACtC,WAAA,MAAM,aAAa,MAAM,UAAU;AAAA,EAAA;AAGhD;AAEA,SAAS,kBAAkB,WAAgB;AACzC,SACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,mBAAmB,EAAE,SAAS,UAAU,SAAS,WAAW;AAE/E;AAEO,SAAS,cACd,SACA;AAEA,QAAM,kBAA+C;AAAA,IACnD,OAAO,CAAC;AAAA;AAAA,IACR,eAAe,MAAM;AAAA,IAAC;AAAA;AAAA,IACtB,qBAAqB;AAAA,IACrB,GAAG;AAAA,EAAA;AAIL,QAAM,CAAC,QAAQ,IAAIC,iBAAM,SAAS,OAAO;AAAA,IACvC,SAASC,sBAAmB,eAAe;AAAA,EAC3C,EAAA;AAGI,QAAA,CAAC,OAAO,QAAQ,IAAID,iBAAM,SAAS,MAAM,SAAS,QAAQ,YAAY;AAInE,WAAA,QAAQ,WAAW,CAAS,UAAA;AAAA,IACnC,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG,QAAQ;AAAA,IACb;AAAA;AAAA;AAAA,IAGA,eAAe,CAAW,YAAA;;AACxB,eAAS,OAAO;AAChB,oBAAQ,kBAAR,iCAAwB;AAAA,IAC1B;AAAA,EACA,EAAA;AAEF,SAAO,SAAS;AAClB;;;;;;;;;;"}
@@ -1,9 +0,0 @@
1
- import { TableOptions, RowData } from '@tanstack/table-core';
2
- import * as React from 'react';
3
- export * from '@tanstack/table-core';
4
- export type Renderable<TProps> = React.ReactNode | React.ComponentType<TProps>;
5
- /**
6
- * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
7
- */
8
- export declare function flexRender<TProps extends object>(Comp: Renderable<TProps>, props: TProps): React.ReactNode | JSX.Element;
9
- export declare function useReactTable<TData extends RowData>(options: TableOptions<TData>): import('@tanstack/table-core').Table<TData>;
@@ -1,9 +0,0 @@
1
- import { TableOptions, RowData } from '@tanstack/table-core';
2
- import * as React from 'react';
3
- export * from '@tanstack/table-core';
4
- export type Renderable<TProps> = React.ReactNode | React.ComponentType<TProps>;
5
- /**
6
- * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
7
- */
8
- export declare function flexRender<TProps extends object>(Comp: Renderable<TProps>, props: TProps): React.ReactNode | JSX.Element;
9
- export declare function useReactTable<TData extends RowData>(options: TableOptions<TData>): import('@tanstack/table-core').Table<TData>;
package/dist/esm/index.js DELETED
@@ -1,55 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { createTable } from "@tanstack/table-core";
4
- export * from "@tanstack/table-core";
5
- function flexRender(Comp, props) {
6
- return !Comp ? null : isReactComponent(Comp) ? /* @__PURE__ */ jsx(Comp, { ...props }) : Comp;
7
- }
8
- function isReactComponent(component) {
9
- return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
10
- }
11
- function isClassComponent(component) {
12
- return typeof component === "function" && (() => {
13
- const proto = Object.getPrototypeOf(component);
14
- return proto.prototype && proto.prototype.isReactComponent;
15
- })();
16
- }
17
- function isExoticComponent(component) {
18
- return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
19
- }
20
- function useReactTable(options) {
21
- const resolvedOptions = {
22
- state: {},
23
- // Dummy state
24
- onStateChange: () => {
25
- },
26
- // noop
27
- renderFallbackValue: null,
28
- ...options
29
- };
30
- const [tableRef] = React.useState(() => ({
31
- current: createTable(resolvedOptions)
32
- }));
33
- const [state, setState] = React.useState(() => tableRef.current.initialState);
34
- tableRef.current.setOptions((prev) => ({
35
- ...prev,
36
- ...options,
37
- state: {
38
- ...state,
39
- ...options.state
40
- },
41
- // Similarly, we'll maintain both our internal state and any user-provided
42
- // state.
43
- onStateChange: (updater) => {
44
- var _a;
45
- setState(updater);
46
- (_a = options.onStateChange) == null ? void 0 : _a.call(options, updater);
47
- }
48
- }));
49
- return tableRef.current;
50
- }
51
- export {
52
- flexRender,
53
- useReactTable
54
- };
55
- //# sourceMappingURL=index.js.map
@@ -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 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\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\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":[],"mappings":";;;;AAiBgB,SAAA,WACd,MACA,OAC+B;AACxB,SAAA,CAAC,OAAO,OAAO,iBAAyB,IAAI,IAChD,oBAAA,MAAA,EAAM,GAAG,MAAO,CAAA,IAEjB;AAEJ;AAEA,SAAS,iBACP,WAC0C;AAC1C,SACE,iBAAiB,SAAS,KAC1B,OAAO,cAAc,cACrB,kBAAkB,SAAS;AAE/B;AAEA,SAAS,iBAAiB,WAAgB;AAEtC,SAAA,OAAO,cAAc,eACpB,MAAM;AACC,UAAA,QAAQ,OAAO,eAAe,SAAS;AACtC,WAAA,MAAM,aAAa,MAAM,UAAU;AAAA,EAAA;AAGhD;AAEA,SAAS,kBAAkB,WAAgB;AACzC,SACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,mBAAmB,EAAE,SAAS,UAAU,SAAS,WAAW;AAE/E;AAEO,SAAS,cACd,SACA;AAEA,QAAM,kBAA+C;AAAA,IACnD,OAAO,CAAC;AAAA;AAAA,IACR,eAAe,MAAM;AAAA,IAAC;AAAA;AAAA,IACtB,qBAAqB;AAAA,IACrB,GAAG;AAAA,EAAA;AAIL,QAAM,CAAC,QAAQ,IAAI,MAAM,SAAS,OAAO;AAAA,IACvC,SAAS,YAAmB,eAAe;AAAA,EAC3C,EAAA;AAGI,QAAA,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,MAAM,SAAS,QAAQ,YAAY;AAInE,WAAA,QAAQ,WAAW,CAAS,UAAA;AAAA,IACnC,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG,QAAQ;AAAA,IACb;AAAA;AAAA;AAAA,IAGA,eAAe,CAAW,YAAA;;AACxB,eAAS,OAAO;AAChB,oBAAQ,kBAAR,iCAAwB;AAAA,IAC1B;AAAA,EACA,EAAA;AAEF,SAAO,SAAS;AAClB;"}
package/src/index.tsx DELETED
@@ -1,94 +0,0 @@
1
- import * as React from 'react'
2
- export * from '@tanstack/table-core'
3
-
4
- import {
5
- TableOptions,
6
- TableOptionsResolved,
7
- RowData,
8
- createTable,
9
- } from '@tanstack/table-core'
10
-
11
- export type Renderable<TProps> = React.ReactNode | React.ComponentType<TProps>
12
-
13
- //
14
-
15
- /**
16
- * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
17
- */
18
- export function flexRender<TProps extends object>(
19
- Comp: Renderable<TProps>,
20
- props: TProps
21
- ): React.ReactNode | JSX.Element {
22
- return !Comp ? null : isReactComponent<TProps>(Comp) ? (
23
- <Comp {...props} />
24
- ) : (
25
- Comp
26
- )
27
- }
28
-
29
- function isReactComponent<TProps>(
30
- component: unknown
31
- ): component is React.ComponentType<TProps> {
32
- return (
33
- isClassComponent(component) ||
34
- typeof component === 'function' ||
35
- isExoticComponent(component)
36
- )
37
- }
38
-
39
- function isClassComponent(component: any) {
40
- return (
41
- typeof component === 'function' &&
42
- (() => {
43
- const proto = Object.getPrototypeOf(component)
44
- return proto.prototype && proto.prototype.isReactComponent
45
- })()
46
- )
47
- }
48
-
49
- function isExoticComponent(component: any) {
50
- return (
51
- typeof component === 'object' &&
52
- typeof component.$$typeof === 'symbol' &&
53
- ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)
54
- )
55
- }
56
-
57
- export function useReactTable<TData extends RowData>(
58
- options: TableOptions<TData>
59
- ) {
60
- // Compose in the generic options to the user options
61
- const resolvedOptions: TableOptionsResolved<TData> = {
62
- state: {}, // Dummy state
63
- onStateChange: () => {}, // noop
64
- renderFallbackValue: null,
65
- ...options,
66
- }
67
-
68
- // Create a new table and store it in state
69
- const [tableRef] = React.useState(() => ({
70
- current: createTable<TData>(resolvedOptions),
71
- }))
72
-
73
- // By default, manage table state here using the table's initial state
74
- const [state, setState] = React.useState(() => tableRef.current.initialState)
75
-
76
- // Compose the default state above with any user state. This will allow the user
77
- // to only control a subset of the state if desired.
78
- tableRef.current.setOptions(prev => ({
79
- ...prev,
80
- ...options,
81
- state: {
82
- ...state,
83
- ...options.state,
84
- },
85
- // Similarly, we'll maintain both our internal state and any user-provided
86
- // state.
87
- onStateChange: updater => {
88
- setState(updater)
89
- options.onStateChange?.(updater)
90
- },
91
- }))
92
-
93
- return tableRef.current
94
- }