@tanstack/vue-table 8.5.30 → 8.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,116 +0,0 @@
1
- /**
2
- * vue-table
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var index = require('../../table-core/build/esm/index.js');
16
- var vue = require('vue');
17
- var mergeProxy = require('./merge-proxy.js');
18
-
19
- const FlexRender = {
20
- props: ['render', 'props'],
21
- setup: props => {
22
- return () => {
23
- if (typeof props.render === 'function' || typeof props.render === 'object') {
24
- return vue.h(props.render, props.props);
25
- }
26
- return props.render;
27
- };
28
- }
29
- };
30
- function useVueTable(options) {
31
- const resolvedOptions = mergeProxy.mergeProxy({
32
- state: {},
33
- // Dummy state
34
- onStateChange: () => {},
35
- // noop
36
- renderFallbackValue: null,
37
- mergeOptions(defaultOptions, options) {
38
- return mergeProxy.mergeProxy(defaultOptions, options);
39
- }
40
- }, options);
41
- const table = index.createTable(resolvedOptions);
42
- // can't use `reactive` because update needs to be immutable
43
- const state = vue.ref(table.initialState);
44
- vue.watchEffect(() => {
45
- table.setOptions(prev => {
46
- const stateProxy = new Proxy({}, {
47
- get: (_, prop) => state.value[prop]
48
- });
49
- return mergeProxy.mergeProxy(prev, options, {
50
- // merge the initialState and `options.state`
51
- // create a new proxy on each `setOptions` call
52
- // and get the value from state on each property access
53
- state: mergeProxy.mergeProxy(stateProxy, options.state ?? {}),
54
- // Similarly, we'll maintain both our internal state and any user-provided
55
- // state.
56
- onStateChange: updater => {
57
- if (updater instanceof Function) {
58
- state.value = updater(state.value);
59
- } else {
60
- state.value = updater;
61
- }
62
- options.onStateChange == null ? void 0 : options.onStateChange(updater);
63
- }
64
- });
65
- });
66
- });
67
- return table;
68
- }
69
-
70
- exports.ColumnSizing = index.ColumnSizing;
71
- exports.Expanding = index.Expanding;
72
- exports.Filters = index.Filters;
73
- exports.Grouping = index.Grouping;
74
- exports.Headers = index.Headers;
75
- exports.Ordering = index.Ordering;
76
- exports.Pagination = index.Pagination;
77
- exports.Pinning = index.Pinning;
78
- exports.RowSelection = index.RowSelection;
79
- exports.Sorting = index.Sorting;
80
- exports.Visibility = index.Visibility;
81
- exports.aggregationFns = index.aggregationFns;
82
- exports.buildHeaderGroups = index.buildHeaderGroups;
83
- exports.createCell = index.createCell;
84
- exports.createColumn = index.createColumn;
85
- exports.createColumnHelper = index.createColumnHelper;
86
- exports.createRow = index.createRow;
87
- exports.createTable = index.createTable;
88
- exports.defaultColumnSizing = index.defaultColumnSizing;
89
- exports.expandRows = index.expandRows;
90
- exports.filterFns = index.filterFns;
91
- exports.flattenBy = index.flattenBy;
92
- exports.functionalUpdate = index.functionalUpdate;
93
- exports.getCoreRowModel = index.getCoreRowModel;
94
- exports.getExpandedRowModel = index.getExpandedRowModel;
95
- exports.getFacetedMinMaxValues = index.getFacetedMinMaxValues;
96
- exports.getFacetedRowModel = index.getFacetedRowModel;
97
- exports.getFacetedUniqueValues = index.getFacetedUniqueValues;
98
- exports.getFilteredRowModel = index.getFilteredRowModel;
99
- exports.getGroupedRowModel = index.getGroupedRowModel;
100
- exports.getPaginationRowModel = index.getPaginationRowModel;
101
- exports.getSortedRowModel = index.getSortedRowModel;
102
- exports.isFunction = index.isFunction;
103
- exports.isRowSelected = index.isRowSelected;
104
- exports.isSubRowSelected = index.isSubRowSelected;
105
- exports.makeStateUpdater = index.makeStateUpdater;
106
- exports.memo = index.memo;
107
- exports.noop = index.noop;
108
- exports.orderColumns = index.orderColumns;
109
- exports.passiveEventSupported = index.passiveEventSupported;
110
- exports.reSplitAlphaNumeric = index.reSplitAlphaNumeric;
111
- exports.selectRowsFn = index.selectRowsFn;
112
- exports.shouldAutoRemoveFilter = index.shouldAutoRemoveFilter;
113
- exports.sortingFns = index.sortingFns;
114
- exports.FlexRender = FlexRender;
115
- exports.useVueTable = useVueTable;
116
- //# 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 } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = {\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":["FlexRender","props","setup","render","h","useVueTable","options","resolvedOptions","mergeProxy","state","onStateChange","renderFallbackValue","mergeOptions","defaultOptions","table","createTable","ref","initialState","watchEffect","setOptions","prev","stateProxy","Proxy","get","_","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AAI,EAAEd,OAAO,EAAE;AAC/B;AACA;AACA;QACAG,KAAK,EAAED,qBAAU,CAACa,UAAU,EAAEf,OAAO,CAACG,KAAK,IAAI,EAAE,CAAC;AAClD;AACA;QACAC,aAAa,EAAGiB,OAAY,IAAK;UAC/B,IAAIA,OAAO,YAAYC,QAAQ,EAAE;YAC/BnB,KAAK,CAACiB,KAAK,GAAGC,OAAO,CAAClB,KAAK,CAACiB,KAAK,CAAC,CAAA;AACpC,WAAC,MAAM;YACLjB,KAAK,CAACiB,KAAK,GAAGC,OAAO,CAAA;AACvB,WAAA;UAEArB,OAAO,CAACI,aAAa,IAArBJ,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACI,aAAa,CAAGiB,OAAO,CAAC,CAAA;AAClC,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOb,KAAK,CAAA;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge-proxy.js","sources":["../../../../src/merge-proxy.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nexport const $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 [...new Set(keys)]\n },\n },\n propTraps\n )\n}\n"],"names":["trueFn","$PROXY","Symbol","propTraps","get","_","property","receiver","has","set","deleteProperty","getOwnPropertyDescriptor","configurable","enumerable","ownKeys","keys","resolveSource","s","value","mergeProxy","sources","Proxy","i","length","v","undefined","push","Object","Set"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,MAAM,GAAG;AAChB,EAAA,OAAO,IAAI,CAAA;AACb,CAAA;MAEaC,MAAM,GAAGC,MAAM,CAAC,aAAa,EAAC;;AAE3C;AACA,MAAMC,SAIJ,GAAG;AACHC,EAAAA,GAAG,CAACC,CAAC,EAAEC,QAAQ,EAAEC,QAAQ,EAAE;AACzB,IAAA,IAAID,QAAQ,KAAKL,MAAM,EAAE,OAAOM,QAAQ,CAAA;AACxC,IAAA,OAAOF,CAAC,CAACD,GAAG,CAACE,QAAQ,CAAC,CAAA;GACvB;AACDE,EAAAA,GAAG,CAACH,CAAC,EAAEC,QAA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