@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.
@@ -2669,7 +2669,7 @@ var drawChart = (function (exports) {
2669
2669
  </script>
2670
2670
  <script>
2671
2671
  /*<!--*/
2672
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"6d83-163"},{"name":"svelte-table/src","children":[{"uid":"6d83-165","name":"placeholder.svelte"},{"uid":"6d83-167","name":"render-component.ts"},{"uid":"6d83-169","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"6d83-163":{"renderedLength":137572,"gzipLength":23395,"brotliLength":0,"mainUid":"6d83-162"},"6d83-165":{"renderedLength":925,"gzipLength":444,"brotliLength":0,"mainUid":"6d83-164"},"6d83-167":{"renderedLength":1365,"gzipLength":519,"brotliLength":0,"mainUid":"6d83-166"},"6d83-169":{"renderedLength":2729,"gzipLength":868,"brotliLength":0,"mainUid":"6d83-168"}},"nodeMetas":{"6d83-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"6d83-163"},"imported":[],"importedBy":[{"uid":"6d83-168"}]},"6d83-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"6d83-165"},"imported":[{"uid":"6d83-170"}],"importedBy":[{"uid":"6d83-168"}]},"6d83-166":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"6d83-167"},"imported":[{"uid":"6d83-170"}],"importedBy":[{"uid":"6d83-168"}]},"6d83-168":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"6d83-169"},"imported":[{"uid":"6d83-162"},{"uid":"6d83-164"},{"uid":"6d83-170"},{"uid":"6d83-171"},{"uid":"6d83-166"}],"importedBy":[],"isEntry":true},"6d83-170":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"6d83-168"},{"uid":"6d83-164"},{"uid":"6d83-166"}],"isExternal":true},"6d83-171":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"6d83-168"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2672
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"50f7-163"},{"name":"svelte-table/src","children":[{"uid":"50f7-165","name":"placeholder.svelte"},{"uid":"50f7-167","name":"placeholder.ts"},{"uid":"50f7-169","name":"render-component.ts"},{"uid":"50f7-171","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"50f7-163":{"renderedLength":138366,"gzipLength":23598,"brotliLength":0,"mainUid":"50f7-162"},"50f7-165":{"renderedLength":927,"gzipLength":445,"brotliLength":0,"mainUid":"50f7-164"},"50f7-167":{"renderedLength":246,"gzipLength":184,"brotliLength":0,"mainUid":"50f7-166"},"50f7-169":{"renderedLength":1458,"gzipLength":539,"brotliLength":0,"mainUid":"50f7-168"},"50f7-171":{"renderedLength":3046,"gzipLength":993,"brotliLength":0,"mainUid":"50f7-170"}},"nodeMetas":{"50f7-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"50f7-163"},"imported":[],"importedBy":[{"uid":"50f7-170"}]},"50f7-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"50f7-165"},"imported":[{"uid":"50f7-172"}],"importedBy":[{"uid":"50f7-166"}]},"50f7-166":{"id":"/packages/svelte-table/src/placeholder.ts","moduleParts":{"index.production.js":"50f7-167"},"imported":[{"uid":"50f7-172"},{"uid":"50f7-164"}],"importedBy":[{"uid":"50f7-170"}]},"50f7-168":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"50f7-169"},"imported":[{"uid":"50f7-172"}],"importedBy":[{"uid":"50f7-170"}]},"50f7-170":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"50f7-171"},"imported":[{"uid":"50f7-162"},{"uid":"50f7-166"},{"uid":"50f7-172"},{"uid":"50f7-173"},{"uid":"50f7-168"}],"importedBy":[],"isEntry":true},"50f7-172":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"50f7-170"},{"uid":"50f7-166"},{"uid":"50f7-168"},{"uid":"50f7-164"}],"isExternal":true},"50f7-173":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"50f7-170"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2673
2673
 
2674
2674
  const run = () => {
2675
2675
  const width = window.innerWidth;
@@ -11,21 +11,25 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "6d83-173"
14
+ "uid": "50f7-175"
15
15
  },
16
16
  {
17
17
  "name": "svelte-table/src",
18
18
  "children": [
19
19
  {
20
- "uid": "6d83-175",
20
+ "uid": "50f7-177",
21
21
  "name": "placeholder.svelte"
22
22
  },
23
23
  {
24
- "uid": "6d83-177",
24
+ "uid": "50f7-179",
25
+ "name": "placeholder.ts"
26
+ },
27
+ {
28
+ "uid": "50f7-181",
25
29
  "name": "render-component.ts"
26
30
  },
27
31
  {
28
- "uid": "6d83-179",
32
+ "uid": "50f7-183",
29
33
  "name": "index.ts"
30
34
  }
31
35
  ]
@@ -38,125 +42,153 @@
38
42
  "isRoot": true
39
43
  },
40
44
  "nodeParts": {
41
- "6d83-173": {
42
- "renderedLength": 137572,
43
- "gzipLength": 23395,
45
+ "50f7-175": {
46
+ "renderedLength": 138366,
47
+ "gzipLength": 23598,
44
48
  "brotliLength": 0,
45
- "mainUid": "6d83-172"
49
+ "mainUid": "50f7-174"
46
50
  },
47
- "6d83-175": {
48
- "renderedLength": 925,
49
- "gzipLength": 444,
51
+ "50f7-177": {
52
+ "renderedLength": 927,
53
+ "gzipLength": 445,
50
54
  "brotliLength": 0,
51
- "mainUid": "6d83-174"
55
+ "mainUid": "50f7-176"
52
56
  },
53
- "6d83-177": {
54
- "renderedLength": 1365,
55
- "gzipLength": 519,
57
+ "50f7-179": {
58
+ "renderedLength": 246,
59
+ "gzipLength": 184,
56
60
  "brotliLength": 0,
57
- "mainUid": "6d83-176"
61
+ "mainUid": "50f7-178"
58
62
  },
59
- "6d83-179": {
60
- "renderedLength": 2729,
61
- "gzipLength": 868,
63
+ "50f7-181": {
64
+ "renderedLength": 1458,
65
+ "gzipLength": 539,
62
66
  "brotliLength": 0,
63
- "mainUid": "6d83-178"
67
+ "mainUid": "50f7-180"
68
+ },
69
+ "50f7-183": {
70
+ "renderedLength": 3046,
71
+ "gzipLength": 993,
72
+ "brotliLength": 0,
73
+ "mainUid": "50f7-182"
64
74
  }
65
75
  },
66
76
  "nodeMetas": {
67
- "6d83-172": {
77
+ "50f7-174": {
68
78
  "id": "/packages/table-core/build/esm/index.js",
69
79
  "moduleParts": {
70
- "index.production.js": "6d83-173"
80
+ "index.production.js": "50f7-175"
71
81
  },
72
82
  "imported": [],
73
83
  "importedBy": [
74
84
  {
75
- "uid": "6d83-178"
85
+ "uid": "50f7-182"
76
86
  }
77
87
  ]
78
88
  },
79
- "6d83-174": {
89
+ "50f7-176": {
80
90
  "id": "/packages/svelte-table/src/placeholder.svelte",
81
91
  "moduleParts": {
82
- "index.production.js": "6d83-175"
92
+ "index.production.js": "50f7-177"
83
93
  },
84
94
  "imported": [
85
95
  {
86
- "uid": "6d83-180"
96
+ "uid": "50f7-184"
87
97
  }
88
98
  ],
89
99
  "importedBy": [
90
100
  {
91
- "uid": "6d83-178"
101
+ "uid": "50f7-178"
92
102
  }
93
103
  ]
94
104
  },
95
- "6d83-176": {
105
+ "50f7-178": {
106
+ "id": "/packages/svelte-table/src/placeholder.ts",
107
+ "moduleParts": {
108
+ "index.production.js": "50f7-179"
109
+ },
110
+ "imported": [
111
+ {
112
+ "uid": "50f7-184"
113
+ },
114
+ {
115
+ "uid": "50f7-176"
116
+ }
117
+ ],
118
+ "importedBy": [
119
+ {
120
+ "uid": "50f7-182"
121
+ }
122
+ ]
123
+ },
124
+ "50f7-180": {
96
125
  "id": "/packages/svelte-table/src/render-component.ts",
97
126
  "moduleParts": {
98
- "index.production.js": "6d83-177"
127
+ "index.production.js": "50f7-181"
99
128
  },
100
129
  "imported": [
101
130
  {
102
- "uid": "6d83-180"
131
+ "uid": "50f7-184"
103
132
  }
104
133
  ],
105
134
  "importedBy": [
106
135
  {
107
- "uid": "6d83-178"
136
+ "uid": "50f7-182"
108
137
  }
109
138
  ]
110
139
  },
111
- "6d83-178": {
140
+ "50f7-182": {
112
141
  "id": "/packages/svelte-table/src/index.ts",
113
142
  "moduleParts": {
114
- "index.production.js": "6d83-179"
143
+ "index.production.js": "50f7-183"
115
144
  },
116
145
  "imported": [
117
146
  {
118
- "uid": "6d83-172"
147
+ "uid": "50f7-174"
119
148
  },
120
149
  {
121
- "uid": "6d83-174"
150
+ "uid": "50f7-178"
122
151
  },
123
152
  {
124
- "uid": "6d83-180"
153
+ "uid": "50f7-184"
125
154
  },
126
155
  {
127
- "uid": "6d83-181"
156
+ "uid": "50f7-185"
128
157
  },
129
158
  {
130
- "uid": "6d83-176"
159
+ "uid": "50f7-180"
131
160
  }
132
161
  ],
133
162
  "importedBy": [],
134
163
  "isEntry": true
135
164
  },
136
- "6d83-180": {
165
+ "50f7-184": {
137
166
  "id": "svelte/internal",
138
167
  "moduleParts": {},
139
168
  "imported": [],
140
169
  "importedBy": [
141
170
  {
142
- "uid": "6d83-178"
171
+ "uid": "50f7-182"
172
+ },
173
+ {
174
+ "uid": "50f7-178"
143
175
  },
144
176
  {
145
- "uid": "6d83-174"
177
+ "uid": "50f7-180"
146
178
  },
147
179
  {
148
- "uid": "6d83-176"
180
+ "uid": "50f7-176"
149
181
  }
150
182
  ],
151
183
  "isExternal": true
152
184
  },
153
- "6d83-181": {
185
+ "50f7-185": {
154
186
  "id": "svelte/store",
155
187
  "moduleParts": {},
156
188
  "imported": [],
157
189
  "importedBy": [
158
190
  {
159
- "uid": "6d83-178"
191
+ "uid": "50f7-182"
160
192
  }
161
193
  ],
162
194
  "isExternal": true
@@ -0,0 +1,3 @@
1
+ import type { SvelteComponentDev } from 'svelte/internal';
2
+ declare const _default: typeof SvelteComponentDev;
3
+ export default _default;
@@ -1535,6 +1535,12 @@
1535
1535
  };
1536
1536
  },
1537
1537
  createCell: (cell, column, row, instance) => {
1538
+ const getRenderValue = () => {
1539
+ var _cell$getValue;
1540
+
1541
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
1542
+ };
1543
+
1538
1544
  return {
1539
1545
  getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
1540
1546
  getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
@@ -1544,15 +1550,19 @@
1544
1550
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1545
1551
  },
1546
1552
  renderAggregatedCell: () => {
1547
- var _column$columnDef$agg;
1553
+ {
1554
+ if (!column.columnDef.aggregatedCell) {
1555
+ console.warn('A columnDef.aggregatedCell template is recommended for displaying aggregated values.');
1556
+ }
1557
+ }
1548
1558
 
1549
- const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1559
+ const template = column.columnDef.aggregatedCell || column.columnDef.cell;
1550
1560
  return template ? instance._render(template, {
1551
1561
  instance,
1552
1562
  column,
1553
1563
  row,
1554
1564
  cell,
1555
- getValue: cell.getValue
1565
+ getValue: getRenderValue
1556
1566
  }) : null;
1557
1567
  }
1558
1568
  };
@@ -2535,8 +2545,10 @@
2535
2545
  // })
2536
2546
  // return
2537
2547
  // }
2548
+ // this needs to be outside of instance.setSorting to be in sync with rerender
2549
+ const nextSortingOrder = column.getNextSortingOrder();
2538
2550
  instance.setSorting(old => {
2539
- var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2551
+ var _instance$options$ena, _instance$options$ena2;
2540
2552
 
2541
2553
  // Find any existing sorting for this column
2542
2554
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2561,30 +2573,29 @@
2561
2573
  } else {
2562
2574
  sortAction = 'replace';
2563
2575
  }
2564
- }
2576
+ } // Handle toggle states that will remove the sorting
2565
2577
 
2566
- 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
2567
2578
 
2568
2579
  if (sortAction === 'toggle' && ( // Must be toggling
2569
2580
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2570
2581
  !hasDescDefined && ( // Must not be setting desc
2571
- multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2572
- existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2573
- ? !sortDescFirst : sortDescFirst)) {
2582
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && // If multi, don't allow if enableMultiRemove
2583
+ !nextSortingOrder // Finally, detect if it should indeed be removed
2584
+ ) {
2574
2585
  sortAction = 'remove';
2575
2586
  }
2576
2587
 
2577
2588
  if (sortAction === 'replace') {
2578
2589
  newSorting = [{
2579
2590
  id: column.id,
2580
- desc: hasDescDefined ? desc : !!sortDescFirst
2591
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2581
2592
  }];
2582
2593
  } else if (sortAction === 'add' && old != null && old.length) {
2583
2594
  var _instance$options$max;
2584
2595
 
2585
2596
  newSorting = [...old, {
2586
2597
  id: column.id,
2587
- desc: hasDescDefined ? desc : !!sortDescFirst
2598
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2588
2599
  }]; // Take latest n columns
2589
2600
 
2590
2601
  newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
@@ -2593,7 +2604,7 @@
2593
2604
  newSorting = old.map(d => {
2594
2605
  if (d.id === column.id) {
2595
2606
  return { ...d,
2596
- desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2607
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2597
2608
  };
2598
2609
  }
2599
2610
 
@@ -2606,6 +2617,23 @@
2606
2617
  return newSorting;
2607
2618
  });
2608
2619
  },
2620
+ getNextSortingOrder: () => {
2621
+ var _ref2, _column$columnDef$sor;
2622
+
2623
+ const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc';
2624
+ const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
2625
+ const isSorted = column.getIsSorted();
2626
+
2627
+ if (!isSorted) {
2628
+ return firstSortDirection;
2629
+ }
2630
+
2631
+ if (isSorted === firstSortDirection) {
2632
+ return isSorted === 'desc' ? 'asc' : 'desc';
2633
+ } else {
2634
+ return false;
2635
+ }
2636
+ },
2609
2637
  getCanSort: () => {
2610
2638
  var _column$columnDef$ena, _instance$options$ena3;
2611
2639
 
@@ -3053,6 +3081,12 @@
3053
3081
  }
3054
3082
 
3055
3083
  function createCell(instance, row, column, columnId) {
3084
+ const getRenderValue = () => {
3085
+ var _cell$getValue;
3086
+
3087
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
3088
+ };
3089
+
3056
3090
  const cell = {
3057
3091
  id: row.id + "_" + column.id,
3058
3092
  row,
@@ -3064,7 +3098,7 @@
3064
3098
  column,
3065
3099
  row,
3066
3100
  cell: cell,
3067
- getValue: cell.getValue
3101
+ getValue: getRenderValue
3068
3102
  }) : null;
3069
3103
  }
3070
3104
  };
@@ -3850,13 +3884,18 @@
3850
3884
  return [content];
3851
3885
  }
3852
3886
 
3853
- class Placeholder extends internal.SvelteComponent {
3887
+ class Placeholder$1 extends internal.SvelteComponent {
3854
3888
  constructor(options) {
3855
3889
  super();
3856
3890
  internal.init(this, options, instance, create_fragment$1, internal.safe_not_equal, { content: 0 });
3857
3891
  }
3858
3892
  }
3859
3893
 
3894
+ const PlaceholderServer = internal.create_ssr_component(($$result, $$props, $$bindings, slots) => {
3895
+ return "" + internal.escape($$props.content);
3896
+ });
3897
+ var Placeholder = typeof document === 'undefined' ? PlaceholderServer : Placeholder$1;
3898
+
3860
3899
  function create_fragment(ctx, Comp, props) {
3861
3900
  let c;
3862
3901
  let current;
@@ -3869,6 +3908,10 @@
3869
3908
  internal.create_component(c.$$.fragment);
3870
3909
  },
3871
3910
 
3911
+ l(nodes) {
3912
+ internal.claim_component(c.$$.fragment, nodes);
3913
+ },
3914
+
3872
3915
  m(target, anchor) {
3873
3916
  // @ts-ignore
3874
3917
  internal.mount_component(c, target, anchor);
@@ -3907,7 +3950,7 @@
3907
3950
 
3908
3951
  function renderServer(Comp, props) {
3909
3952
  const WrapperComp = internal.create_ssr_component(($$result, $$props, $$bindings, slots) => {
3910
- return "" + internal.validate_component(Comp, 'Comp').$$render($$result, props, {}, {});
3953
+ return "" + internal.validate_component(Comp, 'TableComponent').$$render($$result, props, {}, {});
3911
3954
  });
3912
3955
  return WrapperComp;
3913
3956
  }
@@ -3919,7 +3962,10 @@
3919
3962
  }
3920
3963
 
3921
3964
  function isSvelteClientComponent(component) {
3922
- return component.prototype instanceof internal.SvelteComponent;
3965
+ var _component$name, _component$name2;
3966
+
3967
+ let isHMR = ('__SVELTE_HMR' in window);
3968
+ return component.prototype instanceof internal.SvelteComponent || isHMR && ((_component$name = component.name) == null ? void 0 : _component$name.startsWith('Proxy<')) && ((_component$name2 = component.name) == null ? void 0 : _component$name2.endsWith('>'));
3923
3969
  }
3924
3970
 
3925
3971
  function isSvelteComponent(component) {
@@ -3973,6 +4019,7 @@
3973
4019
  onStateChange: () => {},
3974
4020
  // noop
3975
4021
  render,
4022
+ renderFallbackValue: null,
3976
4023
  ...store.get(optionsStore)
3977
4024
  };
3978
4025
  let instance = createTableInstance$1(resolvedOptions);