@eifi1/ui-kit 0.17.0 → 0.19.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 (210) hide show
  1. package/README.md +83 -4
  2. package/dist/chart.d.ts +13 -1
  3. package/dist/components/account-chips.d.ts +153 -0
  4. package/dist/components/account-chips.js +135 -0
  5. package/dist/components/account-chips.js.map +1 -0
  6. package/dist/components/account-settings-labels.d.ts +10 -2
  7. package/dist/components/account-settings-labels.js +3 -0
  8. package/dist/components/account-settings-labels.js.map +1 -1
  9. package/dist/components/amount-input.d.ts +13 -1
  10. package/dist/components/button-group.d.ts +13 -1
  11. package/dist/components/calculator.d.ts +13 -1
  12. package/dist/components/chip.d.ts +25 -1
  13. package/dist/components/chip.js +143 -6
  14. package/dist/components/chip.js.map +1 -1
  15. package/dist/components/confirm-dialog.d.ts +42 -1
  16. package/dist/components/confirm-dialog.js +36 -5
  17. package/dist/components/confirm-dialog.js.map +1 -1
  18. package/dist/components/copy-button.d.ts +13 -1
  19. package/dist/components/danger-confirm.d.ts +55 -4
  20. package/dist/components/danger-confirm.js +67 -30
  21. package/dist/components/danger-confirm.js.map +1 -1
  22. package/dist/components/data-table-cells.d.ts +1 -1
  23. package/dist/components/data-table-filter-popover.d.ts +1 -1
  24. package/dist/components/data-table-filters.d.ts +1 -1
  25. package/dist/components/data-table.d.ts +1 -1
  26. package/dist/components/data-table.js +2 -0
  27. package/dist/components/data-table.js.map +1 -1
  28. package/dist/components/facing-pair.d.ts +13 -1
  29. package/dist/components/file-button.d.ts +13 -1
  30. package/dist/components/file-dropzone.d.ts +13 -1
  31. package/dist/components/floating-panel.d.ts +4 -1
  32. package/dist/components/floating-panel.js +15 -1
  33. package/dist/components/floating-panel.js.map +1 -1
  34. package/dist/components/form-actions.d.ts +13 -1
  35. package/dist/components/form-actions.js +3 -0
  36. package/dist/components/form-actions.js.map +1 -1
  37. package/dist/components/legal.d.ts +84 -0
  38. package/dist/components/legal.js +55 -0
  39. package/dist/components/legal.js.map +1 -0
  40. package/dist/components/money-field.d.ts +13 -1
  41. package/dist/components/number-field.d.ts +14 -2
  42. package/dist/components/number-field.js +23 -22
  43. package/dist/components/number-field.js.map +1 -1
  44. package/dist/components/number-input.d.ts +13 -1
  45. package/dist/components/numpad-sheet.d.ts +13 -1
  46. package/dist/components/passkeys-setting.d.ts +27 -1
  47. package/dist/components/passkeys-setting.js +31 -5
  48. package/dist/components/passkeys-setting.js.map +1 -1
  49. package/dist/components/progress-bar.d.ts +15 -1
  50. package/dist/components/progress-bar.js +8 -1
  51. package/dist/components/progress-bar.js.map +1 -1
  52. package/dist/components/reauth-dialog.d.ts +90 -0
  53. package/dist/components/reauth-dialog.js +158 -0
  54. package/dist/components/reauth-dialog.js.map +1 -0
  55. package/dist/components/series-chart.d.ts +13 -1
  56. package/dist/components/server-wake.d.ts +60 -0
  57. package/dist/components/server-wake.js +79 -0
  58. package/dist/components/server-wake.js.map +1 -0
  59. package/dist/components/settings-fields.d.ts +13 -1
  60. package/dist/components/share-card.d.ts +64 -0
  61. package/dist/components/share-card.js +350 -0
  62. package/dist/components/share-card.js.map +1 -0
  63. package/dist/components/status-dot.d.ts +2 -0
  64. package/dist/components/text-link.d.ts +13 -1
  65. package/dist/components/time-input.d.ts +13 -1
  66. package/dist/components/toast.d.ts +10 -1
  67. package/dist/components/toast.js +42 -2
  68. package/dist/components/toast.js.map +1 -1
  69. package/dist/components/toggle-group.js +5 -2
  70. package/dist/components/toggle-group.js.map +1 -1
  71. package/dist/components/translation-review-editor.d.ts +56 -0
  72. package/dist/components/translation-review-editor.js +159 -0
  73. package/dist/components/translation-review-editor.js.map +1 -0
  74. package/dist/components/translation-review-labels.d.ts +92 -0
  75. package/dist/components/translation-review-labels.js +67 -0
  76. package/dist/components/translation-review-labels.js.map +1 -0
  77. package/dist/components/translation-review-parts.d.ts +97 -0
  78. package/dist/components/translation-review-parts.js +163 -0
  79. package/dist/components/translation-review-parts.js.map +1 -0
  80. package/dist/components/translation-review.d.ts +94 -0
  81. package/dist/components/translation-review.js +344 -0
  82. package/dist/components/translation-review.js.map +1 -0
  83. package/dist/components/ui.d.ts +13 -1
  84. package/dist/components/ui.js +43 -28
  85. package/dist/components/ui.js.map +1 -1
  86. package/dist/components/use-table-state.d.ts +1 -1
  87. package/dist/components/user-avatar.d.ts +2 -0
  88. package/dist/components/write-lock.d.ts +68 -0
  89. package/dist/components/write-lock.js +33 -0
  90. package/dist/components/write-lock.js.map +1 -0
  91. package/dist/{data-table-CpkWUJBY.d.ts → data-table-3mi2R3so.d.ts} +19 -1
  92. package/dist/data-table.d.ts +1 -1
  93. package/dist/hooks/use-file-drop.d.ts +13 -1
  94. package/dist/hooks/use-overlay-history.js +16 -0
  95. package/dist/hooks/use-overlay-history.js.map +1 -1
  96. package/dist/i18n/defaults.d.ts +13 -1
  97. package/dist/i18n/defaults.js +15 -1
  98. package/dist/i18n/defaults.js.map +1 -1
  99. package/dist/i18n/german.d.ts +81 -0
  100. package/dist/i18n/{locales/de.js → german.js} +110 -9
  101. package/dist/i18n/german.js.map +1 -0
  102. package/dist/i18n/kit-labels.d.ts +13 -1
  103. package/dist/i18n/kit-labels.js +5 -0
  104. package/dist/i18n/kit-labels.js.map +1 -1
  105. package/dist/i18n/languages.d.ts +243 -0
  106. package/dist/i18n/languages.js +70 -0
  107. package/dist/i18n/languages.js.map +1 -0
  108. package/dist/i18n/locales/de-CH.d.ts +26 -8
  109. package/dist/i18n/locales/de-CH.js +7 -3
  110. package/dist/i18n/locales/de-CH.js.map +1 -1
  111. package/dist/i18n/locales/en.d.ts +13 -1
  112. package/dist/i18n/locales/en.js +8 -0
  113. package/dist/i18n/locales/en.js.map +1 -1
  114. package/dist/i18n/locales/es.d.ts +13 -1
  115. package/dist/i18n/locales/es.js +127 -27
  116. package/dist/i18n/locales/es.js.map +1 -1
  117. package/dist/i18n/locales/fr.d.ts +13 -1
  118. package/dist/i18n/locales/fr.js +101 -1
  119. package/dist/i18n/locales/fr.js.map +1 -1
  120. package/dist/i18n/locales/hu.d.ts +13 -1
  121. package/dist/i18n/locales/hu.js +105 -1
  122. package/dist/i18n/locales/hu.js.map +1 -1
  123. package/dist/i18n/locales/it.d.ts +13 -1
  124. package/dist/i18n/locales/it.js +134 -34
  125. package/dist/i18n/locales/it.js.map +1 -1
  126. package/dist/i18n/locales/zh.d.ts +13 -1
  127. package/dist/i18n/locales/zh.js +101 -1
  128. package/dist/i18n/locales/zh.js.map +1 -1
  129. package/dist/i18n/review.d.ts +102 -0
  130. package/dist/i18n/review.js +158 -0
  131. package/dist/i18n/review.js.map +1 -0
  132. package/dist/i18n/swiss.d.ts +3 -3
  133. package/dist/i18n/swiss.js.map +1 -1
  134. package/dist/index.d.ts +17 -4
  135. package/dist/index.js +97 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/{kit-labels-C4uB_zmg.d.ts → kit-labels-D1J2_jyD.d.ts} +236 -9
  138. package/dist/lib/floating-stack.d.ts +31 -0
  139. package/dist/lib/floating-stack.js +42 -0
  140. package/dist/lib/floating-stack.js.map +1 -0
  141. package/dist/lib/server-wake.d.ts +146 -0
  142. package/dist/lib/server-wake.js +122 -0
  143. package/dist/lib/server-wake.js.map +1 -0
  144. package/dist/lib/translation-review.d.ts +232 -0
  145. package/dist/lib/translation-review.js +194 -0
  146. package/dist/lib/translation-review.js.map +1 -0
  147. package/dist/rhf/fields.d.ts +13 -1
  148. package/dist/rhf/form.d.ts +13 -1
  149. package/dist/rhf.d.ts +13 -1
  150. package/dist/search/global-search.d.ts +3 -1
  151. package/dist/search/global-search.js.map +1 -1
  152. package/dist/shell/app-shell.d.ts +13 -1
  153. package/dist/shell/top-bar-brand.d.ts +13 -1
  154. package/dist/shell/topbar-action-menu.d.ts +2 -0
  155. package/dist/shell.d.ts +13 -1
  156. package/dist/wizard/stepper-nav.d.ts +13 -1
  157. package/dist/wizard.d.ts +13 -1
  158. package/package.json +1 -1
  159. package/src/components/account-chips.tsx +302 -0
  160. package/src/components/account-settings-labels.ts +16 -2
  161. package/src/components/chip.tsx +239 -6
  162. package/src/components/confirm-dialog.tsx +82 -7
  163. package/src/components/danger-confirm.tsx +118 -33
  164. package/src/components/data-table.tsx +20 -0
  165. package/src/components/floating-panel.tsx +19 -1
  166. package/src/components/form-actions.tsx +22 -3
  167. package/src/components/legal.tsx +159 -0
  168. package/src/components/number-field.tsx +32 -26
  169. package/src/components/passkeys-setting.tsx +68 -7
  170. package/src/components/progress-bar.tsx +21 -1
  171. package/src/components/reauth-dialog.tsx +273 -0
  172. package/src/components/server-wake.tsx +156 -0
  173. package/src/components/share-card.tsx +615 -0
  174. package/src/components/toast.tsx +72 -2
  175. package/src/components/toggle-group.tsx +5 -2
  176. package/src/components/translation-review-editor.tsx +261 -0
  177. package/src/components/translation-review-labels.ts +152 -0
  178. package/src/components/translation-review-parts.tsx +269 -0
  179. package/src/components/translation-review.tsx +502 -0
  180. package/src/components/ui.tsx +89 -32
  181. package/src/components/write-lock.tsx +96 -0
  182. package/src/hooks/use-overlay-history.ts +51 -0
  183. package/src/i18n/defaults.ts +14 -0
  184. package/src/i18n/{locales/de.ts → german.ts} +120 -13
  185. package/src/i18n/kit-labels.tsx +29 -2
  186. package/src/i18n/languages.ts +285 -0
  187. package/src/i18n/locales/de-CH.ts +17 -8
  188. package/src/i18n/locales/en.ts +8 -0
  189. package/src/i18n/locales/es.ts +128 -26
  190. package/src/i18n/locales/fr.ts +103 -0
  191. package/src/i18n/locales/hu.ts +107 -0
  192. package/src/i18n/locales/it.ts +135 -33
  193. package/src/i18n/locales/zh.ts +102 -0
  194. package/src/i18n/review.ts +193 -0
  195. package/src/i18n/swiss.ts +3 -3
  196. package/src/index.ts +86 -1
  197. package/src/lib/floating-stack.ts +66 -0
  198. package/src/lib/server-wake.ts +291 -0
  199. package/src/lib/translation-review.ts +465 -0
  200. package/src/search/global-search.tsx +3 -1
  201. package/dist/i18n/locales/de-CH-informal.d.ts +0 -61
  202. package/dist/i18n/locales/de-CH-informal.js +0 -8
  203. package/dist/i18n/locales/de-CH-informal.js.map +0 -1
  204. package/dist/i18n/locales/de-informal.d.ts +0 -82
  205. package/dist/i18n/locales/de-informal.js +0 -37
  206. package/dist/i18n/locales/de-informal.js.map +0 -1
  207. package/dist/i18n/locales/de.d.ts +0 -66
  208. package/dist/i18n/locales/de.js.map +0 -1
  209. package/src/i18n/locales/de-CH-informal.ts +0 -10
  210. package/src/i18n/locales/de-informal.ts +0 -61
@@ -43,9 +43,20 @@ const DEFAULT_TOAST_LABELS = {
43
43
  let activeLabels = DEFAULT_TOAST_LABELS;
44
44
  const TOAST_ACTION_DURATION = 8e3;
45
45
  const privately = (node) => /* @__PURE__ */ jsx("span", { "data-private": "", children: node });
46
+ const ID_CLASS = "kit-toast-id-";
47
+ const idClass = (id) => `${ID_CLASS}${typeof id === "number" ? "n" : "s"}-${encodeURIComponent(String(id))}`;
48
+ function readToastId(el) {
49
+ for (const token of el.classList) {
50
+ if (!token.startsWith(ID_CLASS)) continue;
51
+ const kind = token.charAt(ID_CLASS.length);
52
+ const raw = decodeURIComponent(token.slice(ID_CLASS.length + 2));
53
+ return kind === "n" ? Number(raw) : raw;
54
+ }
55
+ return null;
56
+ }
46
57
  function toSonnerData(opts, id) {
47
- const { redact, description, duration, action, ...rest } = opts ?? {};
48
- const data = { ...rest, id };
58
+ const { redact, description, duration, action, className, ...rest } = opts ?? {};
59
+ const data = { ...rest, id, className: className ? `${idClass(id)} ${className}` : idClass(id) };
49
60
  if (description !== void 0) data.description = redact ? privately(description) : description;
50
61
  if (action) data.action = action;
51
62
  const resolved = duration ?? (action ? TOAST_ACTION_DURATION : void 0);
@@ -169,6 +180,7 @@ function Toaster({
169
180
  swipeDirections = ALL_DIRECTIONS,
170
181
  offset,
171
182
  mobileOffset,
183
+ dismissOnMiddleClick = true,
172
184
  className,
173
185
  style,
174
186
  ...rest
@@ -191,6 +203,34 @@ function Toaster({
191
203
  if (activeLabels === labels) activeLabels = DEFAULT_TOAST_LABELS;
192
204
  };
193
205
  }, [labels]);
206
+ useEffect(() => {
207
+ if (!dismissOnMiddleClick || !mod) return;
208
+ const toastUnder = (e) => {
209
+ if (e.button !== 1 || !(e.target instanceof Element)) return null;
210
+ const li = e.target.closest("[data-sonner-toast]");
211
+ if (!li || li.dataset.dismissible === "false") return null;
212
+ const control = e.target.closest("a[href], button, input, select, textarea, [role='button'], [role='link']");
213
+ if (control && li.contains(control)) return null;
214
+ return li;
215
+ };
216
+ const onDown = (e) => {
217
+ if (toastUnder(e)) e.preventDefault();
218
+ };
219
+ const onAux = (e) => {
220
+ const li = toastUnder(e);
221
+ if (!li) return;
222
+ e.preventDefault();
223
+ const id = readToastId(li);
224
+ if (id !== null) mod.toast.dismiss(id);
225
+ else li.querySelector("[data-close-button]")?.click();
226
+ };
227
+ document.addEventListener("mousedown", onDown);
228
+ document.addEventListener("auxclick", onAux);
229
+ return () => {
230
+ document.removeEventListener("mousedown", onDown);
231
+ document.removeEventListener("auxclick", onAux);
232
+ };
233
+ }, [dismissOnMiddleClick, mod]);
194
234
  const documentTheme = useSyncExternalStore(subscribeDocumentTheme, readDocumentTheme, () => "light");
195
235
  const phone = useMediaQuery(PHONE_QUERY, false);
196
236
  const resolved = position ?? (phone ? "bottom-center" : "top-center");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/toast.tsx"],"sourcesContent":["import { useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, MouseEvent, ReactElement, ReactNode } from \"react\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { PHONE_QUERY } from \"./ui\";\n\n/**\n * The kit's toast layer: a `toast` API and a `<Toaster>`, over sonner.\n *\n * WHY A WRAPPER AND NOT \"USE SONNER\". Both apps mounted sonner by hand and carried the\n * same policy in it — bottom-centre on a phone so the toast covers neither the header\n * nor the bottom nav, a lift above that nav, swipe in every direction, a z-index above\n * every overlay, the theme fed in from the store — and one of them wrote that policy\n * twice. `toast` mirrors sonner's call shape, so migrating is an import swap:\n *\n * import { toast } from \"@eifi1/ui-kit\"; // was: from \"sonner\"\n *\n * WHY SONNER IS LOADED LAZILY. It is an OPTIONAL peer, and this module is re-exported by\n * the barrel: a static import here would make every app that imports a Button install\n * it (see optional-peer-imports.test.tsx). So nothing here imports it statically. The\n * `<Toaster>` loads it when it mounts — long before anyone clicks anything — and a call\n * made before that is queued and replayed in order the moment it has loaded. Every call\n * returns its id synchronously anyway: the id is chosen here, not by sonner.\n */\n\ntype Sonner = typeof import(\"sonner\");\ntype SonnerData = NonNullable<Parameters<Sonner[\"toast\"]>[1]>;\n\n/* ── Loading sonner ──────────────────────────────────────────────────────── */\n\nlet sonner: Sonner | null = null;\nlet loading: Promise<Sonner | null> | null = null;\nconst queue: Array<(s: Sonner) => void> = [];\n\nfunction loadSonner(): Promise<Sonner | null> {\n loading ??= import(\"sonner\").then(\n (mod) => {\n sonner = mod;\n // Flushed in the SAME callback that sets `sonner`, so a call arriving between\n // the two cannot overtake one that was queued before it.\n for (const fn of queue.splice(0)) fn(mod);\n return mod;\n },\n () => {\n queue.length = 0;\n console.warn(\n \"@eifi1/ui-kit: `toast` needs the optional peer `sonner` — install it (npm i sonner) to show toasts.\",\n );\n return null;\n },\n );\n return loading;\n}\n\nfunction withSonner(fn: (s: Sonner) => void): void {\n if (sonner) {\n fn(sonner);\n return;\n }\n queue.push(fn);\n void loadSonner();\n}\n\nlet counter = 0;\nconst nextId = () => `kit-toast-${++counter}`;\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** The words the toast layer says. `close` and `notifications` are read by a screen\n * reader (the close button's name, the toast region's name); `undo` and `redo` are\n * the default action labels of {@link toast.undo} / {@link toast.redo}. */\nexport interface ToastLabels {\n close: string;\n notifications: string;\n undo: string;\n redo: string;\n}\n\nexport const DEFAULT_TOAST_LABELS: ToastLabels = {\n close: \"Close notification\",\n notifications: \"Notifications\",\n undo: \"Undo\",\n redo: \"Redo\",\n};\n\n/** What the mounted `<Toaster>` resolved from `<UiKitProvider>` — so `toast.undo()`,\n * which is called from mutation callbacks and not from a component, still says\n * \"Rückgängig\" in a German app. */\nlet activeLabels: ToastLabels = DEFAULT_TOAST_LABELS;\n\n/* ── The API ─────────────────────────────────────────────────────────────── */\n\nexport type ToastId = string | number;\n\n/** A button on the toast. Clicking it dismisses the toast, unless `onClick` calls\n * `event.preventDefault()`. */\nexport interface ToastAction {\n label: ReactNode;\n onClick: (event: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport interface ToastOptions {\n /** Re-using an id REPLACES the toast on screen with that id (in place — it does not\n * stack a second one), which is how a toast is updated. Default: a fresh id. */\n id?: ToastId;\n description?: ReactNode;\n action?: ToastAction;\n /** A second, quieter button (sonner's `cancel`). */\n cancel?: ToastAction;\n /** Milliseconds; `Infinity` keeps it until dismissed. Default 4s — or\n * {@link TOAST_ACTION_DURATION} when there is an `action`, so there is time to\n * read the message AND reach the button. */\n duration?: number;\n /** Called when the toast is closed by the user (close button, swipe, action). */\n onDismiss?: (toast: { id: ToastId }) => void;\n /** Called when the toast times out. */\n onAutoClose?: (toast: { id: ToastId }) => void;\n /** Wrap the message and the description in `data-private`, so an app's demo /\n * privacy mode blurs them like every other sensitive value. */\n redact?: boolean;\n /** Replaces the tone's icon. */\n icon?: ReactNode;\n /** `false`: no close button, no swipe. */\n dismissible?: boolean;\n /** Per toast, over the `<Toaster>`'s `closeButton`. */\n closeButton?: boolean;\n className?: string;\n style?: CSSProperties;\n}\n\n/** The default duration of a toast that carries an action (8s rather than 4s). */\nexport const TOAST_ACTION_DURATION = 8000;\n\ntype Kind = \"default\" | \"success\" | \"error\" | \"warning\" | \"info\" | \"loading\";\n\nconst privately = (node: ReactNode) => <span data-private=\"\">{node}</span>;\n\nfunction toSonnerData(opts: ToastOptions | undefined, id: ToastId): SonnerData {\n const { redact, description, duration, action, ...rest } = opts ?? {};\n const data: SonnerData = { ...rest, id };\n if (description !== undefined) data.description = redact ? privately(description) : description;\n if (action) data.action = action;\n const resolved = duration ?? (action ? TOAST_ACTION_DURATION : undefined);\n if (resolved !== undefined) data.duration = resolved;\n return data;\n}\n\nfunction show(kind: Kind, message: ReactNode, opts?: ToastOptions): ToastId {\n const id = opts?.id ?? nextId();\n const title = opts?.redact ? privately(message) : message;\n const data = toSonnerData(opts, id);\n withSonner((s) => {\n if (kind === \"default\") s.toast(title, data);\n else s.toast[kind](title, data);\n });\n return id;\n}\n\nexport interface ToastPromiseOptions<T> extends ToastOptions {\n loading: ReactNode;\n /** The success message, or a function of the resolved value. Omitted: the loading\n * toast is dismissed. */\n success?: ReactNode | ((value: T) => ReactNode);\n /** The error message, or a function of the rejection. Omitted: dismissed. */\n error?: ReactNode | ((error: unknown) => ReactNode);\n finally?: () => void;\n}\n\nexport interface ToastUndoOptions extends Omit<ToastOptions, \"action\"> {\n /** Called when the button is pressed. */\n onUndo: () => void;\n /** Default: `toast.undo` from `<UiKitProvider>` (\"Undo\"). */\n label?: ReactNode;\n /** Default `success` — the step the toast reports worked. */\n tone?: Exclude<Kind, \"loading\">;\n}\n\nexport interface ToastRedoOptions extends Omit<ToastUndoOptions, \"onUndo\"> {\n onRedo: () => void;\n}\n\nfunction undoable(\n message: ReactNode,\n { tone = \"success\", label, run, ...opts }: Omit<ToastUndoOptions, \"onUndo\"> & { run: () => void },\n fallback: ReactNode,\n): ToastId {\n return show(tone, message, {\n ...opts,\n action: { label: label ?? fallback, onClick: () => run() },\n });\n}\n\n/**\n * Show a toast. The same shape as sonner's `toast`, so an app migrates by changing the\n * import: `toast(msg, opts)`, `toast.success` / `error` / `warning` / `info` /\n * `loading`, `toast.promise`, `toast.dismiss`, `toast.custom`. Each returns the toast's\n * id; pass it back as `id` to replace that toast in place.\n *\n * Needs a mounted {@link Toaster}. Messages may be any ReactNode.\n */\nexport const toast = Object.assign(\n (message: ReactNode, opts?: ToastOptions): ToastId => show(\"default\", message, opts),\n {\n message: (message: ReactNode, opts?: ToastOptions) => show(\"default\", message, opts),\n success: (message: ReactNode, opts?: ToastOptions) => show(\"success\", message, opts),\n error: (message: ReactNode, opts?: ToastOptions) => show(\"error\", message, opts),\n warning: (message: ReactNode, opts?: ToastOptions) => show(\"warning\", message, opts),\n info: (message: ReactNode, opts?: ToastOptions) => show(\"info\", message, opts),\n /** A spinner that does not time out — replace it (same `id`) or dismiss it. */\n loading: (message: ReactNode, opts?: ToastOptions) => show(\"loading\", message, opts),\n\n /**\n * A loading toast that becomes the success or the error toast, in place, when\n * `promise` settles. Returns the toast's id; the promise itself is the caller's.\n */\n promise<T>(promise: Promise<T> | (() => Promise<T>), options: ToastPromiseOptions<T>): ToastId {\n const { loading: pending, success, error, finally: onFinally, ...opts } = options;\n const id = show(\"loading\", pending, opts);\n const same = { ...opts, id };\n Promise.resolve()\n .then(() => (typeof promise === \"function\" ? promise() : promise))\n .then(\n (value) => {\n if (success === undefined) toast.dismiss(id);\n else show(\"success\", typeof success === \"function\" ? success(value) : success, same);\n },\n (reason: unknown) => {\n if (error === undefined) toast.dismiss(id);\n else show(\"error\", typeof error === \"function\" ? error(reason) : error, same);\n },\n )\n .finally(() => onFinally?.());\n return id;\n },\n\n /** Close one toast, or every toast when `id` is omitted. */\n dismiss(id?: ToastId): void {\n withSonner((s) => s.toast.dismiss(id));\n },\n\n /** Render your own node in a toast slot — `render` receives the id to dismiss it. */\n custom(render: (id: ToastId) => ReactElement, opts?: Omit<ToastOptions, \"redact\">): ToastId {\n const id = opts?.id ?? nextId();\n const data = toSonnerData(opts, id);\n withSonner((s) => s.toast.custom(render, data));\n return id;\n },\n\n /**\n * \"Deleted — Undo\": a toast whose action takes the step back, labelled by the\n * provider's `toast.undo`. The journal stays the app's; this is only its toast.\n * Pair with {@link toast.redo} so the step back can itself be taken back.\n */\n undo(message: ReactNode, { onUndo, ...opts }: ToastUndoOptions): ToastId {\n return undoable(message, { ...opts, run: onUndo }, activeLabels.undo);\n },\n\n /** {@link toast.undo}'s mirror: the action is labelled `toast.redo`. */\n redo(message: ReactNode, { onRedo, ...opts }: ToastRedoOptions): ToastId {\n return undoable(message, { ...opts, run: onRedo }, activeLabels.redo);\n },\n },\n);\n\n/* ── The Toaster ─────────────────────────────────────────────────────────── */\n\nexport type ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type ToastSwipeDirection = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** sonner's offset: one value for every edge, or per edge. Numbers are px. */\nexport type ToasterOffset =\n | string\n | number\n | { top?: string | number; right?: string | number; bottom?: string | number; left?: string | number };\n\nexport interface ToasterProps {\n /** Default: `bottom-center` on a phone (so the toast covers neither the header's\n * buttons nor the bottom nav's), `top-center` from `md` up. */\n position?: ToastPosition;\n /** The height to keep clear at the bottom — AppShell's bottom nav. Default: its\n * measured `--app-nav-h`, so nothing has to be passed under an AppShell. The safe\n * area is added either way. Numbers are px. */\n navOffset?: string | number;\n /** Default: follows the `.dark` class the kit's theme store (`useApplyTheme`) puts\n * on `<html>` — whichever store the app built, with nothing passed. */\n theme?: \"light\" | \"dark\" | \"system\";\n labels?: Partial<ToastLabels>;\n /** Default 4s (8s for a toast with an action). */\n duration?: number;\n visibleToasts?: number;\n expand?: boolean;\n /** Default true. */\n closeButton?: boolean;\n /** Tone-coloured toasts (the AlertBanner tokens). Default true. */\n richColors?: boolean;\n /** Default: every direction. */\n swipeDirections?: ToastSwipeDirection[];\n /** Overrides the computed offset outright (above the nav on a phone, below a 48px\n * top bar on desktop). */\n offset?: ToasterOffset;\n /** Below 600px, where sonner switches to its full-width layout. Default: `offset`'s\n * phone value. */\n mobileOffset?: ToasterOffset;\n /** Keyboard shortcut that moves focus into the toasts. Default Alt+T. */\n hotkey?: string[];\n gap?: number;\n dir?: \"ltr\" | \"rtl\" | \"auto\";\n className?: string;\n style?: CSSProperties;\n}\n\n/** The kit's palette, mapped onto sonner's variables. Inline on the toaster element,\n * so it wins over sonner's injected sheet with no specificity contest. The tone\n * backgrounds go through `--toast-*` aliases computed at `:root` in tokens.css:\n * sonner redefines `--success-bg` on this same element, and a variable cannot read\n * its own name — `--success-bg: var(--success-bg)` here would be a cycle. */\nconst KIT_TOASTER_STYLE = {\n zIndex: \"var(--z-toast, 2147483647)\",\n fontFamily: \"inherit\",\n \"--normal-bg\": \"var(--bg-surface)\",\n \"--normal-bg-hover\": \"var(--bg-hover)\",\n \"--normal-border\": \"var(--border)\",\n \"--normal-border-hover\": \"var(--border-strong)\",\n \"--normal-text\": \"var(--text-primary)\",\n \"--gray2\": \"var(--bg-hover)\",\n \"--gray5\": \"var(--border-strong)\",\n \"--gray11\": \"var(--text-muted)\",\n \"--success-bg\": \"var(--toast-success-bg)\",\n \"--success-border\": \"var(--toast-success-border)\",\n \"--success-text\": \"var(--success)\",\n \"--info-bg\": \"var(--toast-info-bg)\",\n \"--info-border\": \"var(--toast-info-border)\",\n \"--info-text\": \"var(--info)\",\n \"--warning-bg\": \"var(--toast-warning-bg)\",\n \"--warning-border\": \"var(--toast-warning-border)\",\n \"--warning-text\": \"var(--warning)\",\n \"--error-bg\": \"var(--toast-danger-bg)\",\n \"--error-border\": \"var(--toast-danger-border)\",\n \"--error-text\": \"var(--danger)\",\n} as CSSProperties;\n\nconst ALL_DIRECTIONS: ToastSwipeDirection[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\n/** Light or dark, as the `.dark` class on `<html>` says right now. */\nfunction readDocumentTheme(): \"light\" | \"dark\" {\n return typeof document !== \"undefined\" && document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\";\n}\n\nfunction subscribeDocumentTheme(onChange: () => void): () => void {\n if (typeof MutationObserver === \"undefined\") return () => {};\n const mo = new MutationObserver(onChange);\n mo.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\"] });\n return () => mo.disconnect();\n}\n\nconst px = (v: string | number) => (typeof v === \"number\" ? `${v}px` : v);\n\n/**\n * Where the toasts appear, with the kit's defaults — mount ONE, near the root and\n * inside `<UiKitProvider>` (it reads the `toast` labels) and inside the router if a\n * toast's content navigates.\n *\n * Accessible as sonner makes it: the toasts sit in a polite live region, so a message\n * is announced with its description and its action's label; every toast and every\n * button in it is focusable, the timer pauses while focus or the pointer is inside,\n * and Alt+T ({@link ToasterProps.hotkey}) moves focus to the newest toast. A toast\n * with an action stays up 8s by default, so the button can be reached.\n */\nexport function Toaster({\n position,\n navOffset,\n theme,\n labels: labelsProp,\n closeButton = true,\n richColors = true,\n swipeDirections = ALL_DIRECTIONS,\n offset,\n mobileOffset,\n className,\n style,\n ...rest\n}: ToasterProps) {\n const [mod, setMod] = useState<Sonner | null>(sonner);\n useEffect(() => {\n if (mod) return;\n let live = true;\n void loadSonner().then((m) => {\n if (live && m) setMod(m);\n });\n return () => {\n live = false;\n };\n }, [mod]);\n\n const labels = useKitLabels(\"toast\", DEFAULT_TOAST_LABELS, labelsProp);\n useEffect(() => {\n activeLabels = labels;\n return () => {\n if (activeLabels === labels) activeLabels = DEFAULT_TOAST_LABELS;\n };\n }, [labels]);\n\n const documentTheme = useSyncExternalStore(subscribeDocumentTheme, readDocumentTheme, () => \"light\" as const);\n const phone = useMediaQuery(PHONE_QUERY, false);\n const resolved: ToastPosition = position ?? (phone ? \"bottom-center\" : \"top-center\");\n\n // Above the bottom nav and the home indicator: whichever is taller, since the nav\n // already pads itself by the safe area (the same sum BulkActionBar floats on).\n const bottom = `calc(max(${navOffset === undefined ? \"var(--app-nav-h, 0px)\" : px(navOffset)}, env(safe-area-inset-bottom, 0px)) + 0.75rem)`;\n // Below a 48px TopBar with the same 1rem clearance.\n const top = \"calc(env(safe-area-inset-top, 0px) + 4rem)\";\n const computed = resolved.startsWith(\"bottom\") ? { bottom } : { top };\n\n if (!mod) return null;\n const Sonner = mod.Toaster;\n return (\n <Sonner\n {...rest}\n position={resolved}\n theme={theme ?? documentTheme}\n closeButton={closeButton}\n richColors={richColors}\n swipeDirections={swipeDirections}\n offset={offset ?? computed}\n mobileOffset={mobileOffset ?? offset ?? computed}\n containerAriaLabel={labels.notifications}\n toastOptions={{ closeButtonAriaLabel: labels.close }}\n className={className ? `kit-toaster ${className}` : \"kit-toaster\"}\n style={{ ...KIT_TOASTER_STYLE, ...style }}\n />\n );\n}\n"],"mappings":";AAuIuC;AAvIvC,SAAS,WAAW,UAAU,4BAA4B;AAE1D,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AA0B5B,IAAI,SAAwB;AAC5B,IAAI,UAAyC;AAC7C,MAAM,QAAoC,CAAC;AAE3C,SAAS,aAAqC;AAC5C,cAAY,OAAO,QAAQ,EAAE;AAAA,IAC3B,CAAC,QAAQ;AACP,eAAS;AAGT,iBAAW,MAAM,MAAM,OAAO,CAAC,EAAG,IAAG,GAAG;AACxC,aAAO;AAAA,IACT;AAAA,IACA,MAAM;AACJ,YAAM,SAAS;AACf,cAAQ;AAAA,QACN;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,WAAW,IAA+B;AACjD,MAAI,QAAQ;AACV,OAAG,MAAM;AACT;AAAA,EACF;AACA,QAAM,KAAK,EAAE;AACb,OAAK,WAAW;AAClB;AAEA,IAAI,UAAU;AACd,MAAM,SAAS,MAAM,aAAa,EAAE,OAAO;AAcpC,MAAM,uBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,eAAe;AAAA,EACf,MAAM;AAAA,EACN,MAAM;AACR;AAKA,IAAI,eAA4B;AA2CzB,MAAM,wBAAwB;AAIrC,MAAM,YAAY,CAAC,SAAoB,oBAAC,UAAK,gBAAa,IAAI,gBAAK;AAEnE,SAAS,aAAa,MAAgC,IAAyB;AAC7E,QAAM,EAAE,QAAQ,aAAa,UAAU,QAAQ,GAAG,KAAK,IAAI,QAAQ,CAAC;AACpE,QAAM,OAAmB,EAAE,GAAG,MAAM,GAAG;AACvC,MAAI,gBAAgB,OAAW,MAAK,cAAc,SAAS,UAAU,WAAW,IAAI;AACpF,MAAI,OAAQ,MA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,QAAO,CAAC;AAAA,IACzB,CAAC;AACD,WAAO,MAAM;AACX,aAAO;AAAA,IACT;AAAA,EACF,GAAG,CAAC,GAAG,CAAC;AAER,QAAM,SAAS,aAAa,SAAS,sBAAsB,UAAU;AACrE,YAAU,MAAM;AACd,mBAAe;AACf,WAAO,MAAM;AACX,UAAI,iBAAiB,OAAQ,gBAAe;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAEX,QAAM,gBAAgB,qBAAqB,wBAAwB,mBAAmB,MAAM,OAAgB;AAC5G,QAAM,QAAQ,cAAc,aAAa,KAAK;AAC9C,QAAM,WAA0B,aAAa,QAAQ,kBAAkB;AAIvE,QAAM,SAAS,YAAY,cAAc,SAAY,0BAA0B,GAAG,SAAS,CAAC;AAE5F,QAAM,MAAM;AACZ,QAAM,WAAW,SAAS,WAAW,QAAQ,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI;AAEpE,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,SAAS,IAAI;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,UAAU;AAAA,MACV,OAAO,SAAS;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,cAAc,gBAAgB,UAAU;AAAA,MACxC,oBAAoB,OAAO;AAAA,MAC3B,cAAc,EAAE,sBAAsB,OAAO,MAAM;AAAA,MACnD,WAAW,YAAY,eAAe,SAAS,KAAK;AAAA,MACpD,OAAO,EAAE,GAAG,mBAAmB,GAAG,MAAM;AAAA;AAAA,EAC1C;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/toast.tsx"],"sourcesContent":["import { useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, MouseEvent, ReactElement, ReactNode } from \"react\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { PHONE_QUERY } from \"./ui\";\n\n/**\n * The kit's toast layer: a `toast` API and a `<Toaster>`, over sonner.\n *\n * WHY A WRAPPER AND NOT \"USE SONNER\". Both apps mounted sonner by hand and carried the\n * same policy in it — bottom-centre on a phone so the toast covers neither the header\n * nor the bottom nav, a lift above that nav, swipe in every direction, a z-index above\n * every overlay, the theme fed in from the store — and one of them wrote that policy\n * twice. `toast` mirrors sonner's call shape, so migrating is an import swap:\n *\n * import { toast } from \"@eifi1/ui-kit\"; // was: from \"sonner\"\n *\n * WHY SONNER IS LOADED LAZILY. It is an OPTIONAL peer, and this module is re-exported by\n * the barrel: a static import here would make every app that imports a Button install\n * it (see optional-peer-imports.test.tsx). So nothing here imports it statically. The\n * `<Toaster>` loads it when it mounts — long before anyone clicks anything — and a call\n * made before that is queued and replayed in order the moment it has loaded. Every call\n * returns its id synchronously anyway: the id is chosen here, not by sonner.\n */\n\ntype Sonner = typeof import(\"sonner\");\ntype SonnerData = NonNullable<Parameters<Sonner[\"toast\"]>[1]>;\n\n/* ── Loading sonner ──────────────────────────────────────────────────────── */\n\nlet sonner: Sonner | null = null;\nlet loading: Promise<Sonner | null> | null = null;\nconst queue: Array<(s: Sonner) => void> = [];\n\nfunction loadSonner(): Promise<Sonner | null> {\n loading ??= import(\"sonner\").then(\n (mod) => {\n sonner = mod;\n // Flushed in the SAME callback that sets `sonner`, so a call arriving between\n // the two cannot overtake one that was queued before it.\n for (const fn of queue.splice(0)) fn(mod);\n return mod;\n },\n () => {\n queue.length = 0;\n console.warn(\n \"@eifi1/ui-kit: `toast` needs the optional peer `sonner` — install it (npm i sonner) to show toasts.\",\n );\n return null;\n },\n );\n return loading;\n}\n\nfunction withSonner(fn: (s: Sonner) => void): void {\n if (sonner) {\n fn(sonner);\n return;\n }\n queue.push(fn);\n void loadSonner();\n}\n\nlet counter = 0;\nconst nextId = () => `kit-toast-${++counter}`;\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** The words the toast layer says. `close` and `notifications` are read by a screen\n * reader (the close button's name, the toast region's name); `undo` and `redo` are\n * the default action labels of {@link toast.undo} / {@link toast.redo}. */\nexport interface ToastLabels {\n close: string;\n notifications: string;\n undo: string;\n redo: string;\n}\n\nexport const DEFAULT_TOAST_LABELS: ToastLabels = {\n close: \"Close notification\",\n notifications: \"Notifications\",\n undo: \"Undo\",\n redo: \"Redo\",\n};\n\n/** What the mounted `<Toaster>` resolved from `<UiKitProvider>` — so `toast.undo()`,\n * which is called from mutation callbacks and not from a component, still says\n * \"Rückgängig\" in a German app. */\nlet activeLabels: ToastLabels = DEFAULT_TOAST_LABELS;\n\n/* ── The API ─────────────────────────────────────────────────────────────── */\n\nexport type ToastId = string | number;\n\n/** A button on the toast. Clicking it dismisses the toast, unless `onClick` calls\n * `event.preventDefault()`. */\nexport interface ToastAction {\n label: ReactNode;\n onClick: (event: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport interface ToastOptions {\n /** Re-using an id REPLACES the toast on screen with that id (in place — it does not\n * stack a second one), which is how a toast is updated. Default: a fresh id. */\n id?: ToastId;\n description?: ReactNode;\n action?: ToastAction;\n /** A second, quieter button (sonner's `cancel`). */\n cancel?: ToastAction;\n /** Milliseconds; `Infinity` keeps it until dismissed. Default 4s — or\n * {@link TOAST_ACTION_DURATION} when there is an `action`, so there is time to\n * read the message AND reach the button. */\n duration?: number;\n /** Called when the toast is closed by the user (close button, swipe, action). */\n onDismiss?: (toast: { id: ToastId }) => void;\n /** Called when the toast times out. */\n onAutoClose?: (toast: { id: ToastId }) => void;\n /** Wrap the message and the description in `data-private`, so an app's demo /\n * privacy mode blurs them like every other sensitive value. */\n redact?: boolean;\n /** Replaces the tone's icon. */\n icon?: ReactNode;\n /** `false`: no close button, no swipe. */\n dismissible?: boolean;\n /** Per toast, over the `<Toaster>`'s `closeButton`. */\n closeButton?: boolean;\n className?: string;\n style?: CSSProperties;\n}\n\n/** The default duration of a toast that carries an action (8s rather than 4s). */\nexport const TOAST_ACTION_DURATION = 8000;\n\ntype Kind = \"default\" | \"success\" | \"error\" | \"warning\" | \"info\" | \"loading\";\n\nconst privately = (node: ReactNode) => <span data-private=\"\">{node}</span>;\n\n/**\n * The toast's id, written onto its `<li>` as a class — the one per-toast attribute\n * sonner passes through untouched besides `testId`, which is the app's (sonner keeps the\n * id in React state only). `<Toaster dismissOnMiddleClick>` reads it back to dismiss\n * the toast under the pointer, close button or not. The type is kept (`s`/`n`) because\n * sonner matches ids with `===`, and the value is URI-encoded so any string id is one\n * whitespace-free class token.\n */\nconst ID_CLASS = \"kit-toast-id-\";\nconst idClass = (id: ToastId) =>\n `${ID_CLASS}${typeof id === \"number\" ? \"n\" : \"s\"}-${encodeURIComponent(String(id))}`;\n\n/** The id {@link idClass} stamped on a toast element, or null for a toast the kit did\n * not make (an app still calling sonner directly). */\nfunction readToastId(el: Element): ToastId | null {\n for (const token of el.classList) {\n if (!token.startsWith(ID_CLASS)) continue;\n const kind = token.charAt(ID_CLASS.length);\n const raw = decodeURIComponent(token.slice(ID_CLASS.length + 2));\n return kind === \"n\" ? Number(raw) : raw;\n }\n return null;\n}\n\nfunction toSonnerData(opts: ToastOptions | undefined, id: ToastId): SonnerData {\n const { redact, description, duration, action, className, ...rest } = opts ?? {};\n const data: SonnerData = { ...rest, id, className: className ? `${idClass(id)} ${className}` : idClass(id) };\n if (description !== undefined) data.description = redact ? privately(description) : description;\n if (action) data.action = action;\n const resolved = duration ?? (action ? TOAST_ACTION_DURATION : undefined);\n if (resolved !== undefined) data.duration = resolved;\n return data;\n}\n\nfunction show(kind: Kind, message: ReactNode, opts?: ToastOptions): ToastId {\n const id = opts?.id ?? nextId();\n const title = opts?.redact ? privately(message) : message;\n const data = toSonnerData(opts, id);\n withSonner((s) => {\n if (kind === \"default\") s.toast(title, data);\n else s.toast[kind](title, data);\n });\n return id;\n}\n\nexport interface ToastPromiseOptions<T> extends ToastOptions {\n loading: ReactNode;\n /** The success message, or a function of the resolved value. Omitted: the loading\n * toast is dismissed. */\n success?: ReactNode | ((value: T) => ReactNode);\n /** The error message, or a function of the rejection. Omitted: dismissed. */\n error?: ReactNode | ((error: unknown) => ReactNode);\n finally?: () => void;\n}\n\nexport interface ToastUndoOptions extends Omit<ToastOptions, \"action\"> {\n /** Called when the button is pressed. */\n onUndo: () => void;\n /** Default: `toast.undo` from `<UiKitProvider>` (\"Undo\"). */\n label?: ReactNode;\n /** Default `success` — the step the toast reports worked. */\n tone?: Exclude<Kind, \"loading\">;\n}\n\nexport interface ToastRedoOptions extends Omit<ToastUndoOptions, \"onUndo\"> {\n onRedo: () => void;\n}\n\nfunction undoable(\n message: ReactNode,\n { tone = \"success\", label, run, ...opts }: Omit<ToastUndoOptions, \"onUndo\"> & { run: () => void },\n fallback: ReactNode,\n): ToastId {\n return show(tone, message, {\n ...opts,\n action: { label: label ?? fallback, onClick: () => run() },\n });\n}\n\n/**\n * Show a toast. The same shape as sonner's `toast`, so an app migrates by changing the\n * import: `toast(msg, opts)`, `toast.success` / `error` / `warning` / `info` /\n * `loading`, `toast.promise`, `toast.dismiss`, `toast.custom`. Each returns the toast's\n * id; pass it back as `id` to replace that toast in place.\n *\n * Needs a mounted {@link Toaster}. Messages may be any ReactNode.\n */\nexport const toast = Object.assign(\n (message: ReactNode, opts?: ToastOptions): ToastId => show(\"default\", message, opts),\n {\n message: (message: ReactNode, opts?: ToastOptions) => show(\"default\", message, opts),\n success: (message: ReactNode, opts?: ToastOptions) => show(\"success\", message, opts),\n error: (message: ReactNode, opts?: ToastOptions) => show(\"error\", message, opts),\n warning: (message: ReactNode, opts?: ToastOptions) => show(\"warning\", message, opts),\n info: (message: ReactNode, opts?: ToastOptions) => show(\"info\", message, opts),\n /** A spinner that does not time out — replace it (same `id`) or dismiss it. */\n loading: (message: ReactNode, opts?: ToastOptions) => show(\"loading\", message, opts),\n\n /**\n * A loading toast that becomes the success or the error toast, in place, when\n * `promise` settles. Returns the toast's id; the promise itself is the caller's.\n */\n promise<T>(promise: Promise<T> | (() => Promise<T>), options: ToastPromiseOptions<T>): ToastId {\n const { loading: pending, success, error, finally: onFinally, ...opts } = options;\n const id = show(\"loading\", pending, opts);\n const same = { ...opts, id };\n Promise.resolve()\n .then(() => (typeof promise === \"function\" ? promise() : promise))\n .then(\n (value) => {\n if (success === undefined) toast.dismiss(id);\n else show(\"success\", typeof success === \"function\" ? success(value) : success, same);\n },\n (reason: unknown) => {\n if (error === undefined) toast.dismiss(id);\n else show(\"error\", typeof error === \"function\" ? error(reason) : error, same);\n },\n )\n .finally(() => onFinally?.());\n return id;\n },\n\n /** Close one toast, or every toast when `id` is omitted. */\n dismiss(id?: ToastId): void {\n withSonner((s) => s.toast.dismiss(id));\n },\n\n /** Render your own node in a toast slot — `render` receives the id to dismiss it. */\n custom(render: (id: ToastId) => ReactElement, opts?: Omit<ToastOptions, \"redact\">): ToastId {\n const id = opts?.id ?? nextId();\n const data = toSonnerData(opts, id);\n withSonner((s) => s.toast.custom(render, data));\n return id;\n },\n\n /**\n * \"Deleted — Undo\": a toast whose action takes the step back, labelled by the\n * provider's `toast.undo`. The journal stays the app's; this is only its toast.\n * Pair with {@link toast.redo} so the step back can itself be taken back.\n */\n undo(message: ReactNode, { onUndo, ...opts }: ToastUndoOptions): ToastId {\n return undoable(message, { ...opts, run: onUndo }, activeLabels.undo);\n },\n\n /** {@link toast.undo}'s mirror: the action is labelled `toast.redo`. */\n redo(message: ReactNode, { onRedo, ...opts }: ToastRedoOptions): ToastId {\n return undoable(message, { ...opts, run: onRedo }, activeLabels.redo);\n },\n },\n);\n\n/* ── The Toaster ─────────────────────────────────────────────────────────── */\n\nexport type ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type ToastSwipeDirection = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** sonner's offset: one value for every edge, or per edge. Numbers are px. */\nexport type ToasterOffset =\n | string\n | number\n | { top?: string | number; right?: string | number; bottom?: string | number; left?: string | number };\n\nexport interface ToasterProps {\n /** Default: `bottom-center` on a phone (so the toast covers neither the header's\n * buttons nor the bottom nav's), `top-center` from `md` up. */\n position?: ToastPosition;\n /** The height to keep clear at the bottom — AppShell's bottom nav. Default: its\n * measured `--app-nav-h`, so nothing has to be passed under an AppShell. The safe\n * area is added either way. Numbers are px. */\n navOffset?: string | number;\n /** Default: follows the `.dark` class the kit's theme store (`useApplyTheme`) puts\n * on `<html>` — whichever store the app built, with nothing passed. */\n theme?: \"light\" | \"dark\" | \"system\";\n labels?: Partial<ToastLabels>;\n /** Default 4s (8s for a toast with an action). */\n duration?: number;\n visibleToasts?: number;\n expand?: boolean;\n /** Default true. */\n closeButton?: boolean;\n /** Tone-coloured toasts (the AlertBanner tokens). Default true. */\n richColors?: boolean;\n /** Default: every direction. */\n swipeDirections?: ToastSwipeDirection[];\n /** Overrides the computed offset outright (above the nav on a phone, below a 48px\n * top bar on desktop). */\n offset?: ToasterOffset;\n /** Below 600px, where sonner switches to its full-width layout. Default: `offset`'s\n * phone value. */\n mobileOffset?: ToasterOffset;\n /** Keyboard shortcut that moves focus into the toasts. Default Alt+T. */\n hotkey?: string[];\n gap?: number;\n dir?: \"ltr\" | \"rtl\" | \"auto\";\n /**\n * A middle click on a toast dismisses it (0.18.0) — the gesture that closes a tab,\n * which is what keksdose's users reached for (dev #583). By id, so it works on a\n * toast with `closeButton: false` too; it counts as the user closing it, so\n * `onDismiss` runs. Not on a link or a button inside the toast — a middle click on a\n * link still opens it in a new tab — and not on a `dismissible: false` toast.\n * Default true.\n */\n dismissOnMiddleClick?: boolean;\n className?: string;\n style?: CSSProperties;\n}\n\n/** The kit's palette, mapped onto sonner's variables. Inline on the toaster element,\n * so it wins over sonner's injected sheet with no specificity contest. The tone\n * backgrounds go through `--toast-*` aliases computed at `:root` in tokens.css:\n * sonner redefines `--success-bg` on this same element, and a variable cannot read\n * its own name — `--success-bg: var(--success-bg)` here would be a cycle. */\nconst KIT_TOASTER_STYLE = {\n zIndex: \"var(--z-toast, 2147483647)\",\n fontFamily: \"inherit\",\n \"--normal-bg\": \"var(--bg-surface)\",\n \"--normal-bg-hover\": \"var(--bg-hover)\",\n \"--normal-border\": \"var(--border)\",\n \"--normal-border-hover\": \"var(--border-strong)\",\n \"--normal-text\": \"var(--text-primary)\",\n \"--gray2\": \"var(--bg-hover)\",\n \"--gray5\": \"var(--border-strong)\",\n \"--gray11\": \"var(--text-muted)\",\n \"--success-bg\": \"var(--toast-success-bg)\",\n \"--success-border\": \"var(--toast-success-border)\",\n \"--success-text\": \"var(--success)\",\n \"--info-bg\": \"var(--toast-info-bg)\",\n \"--info-border\": \"var(--toast-info-border)\",\n \"--info-text\": \"var(--info)\",\n \"--warning-bg\": \"var(--toast-warning-bg)\",\n \"--warning-border\": \"var(--toast-warning-border)\",\n \"--warning-text\": \"var(--warning)\",\n \"--error-bg\": \"var(--toast-danger-bg)\",\n \"--error-border\": \"var(--toast-danger-border)\",\n \"--error-text\": \"var(--danger)\",\n} as CSSProperties;\n\nconst ALL_DIRECTIONS: ToastSwipeDirection[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\n/** Light or dark, as the `.dark` class on `<html>` says right now. */\nfunction readDocumentTheme(): \"light\" | \"dark\" {\n return typeof document !== \"undefined\" && document.documentElement.classList.contains(\"dark\")\n ? \"dark\"\n : \"light\";\n}\n\nfunction subscribeDocumentTheme(onChange: () => void): () => void {\n if (typeof MutationObserver === \"undefined\") return () => {};\n const mo = new MutationObserver(onChange);\n mo.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\"] });\n return () => mo.disconnect();\n}\n\nconst px = (v: string | number) => (typeof v === \"number\" ? `${v}px` : v);\n\n/**\n * Where the toasts appear, with the kit's defaults — mount ONE, near the root and\n * inside `<UiKitProvider>` (it reads the `toast` labels) and inside the router if a\n * toast's content navigates.\n *\n * Accessible as sonner makes it: the toasts sit in a polite live region, so a message\n * is announced with its description and its action's label; every toast and every\n * button in it is focusable, the timer pauses while focus or the pointer is inside,\n * and Alt+T ({@link ToasterProps.hotkey}) moves focus to the newest toast. A toast\n * with an action stays up 8s by default, so the button can be reached.\n */\nexport function Toaster({\n position,\n navOffset,\n theme,\n labels: labelsProp,\n closeButton = true,\n richColors = true,\n swipeDirections = ALL_DIRECTIONS,\n offset,\n mobileOffset,\n dismissOnMiddleClick = true,\n className,\n style,\n ...rest\n}: ToasterProps) {\n const [mod, setMod] = useState<Sonner | null>(sonner);\n useEffect(() => {\n if (mod) return;\n let live = true;\n void loadSonner().then((m) => {\n if (live && m) setMod(m);\n });\n return () => {\n live = false;\n };\n }, [mod]);\n\n const labels = useKitLabels(\"toast\", DEFAULT_TOAST_LABELS, labelsProp);\n useEffect(() => {\n activeLabels = labels;\n return () => {\n if (activeLabels === labels) activeLabels = DEFAULT_TOAST_LABELS;\n };\n }, [labels]);\n\n useEffect(() => {\n if (!dismissOnMiddleClick || !mod) return;\n // On the document rather than the toaster: sonner owns the `<ol>`, and a listener\n // there would have to be re-attached whenever it remounts it.\n const toastUnder = (e: globalThis.MouseEvent) => {\n if (e.button !== 1 || !(e.target instanceof Element)) return null;\n const li = e.target.closest<HTMLElement>(\"[data-sonner-toast]\");\n if (!li || li.dataset.dismissible === \"false\") return null;\n // A link keeps its middle click (open in a new tab); a button or a field inside\n // the toast is the app's, not a background to click.\n const control = e.target.closest(\"a[href], button, input, select, textarea, [role='button'], [role='link']\");\n if (control && li.contains(control)) return null;\n return li;\n };\n // `mousedown`: the middle button starts autoscroll (Windows) before any click.\n const onDown = (e: globalThis.MouseEvent) => {\n if (toastUnder(e)) e.preventDefault();\n };\n const onAux = (e: globalThis.MouseEvent) => {\n const li = toastUnder(e);\n if (!li) return;\n // No paste of the primary selection on Linux, no other handler's idea of it.\n e.preventDefault();\n const id = readToastId(li);\n if (id !== null) mod.toast.dismiss(id);\n // A toast made by sonner directly carries no id: its close button, if any.\n else li.querySelector<HTMLButtonElement>(\"[data-close-button]\")?.click();\n };\n document.addEventListener(\"mousedown\", onDown);\n document.addEventListener(\"auxclick\", onAux);\n return () => {\n document.removeEventListener(\"mousedown\", onDown);\n document.removeEventListener(\"auxclick\", onAux);\n };\n }, [dismissOnMiddleClick, mod]);\n\n const documentTheme = useSyncExternalStore(subscribeDocumentTheme, readDocumentTheme, () => \"light\" as const);\n const phone = useMediaQuery(PHONE_QUERY, false);\n const resolved: ToastPosition = position ?? (phone ? \"bottom-center\" : \"top-center\");\n\n // Above the bottom nav and the home indicator: whichever is taller, since the nav\n // already pads itself by the safe area (the same sum BulkActionBar floats on).\n const bottom = `calc(max(${navOffset === undefined ? \"var(--app-nav-h, 0px)\" : px(navOffset)}, env(safe-area-inset-bottom, 0px)) + 0.75rem)`;\n // Below a 48px TopBar with the same 1rem clearance.\n const top = \"calc(env(safe-area-inset-top, 0px) + 4rem)\";\n const computed = resolved.startsWith(\"bottom\") ? { bottom } : { top };\n\n if (!mod) return null;\n const Sonner = mod.Toaster;\n return (\n <Sonner\n {...rest}\n position={resolved}\n theme={theme ?? documentTheme}\n closeButton={closeButton}\n richColors={richColors}\n swipeDirections={swipeDirections}\n offset={offset ?? computed}\n mobileOffset={mobileOffset ?? offset ?? computed}\n containerAriaLabel={labels.notifications}\n toastOptions={{ closeButtonAriaLabel: labels.close }}\n className={className ? `kit-toaster ${className}` : \"kit-toaster\"}\n style={{ ...KIT_TOASTER_STYLE, ...style }}\n />\n );\n}\n"],"mappings":";AAuIuC;AAvIvC,SAAS,WAAW,UAAU,4BAA4B;AAE1D,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AA0B5B,IAAI,SAAwB;AAC5B,IAAI,UAAyC;AAC7C,MAAM,QAAoC,CAAC;AAE3C,SAAS,aAAqC;AAC5C,cAAY,OAAO,QAAQ,EAAE;AAAA,IAC3B,CAAC,QAAQ;AACP,eAAS;AAGT,iBAAW,MAAM,MAAM,OAAO,CAAC,EAAG,IAAG,GAAG;AACxC,aAAO;AAAA,IACT;AAAA,IACA,MAAM;AACJ,YAAM,SAAS;AACf,cAAQ;AAAA,QACN;AAAA,MACF;A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KAAK;AAC9C,QAAM,WAA0B,aAAa,QAAQ,kBAAkB;AAIvE,QAAM,SAAS,YAAY,cAAc,SAAY,0BAA0B,GAAG,SAAS,CAAC;AAE5F,QAAM,MAAM;AACZ,QAAM,WAAW,SAAS,WAAW,QAAQ,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI;AAEpE,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,SAAS,IAAI;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,UAAU;AAAA,MACV,OAAO,SAAS;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,cAAc,gBAAgB,UAAU;AAAA,MACxC,oBAAoB,OAAO;AAAA,MAC3B,cAAc,EAAE,sBAAsB,OAAO,MAAM;AAAA,MACnD,WAAW,YAAY,eAAe,SAAS,KAAK;AAAA,MACpD,OAAO,EAAE,GAAG,mBAAmB,GAAG,MAAM;AAAA;AAAA,EAC1C;AAEJ;","names":[]}
@@ -136,8 +136,11 @@ function ToggleGroup(props) {
136
136
  field && "py-0 leading-5",
137
137
  active ? "bg-[var(--bg-inverse)] text-[var(--text-inverse)]" : "text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]",
138
138
  // No hover fill on a group that cannot be changed — a segment that
139
- // lights up under the pointer is an offer, and there is none here.
140
- disabled && "cursor-not-allowed hover:bg-transparent dark:hover:bg-transparent",
139
+ // lights up under the pointer is an offer, and there is none here. Not on
140
+ // the chosen segment: its fill IS its state, and its inverse text would
141
+ // vanish on a transparent hover.
142
+ disabled && "cursor-not-allowed",
143
+ disabled && !active && "hover:bg-transparent dark:hover:bg-transparent",
141
144
  optionClassName,
142
145
  opt.className
143
146
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/toggle-group.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactElement, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { FIELD_INVALID, FloatingField, Label } from \"./ui\";\n\nexport interface ToggleOption<T extends string> {\n value: T;\n label: string;\n className?: string;\n}\n\n/**\n * `onChange` is the group's own — the chosen VALUE, not a DOM event — so the div's\n * `onChange` is omitted rather than shadowed: leaving both in scope would give the\n * prop two incompatible meanings depending on which overload TypeScript picked.\n *\n * `children` is omitted too: this renders its `options` and nothing else, so a `children` the type\n * accepted and the component ignored would be a prop that silently does nothing —\n * worse than one that does not compile.\n */\nexport interface ToggleGroupBaseProps<T extends string>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\" | \"children\"> {\n options: ToggleOption<T>[];\n className?: string;\n /** Applied to every option button (e.g. to tune height/rounding to match\n * adjacent fields). Per-option `className` still wins over this. */\n optionClassName?: string;\n /**\n * What happens when the options do not fit the group's width. `\"truncate\"`\n * (default): one row, and the labels that do not fit end in an ellipsis — the height\n * never changes. `\"wrap\"`: the segments flow onto a second row and every label stays\n * whole (\"Bewegung\", not \"Beweg…\"), at the price of a taller group on a narrow\n * screen (lenkbank L4: five signal types on a 390px control page). From the width\n * where they fit, both look the same.\n */\n overflow?: \"truncate\" | \"wrap\";\n /**\n * @deprecated Pass `aria-label` instead — the DOM spelling, which every other\n * control in this kit now answers to. Kept working because three applications ship\n * this one today; it names the group only when `aria-label` is absent.\n */\n ariaLabel?: string;\n /**\n * Show, refuse the change (Keksdose live #288: a payment dated in the future has no\n * state to set).\n *\n * Whatever `value` says stays pressed and keeps its own fill rather than going grey\n * with the rest — a reader who cannot see WHICH option is chosen has been told less\n * than before it was disabled. A caller with nothing to show passes no value, and\n * the group renders dimmed with nothing pressed, which is the shape Keksdose's\n * status picker uses for a row whose status does not exist yet.\n *\n * On the whole GROUP, not per option: a segmented control where some segments are\n * live and others are not is a menu with holes in it, and no caller here wants one.\n */\n disabled?: boolean;\n /**\n * `sm`: 12px options with `px-2 py-1` — the compact group keksdose's rule editor\n * (rule-editor:204) writes as `optionClassName=\"px-2 py-1 text-xs\"` beside a small\n * caption. `md` (default) is the size every other group has.\n */\n size?: \"sm\" | \"md\";\n /**\n * Stand in a form row as a FIELD: with a label the group wears the field's chrome —\n * border, surface, the top strip with a small static label in it, a labelled\n * {@link Select}'s height — so beside an Input or a Select it reads as one of them\n * rather than as a control with a caption over it. lenkbank builds exactly this by\n * hand as `ToggleField` (features/gear/common.tsx:97, feedback #69), and its notes\n * are why the chrome STRETCHES to its row as well as matching the select's padding:\n * a native select's height is the browser's, so a toggle a few pixels short of it\n * is levelled up by the row rather than by arithmetic.\n *\n * The label names the group (`aria-labelledby`), so `aria-label` is not needed. With\n * a label, `className` styles the field's wrapper — as on {@link Select} — and the\n * group's own box is dropped: two nested borders read as a control in a control.\n */\n label?: ReactNode;\n /**\n * Where `label` goes. `\"field\"` (default): the field chrome described under `label`.\n * `\"above\"`: the kit's {@link Label} over the bare group — the shape of a {@link Field}\n * — with `hint` beside the label and `error` under the group, for a form that sets\n * its labels above its fields (kastlan's international-rent-calculator.tsx, whose DE\n * cap pair sits in a `Field` column between two labelled-above inputs, where the\n * chrome's inner label would be the only one of its kind).\n *\n * Inside a `Field`, pass no `label` at all and spread the render-prop instead —\n * `{(ids, { labelId }) => <ToggleGroup {...ids} aria-labelledby={labelId} … />}` —\n * so the Field's label names the group and its hint and error describe it.\n */\n labelPlacement?: \"field\" | \"above\";\n /** A {@link FieldHint} on the label line, as on a labelled {@link Select}. Only with\n * `label`. */\n hint?: ReactNode;\n /** The message under the field when it is wrong: paints the field's border with\n * `--danger`, marks the group `aria-invalid` and describes it with the message, as\n * {@link Select}'s `error` does. Only with `label`. */\n error?: ReactNode;\n}\n\n/**\n * A line under the group saying what the CHOSEN option means — lenkbank's ToggleField\n * `hint` (features/gear/common.tsx:97): not help behind a \"?\" but a caption, and one\n * that changes as the choice does. Pass a function of the value for that; it is\n * attached with `aria-describedby`, and a function caption is also a polite live\n * region, because a description is read when the group is entered and not again when\n * an arrow key changes the choice underneath it.\n *\n * In muted 11px text under the field (or the bare group), above an `error`.\n */\ntype ToggleGroupCaption<V> = ReactNode | ((value: V) => ReactNode);\n\n/** The group as it has always been: one option is always the answer. */\nexport interface ToggleGroupRequiredProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty?: false;\n /**\n * What the options ARE to a screen reader, separately from whether the group can be\n * emptied (kastlan feedback #47).\n *\n * - `\"radio\"` (default) — a `radiogroup` of radios: one Tab stop, arrow keys MOVE the\n * choice. Right for a choice between answers (\"Monthly / Yearly\").\n * - `\"pressed\"` — a `group` of toggle buttons (`aria-pressed`), each its own Tab stop,\n * Space/Enter to press; still one option always pressed. Right for a row that reads\n * as a set of switches — a view mode, a toolbar-like filter — where arrows moving the\n * selection on focus would be a surprise.\n *\n * Before this the only way to `aria-pressed` was `allowEmpty`, which also let a second\n * press clear the choice — so kastlan took the clearable shape and threw the `null`\n * away in `onChange` (`(v) => v && setMode(v)`), a group announcing that a press would\n * unpress what it would not. Here a press on the pressed option re-sends its value, as\n * the radio shape does, and nothing is ever unpressed. A clearable group\n * (`allowEmpty`) is always `\"pressed\"`: a radio cannot be unchecked by activating it.\n */\n semantics?: \"radio\" | \"pressed\";\n value: T;\n onChange: (value: T) => void;\n /** See {@link ToggleGroupCaption}. */\n caption?: ToggleGroupCaption<T>;\n}\n\n/**\n * A group that can be emptied: clicking the active option clears it, and `onChange`\n * receives `null` (Keksdose's support-panel filters, where \"no filter\" is reached by\n * clicking the filter that is on).\n *\n * The options become TOGGLE BUTTONS (`aria-pressed`, in a `role=\"group\"`) rather than\n * radios. A radio cannot be unchecked by activating it — no screen reader user expects\n * a second press on \"Open, radio, checked\" to leave nothing checked, and nothing would\n * tell them it had. \"Open, toggle button, pressed\" says exactly what a press will do.\n */\nexport interface ToggleGroupClearableProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty: true;\n /** Always toggle buttons — see {@link ToggleGroupRequiredProps.semantics}. Accepted so\n * a wrapper can forward one `semantics` to either shape. */\n semantics?: \"pressed\";\n value: T | null;\n onChange: (value: T | null) => void;\n /** See {@link ToggleGroupCaption}. `null` while nothing is chosen. */\n caption?: ToggleGroupCaption<T | null>;\n}\n\n/** `allowEmpty` picks the shape, so `onChange` is typed `(T) => void` unless the group\n * can actually emit `null` — no existing caller has a `null` to handle. */\nexport type ToggleGroupProps<T extends string> =\n | ToggleGroupRequiredProps<T>\n | ToggleGroupClearableProps<T>;\n\n/**\n * Overloaded rather than typed by the union alone (keksdose, \"Gaps found adopting\n * 0.6.0\" #7). Inferring `T` through a union of prop shapes let TypeScript settle on\n * `string`, so `<ToggleGroup allowEmpty value={filter} onChange={setFilter} />` over a\n * `useState<Status | null>` did not compile unless the caller spelled\n * `<ToggleGroup<Status>>`. One signature per mode lets each infer `T` from its own\n * `value`/`onChange`/`options`; the third keeps a caller that forwards a\n * {@link ToggleGroupProps} union (a wrapper component) compiling.\n */\nexport function ToggleGroup<T extends string>(props: ToggleGroupClearableProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupRequiredProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement {\n const {\n value,\n options,\n className,\n optionClassName,\n overflow = \"truncate\",\n ariaLabel,\n disabled = false,\n size = \"md\",\n label,\n labelPlacement = \"field\",\n hint,\n error,\n \"aria-label\": ariaLabelAttr,\n ...restWithMode\n } = props;\n const labelId = useId();\n const errorId = useId();\n const labelled = label !== undefined && label !== null && label !== false && label !== \"\";\n // `field` is the chrome; a label placed above keeps the bare group's own box.\n const field = labelled && labelPlacement === \"field\";\n const above = labelled && labelPlacement === \"above\";\n const hasError = labelled && error !== undefined && error !== null && error !== false && error !== \"\";\n // Taken off the rest so neither reaches the DOM; `props` keeps them paired, which is\n // what lets the `onChange` below be called with `null` only in the mode that allows it.\n const { allowEmpty: _allowEmpty, onChange: _onChange, caption, semantics: _semantics, ...rest } = restWithMode;\n // Invalid from outside too: a `Field` hands the bare group `aria-invalid`, and the\n // border has to say what the attribute says.\n const outsideInvalid = rest[\"aria-invalid\"] === true || rest[\"aria-invalid\"] === \"true\";\n const captionId = useId();\n const captionIsLive = typeof caption === \"function\";\n const captionNode = captionIsLive ? (caption as (v: T | null) => ReactNode)(value) : caption;\n const hasCaption = captionNode !== undefined && captionNode !== null && captionNode !== false && captionNode !== \"\";\n const choose = (next: T) => {\n if (props.allowEmpty) props.onChange(next === value ? null : next);\n else props.onChange(next);\n };\n // `pressed`: toggle buttons. Every clearable group is; a required one is when it asks\n // (kastlan #47) — the role, and not whether a second press clears, is what this flag\n // decides from here on, so `choose` above still keys off `allowEmpty` alone.\n const pressed = props.allowEmpty === true || props.semantics === \"pressed\";\n // A radio group is ONE tab stop (the checked radio, else the first) and arrows move\n // the choice — the pattern `role=\"radiogroup\"` promises a screen-reader user. Before\n // 0.7.0 each segment was its own tab stop with no arrow keys. The toggle-button shape\n // is a row of buttons, where separate tab stops are the pattern.\n const tabStop = options.some((o) => o.value === value) ? value : options[0]?.value;\n const onRadioKey = (e: KeyboardEvent<HTMLButtonElement>, index: number) => {\n const last = options.length - 1;\n let next: number | null = null;\n const step = horizontalStep(e.key, e.currentTarget);\n if (step !== 0) next = index + step;\n else if (e.key === \"ArrowDown\") next = index + 1;\n else if (e.key === \"ArrowUp\") next = index - 1;\n else if (e.key === \"Home\") next = 0;\n else if (e.key === \"End\") next = last;\n if (next === null) return;\n e.preventDefault();\n next = next < 0 ? last : next > last ? 0 : next;\n const buttons = e.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>(\":scope > button\");\n buttons?.[next]?.focus();\n choose(options[next].value);\n };\n const group = (\n <div\n // The audit's named example of a closed prop list (§\"Public API design\"): the\n // tour locates a step by CSS SELECTOR, so a component that drops every attribute\n // it was not expecting cannot be spotlighted at all — and Keksdose's rule editor\n // carries a comment explaining that it wraps this group in a bare <div> for\n // exactly that reason.\n //\n // `...rest` first, then the attributes the group cannot do without: a caller\n // hanging an anchor or a test id on the group must not be able to overwrite the\n // radiogroup role or the disabled state by accident. `className` is destructured\n // out entirely and merged through `cn`, so it is never in here.\n {...rest}\n role={pressed ? \"group\" : \"radiogroup\"}\n // The DOM spelling wins; `ariaLabel` is the fallback for the call sites that\n // have not moved yet.\n aria-label={ariaLabelAttr ?? ariaLabel}\n aria-labelledby={labelled && ariaLabelAttr === undefined && ariaLabel === undefined ? labelId : rest[\"aria-labelledby\"]}\n aria-invalid={hasError || rest[\"aria-invalid\"] || undefined}\n aria-describedby={\n [rest[\"aria-describedby\"], hasCaption && captionId, hasError && errorId].filter(Boolean).join(\" \") || undefined\n }\n // `aria-disabled` on the group as well as `disabled` on each button: a radio\n // group is what the user is being refused, and a screen reader announcing\n // three separately-disabled radios does not say that.\n aria-disabled={disabled || undefined}\n className={cn(\n // `gap-0.5` — the same 2px as the container's own padding, so EVERY segment\n // sits in a uniform 2px moat and no two fills ever touch. Flush segments were\n // Keksdose live #268's rework: the pressed segment wears a saturated fill and\n // an unpressed neighbour wears a pale hover fill, and with a shared edge the\n // two rectangles read as one smeared shape — *\"the boundary of the selected\n // option and hovering next to it overlays the boundary of the selected\n // button\"*. A gap is what makes each segment its own chip; it cannot be\n // undone by a caller's per-option colour, which a hover-only fix could.\n //\n // (The hover fill is the DESKTOP half of that report: Tailwind v4 wraps every\n // `hover:` in `@media (hover: hover)`, so a phone never paints it. The half a\n // phone does see is the focus ring — see the segment's own note below.)\n \"inline-flex w-full gap-0.5 rounded-md border border-[var(--border-strong)] bg-[var(--bg-surface)] p-0.5 shadow-sm\",\n overflow === \"wrap\" && \"flex-wrap\",\n // The whole group fades, the way every other disabled control in this\n // package does; `cursor-not-allowed` is on the buttons, which is what a\n // pointer is actually over.\n disabled && \"opacity-60\",\n // The bare group (no chrome to paint) wears the invalid border itself.\n !field && (outsideInvalid || (above && hasError)) && FIELD_INVALID,\n // Inside the field's chrome the group is only a row of segments: no border, no\n // surface, no padding of its own, and the field (not the group) is what dims.\n field && \"border-0 bg-transparent p-0 shadow-none opacity-100\",\n !labelled && className,\n )}\n >\n {options.map((opt, index) => {\n const active = opt.value === value;\n return (\n <button\n key={opt.value}\n type=\"button\"\n role={pressed ? undefined : \"radio\"}\n aria-checked={pressed ? undefined : active}\n aria-pressed={pressed ? active : undefined}\n disabled={disabled}\n tabIndex={pressed ? undefined : opt.value === tabStop ? 0 : -1}\n onKeyDown={pressed ? undefined : (e) => onRadioKey(e, index)}\n onClick={() => choose(opt.value)}\n className={cn(\n // `truncate` (which carries whitespace-nowrap) rather than letting a\n // label wrap: a segmented control sizes its whole row to the tallest\n // option, so one two-word option — Keksdose feedback #147's \"Where I\n // am\" — silently doubles the height of every segment beside it.\n //\n // `basis-auto` is what keeps that ellipsis a LAST resort rather than\n // the normal state (Keksdose dev#475). With flex-1's `basis-0`, a\n // shrink-to-fit group (`w-auto`) still resolves to the sum of the\n // labels' widths — and then splits it EQUALLY, so the short option\n // got 66px it did not need and \"Where I am\" got 66 of the 81 it did:\n // truncated at 1778px of free screen. Basing each segment on its own\n // content and sharing only the LEFTOVER space keeps a full-width\n // group's segments near-equal and an auto-width group's exact.\n //\n // `focus-visible` + `ring-inset`, not `focus` + an outset ring. A ring\n // is a box-shadow that spreads OUTWARD, so on a flush group it painted\n // 2px of ring over both neighbours and over the container's own border\n // — and on a phone it appeared on every TAP, because a tap focuses the\n // button. That is the other half of what live #268's rework saw\n // overlaying the selected segment's boundary. Inset keeps the ring\n // inside the segment it belongs to; focus-visible keeps it for the\n // keyboard, which is the only input that needs it.\n overflow === \"wrap\" ? \"whitespace-nowrap\" : \"min-w-0 truncate\",\n \"flex-1 basis-auto rounded px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--border-strong)]\",\n size === \"sm\" && \"px-2 py-1 text-xs\",\n // In a field: no vertical padding and a 20px line — a `text-sm` line, the\n // same line a labelled Select holds under its label strip — so the field's\n // own `pt-4 pb-1` decides the height, as it does for the select.\n field && \"py-0 leading-5\",\n active\n ? \"bg-[var(--bg-inverse)] text-[var(--text-inverse)]\"\n : \"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]\",\n // No hover fill on a group that cannot be changed — a segment that\n // lights up under the pointer is an offer, and there is none here.\n disabled && \"cursor-not-allowed hover:bg-transparent dark:hover:bg-transparent\",\n optionClassName,\n opt.className,\n )}\n >\n {opt.label}\n </button>\n );\n })}\n </div>\n );\n // Rendered whenever the caption is — `aria-live` must be on the element BEFORE its\n // text changes, or the change is not announced — but empty (no height, no margin)\n // when there is nothing to say, so a function caption that returns null for some\n // options leaves no gap. Empty rather than `hidden`: some readers do not announce\n // text that appears inside an element coming back from `display: none`.\n const captionEl =\n hasCaption || captionIsLive ? (\n <p\n id={captionId}\n aria-live={captionIsLive ? \"polite\" : undefined}\n className={cn(\"text-[11px] leading-snug text-[var(--text-muted)]\", hasCaption && \"mt-1\")}\n >\n {hasCaption ? captionNode : null}\n </p>\n ) : null;\n const errorEl = hasError ? (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n ) : null;\n if (above) {\n // `relative` so a caller's `sr-only` label cannot escape (sr-only-containment).\n return (\n <div className={cn(\"relative grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-center gap-1\">\n {/* A `<label>` with no `htmlFor`: a group is not labelable, so it is named\n by `aria-labelledby` on the group; the element keeps the Field look. */}\n <Label\n id={labelId}\n disabled={disabled}\n data-error={hasError || undefined}\n className=\"data-[error=true]:text-[var(--danger)]\"\n >\n {label}\n </Label>\n {hint}\n </div>\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n {errorEl}\n </div>\n </div>\n );\n }\n if (!field) {\n if (!captionEl) return group;\n // The group keeps its `className`, as without a caption; the wrapper only stacks.\n return (\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n </div>\n );\n }\n return (\n // `h-full` + `flex-1`: the chrome fills a grid or stretched flex row, which is what\n // levels it with a select beside it whatever the browser makes of the select.\n <div className={cn(\"flex h-full flex-col\", className)}>\n <FloatingField\n className=\"flex flex-1 flex-col\"\n label={<span id={labelId}>{label}</span>}\n staticLabel\n hint={hint}\n >\n <div\n className={cn(\n \"flex flex-1 flex-col justify-center rounded-md border border-[var(--border)] bg-[var(--bg-surface)] px-1 pt-4 pb-1 shadow-sm\",\n disabled && \"bg-[var(--bg-surface-2)] opacity-60\",\n hasError && FIELD_INVALID,\n )}\n >\n {group}\n </div>\n </FloatingField>\n {captionEl}\n {errorEl}\n </div>\n );\n}\n"],"mappings":";AA0SU,cAgFF,YAhFE;AA1SV,SAAS,aAAa;AAEtB,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAC/B,SAAS,eAAe,eAAe,aAAa;AA+K7C,SAAS,YAA8B,OAA0C;AACtF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,UAAU,MAAM;AACtB,QAAM,UAAU,MAAM;AACtB,QAAM,WAAW,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AAEvF,QAAM,QAAQ,YAAY,mBAAmB;AAC7C,QAAM,QAAQ,YAAY,mBAAmB;AAC7C,QAAM,WAAW,YAAY,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AAGnG,QAAM,EAAE,YAAY,aAAa,UAAU,WAAW,SAAS,WAAW,YAAY,GAAG,KAAK,IAAI;AAGlG,QAAM,iBAAiB,KAAK,cAAc,MAAM,QAAQ,KAAK,cAAc,MAAM;AACjF,QAAM,YAAY,MAAM;AACxB,QAAM,gBAAgB,OAAO,YAAY;AACzC,QAAM,cAAc,gBAAiB,QAAuC,KAAK,IAAI;AACrF,QAAM,aAAa,gBAA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gB,WAAW;AAAA,MACtC,WAAW,GAAG,qDAAqD,cAAc,MAAM;AAAA,MAEtF,uBAAa,cAAc;AAAA;AAAA,EAC9B,IACE;AACN,QAAM,UAAU,WACd,oBAAC,OAAE,IAAI,SAAS,WAAU,uDACvB,iBACH,IACE;AACJ,MAAI,OAAO;AAET,WACE,qBAAC,SAAI,WAAW,GAAG,iCAAiC,SAAS,GAC3D;AAAA,2BAAC,SAAI,WAAU,2BAGb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,YACJ;AAAA,YACA,cAAY,YAAY;AAAA,YACxB,WAAU;AAAA,YAET;AAAA;AAAA,QACH;AAAA,QACC;AAAA,SACH;AAAA,MACA,qBAAC,SAAI,WAAU,WACZ;AAAA;AAAA,QACA;AAAA,QACA;AAAA,SACH;AAAA,OACF;AAAA,EAEJ;AACA,MAAI,CAAC,OAAO;AACV,QAAI,CAAC,UAAW,QAAO;AAEvB,WACE,qBAAC,SAAI,WAAU,WACZ;AAAA;AAAA,MACA;AAAA,OACH;AAAA,EAEJ;AACA;AAAA;AAAA;AAAA,IAGE,qBAAC,SAAI,WAAW,GAAG,wBAAwB,SAAS,GAClD;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAO,oBAAC,UAAK,IAAI,SAAU,iBAAM;AAAA,UACjC,aAAW;AAAA,UACX;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,YAAY;AAAA,gBACZ,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA,MACC;AAAA,MACA;AAAA,OACH;AAAA;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/toggle-group.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactElement, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { FIELD_INVALID, FloatingField, Label } from \"./ui\";\n\nexport interface ToggleOption<T extends string> {\n value: T;\n label: string;\n className?: string;\n}\n\n/**\n * `onChange` is the group's own — the chosen VALUE, not a DOM event — so the div's\n * `onChange` is omitted rather than shadowed: leaving both in scope would give the\n * prop two incompatible meanings depending on which overload TypeScript picked.\n *\n * `children` is omitted too: this renders its `options` and nothing else, so a `children` the type\n * accepted and the component ignored would be a prop that silently does nothing —\n * worse than one that does not compile.\n */\nexport interface ToggleGroupBaseProps<T extends string>\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\" | \"children\"> {\n options: ToggleOption<T>[];\n className?: string;\n /** Applied to every option button (e.g. to tune height/rounding to match\n * adjacent fields). Per-option `className` still wins over this. */\n optionClassName?: string;\n /**\n * What happens when the options do not fit the group's width. `\"truncate\"`\n * (default): one row, and the labels that do not fit end in an ellipsis — the height\n * never changes. `\"wrap\"`: the segments flow onto a second row and every label stays\n * whole (\"Bewegung\", not \"Beweg…\"), at the price of a taller group on a narrow\n * screen (lenkbank L4: five signal types on a 390px control page). From the width\n * where they fit, both look the same.\n */\n overflow?: \"truncate\" | \"wrap\";\n /**\n * @deprecated Pass `aria-label` instead — the DOM spelling, which every other\n * control in this kit now answers to. Kept working because three applications ship\n * this one today; it names the group only when `aria-label` is absent.\n */\n ariaLabel?: string;\n /**\n * Show, refuse the change (Keksdose live #288: a payment dated in the future has no\n * state to set).\n *\n * Whatever `value` says stays pressed and keeps its own fill rather than going grey\n * with the rest — a reader who cannot see WHICH option is chosen has been told less\n * than before it was disabled. A caller with nothing to show passes no value, and\n * the group renders dimmed with nothing pressed, which is the shape Keksdose's\n * status picker uses for a row whose status does not exist yet.\n *\n * On the whole GROUP, not per option: a segmented control where some segments are\n * live and others are not is a menu with holes in it, and no caller here wants one.\n */\n disabled?: boolean;\n /**\n * `sm`: 12px options with `px-2 py-1` — the compact group keksdose's rule editor\n * (rule-editor:204) writes as `optionClassName=\"px-2 py-1 text-xs\"` beside a small\n * caption. `md` (default) is the size every other group has.\n */\n size?: \"sm\" | \"md\";\n /**\n * Stand in a form row as a FIELD: with a label the group wears the field's chrome —\n * border, surface, the top strip with a small static label in it, a labelled\n * {@link Select}'s height — so beside an Input or a Select it reads as one of them\n * rather than as a control with a caption over it. lenkbank builds exactly this by\n * hand as `ToggleField` (features/gear/common.tsx:97, feedback #69), and its notes\n * are why the chrome STRETCHES to its row as well as matching the select's padding:\n * a native select's height is the browser's, so a toggle a few pixels short of it\n * is levelled up by the row rather than by arithmetic.\n *\n * The label names the group (`aria-labelledby`), so `aria-label` is not needed. With\n * a label, `className` styles the field's wrapper — as on {@link Select} — and the\n * group's own box is dropped: two nested borders read as a control in a control.\n */\n label?: ReactNode;\n /**\n * Where `label` goes. `\"field\"` (default): the field chrome described under `label`.\n * `\"above\"`: the kit's {@link Label} over the bare group — the shape of a {@link Field}\n * — with `hint` beside the label and `error` under the group, for a form that sets\n * its labels above its fields (kastlan's international-rent-calculator.tsx, whose DE\n * cap pair sits in a `Field` column between two labelled-above inputs, where the\n * chrome's inner label would be the only one of its kind).\n *\n * Inside a `Field`, pass no `label` at all and spread the render-prop instead —\n * `{(ids, { labelId }) => <ToggleGroup {...ids} aria-labelledby={labelId} … />}` —\n * so the Field's label names the group and its hint and error describe it.\n */\n labelPlacement?: \"field\" | \"above\";\n /** A {@link FieldHint} on the label line, as on a labelled {@link Select}. Only with\n * `label`. */\n hint?: ReactNode;\n /** The message under the field when it is wrong: paints the field's border with\n * `--danger`, marks the group `aria-invalid` and describes it with the message, as\n * {@link Select}'s `error` does. Only with `label`. */\n error?: ReactNode;\n}\n\n/**\n * A line under the group saying what the CHOSEN option means — lenkbank's ToggleField\n * `hint` (features/gear/common.tsx:97): not help behind a \"?\" but a caption, and one\n * that changes as the choice does. Pass a function of the value for that; it is\n * attached with `aria-describedby`, and a function caption is also a polite live\n * region, because a description is read when the group is entered and not again when\n * an arrow key changes the choice underneath it.\n *\n * In muted 11px text under the field (or the bare group), above an `error`.\n */\ntype ToggleGroupCaption<V> = ReactNode | ((value: V) => ReactNode);\n\n/** The group as it has always been: one option is always the answer. */\nexport interface ToggleGroupRequiredProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty?: false;\n /**\n * What the options ARE to a screen reader, separately from whether the group can be\n * emptied (kastlan feedback #47).\n *\n * - `\"radio\"` (default) — a `radiogroup` of radios: one Tab stop, arrow keys MOVE the\n * choice. Right for a choice between answers (\"Monthly / Yearly\").\n * - `\"pressed\"` — a `group` of toggle buttons (`aria-pressed`), each its own Tab stop,\n * Space/Enter to press; still one option always pressed. Right for a row that reads\n * as a set of switches — a view mode, a toolbar-like filter — where arrows moving the\n * selection on focus would be a surprise.\n *\n * Before this the only way to `aria-pressed` was `allowEmpty`, which also let a second\n * press clear the choice — so kastlan took the clearable shape and threw the `null`\n * away in `onChange` (`(v) => v && setMode(v)`), a group announcing that a press would\n * unpress what it would not. Here a press on the pressed option re-sends its value, as\n * the radio shape does, and nothing is ever unpressed. A clearable group\n * (`allowEmpty`) is always `\"pressed\"`: a radio cannot be unchecked by activating it.\n */\n semantics?: \"radio\" | \"pressed\";\n value: T;\n onChange: (value: T) => void;\n /** See {@link ToggleGroupCaption}. */\n caption?: ToggleGroupCaption<T>;\n}\n\n/**\n * A group that can be emptied: clicking the active option clears it, and `onChange`\n * receives `null` (Keksdose's support-panel filters, where \"no filter\" is reached by\n * clicking the filter that is on).\n *\n * The options become TOGGLE BUTTONS (`aria-pressed`, in a `role=\"group\"`) rather than\n * radios. A radio cannot be unchecked by activating it — no screen reader user expects\n * a second press on \"Open, radio, checked\" to leave nothing checked, and nothing would\n * tell them it had. \"Open, toggle button, pressed\" says exactly what a press will do.\n */\nexport interface ToggleGroupClearableProps<T extends string> extends ToggleGroupBaseProps<T> {\n allowEmpty: true;\n /** Always toggle buttons — see {@link ToggleGroupRequiredProps.semantics}. Accepted so\n * a wrapper can forward one `semantics` to either shape. */\n semantics?: \"pressed\";\n value: T | null;\n onChange: (value: T | null) => void;\n /** See {@link ToggleGroupCaption}. `null` while nothing is chosen. */\n caption?: ToggleGroupCaption<T | null>;\n}\n\n/** `allowEmpty` picks the shape, so `onChange` is typed `(T) => void` unless the group\n * can actually emit `null` — no existing caller has a `null` to handle. */\nexport type ToggleGroupProps<T extends string> =\n | ToggleGroupRequiredProps<T>\n | ToggleGroupClearableProps<T>;\n\n/**\n * Overloaded rather than typed by the union alone (keksdose, \"Gaps found adopting\n * 0.6.0\" #7). Inferring `T` through a union of prop shapes let TypeScript settle on\n * `string`, so `<ToggleGroup allowEmpty value={filter} onChange={setFilter} />` over a\n * `useState<Status | null>` did not compile unless the caller spelled\n * `<ToggleGroup<Status>>`. One signature per mode lets each infer `T` from its own\n * `value`/`onChange`/`options`; the third keeps a caller that forwards a\n * {@link ToggleGroupProps} union (a wrapper component) compiling.\n */\nexport function ToggleGroup<T extends string>(props: ToggleGroupClearableProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupRequiredProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement;\nexport function ToggleGroup<T extends string>(props: ToggleGroupProps<T>): ReactElement {\n const {\n value,\n options,\n className,\n optionClassName,\n overflow = \"truncate\",\n ariaLabel,\n disabled = false,\n size = \"md\",\n label,\n labelPlacement = \"field\",\n hint,\n error,\n \"aria-label\": ariaLabelAttr,\n ...restWithMode\n } = props;\n const labelId = useId();\n const errorId = useId();\n const labelled = label !== undefined && label !== null && label !== false && label !== \"\";\n // `field` is the chrome; a label placed above keeps the bare group's own box.\n const field = labelled && labelPlacement === \"field\";\n const above = labelled && labelPlacement === \"above\";\n const hasError = labelled && error !== undefined && error !== null && error !== false && error !== \"\";\n // Taken off the rest so neither reaches the DOM; `props` keeps them paired, which is\n // what lets the `onChange` below be called with `null` only in the mode that allows it.\n const { allowEmpty: _allowEmpty, onChange: _onChange, caption, semantics: _semantics, ...rest } = restWithMode;\n // Invalid from outside too: a `Field` hands the bare group `aria-invalid`, and the\n // border has to say what the attribute says.\n const outsideInvalid = rest[\"aria-invalid\"] === true || rest[\"aria-invalid\"] === \"true\";\n const captionId = useId();\n const captionIsLive = typeof caption === \"function\";\n const captionNode = captionIsLive ? (caption as (v: T | null) => ReactNode)(value) : caption;\n const hasCaption = captionNode !== undefined && captionNode !== null && captionNode !== false && captionNode !== \"\";\n const choose = (next: T) => {\n if (props.allowEmpty) props.onChange(next === value ? null : next);\n else props.onChange(next);\n };\n // `pressed`: toggle buttons. Every clearable group is; a required one is when it asks\n // (kastlan #47) — the role, and not whether a second press clears, is what this flag\n // decides from here on, so `choose` above still keys off `allowEmpty` alone.\n const pressed = props.allowEmpty === true || props.semantics === \"pressed\";\n // A radio group is ONE tab stop (the checked radio, else the first) and arrows move\n // the choice — the pattern `role=\"radiogroup\"` promises a screen-reader user. Before\n // 0.7.0 each segment was its own tab stop with no arrow keys. The toggle-button shape\n // is a row of buttons, where separate tab stops are the pattern.\n const tabStop = options.some((o) => o.value === value) ? value : options[0]?.value;\n const onRadioKey = (e: KeyboardEvent<HTMLButtonElement>, index: number) => {\n const last = options.length - 1;\n let next: number | null = null;\n const step = horizontalStep(e.key, e.currentTarget);\n if (step !== 0) next = index + step;\n else if (e.key === \"ArrowDown\") next = index + 1;\n else if (e.key === \"ArrowUp\") next = index - 1;\n else if (e.key === \"Home\") next = 0;\n else if (e.key === \"End\") next = last;\n if (next === null) return;\n e.preventDefault();\n next = next < 0 ? last : next > last ? 0 : next;\n const buttons = e.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>(\":scope > button\");\n buttons?.[next]?.focus();\n choose(options[next].value);\n };\n const group = (\n <div\n // The audit's named example of a closed prop list (§\"Public API design\"): the\n // tour locates a step by CSS SELECTOR, so a component that drops every attribute\n // it was not expecting cannot be spotlighted at all — and Keksdose's rule editor\n // carries a comment explaining that it wraps this group in a bare <div> for\n // exactly that reason.\n //\n // `...rest` first, then the attributes the group cannot do without: a caller\n // hanging an anchor or a test id on the group must not be able to overwrite the\n // radiogroup role or the disabled state by accident. `className` is destructured\n // out entirely and merged through `cn`, so it is never in here.\n {...rest}\n role={pressed ? \"group\" : \"radiogroup\"}\n // The DOM spelling wins; `ariaLabel` is the fallback for the call sites that\n // have not moved yet.\n aria-label={ariaLabelAttr ?? ariaLabel}\n aria-labelledby={labelled && ariaLabelAttr === undefined && ariaLabel === undefined ? labelId : rest[\"aria-labelledby\"]}\n aria-invalid={hasError || rest[\"aria-invalid\"] || undefined}\n aria-describedby={\n [rest[\"aria-describedby\"], hasCaption && captionId, hasError && errorId].filter(Boolean).join(\" \") || undefined\n }\n // `aria-disabled` on the group as well as `disabled` on each button: a radio\n // group is what the user is being refused, and a screen reader announcing\n // three separately-disabled radios does not say that.\n aria-disabled={disabled || undefined}\n className={cn(\n // `gap-0.5` — the same 2px as the container's own padding, so EVERY segment\n // sits in a uniform 2px moat and no two fills ever touch. Flush segments were\n // Keksdose live #268's rework: the pressed segment wears a saturated fill and\n // an unpressed neighbour wears a pale hover fill, and with a shared edge the\n // two rectangles read as one smeared shape — *\"the boundary of the selected\n // option and hovering next to it overlays the boundary of the selected\n // button\"*. A gap is what makes each segment its own chip; it cannot be\n // undone by a caller's per-option colour, which a hover-only fix could.\n //\n // (The hover fill is the DESKTOP half of that report: Tailwind v4 wraps every\n // `hover:` in `@media (hover: hover)`, so a phone never paints it. The half a\n // phone does see is the focus ring — see the segment's own note below.)\n \"inline-flex w-full gap-0.5 rounded-md border border-[var(--border-strong)] bg-[var(--bg-surface)] p-0.5 shadow-sm\",\n overflow === \"wrap\" && \"flex-wrap\",\n // The whole group fades, the way every other disabled control in this\n // package does; `cursor-not-allowed` is on the buttons, which is what a\n // pointer is actually over.\n disabled && \"opacity-60\",\n // The bare group (no chrome to paint) wears the invalid border itself.\n !field && (outsideInvalid || (above && hasError)) && FIELD_INVALID,\n // Inside the field's chrome the group is only a row of segments: no border, no\n // surface, no padding of its own, and the field (not the group) is what dims.\n field && \"border-0 bg-transparent p-0 shadow-none opacity-100\",\n !labelled && className,\n )}\n >\n {options.map((opt, index) => {\n const active = opt.value === value;\n return (\n <button\n key={opt.value}\n type=\"button\"\n role={pressed ? undefined : \"radio\"}\n aria-checked={pressed ? undefined : active}\n aria-pressed={pressed ? active : undefined}\n disabled={disabled}\n tabIndex={pressed ? undefined : opt.value === tabStop ? 0 : -1}\n onKeyDown={pressed ? undefined : (e) => onRadioKey(e, index)}\n onClick={() => choose(opt.value)}\n className={cn(\n // `truncate` (which carries whitespace-nowrap) rather than letting a\n // label wrap: a segmented control sizes its whole row to the tallest\n // option, so one two-word option — Keksdose feedback #147's \"Where I\n // am\" — silently doubles the height of every segment beside it.\n //\n // `basis-auto` is what keeps that ellipsis a LAST resort rather than\n // the normal state (Keksdose dev#475). With flex-1's `basis-0`, a\n // shrink-to-fit group (`w-auto`) still resolves to the sum of the\n // labels' widths — and then splits it EQUALLY, so the short option\n // got 66px it did not need and \"Where I am\" got 66 of the 81 it did:\n // truncated at 1778px of free screen. Basing each segment on its own\n // content and sharing only the LEFTOVER space keeps a full-width\n // group's segments near-equal and an auto-width group's exact.\n //\n // `focus-visible` + `ring-inset`, not `focus` + an outset ring. A ring\n // is a box-shadow that spreads OUTWARD, so on a flush group it painted\n // 2px of ring over both neighbours and over the container's own border\n // — and on a phone it appeared on every TAP, because a tap focuses the\n // button. That is the other half of what live #268's rework saw\n // overlaying the selected segment's boundary. Inset keeps the ring\n // inside the segment it belongs to; focus-visible keeps it for the\n // keyboard, which is the only input that needs it.\n overflow === \"wrap\" ? \"whitespace-nowrap\" : \"min-w-0 truncate\",\n \"flex-1 basis-auto rounded px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--border-strong)]\",\n size === \"sm\" && \"px-2 py-1 text-xs\",\n // In a field: no vertical padding and a 20px line — a `text-sm` line, the\n // same line a labelled Select holds under its label strip — so the field's\n // own `pt-4 pb-1` decides the height, as it does for the select.\n field && \"py-0 leading-5\",\n active\n ? \"bg-[var(--bg-inverse)] text-[var(--text-inverse)]\"\n : \"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]\",\n // No hover fill on a group that cannot be changed — a segment that\n // lights up under the pointer is an offer, and there is none here. Not on\n // the chosen segment: its fill IS its state, and its inverse text would\n // vanish on a transparent hover.\n disabled && \"cursor-not-allowed\",\n disabled && !active && \"hover:bg-transparent dark:hover:bg-transparent\",\n optionClassName,\n opt.className,\n )}\n >\n {opt.label}\n </button>\n );\n })}\n </div>\n );\n // Rendered whenever the caption is — `aria-live` must be on the element BEFORE its\n // text changes, or the change is not announced — but empty (no height, no margin)\n // when there is nothing to say, so a function caption that returns null for some\n // options leaves no gap. Empty rather than `hidden`: some readers do not announce\n // text that appears inside an element coming back from `display: none`.\n const captionEl =\n hasCaption || captionIsLive ? (\n <p\n id={captionId}\n aria-live={captionIsLive ? \"polite\" : undefined}\n className={cn(\"text-[11px] leading-snug text-[var(--text-muted)]\", hasCaption && \"mt-1\")}\n >\n {hasCaption ? captionNode : null}\n </p>\n ) : null;\n const errorEl = hasError ? (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n ) : null;\n if (above) {\n // `relative` so a caller's `sr-only` label cannot escape (sr-only-containment).\n return (\n <div className={cn(\"relative grid min-w-0 gap-1.5\", className)}>\n <div className=\"flex items-center gap-1\">\n {/* A `<label>` with no `htmlFor`: a group is not labelable, so it is named\n by `aria-labelledby` on the group; the element keeps the Field look. */}\n <Label\n id={labelId}\n disabled={disabled}\n data-error={hasError || undefined}\n className=\"data-[error=true]:text-[var(--danger)]\"\n >\n {label}\n </Label>\n {hint}\n </div>\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n {errorEl}\n </div>\n </div>\n );\n }\n if (!field) {\n if (!captionEl) return group;\n // The group keeps its `className`, as without a caption; the wrapper only stacks.\n return (\n <div className=\"min-w-0\">\n {group}\n {captionEl}\n </div>\n );\n }\n return (\n // `h-full` + `flex-1`: the chrome fills a grid or stretched flex row, which is what\n // levels it with a select beside it whatever the browser makes of the select.\n <div className={cn(\"flex h-full flex-col\", className)}>\n <FloatingField\n className=\"flex flex-1 flex-col\"\n label={<span id={labelId}>{label}</span>}\n staticLabel\n hint={hint}\n >\n <div\n className={cn(\n \"flex flex-1 flex-col justify-center rounded-md border border-[var(--border)] bg-[var(--bg-surface)] px-1 pt-4 pb-1 shadow-sm\",\n disabled && \"bg-[var(--bg-surface-2)] opacity-60\",\n hasError && FIELD_INVALID,\n )}\n >\n {group}\n </div>\n </FloatingField>\n {captionEl}\n {errorEl}\n </div>\n );\n}\n"],"mappings":";AA0SU,cAmFF,YAnFE;AA1SV,SAAS,aAAa;AAEtB,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAC/B,SAAS,eAAe,eAAe,aAAa;AA+K7C,SAAS,YAA8B,OAA0C;AACtF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,UAAU,MAAM;AACtB,QAAM,UAAU,MAAM;AACtB,QAAM,WAAW,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AAEvF,QAAM,QAAQ,YAAY,mBAAmB;AAC7C,QAAM,QAAQ,YAAY,mBAAmB;AAC7C,QAAM,WAAW,YAAY,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AAGnG,QAAM,EAAE,YAAY,aAAa,UAAU,WAAW,SAAS,WAAW,YAAY,GAAG,KAAK,IAAI;AAGlG,QAAM,iBAAiB,KAAK,cAAc,MAAM,QAAQ,KAAK,cAAc,MAAM;AACjF,QAAM,YAAY,MAAM;AACxB,QAAM,gBAAgB,OAAO,YAAY;AACzC,QAAM,cAAc,gBAAiB,QAAuC,KAAK,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AAc,gBACZ;AAAA,IAAC;AAAA;AAAA,MACC,IAAI;AAAA,MACJ,aAAW,gBAAgB,WAAW;AAAA,MACtC,WAAW,GAAG,qDAAqD,cAAc,MAAM;AAAA,MAEtF,uBAAa,cAAc;AAAA;AAAA,EAC9B,IACE;AACN,QAAM,UAAU,WACd,oBAAC,OAAE,IAAI,SAAS,WAAU,uDACvB,iBACH,IACE;AACJ,MAAI,OAAO;AAET,WACE,qBAAC,SAAI,WAAW,GAAG,iCAAiC,SAAS,GAC3D;AAAA,2BAAC,SAAI,WAAU,2BAGb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,YACJ;AAAA,YACA,cAAY,YAAY;AAAA,YACxB,WAAU;AAAA,YAET;AAAA;AAAA,QACH;AAAA,QACC;AAAA,SACH;AAAA,MACA,qBAAC,SAAI,WAAU,WACZ;AAAA;AAAA,QACA;AAAA,QACA;AAAA,SACH;AAAA,OACF;AAAA,EAEJ;AACA,MAAI,CAAC,OAAO;AACV,QAAI,CAAC,UAAW,QAAO;AAEvB,WACE,qBAAC,SAAI,WAAU,WACZ;AAAA;AAAA,MACA;AAAA,OACH;AAAA,EAEJ;AACA;AAAA;AAAA;AAAA,IAGE,qBAAC,SAAI,WAAW,GAAG,wBAAwB,SAAS,GAClD;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAO,oBAAC,UAAK,IAAI,SAAU,iBAAM;AAAA,UACjC,aAAW;AAAA,UACX;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,YAAY;AAAA,gBACZ,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA,MACC;AAAA,MACA;AAAA,OACH;AAAA;AAEJ;","names":[]}
@@ -0,0 +1,56 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { TranslationRow, TranslationReviewWrite, TranslationReviewKey } from '../lib/translation-review.js';
4
+ import { TranslationReviewLabels } from './translation-review-labels.js';
5
+
6
+ /** A callback may return a promise: resolve and the editor closes, reject and it stays
7
+ * open with the error. */
8
+ type MaybePromise = void | Promise<unknown>;
9
+ interface TranslationReviewEditorProps {
10
+ row: TranslationRow;
11
+ /** The reference language's own name ("English", "Deutsch") — the app's choice of
12
+ * reference, so the app's word for it. */
13
+ referenceLabel: ReactNode;
14
+ /** The reviewed language's own name ("Français"). */
15
+ localeLabel: ReactNode;
16
+ /** Store a verdict. Left out (or `readOnly`): the editor shows the row and its last
17
+ * verdict, with no fields and no actions. */
18
+ onSave?: (write: TranslationReviewWrite) => MaybePromise;
19
+ /** Clear the verdict — back to unreviewed. Left out: no reset button. */
20
+ onClear?: (key: TranslationReviewKey) => MaybePromise;
21
+ /** The Cancel button — and called after a save or a reset resolves, so the panel
22
+ * that opened the editor closes it. */
23
+ onClose?: () => void;
24
+ /** Look, do not touch: a locale the viewer may read but not review. */
25
+ readOnly?: boolean;
26
+ /** How the verdict's date reads. Default: the kit's `formatDate`, medium, in the
27
+ * provider's locale. */
28
+ formatDate?: (iso: string) => string;
29
+ /** Turns a rejection into words. Default {@link TranslationReviewLabels.failed}. */
30
+ formatError?: (error: unknown) => ReactNode;
31
+ className?: string;
32
+ labels?: Partial<TranslationReviewLabels>;
33
+ }
34
+ /**
35
+ * One string, opened: the reference beside the translation, what changed since the last
36
+ * verdict, what a machine can see is wrong (the placeholders), and the two things a
37
+ * reviewer can say about it — keksdose's and kastlan's `translation-review-editor.tsx`.
38
+ *
39
+ * "Better wording" opens on the CURRENT text rather than empty, because the usual
40
+ * correction is a word or an ending, and retyping a sentence to change one word is how
41
+ * new mistakes get in. It is sent only with "Needs a change" — approving says the text is
42
+ * fine as it stands. A "Needs a change" with neither a note nor a different wording tells
43
+ * whoever fixes it nothing, so it takes one of the two.
44
+ *
45
+ * A MISSING string (kastlan: the locale lacks the key) cannot be approved — there is
46
+ * nothing to approve. Its field starts empty and is the translation to add; the verdict
47
+ * is NEEDS_CHANGE on the empty text, which the export hands a developer as the string to
48
+ * add.
49
+ *
50
+ * Every action waits for its callback: the buttons hold while the promise is out, a
51
+ * resolution closes the editor through `onClose`, and a rejection keeps it open with what
52
+ * was typed and the error under the buttons.
53
+ */
54
+ declare function TranslationReviewEditor({ row, referenceLabel, localeLabel, onSave, onClear, onClose, readOnly, formatDate: formatDateProp, formatError, className, labels: labelsProp, }: TranslationReviewEditorProps): react.JSX.Element;
55
+
56
+ export { TranslationReviewEditor, type TranslationReviewEditorProps };
@@ -0,0 +1,159 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { useKitLabels } from "../i18n/kit-labels.js";
5
+ import { cn } from "../lib/cn.js";
6
+ import { useKitFormat } from "../lib/format.js";
7
+ import { placeholderTokens, reviewWrite } from "../lib/translation-review.js";
8
+ import { AlertBanner } from "./alert-banner.js";
9
+ import { Caption, SectionLabel } from "./text.js";
10
+ import { DEFAULT_TRANSLATION_REVIEW_LABELS } from "./translation-review-labels.js";
11
+ import { Button, Textarea } from "./ui.js";
12
+ function Then({ label, text }) {
13
+ return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 min-w-0", children: [
14
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: label }),
15
+ /* @__PURE__ */ jsx("p", { className: "whitespace-pre-line break-words text-[var(--text-secondary)]", children: text })
16
+ ] });
17
+ }
18
+ function TranslationReviewEditor({
19
+ row,
20
+ referenceLabel,
21
+ localeLabel,
22
+ onSave,
23
+ onClear,
24
+ onClose,
25
+ readOnly = false,
26
+ formatDate: formatDateProp,
27
+ formatError,
28
+ className,
29
+ labels: labelsProp
30
+ }) {
31
+ const labels = useKitLabels("translationReview", DEFAULT_TRANSLATION_REVIEW_LABELS, labelsProp);
32
+ const { formatDate } = useKitFormat();
33
+ const review = row.review;
34
+ const missing = row.text === "";
35
+ const editable = !readOnly && onSave !== void 0;
36
+ const [suggestion, setSuggestion] = useState(review?.suggestion ?? row.text);
37
+ const [note, setNote] = useState(review?.note ?? "");
38
+ const [busy, setBusy] = useState(null);
39
+ const [failure, setFailure] = useState(null);
40
+ const canFlag = note.trim() !== "" || suggestion.trim() !== row.text.trim();
41
+ const changed = row.status === "changed" ? review : null;
42
+ const date = (iso) => formatDateProp ? formatDateProp(iso) : formatDate(iso, "medium");
43
+ const run = async (kind, action) => {
44
+ setBusy(kind);
45
+ setFailure(null);
46
+ try {
47
+ await action();
48
+ onClose?.();
49
+ } catch (caught) {
50
+ setFailure(formatError ? formatError(caught) : labels.failed);
51
+ } finally {
52
+ setBusy(null);
53
+ }
54
+ };
55
+ const save = (verdict) => {
56
+ if (!onSave) return;
57
+ const trimmedNote = note.trim() || null;
58
+ const sent = verdict === "APPROVED" ? null : suggestion.trim() || null;
59
+ void run(
60
+ verdict === "APPROVED" ? "approve" : "flag",
61
+ () => onSave(reviewWrite(row, verdict, trimmedNote, sent))
62
+ );
63
+ };
64
+ return /* @__PURE__ */ jsxs("div", { className: cn("min-w-0 space-y-3 text-sm", className), children: [
65
+ /* @__PURE__ */ jsx("code", { className: "block break-all text-xs text-[var(--text-muted)]", children: row.key }),
66
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-3 md:grid-cols-2", children: [
67
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
68
+ /* @__PURE__ */ jsx(SectionLabel, { as: "span", size: "xs", children: referenceLabel }),
69
+ /* @__PURE__ */ jsx("p", { className: "mt-1 whitespace-pre-line break-words text-[var(--text-secondary)]", children: row.reference })
70
+ ] }),
71
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
72
+ /* @__PURE__ */ jsx(SectionLabel, { as: "span", size: "xs", children: localeLabel }),
73
+ missing ? /* @__PURE__ */ jsx("p", { className: "mt-1 italic text-[var(--text-muted)]", children: labels.missingText }) : /* @__PURE__ */ jsx("p", { lang: row.locale, className: "mt-1 whitespace-pre-line break-words", children: row.text })
74
+ ] })
75
+ ] }),
76
+ changed && /* @__PURE__ */ jsx(AlertBanner, { tone: "warning", variant: "inline", size: "sm", block: true, live: false, children: /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
77
+ /* @__PURE__ */ jsx("p", { children: labels.changedSince }),
78
+ changed.text !== row.text && /* @__PURE__ */ jsx(Then, { label: labels.reviewedWording, text: changed.text || "\u2014" }),
79
+ changed.referenceText != null && changed.referenceText !== row.reference && /* @__PURE__ */ jsx(Then, { label: labels.reviewedReference, text: changed.referenceText })
80
+ ] }) }),
81
+ row.placeholderMismatch && /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", variant: "inline", size: "sm", block: true, live: false, children: /* @__PURE__ */ jsx("span", { className: "min-w-0 break-words", children: labels.placeholderMismatch(
82
+ placeholderTokens(row.reference).join(" ") || "\u2014",
83
+ placeholderTokens(row.text).join(" ") || "\u2014"
84
+ ) }) }),
85
+ review && /* @__PURE__ */ jsx(Caption, { children: (review.verdict === "APPROVED" ? labels.lastApproved : labels.lastFlagged)(
86
+ review.reviewerName ?? labels.erasedReviewer,
87
+ date(review.reviewedAt)
88
+ ) }),
89
+ !editable && review?.verdict === "NEEDS_CHANGE" && (review.suggestion || review.note) && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
90
+ review.suggestion && /* @__PURE__ */ jsx(Then, { label: missing ? labels.translation : labels.suggestion, text: review.suggestion }),
91
+ review.note && /* @__PURE__ */ jsx(Then, { label: labels.note, text: review.note })
92
+ ] }),
93
+ editable && /* @__PURE__ */ jsxs(Fragment, { children: [
94
+ /* @__PURE__ */ jsx(
95
+ Textarea,
96
+ {
97
+ label: missing ? labels.translation : labels.suggestion,
98
+ lang: row.locale,
99
+ rows: Math.min(8, Math.max(2, Math.ceil(Math.max(row.text.length, row.reference.length) / 80))),
100
+ value: suggestion,
101
+ disabled: busy !== null,
102
+ onChange: (e) => setSuggestion(e.target.value)
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsx(
106
+ Textarea,
107
+ {
108
+ label: labels.note,
109
+ rows: 2,
110
+ value: note,
111
+ placeholder: labels.notePlaceholder,
112
+ disabled: busy !== null,
113
+ onChange: (e) => setNote(e.target.value)
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
117
+ !missing && /* @__PURE__ */ jsx(
118
+ Button,
119
+ {
120
+ variant: "primary",
121
+ commit: true,
122
+ pending: busy === "approve",
123
+ disabled: busy !== null,
124
+ onClick: () => save("APPROVED"),
125
+ children: labels.approve
126
+ }
127
+ ),
128
+ /* @__PURE__ */ jsx(
129
+ Button,
130
+ {
131
+ variant: missing ? "primary" : "danger",
132
+ commit: true,
133
+ pending: busy === "flag",
134
+ disabled: busy !== null || !canFlag,
135
+ onClick: () => save("NEEDS_CHANGE"),
136
+ children: missing ? labels.suggest : labels.flag
137
+ }
138
+ ),
139
+ review && onClear && /* @__PURE__ */ jsx(
140
+ Button,
141
+ {
142
+ variant: "ghost",
143
+ commit: true,
144
+ pending: busy === "clear",
145
+ disabled: busy !== null,
146
+ onClick: () => void run("clear", () => onClear({ locale: row.locale, key: row.key })),
147
+ children: labels.reset
148
+ }
149
+ ),
150
+ onClose && /* @__PURE__ */ jsx(Button, { variant: "ghost", disabled: busy !== null, onClick: onClose, children: labels.cancel })
151
+ ] })
152
+ ] }),
153
+ failure && /* @__PURE__ */ jsx(AlertBanner, { tone: "danger", size: "sm", role: "alert", children: failure })
154
+ ] });
155
+ }
156
+ export {
157
+ TranslationReviewEditor
158
+ };
159
+ //# sourceMappingURL=translation-review-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/translation-review-editor.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { useKitFormat } from \"../lib/format\";\nimport { placeholderTokens, reviewWrite } from \"../lib/translation-review\";\nimport type {\n TranslationReviewKey,\n TranslationReviewWrite,\n TranslationRow,\n TranslationVerdict,\n} from \"../lib/translation-review\";\nimport { AlertBanner } from \"./alert-banner\";\nimport { Caption, SectionLabel } from \"./text\";\nimport { DEFAULT_TRANSLATION_REVIEW_LABELS } from \"./translation-review-labels\";\nimport type { TranslationReviewLabels } from \"./translation-review-labels\";\nimport { Button, Textarea } from \"./ui\";\n\n/** A callback may return a promise: resolve and the editor closes, reject and it stays\n * open with the error. */\ntype MaybePromise = void | Promise<unknown>;\n\nexport interface TranslationReviewEditorProps {\n row: TranslationRow;\n /** The reference language's own name (\"English\", \"Deutsch\") — the app's choice of\n * reference, so the app's word for it. */\n referenceLabel: ReactNode;\n /** The reviewed language's own name (\"Français\"). */\n localeLabel: ReactNode;\n /** Store a verdict. Left out (or `readOnly`): the editor shows the row and its last\n * verdict, with no fields and no actions. */\n onSave?: (write: TranslationReviewWrite) => MaybePromise;\n /** Clear the verdict — back to unreviewed. Left out: no reset button. */\n onClear?: (key: TranslationReviewKey) => MaybePromise;\n /** The Cancel button — and called after a save or a reset resolves, so the panel\n * that opened the editor closes it. */\n onClose?: () => void;\n /** Look, do not touch: a locale the viewer may read but not review. */\n readOnly?: boolean;\n /** How the verdict's date reads. Default: the kit's `formatDate`, medium, in the\n * provider's locale. */\n formatDate?: (iso: string) => string;\n /** Turns a rejection into words. Default {@link TranslationReviewLabels.failed}. */\n formatError?: (error: unknown) => ReactNode;\n className?: string;\n labels?: Partial<TranslationReviewLabels>;\n}\n\n/** The wording a verdict was given on, under the line that says it changed. */\nfunction Then({ label, text }: { label: string; text: string }) {\n return (\n <div className=\"mt-1.5 min-w-0\">\n <span className=\"text-xs font-medium\">{label}</span>\n <p className=\"whitespace-pre-line break-words text-[var(--text-secondary)]\">{text}</p>\n </div>\n );\n}\n\n/**\n * One string, opened: the reference beside the translation, what changed since the last\n * verdict, what a machine can see is wrong (the placeholders), and the two things a\n * reviewer can say about it — keksdose's and kastlan's `translation-review-editor.tsx`.\n *\n * \"Better wording\" opens on the CURRENT text rather than empty, because the usual\n * correction is a word or an ending, and retyping a sentence to change one word is how\n * new mistakes get in. It is sent only with \"Needs a change\" — approving says the text is\n * fine as it stands. A \"Needs a change\" with neither a note nor a different wording tells\n * whoever fixes it nothing, so it takes one of the two.\n *\n * A MISSING string (kastlan: the locale lacks the key) cannot be approved — there is\n * nothing to approve. Its field starts empty and is the translation to add; the verdict\n * is NEEDS_CHANGE on the empty text, which the export hands a developer as the string to\n * add.\n *\n * Every action waits for its callback: the buttons hold while the promise is out, a\n * resolution closes the editor through `onClose`, and a rejection keeps it open with what\n * was typed and the error under the buttons.\n */\nexport function TranslationReviewEditor({\n row,\n referenceLabel,\n localeLabel,\n onSave,\n onClear,\n onClose,\n readOnly = false,\n formatDate: formatDateProp,\n formatError,\n className,\n labels: labelsProp,\n}: TranslationReviewEditorProps) {\n const labels = useKitLabels(\"translationReview\", DEFAULT_TRANSLATION_REVIEW_LABELS, labelsProp);\n const { formatDate } = useKitFormat();\n const review = row.review;\n const missing = row.text === \"\";\n const editable = !readOnly && onSave !== undefined;\n const [suggestion, setSuggestion] = useState(review?.suggestion ?? row.text);\n const [note, setNote] = useState(review?.note ?? \"\");\n const [busy, setBusy] = useState<\"approve\" | \"flag\" | \"clear\" | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n\n const canFlag = note.trim() !== \"\" || suggestion.trim() !== row.text.trim();\n const changed = row.status === \"changed\" ? review : null;\n const date = (iso: string) => (formatDateProp ? formatDateProp(iso) : formatDate(iso, \"medium\"));\n\n const run = async (kind: \"approve\" | \"flag\" | \"clear\", action: () => MaybePromise) => {\n setBusy(kind);\n setFailure(null);\n try {\n await action();\n onClose?.();\n } catch (caught) {\n setFailure(formatError ? formatError(caught) : labels.failed);\n } finally {\n setBusy(null);\n }\n };\n\n const save = (verdict: TranslationVerdict) => {\n if (!onSave) return;\n const trimmedNote = note.trim() || null;\n // Approving says the text is right as it stands: there is no wording to suggest.\n const sent = verdict === \"APPROVED\" ? null : suggestion.trim() || null;\n void run(verdict === \"APPROVED\" ? \"approve\" : \"flag\", () =>\n onSave(reviewWrite(row, verdict, trimmedNote, sent)),\n );\n };\n\n return (\n <div className={cn(\"min-w-0 space-y-3 text-sm\", className)}>\n <code className=\"block break-all text-xs text-[var(--text-muted)]\">{row.key}</code>\n\n <div className=\"grid gap-3 md:grid-cols-2\">\n <div className=\"min-w-0\">\n <SectionLabel as=\"span\" size=\"xs\">\n {referenceLabel}\n </SectionLabel>\n <p className=\"mt-1 whitespace-pre-line break-words text-[var(--text-secondary)]\">{row.reference}</p>\n </div>\n <div className=\"min-w-0\">\n <SectionLabel as=\"span\" size=\"xs\">\n {localeLabel}\n </SectionLabel>\n {missing ? (\n <p className=\"mt-1 italic text-[var(--text-muted)]\">{labels.missingText}</p>\n ) : (\n <p lang={row.locale} className=\"mt-1 whitespace-pre-line break-words\">\n {row.text}\n </p>\n )}\n </div>\n </div>\n\n {changed && (\n <AlertBanner tone=\"warning\" variant=\"inline\" size=\"sm\" block live={false}>\n <div className=\"min-w-0\">\n <p>{labels.changedSince}</p>\n {changed.text !== row.text && <Then label={labels.reviewedWording} text={changed.text || \"—\"} />}\n {changed.referenceText != null && changed.referenceText !== row.reference && (\n <Then label={labels.reviewedReference} text={changed.referenceText} />\n )}\n </div>\n </AlertBanner>\n )}\n\n {row.placeholderMismatch && (\n <AlertBanner tone=\"danger\" variant=\"inline\" size=\"sm\" block live={false}>\n <span className=\"min-w-0 break-words\">\n {labels.placeholderMismatch(\n placeholderTokens(row.reference).join(\" \") || \"—\",\n placeholderTokens(row.text).join(\" \") || \"—\",\n )}\n </span>\n </AlertBanner>\n )}\n\n {review && (\n <Caption>\n {(review.verdict === \"APPROVED\" ? labels.lastApproved : labels.lastFlagged)(\n review.reviewerName ?? labels.erasedReviewer,\n date(review.reviewedAt),\n )}\n </Caption>\n )}\n\n {/* Read-only: what the reviewer said, as text — the fields are for saying it. */}\n {!editable && review?.verdict === \"NEEDS_CHANGE\" && (review.suggestion || review.note) && (\n <div className=\"space-y-2\">\n {review.suggestion && <Then label={missing ? labels.translation : labels.suggestion} text={review.suggestion} />}\n {review.note && <Then label={labels.note} text={review.note} />}\n </div>\n )}\n\n {editable && (\n <>\n <Textarea\n label={missing ? labels.translation : labels.suggestion}\n lang={row.locale}\n rows={Math.min(8, Math.max(2, Math.ceil(Math.max(row.text.length, row.reference.length) / 80)))}\n value={suggestion}\n disabled={busy !== null}\n onChange={(e) => setSuggestion(e.target.value)}\n />\n <Textarea\n label={labels.note}\n rows={2}\n value={note}\n placeholder={labels.notePlaceholder}\n disabled={busy !== null}\n onChange={(e) => setNote(e.target.value)}\n />\n <div className=\"flex flex-wrap gap-2\">\n {!missing && (\n <Button\n variant=\"primary\"\n commit\n pending={busy === \"approve\"}\n disabled={busy !== null}\n onClick={() => save(\"APPROVED\")}\n >\n {labels.approve}\n </Button>\n )}\n <Button\n variant={missing ? \"primary\" : \"danger\"}\n commit\n pending={busy === \"flag\"}\n disabled={busy !== null || !canFlag}\n onClick={() => save(\"NEEDS_CHANGE\")}\n >\n {missing ? labels.suggest : labels.flag}\n </Button>\n {review && onClear && (\n <Button\n variant=\"ghost\"\n commit\n pending={busy === \"clear\"}\n disabled={busy !== null}\n onClick={() => void run(\"clear\", () => onClear({ locale: row.locale, key: row.key }))}\n >\n {labels.reset}\n </Button>\n )}\n {onClose && (\n <Button variant=\"ghost\" disabled={busy !== null} onClick={onClose}>\n {labels.cancel}\n </Button>\n )}\n </div>\n </>\n )}\n\n {failure && (\n <AlertBanner tone=\"danger\" size=\"sm\" role=\"alert\">\n {failure}\n </AlertBanner>\n )}\n </div>\n );\n}\n"],"mappings":";AAoDI,SA+II,UA9IF,KADF;AApDJ,SAAS,gBAAgB;AAGzB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB,mBAAmB;AAO/C,SAAS,mBAAmB;AAC5B,SAAS,SAAS,oBAAoB;AACtC,SAAS,yCAAyC;AAElD,SAAS,QAAQ,gBA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