@tanstack/vue-table 9.0.0-alpha.9 → 9.0.0-beta.10

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 (70) hide show
  1. package/README.md +127 -0
  2. package/dist/FlexRender.cjs +80 -0
  3. package/dist/FlexRender.cjs.map +1 -0
  4. package/dist/FlexRender.d.cts +63 -0
  5. package/dist/FlexRender.d.ts +63 -0
  6. package/dist/FlexRender.js +79 -0
  7. package/dist/FlexRender.js.map +1 -0
  8. package/dist/createTableHook.cjs +193 -0
  9. package/dist/createTableHook.cjs.map +1 -0
  10. package/dist/createTableHook.d.cts +134 -0
  11. package/dist/createTableHook.d.ts +134 -0
  12. package/dist/createTableHook.js +192 -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 +77 -0
  23. package/dist/merge-proxy.cjs.map +1 -0
  24. package/dist/merge-proxy.js +75 -0
  25. package/dist/merge-proxy.js.map +1 -0
  26. package/dist/reactivity.cjs +64 -0
  27. package/dist/reactivity.cjs.map +1 -0
  28. package/dist/reactivity.js +64 -0
  29. package/dist/reactivity.js.map +1 -0
  30. package/dist/static-functions.cjs +9 -0
  31. package/dist/static-functions.d.cts +1 -0
  32. package/dist/static-functions.d.ts +1 -0
  33. package/dist/static-functions.js +3 -0
  34. package/dist/useTable.cjs +75 -0
  35. package/dist/useTable.cjs.map +1 -0
  36. package/dist/useTable.d.cts +42 -0
  37. package/dist/useTable.d.ts +42 -0
  38. package/dist/useTable.js +75 -0
  39. package/dist/useTable.js.map +1 -0
  40. package/package.json +31 -19
  41. package/skills/vue/client-to-server/SKILL.md +360 -0
  42. package/skills/vue/compose-with-tanstack-form/SKILL.md +369 -0
  43. package/skills/vue/compose-with-tanstack-pacer/SKILL.md +321 -0
  44. package/skills/vue/compose-with-tanstack-query/SKILL.md +383 -0
  45. package/skills/vue/compose-with-tanstack-store/SKILL.md +302 -0
  46. package/skills/vue/compose-with-tanstack-virtual/SKILL.md +344 -0
  47. package/skills/vue/getting-started/SKILL.md +415 -0
  48. package/skills/vue/migrate-v8-to-v9/SKILL.md +393 -0
  49. package/skills/vue/production-readiness/SKILL.md +278 -0
  50. package/skills/vue/table-state/SKILL.md +399 -0
  51. package/src/FlexRender.ts +138 -0
  52. package/src/createTableHook.ts +533 -0
  53. package/src/flex-render.ts +1 -0
  54. package/src/index.ts +3 -74
  55. package/src/merge-proxy.ts +66 -15
  56. package/src/reactivity.ts +89 -0
  57. package/src/static-functions.ts +1 -0
  58. package/src/useTable.ts +180 -0
  59. package/dist/cjs/index.cjs +0 -68
  60. package/dist/cjs/index.cjs.map +0 -1
  61. package/dist/cjs/index.d.cts +0 -14
  62. package/dist/cjs/merge-proxy.cjs +0 -61
  63. package/dist/cjs/merge-proxy.cjs.map +0 -1
  64. package/dist/cjs/merge-proxy.d.cts +0 -11
  65. package/dist/esm/index.d.ts +0 -14
  66. package/dist/esm/index.js +0 -63
  67. package/dist/esm/index.js.map +0 -1
  68. package/dist/esm/merge-proxy.d.ts +0 -11
  69. package/dist/esm/merge-proxy.js +0 -61
  70. package/dist/esm/merge-proxy.js.map +0 -1
@@ -3,15 +3,18 @@ function trueFn() {
3
3
  }
4
4
 
5
5
  const $PROXY = Symbol('merge-proxy')
6
+ const $SOURCES = Symbol('merge-proxy-sources')
6
7
 
7
8
  // https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118
8
9
  const propTraps: ProxyHandler<{
9
10
  get: (k: string | number | symbol) => any
10
11
  has: (k: string | number | symbol) => boolean
11
- keys: () => string[]
12
+ keys: () => Array<string>
13
+ sources: Array<any>
12
14
  }> = {
13
15
  get(_, property, receiver) {
14
16
  if (property === $PROXY) return receiver
17
+ if (property === $SOURCES) return _.sources
15
18
  return _.get(property)
16
19
  },
17
20
  has(_, property) {
@@ -36,46 +39,94 @@ const propTraps: ProxyHandler<{
36
39
  }
37
40
 
38
41
  type UnboxLazy<T> = T extends () => infer U ? U : T
39
- type BoxedTupleTypes<T extends any[]> = {
42
+ type BoxedTupleTypes<T extends Array<any>> = {
40
43
  [P in keyof T]: [UnboxLazy<T[P]>]
41
- }[Exclude<keyof T, keyof any[]>]
42
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
43
- k: infer I
44
+ }[Exclude<keyof T, keyof Array<any>>]
45
+ type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends (
46
+ k: infer I,
44
47
  ) => void
45
48
  ? I
46
49
  : never
47
50
  type UnboxIntersection<T> = T extends { 0: infer U } ? U : never
48
- type MergeProxy<T extends any[]> = UnboxIntersection<
51
+ type MergeProxy<T extends Array<any>> = UnboxIntersection<
49
52
  UnionToIntersection<BoxedTupleTypes<T>>
50
53
  >
51
54
 
52
55
  function resolveSource(s: any) {
53
- return 'value' in s ? s.value : s
56
+ return s && typeof s === 'object' && 'value' in s ? s.value : s
54
57
  }
55
58
 
56
- export function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>
59
+ export function mergeProxy<T extends Array<any>>(...sources: T): MergeProxy<T>
57
60
  export function mergeProxy(...sources: any): any {
61
+ const flattenedSources = sources.flatMap((source: any) => {
62
+ if (
63
+ typeof source === 'object' &&
64
+ source !== null &&
65
+ $SOURCES in source &&
66
+ Array.isArray(source[$SOURCES])
67
+ ) {
68
+ return source[$SOURCES]
69
+ }
70
+
71
+ return [source]
72
+ })
73
+
58
74
  return new Proxy(
59
75
  {
76
+ sources: flattenedSources,
60
77
  get(property: string | number | symbol) {
61
- for (let i = sources.length - 1; i >= 0; i--) {
62
- const v = resolveSource(sources[i])[property]
78
+ for (let i = flattenedSources.length - 1; i >= 0; i--) {
79
+ const v = resolveSource(flattenedSources[i])[property]
63
80
  if (v !== undefined) return v
64
81
  }
65
82
  },
66
83
  has(property: string | number | symbol) {
67
- for (let i = sources.length - 1; i >= 0; i--) {
68
- if (property in resolveSource(sources[i])) return true
84
+ for (let i = flattenedSources.length - 1; i >= 0; i--) {
85
+ if (property in resolveSource(flattenedSources[i])) return true
69
86
  }
70
87
  return false
71
88
  },
72
89
  keys() {
73
90
  const keys = []
74
- for (let i = 0; i < sources.length; i++)
75
- keys.push(...Object.keys(resolveSource(sources[i])))
91
+ for (const source of flattenedSources)
92
+ keys.push(...Object.keys(resolveSource(source)))
76
93
  return [...Array.from(new Set(keys))]
77
94
  },
78
95
  },
79
- propTraps
96
+ propTraps,
80
97
  )
81
98
  }
99
+
100
+ /**
101
+ * Merges objects together by eagerly resolving all values into a flat object.
102
+ *
103
+ * Unlike `mergeProxy`, this does not preserve lazy proxy getters. Use this for
104
+ * repeated option update paths so each merge produces a plain object instead
105
+ * of accumulating a longer source list over time.
106
+ */
107
+ export function flatMerge<T>(source: T): T
108
+ export function flatMerge<T, U>(source: T, source1: U): T & U
109
+ export function flatMerge<T, U, V>(source: T, source1: U, source2: V): T & U & V
110
+ export function flatMerge<T, U, V, W>(
111
+ source: T,
112
+ source1: U,
113
+ source2: V,
114
+ source3: W,
115
+ ): T & U & V & W
116
+ export function flatMerge(...sources: any): any {
117
+ const result: Record<PropertyKey, unknown> = {}
118
+
119
+ for (let source of sources) {
120
+ source = resolveSource(source)
121
+ if (!source) continue
122
+
123
+ for (const key of Reflect.ownKeys(source)) {
124
+ const value = (source as Record<PropertyKey, unknown>)[key]
125
+ if (value !== undefined) {
126
+ result[key] = value
127
+ }
128
+ }
129
+ }
130
+
131
+ return result
132
+ }
@@ -0,0 +1,89 @@
1
+ import { computed, shallowRef, watch } from 'vue'
2
+ import { batch } from '@tanstack/store'
3
+ import type {
4
+ TableAtomOptions,
5
+ TableReactivityBindings,
6
+ } from '@tanstack/table-core/reactivity'
7
+ import type {
8
+ Atom,
9
+ Observer,
10
+ ReadonlyAtom,
11
+ Subscription,
12
+ } from '@tanstack/store'
13
+ import type { ComputedRef, ShallowRef } from 'vue'
14
+
15
+ function observerToCallback<T>(
16
+ observerOrNext: Observer<T> | ((value: T) => void),
17
+ ): (value: T) => void {
18
+ return typeof observerOrNext === 'function'
19
+ ? observerOrNext
20
+ : (value) => observerOrNext.next?.(value)
21
+ }
22
+
23
+ function refToReadonlyAtom<T>(
24
+ source: ComputedRef<T> | ShallowRef<T>,
25
+ ): ReadonlyAtom<T> {
26
+ return Object.assign(source, {
27
+ get: () => source.value,
28
+ subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {
29
+ const stop = watch(source, observerToCallback(observerOrNext), {
30
+ flush: 'sync',
31
+ })
32
+ return { unsubscribe: stop }
33
+ }) as ReadonlyAtom<T>['subscribe'],
34
+ })
35
+ }
36
+
37
+ function refToWritableAtom<T>(source: ShallowRef<T>): Atom<T> {
38
+ return Object.assign(source, {
39
+ set: (updater: T | ((prevVal: T) => T)) => {
40
+ source.value =
41
+ typeof updater === 'function'
42
+ ? (updater as (prevVal: T) => T)(source.value)
43
+ : updater
44
+ },
45
+ get: () => source.value,
46
+ subscribe: ((observerOrNext: Observer<T> | ((value: T) => void)) => {
47
+ const stop = watch(source, observerToCallback(observerOrNext), {
48
+ flush: 'sync',
49
+ })
50
+ return { unsubscribe: stop }
51
+ }) as Atom<T>['subscribe'],
52
+ })
53
+ }
54
+
55
+ /**
56
+ * Creates the table-core reactivity bindings used by the Vue adapter.
57
+ *
58
+ * Table state atoms are backed by TanStack Store atoms. The options store stays
59
+ * framework-native because row-model APIs read `table.options` directly during
60
+ * render. Readonly table atoms bridge Store dependency tracking into Vue computed
61
+ * refs.
62
+ */
63
+ export function vueReactivity(): TableReactivityBindings {
64
+ const subscriptions = new Set<Subscription>()
65
+
66
+ return {
67
+ createOptionsStore: true,
68
+ wrapExternalAtoms: true,
69
+ addSubscription: (subscription) => {
70
+ subscriptions.add(subscription)
71
+ },
72
+ unmount: () => {
73
+ subscriptions.forEach((s) => s.unsubscribe())
74
+ subscriptions.clear()
75
+ },
76
+ schedule: (fn) => queueMicrotask(() => fn()),
77
+ createReadonlyAtom: <T>(fn: () => T, _options?: TableAtomOptions<T>) => {
78
+ return refToReadonlyAtom(computed(() => fn()))
79
+ },
80
+ createWritableAtom: <T>(
81
+ value: T,
82
+ _options?: TableAtomOptions<T>,
83
+ ): Atom<T> => {
84
+ return refToWritableAtom(shallowRef(value) as ShallowRef<T>)
85
+ },
86
+ untrack: (fn) => fn(),
87
+ batch,
88
+ }
89
+ }
@@ -0,0 +1 @@
1
+ export * from '@tanstack/table-core/static-functions'
@@ -0,0 +1,180 @@
1
+ import { getCurrentScope, onScopeDispose, unref, watch } from 'vue'
2
+ import { constructTable } from '@tanstack/table-core'
3
+ import { flatMerge, mergeProxy } from './merge-proxy'
4
+ import { vueReactivity } from './reactivity'
5
+ import type {
6
+ RowData,
7
+ Table,
8
+ TableFeatures,
9
+ TableOptions,
10
+ TableState,
11
+ } from '@tanstack/table-core'
12
+ import type { MaybeRef, VNode } from 'vue'
13
+
14
+ export type TableOptionsWithReactiveData<
15
+ TFeatures extends TableFeatures,
16
+ TData extends RowData,
17
+ > = {
18
+ [K in keyof TableOptions<TFeatures, TData>]: K extends 'data'
19
+ ? MaybeRef<ReadonlyArray<TData>>
20
+ : MaybeRef<TableOptions<TFeatures, TData>[K]>
21
+ }
22
+
23
+ function getOptionsWithReactiveValues<
24
+ TFeatures extends TableFeatures,
25
+ TData extends RowData,
26
+ >(options: TableOptionsWithReactiveData<TFeatures, TData>) {
27
+ const resolvedOptions: Record<string, unknown> = {}
28
+
29
+ for (const key of Object.keys(options)) {
30
+ resolvedOptions[key] = unref(
31
+ options[key as keyof TableOptionsWithReactiveData<TFeatures, TData>],
32
+ )
33
+ }
34
+
35
+ return mergeProxy(options, resolvedOptions)
36
+ }
37
+
38
+ function getReactiveOptionDeps<
39
+ TFeatures extends TableFeatures,
40
+ TData extends RowData,
41
+ >(options: TableOptionsWithReactiveData<TFeatures, TData>) {
42
+ return Object.keys(options).map((key) =>
43
+ unref(options[key as keyof TableOptionsWithReactiveData<TFeatures, TData>]),
44
+ )
45
+ }
46
+
47
+ export type VueTable<
48
+ TFeatures extends TableFeatures,
49
+ TData extends RowData,
50
+ > = Omit<Table<TFeatures, TData>, 'store'> & {
51
+ /**
52
+ * @deprecated Prefer `table.atoms.<slice>.get()` for slice snapshots, or
53
+ * `table.Subscribe` for explicit subscriptions. `table.store.state` is a
54
+ * current-value snapshot and is easy to misuse in render code.
55
+ */
56
+ readonly store: Table<TFeatures, TData>['store']
57
+ /** Creates a reactive render boundary. The child function reads the table
58
+ * atoms it needs, so Vue only tracks those atom reads.
59
+ */
60
+ Subscribe: (props: {
61
+ children: (atoms: Table<TFeatures, TData>['atoms']) => VNode | Array<VNode>
62
+ }) => VNode | Array<VNode>
63
+ }
64
+
65
+ /**
66
+ * Creates a Vue table instance backed by Vue-aware TanStack Store atoms.
67
+ *
68
+ * Table options may contain Vue refs or computed values. The adapter unwraps
69
+ * those reactive inputs, watches them with synchronous flushing, and keeps the
70
+ * table options in sync. Use `table.Subscribe` or native Vue computed values
71
+ * around `table.atoms.<slice>.get()` for selected reactive reads.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const table = useTable(
76
+ * {
77
+ * features,
78
+ * columns,
79
+ * data,
80
+ * },
81
+ * )
82
+ * ```
83
+ */
84
+ export function useTable<
85
+ TFeatures extends TableFeatures,
86
+ TData extends RowData,
87
+ >(
88
+ tableOptions:
89
+ | TableOptions<TFeatures, TData>
90
+ | TableOptionsWithReactiveData<TFeatures, TData>,
91
+ ): VueTable<TFeatures, TData> {
92
+ const syncTableOptions = (
93
+ table: Table<TFeatures, TData>,
94
+ options: TableOptionsWithReactiveData<TFeatures, TData>,
95
+ ) => {
96
+ table.setOptions((prev) =>
97
+ flatMerge(prev, getOptionsWithReactiveValues(options)),
98
+ )
99
+ }
100
+
101
+ const reactivity = vueReactivity()
102
+
103
+ const mergedOptions = mergeProxy(tableOptions, {
104
+ features: {
105
+ coreReactivityFeature: reactivity,
106
+ ...(unref(tableOptions.features) ?? {}),
107
+ },
108
+ }) as TableOptionsWithReactiveData<TFeatures, TData>
109
+
110
+ const resolvedOptions = mergeProxy(
111
+ getOptionsWithReactiveValues(mergedOptions),
112
+ {
113
+ // Remove state and onStateChange - store handles it internally
114
+ mergeOptions: (
115
+ defaultOptions: TableOptions<TFeatures, TData>,
116
+ newOptions: Partial<TableOptions<TFeatures, TData>>,
117
+ ) => {
118
+ return flatMerge(defaultOptions, newOptions)
119
+ },
120
+ },
121
+ ) as TableOptions<TFeatures, TData>
122
+
123
+ const coreTable = constructTable(resolvedOptions)
124
+ const table = coreTable as unknown as VueTable<TFeatures, TData>
125
+
126
+ if (getCurrentScope()) {
127
+ onScopeDispose(() => reactivity.unmount?.())
128
+ }
129
+
130
+ watch(
131
+ () => getReactiveOptionDeps(mergedOptions),
132
+ () => {
133
+ syncTableOptions(coreTable, mergedOptions)
134
+ },
135
+ { immediate: true },
136
+ )
137
+
138
+ watch(
139
+ () => {
140
+ const controlledState = unref(tableOptions.state) as
141
+ | Record<string, unknown>
142
+ | undefined
143
+ const controlledAtoms = unref(tableOptions.atoms) as
144
+ | Record<string, unknown>
145
+ | undefined
146
+
147
+ if (!controlledState) {
148
+ return []
149
+ }
150
+
151
+ const controlledValues: Array<unknown> = []
152
+
153
+ for (const key of Object.keys(table.initialState)) {
154
+ if (!(key in controlledState) || controlledAtoms?.[key] !== undefined) {
155
+ continue
156
+ }
157
+
158
+ // Reading only controlled state slices here lets Vue subscribe to
159
+ // getters/computed values that are passed through `options.state`.
160
+ controlledValues.push(controlledState[key])
161
+ }
162
+
163
+ return controlledValues
164
+ },
165
+ (controlledValues) => {
166
+ if (controlledValues.length > 0) {
167
+ syncTableOptions(coreTable, mergedOptions)
168
+ }
169
+ },
170
+ { immediate: true },
171
+ )
172
+
173
+ table.Subscribe = (props: {
174
+ children: (atoms: Table<TFeatures, TData>['atoms']) => VNode | Array<VNode>
175
+ }) => {
176
+ return props.children(table.atoms)
177
+ }
178
+
179
+ return table
180
+ }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tableCore = require("@tanstack/table-core");
4
- const vue = require("vue");
5
- const mergeProxy = require("./merge-proxy.cjs");
6
- const FlexRender = vue.defineComponent({
7
- props: ["render", "props"],
8
- setup: (props) => {
9
- return () => {
10
- if (typeof props.render === "function" || typeof props.render === "object") {
11
- return vue.h(props.render, props.props);
12
- }
13
- return props.render;
14
- };
15
- }
16
- });
17
- function useTable(options) {
18
- const resolvedOptions = mergeProxy.mergeProxy(
19
- {
20
- state: {},
21
- // Dummy state
22
- onStateChange: () => {
23
- },
24
- // noop
25
- renderFallbackValue: null,
26
- mergeOptions(defaultOptions, options2) {
27
- return mergeProxy.mergeProxy(defaultOptions, options2);
28
- }
29
- },
30
- options
31
- );
32
- const table = tableCore._createTable(resolvedOptions);
33
- const state = vue.ref(table.initialState);
34
- vue.watchEffect(() => {
35
- table.setOptions((prev) => {
36
- const stateProxy = new Proxy({}, {
37
- get: (_, prop) => state.value[prop]
38
- });
39
- return mergeProxy.mergeProxy(prev, options, {
40
- // merge the initialState and `options.state`
41
- // create a new proxy on each `setOptions` call
42
- // and get the value from state on each property access
43
- state: mergeProxy.mergeProxy(stateProxy, options.state ?? {}),
44
- // Similarly, we'll maintain both our internal state and any user-provided
45
- // state.
46
- onStateChange: (updater) => {
47
- var _a;
48
- if (updater instanceof Function) {
49
- state.value = updater(state.value);
50
- } else {
51
- state.value = updater;
52
- }
53
- (_a = options.onStateChange) == null ? void 0 : _a.call(options, updater);
54
- }
55
- });
56
- });
57
- });
58
- return table;
59
- }
60
- exports.FlexRender = FlexRender;
61
- exports.useTable = useTable;
62
- Object.keys(tableCore).forEach((k) => {
63
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
64
- enumerable: true,
65
- get: () => tableCore[k]
66
- });
67
- });
68
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
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)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["defineComponent","h","mergeProxy","options","_createTable","ref","watchEffect"],"mappings":";;;;;AAWO,MAAM,aAAaA,IAAAA,gBAAgB;AAAA,EACxC,OAAO,C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
- export * from '@tanstack/table-core';
4
- export declare const FlexRender: import('vue').DefineComponent<Readonly<{
5
- props?: any;
6
- render?: any;
7
- }>, () => any, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<Readonly<{
8
- props?: any;
9
- render?: any;
10
- }>>>, {
11
- readonly props?: any;
12
- readonly render?: any;
13
- }, {}>;
14
- export declare function useTable<TData extends RowData>(options: TableOptions<TData>): import('@tanstack/table-core').Table<TData>;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function trueFn() {
4
- return true;
5
- }
6
- const $PROXY = Symbol("merge-proxy");
7
- const propTraps = {
8
- get(_, property, receiver) {
9
- if (property === $PROXY) return receiver;
10
- return _.get(property);
11
- },
12
- has(_, property) {
13
- return _.has(property);
14
- },
15
- set: trueFn,
16
- deleteProperty: trueFn,
17
- getOwnPropertyDescriptor(_, property) {
18
- return {
19
- configurable: true,
20
- enumerable: true,
21
- get() {
22
- return _.get(property);
23
- },
24
- set: trueFn,
25
- deleteProperty: trueFn
26
- };
27
- },
28
- ownKeys(_) {
29
- return _.keys();
30
- }
31
- };
32
- function resolveSource(s) {
33
- return "value" in s ? s.value : s;
34
- }
35
- function mergeProxy(...sources) {
36
- return new Proxy(
37
- {
38
- get(property) {
39
- for (let i = sources.length - 1; i >= 0; i--) {
40
- const v = resolveSource(sources[i])[property];
41
- if (v !== void 0) return v;
42
- }
43
- },
44
- has(property) {
45
- for (let i = sources.length - 1; i >= 0; i--) {
46
- if (property in resolveSource(sources[i])) return true;
47
- }
48
- return false;
49
- },
50
- keys() {
51
- const keys = [];
52
- for (let i = 0; i < sources.length; i++)
53
- keys.push(...Object.keys(resolveSource(sources[i])));
54
- return [...Array.from(new Set(keys))];
55
- }
56
- },
57
- propTraps
58
- );
59
- }
60
- exports.mergeProxy = mergeProxy;
61
- //# sourceMappingURL=merge-proxy.cjs.map
@@ -1 +0,0 @@
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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CAAC,CAAC,CAAC;AAC9C,eAAA,CAAC,GAAG,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC;AAAA,MACtC;AAAA,IACF;AAAA,IACA;AAAA,EAAA;AAEJ;;"}
@@ -1,11 +0,0 @@
1
- type UnboxLazy<T> = T extends () => infer U ? U : T;
2
- type BoxedTupleTypes<T extends any[]> = {
3
- [P in keyof T]: [UnboxLazy<T[P]>];
4
- }[Exclude<keyof T, keyof any[]>];
5
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
6
- type UnboxIntersection<T> = T extends {
7
- 0: infer U;
8
- } ? U : never;
9
- type MergeProxy<T extends any[]> = UnboxIntersection<UnionToIntersection<BoxedTupleTypes<T>>>;
10
- export declare function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>;
11
- export {};
@@ -1,14 +0,0 @@
1
- import { TableOptions, RowData } from '@tanstack/table-core';
2
-
3
- export * from '@tanstack/table-core';
4
- export declare const FlexRender: import('vue').DefineComponent<Readonly<{
5
- props?: any;
6
- render?: any;
7
- }>, () => any, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<Readonly<{
8
- props?: any;
9
- render?: any;
10
- }>>>, {
11
- readonly props?: any;
12
- readonly render?: any;
13
- }, {}>;
14
- export declare function useTable<TData extends RowData>(options: TableOptions<TData>): import('@tanstack/table-core').Table<TData>;
package/dist/esm/index.js DELETED
@@ -1,63 +0,0 @@
1
- import { _createTable } from "@tanstack/table-core";
2
- export * from "@tanstack/table-core";
3
- import { defineComponent, h, ref, watchEffect } from "vue";
4
- import { mergeProxy } from "./merge-proxy.js";
5
- const FlexRender = defineComponent({
6
- props: ["render", "props"],
7
- setup: (props) => {
8
- return () => {
9
- if (typeof props.render === "function" || typeof props.render === "object") {
10
- return h(props.render, props.props);
11
- }
12
- return props.render;
13
- };
14
- }
15
- });
16
- function useTable(options) {
17
- const resolvedOptions = mergeProxy(
18
- {
19
- state: {},
20
- // Dummy state
21
- onStateChange: () => {
22
- },
23
- // noop
24
- renderFallbackValue: null,
25
- mergeOptions(defaultOptions, options2) {
26
- return mergeProxy(defaultOptions, options2);
27
- }
28
- },
29
- options
30
- );
31
- const table = _createTable(resolvedOptions);
32
- const state = ref(table.initialState);
33
- watchEffect(() => {
34
- table.setOptions((prev) => {
35
- const stateProxy = new Proxy({}, {
36
- get: (_, prop) => state.value[prop]
37
- });
38
- return mergeProxy(prev, options, {
39
- // merge the initialState and `options.state`
40
- // create a new proxy on each `setOptions` call
41
- // and get the value from state on each property access
42
- state: mergeProxy(stateProxy, options.state ?? {}),
43
- // Similarly, we'll maintain both our internal state and any user-provided
44
- // state.
45
- onStateChange: (updater) => {
46
- var _a;
47
- if (updater instanceof Function) {
48
- state.value = updater(state.value);
49
- } else {
50
- state.value = updater;
51
- }
52
- (_a = options.onStateChange) == null ? void 0 : _a.call(options, updater);
53
- }
54
- });
55
- });
56
- });
57
- return table;
58
- }
59
- export {
60
- FlexRender,
61
- useTable
62
- };
63
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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;"}
@@ -1,11 +0,0 @@
1
- type UnboxLazy<T> = T extends () => infer U ? U : T;
2
- type BoxedTupleTypes<T extends any[]> = {
3
- [P in keyof T]: [UnboxLazy<T[P]>];
4
- }[Exclude<keyof T, keyof any[]>];
5
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
6
- type UnboxIntersection<T> = T extends {
7
- 0: infer U;
8
- } ? U : never;
9
- type MergeProxy<T extends any[]> = UnboxIntersection<UnionToIntersection<BoxedTupleTypes<T>>>;
10
- export declare function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>;
11
- export {};