@tanstack/svelte-table 8.0.0-alpha.76 → 8.0.0-alpha.79
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/build/cjs/svelte-table/src/index.js +38 -9
- package/build/cjs/svelte-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +9 -7
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +46 -16
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +48 -42
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +46 -16
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +39 -7
|
@@ -14,21 +14,50 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
14
14
|
|
|
15
15
|
var index = require('../../table-core/build/esm/index.js');
|
|
16
16
|
var placeholder = require('./placeholder.svelte.js');
|
|
17
|
+
var internal = require('svelte/internal');
|
|
17
18
|
var store = require('svelte/store');
|
|
18
19
|
var renderComponent = require('./render-component.js');
|
|
19
20
|
|
|
20
|
-
function
|
|
21
|
-
|
|
21
|
+
function isSvelteServerComponent(component) {
|
|
22
|
+
return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isSvelteClientComponent(component) {
|
|
26
|
+
return component.prototype instanceof internal.SvelteComponent;
|
|
27
|
+
}
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
29
|
+
function isSvelteComponent(component) {
|
|
30
|
+
if (typeof document === 'undefined') {
|
|
31
|
+
return isSvelteServerComponent(component);
|
|
26
32
|
} else {
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
return isSvelteClientComponent(component);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function wrapInPlaceholder(content) {
|
|
38
|
+
return renderComponent.renderComponent(placeholder["default"], {
|
|
39
|
+
content
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function render(component, props) {
|
|
44
|
+
if (!component) return null;
|
|
45
|
+
|
|
46
|
+
if (isSvelteComponent(component)) {
|
|
47
|
+
return renderComponent.renderComponent(component, props);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof component === 'function') {
|
|
51
|
+
const result = component(props);
|
|
52
|
+
|
|
53
|
+
if (isSvelteComponent(result)) {
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return wrapInPlaceholder(result);
|
|
58
|
+
}
|
|
31
59
|
|
|
60
|
+
return wrapInPlaceholder(component);
|
|
32
61
|
}
|
|
33
62
|
const createTable = index.createTableFactory({
|
|
34
63
|
render
|
|
@@ -1 +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\
|
|
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 { SvelteComponent } from 'svelte/internal'\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\nfunction isSvelteServerComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$render === 'function' &&\n typeof component.render === 'function'\n )\n}\n\nfunction isSvelteClientComponent(component: any) {\n return component.prototype instanceof SvelteComponent\n}\n\nfunction isSvelteComponent(component: any) {\n if (typeof document === 'undefined') {\n return isSvelteServerComponent(component)\n } else {\n return isSvelteClientComponent(component)\n }\n}\n\nfunction wrapInPlaceholder(content: any) {\n return renderComponent(Placeholder, { content })\n}\n\nexport function render(component: any, props: any) {\n if (!component) return null\n\n if (isSvelteComponent(component)) {\n return renderComponent(component, props)\n }\n\n if (typeof component === 'function') {\n const result = component(props)\n\n if (isSvelteComponent(result)) {\n return result\n }\n\n return wrapInPlaceholder(result)\n }\n\n return wrapInPlaceholder(component)\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":["isSvelteServerComponent","component","$$render","render","isSvelteClientComponent","prototype","SvelteComponent","isSvelteComponent","document","wrapInPlaceholder","content","renderComponent","Placeholder","props","result","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","Function","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,SAASA,uBAAT,CAAiCC,SAAjC,EAAiD;AAC/C,EAAA,OACE,OAAOA,SAAP,KAAqB,QAArB,IACA,OAAOA,SAAS,CAACC,QAAjB,KAA8B,UAD9B,IAEA,OAAOD,SAAS,CAACE,MAAjB,KAA4B,UAH9B,CAAA;AAKD,CAAA;;AAED,SAASC,uBAAT,CAAiCH,SAAjC,EAAiD;AAC/C,EAAA,OAAOA,SAAS,CAACI,SAAV,YAA+BC,wBAAtC,CAAA;AACD,CAAA;;AAED,SAASC,iBAAT,CAA2BN,SAA3B,EAA2C;AACzC,EAAA,IAAI,OAAOO,QAAP,KAAoB,WAAxB,EAAqC;AACnC,IAAOR,OAAAA,uBAAuB,CAACC,SAAD,CAA9B,CAAA;AACD,GAFD,MAEO;AACL,IAAOG,OAAAA,uBAAuB,CAACH,SAAD,CAA9B,CAAA;AACD,GAAA;AACF,CAAA;;AAED,SAASQ,iBAAT,CAA2BC,OAA3B,EAAyC;AACvC,EAAOC,OAAAA,+BAAe,CAACC,sBAAD,EAAc;AAAEF,IAAAA,OAAAA;AAAF,GAAd,CAAtB,CAAA;AACD,CAAA;;AAEM,SAASP,MAAT,CAAgBF,SAAhB,EAAgCY,KAAhC,EAA4C;AACjD,EAAA,IAAI,CAACZ,SAAL,EAAgB,OAAO,IAAP,CAAA;;AAEhB,EAAA,IAAIM,iBAAiB,CAACN,S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|
|
@@ -543,7 +543,7 @@ const ColumnSizing = {
|
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
-
const startSize =
|
|
546
|
+
const startSize = header.getSize();
|
|
547
547
|
const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
|
548
548
|
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
549
549
|
|
|
@@ -2690,8 +2690,10 @@ const Headers = {
|
|
|
2690
2690
|
},
|
|
2691
2691
|
// Header Groups
|
|
2692
2692
|
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2693
|
-
|
|
2694
|
-
|
|
2693
|
+
var _left$map$filter, _right$map$filter;
|
|
2694
|
+
|
|
2695
|
+
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2696
|
+
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2695
2697
|
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2696
2698
|
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2697
2699
|
return headerGroups;
|
|
@@ -2715,9 +2717,9 @@ const Headers = {
|
|
|
2715
2717
|
}
|
|
2716
2718
|
}),
|
|
2717
2719
|
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2718
|
-
var _left$map$
|
|
2720
|
+
var _left$map$filter2;
|
|
2719
2721
|
|
|
2720
|
-
const orderedLeafColumns = (_left$map$
|
|
2722
|
+
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2721
2723
|
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2722
2724
|
}, {
|
|
2723
2725
|
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
@@ -2728,9 +2730,9 @@ const Headers = {
|
|
|
2728
2730
|
}
|
|
2729
2731
|
}),
|
|
2730
2732
|
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2731
|
-
var _right$map$
|
|
2733
|
+
var _right$map$filter2;
|
|
2732
2734
|
|
|
2733
|
-
const orderedLeafColumns = (_right$map$
|
|
2735
|
+
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2734
2736
|
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2735
2737
|
}, {
|
|
2736
2738
|
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|