@tanstack/react-table 9.0.0-alpha.9 → 9.0.0-beta.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.
Files changed (82) hide show
  1. package/README.md +127 -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 +13 -0
  9. package/dist/Subscribe.cjs.map +1 -0
  10. package/dist/Subscribe.d.cts +101 -0
  11. package/dist/Subscribe.d.ts +101 -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/reactivity.cjs +34 -0
  34. package/dist/reactivity.cjs.map +1 -0
  35. package/dist/reactivity.js +34 -0
  36. package/dist/reactivity.js.map +1 -0
  37. package/dist/static-functions.cjs +9 -0
  38. package/dist/static-functions.d.cts +1 -0
  39. package/dist/static-functions.d.ts +1 -0
  40. package/dist/static-functions.js +3 -0
  41. package/dist/useLegacyTable.cjs +191 -0
  42. package/dist/useLegacyTable.cjs.map +1 -0
  43. package/dist/useLegacyTable.d.cts +233 -0
  44. package/dist/useLegacyTable.d.ts +233 -0
  45. package/dist/useLegacyTable.js +181 -0
  46. package/dist/useLegacyTable.js.map +1 -0
  47. package/dist/useTable.cjs +72 -0
  48. package/dist/useTable.cjs.map +1 -0
  49. package/dist/useTable.d.cts +122 -0
  50. package/dist/useTable.d.ts +122 -0
  51. package/dist/useTable.js +72 -0
  52. package/dist/useTable.js.map +1 -0
  53. package/package.json +41 -22
  54. package/skills/react/client-to-server/SKILL.md +377 -0
  55. package/skills/react/compose-with-tanstack-form/SKILL.md +363 -0
  56. package/skills/react/compose-with-tanstack-pacer/SKILL.md +287 -0
  57. package/skills/react/compose-with-tanstack-query/SKILL.md +467 -0
  58. package/skills/react/compose-with-tanstack-store/SKILL.md +347 -0
  59. package/skills/react/compose-with-tanstack-virtual/SKILL.md +388 -0
  60. package/skills/react/compose-with-tanstack-virtual/references/column-virtualization-and-infinite-scroll.md +136 -0
  61. package/skills/react/getting-started/SKILL.md +388 -0
  62. package/skills/react/migrate-v8-to-v9/SKILL.md +488 -0
  63. package/skills/react/production-readiness/SKILL.md +341 -0
  64. package/skills/react/react-subscribe-compiler-compat/SKILL.md +269 -0
  65. package/skills/react/table-state/SKILL.md +432 -0
  66. package/src/FlexRender.tsx +136 -0
  67. package/src/Subscribe.ts +153 -0
  68. package/src/createTableHook.tsx +1121 -0
  69. package/src/flex-render.ts +1 -0
  70. package/src/index.ts +6 -0
  71. package/src/legacy.ts +3 -0
  72. package/src/reactivity.ts +41 -0
  73. package/src/static-functions.ts +1 -0
  74. package/src/useLegacyTable.ts +487 -0
  75. package/src/useTable.ts +191 -0
  76. package/dist/cjs/index.cjs +0 -77
  77. package/dist/cjs/index.cjs.map +0 -1
  78. package/dist/cjs/index.d.cts +0 -9
  79. package/dist/esm/index.d.ts +0 -9
  80. package/dist/esm/index.js +0 -55
  81. package/dist/esm/index.js.map +0 -1
  82. package/src/index.tsx +0 -92
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ <div align="center">
2
+ <img src="./media/header_table.png" alt="TanStack Table">
3
+ </div>
4
+
5
+ <br />
6
+
7
+ <div align="center">
8
+ <a href="https://npmjs.com/package/@tanstack/react-table" target="\_parent">
9
+ <img alt="npm downloads" src="https://img.shields.io/npm/dm/@tanstack/react-table.svg" />
10
+ </a>
11
+ <a href="https://github.com/tanstack/table" target="\_parent">
12
+ <img alt="github stars" src="https://img.shields.io/github/stars/tanstack/react-table.svg?style=social&label=Star" />
13
+ </a>
14
+ <a href="https://bundlephobia.com/result?p=@tanstack/react-table@latest" target="\_parent">
15
+ <img alt="bundle size" src="https://badgen.net/bundlephobia/minzip/@tanstack/react-table@latest" />
16
+ </a>
17
+ </div>
18
+
19
+ <div align="center">
20
+ <a href="#badge">
21
+ <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
22
+ </a>
23
+ <a href="https://bestofjs.org/projects/tanstack-table"><img alt="Best of JS" src="https://img.shields.io/endpoint?url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=TanStack%2Ftable%26since=daily" /></a>
24
+ <a href="https://twitter.com/tan_stack"><img src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social" alt="Follow @TanStack"/></a>
25
+ </div>
26
+
27
+ ### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
28
+
29
+ </div>
30
+
31
+ # TanStack Table
32
+
33
+ > [!NOTE]
34
+ > You may know TanStack Table by the adapter names:
35
+ >
36
+ > - [Angular Table](https://tanstack.com/table/alpha/docs/framework/angular/angular-table)
37
+ > - [Lit Table](https://tanstack.com/table/alpha/docs/framework/lit/lit-table)
38
+ > - [React Table](https://tanstack.com/table/alpha/docs/framework/react/react-table)
39
+ > - [Solid Table](https://tanstack.com/table/alpha/docs/framework/solid/solid-table)
40
+ > - [Svelte Table](https://tanstack.com/table/alpha/docs/framework/svelte/svelte-table)
41
+ > - [Vue Table](https://tanstack.com/table/alpha/docs/framework/vue/vue-table)
42
+
43
+ A headless table library for building powerful datagrids with full control over markup, styles, and behavior.
44
+
45
+ - Framework‑agnostic core with bindings for React, Vue & Solid
46
+ - 100% customizable — bring your own UI, components, and styles
47
+ - Sorting, filtering, grouping, aggregation & row selection
48
+ - Lightweight, virtualizable & server‑side friendly
49
+
50
+ ### <a href="https://tanstack.com/table">Read the Docs →</a>
51
+
52
+ ## Using an AI Coding Agent?
53
+
54
+ TanStack Table ships [TanStack Intent](https://github.com/TanStack/intent) skills inside each adapter package. After installing the library, run:
55
+
56
+ ```sh
57
+ npx @tanstack/intent@latest install
58
+ ```
59
+
60
+ to add skill-loading guidance for your agent (Claude Code, Cursor, Copilot, etc.). The same CLI also exposes `intent list` to browse available skills and `intent load <skill>` to print one for inspection. Skills version with the library — your agent gets guidance that matches the version of `@tanstack/<framework>-table` you installed. Only available for v9 and above.
61
+
62
+ ## Get Involved
63
+
64
+ - We welcome issues and pull requests!
65
+ - Participate in [GitHub discussions](https://github.com/TanStack/table/discussions)
66
+ - Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ)
67
+ - See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions
68
+
69
+ ## Partners
70
+
71
+ <table align="center">
72
+ <tr>
73
+ <td>
74
+ <a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS">
75
+ <picture>
76
+ <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-CMcuvjEy.svg" height="40" />
77
+ <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" />
78
+ <img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" />
79
+ </picture>
80
+ </a>
81
+ </td>
82
+ <td padding="20">
83
+ <a href="https://www.cloudflare.com?utm_source=tanstack">
84
+ <picture>
85
+ <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-DQDB7UaL.svg" height="60" />
86
+ <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" />
87
+ <img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" />
88
+ </picture>
89
+ </a>
90
+ </td>
91
+ <td>
92
+ <a href="https://ag-grid.com/react-data-grid/?utm_source=reacttable&utm_campaign=githubreacttable" style="display: flex; align-items: center; border: none;">
93
+ <picture>
94
+ <source media="(prefers-color-scheme: dark)" srcset="./media/ag-grid-dark.svg" height="40" />
95
+ <source media="(prefers-color-scheme: light)" srcset="./media/ag-grid-light.svg" height="40" />
96
+ <img src="https://raw.githubusercontent.com/tannerlinsley/files/master/partners/ag-grid.svg" height="60" alt="AG Grid" />
97
+ </picture>
98
+ </a>
99
+ </td>
100
+ </tr>
101
+ </table>
102
+
103
+ <div align="center">
104
+ <img src="./media/partner_logo.svg" alt="Table & you?" height="65">
105
+ <p>
106
+ We're looking for TanStack Table Partners to join our mission! Partner with us to push the boundaries of TanStack Table and build amazing things together.
107
+ </p>
108
+ <a href="mailto:partners@tanstack.com?subject=TanStack Table Partnership"><b>LET'S CHAT</b></a>
109
+ </div>
110
+
111
+ ## Explore the TanStack Ecosystem
112
+
113
+ - <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages
114
+ - <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store
115
+ - <a href="https://github.com/tanstack/devtools"><b>TanStack DevTools</b></a> – Unified devtools panel
116
+ - <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state
117
+ - <a href="https://github.com/tanstack/pacer"><b>TanStack Pacer</b></a> – Debouncing, throttling, batching <br/>
118
+ - <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching
119
+ - <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives
120
+ - <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state
121
+ - <a href="https://github.com/tanstack/router"><b>TanStack Start</b></a> – Full‑stack SSR & streaming
122
+ - <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store
123
+ - <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering
124
+
125
+ … and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a>
126
+
127
+ <!-- USE THE FORCE LUKE -->
@@ -0,0 +1,61 @@
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ let react = require("react");
3
+ react = require_runtime.__toESM(react);
4
+
5
+ //#region src/FlexRender.tsx
6
+ function isReactComponent(component) {
7
+ return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
8
+ }
9
+ function isClassComponent(component) {
10
+ return typeof component === "function" && (() => {
11
+ const proto = Object.getPrototypeOf(component);
12
+ return proto.prototype && proto.prototype.isReactComponent;
13
+ })();
14
+ }
15
+ function isExoticComponent(component) {
16
+ return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
17
+ }
18
+ /**
19
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
20
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
21
+ */
22
+ function flexRender(Comp, props) {
23
+ return !Comp ? null : isReactComponent(Comp) ? /* @__PURE__ */ react.default.createElement(Comp, props) : Comp;
24
+ }
25
+ /**
26
+ * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
27
+ * Only one prop (`cell`, `header`, or `footer`) may be passed.
28
+ * @example
29
+ * ```tsx
30
+ * <FlexRender cell={cell} />
31
+ * <FlexRender header={header} />
32
+ * <FlexRender footer={footer} />
33
+ * ```
34
+ *
35
+ * This replaces calling `flexRender` directly like this:
36
+ * ```tsx
37
+ * flexRender(cell.column.columnDef.cell, cell.getContext())
38
+ * flexRender(header.column.columnDef.header, header.getContext())
39
+ * flexRender(footer.column.columnDef.footer, footer.getContext())
40
+ * ```
41
+ */
42
+ function FlexRender(props) {
43
+ if ("cell" in props && props.cell) {
44
+ var _groupingCell$getIsAg, _groupingCell$getIsPl;
45
+ const cell = props.cell;
46
+ const def = cell.column.columnDef;
47
+ const groupingCell = cell;
48
+ const groupingDef = def;
49
+ if ((_groupingCell$getIsAg = groupingCell.getIsAggregated) === null || _groupingCell$getIsAg === void 0 ? void 0 : _groupingCell$getIsAg.call(groupingCell)) return flexRender(groupingDef.aggregatedCell ?? def.cell, cell.getContext());
50
+ if ((_groupingCell$getIsPl = groupingCell.getIsPlaceholder) === null || _groupingCell$getIsPl === void 0 ? void 0 : _groupingCell$getIsPl.call(groupingCell)) return null;
51
+ return flexRender(def.cell, cell.getContext());
52
+ }
53
+ if ("header" in props && props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
54
+ if ("footer" in props && props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
55
+ return null;
56
+ }
57
+
58
+ //#endregion
59
+ exports.FlexRender = FlexRender;
60
+ exports.flexRender = flexRender;
61
+ //# sourceMappingURL=FlexRender.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlexRender.cjs","names":[],"sources":["../src/FlexRender.tsx"],"sourcesContent":["import React from 'react'\nimport type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentType, JSX, ReactNode } from 'react'\n\nexport type Renderable<TProps> = ReactNode | ComponentType<TProps>\n\nfunction isReactComponent<TProps>(\n component: unknown,\n): component is 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\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\n * @example flexRender(cell.column.columnDef.cell, cell.getContext())\n */\nexport function flexRender<TProps extends object>(\n Comp: Renderable<TProps>,\n props: TProps,\n): ReactNode | JSX.Element {\n return !Comp ? null : isReactComponent<TProps>(Comp) ? (\n <Comp {...props} />\n ) : (\n Comp\n )\n}\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example <FlexRender cell={cell} />\n * @example <FlexRender header={header} />\n * @example <FlexRender footer={footer} />\n */\nexport type FlexRenderProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> =\n | { cell: Cell<TFeatures, TData, TValue>; header?: never; footer?: never }\n | {\n header: Header<TFeatures, TData, TValue>\n cell?: never\n footer?: never\n }\n | {\n footer: Header<TFeatures, TData, TValue>\n cell?: never\n header?: never\n }\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example\n * ```tsx\n * <FlexRender cell={cell} />\n * <FlexRender header={header} />\n * <FlexRender footer={footer} />\n * ```\n *\n * This replaces calling `flexRender` directly like this:\n * ```tsx\n * flexRender(cell.column.columnDef.cell, cell.getContext())\n * flexRender(header.column.columnDef.header, header.getContext())\n * flexRender(footer.column.columnDef.footer, footer.getContext())\n * ```\n */\nexport function FlexRender<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(props: FlexRenderProps<TFeatures, TData, TValue>) {\n if ('cell' in props && props.cell) {\n const cell = props.cell\n const def = cell.column.columnDef\n const groupingCell = cell as typeof cell & {\n getIsAggregated?: () => boolean\n getIsPlaceholder?: () => boolean\n }\n const groupingDef = def as typeof def & {\n aggregatedCell?: typeof def.cell\n }\n if (groupingCell.getIsAggregated?.()) {\n return flexRender(\n groupingDef.aggregatedCell ?? def.cell,\n cell.getContext(),\n )\n }\n if (groupingCell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, cell.getContext())\n }\n if ('header' in props && props.header) {\n return flexRender(\n props.header.column.columnDef.header,\n props.header.getContext(),\n )\n }\n if ('footer' in props && props.footer) {\n return flexRender(\n props.footer.column.columnDef.footer,\n props.footer.getContext(),\n )\n }\n return null\n}\n"],"mappings":";;;;;AAYA,SAAS,iBACP,WACoC;CACpC,OACE,iBAAiB,SAAS,KAC1B,OAAO,cAAc,cACrB,kBAAkB,SAAS;AAE/B;AAEA,SAAS,iBAAiB,WAAgB;CACxC,OACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,SAAS;EAC7C,OAAO,MAAM,aAAa,MAAM,UAAU;CAC5C,EAAC,CAAE;AAEP;AAEA,SAAS,kBAAkB,WAAgB;CACzC,OACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,mBAAmB,CAAC,CAAC,SAAS,UAAU,SAAS,WAAW;AAE/E;;;;;AAMA,SAAgB,WACd,MACA,OACyB;CACzB,OAAO,CAAC,OAAO,OAAO,iBAAyB,IAAI,IACjD,4CAAC,MAAS,KAAQ,IAElB;AAEJ;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,WAId,OAAkD;CAClD,IAAI,UAAU,SAAS,MAAM,MAAM;;EACjC,MAAM,OAAO,MAAM;EACnB,MAAM,MAAM,KAAK,OAAO;EACxB,MAAM,eAAe;EAIrB,MAAM,cAAc;EAGpB,6BAAI,aAAa,gHAAkB,GACjC,OAAO,WACL,YAAY,kBAAkB,IAAI,MAClC,KAAK,WAAW,CAClB;EAEF,6BAAI,aAAa,iHAAmB,GAClC,OAAO;EAET,OAAO,WAAW,IAAI,MAAM,KAAK,WAAW,CAAC;CAC/C;CACA,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,OAAO;AACT"}
@@ -0,0 +1,51 @@
1
+ import React, { ComponentType, JSX, ReactNode } from "react";
2
+ import { Cell, CellData, Header, RowData, TableFeatures } from "@tanstack/table-core";
3
+
4
+ //#region src/FlexRender.d.ts
5
+ type Renderable<TProps> = ReactNode | ComponentType<TProps>;
6
+ /**
7
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
8
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
9
+ */
10
+ declare function flexRender<TProps extends object>(Comp: Renderable<TProps>, props: TProps): ReactNode | JSX.Element;
11
+ /**
12
+ * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
13
+ * Only one prop (`cell`, `header`, or `footer`) may be passed.
14
+ * @example <FlexRender cell={cell} />
15
+ * @example <FlexRender header={header} />
16
+ * @example <FlexRender footer={footer} />
17
+ */
18
+ type FlexRenderProps<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> = {
19
+ cell: Cell<TFeatures, TData, TValue>;
20
+ header?: never;
21
+ footer?: never;
22
+ } | {
23
+ header: Header<TFeatures, TData, TValue>;
24
+ cell?: never;
25
+ footer?: never;
26
+ } | {
27
+ footer: Header<TFeatures, TData, TValue>;
28
+ cell?: never;
29
+ header?: never;
30
+ };
31
+ /**
32
+ * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
33
+ * Only one prop (`cell`, `header`, or `footer`) may be passed.
34
+ * @example
35
+ * ```tsx
36
+ * <FlexRender cell={cell} />
37
+ * <FlexRender header={header} />
38
+ * <FlexRender footer={footer} />
39
+ * ```
40
+ *
41
+ * This replaces calling `flexRender` directly like this:
42
+ * ```tsx
43
+ * flexRender(cell.column.columnDef.cell, cell.getContext())
44
+ * flexRender(header.column.columnDef.header, header.getContext())
45
+ * flexRender(footer.column.columnDef.footer, footer.getContext())
46
+ * ```
47
+ */
48
+ declare function FlexRender<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | JSX.Element | null | undefined;
49
+ //#endregion
50
+ export { FlexRender, FlexRenderProps, Renderable, flexRender };
51
+ //# sourceMappingURL=FlexRender.d.cts.map
@@ -0,0 +1,51 @@
1
+ import { Cell, CellData, Header, RowData, TableFeatures } from "@tanstack/table-core";
2
+ import React, { ComponentType, JSX, ReactNode } from "react";
3
+
4
+ //#region src/FlexRender.d.ts
5
+ type Renderable<TProps> = ReactNode | ComponentType<TProps>;
6
+ /**
7
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
8
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
9
+ */
10
+ declare function flexRender<TProps extends object>(Comp: Renderable<TProps>, props: TProps): ReactNode | JSX.Element;
11
+ /**
12
+ * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
13
+ * Only one prop (`cell`, `header`, or `footer`) may be passed.
14
+ * @example <FlexRender cell={cell} />
15
+ * @example <FlexRender header={header} />
16
+ * @example <FlexRender footer={footer} />
17
+ */
18
+ type FlexRenderProps<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> = {
19
+ cell: Cell<TFeatures, TData, TValue>;
20
+ header?: never;
21
+ footer?: never;
22
+ } | {
23
+ header: Header<TFeatures, TData, TValue>;
24
+ cell?: never;
25
+ footer?: never;
26
+ } | {
27
+ footer: Header<TFeatures, TData, TValue>;
28
+ cell?: never;
29
+ header?: never;
30
+ };
31
+ /**
32
+ * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
33
+ * Only one prop (`cell`, `header`, or `footer`) may be passed.
34
+ * @example
35
+ * ```tsx
36
+ * <FlexRender cell={cell} />
37
+ * <FlexRender header={header} />
38
+ * <FlexRender footer={footer} />
39
+ * ```
40
+ *
41
+ * This replaces calling `flexRender` directly like this:
42
+ * ```tsx
43
+ * flexRender(cell.column.columnDef.cell, cell.getContext())
44
+ * flexRender(header.column.columnDef.header, header.getContext())
45
+ * flexRender(footer.column.columnDef.footer, footer.getContext())
46
+ * ```
47
+ */
48
+ declare function FlexRender<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | JSX.Element | null | undefined;
49
+ //#endregion
50
+ export { FlexRender, FlexRenderProps, Renderable, flexRender };
51
+ //# sourceMappingURL=FlexRender.d.ts.map
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+
3
+ //#region src/FlexRender.tsx
4
+ function isReactComponent(component) {
5
+ return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
6
+ }
7
+ function isClassComponent(component) {
8
+ return typeof component === "function" && (() => {
9
+ const proto = Object.getPrototypeOf(component);
10
+ return proto.prototype && proto.prototype.isReactComponent;
11
+ })();
12
+ }
13
+ function isExoticComponent(component) {
14
+ return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
15
+ }
16
+ /**
17
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
18
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
19
+ */
20
+ function flexRender(Comp, props) {
21
+ return !Comp ? null : isReactComponent(Comp) ? /* @__PURE__ */ React.createElement(Comp, props) : Comp;
22
+ }
23
+ /**
24
+ * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
25
+ * Only one prop (`cell`, `header`, or `footer`) may be passed.
26
+ * @example
27
+ * ```tsx
28
+ * <FlexRender cell={cell} />
29
+ * <FlexRender header={header} />
30
+ * <FlexRender footer={footer} />
31
+ * ```
32
+ *
33
+ * This replaces calling `flexRender` directly like this:
34
+ * ```tsx
35
+ * flexRender(cell.column.columnDef.cell, cell.getContext())
36
+ * flexRender(header.column.columnDef.header, header.getContext())
37
+ * flexRender(footer.column.columnDef.footer, footer.getContext())
38
+ * ```
39
+ */
40
+ function FlexRender(props) {
41
+ if ("cell" in props && props.cell) {
42
+ var _groupingCell$getIsAg, _groupingCell$getIsPl;
43
+ const cell = props.cell;
44
+ const def = cell.column.columnDef;
45
+ const groupingCell = cell;
46
+ const groupingDef = def;
47
+ if ((_groupingCell$getIsAg = groupingCell.getIsAggregated) === null || _groupingCell$getIsAg === void 0 ? void 0 : _groupingCell$getIsAg.call(groupingCell)) return flexRender(groupingDef.aggregatedCell ?? def.cell, cell.getContext());
48
+ if ((_groupingCell$getIsPl = groupingCell.getIsPlaceholder) === null || _groupingCell$getIsPl === void 0 ? void 0 : _groupingCell$getIsPl.call(groupingCell)) return null;
49
+ return flexRender(def.cell, cell.getContext());
50
+ }
51
+ if ("header" in props && props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
52
+ if ("footer" in props && props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
53
+ return null;
54
+ }
55
+
56
+ //#endregion
57
+ export { FlexRender, flexRender };
58
+ //# sourceMappingURL=FlexRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlexRender.js","names":[],"sources":["../src/FlexRender.tsx"],"sourcesContent":["import React from 'react'\nimport type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentType, JSX, ReactNode } from 'react'\n\nexport type Renderable<TProps> = ReactNode | ComponentType<TProps>\n\nfunction isReactComponent<TProps>(\n component: unknown,\n): component is 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\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\n * @example flexRender(cell.column.columnDef.cell, cell.getContext())\n */\nexport function flexRender<TProps extends object>(\n Comp: Renderable<TProps>,\n props: TProps,\n): ReactNode | JSX.Element {\n return !Comp ? null : isReactComponent<TProps>(Comp) ? (\n <Comp {...props} />\n ) : (\n Comp\n )\n}\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example <FlexRender cell={cell} />\n * @example <FlexRender header={header} />\n * @example <FlexRender footer={footer} />\n */\nexport type FlexRenderProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> =\n | { cell: Cell<TFeatures, TData, TValue>; header?: never; footer?: never }\n | {\n header: Header<TFeatures, TData, TValue>\n cell?: never\n footer?: never\n }\n | {\n footer: Header<TFeatures, TData, TValue>\n cell?: never\n header?: never\n }\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example\n * ```tsx\n * <FlexRender cell={cell} />\n * <FlexRender header={header} />\n * <FlexRender footer={footer} />\n * ```\n *\n * This replaces calling `flexRender` directly like this:\n * ```tsx\n * flexRender(cell.column.columnDef.cell, cell.getContext())\n * flexRender(header.column.columnDef.header, header.getContext())\n * flexRender(footer.column.columnDef.footer, footer.getContext())\n * ```\n */\nexport function FlexRender<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(props: FlexRenderProps<TFeatures, TData, TValue>) {\n if ('cell' in props && props.cell) {\n const cell = props.cell\n const def = cell.column.columnDef\n const groupingCell = cell as typeof cell & {\n getIsAggregated?: () => boolean\n getIsPlaceholder?: () => boolean\n }\n const groupingDef = def as typeof def & {\n aggregatedCell?: typeof def.cell\n }\n if (groupingCell.getIsAggregated?.()) {\n return flexRender(\n groupingDef.aggregatedCell ?? def.cell,\n cell.getContext(),\n )\n }\n if (groupingCell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, cell.getContext())\n }\n if ('header' in props && props.header) {\n return flexRender(\n props.header.column.columnDef.header,\n props.header.getContext(),\n )\n }\n if ('footer' in props && props.footer) {\n return flexRender(\n props.footer.column.columnDef.footer,\n props.footer.getContext(),\n )\n }\n return null\n}\n"],"mappings":";;;AAYA,SAAS,iBACP,WACoC;CACpC,OACE,iBAAiB,SAAS,KAC1B,OAAO,cAAc,cACrB,kBAAkB,SAAS;AAE/B;AAEA,SAAS,iBAAiB,WAAgB;CACxC,OACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,SAAS;EAC7C,OAAO,MAAM,aAAa,MAAM,UAAU;CAC5C,EAAC,CAAE;AAEP;AAEA,SAAS,kBAAkB,WAAgB;CACzC,OACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,mBAAmB,CAAC,CAAC,SAAS,UAAU,SAAS,WAAW;AAE/E;;;;;AAMA,SAAgB,WACd,MACA,OACyB;CACzB,OAAO,CAAC,OAAO,OAAO,iBAAyB,IAAI,IACjD,oCAAC,MAAS,KAAQ,IAElB;AAEJ;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,WAId,OAAkD;CAClD,IAAI,UAAU,SAAS,MAAM,MAAM;;EACjC,MAAM,OAAO,MAAM;EACnB,MAAM,MAAM,KAAK,OAAO;EACxB,MAAM,eAAe;EAIrB,MAAM,cAAc;EAGpB,6BAAI,aAAa,gHAAkB,GACjC,OAAO,WACL,YAAY,kBAAkB,IAAI,MAClC,KAAK,WAAW,CAClB;EAEF,6BAAI,aAAa,iHAAmB,GAClC,OAAO;EAET,OAAO,WAAW,IAAI,MAAM,KAAK,WAAW,CAAC;CAC/C;CACA,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,OAAO;AACT"}
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+
3
+ let _tanstack_react_store = require("@tanstack/react-store");
4
+
5
+ //#region src/Subscribe.ts
6
+ function Subscribe(props) {
7
+ const selected = (0, _tanstack_react_store.useSelector)(props.source, props.selector, { compare: _tanstack_react_store.shallow });
8
+ return typeof props.children === "function" ? props.children(selected) : props.children;
9
+ }
10
+
11
+ //#endregion
12
+ exports.Subscribe = Subscribe;
13
+ //# sourceMappingURL=Subscribe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Subscribe.cjs","names":["shallow"],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/react-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store). The selector\n * receives the source value; children receive the projected `TSelected`.\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected). Prefer\n * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}\n * for clearer inference when `selector` is omitted.\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\n/**\n * A React component that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX\n * contextual typing works. This standalone component uses a union `props` type.\n *\n * @example\n * ```tsx\n * // As a standalone component — full store\n * <Subscribe source={table.store} selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Entire source (atom or store) — no selector\n * <Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Project source value (e.g. one row’s selection)\n * <Subscribe\n * source={table.atoms.rowSelection}\n * selector={(rowSelection) => rowSelection?.[row.id]}\n * >\n * {(selected) => <tr data-selected={!!selected}>...</tr>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // As table.Subscribe (table instance method)\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </table.Subscribe>\n * ```\n */\nexport function Subscribe<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ReturnType<FunctionComponent> {\n const selected = useSelector(\n // Atom and store share the same selection protocol; union args need a widen for TS.\n props.source,\n props.selector as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ReactNode)(selected)\n : props.children\n}\n"],"mappings":";;;;;AAqIA,SAAgB,UAKd,OAC+B;CAC/B,MAAM,kDAEJ,MAAM,QACN,MAAM,UACN,EACE,SAASA,8BACX,CACF;CAEA,OAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAA6C,QAAQ,IAC5D,MAAM;AACZ"}
@@ -0,0 +1,101 @@
1
+ import { FunctionComponent, ReactNode } from "react";
2
+ import { TableFeatures, TableState } from "@tanstack/table-core";
3
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/react-store";
4
+
5
+ //#region src/Subscribe.d.ts
6
+ type SubscribeSource<TValue> = Atom<TValue> | ReadonlyAtom<TValue> | Store<TValue> | ReadonlyStore<TValue>;
7
+ /**
8
+ * Subscribe to `table.store` (full table state). The selector receives the full
9
+ * {@link TableState}.
10
+ */
11
+ type SubscribePropsWithStore<TFeatures extends TableFeatures, TSelected> = {
12
+ source: SubscribeSource<TableState<TFeatures>>;
13
+ /**
14
+ * Select from full table state. Re-renders when the selected value changes
15
+ * (shallow compare).
16
+ *
17
+ * Required in store mode so you never accidentally subscribe to the whole
18
+ * store without an explicit projection.
19
+ */
20
+ selector: (state: TableState<TFeatures>) => TSelected;
21
+ children: ((state: TSelected) => ReactNode) | ReactNode;
22
+ };
23
+ /**
24
+ * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or
25
+ * `table.optionsStore`). Omitting `selector` is equivalent to the identity
26
+ * selector — children receive `TSourceValue`.
27
+ */
28
+ type SubscribePropsWithSourceIdentity<TSourceValue> = {
29
+ source: SubscribeSource<TSourceValue>;
30
+ selector?: undefined;
31
+ children: ((state: TSourceValue) => ReactNode) | ReactNode;
32
+ };
33
+ /**
34
+ * Subscribe to a projected value from a source (atom or store). The selector
35
+ * receives the source value; children receive the projected `TSelected`.
36
+ */
37
+ type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {
38
+ source: SubscribeSource<TSourceValue>;
39
+ selector: (state: TSourceValue) => TSelected;
40
+ children: ((state: TSelected) => ReactNode) | ReactNode;
41
+ };
42
+ /**
43
+ * Subscribe to a single source — atom or store (identity or projected). Prefer
44
+ * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}
45
+ * for clearer inference when `selector` is omitted.
46
+ */
47
+ type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> = SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
48
+ type SubscribeProps<TFeatures extends TableFeatures, TSelected = unknown, TSourceValue = unknown> = SubscribePropsWithStore<TFeatures, TSelected> | SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
49
+ /**
50
+ * A React component that allows you to subscribe to the table state.
51
+ *
52
+ * This is useful for opting into state re-renders for specific parts of the table state.
53
+ *
54
+ * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX
55
+ * contextual typing works. This standalone component uses a union `props` type.
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * // As a standalone component — full store
60
+ * <Subscribe source={table.store} selector={(state) => ({ rowSelection: state.rowSelection })}>
61
+ * {({ rowSelection }) => (
62
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
63
+ * )}
64
+ * </Subscribe>
65
+ * ```
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * // Entire source (atom or store) — no selector
70
+ * <Subscribe source={table.atoms.rowSelection}>
71
+ * {(rowSelection) => <div>...</div>}
72
+ * </Subscribe>
73
+ * ```
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * // Project source value (e.g. one row’s selection)
78
+ * <Subscribe
79
+ * source={table.atoms.rowSelection}
80
+ * selector={(rowSelection) => rowSelection?.[row.id]}
81
+ * >
82
+ * {(selected) => <tr data-selected={!!selected}>...</tr>}
83
+ * </Subscribe>
84
+ * ```
85
+ *
86
+ * @example
87
+ * ```tsx
88
+ * // As table.Subscribe (table instance method)
89
+ * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
90
+ * {({ rowSelection }) => (
91
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
92
+ * )}
93
+ * </table.Subscribe>
94
+ * ```
95
+ */
96
+ declare function Subscribe<TSourceValue>(props: SubscribePropsWithSourceIdentity<TSourceValue>): ReturnType<FunctionComponent>;
97
+ declare function Subscribe<TSourceValue, TSelected>(props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>): ReturnType<FunctionComponent>;
98
+ declare function Subscribe<TFeatures extends TableFeatures, TSelected>(props: SubscribePropsWithStore<TFeatures, TSelected>): ReturnType<FunctionComponent>;
99
+ //#endregion
100
+ export { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource };
101
+ //# sourceMappingURL=Subscribe.d.cts.map
@@ -0,0 +1,101 @@
1
+ import { TableFeatures, TableState } from "@tanstack/table-core";
2
+ import { FunctionComponent, ReactNode } from "react";
3
+ import { Atom, ReadonlyAtom, ReadonlyStore, Store } from "@tanstack/react-store";
4
+
5
+ //#region src/Subscribe.d.ts
6
+ type SubscribeSource<TValue> = Atom<TValue> | ReadonlyAtom<TValue> | Store<TValue> | ReadonlyStore<TValue>;
7
+ /**
8
+ * Subscribe to `table.store` (full table state). The selector receives the full
9
+ * {@link TableState}.
10
+ */
11
+ type SubscribePropsWithStore<TFeatures extends TableFeatures, TSelected> = {
12
+ source: SubscribeSource<TableState<TFeatures>>;
13
+ /**
14
+ * Select from full table state. Re-renders when the selected value changes
15
+ * (shallow compare).
16
+ *
17
+ * Required in store mode so you never accidentally subscribe to the whole
18
+ * store without an explicit projection.
19
+ */
20
+ selector: (state: TableState<TFeatures>) => TSelected;
21
+ children: ((state: TSelected) => ReactNode) | ReactNode;
22
+ };
23
+ /**
24
+ * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or
25
+ * `table.optionsStore`). Omitting `selector` is equivalent to the identity
26
+ * selector — children receive `TSourceValue`.
27
+ */
28
+ type SubscribePropsWithSourceIdentity<TSourceValue> = {
29
+ source: SubscribeSource<TSourceValue>;
30
+ selector?: undefined;
31
+ children: ((state: TSourceValue) => ReactNode) | ReactNode;
32
+ };
33
+ /**
34
+ * Subscribe to a projected value from a source (atom or store). The selector
35
+ * receives the source value; children receive the projected `TSelected`.
36
+ */
37
+ type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {
38
+ source: SubscribeSource<TSourceValue>;
39
+ selector: (state: TSourceValue) => TSelected;
40
+ children: ((state: TSelected) => ReactNode) | ReactNode;
41
+ };
42
+ /**
43
+ * Subscribe to a single source — atom or store (identity or projected). Prefer
44
+ * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}
45
+ * for clearer inference when `selector` is omitted.
46
+ */
47
+ type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> = SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
48
+ type SubscribeProps<TFeatures extends TableFeatures, TSelected = unknown, TSourceValue = unknown> = SubscribePropsWithStore<TFeatures, TSelected> | SubscribePropsWithSourceIdentity<TSourceValue> | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>;
49
+ /**
50
+ * A React component that allows you to subscribe to the table state.
51
+ *
52
+ * This is useful for opting into state re-renders for specific parts of the table state.
53
+ *
54
+ * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX
55
+ * contextual typing works. This standalone component uses a union `props` type.
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * // As a standalone component — full store
60
+ * <Subscribe source={table.store} selector={(state) => ({ rowSelection: state.rowSelection })}>
61
+ * {({ rowSelection }) => (
62
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
63
+ * )}
64
+ * </Subscribe>
65
+ * ```
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * // Entire source (atom or store) — no selector
70
+ * <Subscribe source={table.atoms.rowSelection}>
71
+ * {(rowSelection) => <div>...</div>}
72
+ * </Subscribe>
73
+ * ```
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * // Project source value (e.g. one row’s selection)
78
+ * <Subscribe
79
+ * source={table.atoms.rowSelection}
80
+ * selector={(rowSelection) => rowSelection?.[row.id]}
81
+ * >
82
+ * {(selected) => <tr data-selected={!!selected}>...</tr>}
83
+ * </Subscribe>
84
+ * ```
85
+ *
86
+ * @example
87
+ * ```tsx
88
+ * // As table.Subscribe (table instance method)
89
+ * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
90
+ * {({ rowSelection }) => (
91
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
92
+ * )}
93
+ * </table.Subscribe>
94
+ * ```
95
+ */
96
+ declare function Subscribe<TSourceValue>(props: SubscribePropsWithSourceIdentity<TSourceValue>): ReturnType<FunctionComponent>;
97
+ declare function Subscribe<TSourceValue, TSelected>(props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>): ReturnType<FunctionComponent>;
98
+ declare function Subscribe<TFeatures extends TableFeatures, TSelected>(props: SubscribePropsWithStore<TFeatures, TSelected>): ReturnType<FunctionComponent>;
99
+ //#endregion
100
+ export { Subscribe, SubscribeProps, SubscribePropsWithSource, SubscribePropsWithSourceIdentity, SubscribePropsWithSourceWithSelector, SubscribePropsWithStore, SubscribeSource };
101
+ //# sourceMappingURL=Subscribe.d.ts.map
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+
3
+ import { shallow, useSelector } from "@tanstack/react-store";
4
+
5
+ //#region src/Subscribe.ts
6
+ function Subscribe(props) {
7
+ const selected = useSelector(props.source, props.selector, { compare: shallow });
8
+ return typeof props.children === "function" ? props.children(selected) : props.children;
9
+ }
10
+
11
+ //#endregion
12
+ export { Subscribe };
13
+ //# sourceMappingURL=Subscribe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/react-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store). The selector\n * receives the source value; children receive the projected `TSelected`.\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected). Prefer\n * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}\n * for clearer inference when `selector` is omitted.\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\n/**\n * A React component that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX\n * contextual typing works. This standalone component uses a union `props` type.\n *\n * @example\n * ```tsx\n * // As a standalone component — full store\n * <Subscribe source={table.store} selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Entire source (atom or store) — no selector\n * <Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Project source value (e.g. one row’s selection)\n * <Subscribe\n * source={table.atoms.rowSelection}\n * selector={(rowSelection) => rowSelection?.[row.id]}\n * >\n * {(selected) => <tr data-selected={!!selected}>...</tr>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // As table.Subscribe (table instance method)\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </table.Subscribe>\n * ```\n */\nexport function Subscribe<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ReturnType<FunctionComponent> {\n const selected = useSelector(\n // Atom and store share the same selection protocol; union args need a widen for TS.\n props.source,\n props.selector as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ReactNode)(selected)\n : props.children\n}\n"],"mappings":";;;;;AAqIA,SAAgB,UAKd,OAC+B;CAC/B,MAAM,WAAW,YAEf,MAAM,QACN,MAAM,UACN,EACE,SAAS,QACX,CACF;CAEA,OAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAA6C,QAAQ,IAC5D,MAAM;AACZ"}