@tanstack/svelte-table 8.5.16 → 8.5.18

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.
@@ -4024,7 +4024,7 @@ var drawChart = (function (exports) {
4024
4024
  </script>
4025
4025
  <script>
4026
4026
  /*<!--*/
4027
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"8283-163"},{"name":"svelte-table/src","children":[{"uid":"8283-165","name":"placeholder.svelte"},{"uid":"8283-167","name":"placeholder.ts"},{"uid":"8283-169","name":"render-component.ts"},{"uid":"8283-171","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"8283-163":{"renderedLength":125390,"gzipLength":22307,"brotliLength":0,"mainUid":"8283-162"},"8283-165":{"renderedLength":927,"gzipLength":445,"brotliLength":0,"mainUid":"8283-164"},"8283-167":{"renderedLength":246,"gzipLength":186,"brotliLength":0,"mainUid":"8283-166"},"8283-169":{"renderedLength":1447,"gzipLength":537,"brotliLength":0,"mainUid":"8283-168"},"8283-171":{"renderedLength":2930,"gzipLength":948,"brotliLength":0,"mainUid":"8283-170"}},"nodeMetas":{"8283-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"8283-163"},"imported":[],"importedBy":[{"uid":"8283-170"}]},"8283-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"8283-165"},"imported":[{"uid":"8283-172"}],"importedBy":[{"uid":"8283-166"}]},"8283-166":{"id":"/packages/svelte-table/src/placeholder.ts","moduleParts":{"index.production.js":"8283-167"},"imported":[{"uid":"8283-172"},{"uid":"8283-164"}],"importedBy":[{"uid":"8283-170"}]},"8283-168":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"8283-169"},"imported":[{"uid":"8283-172"}],"importedBy":[{"uid":"8283-170"}]},"8283-170":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"8283-171"},"imported":[{"uid":"8283-162"},{"uid":"8283-166"},{"uid":"8283-172"},{"uid":"8283-173"},{"uid":"8283-168"}],"importedBy":[],"isEntry":true},"8283-172":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"8283-170"},{"uid":"8283-166"},{"uid":"8283-168"},{"uid":"8283-164"}],"isExternal":true},"8283-173":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"8283-170"}],"isExternal":true}},"env":{"rollup":"2.79.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4027
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"0c68-163"},{"name":"svelte-table/src","children":[{"uid":"0c68-165","name":"placeholder.svelte"},{"uid":"0c68-167","name":"placeholder.ts"},{"uid":"0c68-169","name":"render-component.ts"},{"uid":"0c68-171","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"0c68-163":{"renderedLength":126174,"gzipLength":22385,"brotliLength":0,"mainUid":"0c68-162"},"0c68-165":{"renderedLength":927,"gzipLength":445,"brotliLength":0,"mainUid":"0c68-164"},"0c68-167":{"renderedLength":246,"gzipLength":186,"brotliLength":0,"mainUid":"0c68-166"},"0c68-169":{"renderedLength":1447,"gzipLength":537,"brotliLength":0,"mainUid":"0c68-168"},"0c68-171":{"renderedLength":2930,"gzipLength":948,"brotliLength":0,"mainUid":"0c68-170"}},"nodeMetas":{"0c68-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"0c68-163"},"imported":[],"importedBy":[{"uid":"0c68-170"}]},"0c68-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"0c68-165"},"imported":[{"uid":"0c68-172"}],"importedBy":[{"uid":"0c68-166"}]},"0c68-166":{"id":"/packages/svelte-table/src/placeholder.ts","moduleParts":{"index.production.js":"0c68-167"},"imported":[{"uid":"0c68-172"},{"uid":"0c68-164"}],"importedBy":[{"uid":"0c68-170"}]},"0c68-168":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"0c68-169"},"imported":[{"uid":"0c68-172"}],"importedBy":[{"uid":"0c68-170"}]},"0c68-170":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"0c68-171"},"imported":[{"uid":"0c68-162"},{"uid":"0c68-166"},{"uid":"0c68-172"},{"uid":"0c68-173"},{"uid":"0c68-168"}],"importedBy":[],"isEntry":true},"0c68-172":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"0c68-170"},{"uid":"0c68-166"},{"uid":"0c68-168"},{"uid":"0c68-164"}],"isExternal":true},"0c68-173":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"0c68-170"}],"isExternal":true}},"env":{"rollup":"2.79.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4028
4028
 
4029
4029
  const run = () => {
4030
4030
  const width = window.innerWidth;
@@ -11,25 +11,25 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "8283-175"
14
+ "uid": "0c68-175"
15
15
  },
16
16
  {
17
17
  "name": "svelte-table/src",
18
18
  "children": [
19
19
  {
20
- "uid": "8283-177",
20
+ "uid": "0c68-177",
21
21
  "name": "placeholder.svelte"
22
22
  },
23
23
  {
24
- "uid": "8283-179",
24
+ "uid": "0c68-179",
25
25
  "name": "placeholder.ts"
26
26
  },
27
27
  {
28
- "uid": "8283-181",
28
+ "uid": "0c68-181",
29
29
  "name": "render-component.ts"
30
30
  },
31
31
  {
32
- "uid": "8283-183",
32
+ "uid": "0c68-183",
33
33
  "name": "index.ts"
34
34
  }
35
35
  ]
@@ -42,153 +42,153 @@
42
42
  "isRoot": true
43
43
  },
44
44
  "nodeParts": {
45
- "8283-175": {
46
- "renderedLength": 125390,
47
- "gzipLength": 22307,
45
+ "0c68-175": {
46
+ "renderedLength": 126174,
47
+ "gzipLength": 22385,
48
48
  "brotliLength": 0,
49
- "mainUid": "8283-174"
49
+ "mainUid": "0c68-174"
50
50
  },
51
- "8283-177": {
51
+ "0c68-177": {
52
52
  "renderedLength": 927,
53
53
  "gzipLength": 445,
54
54
  "brotliLength": 0,
55
- "mainUid": "8283-176"
55
+ "mainUid": "0c68-176"
56
56
  },
57
- "8283-179": {
57
+ "0c68-179": {
58
58
  "renderedLength": 246,
59
59
  "gzipLength": 186,
60
60
  "brotliLength": 0,
61
- "mainUid": "8283-178"
61
+ "mainUid": "0c68-178"
62
62
  },
63
- "8283-181": {
63
+ "0c68-181": {
64
64
  "renderedLength": 1447,
65
65
  "gzipLength": 537,
66
66
  "brotliLength": 0,
67
- "mainUid": "8283-180"
67
+ "mainUid": "0c68-180"
68
68
  },
69
- "8283-183": {
69
+ "0c68-183": {
70
70
  "renderedLength": 2930,
71
71
  "gzipLength": 948,
72
72
  "brotliLength": 0,
73
- "mainUid": "8283-182"
73
+ "mainUid": "0c68-182"
74
74
  }
75
75
  },
76
76
  "nodeMetas": {
77
- "8283-174": {
77
+ "0c68-174": {
78
78
  "id": "/packages/table-core/build/esm/index.js",
79
79
  "moduleParts": {
80
- "index.production.js": "8283-175"
80
+ "index.production.js": "0c68-175"
81
81
  },
82
82
  "imported": [],
83
83
  "importedBy": [
84
84
  {
85
- "uid": "8283-182"
85
+ "uid": "0c68-182"
86
86
  }
87
87
  ]
88
88
  },
89
- "8283-176": {
89
+ "0c68-176": {
90
90
  "id": "/packages/svelte-table/src/placeholder.svelte",
91
91
  "moduleParts": {
92
- "index.production.js": "8283-177"
92
+ "index.production.js": "0c68-177"
93
93
  },
94
94
  "imported": [
95
95
  {
96
- "uid": "8283-184"
96
+ "uid": "0c68-184"
97
97
  }
98
98
  ],
99
99
  "importedBy": [
100
100
  {
101
- "uid": "8283-178"
101
+ "uid": "0c68-178"
102
102
  }
103
103
  ]
104
104
  },
105
- "8283-178": {
105
+ "0c68-178": {
106
106
  "id": "/packages/svelte-table/src/placeholder.ts",
107
107
  "moduleParts": {
108
- "index.production.js": "8283-179"
108
+ "index.production.js": "0c68-179"
109
109
  },
110
110
  "imported": [
111
111
  {
112
- "uid": "8283-184"
112
+ "uid": "0c68-184"
113
113
  },
114
114
  {
115
- "uid": "8283-176"
115
+ "uid": "0c68-176"
116
116
  }
117
117
  ],
118
118
  "importedBy": [
119
119
  {
120
- "uid": "8283-182"
120
+ "uid": "0c68-182"
121
121
  }
122
122
  ]
123
123
  },
124
- "8283-180": {
124
+ "0c68-180": {
125
125
  "id": "/packages/svelte-table/src/render-component.ts",
126
126
  "moduleParts": {
127
- "index.production.js": "8283-181"
127
+ "index.production.js": "0c68-181"
128
128
  },
129
129
  "imported": [
130
130
  {
131
- "uid": "8283-184"
131
+ "uid": "0c68-184"
132
132
  }
133
133
  ],
134
134
  "importedBy": [
135
135
  {
136
- "uid": "8283-182"
136
+ "uid": "0c68-182"
137
137
  }
138
138
  ]
139
139
  },
140
- "8283-182": {
140
+ "0c68-182": {
141
141
  "id": "/packages/svelte-table/src/index.ts",
142
142
  "moduleParts": {
143
- "index.production.js": "8283-183"
143
+ "index.production.js": "0c68-183"
144
144
  },
145
145
  "imported": [
146
146
  {
147
- "uid": "8283-174"
147
+ "uid": "0c68-174"
148
148
  },
149
149
  {
150
- "uid": "8283-178"
150
+ "uid": "0c68-178"
151
151
  },
152
152
  {
153
- "uid": "8283-184"
153
+ "uid": "0c68-184"
154
154
  },
155
155
  {
156
- "uid": "8283-185"
156
+ "uid": "0c68-185"
157
157
  },
158
158
  {
159
- "uid": "8283-180"
159
+ "uid": "0c68-180"
160
160
  }
161
161
  ],
162
162
  "importedBy": [],
163
163
  "isEntry": true
164
164
  },
165
- "8283-184": {
165
+ "0c68-184": {
166
166
  "id": "svelte/internal",
167
167
  "moduleParts": {},
168
168
  "imported": [],
169
169
  "importedBy": [
170
170
  {
171
- "uid": "8283-182"
171
+ "uid": "0c68-182"
172
172
  },
173
173
  {
174
- "uid": "8283-178"
174
+ "uid": "0c68-178"
175
175
  },
176
176
  {
177
- "uid": "8283-180"
177
+ "uid": "0c68-180"
178
178
  },
179
179
  {
180
- "uid": "8283-176"
180
+ "uid": "0c68-176"
181
181
  }
182
182
  ],
183
183
  "isExternal": true
184
184
  },
185
- "8283-185": {
185
+ "0c68-185": {
186
186
  "id": "svelte/store",
187
187
  "moduleParts": {},
188
188
  "imported": [],
189
189
  "importedBy": [
190
190
  {
191
- "uid": "8283-182"
191
+ "uid": "0c68-182"
192
192
  }
193
193
  ],
194
194
  "isExternal": true
@@ -119,6 +119,9 @@
119
119
  let result = originalRow;
120
120
  for (const key of accessorKey.split('.')) {
121
121
  result = result[key];
122
+ if (result === undefined) {
123
+ throw new Error(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
124
+ }
122
125
  }
123
126
  return result;
124
127
  };
@@ -2671,6 +2674,7 @@
2671
2674
  original,
2672
2675
  depth,
2673
2676
  _valuesCache: {},
2677
+ _uniqueValuesCache: {},
2674
2678
  getValue: columnId => {
2675
2679
  if (row._valuesCache.hasOwnProperty(columnId)) {
2676
2680
  return row._valuesCache[columnId];
@@ -2682,6 +2686,21 @@
2682
2686
  row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
2683
2687
  return row._valuesCache[columnId];
2684
2688
  },
2689
+ getUniqueValues: columnId => {
2690
+ if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
2691
+ return row._uniqueValuesCache[columnId];
2692
+ }
2693
+ const column = table.getColumn(columnId);
2694
+ if (!column.accessorFn) {
2695
+ return undefined;
2696
+ }
2697
+ if (!column.columnDef.getUniqueValues) {
2698
+ row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
2699
+ return row._uniqueValuesCache[columnId];
2700
+ }
2701
+ row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
2702
+ return row._uniqueValuesCache[columnId];
2703
+ },
2685
2704
  renderValue: columnId => row.getValue(columnId) ?? table.options.renderFallbackValue,
2686
2705
  subRows: subRows ?? [],
2687
2706
  getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
@@ -3022,12 +3041,14 @@
3022
3041
  return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3023
3042
  let facetedUniqueValues = new Map();
3024
3043
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3025
- var _facetedRowModel$flat;
3026
- const value = (_facetedRowModel$flat = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3027
- if (facetedUniqueValues.has(value)) {
3028
- facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
3029
- } else {
3030
- facetedUniqueValues.set(value, 1);
3044
+ const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
3045
+ for (let j = 0; j < values.length; j++) {
3046
+ const value = values[j];
3047
+ if (facetedUniqueValues.has(value)) {
3048
+ facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
3049
+ } else {
3050
+ facetedUniqueValues.set(value, 1);
3051
+ }
3031
3052
  }
3032
3053
  }
3033
3054
  return facetedUniqueValues;
@@ -3041,17 +3062,20 @@
3041
3062
  function getFacetedMinMaxValues() {
3042
3063
  return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3043
3064
  var _facetedRowModel$flat;
3044
- const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3065
+ const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getUniqueValues(columnId);
3045
3066
  if (typeof firstValue === 'undefined') {
3046
3067
  return undefined;
3047
3068
  }
3048
3069
  let facetedMinMaxValues = [firstValue, firstValue];
3049
3070
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3050
- const value = facetedRowModel.flatRows[i].getValue(columnId);
3051
- if (value < facetedMinMaxValues[0]) {
3052
- facetedMinMaxValues[0] = value;
3053
- } else if (value > facetedMinMaxValues[1]) {
3054
- facetedMinMaxValues[1] = value;
3071
+ const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
3072
+ for (let j = 0; j < values.length; j++) {
3073
+ const value = values[j];
3074
+ if (value < facetedMinMaxValues[0]) {
3075
+ facetedMinMaxValues[0] = value;
3076
+ } else if (value > facetedMinMaxValues[1]) {
3077
+ facetedMinMaxValues[1] = value;
3078
+ }
3055
3079
  }
3056
3080
  }
3057
3081
  return facetedMinMaxValues;