@urbicon-ui/sveltekit-utils 6.33.0 → 6.34.0

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/README.md CHANGED
@@ -75,6 +75,10 @@ Opt-in URL sync for `@urbicon-ui/table` in `mode="server"`: the `TableQuery` the
75
75
  itemsPerPage={25}
76
76
  initialPage={sync.initialQuery.page}
77
77
  initialGroupBy={sync.initialQuery.groupByKey}
78
+ initialSort={sync.initialQuery.sortColumn
79
+ ? { column: sync.initialQuery.sortColumn, direction: sync.initialQuery.sortDirection }
80
+ : undefined}
81
+ initialFilters={sync.initialQuery.activeFilters}
78
82
  queryFn={async (query, { signal }) => {
79
83
  sync.syncQuery(query); // mirror the query onto the URL (replaceState)
80
84
  const res = await fetch(`/api/users?${tableQueryToSearchParams(query)}`, { signal });
@@ -100,11 +104,11 @@ export const load = async ({ url }) => {
100
104
 
101
105
  **Design notes**
102
106
 
103
- - **Default elision** — values equal to `defaults` are not written; a table in its default state leaves the URL clean. Set `defaults` to the table's initial props (`itemsPerPage`, `initialPage`, `initialGroupBy`) so the elision baseline matches the state the table starts in.
107
+ - **Default elision** — values equal to `defaults` are not written; a table in its default state leaves the URL clean. Set `defaults` to the table's initial props (`itemsPerPage`, `initialPage`, `initialGroupBy`, and `sortColumn`/`sortDirection` when the table ships a baked-in `initialSort`) so the elision baseline matches the state the table starts in.
104
108
  - **Read tolerant, write strict** — unparsable params fall back to the defaults and malformed `filter` entries are skipped; serializing a structurally invalid query (non-positive page, unknown operator) throws instead of writing corrupt state.
105
109
  - **Namespacing** — `prefix: 't_'` scopes all keys (`?t_q=…`) for multiple synced tables on one page; unrelated params are always preserved.
106
110
  - **Types** — `TableQueryParams` is a structural mirror of the table's `TableQuery` (no dependency on `@urbicon-ui/table`; a parity test in the table package guards against drift).
107
- - **Seeding limits** — the table currently has no `initialSort` / initial-filter props, so sort/filter state parsed from the URL can seed your fetch but not the table's header indicators. Once those props exist, `initialQuery` covers them too.
111
+ - **Seeding** — every axis the URL carries can seed the table: `initialPage`, `initialGroupBy`, `initialSort`, `initialFilters` (plus controlled `searchTerm` with an `onSearchTermChange` write-back). The seeds land before the table's first query emission, so a shared URL's sort/filter params survive it the header indicator and filter chips show the URL state instead of the first emission wiping it. One precedence caveat: the `initial*` props seed only what `persistenceConfig` left empty — when both are active, a persisted sort/filter/group wins over the URL. And since persistence stores only non-empty values, a state the user _cleared_ reads as empty on the next load and the seed applies again. Scope or disable persistence for URL-driven tables if the link should be the source of truth.
108
112
 
109
113
  ## Cron Runner (`cron`)
110
114
 
@@ -145,8 +145,11 @@ export interface TableQueryUrlSyncOptions extends TableQueryUrlOptions {
145
145
  *
146
146
  * Two directions, both explicit:
147
147
  * - **URL → query**: `initialQuery` is parsed once at creation (SSR-safe) —
148
- * seed the table (`initialPage`, `initialGroupBy`, controlled `searchTerm`)
149
- * and run the first fetch from it.
148
+ * seed the table (`initialPage`, `initialGroupBy`, `initialSort`,
149
+ * `initialFilters`, controlled `searchTerm`) and run the first fetch from
150
+ * it. The seeds land before the table's first query emission, so URL sort/
151
+ * filter params survive it; note that a value restored via the table's
152
+ * `persistenceConfig` wins over an `initial*` seed for its axis.
150
153
  * - **query → URL**: pass `syncQuery` the query from `onQueryChange`, or call
151
154
  * it inside `queryFn` (when `queryFn` is set, `onQueryChange` does not
152
155
  * fire). It rewrites only its own — optionally prefixed — params via
@@ -175,8 +175,11 @@ export function useUrlArrayParam(key, opts) {
175
175
  *
176
176
  * Two directions, both explicit:
177
177
  * - **URL → query**: `initialQuery` is parsed once at creation (SSR-safe) —
178
- * seed the table (`initialPage`, `initialGroupBy`, controlled `searchTerm`)
179
- * and run the first fetch from it.
178
+ * seed the table (`initialPage`, `initialGroupBy`, `initialSort`,
179
+ * `initialFilters`, controlled `searchTerm`) and run the first fetch from
180
+ * it. The seeds land before the table's first query emission, so URL sort/
181
+ * filter params survive it; note that a value restored via the table's
182
+ * `persistenceConfig` wins over an `initial*` seed for its axis.
180
183
  * - **query → URL**: pass `syncQuery` the query from `onQueryChange`, or call
181
184
  * it inside `queryFn` (when `queryFn` is set, `onQueryChange` does not
182
185
  * fire). It rewrites only its own — optionally prefixed — params via
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urbicon-ui/sveltekit-utils",
3
- "version": "6.33.0",
3
+ "version": "6.34.0",
4
4
  "description": "SvelteKit helper utilities — createCronRunner and URL-state runes",
5
5
  "license": "MIT",
6
6
  "repository": {