@tanstack/vue-table 9.0.0-alpha.4 → 9.0.0-alpha.8
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/dist/cjs/index.cjs +7 -8
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/merge-proxy.cjs +3 -6
- package/dist/cjs/merge-proxy.cjs.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/merge-proxy.js +3 -6
- package/dist/esm/merge-proxy.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +3 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ const FlexRender = vue.defineComponent({
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
function
|
|
17
|
+
function useTable(options) {
|
|
18
18
|
const resolvedOptions = mergeProxy.mergeProxy(
|
|
19
19
|
{
|
|
20
20
|
state: {},
|
|
@@ -29,7 +29,7 @@ function useVueTable(options) {
|
|
|
29
29
|
},
|
|
30
30
|
options
|
|
31
31
|
);
|
|
32
|
-
const table = tableCore.
|
|
32
|
+
const table = tableCore._createTable(resolvedOptions);
|
|
33
33
|
const state = vue.ref(table.initialState);
|
|
34
34
|
vue.watchEffect(() => {
|
|
35
35
|
table.setOptions((prev) => {
|
|
@@ -58,12 +58,11 @@ function useVueTable(options) {
|
|
|
58
58
|
return table;
|
|
59
59
|
}
|
|
60
60
|
exports.FlexRender = FlexRender;
|
|
61
|
-
exports.
|
|
61
|
+
exports.useTable = useTable;
|
|
62
62
|
Object.keys(tableCore).forEach((k) => {
|
|
63
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
63
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: () => tableCore[k]
|
|
66
|
+
});
|
|
68
67
|
});
|
|
69
68
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import {\n TableOptions,\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import {\n TableOptions,\n _createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useTable<TData extends RowData>(options: TableOptions<TData>) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = _createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)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AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AAEM,SAAA;AACT;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -11,4 +11,4 @@ export declare const FlexRender: import('vue').DefineComponent<Readonly<{
|
|
|
11
11
|
readonly props?: any;
|
|
12
12
|
readonly render?: any;
|
|
13
13
|
}, {}>;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function useTable<TData extends RowData>(options: TableOptions<TData>): import('@tanstack/table-core').Table<TData>;
|
package/dist/cjs/merge-proxy.cjs
CHANGED
|
@@ -6,8 +6,7 @@ function trueFn() {
|
|
|
6
6
|
const $PROXY = Symbol("merge-proxy");
|
|
7
7
|
const propTraps = {
|
|
8
8
|
get(_, property, receiver) {
|
|
9
|
-
if (property === $PROXY)
|
|
10
|
-
return receiver;
|
|
9
|
+
if (property === $PROXY) return receiver;
|
|
11
10
|
return _.get(property);
|
|
12
11
|
},
|
|
13
12
|
has(_, property) {
|
|
@@ -39,14 +38,12 @@ function mergeProxy(...sources) {
|
|
|
39
38
|
get(property) {
|
|
40
39
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
41
40
|
const v = resolveSource(sources[i])[property];
|
|
42
|
-
if (v !== void 0)
|
|
43
|
-
return v;
|
|
41
|
+
if (v !== void 0) return v;
|
|
44
42
|
}
|
|
45
43
|
},
|
|
46
44
|
has(property) {
|
|
47
45
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
48
|
-
if (property in resolveSource(sources[i]))
|
|
49
|
-
return true;
|
|
46
|
+
if (property in resolveSource(sources[i])) return true;
|
|
50
47
|
}
|
|
51
48
|
return false;
|
|
52
49
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-proxy.cjs","sources":["../../src/merge-proxy.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nconst $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...Array.from(new Set(keys))]\n },\n },\n propTraps\n )\n}\n"],"names":[],"mappings":";;AAAA,SAAS,SAAS;AACT,SAAA;AACT;AAEA,MAAM,SAAS,OAAO,aAAa;AAGnC,MAAM,YAID;AAAA,EACH,IAAI,GAAG,UAAU,UAAU;
|
|
1
|
+
{"version":3,"file":"merge-proxy.cjs","sources":["../../src/merge-proxy.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nconst $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...Array.from(new Set(keys))]\n },\n },\n propTraps\n )\n}\n"],"names":[],"mapp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M,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC;AAAA,MACtC;AAAA,IACF;AAAA,IACA;AAAA,EAAA;AAEJ;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export declare const FlexRender: import('vue').DefineComponent<Readonly<{
|
|
|
11
11
|
readonly props?: any;
|
|
12
12
|
readonly render?: any;
|
|
13
13
|
}, {}>;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function useTable<TData extends RowData>(options: TableOptions<TData>): import('@tanstack/table-core').Table<TData>;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _createTable } from "@tanstack/table-core";
|
|
2
2
|
export * from "@tanstack/table-core";
|
|
3
3
|
import { defineComponent, h, ref, watchEffect } from "vue";
|
|
4
4
|
import { mergeProxy } from "./merge-proxy.js";
|
|
@@ -13,7 +13,7 @@ const FlexRender = defineComponent({
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
function
|
|
16
|
+
function useTable(options) {
|
|
17
17
|
const resolvedOptions = mergeProxy(
|
|
18
18
|
{
|
|
19
19
|
state: {},
|
|
@@ -28,7 +28,7 @@ function useVueTable(options) {
|
|
|
28
28
|
},
|
|
29
29
|
options
|
|
30
30
|
);
|
|
31
|
-
const table =
|
|
31
|
+
const table = _createTable(resolvedOptions);
|
|
32
32
|
const state = ref(table.initialState);
|
|
33
33
|
watchEffect(() => {
|
|
34
34
|
table.setOptions((prev) => {
|
|
@@ -58,6 +58,6 @@ function useVueTable(options) {
|
|
|
58
58
|
}
|
|
59
59
|
export {
|
|
60
60
|
FlexRender,
|
|
61
|
-
|
|
61
|
+
useTable
|
|
62
62
|
};
|
|
63
63
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n TableOptions,\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n TableOptions,\n _createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useTable<TData extends RowData>(options: TableOptions<TData>) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = _createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["options"],"mappings":";;;;AAWO,MAAM,aAAa,gBAAgB;AAAA,EACxC,OAAO,CAAC,UAAU,OAAO;AAAA,EACzB,OAAO,CAAC,UAAuC;AAC7C,WAAO,MAAM;AACX,UACE,OAAO,MAAM,WAAW,cACxB,OAAO,MAAM,WAAW,UACxB;AACA,eAAO,EAAE,MAAM,QAAQ,MAAM,KAAK;AAAA,MACpC;AAEA,aAAO,MAAM;AAAA,IAAA;AAAA,EAEjB;AACF,CAAC;AAEM,SAAS,SAAgC,SAA8B;AAC5E,QAAM,kBAA+C;AAAA,IACnD;AAAA,MACE,OAAO,CAAC;AAAA;AAAA,MACR,eAAe,MAAM;AAAA,MAAC;AAAA;AAAA,MACtB,qBAAqB;AAAA,MACrB,aACE,gBACAA,UACA;AACO,eAAA,WAAW,gBAAgBA,QAAO;AAAA,MAC3C;AAAA,IACF;AAAA,IACA;AAAA,EAAA;AAGI,QAAA,QAAQ,aAAoB,eAAe;AAE3C,QAAA,QAAQ,IAAI,MAAM,YAAY;AAEpC,cAAY,MAAM;AAChB,UAAM,WAAW,CAAQ,SAAA;AACvB,YAAM,aAAa,IAAI,MAAM,IAA0B;AAAA,QACrD,KAAK,CAAC,GAAG,SAAS,MAAM,MAAM,IAAgC;AAAA,MAAA,CAC/D;AAEM,aAAA,WAAW,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA,QAI/B,OAAO,WAAW,YAAY,QAAQ,SAAS,CAAA,CAAE;AAAA;AAAA;AAAA,QAGjD,eAAe,CAAC,YAAiB;;AAC/B,cAAI,mBAAmB,UAAU;AACzB,kBAAA,QAAQ,QAAQ,MAAM,KAAK;AAAA,UAAA,OAC5B;AACL,kBAAM,QAAQ;AAAA,UAChB;AAEA,wBAAQ,kBAAR,iCAAwB;AAAA,QAC1B;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA,CACF;AAEM,SAAA;AACT;"}
|
package/dist/esm/merge-proxy.js
CHANGED
|
@@ -4,8 +4,7 @@ function trueFn() {
|
|
|
4
4
|
const $PROXY = Symbol("merge-proxy");
|
|
5
5
|
const propTraps = {
|
|
6
6
|
get(_, property, receiver) {
|
|
7
|
-
if (property === $PROXY)
|
|
8
|
-
return receiver;
|
|
7
|
+
if (property === $PROXY) return receiver;
|
|
9
8
|
return _.get(property);
|
|
10
9
|
},
|
|
11
10
|
has(_, property) {
|
|
@@ -37,14 +36,12 @@ function mergeProxy(...sources) {
|
|
|
37
36
|
get(property) {
|
|
38
37
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
39
38
|
const v = resolveSource(sources[i])[property];
|
|
40
|
-
if (v !== void 0)
|
|
41
|
-
return v;
|
|
39
|
+
if (v !== void 0) return v;
|
|
42
40
|
}
|
|
43
41
|
},
|
|
44
42
|
has(property) {
|
|
45
43
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
46
|
-
if (property in resolveSource(sources[i]))
|
|
47
|
-
return true;
|
|
44
|
+
if (property in resolveSource(sources[i])) return true;
|
|
48
45
|
}
|
|
49
46
|
return false;
|
|
50
47
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-proxy.js","sources":["../../src/merge-proxy.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nconst $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...Array.from(new Set(keys))]\n },\n },\n propTraps\n )\n}\n"],"names":[],"mappings":"AAAA,SAAS,SAAS;AACT,SAAA;AACT;AAEA,MAAM,SAAS,OAAO,aAAa;AAGnC,MAAM,YAID;AAAA,EACH,IAAI,GAAG,UAAU,UAAU;
|
|
1
|
+
{"version":3,"file":"merge-proxy.js","sources":["../../src/merge-proxy.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nconst $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...Array.from(new Set(keys))]\n },\n },\n propTraps\n )\n}\n"],"names":[],"mappings":"AAAA,SAAS,SAAS;AACT,SAAA;AACT;AAEA,MAAM,SAAS,OAAO,aAAa;AAGnC,MAAM,YAID;AAAA,EACH,IAAI,GAAG,UAAU,UAAU;AACrB,QAAA,aAAa,OAAe,QAAA;AACzB,WAAA,EAAE,IAAI,QAAQ;AAAA,EACvB;AAAA,EACA,IAAI,GAAG,UAAU;AACR,WAAA,EAAE,IAAI,QAAQ;AAAA,EACvB;AAAA,EACA,KAAK;AAAA,EACL,gBAAgB;AAAA,EAChB,yBAAyB,GAAG,UAAU;AAC7B,WAAA;AAAA,MACL,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,MAAM;AACG,eAAA,EAAE,IAAI,QAAQ;AAAA,MACvB;AAAA,MACA,KAAK;AAAA,MACL,gBAAgB;AAAA,IAAA;AAAA,EAEpB;AAAA,EACA,QAAQ,GAAG;AACT,WAAO,EAAE;EACX;AACF;AAgBA,SAAS,cAAc,GAAQ;AACtB,SAAA,WAAW,IAAI,EAAE,QAAQ;AAClC;AAGO,SAAS,cAAc,SAAmB;AAC/C,SAAO,IAAI;AAAA,IACT;AAAA,MACE,IAAI,UAAoC;AACtC,iBAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AAC5C,gBAAM,IAAI,cAAc,QAAQ,CAAC,CAAC,EAAE,QAAQ;AACxC,cAAA,MAAM,OAAkB,QAAA;AAAA,QAC9B;AAAA,MACF;AAAA,MACA,IAAI,UAAoC;AACtC,iBAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AAC5C,cAAI,YAAY,cAAc,QAAQ,CAAC,CAAC,EAAU,QAAA;AAAA,QACpD;AACO,eAAA;AAAA,MACT;AAAA,MACA,OAAO;AACL,cAAM,OAAO,CAAA;AACb,iBAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ;AAC7B,eAAA,KAAK,GAAG,OAAO,KAAK,cAAc,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC9C,eAAA,CAAC,GAAG,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC;AAAA,MACtC;AAAA,IACF;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-table",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.8",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for Vue.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"src"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@tanstack/table-core": "9.0.0-alpha.
|
|
49
|
+
"@tanstack/table-core": "9.0.0-alpha.8"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@vitejs/plugin-vue": "^5.0.4",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TableOptions,
|
|
3
|
-
|
|
3
|
+
_createTable,
|
|
4
4
|
TableOptionsResolved,
|
|
5
5
|
RowData,
|
|
6
6
|
} from '@tanstack/table-core'
|
|
@@ -25,9 +25,7 @@ export const FlexRender = defineComponent({
|
|
|
25
25
|
},
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
export function
|
|
29
|
-
options: TableOptions<TData>
|
|
30
|
-
) {
|
|
28
|
+
export function useTable<TData extends RowData>(options: TableOptions<TData>) {
|
|
31
29
|
const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(
|
|
32
30
|
{
|
|
33
31
|
state: {}, // Dummy state
|
|
@@ -43,7 +41,7 @@ export function useVueTable<TData extends RowData>(
|
|
|
43
41
|
options
|
|
44
42
|
)
|
|
45
43
|
|
|
46
|
-
const table =
|
|
44
|
+
const table = _createTable<TData>(resolvedOptions)
|
|
47
45
|
// can't use `reactive` because update needs to be immutable
|
|
48
46
|
const state = ref(table.initialState)
|
|
49
47
|
|