@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.
@@ -237,25 +237,19 @@
237
237
  }
238
238
  });
239
239
 
240
- // Sync TanStack sorting → server sorters
240
+ // Sync external sorters ? local sorting state (controlled mode only)
241
241
  $effect(() => {
242
- const newSorters: Sort[] = sorting.map(s => ({
243
- field: s.id,
244
- order: s.desc ? 'desc' as const : 'asc' as const,
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
- // Sync external sorters → TanStack sorting state
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
- sorting = typeof updater === 'function' ? updater(sorting) : updater;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/ui",
3
- "version": "0.34.7",
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": [