@tanstack/preact-table 9.0.0-alpha.22 → 9.0.0-alpha.26
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.
- package/README.md +117 -0
- package/dist/FlexRender.cjs +50 -0
- package/dist/FlexRender.cjs.map +1 -0
- package/dist/FlexRender.d.cts +51 -0
- package/dist/{esm/FlexRender.d.ts → FlexRender.d.ts} +20 -15
- package/dist/FlexRender.js +49 -0
- package/dist/FlexRender.js.map +1 -0
- package/dist/Subscribe.cjs +36 -0
- package/dist/Subscribe.cjs.map +1 -0
- package/dist/Subscribe.d.cts +49 -0
- package/dist/Subscribe.d.ts +49 -0
- package/dist/Subscribe.js +36 -0
- package/dist/Subscribe.js.map +1 -0
- package/dist/createTableHook.cjs +334 -0
- package/dist/createTableHook.cjs.map +1 -0
- package/dist/createTableHook.d.cts +358 -0
- package/dist/createTableHook.d.ts +358 -0
- package/dist/createTableHook.js +334 -0
- package/dist/createTableHook.js.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/{esm/index.js → index.js} +5 -10
- package/dist/useTable.cjs +38 -0
- package/dist/useTable.cjs.map +1 -0
- package/dist/useTable.d.cts +60 -0
- package/dist/useTable.d.ts +60 -0
- package/dist/useTable.js +38 -0
- package/dist/useTable.js.map +1 -0
- package/package.json +11 -13
- package/dist/esm/FlexRender.js +0 -41
- package/dist/esm/FlexRender.js.map +0 -1
- package/dist/esm/Subscribe.d.ts +0 -44
- package/dist/esm/Subscribe.js +0 -9
- package/dist/esm/Subscribe.js.map +0 -1
- package/dist/esm/createTableHook.d.ts +0 -349
- package/dist/esm/createTableHook.js +0 -133
- package/dist/esm/createTableHook.js.map +0 -1
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/useTable.d.ts +0 -55
- package/dist/esm/useTable.js +0 -38
- package/dist/esm/useTable.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
## Get Involved
|
|
53
|
+
|
|
54
|
+
- We welcome issues and pull requests!
|
|
55
|
+
- Participate in [GitHub discussions](https://github.com/TanStack/table/discussions)
|
|
56
|
+
- Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ)
|
|
57
|
+
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions
|
|
58
|
+
|
|
59
|
+
## Partners
|
|
60
|
+
|
|
61
|
+
<table align="center">
|
|
62
|
+
<tr>
|
|
63
|
+
<td>
|
|
64
|
+
<a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS">
|
|
65
|
+
<picture>
|
|
66
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-CMcuvjEy.svg" height="40" />
|
|
67
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" />
|
|
68
|
+
<img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" />
|
|
69
|
+
</picture>
|
|
70
|
+
</a>
|
|
71
|
+
</td>
|
|
72
|
+
<td padding="20">
|
|
73
|
+
<a href="https://www.cloudflare.com?utm_source=tanstack">
|
|
74
|
+
<picture>
|
|
75
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-DQDB7UaL.svg" height="60" />
|
|
76
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" />
|
|
77
|
+
<img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" />
|
|
78
|
+
</picture>
|
|
79
|
+
</a>
|
|
80
|
+
</td>
|
|
81
|
+
<td>
|
|
82
|
+
<a href="https://ag-grid.com/react-data-grid/?utm_source=reacttable&utm_campaign=githubreacttable" style="display: flex; align-items: center; border: none;">
|
|
83
|
+
<picture>
|
|
84
|
+
<source media="(prefers-color-scheme: dark)" srcset="./media/ag-grid-dark.svg" height="40" />
|
|
85
|
+
<source media="(prefers-color-scheme: light)" srcset="./media/ag-grid-light.svg" height="40" />
|
|
86
|
+
<img src="https://raw.githubusercontent.com/tannerlinsley/files/master/partners/ag-grid.svg" height="60" alt="AG Grid" />
|
|
87
|
+
</picture>
|
|
88
|
+
</a>
|
|
89
|
+
</td>
|
|
90
|
+
</tr>
|
|
91
|
+
</table>
|
|
92
|
+
|
|
93
|
+
<div align="center">
|
|
94
|
+
<img src="./media/partner_logo.svg" alt="Table & you?" height="65">
|
|
95
|
+
<p>
|
|
96
|
+
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.
|
|
97
|
+
</p>
|
|
98
|
+
<a href="mailto:partners@tanstack.com?subject=TanStack Table Partnership"><b>LET'S CHAT</b></a>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
## Explore the TanStack Ecosystem
|
|
102
|
+
|
|
103
|
+
- <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages
|
|
104
|
+
- <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store
|
|
105
|
+
- <a href="https://github.com/tanstack/devtools"><b>TanStack DevTools</b></a> – Unified devtools panel
|
|
106
|
+
- <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state
|
|
107
|
+
- <a href="https://github.com/tanstack/pacer"><b>TanStack Pacer</b></a> – Debouncing, throttling, batching <br/>
|
|
108
|
+
- <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching
|
|
109
|
+
- <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives
|
|
110
|
+
- <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state
|
|
111
|
+
- <a href="https://github.com/tanstack/router"><b>TanStack Start</b></a> – Full‑stack SSR & streaming
|
|
112
|
+
- <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store
|
|
113
|
+
- <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering
|
|
114
|
+
|
|
115
|
+
… and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a>
|
|
116
|
+
|
|
117
|
+
<!-- USE THE FORCE LUKE -->
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
let preact_jsx_runtime = require("preact/jsx-runtime");
|
|
2
|
+
|
|
3
|
+
//#region src/FlexRender.tsx
|
|
4
|
+
function isPreactComponent(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.isPreactComponent;
|
|
11
|
+
})();
|
|
12
|
+
}
|
|
13
|
+
function isExoticComponent(component) {
|
|
14
|
+
return typeof component === "object" && typeof component.$$typeof === "symbol" && ["preact.memo", "preact.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 : isPreactComponent(Comp) ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(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) return flexRender(props.cell.column.columnDef.cell, props.cell.getContext());
|
|
42
|
+
if ("header" in props && props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
|
|
43
|
+
if ("footer" in props && props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.FlexRender = FlexRender;
|
|
49
|
+
exports.flexRender = flexRender;
|
|
50
|
+
//# sourceMappingURL=FlexRender.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlexRender.cjs","names":[],"sources":["../src/FlexRender.tsx"],"sourcesContent":["import type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentChild, ComponentType } from 'preact'\n\nexport type Renderable<TProps> = ComponentChild | ComponentType<TProps>\n\nfunction isPreactComponent<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.isPreactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['preact.memo', 'preact.forward_ref'].includes(\n component.$$typeof.description,\n )\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> | null,\n props: TProps,\n): ComponentChild | Element | null {\n return !Comp ? null : isPreactComponent<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 return flexRender(props.cell.column.columnDef.cell, props.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":";;;AAWA,SAAS,kBACP,WACoC;AACpC,QACE,iBAAiB,UAAU,IAC3B,OAAO,cAAc,cACrB,kBAAkB,UAAU;;AAIhC,SAAS,iBAAiB,WAAgB;AACxC,QACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,UAAU;AAC9C,SAAO,MAAM,aAAa,MAAM,UAAU;KACxC;;AAIR,SAAS,kBAAkB,WAAgB;AACzC,QACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,eAAe,qBAAqB,CAAC,SACpC,UAAU,SAAS,YACpB;;;;;;AAQL,SAAgB,WACd,MACA,OACiC;AACjC,QAAO,CAAC,OAAO,OAAO,kBAA0B,KAAK,GACnD,4CAAC,MAAD,EAAM,GAAI,OAAS,IAEnB;;;;;;;;;;;;;;;;;;;AA6CJ,SAAgB,WAId,OAAkD;AAClD,KAAI,UAAU,SAAS,MAAM,KAC3B,QAAO,WAAW,MAAM,KAAK,OAAO,UAAU,MAAM,MAAM,KAAK,YAAY,CAAC;AAE9E,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,QAAO"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Cell, CellData, Header, RowData, TableFeatures } from "@tanstack/table-core";
|
|
2
|
+
import { ComponentChild, ComponentType } from "preact";
|
|
3
|
+
|
|
4
|
+
//#region src/FlexRender.d.ts
|
|
5
|
+
type Renderable<TProps> = ComponentChild | 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> | null, props: TProps): ComponentChild | Element | null;
|
|
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>): ComponentChild;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { FlexRender, FlexRenderProps, Renderable, flexRender };
|
|
51
|
+
//# sourceMappingURL=FlexRender.d.cts.map
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Cell, CellData, Header, RowData, TableFeatures } from
|
|
2
|
-
import { ComponentChild, ComponentType } from
|
|
3
|
-
|
|
1
|
+
import { Cell, CellData, Header, RowData, TableFeatures } from "@tanstack/table-core";
|
|
2
|
+
import { ComponentChild, ComponentType } from "preact";
|
|
3
|
+
|
|
4
|
+
//#region src/FlexRender.d.ts
|
|
5
|
+
type Renderable<TProps> = ComponentChild | ComponentType<TProps>;
|
|
4
6
|
/**
|
|
5
7
|
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
6
8
|
* @example flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
7
9
|
*/
|
|
8
|
-
|
|
10
|
+
declare function flexRender<TProps extends object>(Comp: Renderable<TProps> | null, props: TProps): ComponentChild | Element | null;
|
|
9
11
|
/**
|
|
10
12
|
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
11
13
|
* Only one prop (`cell`, `header`, or `footer`) may be passed.
|
|
@@ -13,18 +15,18 @@ export declare function flexRender<TProps extends object>(Comp: Renderable<TProp
|
|
|
13
15
|
* @example <FlexRender header={header} />
|
|
14
16
|
* @example <FlexRender footer={footer} />
|
|
15
17
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
20
22
|
} | {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
header: Header<TFeatures, TData, TValue>;
|
|
24
|
+
cell?: never;
|
|
25
|
+
footer?: never;
|
|
24
26
|
} | {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
footer: Header<TFeatures, TData, TValue>;
|
|
28
|
+
cell?: never;
|
|
29
|
+
header?: never;
|
|
28
30
|
};
|
|
29
31
|
/**
|
|
30
32
|
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
@@ -43,4 +45,7 @@ export type FlexRenderProps<TFeatures extends TableFeatures, TData extends RowDa
|
|
|
43
45
|
* flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
44
46
|
* ```
|
|
45
47
|
*/
|
|
46
|
-
|
|
48
|
+
declare function FlexRender<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>): ComponentChild;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { FlexRender, FlexRenderProps, Renderable, flexRender };
|
|
51
|
+
//# sourceMappingURL=FlexRender.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/FlexRender.tsx
|
|
4
|
+
function isPreactComponent(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.isPreactComponent;
|
|
11
|
+
})();
|
|
12
|
+
}
|
|
13
|
+
function isExoticComponent(component) {
|
|
14
|
+
return typeof component === "object" && typeof component.$$typeof === "symbol" && ["preact.memo", "preact.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 : isPreactComponent(Comp) ? /* @__PURE__ */ jsx(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) return flexRender(props.cell.column.columnDef.cell, props.cell.getContext());
|
|
42
|
+
if ("header" in props && props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
|
|
43
|
+
if ("footer" in props && props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { FlexRender, flexRender };
|
|
49
|
+
//# sourceMappingURL=FlexRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlexRender.js","names":[],"sources":["../src/FlexRender.tsx"],"sourcesContent":["import type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentChild, ComponentType } from 'preact'\n\nexport type Renderable<TProps> = ComponentChild | ComponentType<TProps>\n\nfunction isPreactComponent<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.isPreactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['preact.memo', 'preact.forward_ref'].includes(\n component.$$typeof.description,\n )\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> | null,\n props: TProps,\n): ComponentChild | Element | null {\n return !Comp ? null : isPreactComponent<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 return flexRender(props.cell.column.columnDef.cell, props.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":";;;AAWA,SAAS,kBACP,WACoC;AACpC,QACE,iBAAiB,UAAU,IAC3B,OAAO,cAAc,cACrB,kBAAkB,UAAU;;AAIhC,SAAS,iBAAiB,WAAgB;AACxC,QACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,UAAU;AAC9C,SAAO,MAAM,aAAa,MAAM,UAAU;KACxC;;AAIR,SAAS,kBAAkB,WAAgB;AACzC,QACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,eAAe,qBAAqB,CAAC,SACpC,UAAU,SAAS,YACpB;;;;;;AAQL,SAAgB,WACd,MACA,OACiC;AACjC,QAAO,CAAC,OAAO,OAAO,kBAA0B,KAAK,GACnD,oBAAC,MAAD,EAAM,GAAI,OAAS,IAEnB;;;;;;;;;;;;;;;;;;;AA6CJ,SAAgB,WAId,OAAkD;AAClD,KAAI,UAAU,SAAS,MAAM,KAC3B,QAAO,WAAW,MAAM,KAAK,OAAO,UAAU,MAAM,MAAM,KAAK,YAAY,CAAC;AAE9E,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,QAAO"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
let _tanstack_preact_store = require("@tanstack/preact-store");
|
|
2
|
+
|
|
3
|
+
//#region src/Subscribe.ts
|
|
4
|
+
/**
|
|
5
|
+
* A Preact component that allows you to subscribe to the table state.
|
|
6
|
+
*
|
|
7
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // As a standalone component
|
|
12
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
13
|
+
* {({ rowSelection }) => (
|
|
14
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
15
|
+
* )}
|
|
16
|
+
* </Subscribe>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // As table.Subscribe (table instance method)
|
|
22
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
23
|
+
* {({ rowSelection }) => (
|
|
24
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
25
|
+
* )}
|
|
26
|
+
* </table.Subscribe>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function Subscribe(props) {
|
|
30
|
+
const selected = (0, _tanstack_preact_store.useStore)(props.table.store, props.selector);
|
|
31
|
+
return typeof props.children === "function" ? props.children(selected) : props.children;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.Subscribe = Subscribe;
|
|
36
|
+
//# sourceMappingURL=Subscribe.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Subscribe.cjs","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { useStore } from '@tanstack/preact-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = {\n /**\n * The table instance to subscribe to. Required when using as a standalone component.\n * Not needed when using as `table.Subscribe`.\n */\n table: Table<TFeatures, TData>\n /**\n * A selector function that selects the part of the table state to subscribe to.\n * This allows for fine-grained reactivity by only re-rendering when the selected state changes.\n */\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n /**\n * The children to render. Can be a function that receives the selected state, or a Preact node.\n */\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * A Preact 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 * @example\n * ```tsx\n * // As a standalone component\n * <Subscribe table={table} 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 * // 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<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(props: SubscribeProps<TFeatures, TData, TSelected>): ComponentChildren {\n const selected = useStore(props.table.store, props.selector)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,UAId,OAAuE;CACvE,MAAM,gDAAoB,MAAM,MAAM,OAAO,MAAM,SAAS;AAE5D,QAAO,OAAO,MAAM,aAAa,aAC7B,MAAM,SAAS,SAAS,GACxB,MAAM"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NoInfer, RowData, Table, TableFeatures, TableState } from "@tanstack/table-core";
|
|
2
|
+
import { ComponentChildren } from "preact";
|
|
3
|
+
|
|
4
|
+
//#region src/Subscribe.d.ts
|
|
5
|
+
type SubscribeProps<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}> = {
|
|
6
|
+
/**
|
|
7
|
+
* The table instance to subscribe to. Required when using as a standalone component.
|
|
8
|
+
* Not needed when using as `table.Subscribe`.
|
|
9
|
+
*/
|
|
10
|
+
table: Table<TFeatures, TData>;
|
|
11
|
+
/**
|
|
12
|
+
* A selector function that selects the part of the table state to subscribe to.
|
|
13
|
+
* This allows for fine-grained reactivity by only re-rendering when the selected state changes.
|
|
14
|
+
*/
|
|
15
|
+
selector: (state: NoInfer<TableState<TFeatures>>) => TSelected;
|
|
16
|
+
/**
|
|
17
|
+
* The children to render. Can be a function that receives the selected state, or a Preact node.
|
|
18
|
+
*/
|
|
19
|
+
children: ((state: TSelected) => ComponentChildren) | ComponentChildren;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A Preact component that allows you to subscribe to the table state.
|
|
23
|
+
*
|
|
24
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // As a standalone component
|
|
29
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
30
|
+
* {({ rowSelection }) => (
|
|
31
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
32
|
+
* )}
|
|
33
|
+
* </Subscribe>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // As table.Subscribe (table instance method)
|
|
39
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
40
|
+
* {({ rowSelection }) => (
|
|
41
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
42
|
+
* )}
|
|
43
|
+
* </table.Subscribe>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}>(props: SubscribeProps<TFeatures, TData, TSelected>): ComponentChildren;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Subscribe, SubscribeProps };
|
|
49
|
+
//# sourceMappingURL=Subscribe.d.cts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NoInfer, RowData, Table, TableFeatures, TableState } from "@tanstack/table-core";
|
|
2
|
+
import { ComponentChildren } from "preact";
|
|
3
|
+
|
|
4
|
+
//#region src/Subscribe.d.ts
|
|
5
|
+
type SubscribeProps<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}> = {
|
|
6
|
+
/**
|
|
7
|
+
* The table instance to subscribe to. Required when using as a standalone component.
|
|
8
|
+
* Not needed when using as `table.Subscribe`.
|
|
9
|
+
*/
|
|
10
|
+
table: Table<TFeatures, TData>;
|
|
11
|
+
/**
|
|
12
|
+
* A selector function that selects the part of the table state to subscribe to.
|
|
13
|
+
* This allows for fine-grained reactivity by only re-rendering when the selected state changes.
|
|
14
|
+
*/
|
|
15
|
+
selector: (state: NoInfer<TableState<TFeatures>>) => TSelected;
|
|
16
|
+
/**
|
|
17
|
+
* The children to render. Can be a function that receives the selected state, or a Preact node.
|
|
18
|
+
*/
|
|
19
|
+
children: ((state: TSelected) => ComponentChildren) | ComponentChildren;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A Preact component that allows you to subscribe to the table state.
|
|
23
|
+
*
|
|
24
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // As a standalone component
|
|
29
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
30
|
+
* {({ rowSelection }) => (
|
|
31
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
32
|
+
* )}
|
|
33
|
+
* </Subscribe>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // As table.Subscribe (table instance method)
|
|
39
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
40
|
+
* {({ rowSelection }) => (
|
|
41
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
42
|
+
* )}
|
|
43
|
+
* </table.Subscribe>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}>(props: SubscribeProps<TFeatures, TData, TSelected>): ComponentChildren;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Subscribe, SubscribeProps };
|
|
49
|
+
//# sourceMappingURL=Subscribe.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useStore } from "@tanstack/preact-store";
|
|
2
|
+
|
|
3
|
+
//#region src/Subscribe.ts
|
|
4
|
+
/**
|
|
5
|
+
* A Preact component that allows you to subscribe to the table state.
|
|
6
|
+
*
|
|
7
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // As a standalone component
|
|
12
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
13
|
+
* {({ rowSelection }) => (
|
|
14
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
15
|
+
* )}
|
|
16
|
+
* </Subscribe>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // As table.Subscribe (table instance method)
|
|
22
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
23
|
+
* {({ rowSelection }) => (
|
|
24
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
25
|
+
* )}
|
|
26
|
+
* </table.Subscribe>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function Subscribe(props) {
|
|
30
|
+
const selected = useStore(props.table.store, props.selector);
|
|
31
|
+
return typeof props.children === "function" ? props.children(selected) : props.children;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { Subscribe };
|
|
36
|
+
//# sourceMappingURL=Subscribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { useStore } from '@tanstack/preact-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = {\n /**\n * The table instance to subscribe to. Required when using as a standalone component.\n * Not needed when using as `table.Subscribe`.\n */\n table: Table<TFeatures, TData>\n /**\n * A selector function that selects the part of the table state to subscribe to.\n * This allows for fine-grained reactivity by only re-rendering when the selected state changes.\n */\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n /**\n * The children to render. Can be a function that receives the selected state, or a Preact node.\n */\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * A Preact 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 * @example\n * ```tsx\n * // As a standalone component\n * <Subscribe table={table} 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 * // 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<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(props: SubscribeProps<TFeatures, TData, TSelected>): ComponentChildren {\n const selected = useStore(props.table.store, props.selector)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,UAId,OAAuE;CACvE,MAAM,WAAW,SAAS,MAAM,MAAM,OAAO,MAAM,SAAS;AAE5D,QAAO,OAAO,MAAM,aAAa,aAC7B,MAAM,SAAS,SAAS,GACxB,MAAM"}
|