@tanstack/svelte-table 8.0.0-beta.3 → 8.0.0-beta.4
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 +6 -2
- package/build/cjs/svelte-table/src/index.js.map +1 -1
- package/build/cjs/svelte-table/src/placeholder.js +24 -0
- package/build/cjs/svelte-table/src/placeholder.js.map +1 -0
- package/build/cjs/svelte-table/src/render-component.js +5 -1
- package/build/cjs/svelte-table/src/render-component.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +47 -13
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +68 -18
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +76 -44
- package/build/types/placeholder.d.ts +3 -0
- package/build/umd/index.development.js +63 -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 +10 -2
- package/src/placeholder.ts +15 -0
- package/src/render-component.ts +5 -1
package/build/esm/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import { SvelteComponent, init, safe_not_equal, text as text$1,
|
|
11
|
+
import { SvelteComponent, init, safe_not_equal, text as text$1, claim_text, insert_hydration, set_data, noop as noop$1, detach, create_ssr_component, escape, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component, validate_component } from 'svelte/internal';
|
|
12
12
|
import { readable, get, writable, derived } from 'svelte/store';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -1534,6 +1534,12 @@ const Grouping = {
|
|
|
1534
1534
|
};
|
|
1535
1535
|
},
|
|
1536
1536
|
createCell: (cell, column, row, instance) => {
|
|
1537
|
+
const getRenderValue = () => {
|
|
1538
|
+
var _cell$getValue;
|
|
1539
|
+
|
|
1540
|
+
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1537
1543
|
return {
|
|
1538
1544
|
getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
|
|
1539
1545
|
getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
|
|
@@ -1543,15 +1549,19 @@ const Grouping = {
|
|
|
1543
1549
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
1544
1550
|
},
|
|
1545
1551
|
renderAggregatedCell: () => {
|
|
1546
|
-
|
|
1552
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1553
|
+
if (!column.columnDef.aggregatedCell) {
|
|
1554
|
+
console.warn('A columnDef.aggregatedCell template is recommended for displaying aggregated values.');
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1547
1557
|
|
|
1548
|
-
const template =
|
|
1558
|
+
const template = column.columnDef.aggregatedCell || column.columnDef.cell;
|
|
1549
1559
|
return template ? instance._render(template, {
|
|
1550
1560
|
instance,
|
|
1551
1561
|
column,
|
|
1552
1562
|
row,
|
|
1553
1563
|
cell,
|
|
1554
|
-
getValue:
|
|
1564
|
+
getValue: getRenderValue
|
|
1555
1565
|
}) : null;
|
|
1556
1566
|
}
|
|
1557
1567
|
};
|
|
@@ -2534,8 +2544,10 @@ const Sorting = {
|
|
|
2534
2544
|
// })
|
|
2535
2545
|
// return
|
|
2536
2546
|
// }
|
|
2547
|
+
// this needs to be outside of instance.setSorting to be in sync with rerender
|
|
2548
|
+
const nextSortingOrder = column.getNextSortingOrder();
|
|
2537
2549
|
instance.setSorting(old => {
|
|
2538
|
-
var
|
|
2550
|
+
var _instance$options$ena, _instance$options$ena2;
|
|
2539
2551
|
|
|
2540
2552
|
// Find any existing sorting for this column
|
|
2541
2553
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
@@ -2560,30 +2572,29 @@ const Sorting = {
|
|
|
2560
2572
|
} else {
|
|
2561
2573
|
sortAction = 'replace';
|
|
2562
2574
|
}
|
|
2563
|
-
}
|
|
2575
|
+
} // Handle toggle states that will remove the sorting
|
|
2564
2576
|
|
|
2565
|
-
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
|
|
2566
2577
|
|
|
2567
2578
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2568
2579
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
2569
2580
|
!hasDescDefined && ( // Must not be setting desc
|
|
2570
|
-
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) &&
|
|
2571
|
-
|
|
2572
|
-
|
|
2581
|
+
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && // If multi, don't allow if enableMultiRemove
|
|
2582
|
+
!nextSortingOrder // Finally, detect if it should indeed be removed
|
|
2583
|
+
) {
|
|
2573
2584
|
sortAction = 'remove';
|
|
2574
2585
|
}
|
|
2575
2586
|
|
|
2576
2587
|
if (sortAction === 'replace') {
|
|
2577
2588
|
newSorting = [{
|
|
2578
2589
|
id: column.id,
|
|
2579
|
-
desc: hasDescDefined ? desc :
|
|
2590
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2580
2591
|
}];
|
|
2581
2592
|
} else if (sortAction === 'add' && old != null && old.length) {
|
|
2582
2593
|
var _instance$options$max;
|
|
2583
2594
|
|
|
2584
2595
|
newSorting = [...old, {
|
|
2585
2596
|
id: column.id,
|
|
2586
|
-
desc: hasDescDefined ? desc :
|
|
2597
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2587
2598
|
}]; // Take latest n columns
|
|
2588
2599
|
|
|
2589
2600
|
newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
|
|
@@ -2592,7 +2603,7 @@ const Sorting = {
|
|
|
2592
2603
|
newSorting = old.map(d => {
|
|
2593
2604
|
if (d.id === column.id) {
|
|
2594
2605
|
return { ...d,
|
|
2595
|
-
desc: hasDescDefined ? desc :
|
|
2606
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2596
2607
|
};
|
|
2597
2608
|
}
|
|
2598
2609
|
|
|
@@ -2605,6 +2616,23 @@ const Sorting = {
|
|
|
2605
2616
|
return newSorting;
|
|
2606
2617
|
});
|
|
2607
2618
|
},
|
|
2619
|
+
getNextSortingOrder: () => {
|
|
2620
|
+
var _ref2, _column$columnDef$sor;
|
|
2621
|
+
|
|
2622
|
+
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc';
|
|
2623
|
+
const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
|
|
2624
|
+
const isSorted = column.getIsSorted();
|
|
2625
|
+
|
|
2626
|
+
if (!isSorted) {
|
|
2627
|
+
return firstSortDirection;
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
if (isSorted === firstSortDirection) {
|
|
2631
|
+
return isSorted === 'desc' ? 'asc' : 'desc';
|
|
2632
|
+
} else {
|
|
2633
|
+
return false;
|
|
2634
|
+
}
|
|
2635
|
+
},
|
|
2608
2636
|
getCanSort: () => {
|
|
2609
2637
|
var _column$columnDef$ena, _instance$options$ena3;
|
|
2610
2638
|
|
|
@@ -3054,6 +3082,12 @@ function createTable$1(_, __, options) {
|
|
|
3054
3082
|
}
|
|
3055
3083
|
|
|
3056
3084
|
function createCell(instance, row, column, columnId) {
|
|
3085
|
+
const getRenderValue = () => {
|
|
3086
|
+
var _cell$getValue;
|
|
3087
|
+
|
|
3088
|
+
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
|
|
3089
|
+
};
|
|
3090
|
+
|
|
3057
3091
|
const cell = {
|
|
3058
3092
|
id: row.id + "_" + column.id,
|
|
3059
3093
|
row,
|
|
@@ -3065,7 +3099,7 @@ function createCell(instance, row, column, columnId) {
|
|
|
3065
3099
|
column,
|
|
3066
3100
|
row,
|
|
3067
3101
|
cell: cell,
|
|
3068
|
-
getValue:
|
|
3102
|
+
getValue: getRenderValue
|
|
3069
3103
|
}) : null;
|
|
3070
3104
|
}
|
|
3071
3105
|
};
|
|
@@ -3827,8 +3861,11 @@ function create_fragment$1(ctx) {
|
|
|
3827
3861
|
c() {
|
|
3828
3862
|
t = text$1(/*content*/ ctx[0]);
|
|
3829
3863
|
},
|
|
3864
|
+
l(nodes) {
|
|
3865
|
+
t = claim_text(nodes, /*content*/ ctx[0]);
|
|
3866
|
+
},
|
|
3830
3867
|
m(target, anchor) {
|
|
3831
|
-
|
|
3868
|
+
insert_hydration(target, t, anchor);
|
|
3832
3869
|
},
|
|
3833
3870
|
p(ctx, [dirty]) {
|
|
3834
3871
|
if (dirty & /*content*/ 1) set_data(t, /*content*/ ctx[0]);
|
|
@@ -3851,13 +3888,18 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
3851
3888
|
return [content];
|
|
3852
3889
|
}
|
|
3853
3890
|
|
|
3854
|
-
class Placeholder extends SvelteComponent {
|
|
3891
|
+
class Placeholder$1 extends SvelteComponent {
|
|
3855
3892
|
constructor(options) {
|
|
3856
3893
|
super();
|
|
3857
3894
|
init(this, options, instance, create_fragment$1, safe_not_equal, { content: 0 });
|
|
3858
3895
|
}
|
|
3859
3896
|
}
|
|
3860
3897
|
|
|
3898
|
+
const PlaceholderServer = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
3899
|
+
return "" + escape($$props.content);
|
|
3900
|
+
});
|
|
3901
|
+
var Placeholder = typeof document === 'undefined' ? PlaceholderServer : Placeholder$1;
|
|
3902
|
+
|
|
3861
3903
|
function create_fragment(ctx, Comp, props) {
|
|
3862
3904
|
let c;
|
|
3863
3905
|
let current;
|
|
@@ -3870,6 +3912,10 @@ function create_fragment(ctx, Comp, props) {
|
|
|
3870
3912
|
create_component(c.$$.fragment);
|
|
3871
3913
|
},
|
|
3872
3914
|
|
|
3915
|
+
l(nodes) {
|
|
3916
|
+
claim_component(c.$$.fragment, nodes);
|
|
3917
|
+
},
|
|
3918
|
+
|
|
3873
3919
|
m(target, anchor) {
|
|
3874
3920
|
// @ts-ignore
|
|
3875
3921
|
mount_component(c, target, anchor);
|
|
@@ -3908,7 +3954,7 @@ function renderClient(Comp, props) {
|
|
|
3908
3954
|
|
|
3909
3955
|
function renderServer(Comp, props) {
|
|
3910
3956
|
const WrapperComp = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
3911
|
-
return "" + validate_component(Comp, '
|
|
3957
|
+
return "" + validate_component(Comp, 'TableComponent').$$render($$result, props, {}, {});
|
|
3912
3958
|
});
|
|
3913
3959
|
return WrapperComp;
|
|
3914
3960
|
}
|
|
@@ -3920,7 +3966,10 @@ function isSvelteServerComponent(component) {
|
|
|
3920
3966
|
}
|
|
3921
3967
|
|
|
3922
3968
|
function isSvelteClientComponent(component) {
|
|
3923
|
-
|
|
3969
|
+
var _component$name, _component$name2;
|
|
3970
|
+
|
|
3971
|
+
let isHMR = ('__SVELTE_HMR' in window);
|
|
3972
|
+
return component.prototype instanceof SvelteComponent || isHMR && ((_component$name = component.name) == null ? void 0 : _component$name.startsWith('Proxy<')) && ((_component$name2 = component.name) == null ? void 0 : _component$name2.endsWith('>'));
|
|
3924
3973
|
}
|
|
3925
3974
|
|
|
3926
3975
|
function isSvelteComponent(component) {
|
|
@@ -3974,6 +4023,7 @@ function createTableInstance(table, options) {
|
|
|
3974
4023
|
onStateChange: () => {},
|
|
3975
4024
|
// noop
|
|
3976
4025
|
render,
|
|
4026
|
+
renderFallbackValue: null,
|
|
3977
4027
|
...get(optionsStore)
|
|
3978
4028
|
};
|
|
3979
4029
|
let instance = createTableInstance$1(resolvedOptions);
|