@tanstack/svelte-table 8.0.0-alpha.67 → 8.0.0-alpha.70

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.
@@ -0,0 +1,130 @@
1
+ /**
2
+ * svelte-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 placeholder = require('./placeholder.svelte.js');
17
+ var store = require('svelte/store');
18
+ var renderComponent = require('./render-component.js');
19
+
20
+ function render(Comp, props) {
21
+ if (!Comp) return null;
22
+
23
+ if (Comp instanceof Function) {
24
+ let res = Comp(props);
25
+ return res;
26
+ } else {
27
+ return renderComponent.renderComponent(placeholder["default"], {
28
+ content: Comp
29
+ });
30
+ } // return Comp
31
+
32
+ }
33
+ const createTable = index.createTableFactory({
34
+ render
35
+ });
36
+ function createTableInstance(table, options) {
37
+ let optionsStore;
38
+
39
+ if ('subscribe' in options) {
40
+ optionsStore = options;
41
+ } else {
42
+ optionsStore = store.readable(options);
43
+ }
44
+
45
+ let resolvedOptions = { ...table.options,
46
+ state: {},
47
+ // Dummy state
48
+ onStateChange: () => {},
49
+ // noop
50
+ render,
51
+ ...store.get(optionsStore)
52
+ };
53
+ let instance = index.createTableInstance(resolvedOptions);
54
+ let stateStore = store.writable(
55
+ /** @type {number} */
56
+ instance.initialState); // combine stores
57
+
58
+ let stateOptionsStore = store.derived([stateStore, optionsStore], s => s);
59
+ const instanceReadable = store.readable(instance, function start(set) {
60
+ const unsubscribe = stateOptionsStore.subscribe(_ref => {
61
+ let [state, options] = _ref;
62
+ instance.setOptions(prev => {
63
+ return { ...prev,
64
+ ...options,
65
+ state: { ...state,
66
+ ...options.state
67
+ },
68
+ // Similarly, we'll maintain both our internal state and any user-provided
69
+ // state.
70
+ onStateChange: updater => {
71
+ if (updater instanceof Function) {
72
+ stateStore.update(updater);
73
+ } else {
74
+ stateStore.set(updater);
75
+ }
76
+
77
+ resolvedOptions.onStateChange == null ? void 0 : resolvedOptions.onStateChange(updater);
78
+ }
79
+ };
80
+ }); // it didn't seem to rerender without setting the instance
81
+
82
+ set(instance);
83
+ });
84
+ return function stop() {
85
+ unsubscribe();
86
+ };
87
+ });
88
+ return instanceReadable;
89
+ }
90
+
91
+ exports.ColumnSizing = index.ColumnSizing;
92
+ exports.Expanding = index.Expanding;
93
+ exports.Filters = index.Filters;
94
+ exports.Grouping = index.Grouping;
95
+ exports.Headers = index.Headers;
96
+ exports.Ordering = index.Ordering;
97
+ exports.Pagination = index.Pagination;
98
+ exports.Pinning = index.Pinning;
99
+ exports.RowSelection = index.RowSelection;
100
+ exports.Sorting = index.Sorting;
101
+ exports.Visibility = index.Visibility;
102
+ exports.buildHeaderGroups = index.buildHeaderGroups;
103
+ exports.createTableFactory = index.createTableFactory;
104
+ exports.defaultColumnSizing = index.defaultColumnSizing;
105
+ exports.expandRows = index.expandRows;
106
+ exports.flattenBy = index.flattenBy;
107
+ exports.functionalUpdate = index.functionalUpdate;
108
+ exports.getCoreRowModel = index.getCoreRowModel;
109
+ exports.getExpandedRowModel = index.getExpandedRowModel;
110
+ exports.getFacetedMinMaxValues = index.getFacetedMinMaxValues;
111
+ exports.getFacetedRowModel = index.getFacetedRowModel;
112
+ exports.getFacetedUniqueValues = index.getFacetedUniqueValues;
113
+ exports.getFilteredRowModel = index.getFilteredRowModel;
114
+ exports.getGroupedRowModel = index.getGroupedRowModel;
115
+ exports.getPaginationRowModel = index.getPaginationRowModel;
116
+ exports.getSortedRowModel = index.getSortedRowModel;
117
+ exports.isFunction = index.isFunction;
118
+ exports.isRowSelected = index.isRowSelected;
119
+ exports.makeStateUpdater = index.makeStateUpdater;
120
+ exports.memo = index.memo;
121
+ exports.noop = index.noop;
122
+ exports.orderColumns = index.orderColumns;
123
+ exports.passiveEventSupported = index.passiveEventSupported;
124
+ exports.selectRowsFn = index.selectRowsFn;
125
+ exports.shouldAutoRemoveFilter = index.shouldAutoRemoveFilter;
126
+ exports.renderComponent = renderComponent.renderComponent;
127
+ exports.createTable = createTable;
128
+ exports.createTableInstance = createTableInstance;
129
+ exports.render = render;
130
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n createTableFactory,\n createTableInstance as coreCreateTableInstance,\n PartialKeys,\n Table,\n TableGenerics,\n TableOptions,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder.svelte'\nimport { readable, writable, derived, Readable, get } from 'svelte/store'\nimport { renderComponent } from './render-component'\n\nexport { renderComponent } from './render-component'\n\nexport * from '@tanstack/table-core'\n\nexport function render(Comp: any, props: any) {\n if (!Comp) return null\n\n if (Comp instanceof Function) {\n let res = Comp(props)\n return res\n } else {\n return renderComponent(Placeholder, { content: Comp })\n }\n\n // return Comp\n}\n\nexport const createTable = createTableFactory({ render })\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: ReadableOrVal<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n) {\n let optionsStore: Readable<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n\n if ('subscribe' in options) {\n optionsStore = options\n } else {\n optionsStore = readable(options)\n }\n\n let resolvedOptions: TableOptions<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...get(optionsStore),\n }\n\n let instance = coreCreateTableInstance(resolvedOptions)\n\n let stateStore = writable(/** @type {number} */ instance.initialState)\n // combine stores\n let stateOptionsStore = derived([stateStore, optionsStore], s => s)\n const instanceReadable = readable(instance, function start(set) {\n const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {\n instance.setOptions(prev => {\n return {\n ...prev,\n ...options,\n state: { ...state, ...options.state },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n if (updater instanceof Function) {\n stateStore.update(updater)\n } else {\n stateStore.set(updater)\n }\n\n resolvedOptions.onStateChange?.(updater)\n },\n }\n })\n\n // it didn't seem to rerender without setting the instance\n set(instance)\n })\n\n return function stop() {\n unsubscribe()\n }\n })\n\n return instanceReadable\n}\n"],"names":["render","Comp","props","Function","res","renderComponent","Placeholder","content","createTable","createTableFactory","createTableInstance","table","options","optionsStore","readable","resolvedOptions","state","onStateChange","get","instance","coreCreateTableInstance","stateStore","writable","initialState","stateOptionsStore","derived","s","instanceReadable","start","set","unsubscribe","subscribe","setOptions","prev","updater","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBO,SAASA,MAAT,CAAgBC,IAAhB,EAA2BC,KAA3B,EAAuC;AAC5C,EAAA,IAAI,CAACD,IAAL,EAAW,OAAO,IAAP,CAAA;;AAEX,EAAIA,IAAAA,IAAI,YAAYE,QAApB,EAA8B;AAC5B,IAAA,IAAIC,GAAG,GAAGH,IAAI,CAACC,KAAD,CAAd,CAAA;AACA,IAAA,OAAOE,GAAP,CAAA;AACD,GAHD,MAGO;AACL,IAAOC,OAAAA,+BAAe,CAACC,sBAAD,EAAc;AAAEC,MAAAA,OAAO,EAAEN,IAAAA;AAAX,KAAd,CAAtB,CAAA;AACD,GAR2C;;AAW7C,CAAA;AAEYO,MAAAA,WAAW,GAAGC,wBAAkB,CAAC;AAAET,EAAAA,MAAAA;AAAF,CAAD,EAAtC;AAIA,SAASU,mBAAT,CACLC,KADK,EAELC,OAFK,EAQL;AACA,EAAA,IAAIC,YAAJ,CAAA;;AAOA,EAAI,IAAA,WAAA,IAAeD,OAAnB,EAA4B;AAC1BC,IAAAA,YAAY,GAAGD,OAAf,CAAA;AACD,GAFD,MAEO;AACLC,IAAAA,YAAY,GAAGC,cA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,GAAX,CAAeK,OAAf,CAAA,CAAA;AACD,aAAA;;AAEDnB,YAAAA,eAAe,CAACE,aAAhB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAF,eAAe,CAACE,aAAhB,CAAgCiB,OAAhC,CAAA,CAAA;AACD,WAAA;AAdI,SAAP,CAAA;AAgBD,OAjBD,EADoE;;AAqBpEL,MAAAA,GAAG,CAACV,QAAD,CAAH,CAAA;AACD,KAtBmB,CAApB,CAAA;AAwBA,IAAO,OAAA,SAASiB,IAAT,GAAgB;AACrBN,MAAAA,WAAW,EAAA,CAAA;AACZ,KAFD,CAAA;AAGD,GA5BgC,CAAjC,CAAA;AA8BA,EAAA,OAAOH,gBAAP,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placeholder.svelte.js","sources":["../../../../src/placeholder.svelte"],"sourcesContent":["<script>\nexport let content;\n</script>\n\n{content}"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iCAIC,GAAO,CAAA,CAAA,CAAA,CAAA,CAAA;;;;;;+DAAP,GAAO,CAAA,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;OAHG,OAAO,EAAA,GAAA,OAAA,CAAA;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * svelte-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 internal = require('svelte/internal');
16
+
17
+ function create_fragment(ctx, Comp, props) {
18
+ let c;
19
+ let current;
20
+ c = new Comp({
21
+ props,
22
+ $$inline: true
23
+ });
24
+ return {
25
+ c() {
26
+ internal.create_component(c.$$.fragment);
27
+ },
28
+
29
+ m(target, anchor) {
30
+ // @ts-ignore
31
+ internal.mount_component(c, target, anchor);
32
+ current = true;
33
+ },
34
+
35
+ p: internal.noop,
36
+
37
+ i(local) {
38
+ if (current) return;
39
+ internal.transition_in(c.$$.fragment, local);
40
+ current = true;
41
+ },
42
+
43
+ o(local) {
44
+ internal.transition_out(c.$$.fragment, local);
45
+ current = false;
46
+ },
47
+
48
+ d(detaching) {
49
+ internal.destroy_component(c, detaching);
50
+ }
51
+
52
+ };
53
+ }
54
+
55
+ function renderClient(Comp, props) {
56
+ return class WrapperComp extends internal.SvelteComponent {
57
+ constructor(options) {
58
+ super();
59
+ internal.init(this, options, null, ctx => create_fragment(ctx, Comp, props), internal.safe_not_equal, {}, undefined);
60
+ }
61
+
62
+ };
63
+ }
64
+
65
+ function renderServer(Comp, props) {
66
+ const WrapperComp = internal.create_ssr_component(($$result, $$props, $$bindings, slots) => {
67
+ return "" + internal.validate_component(Comp, 'Comp').$$render($$result, props, {}, {});
68
+ });
69
+ return WrapperComp;
70
+ }
71
+
72
+ const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
73
+
74
+ exports.renderComponent = renderComponent;
75
+ //# sourceMappingURL=render-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-component.js","sources":["../../../../src/render-component.ts"],"sourcesContent":["import {\n SvelteComponent,\n create_component,\n destroy_component,\n init,\n mount_component,\n noop,\n safe_not_equal,\n transition_in,\n transition_out,\n create_ssr_component,\n validate_component,\n} from 'svelte/internal'\n\nfunction create_fragment(ctx: any, Comp: any, props: any) {\n let c: any\n let current: any\n c = new Comp({ props, $$inline: true })\n\n return {\n c() {\n create_component(c.$$.fragment)\n },\n m(target: any, anchor: any) {\n // @ts-ignore\n mount_component(c, target, anchor)\n current = true\n },\n p: noop,\n i(local: any) {\n if (current) return\n transition_in(c.$$.fragment, local)\n current = true\n },\n o(local: any) {\n transition_out(c.$$.fragment, local)\n current = false\n },\n d(detaching: any) {\n destroy_component(c, detaching)\n },\n }\n}\n\nfunction renderClient(Comp: any, props: any): any {\n return class WrapperComp extends SvelteComponent {\n constructor(options: any) {\n super()\n init(\n this,\n options,\n null,\n (ctx: any) => create_fragment(ctx, Comp, props),\n safe_not_equal,\n {},\n undefined\n )\n }\n }\n}\n\nfunction renderServer(Comp: any, props: any) {\n const WrapperComp = create_ssr_component(\n ($$result: any, $$props: any, $$bindings: any, slots: any) => {\n return `${validate_component(Comp, 'Comp').$$render(\n $$result,\n props,\n {},\n {}\n )}`\n }\n )\n\n return WrapperComp\n}\n\nexport const renderComponent =\n typeof window === 'undefined' ? renderServer : renderClient\n"],"names":["create_fragment","ctx","Comp","props","c","current","$$inline","create_component","$$","fragment","m","target","anchor","mount_component","p","noop","i","local","transition_in","o","transition_out","d","detaching","destroy_component","renderClient","WrapperComp","SvelteComponent","constructor","options","init","safe_not_equal","undefined","renderServer","create_ssr_component","$$result","$$props","$$bindings","slots","validate_component","$$render","renderComponent","window"],"mappings":";;;;;;;;;;;;;;;;AAcA,SAASA,eAAT,CAAyBC,GAAzB,EAAmCC,IAAnC,EAA8CC,KAA9C,EAA0D;AACxD,EAAA,IAAIC,CAAJ,CAAA;AACA,EAAA,IAAIC,OAAJ,CAAA;AACAD,EAAAA,CAAC,GAAG,IAAIF,IAAJ,CAAS;AAAEC,IAAAA,KAAF;AAASG,IAAAA,QAAQ,EAAE,IAAA;AAAnB,GAAT,CAAJ,CAAA;AAEA,EAAO,OAAA;AACLF,IAAAA,CAAC,GAAG;AACFG,MAAAA,yBAAgB,CAACH,CAAC,CAACI,EAAF,CAAKC,QAAN,CAAhB,CAAA;AACD,KAHI;;AAILC,IAAAA,CAAC,CAACC,MAAD,EAAcC,MAAd,EAA2B;AAC1B;AACAC,MAAAA,wBAAe,CAACT,CAAD,EAAIO,MAAJ,EAAYC,MAAZ,CAAf,CAAA;AACAP,MAAAA,OAAO,GAAG,IAAV,CAAA;AACD,KARI;;AASLS,IAAAA,CAAC,EAAEC,aATE;;AAULC,IAAAA,CAAC,CAACC,KAAD,EAAa;AACZ,MAAA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