@tanstack/vue-table 9.0.0-alpha.4 → 9.0.0-alpha.41

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 (55) hide show
  1. package/README.md +117 -0
  2. package/dist/FlexRender.cjs +80 -0
  3. package/dist/FlexRender.cjs.map +1 -0
  4. package/dist/FlexRender.d.cts +46 -0
  5. package/dist/FlexRender.d.ts +46 -0
  6. package/dist/FlexRender.js +79 -0
  7. package/dist/FlexRender.js.map +1 -0
  8. package/dist/createTableHook.cjs +216 -0
  9. package/dist/createTableHook.cjs.map +1 -0
  10. package/dist/createTableHook.d.cts +121 -0
  11. package/dist/createTableHook.d.ts +121 -0
  12. package/dist/createTableHook.js +215 -0
  13. package/dist/createTableHook.js.map +1 -0
  14. package/dist/flex-render.cjs +5 -0
  15. package/dist/flex-render.d.cts +2 -0
  16. package/dist/flex-render.d.ts +2 -0
  17. package/dist/flex-render.js +3 -0
  18. package/dist/index.cjs +17 -0
  19. package/dist/index.d.cts +5 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.js +7 -0
  22. package/dist/merge-proxy.cjs +64 -0
  23. package/dist/merge-proxy.cjs.map +1 -0
  24. package/dist/merge-proxy.js +63 -0
  25. package/dist/merge-proxy.js.map +1 -0
  26. package/dist/static-functions.cjs +9 -0
  27. package/dist/static-functions.d.cts +1 -0
  28. package/dist/static-functions.d.ts +1 -0
  29. package/dist/static-functions.js +3 -0
  30. package/dist/useTable.cjs +73 -0
  31. package/dist/useTable.cjs.map +1 -0
  32. package/dist/useTable.d.cts +42 -0
  33. package/dist/useTable.d.ts +42 -0
  34. package/dist/useTable.js +73 -0
  35. package/dist/useTable.js.map +1 -0
  36. package/package.json +27 -17
  37. package/src/FlexRender.ts +123 -0
  38. package/src/createTableHook.ts +576 -0
  39. package/src/flex-render.ts +1 -0
  40. package/src/index.ts +3 -76
  41. package/src/merge-proxy.ts +31 -14
  42. package/src/static-functions.ts +1 -0
  43. package/src/useTable.ts +240 -0
  44. package/dist/cjs/index.cjs +0 -69
  45. package/dist/cjs/index.cjs.map +0 -1
  46. package/dist/cjs/index.d.cts +0 -14
  47. package/dist/cjs/merge-proxy.cjs +0 -64
  48. package/dist/cjs/merge-proxy.cjs.map +0 -1
  49. package/dist/cjs/merge-proxy.d.cts +0 -11
  50. package/dist/esm/index.d.ts +0 -14
  51. package/dist/esm/index.js +0 -63
  52. package/dist/esm/index.js.map +0 -1
  53. package/dist/esm/merge-proxy.d.ts +0 -11
  54. package/dist/esm/merge-proxy.js +0 -64
  55. package/dist/esm/merge-proxy.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,80 @@
1
+ let vue = require("vue");
2
+
3
+ //#region src/FlexRender.ts
4
+ /**
5
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
6
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
7
+ */
8
+ function flexRender(render, props) {
9
+ if (typeof render === "function") {
10
+ const rendered = render(props);
11
+ if ((0, vue.isVNode)(rendered)) return rendered;
12
+ if (typeof rendered === "function" || typeof rendered === "object") return (0, vue.h)(rendered, props);
13
+ return rendered;
14
+ }
15
+ if (typeof render === "object") return (0, vue.h)(render, props);
16
+ return render;
17
+ }
18
+ /**
19
+ * Simplified component for rendering headers, cells, or footers.
20
+ *
21
+ * Supports both the new shorthand pattern and the legacy `:render`/`:props` pattern:
22
+ * @example
23
+ * ```vue
24
+ * <!-- New shorthand pattern -->
25
+ * <FlexRender :cell="cell" />
26
+ * <FlexRender :header="header" />
27
+ * <FlexRender :footer="header" />
28
+ *
29
+ * <!-- Legacy pattern (still supported) -->
30
+ * <FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
31
+ * ```
32
+ */
33
+ const FlexRender = (0, vue.defineComponent)({
34
+ props: {
35
+ render: {
36
+ type: [
37
+ Function,
38
+ Object,
39
+ String
40
+ ],
41
+ default: void 0
42
+ },
43
+ props: {
44
+ type: Object,
45
+ default: void 0
46
+ },
47
+ cell: {
48
+ type: Object,
49
+ default: void 0
50
+ },
51
+ header: {
52
+ type: Object,
53
+ default: void 0
54
+ },
55
+ footer: {
56
+ type: Object,
57
+ default: void 0
58
+ }
59
+ },
60
+ setup: (props) => {
61
+ return () => {
62
+ if (props.cell) {
63
+ var _cell$getIsAggregated, _cell$getIsPlaceholde;
64
+ const cell = props.cell;
65
+ const def = cell.column.columnDef;
66
+ if ((_cell$getIsAggregated = cell.getIsAggregated) === null || _cell$getIsAggregated === void 0 ? void 0 : _cell$getIsAggregated.call(cell)) return flexRender(def.aggregatedCell ?? def.cell, cell.getContext());
67
+ if ((_cell$getIsPlaceholde = cell.getIsPlaceholder) === null || _cell$getIsPlaceholde === void 0 ? void 0 : _cell$getIsPlaceholde.call(cell)) return null;
68
+ return flexRender(def.cell, cell.getContext());
69
+ }
70
+ if (props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
71
+ if (props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
72
+ return flexRender(props.render, props.props);
73
+ };
74
+ }
75
+ });
76
+
77
+ //#endregion
78
+ exports.FlexRender = FlexRender;
79
+ exports.flexRender = flexRender;
80
+ //# sourceMappingURL=FlexRender.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlexRender.cjs","names":[],"sources":["../src/FlexRender.ts"],"sourcesContent":["import { defineComponent, h, isVNode } from 'vue'\nimport type { PropType } from 'vue'\nimport type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\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(render: any, props: any): any {\n if (typeof render === 'function') {\n const rendered = render(props)\n\n if (isVNode(rendered)) {\n return rendered\n }\n\n if (typeof rendered === 'function' || typeof rendered === 'object') {\n return h(rendered, props)\n }\n\n return rendered\n }\n\n if (typeof render === 'object') {\n return h(render, props)\n }\n\n return render\n}\n\n/**\n * Simplified component for rendering headers, cells, or footers.\n *\n * Supports both the new shorthand pattern and the legacy `:render`/`:props` pattern:\n * @example\n * ```vue\n * <!-- New shorthand pattern -->\n * <FlexRender :cell=\"cell\" />\n * <FlexRender :header=\"header\" />\n * <FlexRender :footer=\"header\" />\n *\n * <!-- Legacy pattern (still supported) -->\n * <FlexRender :render=\"cell.column.columnDef.cell\" :props=\"cell.getContext()\" />\n * ```\n */\nexport const FlexRender = defineComponent({\n props: {\n render: {\n type: [Function, Object, String] as PropType<any>,\n default: undefined,\n },\n props: {\n type: Object as PropType<any>,\n default: undefined,\n },\n cell: {\n type: Object as PropType<Cell<any, any, any>>,\n default: undefined,\n },\n header: {\n type: Object as PropType<Header<any, any, any>>,\n default: undefined,\n },\n footer: {\n type: Object as PropType<Header<any, any, any>>,\n default: undefined,\n },\n },\n setup: (props: {\n render?: any\n props?: any\n cell?: Cell<any, any, any>\n header?: Header<any, any, any>\n footer?: Header<any, any, any>\n }) => {\n return () => {\n // New shorthand pattern: extract render and props from cell/header/footer\n if (props.cell) {\n const cell = props.cell\n const def = cell.column.columnDef\n // When the column-grouping feature is registered, a cell can be in\n // one of three special modes that should not render `columnDef.cell`\n // directly:\n // - aggregated: render `columnDef.aggregatedCell` (falling back to\n // `columnDef.cell` if the column did not define one)\n // - placeholder: a duplicate value within a group — render nothing\n // - grouped: fall through to `columnDef.cell`; consumers that want\n // a custom group header typically branch on `cell.getIsGrouped()`\n // themselves first\n if (cell.getIsAggregated?.()) {\n return flexRender(def.aggregatedCell ?? def.cell, cell.getContext())\n }\n if (cell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, cell.getContext())\n }\n\n if (props.header) {\n return flexRender(\n props.header.column.columnDef.header,\n props.header.getContext(),\n )\n }\n\n if (props.footer) {\n return flexRender(\n props.footer.column.columnDef.footer,\n props.footer.getContext(),\n )\n }\n\n // Legacy pattern: use render and props directly\n return flexRender(props.render, props.props)\n }\n },\n})\n"],"mappings":";;;;;;;AAcA,SAAgB,WAAW,QAAa,OAAiB;AACvD,KAAI,OAAO,WAAW,YAAY;EAChC,MAAM,WAAW,OAAO,MAAM;AAE9B,uBAAY,SAAS,CACnB,QAAO;AAGT,MAAI,OAAO,aAAa,cAAc,OAAO,aAAa,SACxD,mBAAS,UAAU,MAAM;AAG3B,SAAO;;AAGT,KAAI,OAAO,WAAW,SACpB,mBAAS,QAAQ,MAAM;AAGzB,QAAO;;;;;;;;;;;;;;;;;AAkBT,MAAa,sCAA6B;CACxC,OAAO;EACL,QAAQ;GACN,MAAM;IAAC;IAAU;IAAQ;IAAO;GAChC,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACF;CACD,QAAQ,UAMF;AACJ,eAAa;AAEX,OAAI,MAAM,MAAM;;IACd,MAAM,OAAO,MAAM;IACnB,MAAM,MAAM,KAAK,OAAO;AAUxB,iCAAI,KAAK,yGAAmB,CAC1B,QAAO,WAAW,IAAI,kBAAkB,IAAI,MAAM,KAAK,YAAY,CAAC;AAEtE,iCAAI,KAAK,0GAAoB,CAC3B,QAAO;AAET,WAAO,WAAW,IAAI,MAAM,KAAK,YAAY,CAAC;;AAGhD,OAAI,MAAM,OACR,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAGH,OAAI,MAAM,OACR,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAIH,UAAO,WAAW,MAAM,QAAQ,MAAM,MAAM;;;CAGjD,CAAC"}
@@ -0,0 +1,46 @@
1
+ import * as _$vue from "vue";
2
+ import { Cell, Header } from "@tanstack/table-core";
3
+
4
+ //#region src/FlexRender.d.ts
5
+ /**
6
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
7
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
8
+ */
9
+ declare function flexRender(render: any, props: any): any;
10
+ /**
11
+ * Simplified component for rendering headers, cells, or footers.
12
+ *
13
+ * Supports both the new shorthand pattern and the legacy `:render`/`:props` pattern:
14
+ * @example
15
+ * ```vue
16
+ * <!-- New shorthand pattern -->
17
+ * <FlexRender :cell="cell" />
18
+ * <FlexRender :header="header" />
19
+ * <FlexRender :footer="header" />
20
+ *
21
+ * <!-- Legacy pattern (still supported) -->
22
+ * <FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
23
+ * ```
24
+ */
25
+ declare const FlexRender: _$vue.DefineComponent<{
26
+ render?: any;
27
+ props?: any;
28
+ cell?: Cell<any, any, any>;
29
+ header?: Header<any, any, any>;
30
+ footer?: Header<any, any, any>;
31
+ }, () => any, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{
32
+ render?: any;
33
+ props?: any;
34
+ cell?: Cell<any, any, any>;
35
+ header?: Header<any, any, any>;
36
+ footer?: Header<any, any, any>;
37
+ }> & Readonly<{}>, {
38
+ props: any;
39
+ render: any;
40
+ cell: any;
41
+ header: any;
42
+ footer: any;
43
+ }, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
44
+ //#endregion
45
+ export { FlexRender, flexRender };
46
+ //# sourceMappingURL=FlexRender.d.cts.map
@@ -0,0 +1,46 @@
1
+ import * as _$vue from "vue";
2
+ import { Cell, Header } from "@tanstack/table-core";
3
+
4
+ //#region src/FlexRender.d.ts
5
+ /**
6
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
7
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
8
+ */
9
+ declare function flexRender(render: any, props: any): any;
10
+ /**
11
+ * Simplified component for rendering headers, cells, or footers.
12
+ *
13
+ * Supports both the new shorthand pattern and the legacy `:render`/`:props` pattern:
14
+ * @example
15
+ * ```vue
16
+ * <!-- New shorthand pattern -->
17
+ * <FlexRender :cell="cell" />
18
+ * <FlexRender :header="header" />
19
+ * <FlexRender :footer="header" />
20
+ *
21
+ * <!-- Legacy pattern (still supported) -->
22
+ * <FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
23
+ * ```
24
+ */
25
+ declare const FlexRender: _$vue.DefineComponent<{
26
+ render?: any;
27
+ props?: any;
28
+ cell?: Cell<any, any, any>;
29
+ header?: Header<any, any, any>;
30
+ footer?: Header<any, any, any>;
31
+ }, () => any, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{
32
+ render?: any;
33
+ props?: any;
34
+ cell?: Cell<any, any, any>;
35
+ header?: Header<any, any, any>;
36
+ footer?: Header<any, any, any>;
37
+ }> & Readonly<{}>, {
38
+ props: any;
39
+ render: any;
40
+ cell: any;
41
+ header: any;
42
+ footer: any;
43
+ }, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
44
+ //#endregion
45
+ export { FlexRender, flexRender };
46
+ //# sourceMappingURL=FlexRender.d.ts.map
@@ -0,0 +1,79 @@
1
+ import { defineComponent, h, isVNode } from "vue";
2
+
3
+ //#region src/FlexRender.ts
4
+ /**
5
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
6
+ * @example flexRender(cell.column.columnDef.cell, cell.getContext())
7
+ */
8
+ function flexRender(render, props) {
9
+ if (typeof render === "function") {
10
+ const rendered = render(props);
11
+ if (isVNode(rendered)) return rendered;
12
+ if (typeof rendered === "function" || typeof rendered === "object") return h(rendered, props);
13
+ return rendered;
14
+ }
15
+ if (typeof render === "object") return h(render, props);
16
+ return render;
17
+ }
18
+ /**
19
+ * Simplified component for rendering headers, cells, or footers.
20
+ *
21
+ * Supports both the new shorthand pattern and the legacy `:render`/`:props` pattern:
22
+ * @example
23
+ * ```vue
24
+ * <!-- New shorthand pattern -->
25
+ * <FlexRender :cell="cell" />
26
+ * <FlexRender :header="header" />
27
+ * <FlexRender :footer="header" />
28
+ *
29
+ * <!-- Legacy pattern (still supported) -->
30
+ * <FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
31
+ * ```
32
+ */
33
+ const FlexRender = defineComponent({
34
+ props: {
35
+ render: {
36
+ type: [
37
+ Function,
38
+ Object,
39
+ String
40
+ ],
41
+ default: void 0
42
+ },
43
+ props: {
44
+ type: Object,
45
+ default: void 0
46
+ },
47
+ cell: {
48
+ type: Object,
49
+ default: void 0
50
+ },
51
+ header: {
52
+ type: Object,
53
+ default: void 0
54
+ },
55
+ footer: {
56
+ type: Object,
57
+ default: void 0
58
+ }
59
+ },
60
+ setup: (props) => {
61
+ return () => {
62
+ if (props.cell) {
63
+ var _cell$getIsAggregated, _cell$getIsPlaceholde;
64
+ const cell = props.cell;
65
+ const def = cell.column.columnDef;
66
+ if ((_cell$getIsAggregated = cell.getIsAggregated) === null || _cell$getIsAggregated === void 0 ? void 0 : _cell$getIsAggregated.call(cell)) return flexRender(def.aggregatedCell ?? def.cell, cell.getContext());
67
+ if ((_cell$getIsPlaceholde = cell.getIsPlaceholder) === null || _cell$getIsPlaceholde === void 0 ? void 0 : _cell$getIsPlaceholde.call(cell)) return null;
68
+ return flexRender(def.cell, cell.getContext());
69
+ }
70
+ if (props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
71
+ if (props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
72
+ return flexRender(props.render, props.props);
73
+ };
74
+ }
75
+ });
76
+
77
+ //#endregion
78
+ export { FlexRender, flexRender };
79
+ //# sourceMappingURL=FlexRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlexRender.js","names":[],"sources":["../src/FlexRender.ts"],"sourcesContent":["import { defineComponent, h, isVNode } from 'vue'\nimport type { PropType } from 'vue'\nimport type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\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(render: any, props: any): any {\n if (typeof render === 'function') {\n const rendered = render(props)\n\n if (isVNode(rendered)) {\n return rendered\n }\n\n if (typeof rendered === 'function' || typeof rendered === 'object') {\n return h(rendered, props)\n }\n\n return rendered\n }\n\n if (typeof render === 'object') {\n return h(render, props)\n }\n\n return render\n}\n\n/**\n * Simplified component for rendering headers, cells, or footers.\n *\n * Supports both the new shorthand pattern and the legacy `:render`/`:props` pattern:\n * @example\n * ```vue\n * <!-- New shorthand pattern -->\n * <FlexRender :cell=\"cell\" />\n * <FlexRender :header=\"header\" />\n * <FlexRender :footer=\"header\" />\n *\n * <!-- Legacy pattern (still supported) -->\n * <FlexRender :render=\"cell.column.columnDef.cell\" :props=\"cell.getContext()\" />\n * ```\n */\nexport const FlexRender = defineComponent({\n props: {\n render: {\n type: [Function, Object, String] as PropType<any>,\n default: undefined,\n },\n props: {\n type: Object as PropType<any>,\n default: undefined,\n },\n cell: {\n type: Object as PropType<Cell<any, any, any>>,\n default: undefined,\n },\n header: {\n type: Object as PropType<Header<any, any, any>>,\n default: undefined,\n },\n footer: {\n type: Object as PropType<Header<any, any, any>>,\n default: undefined,\n },\n },\n setup: (props: {\n render?: any\n props?: any\n cell?: Cell<any, any, any>\n header?: Header<any, any, any>\n footer?: Header<any, any, any>\n }) => {\n return () => {\n // New shorthand pattern: extract render and props from cell/header/footer\n if (props.cell) {\n const cell = props.cell\n const def = cell.column.columnDef\n // When the column-grouping feature is registered, a cell can be in\n // one of three special modes that should not render `columnDef.cell`\n // directly:\n // - aggregated: render `columnDef.aggregatedCell` (falling back to\n // `columnDef.cell` if the column did not define one)\n // - placeholder: a duplicate value within a group — render nothing\n // - grouped: fall through to `columnDef.cell`; consumers that want\n // a custom group header typically branch on `cell.getIsGrouped()`\n // themselves first\n if (cell.getIsAggregated?.()) {\n return flexRender(def.aggregatedCell ?? def.cell, cell.getContext())\n }\n if (cell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, cell.getContext())\n }\n\n if (props.header) {\n return flexRender(\n props.header.column.columnDef.header,\n props.header.getContext(),\n )\n }\n\n if (props.footer) {\n return flexRender(\n props.footer.column.columnDef.footer,\n props.footer.getContext(),\n )\n }\n\n // Legacy pattern: use render and props directly\n return flexRender(props.render, props.props)\n }\n },\n})\n"],"mappings":";;;;;;;AAcA,SAAgB,WAAW,QAAa,OAAiB;AACvD,KAAI,OAAO,WAAW,YAAY;EAChC,MAAM,WAAW,OAAO,MAAM;AAE9B,MAAI,QAAQ,SAAS,CACnB,QAAO;AAGT,MAAI,OAAO,aAAa,cAAc,OAAO,aAAa,SACxD,QAAO,EAAE,UAAU,MAAM;AAG3B,SAAO;;AAGT,KAAI,OAAO,WAAW,SACpB,QAAO,EAAE,QAAQ,MAAM;AAGzB,QAAO;;;;;;;;;;;;;;;;;AAkBT,MAAa,aAAa,gBAAgB;CACxC,OAAO;EACL,QAAQ;GACN,MAAM;IAAC;IAAU;IAAQ;IAAO;GAChC,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACF;CACD,QAAQ,UAMF;AACJ,eAAa;AAEX,OAAI,MAAM,MAAM;;IACd,MAAM,OAAO,MAAM;IACnB,MAAM,MAAM,KAAK,OAAO;AAUxB,iCAAI,KAAK,yGAAmB,CAC1B,QAAO,WAAW,IAAI,kBAAkB,IAAI,MAAM,KAAK,YAAY,CAAC;AAEtE,iCAAI,KAAK,0GAAoB,CAC3B,QAAO;AAET,WAAO,WAAW,IAAI,MAAM,KAAK,YAAY,CAAC;;AAGhD,OAAI,MAAM,OACR,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAGH,OAAI,MAAM,OACR,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAIH,UAAO,WAAW,MAAM,QAAQ,MAAM,MAAM;;;CAGjD,CAAC"}
@@ -0,0 +1,216 @@
1
+ const require_FlexRender = require('./FlexRender.cjs');
2
+ const require_merge_proxy = require('./merge-proxy.cjs');
3
+ const require_useTable = require('./useTable.cjs');
4
+ let vue = require("vue");
5
+ let _tanstack_table_core = require("@tanstack/table-core");
6
+ let _tanstack_vue_store = require("@tanstack/vue-store");
7
+
8
+ //#region src/createTableHook.ts
9
+ const AppFlexRender = (0, vue.defineComponent)({
10
+ name: "TableFlexRender",
11
+ props: {
12
+ cell: {
13
+ type: Object,
14
+ default: void 0
15
+ },
16
+ header: {
17
+ type: Object,
18
+ default: void 0
19
+ },
20
+ footer: {
21
+ type: Object,
22
+ default: void 0
23
+ }
24
+ },
25
+ setup(props) {
26
+ return () => {
27
+ if (props.cell) return (0, vue.h)(require_FlexRender.FlexRender, {
28
+ render: props.cell.column.columnDef.cell,
29
+ props: props.cell.getContext()
30
+ });
31
+ if (props.header) return (0, vue.h)(require_FlexRender.FlexRender, {
32
+ render: props.header.column.columnDef.header,
33
+ props: props.header.getContext()
34
+ });
35
+ if (props.footer) return (0, vue.h)(require_FlexRender.FlexRender, {
36
+ render: props.footer.column.columnDef.footer,
37
+ props: props.footer.getContext()
38
+ });
39
+ return null;
40
+ };
41
+ }
42
+ });
43
+ function createTableHook({ tableComponents, cellComponents, headerComponents, ...defaultTableOptions }) {
44
+ const TableContext = Symbol("TableContext");
45
+ const CellContext = Symbol("CellContext");
46
+ const HeaderContext = Symbol("HeaderContext");
47
+ function createAppColumnHelper() {
48
+ return (0, _tanstack_table_core.createColumnHelper)();
49
+ }
50
+ function useTableContext() {
51
+ const table = (0, vue.inject)(TableContext);
52
+ if (!table) throw new Error("`useTableContext` must be used within an `AppTable` component. Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.");
53
+ return table;
54
+ }
55
+ function useCellContext() {
56
+ const cell = (0, vue.inject)(CellContext);
57
+ if (!cell) throw new Error("`useCellContext` must be used within an `AppCell` component. Make sure your component is wrapped with `<table.AppCell :cell=\"cell\">...</table.AppCell>`.");
58
+ return cell;
59
+ }
60
+ function useHeaderContext() {
61
+ const header = (0, vue.inject)(HeaderContext);
62
+ if (!header) throw new Error("`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.");
63
+ return header;
64
+ }
65
+ const CellFlexRender = (0, vue.defineComponent)({
66
+ name: "AppCellFlexRender",
67
+ setup() {
68
+ const cell = useCellContext();
69
+ return () => (0, vue.h)(AppFlexRender, { cell });
70
+ }
71
+ });
72
+ const HeaderFlexRender = (0, vue.defineComponent)({
73
+ name: "AppHeaderFlexRender",
74
+ setup() {
75
+ const header = useHeaderContext();
76
+ return () => (0, vue.h)(AppFlexRender, { header });
77
+ }
78
+ });
79
+ const FooterFlexRender = (0, vue.defineComponent)({
80
+ name: "AppFooterFlexRender",
81
+ setup() {
82
+ const header = useHeaderContext();
83
+ return () => (0, vue.h)(AppFlexRender, { footer: header });
84
+ }
85
+ });
86
+ function useAppTable(tableOptions, selector) {
87
+ const table = require_useTable.useTable(require_merge_proxy.mergeProxy(defaultTableOptions, tableOptions), selector);
88
+ const AppTable = (0, vue.defineComponent)({
89
+ name: "AppTable",
90
+ props: { selector: {
91
+ type: Function,
92
+ default: void 0
93
+ } },
94
+ setup(props, { slots }) {
95
+ (0, vue.provide)(TableContext, table);
96
+ const selected = props.selector ? (0, _tanstack_vue_store.useSelector)(table.store, props.selector) : void 0;
97
+ return () => {
98
+ var _slots$default2;
99
+ if (!props.selector) {
100
+ var _slots$default;
101
+ return (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
102
+ }
103
+ return (_slots$default2 = slots.default) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots, { state: selected === null || selected === void 0 ? void 0 : selected.value });
104
+ };
105
+ }
106
+ });
107
+ const AppCell = (0, vue.defineComponent)({
108
+ name: "AppCell",
109
+ props: {
110
+ cell: {
111
+ type: Object,
112
+ required: true
113
+ },
114
+ selector: {
115
+ type: Function,
116
+ default: void 0
117
+ }
118
+ },
119
+ setup(props, { slots }) {
120
+ const cell = props.cell;
121
+ (0, vue.provide)(CellContext, cell);
122
+ const selected = props.selector ? (0, _tanstack_vue_store.useSelector)(table.store, props.selector) : void 0;
123
+ const extendedCell = Object.assign(cell, {
124
+ FlexRender: CellFlexRender,
125
+ ...cellComponents ?? {}
126
+ });
127
+ return () => {
128
+ var _slots$default3;
129
+ return (_slots$default3 = slots.default) === null || _slots$default3 === void 0 ? void 0 : _slots$default3.call(slots, props.selector ? {
130
+ cell: extendedCell,
131
+ state: selected === null || selected === void 0 ? void 0 : selected.value
132
+ } : { cell: extendedCell });
133
+ };
134
+ }
135
+ });
136
+ const AppHeader = (0, vue.defineComponent)({
137
+ name: "AppHeader",
138
+ props: {
139
+ header: {
140
+ type: Object,
141
+ required: true
142
+ },
143
+ selector: {
144
+ type: Function,
145
+ default: void 0
146
+ }
147
+ },
148
+ setup(props, { slots }) {
149
+ const header = props.header;
150
+ (0, vue.provide)(HeaderContext, header);
151
+ const selected = props.selector ? (0, _tanstack_vue_store.useSelector)(table.store, props.selector) : void 0;
152
+ const extendedHeader = Object.assign(header, {
153
+ FlexRender: HeaderFlexRender,
154
+ ...headerComponents ?? {}
155
+ });
156
+ return () => {
157
+ var _slots$default4;
158
+ return (_slots$default4 = slots.default) === null || _slots$default4 === void 0 ? void 0 : _slots$default4.call(slots, props.selector ? {
159
+ header: extendedHeader,
160
+ state: selected === null || selected === void 0 ? void 0 : selected.value
161
+ } : { header: extendedHeader });
162
+ };
163
+ }
164
+ });
165
+ const AppFooter = (0, vue.defineComponent)({
166
+ name: "AppFooter",
167
+ props: {
168
+ header: {
169
+ type: Object,
170
+ required: true
171
+ },
172
+ selector: {
173
+ type: Function,
174
+ default: void 0
175
+ }
176
+ },
177
+ setup(props, { slots }) {
178
+ const header = props.header;
179
+ (0, vue.provide)(HeaderContext, header);
180
+ const selected = props.selector ? (0, _tanstack_vue_store.useSelector)(table.store, props.selector) : void 0;
181
+ const extendedHeader = Object.assign(header, {
182
+ FlexRender: FooterFlexRender,
183
+ ...headerComponents ?? {}
184
+ });
185
+ return () => {
186
+ var _slots$default5;
187
+ return (_slots$default5 = slots.default) === null || _slots$default5 === void 0 ? void 0 : _slots$default5.call(slots, props.selector ? {
188
+ header: extendedHeader,
189
+ state: selected === null || selected === void 0 ? void 0 : selected.value
190
+ } : { header: extendedHeader });
191
+ };
192
+ }
193
+ });
194
+ return Object.assign(table, {
195
+ AppTable,
196
+ AppCell,
197
+ AppHeader,
198
+ AppFooter,
199
+ FlexRender: AppFlexRender,
200
+ ...tableComponents ?? {}
201
+ });
202
+ }
203
+ return {
204
+ appFeatures: defaultTableOptions._features,
205
+ createAppColumnHelper,
206
+ useAppTable,
207
+ useTableContext,
208
+ useCellContext,
209
+ useHeaderContext
210
+ };
211
+ }
212
+
213
+ //#endregion
214
+ exports.AppFlexRender = AppFlexRender;
215
+ exports.createTableHook = createTableHook;
216
+ //# sourceMappingURL=createTableHook.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTableHook.cjs","names":["FlexRender","useTable","mergeProxy"],"sources":["../src/createTableHook.ts"],"sourcesContent":["import { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'\nimport { useSelector } from '@tanstack/vue-store'\nimport { defineComponent, h, inject, provide } from 'vue'\nimport { FlexRender } from './FlexRender'\nimport { mergeProxy } from './merge-proxy'\nimport { useTable } from './useTable'\nimport type { TableOptionsWithReactiveData, VueTable } from './useTable'\nimport type { Component, InjectionKey, PropType, VNodeChild } from 'vue'\nimport type {\n AccessorFn,\n AccessorFnColumnDef,\n AccessorKeyColumnDef,\n Cell,\n CellContext,\n CellData,\n Column,\n ColumnDef,\n DeepKeys,\n DeepValue,\n DisplayColumnDef,\n GroupColumnDef,\n Header,\n IdentifiedColumnDef,\n NoInfer,\n Row,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\n\nexport type ComponentType<T extends Record<string, any>> = Component<T>\n\nexport type AppCellContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> = {\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: Component }\n column: Column<TFeatures, TData, TValue>\n getValue: CellContext<TFeatures, TData, TValue>['getValue']\n renderValue: CellContext<TFeatures, TData, TValue>['renderValue']\n row: Row<TFeatures, TData>\n table: Table<TFeatures, TData>\n}\n\nexport type AppHeaderContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n column: Column<TFeatures, TData, TValue>\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: Component }\n table: Table<TFeatures, TData>\n}\n\nexport type AppColumnDefTemplate<TProps extends object> =\n | string\n | ((props: TProps) => any)\n\nexport type AppColumnDefBase<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n IdentifiedColumnDef<TFeatures, TData, TValue>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, TValue, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n}\n\nexport type AppDisplayColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n DisplayColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n}\n\nexport type AppGroupColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n GroupColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer' | 'columns'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n columns?: Array<ColumnDef<TFeatures, TData, unknown>>\n}\n\nexport type AppColumnHelper<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n accessor: <\n TAccessor extends AccessorFn<TData> | DeepKeys<TData>,\n TValue extends TAccessor extends AccessorFn<TData, infer TReturn>\n ? TReturn\n : TAccessor extends DeepKeys<TData>\n ? DeepValue<TData, TAccessor>\n : never,\n >(\n accessor: TAccessor,\n column: TAccessor extends AccessorFn<TData>\n ? AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n > & { id: string }\n : AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n >,\n ) => TAccessor extends AccessorFn<TData>\n ? AccessorFnColumnDef<TFeatures, TData, TValue>\n : AccessorKeyColumnDef<TFeatures, TData, TValue>\n columns: <TColumns extends ReadonlyArray<ColumnDef<TFeatures, TData, any>>>(\n columns: [...TColumns],\n ) => Array<ColumnDef<TFeatures, TData, any>> & [...TColumns]\n display: (\n column: AppDisplayColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => DisplayColumnDef<TFeatures, TData, unknown>\n group: (\n column: AppGroupColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => GroupColumnDef<TFeatures, TData, unknown>\n}\n\nexport type CreateTableHookOptions<\n TFeatures extends TableFeatures,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n TableOptionsWithReactiveData<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n> & {\n tableComponents?: TTableComponents\n cellComponents?: TCellComponents\n headerComponents?: THeaderComponents\n}\n\nexport interface AppTableProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n> {\n selector?: (state: TableState<TFeatures>) => TSelected\n}\n\nexport interface AppCellProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n TSelected = unknown,\n> {\n cell: Cell<TFeatures, TData, TValue>\n selector?: (state: TableState<TFeatures>) => TSelected\n}\n\nexport interface AppHeaderProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n TSelected = unknown,\n> {\n header: Header<TFeatures, TData, TValue>\n selector?: (state: TableState<TFeatures>) => TSelected\n}\n\nexport type AppVueTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = VueTable<TFeatures, TData, TSelected> &\n NoInfer<TTableComponents> & {\n AppTable: Component<AppTableProps<TFeatures>>\n AppCell: Component<AppCellProps<TFeatures, TData>>\n AppHeader: Component<AppHeaderProps<TFeatures, TData>>\n AppFooter: Component<AppHeaderProps<TFeatures, TData>>\n FlexRender: typeof AppFlexRender\n }\n\nexport const AppFlexRender = defineComponent({\n name: 'TableFlexRender',\n props: {\n cell: {\n type: Object as PropType<Cell<any, any, any>>,\n default: undefined,\n },\n header: {\n type: Object as PropType<Header<any, any, any>>,\n default: undefined,\n },\n footer: {\n type: Object as PropType<Header<any, any, any>>,\n default: undefined,\n },\n },\n setup(props) {\n return () => {\n if (props.cell) {\n return h(FlexRender, {\n render: props.cell.column.columnDef.cell,\n props: props.cell.getContext(),\n })\n }\n\n if (props.header) {\n return h(FlexRender, {\n render: props.header.column.columnDef.header,\n props: props.header.getContext(),\n })\n }\n\n if (props.footer) {\n return h(FlexRender, {\n render: props.footer.column.columnDef.footer,\n props: props.footer.getContext(),\n })\n }\n\n return null\n }\n },\n})\n\nexport function createTableHook<\n TFeatures extends TableFeatures,\n const TTableComponents extends Record<string, ComponentType<any>>,\n const TCellComponents extends Record<string, ComponentType<any>>,\n const THeaderComponents extends Record<string, ComponentType<any>>,\n>({\n tableComponents,\n cellComponents,\n headerComponents,\n ...defaultTableOptions\n}: CreateTableHookOptions<\n TFeatures,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n>) {\n const TableContext = Symbol('TableContext') as InjectionKey<\n VueTable<TFeatures, any, any>\n >\n const CellContext = Symbol('CellContext') as InjectionKey<\n Cell<TFeatures, any, any>\n >\n const HeaderContext = Symbol('HeaderContext') as InjectionKey<\n Header<TFeatures, any, any>\n >\n\n function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n > {\n return coreCreateColumnHelper<TFeatures, TData>() as AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >\n }\n\n function useTableContext<TData extends RowData = RowData>(): VueTable<\n TFeatures,\n TData\n > {\n const table = inject(TableContext)\n\n if (!table) {\n throw new Error(\n '`useTableContext` must be used within an `AppTable` component. ' +\n 'Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.',\n )\n }\n\n return table as VueTable<TFeatures, TData>\n }\n\n function useCellContext<TValue extends CellData = CellData>(): Cell<\n TFeatures,\n any,\n TValue\n > {\n const cell = inject(CellContext)\n\n if (!cell) {\n throw new Error(\n '`useCellContext` must be used within an `AppCell` component. ' +\n 'Make sure your component is wrapped with `<table.AppCell :cell=\"cell\">...</table.AppCell>`.',\n )\n }\n\n return cell as Cell<TFeatures, any, TValue>\n }\n\n function useHeaderContext<TValue extends CellData = CellData>(): Header<\n TFeatures,\n any,\n TValue\n > {\n const header = inject(HeaderContext)\n\n if (!header) {\n throw new Error(\n '`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.',\n )\n }\n\n return header as Header<TFeatures, any, TValue>\n }\n\n const CellFlexRender = defineComponent({\n name: 'AppCellFlexRender',\n setup() {\n const cell = useCellContext()\n return () => h(AppFlexRender, { cell })\n },\n })\n\n const HeaderFlexRender = defineComponent({\n name: 'AppHeaderFlexRender',\n setup() {\n const header = useHeaderContext()\n return () => h(AppFlexRender, { header })\n },\n })\n\n const FooterFlexRender = defineComponent({\n name: 'AppFooterFlexRender',\n setup() {\n const header = useHeaderContext()\n return () => h(AppFlexRender, { footer: header })\n },\n })\n\n function useAppTable<TData extends RowData, TSelected = {}>(\n tableOptions: Omit<\n TableOptionsWithReactiveData<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: (state: TableState<TFeatures>) => TSelected,\n ): AppVueTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n > {\n const mergedOptions = mergeProxy(\n defaultTableOptions,\n tableOptions,\n ) as TableOptionsWithReactiveData<TFeatures, TData>\n\n const table = useTable<TFeatures, TData, TSelected>(mergedOptions, selector)\n\n const AppTable = defineComponent({\n name: 'AppTable',\n props: {\n selector: {\n type: Function as PropType<(state: TableState<TFeatures>) => unknown>,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n provide(TableContext, table)\n const selected = props.selector\n ? useSelector(table.store, props.selector)\n : undefined\n\n return () => {\n if (!props.selector) {\n return slots.default?.()\n }\n\n return slots.default?.({ state: selected?.value })\n }\n },\n })\n\n const AppCell = defineComponent({\n name: 'AppCell',\n props: {\n cell: {\n type: Object as PropType<object>,\n required: true,\n },\n selector: {\n type: Function as PropType<(state: TableState<TFeatures>) => unknown>,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const cell = props.cell as Cell<TFeatures, TData, any>\n\n provide(CellContext, cell)\n\n const selected = props.selector\n ? useSelector(table.store, props.selector)\n : undefined\n\n const extendedCell = Object.assign(cell, {\n FlexRender: CellFlexRender,\n ...(cellComponents ?? {}),\n }) as Cell<TFeatures, TData, any> &\n TCellComponents & { FlexRender: Component }\n\n return () => {\n return slots.default?.(\n props.selector\n ? { cell: extendedCell, state: selected?.value }\n : { cell: extendedCell },\n )\n }\n },\n })\n\n const AppHeader = defineComponent({\n name: 'AppHeader',\n props: {\n header: {\n type: Object as PropType<object>,\n required: true,\n },\n selector: {\n type: Function as PropType<(state: TableState<TFeatures>) => unknown>,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const header = props.header as Header<TFeatures, TData, any>\n\n provide(HeaderContext, header)\n\n const selected = props.selector\n ? useSelector(table.store, props.selector)\n : undefined\n\n const extendedHeader = Object.assign(header, {\n FlexRender: HeaderFlexRender,\n ...(headerComponents ?? {}),\n }) as Header<TFeatures, TData, any> &\n THeaderComponents & { FlexRender: Component }\n\n return () => {\n return slots.default?.(\n props.selector\n ? { header: extendedHeader, state: selected?.value }\n : { header: extendedHeader },\n )\n }\n },\n })\n\n const AppFooter = defineComponent({\n name: 'AppFooter',\n props: {\n header: {\n type: Object as PropType<object>,\n required: true,\n },\n selector: {\n type: Function as PropType<(state: TableState<TFeatures>) => unknown>,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const header = props.header as Header<TFeatures, TData, any>\n\n provide(HeaderContext, header)\n\n const selected = props.selector\n ? useSelector(table.store, props.selector)\n : undefined\n\n const extendedHeader = Object.assign(header, {\n FlexRender: FooterFlexRender,\n ...(headerComponents ?? {}),\n }) as Header<TFeatures, TData, any> &\n THeaderComponents & { FlexRender: Component }\n\n return () => {\n return slots.default?.(\n props.selector\n ? { header: extendedHeader, state: selected?.value }\n : { header: extendedHeader },\n )\n }\n },\n })\n\n return Object.assign(table, {\n AppTable,\n AppCell,\n AppHeader,\n AppFooter,\n FlexRender: AppFlexRender,\n ...(tableComponents ?? {}),\n }) as AppVueTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n >\n }\n\n return {\n appFeatures: defaultTableOptions._features as TFeatures,\n createAppColumnHelper,\n useAppTable,\n useTableContext,\n useCellContext,\n useHeaderContext,\n }\n}\n"],"mappings":"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"}