@svadmin/ui 0.34.7 → 0.34.8
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/dist/components/AutoTable.svelte +23 -15
- package/package.json +1 -1
|
@@ -237,25 +237,19 @@
|
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
// Sync
|
|
240
|
+
// Sync external sorters ? local sorting state (controlled mode only)
|
|
241
241
|
$effect(() => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}));
|
|
246
|
-
if (JSON.stringify(newSorters) !== JSON.stringify(sorters)) {
|
|
247
|
-
sorters = newSorters;
|
|
242
|
+
if (!externalSorters) return;
|
|
243
|
+
if (JSON.stringify(externalSorters) !== JSON.stringify(sorters)) {
|
|
244
|
+
sorters = externalSorters;
|
|
248
245
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
$effect(() => {
|
|
253
|
-
const newSorting = sorters.map(s => ({ id: s.field, desc: s.order === 'desc' }));
|
|
254
|
-
if (JSON.stringify(newSorting) !== JSON.stringify(sorting)) {
|
|
255
|
-
sorting = newSorting;
|
|
246
|
+
const nextSorting = externalSorters.map(s => ({ id: s.field, desc: s.order === 'desc' }));
|
|
247
|
+
if (JSON.stringify(nextSorting) !== JSON.stringify(sorting)) {
|
|
248
|
+
sorting = nextSorting;
|
|
256
249
|
}
|
|
257
250
|
});
|
|
258
251
|
|
|
252
|
+
|
|
259
253
|
// ─── Auto-generate columns from resource fields ──────────────
|
|
260
254
|
const visibleFields = $derived(
|
|
261
255
|
resource.fields.filter(f => f.showInList !== false)
|
|
@@ -311,7 +305,21 @@
|
|
|
311
305
|
get columnOrder() { return columnOrder; },
|
|
312
306
|
},
|
|
313
307
|
onSortingChange: (updater: any) => {
|
|
314
|
-
|
|
308
|
+
const nextSorting = typeof updater === 'function' ? updater(sorting) : updater;
|
|
309
|
+
sorting = nextSorting;
|
|
310
|
+
|
|
311
|
+
const nextSorters: Sort[] = nextSorting.map((s: any) => ({
|
|
312
|
+
field: s.id,
|
|
313
|
+
order: s.desc ? 'desc' as const : 'asc' as const,
|
|
314
|
+
}));
|
|
315
|
+
|
|
316
|
+
if (JSON.stringify(nextSorters) !== JSON.stringify(sorters)) {
|
|
317
|
+
sorters = nextSorters;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if ((pagination.current ?? 1) !== 1) {
|
|
321
|
+
pagination = { ...pagination, current: 1 };
|
|
322
|
+
}
|
|
315
323
|
},
|
|
316
324
|
onColumnVisibilityChange: (updater: any) => {
|
|
317
325
|
columnVisibility = typeof updater === 'function' ? updater(columnVisibility) : updater;
|