@trackunit/react-components 3.12.3-alpha-4632fb37afe.0 → 4.0.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.
Files changed (60) hide show
  1. package/index.cjs.js +104 -959
  2. package/index.esm.js +102 -952
  3. package/migrations/assets/react-router-components/package.json +23 -0
  4. package/migrations/utils/move-named-imports.js +409 -0
  5. package/migrations/utils/package-json-utils.js +73 -0
  6. package/migrations/v4-0-0/move-to-router-components.js +71 -0
  7. package/migrations.json +5 -0
  8. package/package.json +6 -7
  9. package/src/components/ExternalLink/ExternalLink.d.ts +2 -2
  10. package/src/index.d.ts +0 -4
  11. package/translation.cjs.js +0 -1
  12. package/translation.esm.js +0 -1
  13. package/translation10.cjs.js +0 -1
  14. package/translation10.esm.js +0 -1
  15. package/translation11.cjs.js +0 -1
  16. package/translation11.esm.js +0 -1
  17. package/translation12.cjs.js +0 -1
  18. package/translation12.esm.js +0 -1
  19. package/translation13.cjs.js +0 -1
  20. package/translation13.esm.js +0 -1
  21. package/translation14.cjs.js +0 -1
  22. package/translation14.esm.js +0 -1
  23. package/translation15.cjs.js +0 -1
  24. package/translation15.esm.js +0 -1
  25. package/translation16.cjs.js +0 -1
  26. package/translation16.esm.js +0 -1
  27. package/translation17.cjs.js +0 -1
  28. package/translation17.esm.js +0 -1
  29. package/translation2.cjs.js +0 -1
  30. package/translation2.esm.js +0 -1
  31. package/translation3.cjs.js +0 -1
  32. package/translation3.esm.js +0 -1
  33. package/translation4.cjs.js +0 -1
  34. package/translation4.esm.js +0 -1
  35. package/translation5.cjs.js +0 -1
  36. package/translation5.esm.js +0 -1
  37. package/translation6.cjs.js +0 -1
  38. package/translation6.esm.js +0 -1
  39. package/translation7.cjs.js +0 -1
  40. package/translation7.esm.js +0 -1
  41. package/translation8.cjs.js +0 -1
  42. package/translation8.esm.js +0 -1
  43. package/translation9.cjs.js +0 -1
  44. package/translation9.esm.js +0 -1
  45. package/src/components/Breadcrumb/Breadcrumb.d.ts +0 -39
  46. package/src/components/Breadcrumb/Breadcrumb.variant.d.ts +0 -45
  47. package/src/components/Breadcrumb/BreadcrumbContainer.d.ts +0 -8
  48. package/src/components/Breadcrumb/BreadcrumbForLargeScreen.d.ts +0 -6
  49. package/src/components/Breadcrumb/BreadcrumbForMediumScreen.d.ts +0 -6
  50. package/src/components/Breadcrumb/BreadcrumbForSmallScreen.d.ts +0 -6
  51. package/src/components/Breadcrumb/BreadcrumbItem.d.ts +0 -6
  52. package/src/components/Breadcrumb/utils/types.d.ts +0 -28
  53. package/src/components/Breadcrumb/utils/useBreadcrumbItemsToRender.d.ts +0 -6
  54. package/src/hooks/persistence/hashFragment.d.ts +0 -70
  55. package/src/hooks/persistence/readPrimitiveSearchParam.d.ts +0 -8
  56. package/src/hooks/persistence/urlIdentity.d.ts +0 -64
  57. package/src/hooks/persistence/usePersistedState.d.ts +0 -117
  58. package/src/hooks/persistence/useSearchParamSync.d.ts +0 -17
  59. package/src/hooks/persistence/useUrlParamSync.d.ts +0 -71
  60. package/src/hooks/useCursorUrlSync.d.ts +0 -23
@@ -1,117 +0,0 @@
1
- import { type UrlParamLocation } from "./useUrlParamSync";
2
- /**
3
- * Selects which part of the URL backs the persisted state.
4
- *
5
- * - `"search"` (default): `?<key>=<encoded>`. Subject to the AWS WAF
6
- * managed-rule cap (~5000 bytes) — large states are dropped from the URL.
7
- * - `"hash"`: `#<key>=<encoded>`. Stays on the client, so the cap is
8
- * driven only by browser URL limits.
9
- */
10
- export type UrlPersistenceLocation = UrlParamLocation;
11
- type UsePersistedStateOptions<TState> = {
12
- readonly key: string;
13
- readonly validate: (raw: unknown) => TState | undefined;
14
- readonly toUrlValue?: (state: TState) => string | object | Array<object>;
15
- readonly fromUrlValue?: (decoded: unknown) => unknown;
16
- readonly localStorageEnabled?: boolean;
17
- readonly replace?: boolean;
18
- readonly clientSideUserId?: string;
19
- /**
20
- * When `true` and both URL and localStorage have valid state, the read
21
- * returns a shallow merge `{ ...storage, ...url }` where URL fields take
22
- * precedence and storage fills in fields the URL omits.
23
- *
24
- * Use this when `toUrlValue` deliberately omits some fields from the URL
25
- * (e.g. per-user layout details that shouldn't be shareable) so the
26
- * omitted fields still survive reloads via localStorage.
27
- *
28
- * Default is `false`: URL state fully replaces localStorage state on read.
29
- */
30
- readonly mergeWithStorageOnRead?: boolean;
31
- /**
32
- * Which slot of the URL backs the persisted value. Default `"search"`.
33
- * See {@link UrlPersistenceLocation} for the trade-offs.
34
- */
35
- readonly urlLocation?: UrlPersistenceLocation;
36
- /**
37
- * When `true`, every URL write is stamped with a fingerprint of
38
- * `clientSideUserId` (`{ o: <fingerprint>, v: <payload> }`). Reads are
39
- * unaffected: the URL still wins on load for everyone, so links and
40
- * bookmarks render for whoever opens them.
41
- *
42
- * The stamp exists for the login redirect. The URL is shared by every
43
- * account that signs in from the same browser and `redirectToLogin`
44
- * carries it through to the next account, which is how one account's
45
- * state replaced another's on a shared PC (GLU-2396). At that boundary
46
- * `useStripForeignIdentityHash` drops entries stamped by a different
47
- * identity that has state stored in this browser. Default `false`.
48
- */
49
- readonly stampUrlWithIdentity?: boolean;
50
- };
51
- type UsePersistedStateReturn<TState> = {
52
- readonly initialState: TState | undefined;
53
- /** Writes `state` to localStorage and the URL; each slot skips a value equal to its last write. */
54
- readonly persistState: (state: TState) => void;
55
- /**
56
- * Writes `state` to localStorage only; `undefined` removes the entry.
57
- * Use together with `persistToUrl` when the two writes should not share a
58
- * schedule — e.g. storage immediately, URL debounced.
59
- */
60
- readonly persistToStorage: (state: TState | undefined) => void;
61
- /** Writes `state` to the URL only; `undefined` removes the entry. */
62
- readonly persistToUrl: (state: TState | undefined) => void;
63
- };
64
- /**
65
- * Generic persistence hook that loads state from a URL slot (search param
66
- * or hash fragment, depending on `urlLocation`) with localStorage fallback,
67
- * and writes changes to both.
68
- *
69
- * On mount the hook resolves the initial state as follows:
70
- * - If the URL slot holds a value, decode it and pass through `validate`.
71
- * - If localStorage is enabled, read and validate its value.
72
- * - When `mergeWithStorageOnRead` is `false` (default): URL state wins
73
- * entirely when present, otherwise fall back to localStorage.
74
- * - When `mergeWithStorageOnRead` is `true`: shallow-merge URL fields over
75
- * localStorage so fields stripped by `toUrlValue` survive via storage.
76
- *
77
- * A value that comes only from localStorage is never written to the URL on
78
- * load. Copying it left a layout in history, bookmarks, and login redirects,
79
- * which then replayed an older layout over the saved one (GLU-2396). The URL
80
- * is written when the consumer persists a change.
81
- *
82
- * `persistState` writes to localStorage (`storageSerializer`) and to the URL
83
- * (via `toUrlValue` + encoding).
84
- * Each slot skips a value equal to its last write. The URL side compares what
85
- * would land in the URL (the `toUrlValue` projection and the identity stamp),
86
- * starting from the projection of the hydrated state and the stamp the URL
87
- * carries: echoing `initialState`, or changing only a field the projection
88
- * strips, writes no URL entry, while an equal state persisted after the
89
- * identity resolves rewrites the URL with its stamp. The storage side starts
90
- * from what localStorage held, so a consumer that persists `initialState`
91
- * after opening a link saves that link's state for the account that opened
92
- * it, and a reload of the account's own link writes nothing.
93
- * `persistToStorage` and `persistToUrl` are the same two halves exposed
94
- * separately for consumers that schedule them differently; passing `undefined`
95
- * removes the entry rather than writing an empty value.
96
- *
97
- * The snapshot is re-read when the storage key or the storage/merge options
98
- * change, in the same render, so a write in that commit already sees the
99
- * state for the new key.
100
- *
101
- * @param options - Configuration for the persisted state.
102
- * @param options.key - Unique identifier used for both the URL slot and the localStorage key.
103
- * @param options.validate - Called with the decoded/parsed value; must return `TState` or `undefined`.
104
- * @param options.toUrlValue - Transform applied before URL encoding (default: encode state as-is).
105
- * @param options.fromUrlValue - Transform applied after URL decoding, before validation (default: identity).
106
- * @param options.localStorageEnabled - When `false` localStorage is neither read nor written (default `true`).
107
- * @param options.replace - Forwarded to the underlying URL sync hook.
108
- * @param options.clientSideUserId - The user ID to use for the localStorage key.
109
- * @param options.mergeWithStorageOnRead - Merge URL state on top of localStorage
110
- * state on read (URL wins on shared keys). Use when `toUrlValue` deliberately
111
- * omits fields so they still survive via localStorage. Default `false`.
112
- * @param options.urlLocation - Which URL slot backs the value (`"search"` or `"hash"`). Default `"search"`.
113
- * @param options.stampUrlWithIdentity - Stamp URL writes with the current identity so the login
114
- * redirect can drop entries left by another account on this browser. Default `false`.
115
- */
116
- export declare const usePersistedState: <TState extends object>({ key, validate, toUrlValue, fromUrlValue, localStorageEnabled, replace, clientSideUserId, mergeWithStorageOnRead, urlLocation, stampUrlWithIdentity, }: UsePersistedStateOptions<TState>) => UsePersistedStateReturn<TState>;
117
- export {};
@@ -1,17 +0,0 @@
1
- import { type UseUrlParamSyncOptions, type UseUrlParamSyncReturn } from "./useUrlParamSync";
2
- export { MAX_URL_LENGTH } from "./useUrlParamSync";
3
- type UseSearchParamSyncOptions = Omit<UseUrlParamSyncOptions, "location">;
4
- /**
5
- * Syncs an encoded string value with a URL search parameter via Tanstack Router.
6
- *
7
- * Thin wrapper over {@link useUrlParamSync} with `location: "search"`; see it
8
- * for the write queue, the size guard (`MAX_URL_LENGTH`), and external-change
9
- * detection.
10
- *
11
- * @param options - Configuration for the search param sync.
12
- * @param options.key - The URL search parameter name.
13
- * @param options.enabled - Set to `false` to disable all URL interaction (default `true`).
14
- * @param options.onExternalChange - Called when the param changes externally.
15
- * @param options.replace - `true` to always use `replaceState`.
16
- */
17
- export declare const useSearchParamSync: (options: UseSearchParamSyncOptions) => UseUrlParamSyncReturn;
@@ -1,71 +0,0 @@
1
- /**
2
- * Maximum full URL length after adding one persisted search param before the
3
- * URL write is skipped (localStorage still persists the full state).
4
- *
5
- * Sized to stay safely below the AWS WAF managed-rule default
6
- * `SizeRestrictions_QUERYSTRING` cap of 5000 bytes for the entire
7
- * host + path + query + hash string.
8
- */
9
- export declare const MAX_URL_LENGTH = 5000;
10
- /**
11
- * Maximum length of the URL fragment after adding one persisted entry.
12
- * Oversized new entries are skipped; oversized replacements remove the stale
13
- * entry so localStorage remains authoritative.
14
- *
15
- * The fragment is never sent to the server, so the WAF cap above does not
16
- * apply. 64 KB stays well below typical browser URL limits (Chromium ≳ 100 KB,
17
- * Firefox ≳ 64 KB on the address bar) while leaving generous headroom for any
18
- * realistic table state.
19
- */
20
- export declare const MAX_HASH_LENGTH: number;
21
- /**
22
- * Which part of the URL a persisted value lives in.
23
- *
24
- * - `"search"`: `?<key>=<encoded>`. Subject to the AWS WAF cap
25
- * ({@link MAX_URL_LENGTH}); large states are dropped from the URL.
26
- * - `"hash"`: `#<key>=<encoded>`. Client-only, capped by
27
- * {@link MAX_HASH_LENGTH}.
28
- */
29
- export type UrlParamLocation = "search" | "hash";
30
- export type UseUrlParamSyncOptions = {
31
- readonly key: string;
32
- readonly location: UrlParamLocation;
33
- readonly enabled?: boolean;
34
- readonly onExternalChange?: () => void;
35
- readonly replace?: boolean;
36
- };
37
- export type UseUrlParamSyncReturn = {
38
- /** The raw encoded value currently in the URL slot, or `undefined` when absent or disabled. */
39
- readonly searchValue: string | undefined;
40
- /** Writes `encodedValue` into the URL slot; `undefined` removes the entry. */
41
- readonly updateSearchParam: (encodedValue: string | undefined) => void;
42
- };
43
- /**
44
- * Syncs an encoded string value with a single named entry in the URL — either
45
- * a search param or an entry inside the hash fragment — via Tanstack Router.
46
- *
47
- * Writes go through the application router so other search params and
48
- * foreign fragment content are preserved. Each slot has a size guard
49
- * ({@link MAX_URL_LENGTH} for search, {@link MAX_HASH_LENGTH} for hash); an
50
- * oversized value is dropped from the URL and localStorage stays
51
- * authoritative. External changes to the entry (browser back/forward, a
52
- * pasted link, a foreign router push) fire `onExternalChange`.
53
- *
54
- * Writes are dispatched via a pending-write queue rather than calling
55
- * `navigate` directly. Tanstack Router's `router.state.status === "pending"`
56
- * is common during the first paint of a route (loaders, suspense), and an
57
- * implementation that simply returned in that case lost the write outright.
58
- * `updateSearchParam` stores the latest attempted write and schedules an rAF
59
- * flush; the flush only navigates when the router is idle, and an effect
60
- * retries whenever the router settles. A queued write is dropped on unmount so
61
- * it cannot drain onto the next route.
62
- *
63
- * @param options - Configuration for the URL entry sync.
64
- * @param options.key - The search param name or fragment entry name.
65
- * @param options.location - `"search"` or `"hash"`.
66
- * @param options.enabled - Set to `false` to disable all URL interaction (default `true`).
67
- * @param options.onExternalChange - Called when the entry changes externally.
68
- * @param options.replace - `true` to always use `replaceState`; `false` to always push.
69
- * Default: replace when the entry is being added, push when it already has a value.
70
- */
71
- export declare const useUrlParamSync: ({ key, location: urlLocation, enabled, onExternalChange, replace: replaceOption, }: UseUrlParamSyncOptions) => UseUrlParamSyncReturn;
@@ -1,23 +0,0 @@
1
- type UseCursorUrlSyncOptions = {
2
- readonly paramName?: string;
3
- readonly debounceMs?: number;
4
- };
5
- type UseCursorUrlSyncResult = {
6
- readonly initialCursor: string | undefined;
7
- readonly updateCursor: (cursor: string | undefined) => void;
8
- };
9
- /**
10
- * Reads a cursor from the URL search params on mount and provides a debounced
11
- * updater for writing it back. Uses `replace: true` to avoid polluting browser
12
- * history with every scroll position change.
13
- *
14
- * Wire `initialCursor` into `usePaginationQuery` and `updateCursor` into
15
- * `useBidirectionalScroll`'s `onTopItemChange` callback (mapping index to cursor).
16
- *
17
- * A pending write is dropped whenever a path-changing navigation starts or the
18
- * location has moved on: the write targets `to: "."`, so landing it after the
19
- * user opened a row would replace their destination with the list they came
20
- * from.
21
- */
22
- export declare const useCursorUrlSync: ({ paramName, debounceMs, }?: UseCursorUrlSyncOptions) => UseCursorUrlSyncResult;
23
- export {};