@tanstack/vue-table 9.0.0-alpha.4 → 9.0.0-alpha.40
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 +117 -0
- package/dist/FlexRender.cjs +80 -0
- package/dist/FlexRender.cjs.map +1 -0
- package/dist/FlexRender.d.cts +46 -0
- package/dist/FlexRender.d.ts +46 -0
- package/dist/FlexRender.js +79 -0
- package/dist/FlexRender.js.map +1 -0
- package/dist/createTableHook.cjs +216 -0
- package/dist/createTableHook.cjs.map +1 -0
- package/dist/createTableHook.d.cts +121 -0
- package/dist/createTableHook.d.ts +121 -0
- package/dist/createTableHook.js +215 -0
- package/dist/createTableHook.js.map +1 -0
- package/dist/flex-render.cjs +5 -0
- package/dist/flex-render.d.cts +2 -0
- package/dist/flex-render.d.ts +2 -0
- package/dist/flex-render.js +3 -0
- package/dist/index.cjs +17 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/merge-proxy.cjs +64 -0
- package/dist/merge-proxy.cjs.map +1 -0
- package/dist/merge-proxy.js +63 -0
- package/dist/merge-proxy.js.map +1 -0
- package/dist/static-functions.cjs +9 -0
- package/dist/static-functions.d.cts +1 -0
- package/dist/static-functions.d.ts +1 -0
- package/dist/static-functions.js +3 -0
- package/dist/useTable.cjs +73 -0
- package/dist/useTable.cjs.map +1 -0
- package/dist/useTable.d.cts +42 -0
- package/dist/useTable.d.ts +42 -0
- package/dist/useTable.js +73 -0
- package/dist/useTable.js.map +1 -0
- package/package.json +27 -17
- package/src/FlexRender.ts +123 -0
- package/src/createTableHook.ts +576 -0
- package/src/flex-render.ts +1 -0
- package/src/index.ts +3 -76
- package/src/merge-proxy.ts +31 -14
- package/src/static-functions.ts +1 -0
- package/src/useTable.ts +240 -0
- package/dist/cjs/index.cjs +0 -69
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -14
- package/dist/cjs/merge-proxy.cjs +0 -64
- package/dist/cjs/merge-proxy.cjs.map +0 -1
- package/dist/cjs/merge-proxy.d.cts +0 -11
- package/dist/esm/index.d.ts +0 -14
- package/dist/esm/index.js +0 -63
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/merge-proxy.d.ts +0 -11
- package/dist/esm/merge-proxy.js +0 -64
- package/dist/esm/merge-proxy.js.map +0 -1
package/src/merge-proxy.ts
CHANGED
|
@@ -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,16 +39,16 @@ 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<
|
|
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
|
|
51
|
+
type MergeProxy<T extends Array<any>> = UnboxIntersection<
|
|
49
52
|
UnionToIntersection<BoxedTupleTypes<T>>
|
|
50
53
|
>
|
|
51
54
|
|
|
@@ -53,29 +56,43 @@ function resolveSource(s: any) {
|
|
|
53
56
|
return 'value' in s ? s.value : s
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
export function mergeProxy<T extends any
|
|
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 =
|
|
62
|
-
const v = resolveSource(
|
|
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 =
|
|
68
|
-
if (property in resolveSource(
|
|
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 (
|
|
75
|
-
keys.push(...Object.keys(resolveSource(
|
|
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
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@tanstack/table-core/static-functions'
|
package/src/useTable.ts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { isRef, ref, unref, watch, watchEffect } from 'vue'
|
|
2
|
+
import {
|
|
3
|
+
constructReactivityFeature,
|
|
4
|
+
constructTable,
|
|
5
|
+
} from '@tanstack/table-core'
|
|
6
|
+
import { shallow, useSelector } from '@tanstack/vue-store'
|
|
7
|
+
import { mergeProxy } from './merge-proxy'
|
|
8
|
+
import type { Atom, ReadonlyAtom } from '@tanstack/vue-store'
|
|
9
|
+
import type {
|
|
10
|
+
NoInfer,
|
|
11
|
+
RowData,
|
|
12
|
+
Table,
|
|
13
|
+
TableFeatures,
|
|
14
|
+
TableOptions,
|
|
15
|
+
TableState,
|
|
16
|
+
} from '@tanstack/table-core'
|
|
17
|
+
import type { MaybeRef, VNode } from 'vue'
|
|
18
|
+
|
|
19
|
+
export type TableOptionsWithReactiveData<
|
|
20
|
+
TFeatures extends TableFeatures,
|
|
21
|
+
TData extends RowData,
|
|
22
|
+
> = {
|
|
23
|
+
[K in keyof TableOptions<TFeatures, TData>]: K extends 'data'
|
|
24
|
+
? MaybeRef<ReadonlyArray<TData>>
|
|
25
|
+
: MaybeRef<TableOptions<TFeatures, TData>[K]>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getOptionsWithReactiveValues<
|
|
29
|
+
TFeatures extends TableFeatures,
|
|
30
|
+
TData extends RowData,
|
|
31
|
+
>(options: TableOptionsWithReactiveData<TFeatures, TData>) {
|
|
32
|
+
const resolvedOptions: Record<string, unknown> = {}
|
|
33
|
+
|
|
34
|
+
for (const key of Object.keys(options)) {
|
|
35
|
+
resolvedOptions[key] = unref(
|
|
36
|
+
options[key as keyof TableOptionsWithReactiveData<TFeatures, TData>],
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return mergeProxy(options, resolvedOptions)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getReactiveOptionDeps<
|
|
44
|
+
TFeatures extends TableFeatures,
|
|
45
|
+
TData extends RowData,
|
|
46
|
+
>(options: TableOptionsWithReactiveData<TFeatures, TData>) {
|
|
47
|
+
return Object.keys(options).map((key) =>
|
|
48
|
+
unref(options[key as keyof TableOptionsWithReactiveData<TFeatures, TData>]),
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type VueTable<
|
|
53
|
+
TFeatures extends TableFeatures,
|
|
54
|
+
TData extends RowData,
|
|
55
|
+
TSelected = {},
|
|
56
|
+
> = Table<TFeatures, TData> & {
|
|
57
|
+
/**
|
|
58
|
+
* Store mode: `selector` required. Source mode: pass `source` (atom or store); omit
|
|
59
|
+
* `selector` for the whole value (identity), or pass `selector` to project. Split
|
|
60
|
+
* overloads so source-only infers `TSourceValue` for `children` (see React `Subscribe`).
|
|
61
|
+
*/
|
|
62
|
+
Subscribe: {
|
|
63
|
+
<TSourceValue>(props: {
|
|
64
|
+
source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>
|
|
65
|
+
selector?: undefined
|
|
66
|
+
children:
|
|
67
|
+
| ((state: Readonly<TSourceValue>) => VNode | Array<VNode>)
|
|
68
|
+
| VNode
|
|
69
|
+
| Array<VNode>
|
|
70
|
+
}): VNode | Array<VNode>
|
|
71
|
+
<TSourceValue, TSubSelected>(props: {
|
|
72
|
+
source: Atom<TSourceValue> | ReadonlyAtom<TSourceValue>
|
|
73
|
+
selector: (state: TSourceValue) => TSubSelected
|
|
74
|
+
children:
|
|
75
|
+
| ((state: Readonly<TSubSelected>) => VNode | Array<VNode>)
|
|
76
|
+
| VNode
|
|
77
|
+
| Array<VNode>
|
|
78
|
+
}): VNode | Array<VNode>
|
|
79
|
+
<TSubSelected>(props: {
|
|
80
|
+
selector: (state: NoInfer<TableState<TFeatures>>) => TSubSelected
|
|
81
|
+
children:
|
|
82
|
+
| ((state: Readonly<TSubSelected>) => VNode | Array<VNode>)
|
|
83
|
+
| VNode
|
|
84
|
+
| Array<VNode>
|
|
85
|
+
}): VNode | Array<VNode>
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The selected state of the table. This state may not match the structure of `table.store.state` because it is selected by the `selector` function that you pass as the 2nd argument to `useTable`.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state
|
|
92
|
+
*
|
|
93
|
+
* console.log(table.state.globalFilter)
|
|
94
|
+
*/
|
|
95
|
+
readonly state: Readonly<TSelected>
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function useTable<
|
|
99
|
+
TFeatures extends TableFeatures,
|
|
100
|
+
TData extends RowData,
|
|
101
|
+
TSelected = {},
|
|
102
|
+
>(
|
|
103
|
+
tableOptions:
|
|
104
|
+
| TableOptions<TFeatures, TData>
|
|
105
|
+
| TableOptionsWithReactiveData<TFeatures, TData>,
|
|
106
|
+
selector: (state: TableState<TFeatures>) => TSelected = () =>
|
|
107
|
+
({}) as TSelected,
|
|
108
|
+
): VueTable<TFeatures, TData, TSelected> {
|
|
109
|
+
const notifier = ref<number>(0)
|
|
110
|
+
|
|
111
|
+
const syncTableOptions = (
|
|
112
|
+
table: Table<TFeatures, TData>,
|
|
113
|
+
options: TableOptionsWithReactiveData<TFeatures, TData>,
|
|
114
|
+
) => {
|
|
115
|
+
table.setOptions(
|
|
116
|
+
() =>
|
|
117
|
+
getOptionsWithReactiveValues(options) as TableOptions<TFeatures, TData>,
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const vueReactivityFeature = constructReactivityFeature({
|
|
122
|
+
stateNotifier: () => notifier.value,
|
|
123
|
+
optionsNotifier: () => notifier.value,
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const mergedOptions = {
|
|
127
|
+
...tableOptions,
|
|
128
|
+
_features: {
|
|
129
|
+
...tableOptions._features,
|
|
130
|
+
vueReactivityFeature,
|
|
131
|
+
},
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const resolvedOptions = mergeProxy(
|
|
135
|
+
getOptionsWithReactiveValues(
|
|
136
|
+
mergedOptions as TableOptionsWithReactiveData<TFeatures, TData>,
|
|
137
|
+
),
|
|
138
|
+
{
|
|
139
|
+
// Remove state and onStateChange - store handles it internally
|
|
140
|
+
mergeOptions: (
|
|
141
|
+
defaultOptions: TableOptions<TFeatures, TData>,
|
|
142
|
+
newOptions: Partial<TableOptions<TFeatures, TData>>,
|
|
143
|
+
) => {
|
|
144
|
+
return mergeProxy(defaultOptions, newOptions)
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
) as TableOptions<TFeatures, TData>
|
|
148
|
+
|
|
149
|
+
const table = constructTable(resolvedOptions) as VueTable<
|
|
150
|
+
TFeatures,
|
|
151
|
+
TData,
|
|
152
|
+
TSelected
|
|
153
|
+
>
|
|
154
|
+
|
|
155
|
+
const allState = useSelector(table.store, (state) => state)
|
|
156
|
+
const allOptions = useSelector(table.optionsStore, (state) => state)
|
|
157
|
+
|
|
158
|
+
watchEffect(() => {
|
|
159
|
+
allState.value
|
|
160
|
+
allOptions.value
|
|
161
|
+
notifier.value++
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
watch(
|
|
165
|
+
() =>
|
|
166
|
+
getReactiveOptionDeps(
|
|
167
|
+
mergedOptions as TableOptionsWithReactiveData<TFeatures, TData>,
|
|
168
|
+
),
|
|
169
|
+
() => {
|
|
170
|
+
syncTableOptions(table, mergedOptions)
|
|
171
|
+
},
|
|
172
|
+
{ immediate: true },
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
watch(
|
|
176
|
+
() => {
|
|
177
|
+
const controlledState = unref(tableOptions.state) as
|
|
178
|
+
| Record<string, unknown>
|
|
179
|
+
| undefined
|
|
180
|
+
const controlledAtoms = unref(tableOptions.atoms) as
|
|
181
|
+
| Record<string, unknown>
|
|
182
|
+
| undefined
|
|
183
|
+
|
|
184
|
+
if (!controlledState) {
|
|
185
|
+
return []
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const controlledValues: Array<unknown> = []
|
|
189
|
+
|
|
190
|
+
for (const key of Object.keys(table.initialState)) {
|
|
191
|
+
if (!(key in controlledState) || controlledAtoms?.[key] !== undefined) {
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Reading only controlled state slices here lets Vue subscribe to
|
|
196
|
+
// getters/computed values that are passed through `options.state`.
|
|
197
|
+
controlledValues.push(controlledState[key])
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return controlledValues
|
|
201
|
+
},
|
|
202
|
+
(controlledValues) => {
|
|
203
|
+
if (controlledValues.length > 0) {
|
|
204
|
+
syncTableOptions(table, mergedOptions)
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{ immediate: true },
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
table.Subscribe = ((props: {
|
|
211
|
+
source?: Atom<unknown> | ReadonlyAtom<unknown>
|
|
212
|
+
selector?: ((state: unknown) => unknown) | undefined
|
|
213
|
+
children:
|
|
214
|
+
| ((state: Readonly<unknown>) => VNode | Array<VNode>)
|
|
215
|
+
| VNode
|
|
216
|
+
| Array<VNode>
|
|
217
|
+
}) => {
|
|
218
|
+
const source = props.source !== undefined ? props.source : table.store
|
|
219
|
+
const selectFn =
|
|
220
|
+
props.source !== undefined
|
|
221
|
+
? (props.selector ?? ((x: unknown) => x))
|
|
222
|
+
: props.selector
|
|
223
|
+
const selected = useSelector(source as never, selectFn as never, {
|
|
224
|
+
compare: shallow,
|
|
225
|
+
})
|
|
226
|
+
if (typeof props.children === 'function') {
|
|
227
|
+
return props.children(selected.value as Readonly<unknown>)
|
|
228
|
+
}
|
|
229
|
+
return props.children
|
|
230
|
+
}) as VueTable<TFeatures, TData, TSelected>['Subscribe']
|
|
231
|
+
|
|
232
|
+
const stateStore = useSelector(table.store, selector)
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
...table,
|
|
236
|
+
get state() {
|
|
237
|
+
return stateStore.value
|
|
238
|
+
},
|
|
239
|
+
}
|
|
240
|
+
}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,69 +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 useVueTable(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.useVueTable = useVueTable;
|
|
62
|
-
Object.keys(tableCore).forEach((k) => {
|
|
63
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
64
|
-
Object.defineProperty(exports, k, {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: () => tableCore[k]
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
DELETED
|
@@ -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 useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\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,CAAC,UAAU,OAAO;AAAA,EACzB,OAAO,CAAC,UAAuC;AAC7C,WAAO,MAAM;AACX,UACE,OAAO,MAAM,WAAW,cACxB,OAAO,MAAM,WAAW,UACxB;AACA,eAAOC,IAAE,EAAA,MAAM,QAAQ,MAAM,KAAK;AAAA,MACpC;AAEA,aAAO,MAAM;AAAA,IAAA;AAAA,EAEjB;AACF,CAAC;AAEM,SAAS,YACd,SACA;AACA,QAAM,kBAA+CC,WAAA;AAAA,IACnD;AAAA,MACE,OAAO,CAAC;AAAA;AAAA,MACR,eAAe,MAAM;AAAA,MAAC;AAAA;AAAA,MACtB,qBAAqB;AAAA,MACrB,aACE,gBACAC,UACA;AACO,eAAAD,WAAA,WAAW,gBAAgBC,QAAO;AAAA,MAC3C;AAAA,IACF;AAAA,IACA;AAAA,EAAA;AAGI,QAAA,QAAQC,sBAAmB,eAAe;AAE1C,QAAA,QAAQC,IAAAA,IAAI,MAAM,YAAY;AAEpCC,MAAAA,YAAY,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,aAAAJ,WAAA,WAAW,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA,QAI/B,OAAOA,WAAAA,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/cjs/index.d.cts
DELETED
|
@@ -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 useVueTable<TData extends RowData>(options: TableOptions<TData>): import('@tanstack/table-core').Table<TData>;
|
package/dist/cjs/merge-proxy.cjs
DELETED
|
@@ -1,64 +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)
|
|
10
|
-
return receiver;
|
|
11
|
-
return _.get(property);
|
|
12
|
-
},
|
|
13
|
-
has(_, property) {
|
|
14
|
-
return _.has(property);
|
|
15
|
-
},
|
|
16
|
-
set: trueFn,
|
|
17
|
-
deleteProperty: trueFn,
|
|
18
|
-
getOwnPropertyDescriptor(_, property) {
|
|
19
|
-
return {
|
|
20
|
-
configurable: true,
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get() {
|
|
23
|
-
return _.get(property);
|
|
24
|
-
},
|
|
25
|
-
set: trueFn,
|
|
26
|
-
deleteProperty: trueFn
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
ownKeys(_) {
|
|
30
|
-
return _.keys();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
function resolveSource(s) {
|
|
34
|
-
return "value" in s ? s.value : s;
|
|
35
|
-
}
|
|
36
|
-
function mergeProxy(...sources) {
|
|
37
|
-
return new Proxy(
|
|
38
|
-
{
|
|
39
|
-
get(property) {
|
|
40
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
41
|
-
const v = resolveSource(sources[i])[property];
|
|
42
|
-
if (v !== void 0)
|
|
43
|
-
return v;
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
has(property) {
|
|
47
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
48
|
-
if (property in resolveSource(sources[i]))
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
},
|
|
53
|
-
keys() {
|
|
54
|
-
const keys = [];
|
|
55
|
-
for (let i = 0; i < sources.length; i++)
|
|
56
|
-
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
57
|
-
return [...Array.from(new Set(keys))];
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
propTraps
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
exports.mergeProxy = mergeProxy;
|
|
64
|
-
//# 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(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;AACzB,QAAI,aAAa;AAAe,aAAA;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;AAC5C,cAAI,MAAM;AAAkB,mBAAA;AAAA,QAC9B;AAAA,MACF;AAAA,MACA,IAAI,UAAoC;AACtC,iBAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AAC5C,cAAI,YAAY,cAAc,QAAQ,CAAC,CAAC;AAAU,mBAAA;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;;"}
|
|
@@ -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 {};
|
package/dist/esm/index.d.ts
DELETED
|
@@ -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 useVueTable<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 useVueTable(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
|
-
useVueTable
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -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 useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\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,YACd,SACA;AACA,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,YAAmB,eAAe;AAE1C,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 {};
|
package/dist/esm/merge-proxy.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
function trueFn() {
|
|
2
|
-
return true;
|
|
3
|
-
}
|
|
4
|
-
const $PROXY = Symbol("merge-proxy");
|
|
5
|
-
const propTraps = {
|
|
6
|
-
get(_, property, receiver) {
|
|
7
|
-
if (property === $PROXY)
|
|
8
|
-
return receiver;
|
|
9
|
-
return _.get(property);
|
|
10
|
-
},
|
|
11
|
-
has(_, property) {
|
|
12
|
-
return _.has(property);
|
|
13
|
-
},
|
|
14
|
-
set: trueFn,
|
|
15
|
-
deleteProperty: trueFn,
|
|
16
|
-
getOwnPropertyDescriptor(_, property) {
|
|
17
|
-
return {
|
|
18
|
-
configurable: true,
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get() {
|
|
21
|
-
return _.get(property);
|
|
22
|
-
},
|
|
23
|
-
set: trueFn,
|
|
24
|
-
deleteProperty: trueFn
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
ownKeys(_) {
|
|
28
|
-
return _.keys();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
function resolveSource(s) {
|
|
32
|
-
return "value" in s ? s.value : s;
|
|
33
|
-
}
|
|
34
|
-
function mergeProxy(...sources) {
|
|
35
|
-
return new Proxy(
|
|
36
|
-
{
|
|
37
|
-
get(property) {
|
|
38
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
39
|
-
const v = resolveSource(sources[i])[property];
|
|
40
|
-
if (v !== void 0)
|
|
41
|
-
return v;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
has(property) {
|
|
45
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
46
|
-
if (property in resolveSource(sources[i]))
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
},
|
|
51
|
-
keys() {
|
|
52
|
-
const keys = [];
|
|
53
|
-
for (let i = 0; i < sources.length; i++)
|
|
54
|
-
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
55
|
-
return [...Array.from(new Set(keys))];
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
propTraps
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
mergeProxy
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=merge-proxy.js.map
|