@eifi1/ui-kit 0.52.0 → 0.53.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 (193) hide show
  1. package/README.md +47 -54
  2. package/dist/billing/cancel-subscription.d.ts +5 -14
  3. package/dist/billing/cancel-subscription.js +1 -3
  4. package/dist/billing/cancel-subscription.js.map +1 -1
  5. package/dist/billing/plan-card.d.ts +5 -13
  6. package/dist/billing/plan-card.js +3 -11
  7. package/dist/billing/plan-card.js.map +1 -1
  8. package/dist/billing/plan-switch.d.ts +5 -14
  9. package/dist/billing/plan-switch.js +1 -3
  10. package/dist/billing/plan-switch.js.map +1 -1
  11. package/dist/chart.d.ts +3 -14
  12. package/dist/chart.js +64 -11
  13. package/dist/chart.js.map +1 -1
  14. package/dist/components/date-field.d.ts +1 -1
  15. package/dist/components/date-field.js.map +1 -1
  16. package/dist/components/date-picker.d.ts +1 -1
  17. package/dist/components/date-picker.js.map +1 -1
  18. package/dist/components/date-range-picker.d.ts +4 -17
  19. package/dist/components/date-range-picker.js +2 -2
  20. package/dist/components/date-range-picker.js.map +1 -1
  21. package/dist/components/nav-pills.d.ts +1 -1
  22. package/dist/components/nav-pills.js.map +1 -1
  23. package/dist/components/series-chart-axes.d.ts +1 -1
  24. package/dist/components/series-chart-axes.js.map +1 -1
  25. package/dist/components/series-chart.d.ts +64 -19
  26. package/dist/components/series-chart.js +2 -1
  27. package/dist/components/series-chart.js.map +1 -1
  28. package/dist/components/treemap-labels.d.ts +6 -1
  29. package/dist/components/treemap-labels.js +2 -2
  30. package/dist/components/treemap-labels.js.map +1 -1
  31. package/dist/components/treemap.d.ts +29 -4
  32. package/dist/components/treemap.js +22 -9
  33. package/dist/components/treemap.js.map +1 -1
  34. package/dist/data-table.d.ts +1 -6
  35. package/dist/data-table.js +1 -9
  36. package/dist/data-table.js.map +1 -1
  37. package/dist/demo/demo-countdown.d.ts +0 -5
  38. package/dist/demo/demo-countdown.js +0 -4
  39. package/dist/demo/demo-countdown.js.map +1 -1
  40. package/dist/eslint/index.js +1 -1
  41. package/dist/feedback/feedback-mutation.d.ts +11 -23
  42. package/dist/feedback/feedback-mutation.js +1 -9
  43. package/dist/feedback/feedback-mutation.js.map +1 -1
  44. package/dist/feedback/feedback-public-list.d.ts +1 -6
  45. package/dist/feedback/feedback-public-list.js +1 -2
  46. package/dist/feedback/feedback-public-list.js.map +1 -1
  47. package/dist/feedback/feedback-row-detail-labels.js +0 -8
  48. package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
  49. package/dist/feedback/feedback-row-detail.d.ts +3 -50
  50. package/dist/feedback/feedback-row-detail.js +0 -8
  51. package/dist/feedback/feedback-row-detail.js.map +1 -1
  52. package/dist/feedback/feedback-status-undo.d.ts +3 -19
  53. package/dist/feedback/feedback-status-undo.js.map +1 -1
  54. package/dist/feedback/feedback-thread.d.ts +0 -9
  55. package/dist/feedback/feedback-thread.js.map +1 -1
  56. package/dist/feedback.d.ts +6 -40
  57. package/dist/feedback.js +88 -46
  58. package/dist/feedback.js.map +1 -1
  59. package/dist/i18n/defaults.js +0 -4
  60. package/dist/i18n/defaults.js.map +1 -1
  61. package/dist/i18n/german.js +2 -19
  62. package/dist/i18n/german.js.map +1 -1
  63. package/dist/i18n/kit-labels.d.ts +5 -14
  64. package/dist/i18n/kit-labels.js.map +1 -1
  65. package/dist/i18n/locales/en.js +2 -30
  66. package/dist/i18n/locales/en.js.map +3 -3
  67. package/dist/i18n/locales/es.js +2 -19
  68. package/dist/i18n/locales/es.js.map +1 -1
  69. package/dist/i18n/locales/fr.js +2 -19
  70. package/dist/i18n/locales/fr.js.map +1 -1
  71. package/dist/i18n/locales/hu.js +2 -19
  72. package/dist/i18n/locales/hu.js.map +1 -1
  73. package/dist/i18n/locales/it.js +2 -20
  74. package/dist/i18n/locales/it.js.map +1 -1
  75. package/dist/i18n/locales/zh.js +2 -19
  76. package/dist/i18n/locales/zh.js.map +1 -1
  77. package/dist/i18n/review.js +9 -4
  78. package/dist/i18n/review.js.map +1 -1
  79. package/dist/i18n/shared-labels.js +0 -1
  80. package/dist/i18n/shared-labels.js.map +1 -1
  81. package/dist/index.d.ts +15 -64
  82. package/dist/index.js +22 -102
  83. package/dist/index.js.map +1 -1
  84. package/dist/rhf/fields.d.ts +2 -2
  85. package/dist/rhf/fields.js.map +1 -1
  86. package/dist/search/search-index.d.ts +0 -6
  87. package/dist/search/search-index.js +0 -4
  88. package/dist/search/search-index.js.map +1 -1
  89. package/dist/search.d.ts +1 -8
  90. package/dist/search.js +2 -7
  91. package/dist/search.js.map +1 -1
  92. package/dist/shell/account-menu-language.d.ts +7 -21
  93. package/dist/shell/account-menu-language.js +1 -3
  94. package/dist/shell/account-menu-language.js.map +1 -1
  95. package/dist/shell/account-menu-text-size.d.ts +9 -23
  96. package/dist/shell/account-menu-text-size.js +2 -3
  97. package/dist/shell/account-menu-text-size.js.map +1 -1
  98. package/dist/shell/app-shell.d.ts +0 -10
  99. package/dist/shell/app-shell.js +1 -7
  100. package/dist/shell/app-shell.js.map +1 -1
  101. package/dist/shell/company-switcher.d.ts +1 -1
  102. package/dist/shell/company-switcher.js.map +1 -1
  103. package/dist/shell/dev-menu.d.ts +1 -1
  104. package/dist/shell/dev-menu.js.map +1 -1
  105. package/dist/shell/top-bar-parts-labels.d.ts +1 -1
  106. package/dist/shell/top-bar-parts-labels.js.map +1 -1
  107. package/dist/shell.d.ts +7 -29
  108. package/dist/shell.js +12 -42
  109. package/dist/shell.js.map +1 -1
  110. package/dist/sync.d.ts +2 -6
  111. package/dist/sync.js +2 -15
  112. package/dist/sync.js.map +1 -1
  113. package/dist/theme/chart-palette.d.ts +0 -5
  114. package/dist/theme/chart-palette.js +0 -2
  115. package/dist/theme/chart-palette.js.map +1 -1
  116. package/package.json +1 -1
  117. package/src/billing/cancel-subscription.tsx +5 -16
  118. package/src/billing/plan-card.tsx +7 -24
  119. package/src/billing/plan-switch.tsx +5 -16
  120. package/src/chart.ts +62 -13
  121. package/src/components/date-field.tsx +1 -1
  122. package/src/components/date-picker.tsx +0 -1
  123. package/src/components/date-range-picker.tsx +6 -22
  124. package/src/components/nav-pills.tsx +1 -1
  125. package/src/components/series-chart-axes.ts +6 -1
  126. package/src/components/series-chart.tsx +78 -21
  127. package/src/components/treemap-labels.ts +11 -3
  128. package/src/components/treemap.tsx +65 -12
  129. package/src/data-table.ts +1 -11
  130. package/src/demo/demo-countdown.ts +3 -8
  131. package/src/feedback/feedback-mutation.ts +12 -33
  132. package/src/feedback/feedback-public-list.tsx +1 -7
  133. package/src/feedback/feedback-row-detail-labels.ts +0 -8
  134. package/src/feedback/feedback-row-detail.tsx +8 -58
  135. package/src/feedback/feedback-status-undo.ts +4 -18
  136. package/src/feedback/feedback-thread.tsx +0 -10
  137. package/src/feedback.ts +89 -48
  138. package/src/i18n/defaults.ts +0 -4
  139. package/src/i18n/german.ts +2 -19
  140. package/src/i18n/kit-labels.tsx +5 -14
  141. package/src/i18n/locales/es.ts +2 -19
  142. package/src/i18n/locales/fr.ts +2 -19
  143. package/src/i18n/locales/hu.ts +2 -19
  144. package/src/i18n/locales/it.ts +2 -20
  145. package/src/i18n/locales/zh.ts +2 -19
  146. package/src/i18n/review.ts +9 -4
  147. package/src/i18n/shared-labels.ts +0 -1
  148. package/src/index.ts +30 -112
  149. package/src/rhf/fields.tsx +2 -2
  150. package/src/search/search-index.ts +0 -15
  151. package/src/search.ts +8 -8
  152. package/src/shell/account-menu-language.tsx +7 -27
  153. package/src/shell/account-menu-text-size.tsx +13 -32
  154. package/src/shell/app-shell.tsx +0 -13
  155. package/src/shell/company-switcher.tsx +1 -1
  156. package/src/shell/dev-menu.tsx +1 -1
  157. package/src/shell/top-bar-parts-labels.ts +1 -1
  158. package/src/shell.ts +17 -44
  159. package/src/sync.ts +2 -15
  160. package/src/theme/chart-palette.ts +0 -2
  161. package/tokens.css +4 -4
  162. package/dist/billing/dialog-close.d.ts +0 -29
  163. package/dist/billing/dialog-close.js +0 -8
  164. package/dist/billing/dialog-close.js.map +0 -1
  165. package/dist/components/field-sync-labels.d.ts +0 -3
  166. package/dist/components/field-sync-labels.js +0 -12
  167. package/dist/components/field-sync-labels.js.map +0 -1
  168. package/dist/components/field-sync.d.ts +0 -186
  169. package/dist/components/field-sync.js +0 -269
  170. package/dist/components/field-sync.js.map +0 -1
  171. package/dist/components/section-nav.d.ts +0 -44
  172. package/dist/components/section-nav.js +0 -33
  173. package/dist/components/section-nav.js.map +0 -1
  174. package/dist/components/sign-chip-labels.d.ts +0 -3
  175. package/dist/components/sign-chip-labels.js +0 -11
  176. package/dist/components/sign-chip-labels.js.map +0 -1
  177. package/dist/components/sign-chip.d.ts +0 -77
  178. package/dist/components/sign-chip.js +0 -47
  179. package/dist/components/sign-chip.js.map +0 -1
  180. package/dist/lib/isin.d.ts +0 -38
  181. package/dist/lib/isin.js +0 -36
  182. package/dist/lib/isin.js.map +0 -1
  183. package/dist/shell/role-switcher.d.ts +0 -28
  184. package/dist/shell/role-switcher.js +0 -31
  185. package/dist/shell/role-switcher.js.map +0 -1
  186. package/src/billing/dialog-close.ts +0 -34
  187. package/src/components/field-sync-labels.ts +0 -14
  188. package/src/components/field-sync.tsx +0 -504
  189. package/src/components/section-nav.tsx +0 -72
  190. package/src/components/sign-chip-labels.ts +0 -13
  191. package/src/components/sign-chip.tsx +0 -133
  192. package/src/lib/isin.ts +0 -72
  193. package/src/shell/role-switcher.tsx +0 -53
@@ -1,504 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
2
- import type { ReactNode } from "react";
3
- import { AlertCircle, Check, Loader2, Pencil, PencilLine } from "lucide-react";
4
- import { cn } from "../lib/cn";
5
- import { Tooltip } from "./tooltip";
6
- import { FOCUS_RING } from "./focus-ring";
7
- import { useKitLabels, type LabelOverride } from "../i18n/kit-labels";
8
- import { useLargeText } from "../hooks/use-large-text";
9
- import { DEFAULT_FIELD_SYNC_LABELS } from "./field-sync-labels";
10
-
11
- /**
12
- * Sync state for a field backed by a database row.
13
- *
14
- * The four states a value can be in between the keyboard and the server:
15
- *
16
- * synced the draft equals what was last persisted
17
- * edited the draft differs and nothing has been sent yet
18
- * pending a save is in flight
19
- * error the last save was rejected; `error` carries why
20
- *
21
- * `useFieldSync` is the engine and holds no opinion about markup;
22
- * `FieldSyncIndicator` is the affordance and holds no state. They are separate
23
- * because the state is useful without the dot — a form can disable its submit
24
- * button while any field is `pending`, and a router can block navigation while
25
- * any field is `edited`.
26
- *
27
- * Deprecated in 0.52 as a whole, removed in 0.53 (decision 4 of the refactor audit
28
- * 2026-10-30, MOD-5): no app renders it or calls the hook — 483 lines and a namespace in
29
- * seven catalogues that only this package's tests and showcase read. An app that wants
30
- * it keeps a copy of this file.
31
- *
32
- * @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53.
33
- */
34
- export type FieldSyncState = "synced" | "edited" | "pending" | "error";
35
-
36
- /** @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53. */
37
- export interface FieldSyncLabels {
38
- synced: string;
39
- edited: string;
40
- pending: string;
41
- /** Shown when the failure carries no message of its own. */
42
- error: string;
43
- retry: string;
44
- }
45
-
46
- // Defined in ./field-sync-labels, which holds no component code (0.34, KS U8).
47
- export { DEFAULT_FIELD_SYNC_LABELS };
48
-
49
- /** @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53. */
50
- export interface UseFieldSyncOptions<T> {
51
- /** What the database currently holds. Changing it re-seeds a CLEAN field. */
52
- value: T;
53
- /** Persist `next`. Reject — or throw — to put the field in `error`. */
54
- onSave: (next: T) => Promise<void> | void;
55
- /**
56
- * Quiet period before an edit saves itself, in ms. Default `0`: no auto-save at
57
- * all, so `save()` is the only way to persist — called on blur by `FieldSyncRow`,
58
- * and on Enter by the caller. Saving after a pause in typing wrote half-finished
59
- * values to the database whenever somebody stopped to think; pass a positive
60
- * number only for a field where that is genuinely wanted.
61
- */
62
- debounceMs?: number;
63
- /** How to tell two values apart. Defaults to `Object.is`. */
64
- equals?: (a: T, b: T) => boolean;
65
- /** Called once per rejected save, with whatever `onSave` threw. */
66
- onError?: (error: Error) => void;
67
- }
68
-
69
- /** @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53. */
70
- export interface UseFieldSyncReturn<T> {
71
- /** The draft — bind this to the input, not the `value` option. */
72
- value: T;
73
- setValue: (next: T) => void;
74
- state: FieldSyncState;
75
- /** Non-null exactly when `state === "error"`. */
76
- error: Error | null;
77
- /** True whenever the draft differs from the last persisted value. */
78
- dirty: boolean;
79
- /** Persist now, cancelling any pending debounce. A no-op on a clean field. */
80
- save: () => void;
81
- /** Send the current draft again after a failure. */
82
- retry: () => void;
83
- /** Throw the draft away and go back to the last persisted value. */
84
- reset: () => void;
85
- }
86
-
87
- function toError(cause: unknown): Error {
88
- if (cause instanceof Error) return cause;
89
- // An EMPTY message for a rejection that carried none, not an English one: the
90
- // indicator shows `error.message` when there is one and the translated
91
- // `fieldSync.error` otherwise, so a fallback message here was an English sentence
92
- // that outranked the app's own translation. The original value stays on `cause`
93
- // for whoever logs it from `onError`.
94
- return new Error(typeof cause === "string" ? cause : "", { cause });
95
- }
96
-
97
- /**
98
- * Track one database-backed field: a local draft, a debounced save, and the state
99
- * of the round trip.
100
- *
101
- * Four things this handles that a `useState` + `useEffect` in a page does not:
102
- *
103
- * 1. **An edit during a save is never lost.** A save in flight is not cancelled
104
- * and not raced — when it settles, the draft is compared again and sent once
105
- * more if it moved. Cancelling instead would drop a keystroke that arrived
106
- * mid-flight; firing immediately would let two writes land out of order.
107
- * 2. **The server value is only adopted when the field is clean.** An external
108
- * refresh that overwrote what somebody was typing would be a data-loss bug, so
109
- * a dirty draft wins and keeps winning until it is saved or reset.
110
- * 3. **Nothing is set after unmount.** The save resolves into a component that
111
- * may be gone — a row scrolled out of a virtualised table, a closed dialog.
112
- * 4. **`onSave` is read through a ref**, so an inline arrow — which every call
113
- * site will pass — does not restart the debounce on every render.
114
- *
115
- * @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53.
116
- */
117
- export function useFieldSync<T>({
118
- value,
119
- onSave,
120
- debounceMs = 0,
121
- equals = Object.is,
122
- onError,
123
- }: UseFieldSyncOptions<T>): UseFieldSyncReturn<T> {
124
- const [draft, setDraft] = useState<T>(value);
125
- const [state, setState] = useState<FieldSyncState>("synced");
126
- const [error, setError] = useState<Error | null>(null);
127
-
128
- // The last value known to be on the server. Not state: it changes together with
129
- // `state` inside the save, and a second render for it would be a wasted one.
130
- const savedRef = useRef<T>(value);
131
- const draftRef = useRef<T>(value);
132
- const inFlightRef = useRef(false);
133
- const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
134
- const mountedRef = useRef(true);
135
-
136
- // Latest-ref for the callbacks and comparators, so a caller passing inline
137
- // functions (all of them) does not invalidate the timer on every render.
138
- const onSaveRef = useRef(onSave);
139
- const onErrorRef = useRef(onError);
140
- const equalsRef = useRef(equals);
141
- useEffect(() => {
142
- onSaveRef.current = onSave;
143
- onErrorRef.current = onError;
144
- equalsRef.current = equals;
145
- });
146
-
147
- useEffect(() => {
148
- mountedRef.current = true;
149
- return () => {
150
- mountedRef.current = false;
151
- if (timerRef.current) clearTimeout(timerRef.current);
152
- };
153
- }, []);
154
-
155
- // A named inner function so the settle path can start the next round by calling it
156
- // again; a `useCallback` cannot refer to its own binding while it is being built.
157
- const flush = useCallback(() => {
158
- const run = async (): Promise<void> => {
159
- if (inFlightRef.current) return; // the settle path below picks the new draft up
160
- const next = draftRef.current;
161
- if (equalsRef.current(next, savedRef.current)) return;
162
-
163
- inFlightRef.current = true;
164
- setState("pending");
165
- setError(null);
166
- try {
167
- await onSaveRef.current(next);
168
- savedRef.current = next;
169
- inFlightRef.current = false;
170
- if (!mountedRef.current) return;
171
- // The draft may have moved while this was in the air. Compare against what is
172
- // on screen NOW, not against what was sent.
173
- if (equalsRef.current(draftRef.current, next)) {
174
- setState("synced");
175
- } else {
176
- setState("edited");
177
- void run();
178
- }
179
- } catch (cause) {
180
- inFlightRef.current = false;
181
- const err = toError(cause);
182
- onErrorRef.current?.(err);
183
- if (!mountedRef.current) return;
184
- setState("error");
185
- setError(err);
186
- }
187
- };
188
- return run();
189
- }, []);
190
-
191
- const setValue = useCallback(
192
- (next: T) => {
193
- draftRef.current = next;
194
- setDraft(next);
195
- if (timerRef.current) clearTimeout(timerRef.current);
196
-
197
- if (equalsRef.current(next, savedRef.current)) {
198
- // Typed back to what the server already has. Nothing to send, and an error
199
- // from the previous attempt no longer describes anything.
200
- setState(inFlightRef.current ? "pending" : "synced");
201
- setError(null);
202
- return;
203
- }
204
-
205
- setState("edited");
206
- setError(null);
207
- if (debounceMs > 0) timerRef.current = setTimeout(() => void flush(), debounceMs);
208
- },
209
- [debounceMs, flush],
210
- );
211
-
212
- const save = useCallback(() => {
213
- if (timerRef.current) clearTimeout(timerRef.current);
214
- void flush();
215
- }, [flush]);
216
-
217
- const retry = save;
218
-
219
- const reset = useCallback(() => {
220
- if (timerRef.current) clearTimeout(timerRef.current);
221
- draftRef.current = savedRef.current;
222
- setDraft(savedRef.current);
223
- setState(inFlightRef.current ? "pending" : "synced");
224
- setError(null);
225
- }, []);
226
-
227
- // Anything that is not `synced` has something not yet on the server: `edited` and
228
- // `error` obviously, and `pending` too — the write is in the air, not landed.
229
- // Derived from state rather than by comparing against `savedRef` during render,
230
- // because a ref read here would not re-render when the comparison's answer changes.
231
- const dirty = state !== "synced";
232
-
233
- // Adopt a new server value ONLY when there is nothing local to lose.
234
- useEffect(() => {
235
- if (inFlightRef.current) return;
236
- if (!equalsRef.current(draftRef.current, savedRef.current)) return; // dirty: keep it
237
- if (equalsRef.current(value, savedRef.current)) return; // unchanged
238
- savedRef.current = value;
239
- draftRef.current = value;
240
- setDraft(value);
241
- setState("synced");
242
- setError(null);
243
- }, [value]);
244
-
245
- return { value: draft, setValue, state, error, dirty, save, retry, reset };
246
- }
247
-
248
- const STATE_STYLE: Record<FieldSyncState, { color: string; Icon: typeof Check }> = {
249
- synced: { color: "var(--status-synced)", Icon: Check },
250
- edited: { color: "var(--status-edited)", Icon: Pencil },
251
- pending: { color: "var(--status-pending)", Icon: Loader2 },
252
- error: { color: "var(--status-error)", Icon: AlertCircle },
253
- };
254
-
255
- /** @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53. */
256
- export interface FieldSyncIndicatorProps {
257
- state: FieldSyncState;
258
- /** The failure. Its message becomes the tooltip when `state === "error"`. */
259
- error?: Error | null;
260
- /** Override any of the five English defaults. */
261
- labels?: LabelOverride<FieldSyncLabels>;
262
- /** Render the label beside the icon instead of only in the tooltip. Always on at
263
- * Large and Extra large (0.32, docs/text-size-harmonization.md §4 "No fact only in a
264
- * tooltip"): the reader who asked for bigger type gets the words, not a 14 px glyph
265
- * and a bubble. */
266
- showLabel?: boolean;
267
- /** When given, the error state renders a retry button after the icon. */
268
- onRetry?: () => void;
269
- className?: string;
270
- }
271
-
272
- /**
273
- * The affordance for {@link useFieldSync}: a coloured icon, and the reason on hover.
274
- *
275
- * **Every state has its own icon, and that is not decoration.** The four colours
276
- * include the green/red pair, which is the one combination this package's palette
277
- * otherwise refuses (see the note in `tokens.css`) because red-green colour blindness
278
- * affects roughly one man in twelve. The icon is what carries the meaning for them,
279
- * and what carries it into a greyscale print or a screenshot. WCAG 1.4.1 is the same
280
- * requirement stated formally.
281
- *
282
- * The state is also announced: the wrapper is a polite live region, so a screen
283
- * reader hears "Saving…" then "Saved" without the user going looking. `error` is
284
- * assertive instead — a failed write is worth interrupting for.
285
- *
286
- * @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53.
287
- */
288
- export function FieldSyncIndicator({
289
- state,
290
- error,
291
- labels,
292
- showLabel = false,
293
- onRetry,
294
- className,
295
- }: FieldSyncIndicatorProps) {
296
- const l = useKitLabels("fieldSync", DEFAULT_FIELD_SYNC_LABELS, labels);
297
- const large = useLargeText();
298
- showLabel = showLabel || large;
299
- const { color, Icon } = STATE_STYLE[state];
300
- const text = state === "error" ? (error?.message?.trim() ? error.message : l.error) : l[state];
301
-
302
- return (
303
- <span
304
- // The ICON carries the status colour; the words are `--text-secondary`, because
305
- // the amber of `edited` is a graphic colour (3:1), not a text colour (4.5:1).
306
- className={cn("inline-flex items-center gap-1.5 text-xs text-secondary", className)}
307
- // Polite for the three ordinary states so save chatter does not interrupt
308
- // typing; assertive for a failure, which the user has to know about now.
309
- role={state === "error" ? "alert" : "status"}
310
- aria-live={state === "error" ? "assertive" : "polite"}
311
- >
312
- <Tooltip label={showLabel ? undefined : text} redact={state === "error"}>
313
- <span className="inline-flex items-center gap-1.5">
314
- <Icon
315
- aria-hidden
316
- style={{ color }}
317
- className={cn("size-3.5 shrink-0", state === "pending" && "animate-spin")}
318
- />
319
- {/* Always in the DOM, so the live region has something to announce even
320
- when the label is visually a tooltip. */}
321
- <span className={showLabel ? undefined : "sr-only"}>{text}</span>
322
- </span>
323
- </Tooltip>
324
- {state === "error" && onRetry && (
325
- <button
326
- type="button"
327
- onClick={onRetry}
328
- // The kit's focus frame (0.32, §5), stood off the word.
329
- className={cn(
330
- "rounded underline underline-offset-2 hover:no-underline focus-visible:ring-offset-2 focus-visible:ring-offset-surface",
331
- FOCUS_RING,
332
- )}
333
- style={{ color }}
334
- >
335
- {l.retry}
336
- </button>
337
- )}
338
- </span>
339
- );
340
- }
341
-
342
- /**
343
- * The field's own frame, coloured by state — applied from the WRAPPER to whatever
344
- * native control sits inside it, so {@link FieldSyncRow} works with any of the kit's
345
- * inputs (and a caller's own) without each one growing a `syncState` prop.
346
- *
347
- * Border AND a 1px ring, for the reason {@link FIELD_INVALID} gives: a lone 1px
348
- * border loses a vertical edge to sub-pixel spread at 125% display scaling. The
349
- * `:focus` twins are what keep the state visible while the reader is typing —
350
- * the base field class's `focus:` brand colour is `(0,2,0)` and would otherwise win
351
- * over a descendant selector exactly when the field is in use.
352
- *
353
- * `synced` is green, but {@link FieldSyncRow} paints it only for a moment after a
354
- * save lands — a form of eight permanently green boxes says nothing the absence of
355
- * colour does not.
356
- *
357
- * Every class is a literal so Tailwind's scanner can see it.
358
- *
359
- * @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53.
360
- */
361
- export const FIELD_SYNC_FRAME: Record<FieldSyncState, string> = {
362
- synced:
363
- "[&_:is(input,select,textarea)]:border-[var(--status-synced)] [&_:is(input,select,textarea)]:ring-1 [&_:is(input,select,textarea)]:ring-[var(--status-synced)] [&_:is(input,select,textarea):focus]:border-[var(--status-synced)] [&_:is(input,select,textarea):focus]:ring-[var(--status-synced)]",
364
- edited:
365
- "[&_:is(input,select,textarea)]:border-[var(--status-edited)] [&_:is(input,select,textarea)]:ring-1 [&_:is(input,select,textarea)]:ring-[var(--status-edited)] [&_:is(input,select,textarea):focus]:border-[var(--status-edited)] [&_:is(input,select,textarea):focus]:ring-[var(--status-edited)]",
366
- pending:
367
- "[&_:is(input,select,textarea)]:border-[var(--status-pending)] [&_:is(input,select,textarea)]:ring-1 [&_:is(input,select,textarea)]:ring-[var(--status-pending)] [&_:is(input,select,textarea):focus]:border-[var(--status-pending)] [&_:is(input,select,textarea):focus]:ring-[var(--status-pending)]",
368
- error:
369
- "[&_:is(input,select,textarea)]:border-[var(--status-error)] [&_:is(input,select,textarea)]:ring-1 [&_:is(input,select,textarea)]:ring-[var(--status-error)] [&_:is(input,select,textarea):focus]:border-[var(--status-error)] [&_:is(input,select,textarea):focus]:ring-[var(--status-error)]",
370
- };
371
-
372
- /** How long the green "saved" frame and check stay after a save lands, in ms.
373
- *
374
- * @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53. */
375
- export const FIELD_SYNC_SAVED_MS = 1500;
376
-
377
- /** @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53. */
378
- export interface FieldSyncRowProps<T> extends Omit<FieldSyncIndicatorProps, "state" | "error" | "showLabel"> {
379
- sync: UseFieldSyncReturn<T>;
380
- children: ReactNode;
381
- /** Call `sync.save()` when focus leaves the field. Default true — together with the
382
- * hook's default `debounceMs: 0` this is "save on blur": nothing is written while
383
- * the reader is still typing, however long they pause. */
384
- saveOnBlur?: boolean;
385
- /** How long the saved confirmation shows. Default {@link FIELD_SYNC_SAVED_MS}. */
386
- savedMs?: number;
387
- }
388
-
389
- /**
390
- * A field wearing its sync state — as its FRAME COLOUR and an ICON AT THE END OF THE
391
- * FIELD, so the field never changes size (a helper line appearing under it moved
392
- * everything below it on every save):
393
- *
394
- * edited amber frame, pencil — changed, not yet saved
395
- * pending blue frame, spinning circle — for as long as the save is in flight
396
- * synced green frame, check — for {@link FIELD_SYNC_SAVED_MS} after a
397
- * save lands, then an ordinary field again
398
- * error red frame, alert mark — hover or focus the mark for the reason;
399
- * click it to retry
400
- *
401
- * It saves when focus LEAVES the field (`saveOnBlur`), not after a pause in typing: a
402
- * database write in the middle of a word is a write nobody asked for. Enter in a
403
- * single-line field is the caller's to wire to `sync.save`.
404
- *
405
- * Colour is never the only signal: every state has its own icon, and the state text is
406
- * always in the DOM as a live region — polite for the ordinary states, assertive for
407
- * a failure. The input gets end padding for the icon whether or not one is showing,
408
- * so the text never reflows when the state changes.
409
- *
410
- * @deprecated 0.52 — none: no app uses the FieldSync family (MOD-5); removed in 0.53.
411
- */
412
- export function FieldSyncRow<T>({
413
- sync,
414
- children,
415
- className,
416
- labels,
417
- onRetry,
418
- saveOnBlur = true,
419
- savedMs = FIELD_SYNC_SAVED_MS,
420
- }: FieldSyncRowProps<T>) {
421
- const l = useKitLabels("fieldSync", DEFAULT_FIELD_SYNC_LABELS, labels);
422
- const { state, error } = sync;
423
- const isError = state === "error";
424
- const text = isError ? (error?.message?.trim() ? error.message : l.error) : l[state];
425
- const retry = onRetry ?? sync.retry;
426
-
427
- // The saved confirmation: on only for the moment after a save lands. Keyed on the
428
- // TRANSITION pending → synced, so a field that starts synced shows nothing. The
429
- // transition is seen while rendering, against the previous state; the effect only
430
- // owns the timer that turns it off again.
431
- const [previous, setPrevious] = useState(state);
432
- const [justSaved, setJustSaved] = useState(false);
433
- if (state !== previous) {
434
- setPrevious(state);
435
- setJustSaved(state === "synced" && previous === "pending");
436
- }
437
- useEffect(() => {
438
- if (!justSaved) return;
439
- const t = setTimeout(() => setJustSaved(false), savedMs);
440
- return () => clearTimeout(t);
441
- }, [justSaved, savedMs]);
442
- const shown: FieldSyncState | null = state === "synced" ? (justSaved ? "synced" : null) : state;
443
-
444
- return (
445
- /* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- not an interaction:
446
- `onBlur` listens for focus leaving the row's own controls (which are the
447
- interactive elements) to save; the wrapper itself is never focused. */
448
- <div
449
- data-field-sync={state}
450
- className={cn(
451
- // `relative` for the icon and for the sr-only live region's containing block.
452
- "relative [&_:is(input,select,textarea)]:pe-9",
453
- shown && FIELD_SYNC_FRAME[shown],
454
- className,
455
- )}
456
- onBlur={
457
- saveOnBlur
458
- ? (e) => {
459
- // Focus moving between two controls INSIDE the row is not leaving it.
460
- if (!e.currentTarget.contains(e.relatedTarget as Node | null)) sync.save();
461
- }
462
- : undefined
463
- }
464
- >
465
- {children}
466
- <span className="pointer-events-none absolute inset-y-0 end-0 flex items-center pe-3">
467
- {state === "edited" && <PencilLine aria-hidden className="size-4 text-[var(--status-edited)]" />}
468
- {state === "pending" && (
469
- <Loader2
470
- aria-hidden
471
- className="size-4 animate-spin text-[var(--status-pending)] motion-reduce:animate-none"
472
- />
473
- )}
474
- {state === "synced" && (
475
- <Check
476
- aria-hidden
477
- className={cn(
478
- "size-4 text-[var(--status-synced)] transition-opacity duration-500 motion-reduce:transition-none",
479
- justSaved ? "opacity-100" : "opacity-0",
480
- )}
481
- />
482
- )}
483
- {isError && (
484
- <Tooltip label={text} portal redact>
485
- <button
486
- type="button"
487
- onClick={retry}
488
- aria-label={l.retry}
489
- className={cn(
490
- "pointer-events-auto flex rounded-full text-[var(--status-error)] focus-visible:ring-offset-2 focus-visible:ring-offset-surface",
491
- FOCUS_RING,
492
- )}
493
- >
494
- <AlertCircle aria-hidden className="size-4" />
495
- </button>
496
- </Tooltip>
497
- )}
498
- </span>
499
- <span role={isError ? "alert" : "status"} aria-live={isError ? "assertive" : "polite"} className="sr-only">
500
- {shown === null ? "" : text}
501
- </span>
502
- </div>
503
- );
504
- }
@@ -1,72 +0,0 @@
1
- import { cn } from "../lib/cn";
2
- import { NavPills } from "./nav-pills";
3
- import type { NavPillItem, NavPillLinkProps } from "./nav-pills";
4
- import type { ReactElement, Ref } from "react";
5
-
6
- /** @deprecated 0.52 — `NavPillsProps` with `layout="scroll"`, what SectionNav wraps; removed in
7
- * 0.53 (no app renders SectionNav: refactor audit 2026-10-30, MOD-5). */
8
- export interface SectionNavProps<T extends string> {
9
- /** The section's pages, each with its `href` (a pill without one is a button that
10
- * calls `onSelect`). Labels short: the row is one line. */
11
- items: NavPillItem<T>[];
12
- /** The page that is open. `null`: none of them. */
13
- current: T | null;
14
- /** The section's name — the landmark's accessible name ("Accounting"). */
15
- label: string;
16
- /** Called with a pill's value on a click, before the router follows its link. */
17
- onSelect?: (value: T) => void;
18
- /** Your router's link. Default: the `<UiKitProvider linkComponent>`, then `<a>`. */
19
- renderLink?: (props: NavPillLinkProps) => ReactElement;
20
- /** Default `true`: only below `md`, where the sidebar that lists the same pages is
21
- * gone. `false` shows it at every width. */
22
- phoneOnly?: boolean;
23
- className?: string;
24
- ref?: Ref<HTMLElement>;
25
- }
26
-
27
- /**
28
- * The pages of a section on a phone, as one row of pills under the page title (0.49
29
- * KIT-6) — kastlan's section pills, which each section page drew by hand.
30
- *
31
- * On a desktop the sidebar lists a group's pages; on a phone the AppShell's bar holds
32
- * the groups, and a group's pages are a sheet away. This row puts them on the page
33
- * itself: {@link NavPills} with `layout="scroll"` — one line that scrolls sideways, faded
34
- * where it is cut, the open page scrolled into view (the row only, never the page). At
35
- * most 48 px high: 44 px pills, the touch target a finger needs, and 2 px above and
36
- * below. Each pill is a link (`aria-current="page"` on the open one) and its own tab
37
- * stop; the row is a `<nav>` named by `label`.
38
- *
39
- * Place it right under the page's title (`PageHeader`); the AppShell's own row of a
40
- * group's pages above the bar (`mobileSubNav`) is the shell-wide alternative — use one,
41
- * not both, for the same pages.
42
- *
43
- * @deprecated 0.52 — `<NavPills layout="scroll" itemClassName="min-h-11 focus-visible:ring-inset"
44
- * className="md:hidden">`, the same row; removed in 0.53. kastlan, whose section pills it
45
- * was made for (0.49 KIT-6), never adopted it: no app renders it (refactor audit
46
- * 2026-10-30, MOD-5).
47
- */
48
- export function SectionNav<T extends string>({
49
- items,
50
- current,
51
- label,
52
- onSelect,
53
- renderLink,
54
- phoneOnly = true,
55
- className,
56
- ref,
57
- }: SectionNavProps<T>) {
58
- return (
59
- <NavPills
60
- ref={ref}
61
- aria-label={label}
62
- items={items}
63
- current={current}
64
- onSelect={onSelect}
65
- renderLink={renderLink}
66
- layout="scroll"
67
- // The ring inside the pill: the row scrolls, so it clips what leaves its box.
68
- itemClassName="min-h-11 focus-visible:ring-inset"
69
- className={cn("py-0.5 large:py-0", phoneOnly && "md:hidden", className)}
70
- />
71
- );
72
- }
@@ -1,13 +0,0 @@
1
- // The English words of ./sign-chip, in a module with no component code: the English
2
- // catalogue (src/i18n/defaults.ts) imports them without the component, so `en` loads as one
3
- // chunk like the other languages (0.34, KS U8). ./sign-chip re-exports them.
4
-
5
- import type { SignChipLabels } from "./sign-chip";
6
-
7
- /** @deprecated 0.52 — a `Chip` of your own, as keksdose's DirectionToggle is (MOD-5); removed in 0.53. */
8
- export const DEFAULT_SIGN_CHIP_LABELS: SignChipLabels = {
9
- outflow: "Outflow",
10
- inflow: "Inflow",
11
- direction: (current, next) => `Direction: ${current} — switch to ${next}`,
12
- switchTo: (next) => `Switch to ${next}`,
13
- };