@svadmin/ui 0.34.6 → 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 +31 -21
- package/package.json +5 -4
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
import {
|
|
5
5
|
createTable,
|
|
6
6
|
createCoreRowModel,
|
|
7
|
+
type ColumnDef,
|
|
8
|
+
type SortingState,
|
|
9
|
+
type RowSelectionState,
|
|
10
|
+
type ColumnVisibilityState,
|
|
11
|
+
type ExpandedState,
|
|
12
|
+
} from '@tanstack/svelte-table';
|
|
13
|
+
import {
|
|
7
14
|
column_getCanSort,
|
|
8
15
|
column_getIsSorted,
|
|
9
16
|
column_toggleSorting,
|
|
@@ -21,12 +28,7 @@
|
|
|
21
28
|
row_getIsExpanded,
|
|
22
29
|
row_toggleExpanded,
|
|
23
30
|
cell_getValue,
|
|
24
|
-
|
|
25
|
-
type SortingState,
|
|
26
|
-
type RowSelectionState,
|
|
27
|
-
type ColumnVisibilityState,
|
|
28
|
-
type ExpandedState,
|
|
29
|
-
} from '@tanstack/svelte-table';
|
|
31
|
+
} from '@tanstack/svelte-table/static-functions';
|
|
30
32
|
|
|
31
33
|
import { useList, useDelete, useDeleteMany, getResource, notify } from '@svadmin/core';
|
|
32
34
|
import type { Pagination as PaginationState, Sort, Filter, FieldDefinition } from '@svadmin/core';
|
|
@@ -235,25 +237,19 @@
|
|
|
235
237
|
}
|
|
236
238
|
});
|
|
237
239
|
|
|
238
|
-
// Sync
|
|
240
|
+
// Sync external sorters ? local sorting state (controlled mode only)
|
|
239
241
|
$effect(() => {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}));
|
|
244
|
-
if (JSON.stringify(newSorters) !== JSON.stringify(sorters)) {
|
|
245
|
-
sorters = newSorters;
|
|
242
|
+
if (!externalSorters) return;
|
|
243
|
+
if (JSON.stringify(externalSorters) !== JSON.stringify(sorters)) {
|
|
244
|
+
sorters = externalSorters;
|
|
246
245
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
$effect(() => {
|
|
251
|
-
const newSorting = sorters.map(s => ({ id: s.field, desc: s.order === 'desc' }));
|
|
252
|
-
if (JSON.stringify(newSorting) !== JSON.stringify(sorting)) {
|
|
253
|
-
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;
|
|
254
249
|
}
|
|
255
250
|
});
|
|
256
251
|
|
|
252
|
+
|
|
257
253
|
// ─── Auto-generate columns from resource fields ──────────────
|
|
258
254
|
const visibleFields = $derived(
|
|
259
255
|
resource.fields.filter(f => f.showInList !== false)
|
|
@@ -309,7 +305,21 @@
|
|
|
309
305
|
get columnOrder() { return columnOrder; },
|
|
310
306
|
},
|
|
311
307
|
onSortingChange: (updater: any) => {
|
|
312
|
-
|
|
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
|
+
}
|
|
313
323
|
},
|
|
314
324
|
onColumnVisibilityChange: (updater: any) => {
|
|
315
325
|
columnVisibility = typeof updater === 'function' ? updater(columnVisibility) : updater;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/ui",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.8",
|
|
4
4
|
"description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"./components/*": "./dist/components/*"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@svadmin/core": "^0.25.
|
|
37
|
-
"@tanstack/svelte-query": "^6.
|
|
36
|
+
"@svadmin/core": "^0.25.4",
|
|
37
|
+
"@tanstack/svelte-query": "^6.1.29",
|
|
38
38
|
"highlight.js": "^11.11.1",
|
|
39
39
|
"isomorphic-dompurify": "^3.7.1",
|
|
40
40
|
"marked": "^17.0.5",
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@lucide/svelte": "^1.7.0",
|
|
72
|
-
"@tanstack/svelte-table": "9.0.0-alpha.
|
|
72
|
+
"@tanstack/svelte-table": "9.0.0-alpha.45",
|
|
73
|
+
"@tanstack/table-core": "9.0.0-alpha.43",
|
|
73
74
|
"bits-ui": "^2.17.1",
|
|
74
75
|
"clsx": "^2.1.1",
|
|
75
76
|
"cmdk-sv": "^0.0.19",
|