@tanstack/vue-table 9.0.0-beta.9 → 9.0.0
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 +27 -9
- package/dist/FlexRender.d.ts +1 -2
- package/dist/FlexRender.js +5 -5
- package/dist/createTableHook.d.ts +40 -20
- package/dist/createTableHook.js +10 -24
- package/dist/experimental-worker-plugin.d.ts +1 -0
- package/dist/experimental-worker-plugin.js +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/merge-proxy.js +1 -2
- package/dist/reactivity.js +3 -8
- package/dist/useTable.d.ts +3 -12
- package/dist/useTable.js +6 -10
- package/package.json +14 -22
- package/skills/create-table-hook/SKILL.md +146 -0
- package/skills/getting-started/SKILL.md +144 -0
- package/skills/migrate-v8-to-v9/SKILL.md +185 -0
- package/skills/table-state/SKILL.md +191 -0
- package/skills/with-tanstack-query/SKILL.md +127 -0
- package/skills/with-tanstack-virtual/SKILL.md +116 -0
- package/dist/FlexRender.cjs +0 -80
- package/dist/FlexRender.cjs.map +0 -1
- package/dist/FlexRender.d.cts +0 -63
- package/dist/FlexRender.js.map +0 -1
- package/dist/createTableHook.cjs +0 -194
- package/dist/createTableHook.cjs.map +0 -1
- package/dist/createTableHook.d.cts +0 -135
- package/dist/createTableHook.js.map +0 -1
- package/dist/flex-render.cjs +0 -5
- package/dist/flex-render.d.cts +0 -2
- package/dist/index.cjs +0 -17
- package/dist/index.d.cts +0 -5
- package/dist/merge-proxy.cjs +0 -77
- package/dist/merge-proxy.cjs.map +0 -1
- package/dist/merge-proxy.js.map +0 -1
- package/dist/reactivity.cjs +0 -64
- package/dist/reactivity.cjs.map +0 -1
- package/dist/reactivity.js.map +0 -1
- package/dist/static-functions.cjs +0 -9
- package/dist/static-functions.d.cts +0 -1
- package/dist/useTable.cjs +0 -76
- package/dist/useTable.cjs.map +0 -1
- package/dist/useTable.d.cts +0 -43
- package/dist/useTable.js.map +0 -1
- package/skills/vue/client-to-server/SKILL.md +0 -365
- package/skills/vue/compose-with-tanstack-form/SKILL.md +0 -369
- package/skills/vue/compose-with-tanstack-pacer/SKILL.md +0 -318
- package/skills/vue/compose-with-tanstack-query/SKILL.md +0 -385
- package/skills/vue/compose-with-tanstack-store/SKILL.md +0 -301
- package/skills/vue/compose-with-tanstack-virtual/SKILL.md +0 -340
- package/skills/vue/getting-started/SKILL.md +0 -409
- package/skills/vue/migrate-v8-to-v9/SKILL.md +0 -375
- package/skills/vue/production-readiness/SKILL.md +0 -271
- package/skills/vue/table-state/SKILL.md +0 -403
- package/src/FlexRender.ts +0 -138
- package/src/createTableHook.ts +0 -534
- package/src/flex-render.ts +0 -1
- package/src/index.ts +0 -4
- package/src/merge-proxy.ts +0 -132
- package/src/reactivity.ts +0 -89
- package/src/static-functions.ts +0 -1
- package/src/useTable.ts +0 -181
package/README.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
2
|
+
<picture>
|
|
3
|
+
<source
|
|
4
|
+
media="(prefers-color-scheme: dark)"
|
|
5
|
+
srcset="https://tanstack.com/api/readme/table.png?theme=dark"
|
|
6
|
+
/>
|
|
7
|
+
<source
|
|
8
|
+
media="(prefers-color-scheme: light)"
|
|
9
|
+
srcset="https://tanstack.com/api/readme/table.png"
|
|
10
|
+
/>
|
|
11
|
+
<img
|
|
12
|
+
src="https://tanstack.com/api/readme/table.png"
|
|
13
|
+
alt="TanStack Table"
|
|
14
|
+
width="900"
|
|
15
|
+
/>
|
|
16
|
+
</picture>
|
|
3
17
|
</div>
|
|
4
18
|
|
|
5
19
|
<br />
|
|
@@ -33,16 +47,20 @@
|
|
|
33
47
|
> [!NOTE]
|
|
34
48
|
> You may know TanStack Table by the adapter names:
|
|
35
49
|
>
|
|
36
|
-
> - [Angular Table](https://tanstack.com/table/
|
|
37
|
-
> - [Lit Table](https://tanstack.com/table/
|
|
38
|
-
> - [
|
|
39
|
-
> - [
|
|
40
|
-
> - [
|
|
41
|
-
> - [
|
|
50
|
+
> - [Angular Table](https://tanstack.com/table/latest/docs/framework/angular/angular-table)
|
|
51
|
+
> - [Lit Table](https://tanstack.com/table/latest/docs/framework/lit/lit-table)
|
|
52
|
+
> - [Octane Table](https://tanstack.com/table/latest/docs/framework/octane/quick-start)
|
|
53
|
+
> - [Preact Table](https://tanstack.com/table/latest/docs/framework/preact/quick-start)
|
|
54
|
+
> - [React Table](https://tanstack.com/table/latest/docs/framework/react/react-table)
|
|
55
|
+
> - [Solid Table](https://tanstack.com/table/latest/docs/framework/solid/solid-table)
|
|
56
|
+
> - [Svelte Table](https://tanstack.com/table/latest/docs/framework/svelte/svelte-table)
|
|
57
|
+
> - [Vue Table](https://tanstack.com/table/latest/docs/framework/vue/vue-table)
|
|
58
|
+
> - [Alpine Table](https://tanstack.com/table/latest/docs/framework/alpine/alpine-table)
|
|
59
|
+
> - [Ember Table](https://tanstack.com/table/latest/docs/framework/ember/ember-table)
|
|
42
60
|
|
|
43
61
|
A headless table library for building powerful datagrids with full control over markup, styles, and behavior.
|
|
44
62
|
|
|
45
|
-
- Framework
|
|
63
|
+
- Framework-agnostic core with bindings for React, Preact, Octane, Vue, Solid, Svelte, Angular, Ember, Lit, and Alpine
|
|
46
64
|
- 100% customizable — bring your own UI, components, and styles
|
|
47
65
|
- Sorting, filtering, grouping, aggregation & row selection
|
|
48
66
|
- Lightweight, virtualizable & server‑side friendly
|
|
@@ -57,7 +75,7 @@ TanStack Table ships [TanStack Intent](https://github.com/TanStack/intent) skill
|
|
|
57
75
|
npx @tanstack/intent@latest install
|
|
58
76
|
```
|
|
59
77
|
|
|
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
|
|
78
|
+
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 are versioned with the library — your agent gets guidance that matches the version of `@tanstack/<framework>-table` you installed. Only available for v9 and above.
|
|
61
79
|
|
|
62
80
|
## Get Involved
|
|
63
81
|
|
package/dist/FlexRender.d.ts
CHANGED
|
@@ -59,5 +59,4 @@ declare const FlexRender: import("vue").DefineComponent<{
|
|
|
59
59
|
footer: FlexRenderHeader;
|
|
60
60
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
61
61
|
//#endregion
|
|
62
|
-
export { FlexRender, FlexRenderCell, FlexRenderHeader, flexRender };
|
|
63
|
-
//# sourceMappingURL=FlexRender.d.ts.map
|
|
62
|
+
export { FlexRender, FlexRenderCell, FlexRenderHeader, flexRender };
|
package/dist/FlexRender.js
CHANGED
|
@@ -6,8 +6,10 @@ import { defineComponent, h, isVNode } from "vue";
|
|
|
6
6
|
* @example flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
7
7
|
*/
|
|
8
8
|
function flexRender(render, props) {
|
|
9
|
+
if (render === null || render === void 0) return render;
|
|
9
10
|
if (typeof render === "function") {
|
|
10
11
|
const rendered = render(props);
|
|
12
|
+
if (rendered === null || rendered === void 0) return rendered;
|
|
11
13
|
if (isVNode(rendered)) return rendered;
|
|
12
14
|
if (typeof rendered === "function" || typeof rendered === "object") return h(rendered, props);
|
|
13
15
|
return rendered;
|
|
@@ -60,11 +62,10 @@ const FlexRender = defineComponent({
|
|
|
60
62
|
setup: (props) => {
|
|
61
63
|
return () => {
|
|
62
64
|
if (props.cell) {
|
|
63
|
-
var _cell$getIsAggregated, _cell$getIsPlaceholde;
|
|
64
65
|
const cell = props.cell;
|
|
65
66
|
const def = cell.column.columnDef;
|
|
66
|
-
if (
|
|
67
|
-
if (
|
|
67
|
+
if (cell.getIsAggregated?.()) return flexRender(def.aggregatedCell ?? def.cell, cell.getContext());
|
|
68
|
+
if (cell.getIsPlaceholder?.()) return null;
|
|
68
69
|
return flexRender(def.cell, cell.getContext());
|
|
69
70
|
}
|
|
70
71
|
if (props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
|
|
@@ -75,5 +76,4 @@ const FlexRender = defineComponent({
|
|
|
75
76
|
});
|
|
76
77
|
|
|
77
78
|
//#endregion
|
|
78
|
-
export { FlexRender, flexRender };
|
|
79
|
-
//# sourceMappingURL=FlexRender.js.map
|
|
79
|
+
export { FlexRender, flexRender };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FlexRenderCell, FlexRenderHeader } from "./FlexRender.js";
|
|
2
2
|
import { TableOptionsWithReactiveData, VueTable } from "./useTable.js";
|
|
3
3
|
import { Component, PropType } from "vue";
|
|
4
|
-
import { AccessorFn, AccessorFnColumnDef, AccessorKeyColumnDef, Cell, CellContext, CellData, Column, ColumnDef, DeepKeys, DeepValue, DisplayColumnDef, GroupColumnDef, Header, IdentifiedColumnDef, NoInfer, Row, RowData, Table, TableFeatures
|
|
5
|
-
|
|
4
|
+
import { AccessorFn, AccessorFnColumnDef, AccessorKeyColumnDef, Cell, CellContext, CellData, Column, ColumnDef, DeepKeys, DeepValue, DisplayColumnDef, GroupColumnDef, Header, IdentifiedColumnDef, NoInfer, Row, RowData, Table, TableFeatures } from "@tanstack/table-core";
|
|
6
5
|
//#region src/createTableHook.d.ts
|
|
7
6
|
type ComponentType<T extends Record<string, any>> = Component<T>;
|
|
8
7
|
type AppCellContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData, TCellComponents extends Record<string, ComponentType<any>>> = {
|
|
@@ -37,7 +36,7 @@ type AppGroupColumnDef<TFeatures extends TableFeatures, TData extends RowData, T
|
|
|
37
36
|
cell?: AppColumnDefTemplate<AppCellContext<TFeatures, TData, unknown, TCellComponents>>;
|
|
38
37
|
header?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>>;
|
|
39
38
|
footer?: AppColumnDefTemplate<AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>>;
|
|
40
|
-
columns?:
|
|
39
|
+
columns?: ReadonlyArray<ColumnDef<TFeatures, TData, unknown>>;
|
|
41
40
|
};
|
|
42
41
|
type AppColumnHelper<TFeatures extends TableFeatures, TData extends RowData, TCellComponents extends Record<string, ComponentType<any>>, THeaderComponents extends Record<string, ComponentType<any>>> = {
|
|
43
42
|
accessor: <TAccessor extends AccessorFn<TData> | DeepKeys<TData>, TValue extends (TAccessor extends AccessorFn<TData, infer TReturn> ? TReturn : TAccessor extends DeepKeys<TData> ? DeepValue<TData, TAccessor> : never)>(accessor: TAccessor, column: TAccessor extends AccessorFn<TData> ? AppColumnDefBase<TFeatures, TData, TValue, TCellComponents, THeaderComponents> & {
|
|
@@ -59,13 +58,48 @@ interface AppCellProps<TFeatures extends TableFeatures, TData extends RowData, T
|
|
|
59
58
|
interface AppHeaderProps<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
60
59
|
header: Header<TFeatures, TData, TValue>;
|
|
61
60
|
}
|
|
62
|
-
type AppVueTable<TFeatures extends TableFeatures, TData extends RowData,
|
|
61
|
+
type AppVueTable<TFeatures extends TableFeatures, TData extends RowData, TTableComponents extends Record<string, ComponentType<any>>, _TCellComponents extends Record<string, ComponentType<any>>, _THeaderComponents extends Record<string, ComponentType<any>>> = VueTable<TFeatures, TData> & NoInfer<TTableComponents> & {
|
|
63
62
|
AppTable: Component<AppTableProps>;
|
|
64
63
|
AppCell: Component<AppCellProps<TFeatures, TData>>;
|
|
65
64
|
AppHeader: Component<AppHeaderProps<TFeatures, TData>>;
|
|
66
65
|
AppFooter: Component<AppHeaderProps<TFeatures, TData>>;
|
|
67
66
|
FlexRender: typeof AppFlexRender;
|
|
68
67
|
};
|
|
68
|
+
interface CreateTableHookResult<TFeatures extends TableFeatures, TTableComponents extends Record<string, ComponentType<any>>, TCellComponents extends Record<string, ComponentType<any>>, THeaderComponents extends Record<string, ComponentType<any>>> {
|
|
69
|
+
/** The features object that was passed to `createTableHook`. */
|
|
70
|
+
appFeatures: TFeatures;
|
|
71
|
+
/**
|
|
72
|
+
* A column helper pre-bound to `TFeatures` and the registered components, so
|
|
73
|
+
* the cell/header/footer render props expose the bound components.
|
|
74
|
+
*/
|
|
75
|
+
createAppColumnHelper: <TData extends RowData>() => AppColumnHelper<TFeatures, TData, TCellComponents, THeaderComponents>;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a table with the `App*` wrapper components and registered
|
|
78
|
+
* `tableComponents` attached. `TData` is inferred from the `data` option.
|
|
79
|
+
*/
|
|
80
|
+
useAppTable: <TData extends RowData>(tableOptions: Omit<TableOptionsWithReactiveData<TFeatures, TData>, 'features'>) => AppVueTable<TFeatures, TData, TTableComponents, TCellComponents, THeaderComponents>;
|
|
81
|
+
/**
|
|
82
|
+
* Reads the table provided by the nearest `<table.AppTable>`. This is the same
|
|
83
|
+
* extended instance `useAppTable` returns, so the `App*` components and your
|
|
84
|
+
* `tableComponents` are available on it.
|
|
85
|
+
*/
|
|
86
|
+
useTableContext: <TData extends RowData = RowData>() => AppVueTable<TFeatures, TData, TTableComponents, TCellComponents, THeaderComponents>;
|
|
87
|
+
/**
|
|
88
|
+
* Reads the cell provided by the nearest `<table.AppCell>`, extended with your
|
|
89
|
+
* `cellComponents` and a context-bound `FlexRender`.
|
|
90
|
+
*/
|
|
91
|
+
useCellContext: <TValue extends CellData = CellData>() => Cell<TFeatures, any, TValue> & TCellComponents & {
|
|
92
|
+
FlexRender: Component;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Reads the header provided by the nearest `<table.AppHeader>` /
|
|
96
|
+
* `<table.AppFooter>`, extended with your `headerComponents` and a
|
|
97
|
+
* context-bound `FlexRender`.
|
|
98
|
+
*/
|
|
99
|
+
useHeaderContext: <TValue extends CellData = CellData>() => Header<TFeatures, any, TValue> & THeaderComponents & {
|
|
100
|
+
FlexRender: Component;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
69
103
|
declare const AppFlexRender: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
70
104
|
cell: {
|
|
71
105
|
type: PropType<FlexRenderCell>;
|
|
@@ -110,26 +144,12 @@ declare const AppFlexRender: import("vue").DefineComponent<import("vue").Extract
|
|
|
110
144
|
* ```ts
|
|
111
145
|
* const { useAppTable, createAppColumnHelper } = createTableHook({
|
|
112
146
|
* features,
|
|
113
|
-
* rowModels: {},
|
|
114
147
|
* tableComponents: {},
|
|
115
148
|
* cellComponents: {},
|
|
116
149
|
* headerComponents: {},
|
|
117
150
|
* })
|
|
118
151
|
* ```
|
|
119
152
|
*/
|
|
120
|
-
declare function createTableHook<TFeatures extends TableFeatures, const TTableComponents extends Record<string, ComponentType<any>>, const TCellComponents extends Record<string, ComponentType<any>>, const THeaderComponents extends Record<string, ComponentType<any>>>({
|
|
121
|
-
tableComponents,
|
|
122
|
-
cellComponents,
|
|
123
|
-
headerComponents,
|
|
124
|
-
...defaultTableOptions
|
|
125
|
-
}: CreateTableHookOptions<TFeatures, TTableComponents, TCellComponents, THeaderComponents>): {
|
|
126
|
-
appFeatures: TFeatures;
|
|
127
|
-
createAppColumnHelper: <TData extends RowData>() => AppColumnHelper<TFeatures, TData, TCellComponents, THeaderComponents>;
|
|
128
|
-
useAppTable: <TData extends RowData>(tableOptions: Omit<TableOptionsWithReactiveData<TFeatures, TData>, "features" | "rowModels">) => AppVueTable<TFeatures, TData, TableState<TFeatures>, TTableComponents, TCellComponents, THeaderComponents>;
|
|
129
|
-
useTableContext: <TData extends RowData = RowData>() => VueTable<TFeatures, TData>;
|
|
130
|
-
useCellContext: <TValue extends CellData = unknown>() => Cell<TFeatures, any, TValue>;
|
|
131
|
-
useHeaderContext: <TValue extends CellData = unknown>() => Header<TFeatures, any, TValue>;
|
|
132
|
-
};
|
|
153
|
+
declare function createTableHook<TFeatures extends TableFeatures, const TTableComponents extends Record<string, ComponentType<any>>, const TCellComponents extends Record<string, ComponentType<any>>, const THeaderComponents extends Record<string, ComponentType<any>>>({ tableComponents, cellComponents, headerComponents, ...defaultTableOptions }: CreateTableHookOptions<TFeatures, TTableComponents, TCellComponents, THeaderComponents>): CreateTableHookResult<TFeatures, TTableComponents, TCellComponents, THeaderComponents>;
|
|
133
154
|
//#endregion
|
|
134
|
-
export { AppCellContext, AppCellProps, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppFlexRender, AppGroupColumnDef, AppHeaderContext, AppHeaderProps, AppTableProps, AppVueTable, ComponentType, CreateTableHookOptions, createTableHook };
|
|
135
|
-
//# sourceMappingURL=createTableHook.d.ts.map
|
|
155
|
+
export { AppCellContext, AppCellProps, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppFlexRender, AppGroupColumnDef, AppHeaderContext, AppHeaderProps, AppTableProps, AppVueTable, ComponentType, CreateTableHookOptions, CreateTableHookResult, createTableHook };
|
package/dist/createTableHook.js
CHANGED
|
@@ -23,18 +23,9 @@ const AppFlexRender = defineComponent({
|
|
|
23
23
|
},
|
|
24
24
|
setup(props) {
|
|
25
25
|
return () => {
|
|
26
|
-
if (props.cell) return h(FlexRender, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
if (props.header) return h(FlexRender, {
|
|
31
|
-
render: props.header.column.columnDef.header,
|
|
32
|
-
props: props.header.getContext()
|
|
33
|
-
});
|
|
34
|
-
if (props.footer) return h(FlexRender, {
|
|
35
|
-
render: props.footer.column.columnDef.footer,
|
|
36
|
-
props: props.footer.getContext()
|
|
37
|
-
});
|
|
26
|
+
if (props.cell) return h(FlexRender, { cell: props.cell });
|
|
27
|
+
if (props.header) return h(FlexRender, { header: props.header });
|
|
28
|
+
if (props.footer) return h(FlexRender, { footer: props.footer });
|
|
38
29
|
return null;
|
|
39
30
|
};
|
|
40
31
|
}
|
|
@@ -50,7 +41,6 @@ const AppFlexRender = defineComponent({
|
|
|
50
41
|
* ```ts
|
|
51
42
|
* const { useAppTable, createAppColumnHelper } = createTableHook({
|
|
52
43
|
* features,
|
|
53
|
-
* rowModels: {},
|
|
54
44
|
* tableComponents: {},
|
|
55
45
|
* cellComponents: {},
|
|
56
46
|
* headerComponents: {},
|
|
@@ -101,14 +91,14 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
101
91
|
}
|
|
102
92
|
});
|
|
103
93
|
function useAppTable(tableOptions) {
|
|
104
|
-
const
|
|
94
|
+
const mergedOptions = mergeProxy(defaultTableOptions, tableOptions);
|
|
95
|
+
const table = useTable(mergedOptions);
|
|
105
96
|
const AppTable = defineComponent({
|
|
106
97
|
name: "AppTable",
|
|
107
98
|
setup(_, { slots }) {
|
|
108
99
|
provide(TableContext, table);
|
|
109
100
|
return () => {
|
|
110
|
-
|
|
111
|
-
return (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
|
|
101
|
+
return slots.default?.();
|
|
112
102
|
};
|
|
113
103
|
}
|
|
114
104
|
});
|
|
@@ -126,8 +116,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
126
116
|
...cellComponents ?? {}
|
|
127
117
|
});
|
|
128
118
|
return () => {
|
|
129
|
-
|
|
130
|
-
return (_slots$default2 = slots.default) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots, { cell: extendedCell });
|
|
119
|
+
return slots.default?.({ cell: extendedCell });
|
|
131
120
|
};
|
|
132
121
|
}
|
|
133
122
|
});
|
|
@@ -145,8 +134,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
145
134
|
...headerComponents ?? {}
|
|
146
135
|
});
|
|
147
136
|
return () => {
|
|
148
|
-
|
|
149
|
-
return (_slots$default3 = slots.default) === null || _slots$default3 === void 0 ? void 0 : _slots$default3.call(slots, { header: extendedHeader });
|
|
137
|
+
return slots.default?.({ header: extendedHeader });
|
|
150
138
|
};
|
|
151
139
|
}
|
|
152
140
|
});
|
|
@@ -164,8 +152,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
164
152
|
...headerComponents ?? {}
|
|
165
153
|
});
|
|
166
154
|
return () => {
|
|
167
|
-
|
|
168
|
-
return (_slots$default4 = slots.default) === null || _slots$default4 === void 0 ? void 0 : _slots$default4.call(slots, { header: extendedHeader });
|
|
155
|
+
return slots.default?.({ header: extendedHeader });
|
|
169
156
|
};
|
|
170
157
|
}
|
|
171
158
|
});
|
|
@@ -189,5 +176,4 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
189
176
|
}
|
|
190
177
|
|
|
191
178
|
//#endregion
|
|
192
|
-
export { AppFlexRender, createTableHook };
|
|
193
|
-
//# sourceMappingURL=createTableHook.js.map
|
|
179
|
+
export { AppFlexRender, createTableHook };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tanstack/table-core/experimental-worker-plugin";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FlexRender, FlexRenderCell, FlexRenderHeader, flexRender } from "./FlexRender.js";
|
|
2
2
|
import { TableOptionsWithReactiveData, VueTable, useTable } from "./useTable.js";
|
|
3
|
-
import { AppCellContext, AppCellProps, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppFlexRender, AppGroupColumnDef, AppHeaderContext, AppHeaderProps, AppTableProps, AppVueTable, ComponentType, CreateTableHookOptions, createTableHook } from "./createTableHook.js";
|
|
3
|
+
import { AppCellContext, AppCellProps, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppFlexRender, AppGroupColumnDef, AppHeaderContext, AppHeaderProps, AppTableProps, AppVueTable, ComponentType, CreateTableHookOptions, CreateTableHookResult, createTableHook } from "./createTableHook.js";
|
|
4
4
|
export * from "@tanstack/table-core";
|
|
5
|
-
export { AppCellContext, AppCellProps, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppFlexRender, AppGroupColumnDef, AppHeaderContext, AppHeaderProps, AppTableProps, AppVueTable, ComponentType, CreateTableHookOptions, FlexRender, FlexRenderCell, FlexRenderHeader, TableOptionsWithReactiveData, VueTable, createTableHook, flexRender, useTable };
|
|
5
|
+
export { AppCellContext, AppCellProps, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppFlexRender, AppGroupColumnDef, AppHeaderContext, AppHeaderProps, AppTableProps, AppVueTable, ComponentType, CreateTableHookOptions, CreateTableHookResult, FlexRender, FlexRenderCell, FlexRenderHeader, TableOptionsWithReactiveData, VueTable, createTableHook, flexRender, useTable };
|
package/dist/merge-proxy.js
CHANGED
package/dist/reactivity.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { computed, shallowRef, watch } from "vue";
|
|
2
|
-
import { batch } from "@tanstack/store";
|
|
3
2
|
|
|
4
3
|
//#region src/reactivity.ts
|
|
5
4
|
function observerToCallback(observerOrNext) {
|
|
6
|
-
return typeof observerOrNext === "function" ? observerOrNext : (value) =>
|
|
7
|
-
var _observerOrNext$next;
|
|
8
|
-
return (_observerOrNext$next = observerOrNext.next) === null || _observerOrNext$next === void 0 ? void 0 : _observerOrNext$next.call(observerOrNext, value);
|
|
9
|
-
};
|
|
5
|
+
return typeof observerOrNext === "function" ? observerOrNext : (value) => observerOrNext.next?.(value);
|
|
10
6
|
}
|
|
11
7
|
function refToReadonlyAtom(source) {
|
|
12
8
|
return Object.assign(source, {
|
|
@@ -55,10 +51,9 @@ function vueReactivity() {
|
|
|
55
51
|
return refToWritableAtom(shallowRef(value));
|
|
56
52
|
},
|
|
57
53
|
untrack: (fn) => fn(),
|
|
58
|
-
batch
|
|
54
|
+
batch: (fn) => fn()
|
|
59
55
|
};
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
//#endregion
|
|
63
|
-
export { vueReactivity };
|
|
64
|
-
//# sourceMappingURL=reactivity.js.map
|
|
59
|
+
export { vueReactivity };
|
package/dist/useTable.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { MaybeRef, VNode } from "vue";
|
|
2
2
|
import { RowData, Table, TableFeatures, TableOptions } from "@tanstack/table-core";
|
|
3
|
-
|
|
4
3
|
//#region src/useTable.d.ts
|
|
5
|
-
type TableOptionsWithReactiveData<TFeatures extends TableFeatures, TData extends RowData> = { [K in keyof TableOptions<TFeatures, TData>]: K extends 'data' ? MaybeRef<ReadonlyArray<TData>> : MaybeRef<TableOptions<TFeatures, TData>[K]
|
|
6
|
-
type VueTable<TFeatures extends TableFeatures, TData extends RowData> =
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Prefer `table.atoms.<slice>.get()` for slice snapshots, or
|
|
9
|
-
* `table.Subscribe` for explicit subscriptions. `table.store.state` is a
|
|
10
|
-
* current-value snapshot and is easy to misuse in render code.
|
|
11
|
-
*/
|
|
12
|
-
readonly store: Table<TFeatures, TData>['store'];
|
|
4
|
+
type TableOptionsWithReactiveData<TFeatures extends TableFeatures, TData extends RowData> = { [K in keyof TableOptions<TFeatures, TData>]: K extends 'data' ? MaybeRef<ReadonlyArray<TData>> : MaybeRef<TableOptions<TFeatures, TData>[K]>; };
|
|
5
|
+
type VueTable<TFeatures extends TableFeatures, TData extends RowData> = Table<TFeatures, TData> & {
|
|
13
6
|
/** Creates a reactive render boundary. The child function reads the table
|
|
14
7
|
* atoms it needs, so Vue only tracks those atom reads.
|
|
15
8
|
*/
|
|
@@ -30,7 +23,6 @@ type VueTable<TFeatures extends TableFeatures, TData extends RowData> = Omit<Tab
|
|
|
30
23
|
* const table = useTable(
|
|
31
24
|
* {
|
|
32
25
|
* features,
|
|
33
|
-
* rowModels: {},
|
|
34
26
|
* columns,
|
|
35
27
|
* data,
|
|
36
28
|
* },
|
|
@@ -39,5 +31,4 @@ type VueTable<TFeatures extends TableFeatures, TData extends RowData> = Omit<Tab
|
|
|
39
31
|
*/
|
|
40
32
|
declare function useTable<TFeatures extends TableFeatures, TData extends RowData>(tableOptions: TableOptions<TFeatures, TData> | TableOptionsWithReactiveData<TFeatures, TData>): VueTable<TFeatures, TData>;
|
|
41
33
|
//#endregion
|
|
42
|
-
export { TableOptionsWithReactiveData, VueTable, useTable };
|
|
43
|
-
//# sourceMappingURL=useTable.d.ts.map
|
|
34
|
+
export { TableOptionsWithReactiveData, VueTable, useTable };
|
package/dist/useTable.js
CHANGED
|
@@ -25,7 +25,6 @@ function getReactiveOptionDeps(options) {
|
|
|
25
25
|
* const table = useTable(
|
|
26
26
|
* {
|
|
27
27
|
* features,
|
|
28
|
-
* rowModels: {},
|
|
29
28
|
* columns,
|
|
30
29
|
* data,
|
|
31
30
|
* },
|
|
@@ -41,14 +40,12 @@ function useTable(tableOptions) {
|
|
|
41
40
|
coreReactivityFeature: reactivity,
|
|
42
41
|
...unref(tableOptions.features) ?? {}
|
|
43
42
|
} });
|
|
44
|
-
const
|
|
43
|
+
const resolvedOptions = mergeProxy(getOptionsWithReactiveValues(mergedOptions), { mergeOptions: (defaultOptions, newOptions) => {
|
|
45
44
|
return flatMerge(defaultOptions, newOptions);
|
|
46
|
-
} })
|
|
45
|
+
} });
|
|
46
|
+
const coreTable = constructTable(resolvedOptions);
|
|
47
47
|
const table = coreTable;
|
|
48
|
-
if (getCurrentScope()) onScopeDispose(() =>
|
|
49
|
-
var _reactivity$unmount;
|
|
50
|
-
return (_reactivity$unmount = reactivity.unmount) === null || _reactivity$unmount === void 0 ? void 0 : _reactivity$unmount.call(reactivity);
|
|
51
|
-
});
|
|
48
|
+
if (getCurrentScope()) onScopeDispose(() => reactivity.unmount?.());
|
|
52
49
|
watch(() => getReactiveOptionDeps(mergedOptions), () => {
|
|
53
50
|
syncTableOptions(coreTable, mergedOptions);
|
|
54
51
|
}, { immediate: true });
|
|
@@ -58,7 +55,7 @@ function useTable(tableOptions) {
|
|
|
58
55
|
if (!controlledState) return [];
|
|
59
56
|
const controlledValues = [];
|
|
60
57
|
for (const key of Object.keys(table.initialState)) {
|
|
61
|
-
if (!(key in controlledState) ||
|
|
58
|
+
if (!(key in controlledState) || controlledAtoms?.[key] !== void 0) continue;
|
|
62
59
|
controlledValues.push(controlledState[key]);
|
|
63
60
|
}
|
|
64
61
|
return controlledValues;
|
|
@@ -72,5 +69,4 @@ function useTable(tableOptions) {
|
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
//#endregion
|
|
75
|
-
export { useTable };
|
|
76
|
-
//# sourceMappingURL=useTable.js.map
|
|
72
|
+
export { useTable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-table",
|
|
3
|
-
"version": "9.0.0
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for Vue.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,41 +22,31 @@
|
|
|
22
22
|
"tanstack-intent"
|
|
23
23
|
],
|
|
24
24
|
"type": "module",
|
|
25
|
-
"types": "./dist/index.d.
|
|
26
|
-
"main": "./dist/index.cjs",
|
|
27
|
-
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
28
26
|
"exports": {
|
|
29
|
-
".":
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"./flex-render": {
|
|
34
|
-
"import": "./dist/flex-render.js",
|
|
35
|
-
"require": "./dist/flex-render.cjs"
|
|
36
|
-
},
|
|
37
|
-
"./static-functions": {
|
|
38
|
-
"import": "./dist/static-functions.js",
|
|
39
|
-
"require": "./dist/static-functions.cjs"
|
|
40
|
-
},
|
|
27
|
+
".": "./dist/index.js",
|
|
28
|
+
"./experimental-worker-plugin": "./dist/experimental-worker-plugin.js",
|
|
29
|
+
"./flex-render": "./dist/flex-render.js",
|
|
30
|
+
"./static-functions": "./dist/static-functions.js",
|
|
41
31
|
"./package.json": "./package.json"
|
|
42
32
|
},
|
|
43
33
|
"sideEffects": false,
|
|
44
34
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
35
|
+
"node": ">=20"
|
|
46
36
|
},
|
|
47
37
|
"files": [
|
|
48
38
|
"dist",
|
|
49
|
-
"src",
|
|
50
39
|
"skills"
|
|
51
40
|
],
|
|
52
41
|
"dependencies": {
|
|
53
42
|
"@tanstack/store": "^0.11.0",
|
|
54
|
-
"@tanstack/table-core": "9.0.0
|
|
43
|
+
"@tanstack/table-core": "9.0.0"
|
|
55
44
|
},
|
|
56
45
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"vue": "^
|
|
46
|
+
"@testing-library/vue": "^8.1.0",
|
|
47
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
48
|
+
"eslint-plugin-vue": "^10.10.0",
|
|
49
|
+
"vue": "^3.5.40"
|
|
60
50
|
},
|
|
61
51
|
"peerDependencies": {
|
|
62
52
|
"vue": ">=3.2"
|
|
@@ -64,6 +54,8 @@
|
|
|
64
54
|
"scripts": {
|
|
65
55
|
"clean": "rimraf ./build && rimraf ./dist",
|
|
66
56
|
"test:eslint": "eslint ./src",
|
|
57
|
+
"test:lib": "vitest --passWithNoTests",
|
|
58
|
+
"test:lib:dev": "pnpm test:lib --watch",
|
|
67
59
|
"test:types": "tsc",
|
|
68
60
|
"test:build": "publint --strict",
|
|
69
61
|
"build": "tsdown"
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create-table-hook
|
|
3
|
+
description: >
|
|
4
|
+
Create a reusable Vue useAppTable/createAppColumnHelper with shared features/defaults, reactive per-table options, optional component registries, dynamic App wrappers, typed context hooks, and explicit types that break circular inference.
|
|
5
|
+
metadata:
|
|
6
|
+
type: framework
|
|
7
|
+
library: '@tanstack/vue-table'
|
|
8
|
+
framework: vue
|
|
9
|
+
library_version: '9.0.0'
|
|
10
|
+
requires:
|
|
11
|
+
- '@tanstack/table-core#core'
|
|
12
|
+
- getting-started
|
|
13
|
+
- table-state
|
|
14
|
+
sources:
|
|
15
|
+
- 'TanStack/table:docs/framework/vue/guide/composable-tables.md'
|
|
16
|
+
- 'TanStack/table:examples/vue/composable-tables'
|
|
17
|
+
- 'TanStack/table:packages/vue-table/src/createTableHook.ts'
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
This skill builds on `@tanstack/table-core#core`, `getting-started`, and `table-state`. Use it for recurring app conventions; use `useTable` for a one-off.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {
|
|
26
|
+
createTableHook,
|
|
27
|
+
rowSortingFeature,
|
|
28
|
+
tableFeatures,
|
|
29
|
+
} from '@tanstack/vue-table'
|
|
30
|
+
import type { RowData, VueTable } from '@tanstack/vue-table'
|
|
31
|
+
|
|
32
|
+
const features = tableFeatures({ rowSortingFeature })
|
|
33
|
+
const hook = createTableHook({ features })
|
|
34
|
+
export const useAppTable = hook.useAppTable
|
|
35
|
+
export const createAppColumnHelper = hook.createAppColumnHelper
|
|
36
|
+
export const useTableContext: <TData extends RowData = RowData>() => VueTable<
|
|
37
|
+
typeof features,
|
|
38
|
+
TData
|
|
39
|
+
> = hook.useTableContext
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The explicit exported context-hook types are important when registered components import the hook module that also imports those components.
|
|
43
|
+
|
|
44
|
+
## Core Patterns
|
|
45
|
+
|
|
46
|
+
### Keep per-table values reactive
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
const helper = createAppColumnHelper<Person>()
|
|
50
|
+
const columns = helper.columns([helper.accessor('name', { header: 'Name' })])
|
|
51
|
+
const table = useAppTable({ columns, data })
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Pass refs/computed options through unchanged.
|
|
55
|
+
|
|
56
|
+
### Wrap registered component context
|
|
57
|
+
|
|
58
|
+
Render through `table.AppTable`, `table.AppCell`, or `table.AppHeader`; inside registered components call the corresponding typed context hook instead of prop drilling.
|
|
59
|
+
|
|
60
|
+
## Common Mistakes
|
|
61
|
+
|
|
62
|
+
### HIGH Creating circular inferred exports
|
|
63
|
+
|
|
64
|
+
Wrong:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
export const { useAppTable, useTableContext } = createTableHook({
|
|
68
|
+
tableComponents: { Pager },
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Correct:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const hook = createTableHook({ tableComponents: { Pager } })
|
|
76
|
+
export const useTableContext: <TData extends RowData = RowData>() => VueTable<
|
|
77
|
+
typeof features,
|
|
78
|
+
TData
|
|
79
|
+
> = hook.useTableContext
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When `Pager` imports `useTableContext`, inferred destructured exports can form a circular inference/import chain.
|
|
83
|
+
|
|
84
|
+
Source: `docs/framework/vue/guide/composable-tables.md`
|
|
85
|
+
|
|
86
|
+
### HIGH Flattening reactive table options
|
|
87
|
+
|
|
88
|
+
Wrong:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
useAppTable({ columns, data: data.value })
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Correct:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
useAppTable({ columns, data })
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The app hook preserves the adapter’s `MaybeRef` option contract.
|
|
101
|
+
|
|
102
|
+
Source: `packages/vue-table/src/createTableHook.ts`
|
|
103
|
+
|
|
104
|
+
### HIGH Using context without App wrappers
|
|
105
|
+
|
|
106
|
+
Wrong:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
const table = useTableContext()
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Correct:
|
|
113
|
+
|
|
114
|
+
```vue
|
|
115
|
+
<component :is="table.AppTable"><Pager /></component>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The typed context exists only below the corresponding dynamic wrapper.
|
|
119
|
+
|
|
120
|
+
Source: `packages/vue-table/src/createTableHook.ts`
|
|
121
|
+
|
|
122
|
+
### MEDIUM Treating Subscribe children as slots
|
|
123
|
+
|
|
124
|
+
Wrong:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
<table.Subscribe>
|
|
128
|
+
{(atoms) => <Pager page={atoms.pagination.get()} />}
|
|
129
|
+
</table.Subscribe>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Correct:
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
<table.Subscribe
|
|
136
|
+
children={(atoms) => <Pager page={atoms.pagination.get()} />}
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Vue’s adapter expects an explicit `children` prop in JSX.
|
|
141
|
+
|
|
142
|
+
Source: `packages/vue-table/src/useTable.ts`
|
|
143
|
+
|
|
144
|
+
## API Discovery
|
|
145
|
+
|
|
146
|
+
Inspect `node_modules/@tanstack/vue-table/dist/createTableHook.d.ts` for the returned helpers, wrapper props, registry types, and context contracts.
|