@tanstack/vue-table 9.0.0-beta.6 → 9.0.0-beta.61
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 +2 -0
- package/dist/FlexRender.d.ts +1 -2
- package/dist/FlexRender.js +5 -5
- package/dist/createTableHook.d.ts +39 -13
- package/dist/createTableHook.js +8 -23
- 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 +2 -10
- package/dist/useTable.js +4 -9
- package/package.json +12 -20
- 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
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
> - [Solid Table](https://tanstack.com/table/alpha/docs/framework/solid/solid-table)
|
|
40
40
|
> - [Svelte Table](https://tanstack.com/table/alpha/docs/framework/svelte/svelte-table)
|
|
41
41
|
> - [Vue Table](https://tanstack.com/table/alpha/docs/framework/vue/vue-table)
|
|
42
|
+
> - [Alpine Table](https://tanstack.com/table/alpha/docs/framework/alpine/alpine-table)
|
|
43
|
+
> - [Ember Table](https://tanstack.com/table/alpha/docs/framework/ember/ember-table)
|
|
42
44
|
|
|
43
45
|
A headless table library for building powerful datagrids with full control over markup, styles, and behavior.
|
|
44
46
|
|
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,7 +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
|
|
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";
|
|
5
5
|
|
|
6
6
|
//#region src/createTableHook.d.ts
|
|
7
7
|
type ComponentType<T extends Record<string, any>> = Component<T>;
|
|
@@ -59,13 +59,48 @@ interface AppCellProps<TFeatures extends TableFeatures, TData extends RowData, T
|
|
|
59
59
|
interface AppHeaderProps<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
|
|
60
60
|
header: Header<TFeatures, TData, TValue>;
|
|
61
61
|
}
|
|
62
|
-
type AppVueTable<TFeatures extends TableFeatures, TData extends RowData,
|
|
62
|
+
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
63
|
AppTable: Component<AppTableProps>;
|
|
64
64
|
AppCell: Component<AppCellProps<TFeatures, TData>>;
|
|
65
65
|
AppHeader: Component<AppHeaderProps<TFeatures, TData>>;
|
|
66
66
|
AppFooter: Component<AppHeaderProps<TFeatures, TData>>;
|
|
67
67
|
FlexRender: typeof AppFlexRender;
|
|
68
68
|
};
|
|
69
|
+
interface CreateTableHookResult<TFeatures extends TableFeatures, TTableComponents extends Record<string, ComponentType<any>>, TCellComponents extends Record<string, ComponentType<any>>, THeaderComponents extends Record<string, ComponentType<any>>> {
|
|
70
|
+
/** The features object that was passed to `createTableHook`. */
|
|
71
|
+
appFeatures: TFeatures;
|
|
72
|
+
/**
|
|
73
|
+
* A column helper pre-bound to `TFeatures` and the registered components, so
|
|
74
|
+
* the cell/header/footer render props expose the bound components.
|
|
75
|
+
*/
|
|
76
|
+
createAppColumnHelper: <TData extends RowData>() => AppColumnHelper<TFeatures, TData, TCellComponents, THeaderComponents>;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a table with the `App*` wrapper components and registered
|
|
79
|
+
* `tableComponents` attached. `TData` is inferred from the `data` option.
|
|
80
|
+
*/
|
|
81
|
+
useAppTable: <TData extends RowData>(tableOptions: Omit<TableOptionsWithReactiveData<TFeatures, TData>, 'features'>) => AppVueTable<TFeatures, TData, TTableComponents, TCellComponents, THeaderComponents>;
|
|
82
|
+
/**
|
|
83
|
+
* Reads the table provided by the nearest `<table.AppTable>`. This is the same
|
|
84
|
+
* extended instance `useAppTable` returns, so the `App*` components and your
|
|
85
|
+
* `tableComponents` are available on it.
|
|
86
|
+
*/
|
|
87
|
+
useTableContext: <TData extends RowData = RowData>() => AppVueTable<TFeatures, TData, TTableComponents, TCellComponents, THeaderComponents>;
|
|
88
|
+
/**
|
|
89
|
+
* Reads the cell provided by the nearest `<table.AppCell>`, extended with your
|
|
90
|
+
* `cellComponents` and a context-bound `FlexRender`.
|
|
91
|
+
*/
|
|
92
|
+
useCellContext: <TValue extends CellData = CellData>() => Cell<TFeatures, any, TValue> & TCellComponents & {
|
|
93
|
+
FlexRender: Component;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Reads the header provided by the nearest `<table.AppHeader>` /
|
|
97
|
+
* `<table.AppFooter>`, extended with your `headerComponents` and a
|
|
98
|
+
* context-bound `FlexRender`.
|
|
99
|
+
*/
|
|
100
|
+
useHeaderContext: <TValue extends CellData = CellData>() => Header<TFeatures, any, TValue> & THeaderComponents & {
|
|
101
|
+
FlexRender: Component;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
69
104
|
declare const AppFlexRender: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
70
105
|
cell: {
|
|
71
106
|
type: PropType<FlexRenderCell>;
|
|
@@ -110,7 +145,6 @@ declare const AppFlexRender: import("vue").DefineComponent<import("vue").Extract
|
|
|
110
145
|
* ```ts
|
|
111
146
|
* const { useAppTable, createAppColumnHelper } = createTableHook({
|
|
112
147
|
* features,
|
|
113
|
-
* rowModels: {},
|
|
114
148
|
* tableComponents: {},
|
|
115
149
|
* cellComponents: {},
|
|
116
150
|
* headerComponents: {},
|
|
@@ -122,14 +156,6 @@ declare function createTableHook<TFeatures extends TableFeatures, const TTableCo
|
|
|
122
156
|
cellComponents,
|
|
123
157
|
headerComponents,
|
|
124
158
|
...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
|
-
};
|
|
159
|
+
}: CreateTableHookOptions<TFeatures, TTableComponents, TCellComponents, THeaderComponents>): CreateTableHookResult<TFeatures, TTableComponents, TCellComponents, THeaderComponents>;
|
|
133
160
|
//#endregion
|
|
134
|
-
export { AppCellContext, AppCellProps, AppColumnDefBase, AppColumnDefTemplate, AppColumnHelper, AppDisplayColumnDef, AppFlexRender, AppGroupColumnDef, AppHeaderContext, AppHeaderProps, AppTableProps, AppVueTable, ComponentType, CreateTableHookOptions, createTableHook };
|
|
135
|
-
//# sourceMappingURL=createTableHook.d.ts.map
|
|
161
|
+
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: {},
|
|
@@ -107,8 +97,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
107
97
|
setup(_, { slots }) {
|
|
108
98
|
provide(TableContext, table);
|
|
109
99
|
return () => {
|
|
110
|
-
|
|
111
|
-
return (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
|
|
100
|
+
return slots.default?.();
|
|
112
101
|
};
|
|
113
102
|
}
|
|
114
103
|
});
|
|
@@ -126,8 +115,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
126
115
|
...cellComponents ?? {}
|
|
127
116
|
});
|
|
128
117
|
return () => {
|
|
129
|
-
|
|
130
|
-
return (_slots$default2 = slots.default) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots, { cell: extendedCell });
|
|
118
|
+
return slots.default?.({ cell: extendedCell });
|
|
131
119
|
};
|
|
132
120
|
}
|
|
133
121
|
});
|
|
@@ -145,8 +133,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
145
133
|
...headerComponents ?? {}
|
|
146
134
|
});
|
|
147
135
|
return () => {
|
|
148
|
-
|
|
149
|
-
return (_slots$default3 = slots.default) === null || _slots$default3 === void 0 ? void 0 : _slots$default3.call(slots, { header: extendedHeader });
|
|
136
|
+
return slots.default?.({ header: extendedHeader });
|
|
150
137
|
};
|
|
151
138
|
}
|
|
152
139
|
});
|
|
@@ -164,8 +151,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
164
151
|
...headerComponents ?? {}
|
|
165
152
|
});
|
|
166
153
|
return () => {
|
|
167
|
-
|
|
168
|
-
return (_slots$default4 = slots.default) === null || _slots$default4 === void 0 ? void 0 : _slots$default4.call(slots, { header: extendedHeader });
|
|
154
|
+
return slots.default?.({ header: extendedHeader });
|
|
169
155
|
};
|
|
170
156
|
}
|
|
171
157
|
});
|
|
@@ -189,5 +175,4 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
|
|
|
189
175
|
}
|
|
190
176
|
|
|
191
177
|
//#endregion
|
|
192
|
-
export { AppFlexRender, createTableHook };
|
|
193
|
-
//# sourceMappingURL=createTableHook.js.map
|
|
178
|
+
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
|
@@ -3,13 +3,7 @@ import { RowData, Table, TableFeatures, TableOptions } from "@tanstack/table-cor
|
|
|
3
3
|
|
|
4
4
|
//#region src/useTable.d.ts
|
|
5
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'];
|
|
6
|
+
type VueTable<TFeatures extends TableFeatures, TData extends RowData> = Table<TFeatures, TData> & {
|
|
13
7
|
/** Creates a reactive render boundary. The child function reads the table
|
|
14
8
|
* atoms it needs, so Vue only tracks those atom reads.
|
|
15
9
|
*/
|
|
@@ -30,7 +24,6 @@ type VueTable<TFeatures extends TableFeatures, TData extends RowData> = Omit<Tab
|
|
|
30
24
|
* const table = useTable(
|
|
31
25
|
* {
|
|
32
26
|
* features,
|
|
33
|
-
* rowModels: {},
|
|
34
27
|
* columns,
|
|
35
28
|
* data,
|
|
36
29
|
* },
|
|
@@ -39,5 +32,4 @@ type VueTable<TFeatures extends TableFeatures, TData extends RowData> = Omit<Tab
|
|
|
39
32
|
*/
|
|
40
33
|
declare function useTable<TFeatures extends TableFeatures, TData extends RowData>(tableOptions: TableOptions<TFeatures, TData> | TableOptionsWithReactiveData<TFeatures, TData>): VueTable<TFeatures, TData>;
|
|
41
34
|
//#endregion
|
|
42
|
-
export { TableOptionsWithReactiveData, VueTable, useTable };
|
|
43
|
-
//# sourceMappingURL=useTable.d.ts.map
|
|
35
|
+
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
|
* },
|
|
@@ -38,17 +37,14 @@ function useTable(tableOptions) {
|
|
|
38
37
|
};
|
|
39
38
|
const reactivity = vueReactivity();
|
|
40
39
|
const mergedOptions = mergeProxy(tableOptions, { features: {
|
|
41
|
-
|
|
40
|
+
coreReactivityFeature: reactivity,
|
|
42
41
|
...unref(tableOptions.features) ?? {}
|
|
43
42
|
} });
|
|
44
43
|
const coreTable = constructTable(mergeProxy(getOptionsWithReactiveValues(mergedOptions), { mergeOptions: (defaultOptions, newOptions) => {
|
|
45
44
|
return flatMerge(defaultOptions, newOptions);
|
|
46
45
|
} }));
|
|
47
46
|
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
|
-
});
|
|
47
|
+
if (getCurrentScope()) onScopeDispose(() => reactivity.unmount?.());
|
|
52
48
|
watch(() => getReactiveOptionDeps(mergedOptions), () => {
|
|
53
49
|
syncTableOptions(coreTable, mergedOptions);
|
|
54
50
|
}, { immediate: true });
|
|
@@ -58,7 +54,7 @@ function useTable(tableOptions) {
|
|
|
58
54
|
if (!controlledState) return [];
|
|
59
55
|
const controlledValues = [];
|
|
60
56
|
for (const key of Object.keys(table.initialState)) {
|
|
61
|
-
if (!(key in controlledState) ||
|
|
57
|
+
if (!(key in controlledState) || controlledAtoms?.[key] !== void 0) continue;
|
|
62
58
|
controlledValues.push(controlledState[key]);
|
|
63
59
|
}
|
|
64
60
|
return controlledValues;
|
|
@@ -72,5 +68,4 @@ function useTable(tableOptions) {
|
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
//#endregion
|
|
75
|
-
export { useTable };
|
|
76
|
-
//# sourceMappingURL=useTable.js.map
|
|
71
|
+
export { useTable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-table",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.61",
|
|
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": "
|
|
43
|
+
"@tanstack/table-core": "9.0.0-beta.61"
|
|
55
44
|
},
|
|
56
45
|
"devDependencies": {
|
|
46
|
+
"@testing-library/vue": "^8.1.0",
|
|
57
47
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
58
48
|
"eslint-plugin-vue": "^10.9.2",
|
|
59
|
-
"vue": "^3.5.
|
|
49
|
+
"vue": "^3.5.38"
|
|
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-beta.61'
|
|
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.
|