@trackunit/react-components 3.7.4-alpha-76dda49b705.0 → 3.8.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/index.cjs.js +24 -19
- package/index.esm.js +24 -19
- package/package.json +6 -6
- package/src/hooks/persistence/usePersistedState.d.ts +8 -4
- package/translation.cjs.js +1 -0
- package/translation.esm.js +1 -0
- package/translation10.cjs.js +1 -0
- package/translation10.esm.js +1 -0
- package/translation11.cjs.js +1 -0
- package/translation11.esm.js +1 -0
- package/translation12.cjs.js +1 -0
- package/translation12.esm.js +1 -0
- package/translation13.cjs.js +1 -0
- package/translation13.esm.js +1 -0
- package/translation14.cjs.js +1 -0
- package/translation14.esm.js +1 -0
- package/translation15.cjs.js +1 -0
- package/translation15.esm.js +1 -0
- package/translation16.cjs.js +1 -0
- package/translation16.esm.js +1 -0
- package/translation17.cjs.js +1 -0
- package/translation17.esm.js +1 -0
- package/translation2.cjs.js +1 -0
- package/translation2.esm.js +1 -0
- package/translation3.cjs.js +1 -0
- package/translation3.esm.js +1 -0
- package/translation4.cjs.js +1 -0
- package/translation4.esm.js +1 -0
- package/translation5.cjs.js +1 -0
- package/translation5.esm.js +1 -0
- package/translation6.cjs.js +1 -0
- package/translation6.esm.js +1 -0
- package/translation7.cjs.js +1 -0
- package/translation7.esm.js +1 -0
- package/translation8.cjs.js +1 -0
- package/translation8.esm.js +1 -0
- package/translation9.cjs.js +1 -0
- package/translation9.esm.js +1 -0
package/index.cjs.js
CHANGED
|
@@ -13685,11 +13685,9 @@ const useHashParamSync = ({ key, enabled = true, onExternalChange, replace: repl
|
|
|
13685
13685
|
// `navigate` directly from inside the rAF callback. Tanstack Router's
|
|
13686
13686
|
// `router.state.status === "pending"` is common during the first paint
|
|
13687
13687
|
// of a route (loaders, suspense), and an earlier implementation that
|
|
13688
|
-
// simply returned in that case lost the write outright
|
|
13689
|
-
//
|
|
13690
|
-
//
|
|
13691
|
-
// router the canonical hash never got populated and users saw an
|
|
13692
|
-
// intermittent "hash not set on initial visit" bug.
|
|
13688
|
+
// simply returned in that case lost the write outright. A one-shot write
|
|
13689
|
+
// (a legacy search-param migrated into the hash, or the first edit)
|
|
13690
|
+
// would otherwise never land.
|
|
13693
13691
|
//
|
|
13694
13692
|
// The queue + retry pattern below makes writes reliable:
|
|
13695
13693
|
// - `updateHashParam` stores the latest attempted write in
|
|
@@ -14076,9 +14074,9 @@ const useSearchParamSync = ({ key, enabled = true, onExternalChange, replace: re
|
|
|
14076
14074
|
// `navigate` directly from inside the rAF callback. See the matching
|
|
14077
14075
|
// comment block in `useHashParamSync` for the full rationale — in short,
|
|
14078
14076
|
// navigating while `router.state.status === "pending"` was previously
|
|
14079
|
-
// dropped silently, which lost
|
|
14080
|
-
//
|
|
14081
|
-
// pending phase.
|
|
14077
|
+
// dropped silently, which lost a one-shot write (a legacy search param
|
|
14078
|
+
// migrated into the URL, or the first edit) on routes that mount during
|
|
14079
|
+
// a loader-driven pending phase.
|
|
14082
14080
|
const flushPendingWrite = react.useCallback(() => {
|
|
14083
14081
|
const pending = pendingWriteRef.current;
|
|
14084
14082
|
if (pending === null) {
|
|
@@ -14200,10 +14198,14 @@ const rawLocalStorage = {
|
|
|
14200
14198
|
* On mount the hook resolves the initial state as follows:
|
|
14201
14199
|
* - If the canonical URL slot (search OR hash, per `urlLocation`) holds a
|
|
14202
14200
|
* value, decode it and pass through `validate`.
|
|
14203
|
-
* - In `urlLocation: "hash"` mode, if the canonical hash slot
|
|
14204
|
-
* but a **legacy** `?<key>=...` search param is present, decode and
|
|
14205
|
-
* validate that as a one-shot fallback.
|
|
14206
|
-
* the
|
|
14201
|
+
* - In `urlLocation: "hash"` mode, if the canonical hash slot has no valid
|
|
14202
|
+
* value but a **legacy** `?<key>=...` search param is present, decode and
|
|
14203
|
+
* validate that as a one-shot fallback. The value is copied into the hash
|
|
14204
|
+
* and the search param is stripped via a `replace` navigation.
|
|
14205
|
+
* - A value that comes only from localStorage is not written to the URL.
|
|
14206
|
+
* Copying it on load left a layout in history, bookmarks, and login
|
|
14207
|
+
* redirects, which then replayed an older layout over the saved one
|
|
14208
|
+
* (GLU-2396). The URL is written when the user changes the state.
|
|
14207
14209
|
* - If localStorage is enabled, read and validate its value.
|
|
14208
14210
|
* - When `mergeWithStorageOnRead` is `false` (default): URL state wins
|
|
14209
14211
|
* entirely when present, otherwise fall back to localStorage.
|
|
@@ -14389,7 +14391,9 @@ const usePersistedState = ({ key, validate, serialize, toUrlValue, fromUrlValue,
|
|
|
14389
14391
|
initialState: storageState,
|
|
14390
14392
|
canonicalUrlHasValidState: false,
|
|
14391
14393
|
canonicalUrlPayload: undefined,
|
|
14392
|
-
|
|
14394
|
+
// Leave the URL alone. A storage-only load must not grow a hash,
|
|
14395
|
+
// or the next history/bookmark/login of this page replays it.
|
|
14396
|
+
needsUrlRestore: false,
|
|
14393
14397
|
};
|
|
14394
14398
|
}
|
|
14395
14399
|
return {
|
|
@@ -14400,7 +14404,7 @@ const usePersistedState = ({ key, validate, serialize, toUrlValue, fromUrlValue,
|
|
|
14400
14404
|
};
|
|
14401
14405
|
}, [decode, enabled, localStorageEnabled, storageKey, mergeWithStorageOnRead]);
|
|
14402
14406
|
// Every URL write goes through here so the ownership stamp is applied
|
|
14403
|
-
// uniformly (user edits
|
|
14407
|
+
// uniformly (user edits and legacy search-param migration).
|
|
14404
14408
|
const encodeForUrl = react.useCallback((state) => {
|
|
14405
14409
|
const urlValue = toUrlValueRef.current ? toUrlValueRef.current(state) : state;
|
|
14406
14410
|
return encode(currentUrlOwner === undefined ? urlValue : wrapUrlOwner(urlValue, currentUrlOwner));
|
|
@@ -14474,11 +14478,12 @@ const usePersistedState = ({ key, validate, serialize, toUrlValue, fromUrlValue,
|
|
|
14474
14478
|
if (hasRestoredUrlRef.current) {
|
|
14475
14479
|
return;
|
|
14476
14480
|
}
|
|
14477
|
-
//
|
|
14478
|
-
//
|
|
14479
|
-
//
|
|
14480
|
-
//
|
|
14481
|
-
//
|
|
14481
|
+
// Only a legacy search param is copied into the hash. Storage is not:
|
|
14482
|
+
// mirroring it on load is what put a layout into every history entry
|
|
14483
|
+
// (GLU-2396). Gate on `canonicalUrlHasValidState`, not on the raw
|
|
14484
|
+
// `searchValue`: an undecodable string in the hash slot must not block
|
|
14485
|
+
// the legacy copy, or the migration strips the search param and the
|
|
14486
|
+
// bad string is the only state left on the next reload.
|
|
14482
14487
|
if (!enabled || !needsUrlRestore || initialState === undefined || canonicalUrlHasValidState) {
|
|
14483
14488
|
return;
|
|
14484
14489
|
}
|
package/index.esm.js
CHANGED
|
@@ -13684,11 +13684,9 @@ const useHashParamSync = ({ key, enabled = true, onExternalChange, replace: repl
|
|
|
13684
13684
|
// `navigate` directly from inside the rAF callback. Tanstack Router's
|
|
13685
13685
|
// `router.state.status === "pending"` is common during the first paint
|
|
13686
13686
|
// of a route (loaders, suspense), and an earlier implementation that
|
|
13687
|
-
// simply returned in that case lost the write outright
|
|
13688
|
-
//
|
|
13689
|
-
//
|
|
13690
|
-
// router the canonical hash never got populated and users saw an
|
|
13691
|
-
// intermittent "hash not set on initial visit" bug.
|
|
13687
|
+
// simply returned in that case lost the write outright. A one-shot write
|
|
13688
|
+
// (a legacy search-param migrated into the hash, or the first edit)
|
|
13689
|
+
// would otherwise never land.
|
|
13692
13690
|
//
|
|
13693
13691
|
// The queue + retry pattern below makes writes reliable:
|
|
13694
13692
|
// - `updateHashParam` stores the latest attempted write in
|
|
@@ -14075,9 +14073,9 @@ const useSearchParamSync = ({ key, enabled = true, onExternalChange, replace: re
|
|
|
14075
14073
|
// `navigate` directly from inside the rAF callback. See the matching
|
|
14076
14074
|
// comment block in `useHashParamSync` for the full rationale — in short,
|
|
14077
14075
|
// navigating while `router.state.status === "pending"` was previously
|
|
14078
|
-
// dropped silently, which lost
|
|
14079
|
-
//
|
|
14080
|
-
// pending phase.
|
|
14076
|
+
// dropped silently, which lost a one-shot write (a legacy search param
|
|
14077
|
+
// migrated into the URL, or the first edit) on routes that mount during
|
|
14078
|
+
// a loader-driven pending phase.
|
|
14081
14079
|
const flushPendingWrite = useCallback(() => {
|
|
14082
14080
|
const pending = pendingWriteRef.current;
|
|
14083
14081
|
if (pending === null) {
|
|
@@ -14199,10 +14197,14 @@ const rawLocalStorage = {
|
|
|
14199
14197
|
* On mount the hook resolves the initial state as follows:
|
|
14200
14198
|
* - If the canonical URL slot (search OR hash, per `urlLocation`) holds a
|
|
14201
14199
|
* value, decode it and pass through `validate`.
|
|
14202
|
-
* - In `urlLocation: "hash"` mode, if the canonical hash slot
|
|
14203
|
-
* but a **legacy** `?<key>=...` search param is present, decode and
|
|
14204
|
-
* validate that as a one-shot fallback.
|
|
14205
|
-
* the
|
|
14200
|
+
* - In `urlLocation: "hash"` mode, if the canonical hash slot has no valid
|
|
14201
|
+
* value but a **legacy** `?<key>=...` search param is present, decode and
|
|
14202
|
+
* validate that as a one-shot fallback. The value is copied into the hash
|
|
14203
|
+
* and the search param is stripped via a `replace` navigation.
|
|
14204
|
+
* - A value that comes only from localStorage is not written to the URL.
|
|
14205
|
+
* Copying it on load left a layout in history, bookmarks, and login
|
|
14206
|
+
* redirects, which then replayed an older layout over the saved one
|
|
14207
|
+
* (GLU-2396). The URL is written when the user changes the state.
|
|
14206
14208
|
* - If localStorage is enabled, read and validate its value.
|
|
14207
14209
|
* - When `mergeWithStorageOnRead` is `false` (default): URL state wins
|
|
14208
14210
|
* entirely when present, otherwise fall back to localStorage.
|
|
@@ -14388,7 +14390,9 @@ const usePersistedState = ({ key, validate, serialize, toUrlValue, fromUrlValue,
|
|
|
14388
14390
|
initialState: storageState,
|
|
14389
14391
|
canonicalUrlHasValidState: false,
|
|
14390
14392
|
canonicalUrlPayload: undefined,
|
|
14391
|
-
|
|
14393
|
+
// Leave the URL alone. A storage-only load must not grow a hash,
|
|
14394
|
+
// or the next history/bookmark/login of this page replays it.
|
|
14395
|
+
needsUrlRestore: false,
|
|
14392
14396
|
};
|
|
14393
14397
|
}
|
|
14394
14398
|
return {
|
|
@@ -14399,7 +14403,7 @@ const usePersistedState = ({ key, validate, serialize, toUrlValue, fromUrlValue,
|
|
|
14399
14403
|
};
|
|
14400
14404
|
}, [decode, enabled, localStorageEnabled, storageKey, mergeWithStorageOnRead]);
|
|
14401
14405
|
// Every URL write goes through here so the ownership stamp is applied
|
|
14402
|
-
// uniformly (user edits
|
|
14406
|
+
// uniformly (user edits and legacy search-param migration).
|
|
14403
14407
|
const encodeForUrl = useCallback((state) => {
|
|
14404
14408
|
const urlValue = toUrlValueRef.current ? toUrlValueRef.current(state) : state;
|
|
14405
14409
|
return encode(currentUrlOwner === undefined ? urlValue : wrapUrlOwner(urlValue, currentUrlOwner));
|
|
@@ -14473,11 +14477,12 @@ const usePersistedState = ({ key, validate, serialize, toUrlValue, fromUrlValue,
|
|
|
14473
14477
|
if (hasRestoredUrlRef.current) {
|
|
14474
14478
|
return;
|
|
14475
14479
|
}
|
|
14476
|
-
//
|
|
14477
|
-
//
|
|
14478
|
-
//
|
|
14479
|
-
//
|
|
14480
|
-
//
|
|
14480
|
+
// Only a legacy search param is copied into the hash. Storage is not:
|
|
14481
|
+
// mirroring it on load is what put a layout into every history entry
|
|
14482
|
+
// (GLU-2396). Gate on `canonicalUrlHasValidState`, not on the raw
|
|
14483
|
+
// `searchValue`: an undecodable string in the hash slot must not block
|
|
14484
|
+
// the legacy copy, or the migration strips the search param and the
|
|
14485
|
+
// bad string is the only state left on the next reload.
|
|
14481
14486
|
if (!enabled || !needsUrlRestore || initialState === undefined || canonicalUrlHasValidState) {
|
|
14482
14487
|
return;
|
|
14483
14488
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.18.3
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "2.3.3
|
|
19
|
-
"@trackunit/shared-utils": "1.19.3
|
|
20
|
-
"@trackunit/ui-icons": "1.17.3
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.18.3",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "2.3.3",
|
|
19
|
+
"@trackunit/shared-utils": "1.19.3",
|
|
20
|
+
"@trackunit/ui-icons": "1.17.3",
|
|
21
21
|
"es-toolkit": "^1.52.0",
|
|
22
22
|
"@tanstack/react-virtual": "^3.14.13",
|
|
23
23
|
"dequal": "^2.0.3",
|
|
24
24
|
"fflate": "^0.8.3",
|
|
25
25
|
"zod": "^3.25.76",
|
|
26
|
-
"@trackunit/i18n-library-translation": "2.8.3
|
|
26
|
+
"@trackunit/i18n-library-translation": "2.8.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "^19.0.0",
|
|
@@ -74,10 +74,14 @@ type UsePersistedStateReturn<TState> = {
|
|
|
74
74
|
* On mount the hook resolves the initial state as follows:
|
|
75
75
|
* - If the canonical URL slot (search OR hash, per `urlLocation`) holds a
|
|
76
76
|
* value, decode it and pass through `validate`.
|
|
77
|
-
* - In `urlLocation: "hash"` mode, if the canonical hash slot
|
|
78
|
-
* but a **legacy** `?<key>=...` search param is present, decode and
|
|
79
|
-
* validate that as a one-shot fallback.
|
|
80
|
-
* the
|
|
77
|
+
* - In `urlLocation: "hash"` mode, if the canonical hash slot has no valid
|
|
78
|
+
* value but a **legacy** `?<key>=...` search param is present, decode and
|
|
79
|
+
* validate that as a one-shot fallback. The value is copied into the hash
|
|
80
|
+
* and the search param is stripped via a `replace` navigation.
|
|
81
|
+
* - A value that comes only from localStorage is not written to the URL.
|
|
82
|
+
* Copying it on load left a layout in history, bookmarks, and login
|
|
83
|
+
* redirects, which then replayed an older layout over the saved one
|
|
84
|
+
* (GLU-2396). The URL is written when the user changes the state.
|
|
81
85
|
* - If localStorage is enabled, read and validate its value.
|
|
82
86
|
* - When `mergeWithStorageOnRead` is `false` (default): URL state wins
|
|
83
87
|
* entirely when present, otherwise fall back to localStorage.
|
package/translation.cjs.js
CHANGED
package/translation.esm.js
CHANGED
package/translation10.cjs.js
CHANGED
package/translation10.esm.js
CHANGED
package/translation11.cjs.js
CHANGED
package/translation11.esm.js
CHANGED
package/translation12.cjs.js
CHANGED
package/translation12.esm.js
CHANGED
package/translation13.cjs.js
CHANGED
package/translation13.esm.js
CHANGED
package/translation14.cjs.js
CHANGED
package/translation14.esm.js
CHANGED
package/translation15.cjs.js
CHANGED
package/translation15.esm.js
CHANGED
package/translation16.cjs.js
CHANGED
package/translation16.esm.js
CHANGED
package/translation17.cjs.js
CHANGED
package/translation17.esm.js
CHANGED
package/translation2.cjs.js
CHANGED
package/translation2.esm.js
CHANGED
package/translation3.cjs.js
CHANGED
package/translation3.esm.js
CHANGED
package/translation4.cjs.js
CHANGED
package/translation4.esm.js
CHANGED
package/translation5.cjs.js
CHANGED
package/translation5.esm.js
CHANGED
package/translation6.cjs.js
CHANGED
package/translation6.esm.js
CHANGED
package/translation7.cjs.js
CHANGED
package/translation7.esm.js
CHANGED
package/translation8.cjs.js
CHANGED
package/translation8.esm.js
CHANGED
package/translation9.cjs.js
CHANGED
package/translation9.esm.js
CHANGED