@kayord/ui 4.0.1 → 4.0.3

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.
@@ -26,10 +26,8 @@
26
26
  </p>
27
27
  {/if}
28
28
  <p>
29
- {#if !table.options.manualPagination}
30
- {table.getPrePaginatedRowModel().rows.length.toLocaleString()}
31
- of {table.options.data.length.toLocaleString()} rows
32
- {/if}
29
+ {table.getRowModel().rows.length.toLocaleString()}
30
+ of {table.getRowCount().toLocaleString()} rows
33
31
  </p>
34
32
  </div>
35
33
  <div class="flex items-center gap-6 lg:gap-8">
@@ -1,5 +1,5 @@
1
1
  import { untrack } from "svelte";
2
- import { beforeNavigate } from "$app/navigation";
2
+ import { afterNavigate, beforeNavigate } from "$app/navigation";
3
3
  import { useSearchParams } from "runed/kit";
4
4
  import { defaultSearchParamSchema } from "./types";
5
5
  import { decodeColumnFilters, decodeGlobalFilter, decodePageIndex, decodeSorting, encodeColumnFilters, encodeSorting, } from "./table-search-params";
@@ -43,22 +43,35 @@ export function useTableUrlSync(table, options) {
43
43
  table.setPageIndex(decodePageIndex());
44
44
  if (enabled.columnFilters)
45
45
  table.setColumnFilters(decodeColumnFilters() ?? []);
46
- // When navigating with new sort/search/filter params, snap back to the first page
47
- // unless the target URL explicitly points at a later page.
46
+ // When navigating with new sort/search/filter params, snap back to the first
47
+ // page unless the target URL explicitly points at a later page. Only same-route
48
+ // query changes count: resetting on a cross-route navigation would mutate state
49
+ // mid-navigation, and the write-back effect below would then issue a competing
50
+ // `goto("?…")` that cancels the in-flight navigation (links off the table page
51
+ // would "do nothing" whenever the table isn't already on page 1).
52
+ let leavePage = false;
48
53
  beforeNavigate((navigation) => {
54
+ const from = navigation.from?.url;
55
+ const to = navigation.to?.url;
56
+ if (!from || !to)
57
+ return;
58
+ if (from.pathname !== to.pathname) {
59
+ leavePage = true;
60
+ return;
61
+ }
49
62
  if (!enabled.pagination)
50
63
  return;
51
- const targetPage = Number(navigation.to?.url.searchParams.get("page") ?? "0");
52
- const queryChanged = (enabled.sorting &&
53
- navigation.from?.url.searchParams.get("sort") != navigation.to?.url.searchParams.get("sort")) ||
54
- (enabled.globalFilter &&
55
- navigation.from?.url.searchParams.get("search") != navigation.to?.url.searchParams.get("search")) ||
56
- (enabled.columnFilters &&
57
- navigation.from?.url.searchParams.get("filter") != navigation.to?.url.searchParams.get("filter"));
64
+ const targetPage = Number(to.searchParams.get("page") ?? "0");
65
+ const queryChanged = (enabled.sorting && from.searchParams.get("sort") != to.searchParams.get("sort")) ||
66
+ (enabled.globalFilter && from.searchParams.get("search") != to.searchParams.get("search")) ||
67
+ (enabled.columnFilters && from.searchParams.get("filter") != to.searchParams.get("filter"));
58
68
  if (queryChanged && (!Number.isFinite(targetPage) || targetPage <= 0)) {
59
69
  table.resetPageIndex();
60
70
  }
61
71
  });
72
+ afterNavigate(() => {
73
+ leavePage = false;
74
+ });
62
75
  // Write atoms back to the URL. Only the enabled atoms are read (and thus
63
76
  // tracked) so the effect doesn't re-run on unrelated state (e.g. row
64
77
  // selection), and disabled params are left untouched in the URL.
@@ -68,6 +81,10 @@ export function useTableUrlSync(table, options) {
68
81
  const sorting = enabled.sorting ? table.atoms.sorting.get() : undefined;
69
82
  const columnFilters = enabled.columnFilters ? table.atoms.columnFilters.get() : undefined;
70
83
  untrack(() => {
84
+ // Skip writes while leaving the route: state mutating mid-navigation
85
+ // (e.g. a debounced filter landing) must not `goto` over the target URL.
86
+ if (leavePage)
87
+ return;
71
88
  if (enabled.globalFilter)
72
89
  params.search = search;
73
90
  if (enabled.pagination && page !== undefined)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kayord/ui",
3
3
  "private": false,
4
- "version": "4.0.1",
4
+ "version": "4.0.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/kayordDX/ui.git"
@@ -107,46 +107,46 @@
107
107
  }
108
108
  },
109
109
  "dependencies": {
110
- "bits-ui": "2.18.1",
110
+ "bits-ui": "2.19.0",
111
111
  "clsx": "^2.1.1",
112
112
  "runed": "^0.37.1",
113
113
  "tailwind-merge": "^3.6.0",
114
114
  "tailwind-variants": "^3.3.1",
115
- "zod": "4.4.3"
115
+ "zod": "4.5.2"
116
116
  },
117
117
  "devDependencies": {
118
118
  "@eslint/compat": "^2.1.0",
119
119
  "@eslint/js": "^10.0.1",
120
120
  "@internationalized/date": "^3.12.3",
121
- "@lucide/svelte": "^1.31.0",
121
+ "@lucide/svelte": "^1.37.0",
122
122
  "@sveltejs/adapter-auto": "^7.0.1",
123
- "@sveltejs/kit": "^2.70.2",
123
+ "@sveltejs/kit": "^2.70.3",
124
124
  "@sveltejs/package": "^2.5.8",
125
125
  "@sveltejs/vite-plugin-svelte": "7.3.0",
126
126
  "@tailwindcss/vite": "^4.3.3",
127
- "@tanstack/svelte-table": "^9.1.2",
127
+ "@tanstack/svelte-table": "^9.2.4",
128
128
  "@types/d3-scale": "^4.0.9",
129
- "@types/d3-shape": "^3.1.8",
130
- "@vitest/browser": "^4.1.10",
131
- "@vitest/browser-playwright": "^4.1.10",
129
+ "@types/d3-shape": "^3.2.0",
130
+ "@vitest/browser": "^4.1.11",
131
+ "@vitest/browser-playwright": "^4.1.11",
132
132
  "d3-scale": "^4.0.2",
133
133
  "d3-shape": "^3.2.0",
134
134
  "embla-carousel-svelte": "^8.6.0",
135
- "eslint": "^10.8.1",
135
+ "eslint": "^10.9.1",
136
136
  "eslint-config-prettier": "^10.1.8",
137
137
  "eslint-plugin-svelte": "^3.23.0",
138
138
  "formsnap": "^2.0.1",
139
139
  "globals": "^17.11.0",
140
- "layerchart": "^2.2.0",
140
+ "layerchart": "^2.3.1",
141
141
  "mode-watcher": "^1.1.0",
142
142
  "paneforge": "^1.0.2",
143
143
  "playwright": "^1.62.1",
144
144
  "prettier": "^3.9.6",
145
145
  "prettier-plugin-svelte": "4.1.1",
146
146
  "prettier-plugin-tailwindcss": "^0.8.1",
147
- "publint": "^0.3.23",
148
- "shadcn-svelte": "^1.5.0",
149
- "svelte": "^5.56.9",
147
+ "publint": "^0.3.24",
148
+ "shadcn-svelte": "^1.5.1",
149
+ "svelte": "^5.57.0",
150
150
  "svelte-check": "^4.7.6",
151
151
  "svelte-sonner": "^1.2.1",
152
152
  "sveltekit-superforms": "^2.30.2",
@@ -154,10 +154,10 @@
154
154
  "tslib": "^2.8.1",
155
155
  "tw-animate-css": "1.4.0",
156
156
  "typescript": "^6.0.3",
157
- "typescript-eslint": "^8.67.0",
157
+ "typescript-eslint": "^8.68.0",
158
158
  "vaul-svelte": "1.0.0-next.7",
159
- "vite": "^8.2.1",
160
- "vitest": "^4.1.10",
159
+ "vite": "^8.2.2",
160
+ "vitest": "^4.1.11",
161
161
  "vitest-browser-svelte": "^3.0.0"
162
162
  },
163
163
  "svelte": "./dist/index.js",