@eifi1/ui-kit 0.34.0 → 0.35.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 (241) hide show
  1. package/README.md +82 -38
  2. package/dist/billing/billing-banner.d.ts +5 -2
  3. package/dist/billing/billing-banner.js.map +1 -1
  4. package/dist/billing/plan-limit-notice.d.ts +5 -2
  5. package/dist/billing/plan-limit-notice.js.map +1 -1
  6. package/dist/chart.js.map +1 -1
  7. package/dist/components/amount-input.d.ts +0 -3
  8. package/dist/components/amount-input.js +2 -2
  9. package/dist/components/amount-input.js.map +1 -1
  10. package/dist/components/calculator.d.ts +1 -4
  11. package/dist/components/calculator.js +1 -3
  12. package/dist/components/calculator.js.map +1 -1
  13. package/dist/components/chart-zoom.d.ts +0 -37
  14. package/dist/components/chart-zoom.js +1 -28
  15. package/dist/components/chart-zoom.js.map +1 -1
  16. package/dist/components/chip-input.d.ts +0 -4
  17. package/dist/components/chip-input.js +1 -5
  18. package/dist/components/chip-input.js.map +1 -1
  19. package/dist/components/combobox.d.ts +1 -1
  20. package/dist/components/combobox.js.map +1 -1
  21. package/dist/components/copy-button.d.ts +5 -1
  22. package/dist/components/copy-button.js.map +1 -1
  23. package/dist/components/currency-option-list.d.ts +3 -8
  24. package/dist/components/currency-option-list.js +1 -29
  25. package/dist/components/currency-option-list.js.map +1 -1
  26. package/dist/components/danger-confirm.d.ts +3 -3
  27. package/dist/components/danger-confirm.js.map +1 -1
  28. package/dist/components/data-table-filter-popover.d.ts +1 -1
  29. package/dist/components/data-table-filter-popover.js +1 -1
  30. package/dist/components/data-table-filter-popover.js.map +1 -1
  31. package/dist/components/data-table-labels.d.ts +1 -42
  32. package/dist/components/data-table-labels.js +2 -31
  33. package/dist/components/data-table-labels.js.map +1 -1
  34. package/dist/components/data-table-shared.d.ts +17 -1
  35. package/dist/components/data-table-shared.js +22 -0
  36. package/dist/components/data-table-shared.js.map +1 -1
  37. package/dist/components/data-table.d.ts +12 -2
  38. package/dist/components/data-table.js +18 -14
  39. package/dist/components/data-table.js.map +1 -1
  40. package/dist/components/dialog-frame.d.ts +3 -1
  41. package/dist/components/dialog-frame.js.map +1 -1
  42. package/dist/components/dropdown.d.ts +18 -15
  43. package/dist/components/dropdown.js +11 -3
  44. package/dist/components/dropdown.js.map +1 -1
  45. package/dist/components/entity-combobox.d.ts +1 -1
  46. package/dist/components/entity-combobox.js.map +1 -1
  47. package/dist/components/field-base.d.ts +0 -5
  48. package/dist/components/field-base.js +0 -5
  49. package/dist/components/field-base.js.map +1 -1
  50. package/dist/components/field-parts.d.ts +3 -11
  51. package/dist/components/field-parts.js +1 -9
  52. package/dist/components/field-parts.js.map +1 -1
  53. package/dist/components/field-strip.d.ts +8 -23
  54. package/dist/components/field-strip.js +24 -22
  55. package/dist/components/field-strip.js.map +1 -1
  56. package/dist/components/field-sync.d.ts +0 -4
  57. package/dist/components/field-sync.js +0 -4
  58. package/dist/components/field-sync.js.map +1 -1
  59. package/dist/components/field.d.ts +4 -4
  60. package/dist/components/field.js.map +1 -1
  61. package/dist/components/full-bleed-dialog.js +2 -2
  62. package/dist/components/full-bleed-dialog.js.map +1 -1
  63. package/dist/components/hover-menu.d.ts +6 -13
  64. package/dist/components/hover-menu.js +3 -3
  65. package/dist/components/hover-menu.js.map +1 -1
  66. package/dist/components/inline-entity-combobox.d.ts +1 -1
  67. package/dist/components/inline-entity-combobox.js.map +1 -1
  68. package/dist/components/modal.d.ts +9 -1
  69. package/dist/components/modal.js +7 -4
  70. package/dist/components/modal.js.map +1 -1
  71. package/dist/components/multi-select.d.ts +5 -16
  72. package/dist/components/multi-select.js +5 -10
  73. package/dist/components/multi-select.js.map +1 -1
  74. package/dist/components/number-input.d.ts +0 -3
  75. package/dist/components/number-input.js +2 -4
  76. package/dist/components/number-input.js.map +1 -1
  77. package/dist/components/popover.js +2 -2
  78. package/dist/components/popover.js.map +1 -1
  79. package/dist/components/series-chart.js.map +1 -1
  80. package/dist/components/server-wake.d.ts +0 -6
  81. package/dist/components/server-wake.js.map +1 -1
  82. package/dist/components/settings-fields.d.ts +4 -2
  83. package/dist/components/settings-fields.js.map +1 -1
  84. package/dist/components/stat-tile.d.ts +8 -2
  85. package/dist/components/stat-tile.js.map +1 -1
  86. package/dist/components/swipeable-row.d.ts +2 -17
  87. package/dist/components/swipeable-row.js +11 -16
  88. package/dist/components/swipeable-row.js.map +1 -1
  89. package/dist/components/tooltip.d.ts +9 -1
  90. package/dist/components/tooltip.js +20 -5
  91. package/dist/components/tooltip.js.map +1 -1
  92. package/dist/components/translation-review.d.ts +10 -2
  93. package/dist/components/translation-review.js +11 -3
  94. package/dist/components/translation-review.js.map +1 -1
  95. package/dist/components/use-table-state.d.ts +31 -3
  96. package/dist/components/use-table-state.js +53 -8
  97. package/dist/components/use-table-state.js.map +1 -1
  98. package/dist/components/user-avatar.d.ts +2 -2
  99. package/dist/components/user-avatar.js.map +1 -1
  100. package/dist/components/wizard-stepper.d.ts +1 -4
  101. package/dist/components/wizard-stepper.js +2 -3
  102. package/dist/components/wizard-stepper.js.map +1 -1
  103. package/dist/currencies.d.ts +23 -0
  104. package/dist/currencies.js +38 -0
  105. package/dist/currencies.js.map +1 -0
  106. package/dist/demo/demo-banner.d.ts +7 -2
  107. package/dist/demo/demo-banner.js.map +1 -1
  108. package/dist/eslint/index.d.ts +83 -0
  109. package/dist/eslint/index.js +69 -0
  110. package/dist/eslint/index.js.map +1 -0
  111. package/dist/eslint/role-utilities.d.ts +48 -0
  112. package/dist/eslint/role-utilities.generated.d.ts +2 -0
  113. package/dist/eslint/role-utilities.generated.js +143 -0
  114. package/dist/eslint/role-utilities.generated.js.map +1 -0
  115. package/dist/eslint/role-utilities.js +43 -0
  116. package/dist/eslint/role-utilities.js.map +1 -0
  117. package/dist/feedback/feedback-menu.d.ts +2 -2
  118. package/dist/feedback/feedback-menu.js.map +1 -1
  119. package/dist/feedback/feedback-thread.d.ts +3 -8
  120. package/dist/feedback/feedback-thread.js +0 -2
  121. package/dist/feedback/feedback-thread.js.map +1 -1
  122. package/dist/hooks/use-dismiss.d.ts +16 -3
  123. package/dist/hooks/use-dismiss.js +14 -2
  124. package/dist/hooks/use-dismiss.js.map +1 -1
  125. package/dist/i18n/kit-labels.d.ts +14 -4
  126. package/dist/i18n/kit-labels.js.map +1 -1
  127. package/dist/i18n/locales/en.js +1 -1
  128. package/dist/i18n/locales/en.js.map +2 -2
  129. package/dist/i18n/locales/fr.js +3 -2
  130. package/dist/i18n/locales/fr.js.map +1 -1
  131. package/dist/i18n/locales/it.js +3 -2
  132. package/dist/i18n/locales/it.js.map +1 -1
  133. package/dist/index.d.ts +2 -1
  134. package/dist/index.js +2 -2
  135. package/dist/index.js.map +1 -1
  136. package/dist/lib/refs.d.ts +13 -0
  137. package/dist/lib/refs.js +15 -0
  138. package/dist/lib/refs.js.map +1 -0
  139. package/dist/rhf/fields.d.ts +10 -10
  140. package/dist/rhf/fields.js.map +1 -1
  141. package/dist/rhf/form-core.d.ts +5 -4
  142. package/dist/rhf/form-core.js.map +1 -1
  143. package/dist/rhf/form.d.ts +7 -36
  144. package/dist/rhf/form.js +1 -16
  145. package/dist/rhf/form.js.map +1 -1
  146. package/dist/rhf/line-items.d.ts +1 -1
  147. package/dist/rhf/line-items.js.map +1 -1
  148. package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
  149. package/dist/rhf.js.map +1 -1
  150. package/dist/shell/option-switcher-menu.d.ts +5 -17
  151. package/dist/shell/option-switcher-menu.js +1 -3
  152. package/dist/shell/option-switcher-menu.js.map +1 -1
  153. package/dist/shell/role-switcher.d.ts +1 -4
  154. package/dist/shell/role-switcher.js +2 -3
  155. package/dist/shell/role-switcher.js.map +1 -1
  156. package/dist/shell/topbar-action-menu.d.ts +7 -19
  157. package/dist/shell/topbar-action-menu.js +1 -3
  158. package/dist/shell/topbar-action-menu.js.map +1 -1
  159. package/dist/shell/topbar-controls.d.ts +3 -12
  160. package/dist/shell/topbar-controls.js +6 -9
  161. package/dist/shell/topbar-controls.js.map +1 -1
  162. package/dist/testing/index.d.ts +1 -1
  163. package/dist/testing/index.js +2 -0
  164. package/dist/testing/index.js.map +1 -1
  165. package/dist/testing/viewport.d.ts +25 -2
  166. package/dist/testing/viewport.js +61 -10
  167. package/dist/testing/viewport.js.map +1 -1
  168. package/dist/theme/palette-presets.d.ts +0 -7
  169. package/dist/theme/palette-presets.js +0 -279
  170. package/dist/theme/palette-presets.js.map +1 -1
  171. package/dist/wizard/types.d.ts +0 -5
  172. package/dist/wizard/types.js +1 -5
  173. package/dist/wizard/types.js.map +1 -1
  174. package/package.json +9 -1
  175. package/src/billing/billing-banner.tsx +5 -2
  176. package/src/billing/plan-limit-notice.tsx +5 -2
  177. package/src/chart.ts +5 -3
  178. package/src/components/amount-input.tsx +2 -6
  179. package/src/components/calculator.tsx +2 -7
  180. package/src/components/chart-zoom.tsx +4 -47
  181. package/src/components/chip-input.tsx +0 -7
  182. package/src/components/combobox.tsx +1 -1
  183. package/src/components/copy-button.tsx +5 -1
  184. package/src/components/currency-option-list.tsx +8 -42
  185. package/src/components/danger-confirm.tsx +3 -3
  186. package/src/components/data-table-filter-popover.tsx +2 -1
  187. package/src/components/data-table-labels.ts +2 -84
  188. package/src/components/data-table-shared.tsx +55 -2
  189. package/src/components/data-table.tsx +29 -17
  190. package/src/components/dialog-frame.tsx +3 -1
  191. package/src/components/dropdown.tsx +42 -18
  192. package/src/components/entity-combobox.tsx +1 -1
  193. package/src/components/field-base.tsx +0 -11
  194. package/src/components/field-parts.tsx +5 -19
  195. package/src/components/field-strip.tsx +9 -25
  196. package/src/components/field-sync.tsx +0 -7
  197. package/src/components/field.tsx +4 -4
  198. package/src/components/full-bleed-dialog.tsx +4 -3
  199. package/src/components/hover-menu.tsx +12 -16
  200. package/src/components/inline-entity-combobox.tsx +1 -1
  201. package/src/components/modal.tsx +20 -4
  202. package/src/components/multi-select.tsx +13 -30
  203. package/src/components/number-input.tsx +3 -8
  204. package/src/components/popover.tsx +5 -3
  205. package/src/components/series-chart.tsx +1 -1
  206. package/src/components/server-wake.tsx +0 -6
  207. package/src/components/settings-fields.tsx +4 -2
  208. package/src/components/stat-tile.tsx +8 -2
  209. package/src/components/swipeable-row.tsx +15 -37
  210. package/src/components/tooltip.tsx +37 -6
  211. package/src/components/translation-review.tsx +25 -7
  212. package/src/components/use-table-state.ts +91 -10
  213. package/src/components/user-avatar.tsx +2 -2
  214. package/src/components/wizard-stepper.tsx +2 -6
  215. package/src/currencies.ts +70 -0
  216. package/src/demo/demo-banner.tsx +7 -2
  217. package/src/eslint/index.ts +161 -0
  218. package/src/eslint/role-utilities.generated.ts +146 -0
  219. package/src/eslint/role-utilities.ts +99 -0
  220. package/src/feedback/feedback-menu.tsx +2 -2
  221. package/src/feedback/feedback-thread.tsx +3 -8
  222. package/src/hooks/use-dismiss.ts +39 -4
  223. package/src/i18n/kit-labels.tsx +15 -5
  224. package/src/i18n/locales/fr.ts +3 -2
  225. package/src/i18n/locales/it.ts +3 -2
  226. package/src/index.ts +3 -1
  227. package/src/lib/refs.ts +22 -0
  228. package/src/rhf/fields.tsx +10 -10
  229. package/src/rhf/form-core.tsx +5 -4
  230. package/src/rhf/form.tsx +7 -43
  231. package/src/rhf/line-items.tsx +1 -1
  232. package/src/rhf/use-rhf-wizard-step.ts +4 -4
  233. package/src/rhf.ts +3 -2
  234. package/src/shell/option-switcher-menu.tsx +5 -22
  235. package/src/shell/role-switcher.tsx +2 -6
  236. package/src/shell/topbar-action-menu.tsx +7 -24
  237. package/src/shell/topbar-controls.tsx +6 -18
  238. package/src/testing/index.ts +3 -1
  239. package/src/testing/viewport.ts +125 -19
  240. package/src/theme/palette-presets.ts +7 -293
  241. package/src/wizard/types.ts +0 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/amount-input.tsx"],"sourcesContent":["import { useId, useMemo, useRef } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport type { ReactNode, Ref } from \"react\";\nimport { CurrencyOptionList, getCurrency } from \"./currency-option-list\";\nimport { useComboboxCore } from \"./combobox-core\";\nimport {\n FIELD_BASE,\n FIELD_DISPLAY,\n FIELD_INVALID,\n FLOATING_INPUT_CLASS,\n FloatingField,\n} from \"./field-base\";\nimport { cn } from \"../lib/cn\";\nimport { currencyMinorDigits } from \"../lib/format\";\nimport { roundHalfAway } from \"../lib/round\";\nimport { CalculatorButton, type CalculatorButtonLabels } from \"./calculator\";\nimport { NumberPadSheet, type NumberPadSheetLabels } from \"./numpad-sheet\";\nimport {\n DEFAULT_COMMON_LABELS,\n DEFAULT_CURRENCY_LABELS,\n useKitLabels,\n useKitLocale,\n type CurrencyLabels,\n} from \"../i18n/kit-labels\";\nimport {\n commitExpression,\n evaluateExpression,\n formatResult,\n isBareAmount,\n looksLikeExpression,\n sanitizeLive,\n splitLeadingSign,\n} from \"../lib/calc\";\nimport {\n FieldCaption,\n LockedReason,\n mergeRefs,\n type DisabledReasonDisplay,\n type LockReason,\n} from \"./field-parts\";\nimport { useEndWidth, useNumericField } from \"./numeric-field\";\nimport type { CommitScope } from \"./write-lock\";\n\n/** {@link AmountInput}'s props — exported since 0.34 (refactor audit 2026-10, API-9): a\n * wrapper typed itself off `ComponentProps<typeof AmountInput>` until then. */\nexport interface AmountInputProps {\n value: string;\n onChange: (value: string) => void;\n currency?: string;\n onCurrencyChange?: (code: string) => void;\n placeholder?: string;\n label?: ReactNode;\n disabled?: boolean;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /**\n * What is wrong with the amount, in the caller's own words — {@link Input}'s `error`\n * (keksdose K4: \"exceeds the outstanding balance\" was a loose `<p>` beside the field\n * that nothing pointed at). Rendered under the field, after a text `hint`; merged into\n * `aria-describedby` after the caller's ids and the hint's; implies `invalid`, so the\n * field paints as well as announces. `null`, `false` and `\"\"` are no message.\n * {@link MoneyField} takes it too.\n */\n error?: ReactNode;\n /**\n * Show the desktop calculator trigger (default `true`). `false` for an amount in an\n * ephemeral close-on-blur editor — a budget's assigned cell, a VAT cell (keksdose K6)\n * — where a click on the icon blurs the field and tears the editor down before the\n * popover can open. Typing a calculation (\"200+50\", then Enter) still evaluates, and\n * a phone keeps its numpad, exactly as {@link NumberInput}'s `calculator={false}`.\n */\n calculator?: boolean;\n /** The field's WRAPPER — width, a margin, a flex share. The `<input>` is\n * `inputClassName`'s. */\n className?: string;\n /**\n * Classes for the `<input>` itself — {@link NumberInput}'s and {@link Input}'s prop of\n * the same name, merged the same way: after everything the field sets for LOOKS — the\n * base classes, the plain end padding, the display shape's centring and the `tone`\n * colour — so it can restyle the figure (`text-end` for a money column whose decimal\n * points line up, `font-medium`, a tighter `py-1` or a symmetric `px-2` in a table\n * cell, `text-transparent` while a figure is being re-fetched), and before what the\n * field needs to WORK: the end padding the calculator and the currency chip reserve,\n * and the invalid border. Neither of those can be taken away by accident — a caller's\n * `px-2` keeps its start edge and the digits still stop short of the chip, and a\n * borderless cell's `border-transparent` still turns red when the value is wrong.\n *\n * keksdose G7: the invoice's VAT cell right-aligns its figure, and with only\n * `className` (the wrapper) it reached the element through `[&_input]:text-end` — a\n * descendant selector that depends on the field's inner markup, which the kit is free\n * to change, and that a reader of the call site has to decode. {@link MoneyField}\n * passes it through, and `RhfMoneyField` takes it too.\n *\n * keksdose 0.24: until then it sat BEFORE the plain end padding (`pe-3`) and the tone,\n * so the budget's assigned cell could not make its padding symmetric (`px-2` came out\n * `px-2 pe-3`) and the holdings price could not hide an outflow-toned figure while\n * re-fetching — both were back on `[&_input]:` selectors on the wrapper.\n */\n inputClassName?: string;\n id?: string;\n /** Names the field when it has no visible `label` (a table cell, the display shape). */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the field only when `aria-label` is absent. */\n ariaLabel?: string;\n /**\n * Set on the `<input>`, with `id` above. Declared so `Field`'s render-prop spread —\n * `{(ids) => <AmountInput {...ids} … />}` — is typed and reaches the input: the\n * hint and error are described, a required amount is announced as required, and\n * `aria-invalid` paints {@link FIELD_INVALID} the way `invalid` does.\n */\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean | \"true\" | \"false\";\n \"aria-required\"?: boolean | \"true\" | \"false\";\n /**\n * BCP 47 tag for this field — {@link NumberInput}'s `locale` (0.34, DUP-10): the decimal\n * mark the field SHOWS and reads typing in (\"1,5\" for fr-CH, \"1.5\" for de-CH, as `Intl`\n * decides), and the language of the currency picker's search. Default the\n * `<UiKitProvider locale>`, else the runtime's. `value` and `onChange` stay\n * dot-decimal.\n */\n locale?: string;\n /** {@link NumberInput}'s `hint`, the same rule: a {@link FieldHint} \"?\" rides the\n * label's own line, beside the label (not at the far end, where the calculator and\n * the currency chip live); plain TEXT (a string or a number) is a caption UNDER\n * the field, attached through `aria-describedby` after the caller's own. A phone's\n * `variant=\"display\"` has no visible label, so a FieldHint is dropped there; a\n * caption still shows.\n *\n * Since 0.34 a FieldHint is that caption at Large and on a touch screen, as on\n * NumberInput since 0.32 (`useInlineHint`, docs/text-size-harmonization.md §4: a fact\n * a finger cannot hover open is printed). A `HelpPopover` — help, not a fact (§10.23)\n * — stays on the label line at every size. */\n hint?: ReactNode;\n /** Every user-facing string this component and the two it composes own, so a\n * translating host can supply its own. Each key optional, and each a per-field\n * override of the kit-wide translation in `<UiKitProvider labels>`: `currency`\n * and `currencySearch` of its `currency` namespace, the rest of `calculator`.\n * `currency` names the picker chip, composed with the selected code through\n * `common.fieldValue`; the rest are pass-through. */\n labels?: {\n currency?: string;\n currencySearch?: string;\n /** Names the calculator TRIGGER this component renders. `calculator` below\n * names the controls inside the popover it opens. */\n calculatorTrigger?: string;\n pad?: NumberPadSheetLabels;\n calculator?: CalculatorButtonLabels;\n };\n /** Translated currency names for the chip's picker, keyed by ISO code. The same\n * sparse override `CurrencySelect` takes, and for the same reason: the names in\n * `CURRENCIES` are shipped data, so without this they are the one English word\n * left in a translated row. Not part of `labels` because it is keyed by DATA\n * rather than by a fixed set of slots, and an app passes the same map to both\n * pickers. */\n currencyNames?: Record<string, string>;\n /** Offer only these ISO codes in the chip's list, in this order — `CurrencySelect`'s\n * `options`, since the chip renders CurrencySelect's list (round 0.34 Wave 2, DUP-4).\n * Default every currency the kit knows. */\n currencyOptions?: string[];\n /** Focus the field on mount — on mobile this also opens the numpad sheet, so a\n * new-transaction form can jump straight to amount entry (feedback #70). */\n autoFocus?: boolean;\n /**\n * Tint the typed figure by what it will DO (Keksdose feedback #167).\n *\n * The direction is chosen with a toggle beside the field rather than typed, so\n * the digits alone say nothing about which way the money goes — on the one screen\n * where getting that backwards is the expensive mistake. Colour says it\n * continuously, and it costs no layout. It stays the MAIN indication (live #201\n * rework: *\"The main indication shall still be the color\"*); {@link negative}\n * renders the sign as a second, quieter signal in front of the figure.\n *\n * Never the ONLY signal: the toggle it mirrors is right there, labelled, so this\n * is reinforcement rather than the sole carrier of the meaning.\n */\n tone?: \"neutral\" | \"outflow\" | \"inflow\";\n /**\n * The SIGN of the figure, owned by the caller's direction control (Keksdose live\n * #201 rework: *\"Outflow should be negative and inflow positive … the sign shall\n * be displayed but not necessarily be typed in\"*).\n *\n * `value` stays the MAGNITUDE. The minus is glued on at render time and stripped\n * off again before anything is reported back, so the caller never sees its own\n * prefix echoed and no code path can end up applying it twice. That is the whole\n * cure: there is exactly ONE place the sign lives, and it is not the text.\n *\n * Because it is rendered rather than stored it cannot be deleted (the next render\n * puts it back), a select-all-and-retype keeps the direction, and the caret needs\n * no minding.\n *\n * Since 0.15.5 it is drawn on its own too, for a read-only or disabled signed figure\n * (an \"Items total\" of −5.18): no `onNegativeChange` needed just to show the minus.\n */\n negative?: boolean;\n /**\n * A sign the user TYPED, or a calculation that resolved to a signed number.\n *\n * SET, never flip. A \"-\" means *\"this is an outflow\"*, so typing it twice says the\n * same thing twice — which is exactly what the rework asks for (*\"Subtracting\n * values twice resulting in inflow -> outflow and back to inflow seems not\n * reasonable\"*). \"+\" says the other direction.\n *\n * Its presence is what ARMS the whole sign behaviour. A field with no direction\n * control — an account's starting balance, a loan payment, a holding's cost —\n * passes neither prop and keeps a text that is the whole truth, minus included.\n */\n onNegativeChange?: (negative: boolean) => void;\n /**\n * How the field presents itself ON A PHONE (Keksdose feedback #176).\n *\n * `\"field\"` (default) is the labelled, bordered input used everywhere else.\n *\n * `\"display\"` keeps every mechanic — the same `<input>`, the same numpad sheet,\n * the same currency picker, the same commit/blur contract — and only drops the\n * chrome: no border, no fill, no floating label, the figure set at display size.\n * On a form whose whole point is one number, a bordered `text-sm` box draws the\n * amount at the same weight as the memo beside it; this makes it the headline\n * instead. It stays fully editable — the underline and the caret are what say so.\n *\n * Phone-only by construction: it keys off the same breakpoint as the numpad, so\n * from `md` up the field is byte-for-byte the normal one and a desktop grid keeps\n * its column rhythm.\n */\n variant?: \"field\" | \"display\";\n /**\n * Where the figure sits in its row, for `variant=\"display\"` only (Keksdose\n * feedback #176 rework).\n *\n * `\"start\"` (default) keeps it flush left, in the reading column the fields\n * below it share — and it is what the entry forms use, because a figure that\n * starts at a known edge is legible at any width: when the value outgrows the\n * field, the digits that scroll out of sight are the trailing ones, not the\n * magnitude (Keksdose feedback #430 rework).\n *\n * `\"center\"` makes it a centred headline. It centres in the width that REMAINS\n * after the trailing currency control, not in the whole box: the control is\n * pinned to the right edge, so a plain `text-center` would centre the figure\n * under it and the last digits would sit behind the chip. This used to mirror\n * the control's reservation onto the left instead, which centred correctly but\n * spent twice the control's width on padding — fatal on a 375px screen, where\n * it left a 36px figure 16px to live in.\n */\n align?: \"start\" | \"center\";\n /**\n * Decimals the committed amount is rounded to (kastlan 0.12: \"12.345\" and a\n * calculator's \"100/3\" reached a `Numeric(10,2)` column unrounded and failed with a\n * 422). Default: the currency's minor unit, from `Intl` (CHF and EUR 2, JPY 0). With\n * no `currency`, nothing is rounded unless this is set. Rounding is half away from\n * zero (12.345 → 12.35, -12.345 → -12.35) and happens when the figure settles: on\n * blur, on Enter, and on every result the calculator writes back. Keystrokes are left\n * alone, so \"12.3\" can still become \"12.34\".\n *\n * ⚠️ **A unit price or a rate needs `digits`.** The default is right for an amount of\n * money and silently wrong for a price per unit: a fund's NAV of 123.4567 or fuel at\n * 1.789 €/l is stored as 123.46 / 1.79, and no test fails (keksdose G2, a\n * `Numeric(18,6)` holding price and a `Numeric(18,4)` unit price). Pass the column's\n * scale: `digits={4}`, `digits={6}`.\n *\n * **Set `digits` for any sub-currency scale** — not only a price: any field whose\n * column holds more decimals than the currency's minor unit. A split line stored at\n * the ledger's 4dp (`Numeric(18,4)`) and loaded as 12.3456 is SHOWN as 12.35, and\n * committed as 12.35 as soon as the user tabs through it (blur settles) — so the form\n * no longer equals what the server holds: the lines stop summing to the 4dp total,\n * and Save is held (keksdose live #240). With a `currency`, every commit rounds to that currency's\n * minor unit unless `digits` says otherwise: pass the column's scale (`digits={4}`).\n */\n digits?: number;\n /** The smallest amount the field settles on. A lower figure is raised to it when it\n * settles, like `digits`. Compared with the signed figure. */\n min?: number;\n /** The largest amount the field settles on (a deposit release capped at the\n * balance). A higher figure is lowered to it when it settles. */\n max?: number;\n /**\n * The SETTLED figure, dot-decimal, sign included — fired on blur, on Enter, on the\n * numpad's \"=\" and on every result the calculator writes back, never on a keystroke\n * (\"1200+\" is not a figure yet). `onChange` still reports every keystroke; this is\n * for a host that stores a number and must not see drafts (kastlan 52; see\n * {@link MoneyField}, which is built on it).\n */\n onCommit?: (value: string) => void;\n /**\n * Why the amount cannot be changed — {@link NumberInput}'s `disabledReason` (0.34,\n * round 0.34 C2), for an amount that SAVES itself: a budget row's assigned cell, a\n * price committed on blur. `disabled` takes the field out of the tab order, so the\n * reason never reached a keyboard.\n *\n * With a reason the field stays in the tab order and shows its figure, `readOnly` (the\n * settled grey FIELD_BASE gives a `[readonly]` field) and `aria-disabled`. Nothing\n * changes the amount: the calculator and the phone's numpad are not offered, the\n * currency chip is a read-out rather than a picker, and neither blur nor Enter\n * settles — so `onChange`, `onCommit`, `onNegativeChange` and `onCurrencyChange` are\n * never called. Enter is swallowed, so the field does not submit the form around it.\n * The reason is a line under the field at Large and on a touch screen, else in the kit\n * {@link Tooltip} (`disabledReasonDisplay`), and on the input's `aria-describedby`,\n * between the caption and the error. Wins over `disabled`. {@link MoneyField} and\n * `RhfMoneyField` take it too.\n */\n disabledReason?: ReactNode;\n /**\n * Where the reason shows — {@link Button}'s `disabledReasonDisplay`: by default a line\n * under the field at Large and on a touch screen, the tooltip otherwise (§4 \"No fact\n * only in a tooltip\"; DUP-3, refactor audit 2026-10).\n */\n disabledReasonDisplay?: DisabledReasonDisplay;\n /**\n * This amount COMMITS — {@link Button}'s `commit`, NumberInput's: under a locked\n * {@link WriteLockProvider} it is locked the `disabledReason` way with the lock's reason\n * (which wins over its own). An amount that only reaches the server through its form's\n * Save leaves this off and stays editable under the lock; the Save takes `commit`. No\n * provider, or an unlocked one: no effect.\n */\n commit?: CommitScope;\n /** The `<input>`. A React 19 ref prop since 0.34 (MOD-4, refactor audit 2026-10); it\n * was `forwardRef`. */\n ref?: Ref<HTMLInputElement>;\n}\n\n\n/**\n * A settled figure, rounded to `digits` (half away from zero) and clamped to\n * `min`/`max`. Only a plain number is touched. A half-typed draft or an expression\n * comes back as it was. Rounding is `lib/round.ts`'s, shared with `roundToCurrency`\n * (BUG-11: this copy blanked \"0.0000001\" and a 22-digit figure on blur).\n */\nfunction settleAmount(text: string, digits: number | undefined, min?: number, max?: number): string {\n const t = text.trim();\n if (!/^-?\\d*\\.?\\d*$/.test(t) || !/\\d/.test(t)) return text;\n let n = Number(t);\n if (!Number.isFinite(n)) return text;\n if (digits !== undefined) n = roundHalfAway(n, digits);\n if (min !== undefined && n < min) n = min;\n if (max !== undefined && n > max) n = max;\n const out = formatResult(n);\n // Unchanged figures keep their own spelling (\"12.50\" stays \"12.50\").\n return Number(out) === Number(t) ? text : out;\n}\n\n// The locale's decimal mark and the grouping parse (kastlan 40, keksdose G1) live in\n// `lib/decimal-marks.ts`, read through the engine NumberInput and this field share\n// (`numeric-field.ts`, DUP-10).\n\n// The consuming app's ONE money palette (`--money-expense` / `--money-income`),\n// not a bespoke rose/emerald pairing: a figure being typed has to wear the same\n// colour the same figure will wear once it is a row in the table behind the form\n// (Keksdose dev#434). The utilities are unlayered and theme-aware, so no `dark:`\n// variant is needed and they win over the field's own text colour regardless of\n// where `cn` puts them.\nconst TONE_CLASS: Record<\"neutral\" | \"outflow\" | \"inflow\", string> = {\n neutral: \"\",\n outflow: \"text-money-neg\",\n inflow: \"text-money-pos\",\n};\n\n// The shared chrome-less treatment at money size. `tabular-nums` so digits don't\n// reflow the figure as they are typed; FIELD_DISPLAY's own muted placeholder\n// colour is what keeps an EMPTY form from painting its zero in the direction tint\n// (`tone` is computed from 0, which reads as an inflow).\nconst DISPLAY_INPUT_CLASS = cn(\n FIELD_DISPLAY,\n \"text-4xl font-semibold leading-tight tracking-tight tabular-nums\",\n);\n\n/**\n * Is `text` the ANSWER to `previous`, or something typed OVER it?\n *\n * \"The old text was a sum and the new one is bare\" cannot tell those apart, and both\n * gestures are ordinary: select-all-and-retype after a typo, or backspacing \"-20+\"\n * back down to a fresh figure. Read as an answer, they move the direction chip — so\n * an outflow of 7 quietly booked +7.00 (live #201 rework).\n *\n * The question that does separate them is arithmetic, not shape: evaluate what the\n * text replaced and see whether this IS that number. \"-12+30\" → \"18\" still is, so a\n * sum that comes out positive still takes the chip with it; \"-20+50\" → \"7\" is not,\n * and \"-20+\" evaluates to nothing at all.\n */\nfunction isResultOf(previous: string, text: string, settle: (text: string) => string): boolean {\n const n = evaluateExpression(previous);\n // Compared settled, since the field rounds what the calculator hands it.\n return n !== null && settle(formatResult(n)) === text.trim();\n}\n\nexport function AmountInput(props: AmountInputProps) {\n const { ref, value, onChange, currency, onCurrencyChange, placeholder, label, className, inputClassName, id, \"aria-label\": ariaLabelAttr, ariaLabel: ariaLabelProp, \"aria-required\": ariaRequired, autoFocus, tone = \"neutral\", negative = false, onNegativeChange, align = \"start\", labels, currencyNames, currencyOptions, digits: digitsProp, min, max, onCommit, disabledReasonDisplay } = props;\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n // The sign is DISPLAYED, not stored (live #201 rework). `value` is the\n // magnitude; the minus is glued on here and taken off again in handleText, so\n // the two can never disagree and the caller can never double-apply it. Only in\n // front of a bare amount: an expression being typed (\"12-30\") owns its own\n // minus and has to survive keystroke-for-keystroke.\n const signOwned = onNegativeChange !== undefined;\n // The sign is DRAWN whenever `negative` says so, handler or not (keksdose live #366):\n // a read-only or disabled total (\"−5.18\") used to need a dummy `onNegativeChange`\n // just to show its minus. Without the handler there is nothing to toggle — a typed\n // minus simply stays in the text, as in any field without a direction control.\n const shown = negative && isBareAmount(value) ? `-${value}` : value;\n // What the user SEES is `shown` with the locale's decimal mark (kastlan 40: a\n // fr-CH user typed \"1,5\" and watched it turn into \"1.5\" under their fingers). Display only — `value`, `onChange`, the sign split and the settle all\n // stay dot-decimal, because that string is the contract: RhfMoneyField's\n // `parseAmount`, every app's `Number(value)` and the calculator's evaluator read\n // it. The way back is free: {@link sanitizeLive} already folds a typed \",\" into\n // \".\", so a comma typed, pasted or tapped on the numpad lands as a dot.\n //\n // One character for one character, and no digit grouping: the caret stays where\n // the typist put it, and \"1.000\" cannot be read back as a thousand in one locale\n // and as one in the other. de-CH and it-CH are \".\" — CLDR says so, and this\n // follows `Intl` rather than a guess about a country. The field's own `locale`,\n // else the provider's (0.34, DUP-10).\n const locale = useKitLocale(props.locale);\n // Decimals the figure settles to: `digits`, else the currency's minor unit.\n const digits = digitsProp ?? currencyMinorDigits(currency);\n const settle = (text: string) => settleAmount(text, digits, min, max);\n // The engine NumberInput shares (DUP-10): the lock (focusable, `readOnly`, nothing\n // changes or settles — see `disabledReason`), the hint — a FieldHint is its words at\n // Large and on touch, §4 — the error, the description's order, the typist's draft\n // in the locale's mark, the calculator and the numpad. On a phone the OS keyboard\n // is suppressed for the numpad sheet (feedback #334), and the display shape keys off\n // the SAME phone layout, so the two can never drift apart on the breakpoint.\n //\n // A value the HOST set (not one typed here) is shown at the currency's minor unit\n // while the field is not being edited: an FX estimate of 93.4213 showed four\n // decimals (keksdose live #356). Display only — `value` is the host's, untouched.\n const numeric = useNumericField(props, {\n settle,\n display: (focused) => (focused ? shown : settleAmount(shown, digits)),\n });\n const { lock, locked, off, isMobile, asDisplay, showCalc, showNumpad, setFocused, mark, draft, setDraft, derived } =\n numeric;\n const invalid = numeric.isInvalid;\n // A locked chip is a read-out: picking a currency is a change too.\n const editable = !!onCurrencyChange && !locked;\n // Room for the trailing controls — the calculator and the currency chip — once\n // measured, as NumberInput reserves its own (keksdose live #367, DUP-10): their\n // width, the track's `end-1` inset in the boxed shape, and NumberInput's 4px gap.\n // Before that (the first paint, and wherever there is no layout) the classes below\n // stand in. showCalc is always false on a phone, so the display shape only has to\n // clear the chip, by its own width rather than the boxed shape's room (feedback #430\n // rework: on a 375px screen 16px decide between a readable figure and a clipped one).\n const hasEnd = showCalc || Boolean(currency);\n const [endRef, endWidth] = useEndWidth(hasEnd);\n const trailingRoom = asDisplay\n ? currency ? (editable ? \"pe-16\" : \"pe-12\") : undefined\n : showCalc\n ? currency ? (editable ? \"pe-24\" : \"pe-16\") : \"pe-10\"\n : currency ? (editable ? \"pe-20\" : \"pe-14\") : undefined;\n const innerRef = useRef<HTMLInputElement>(null);\n const setRefs = useMemo(() => mergeRefs(innerRef, ref), [ref]);\n // While the typist is typing, the field shows THEIR text (\"1.234,5\" stays exactly\n // that), not the value re-spelt: re-spelling turned a grouping \".\" into a \",\" under\n // their fingers, after which no rule could tell the two apart (keksdose G1). The\n // draft only while it says what the field holds AND holds nothing the live\n // sanitising would drop — a letter, a second decimal point (see `showsTyped`); a\n // value set from outside, a calculator result or a commit shows the derived spelling.\n const display =\n draft === null\n ? derived\n : (numeric.typedFor(shown) ??\n // The caller owns the sign: the typed \"12\" is shown as the \"-12\" it is.\n (signOwned && negative && shown.startsWith(\"-\") && numeric.typedFor(shown.slice(1)) !== null\n ? `-${draft}`\n : derived));\n // Every route into the field — typing, the numpad sheet, the desktop\n // calculator, the blur/Enter commit — funnels through here, so the split is\n // written once and the four entry paths cannot drift.\n //\n // `previous` is the text this one REPLACES, and it is what says whether a bare\n // figure arriving here is an answer or a magnitude. For the three paths that\n // edit the field's own text that is simply what the field was showing; the\n // desktop calculator keeps its expression in a popover the field never sees,\n // so it passes it in (see `CalculatorButton`'s `onChange`).\n const handleText = (raw: string, previous: string = shown) => {\n const text = sanitizeLive(raw);\n if (!signOwned) {\n onChange(text);\n return;\n }\n const { sign, rest } = splitLeadingSign(text);\n if (sign) {\n // SET, not flip: re-reporting the same sign on every keystroke is a no-op.\n onNegativeChange(sign === \"-\");\n } else if (looksLikeExpression(previous) && isBareAmount(text) && isResultOf(previous, text, settle)) {\n // A calculation that just RESOLVED states its sign in both directions. The\n // figure it ran on is the SIGNED one the user could see — \"-12+30\" is +18 —\n // so a positive result has to move the chip too, or the field would answer\n // that sum with \"-18\" and contradict the arithmetic it just showed.\n //\n // Only when it really resolved, though: see {@link isResultOf}. A bare figure\n // arriving on top of an expression is far more often a replacement than an\n // answer, and reading it as an answer flips the direction of money.\n onNegativeChange(false);\n }\n onChange(sign ? rest : text);\n };\n const commit = () => {\n setDraft(null);\n const settled = settle(commitExpression(shown));\n handleText(settled);\n onCommit?.(settled);\n };\n const typed = (raw: string) => handleText(numeric.read(raw));\n // The currency list is CurrencySelect's (round 0.34 Wave 2, DUP-4) on the picker\n // family's core: the chip was a hand copy of it and had drifted (no wrap at Large, no\n // `options` subset, no check mark, no listbox id, no #308 width), and both were plain\n // buttons under a listbox promise. `filter: false`: the list filters its own rows.\n const core = useComboboxCore<string>({ filter: false, backCloses: true });\n // `chipRef`: the chip the currency list hangs off (Keksdose dev#548: portalled, so the\n // panel needs a real trigger rect rather than a relative parent). It is also where\n // Escape and a pick hand focus back (round 0.34 BUG-1): Safari does not focus a\n // clicked button, so \"whatever held focus\" is not the chip.\n const { open, setOpen, closeToTrigger, triggerRef: chipRef } = core;\n const listboxId = `${generatedId}-currencies`;\n // A lock arriving while the list is up closes it, as on CountrySelect — adjusted\n // while rendering, so no frame shows a list that can no longer be used.\n if (!editable && open) setOpen(false);\n\n // The currency chip's strings are the `currency` namespace — the same two\n // `CurrencySelect` resolves, under this component's older key names. The\n // calculator and the numpad resolve `calculator` themselves; `labels.calculator`\n // and `labels.pad` are handed straight through to them as overrides.\n // The two strings read out first, so the memo depends on them and not on the\n // caller's `labels` object (a new one every render) — what the React Compiler infers.\n const currencyLabel = labels?.currency;\n const currencySearchLabel = labels?.currencySearch;\n const currencyOverrides = useMemo(() => {\n const out: Partial<CurrencyLabels> = {};\n if (currencyLabel !== undefined) out.currency = currencyLabel;\n if (currencySearchLabel !== undefined) out.search = currencySearchLabel;\n return out;\n }, [currencyLabel, currencySearchLabel]);\n const currencyText = useKitLabels(\"currency\", DEFAULT_CURRENCY_LABELS, currencyOverrides);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n\n const selected = getCurrency(currency);\n\n return (\n <div className={cn(\"w-full\", className)}>\n {/* Inner relative box holds the input + its absolutely-positioned\n trailing controls (calculator / currency), so those stay anchored to\n the INPUT even when the mobile math bar is rendered below (#334). It is\n the kit's FloatingField, which draws the label — floating, or sr-only in\n the display shape — and puts a FieldHint on the label's line, as it does\n for NumberInput. */}\n {/* Locked, the field sits in the reason's frame (LockedReason: the line, or the\n Tooltip), as NumberInput does; the root above keeps `className`, so nothing\n reflows. */}\n <LockedOrNot lock={lock} display={disabledReasonDisplay}>\n <FloatingField\n className=\"w-full\"\n htmlFor={fieldId}\n label={label}\n srOnlyLabel={asDisplay}\n hint={numeric.hint.labelHint}\n >\n <input\n ref={setRefs}\n id={fieldId}\n // The DOM spelling wins; `ariaLabel` is the fallback for call sites not moved yet.\n aria-label={ariaLabelAttr ?? ariaLabelProp}\n type=\"text\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- opt-in per call site (feedback #70)\n autoFocus={autoFocus}\n // On mobile suppress the OS keyboard so our numpad sheet owns entry; the\n // field keeps focus/caret. Desktop keeps the native decimal keypad.\n inputMode={isMobile ? \"none\" : \"decimal\"}\n autoComplete=\"off\"\n disabled={off}\n // Locked: focusable, `readOnly`, `aria-disabled` — see `disabledReason`.\n readOnly={locked || undefined}\n aria-disabled={locked || undefined}\n // The floating-label pattern needs a blank placeholder for its\n // peer-placeholder-shown trick. The display shape has no floating label,\n // so it spends the placeholder on what an empty borderless form actually\n // needs: a zero to aim at, at full size. The caller supplies it because\n // only the app knows the locale's decimal separator.\n placeholder={asDisplay ? (placeholder ?? \"0\") : label !== undefined ? \" \" : placeholder}\n value={display}\n onChange={(e) => {\n if (!locked) typed(e.target.value);\n }}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n // Nothing settles under the lock — not even a draft typed before it arrived,\n // which stays in the field for when it lifts.\n if (!locked) commit();\n setFocused(false);\n }}\n onKeyDown={(e) => {\n if (e.key !== \"Enter\") return;\n // Locked: Enter submits no form and settles nothing.\n if (locked) e.preventDefault();\n else commit();\n }}\n className={cn(\n // With a label, use the floating-input padding (pt-4 pb-1) like every\n // other labelled field so the value sits BELOW the floated label rather\n // than vertically centred where it overlaps the resting label\n // (feedback #314). FLOATING_INPUT_CLASS already bundles the peer +\n // transparent-placeholder bits.\n asDisplay ? DISPLAY_INPUT_CLASS : label !== undefined ? FLOATING_INPUT_CLASS : FIELD_BASE,\n // The plain end padding, with nothing trailing: cosmetic, so the caller's\n // to change (keksdose 0.24 — a symmetric `px-2` in a budget cell).\n !trailingRoom && (asDisplay ? \"pe-0\" : \"pe-3\"),\n // Centred display shape: centre in what is LEFT of the currency chip.\n // `text-center` alone would centre the figure in the whole box, i.e.\n // partly underneath the chip; the padding below is what takes the chip\n // out of the centring, and nothing is added at the start because a\n // mirrored reservation would spend the width twice (see `align`).\n asDisplay && align === \"center\" && \"text-center\",\n // Over the base class's own text colour.\n TONE_CLASS[tone],\n // The caller's, over all of the above — base, plain padding, alignment and\n // tone — and under only what the field needs to work (see `inputClassName`).\n inputClassName,\n // Room for the trailing controls, after the caller's so a `px-2` cannot run\n // the digits under the chip (NumberInput's order, which reserves its unit\n // and calculator the same way).\n trailingRoom,\n invalid && FIELD_INVALID,\n locked && \"cursor-not-allowed\",\n )}\n // The classes above are the fallback; once measured the field reserves exactly\n // its trailing controls' width, inline so it wins over every class (see\n // `trailingRoom`).\n style={hasEnd && endWidth != null ? { paddingInlineEnd: endWidth + (asDisplay ? 4 : 8) } : undefined}\n aria-invalid={invalid || undefined}\n aria-describedby={numeric.describedBy}\n aria-required={ariaRequired}\n />\n {/* The label is FloatingField's, after these children (the floating trick\n reads the input through `peer-*`). The display shape drops it VISUALLY,\n not from the accessibility tree: a 36px tinted figure at the top of a\n transaction form is legibly the amount, but a screen reader still needs\n the name, and callers that pass `label` without `aria-label` would\n otherwise be left with none. */}\n {/* Trailing controls share one flex track so the calculator icon and the\n currency suffix/picker sit side by side without overlapping. */}\n {/* The display shape has no box to inset from, so the controls align to the\n figure's own end edge and its baseline strip (`bottom-1`, matching the\n input's pb-1) instead of floating inside a field. */}\n <div\n // Measured for the input's end padding (see `trailingRoom`).\n ref={endRef}\n className={cn(\n \"absolute flex items-center gap-0.5\",\n // Logical `end-*`: the chip and the calculator are the figure's trailing\n // controls, so a right-to-left form carries them on the left.\n asDisplay ? \"bottom-1 end-0\" : \"inset-y-1 end-1\",\n )}\n >\n {showCalc && (\n <CalculatorButton\n // The mark the field shows but not the typist's grouping: the evaluator\n // reads either mark, and \"1.234,5\" is two of them. The result comes back\n // dot-decimal.\n value={derived}\n onChange={(result, expression) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled, expression);\n onCommit?.(settled);\n }}\n className=\"px-1.5\"\n aria-label={labels?.calculatorTrigger}\n labels={labels?.calculator}\n />\n )}\n {currency && !editable && (\n <span\n aria-hidden\n className={cn(\n \"pointer-events-none px-1 font-medium text-muted\",\n // A text-xs chip next to a 36px figure reads as a stray footnote.\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n </span>\n )}\n {currency && editable && (\n <button\n ref={chipRef}\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n // A button that opens a listbox, and says so: the chip is a control inside\n // a text field, not a field of its own, so not a combobox.\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={listboxId}\n aria-label={\n // \"Currency: EUR\" through `common.fieldValue`, not a template literal:\n // the colon-and-space is punctuation a translation has to own.\n selected ? common.fieldValue(currencyText.currency, selected.code) : currencyText.currency\n }\n className={cn(\n \"flex items-center gap-1 rounded px-2 py-1 font-medium text-secondary hover:bg-hover\",\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n <ChevronDown className=\"size-3\" />\n </button>\n )}\n </div>\n {editable && (\n <CurrencyOptionList\n core={core}\n listboxId={listboxId}\n value={currency}\n codes={currencyOptions}\n currencyNames={currencyNames}\n locale={locale}\n searchPlaceholder={currencyText.search}\n // The phone sheet's title: what the chip is for.\n sheetTitle={currencyText.currency}\n onChoose={(code) => {\n onCurrencyChange?.(code);\n closeToTrigger();\n }}\n />\n )}\n </FloatingField>\n </LockedOrNot>\n {/* Outside the relative box, as NumberInput's caption is: the trailing\n controls are `inset-y-1` in it and would stretch down over a second line. */}\n <FieldCaption parts={numeric.hint} />\n {/* The news after the standing advice, as Select orders them. The root is\n already a steady box, so the message coming and going remounts nothing. */}\n {numeric.errorEl}\n {showNumpad && (\n <NumberPadSheet\n // Localised like the field it mirrors. Keys are typing, read by the\n // locale's marks like the keyboard's; \"=\" is a result, dot-decimal.\n value={display}\n onChange={typed}\n onResult={(result) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled);\n onCommit?.(settled);\n }}\n onDone={() => innerRef.current?.blur()}\n label={label}\n labels={labels?.pad}\n decimalMark={mark}\n />\n )}\n </div>\n );\n}\n\n/** The field in its lock's {@link LockedReason} while locked, as it is otherwise. A\n * component rather than a ternary so the field's JSX is written once. `block w-full`:\n * the frame's box stands where the field's own did. */\nfunction LockedOrNot({\n lock,\n display,\n children,\n}: {\n lock: LockReason;\n display: DisabledReasonDisplay | undefined;\n children: ReactNode;\n}) {\n if (!lock.locked) return <>{children}</>;\n return (\n <LockedReason lock={lock} display={display} className=\"block w-full\">\n {children}\n </LockedReason>\n );\n}\n"],"mappings":";AA2iBM,SAiNqB,UAjNrB,KA8HI,YA9HJ;AA3iBN,SAAS,OAAO,SAAS,cAAc;AACvC,SAAS,mBAAmB;AAE5B,SAAS,oBAAoB,mBAAmB;AAChD,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AACnB,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,wBAAqD;AAC9D,SAAS,sBAAiD;AAC1D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,aAAa,uBAAuB;AA8R7C,SAAS,aAAa,MAAc,QAA4B,KAAc,KAAsB;AAClG,QAAM,IAAI,KAAK,KAAK;AACpB,MAAI,CAAC,gBAAgB,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,EAAG,QAAO;AACtD,MAAI,IAAI,OAAO,CAAC;AAChB,MAAI,CAAC,OAAO,SAAS,CAAC,EAAG,QAAO;AAChC,MAAI,WAAW,OAAW,KAAI,cAAc,GAAG,MAAM;AACrD,MAAI,QAAQ,UAAa,IAAI,IAAK,KAAI;AACtC,MAAI,QAAQ,UAAa,IAAI,IAAK,KAAI;AACtC,QAAM,MAAM,aAAa,CAAC;AAE1B,SAAO,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,OAAO;AAC5C;AAYA,MAAM,aAA+D;AAAA,EACnE,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;AAMA,MAAM,sBAAsB;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;AAAA,oBAEpF,WAAW;AAAA,sBACT;AAAA,sBACA,YAAY,YAAY;AAAA,oBAC1B;AAAA,oBAEC;AAAA;AAAA,sBACD,oBAAC,eAAY,WAAU,UAAS;AAAA;AAAA;AAAA,gBAClC;AAAA;AAAA;AAAA,UAEJ;AAAA,UACC,YACC;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA;AAAA,cACA,OAAO;AAAA,cACP,OAAO;AAAA,cACP;AAAA,cACA;AAAA,cACA,mBAAmB,aAAa;AAAA,cAEhC,YAAY,aAAa;AAAA,cACzB,UAAU,CAAC,SAAS;AAClB,mCAAmB,IAAI;AACvB,+BAAe;AAAA,cACjB;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IAEF,GACA;AAAA,IAGA,oBAAC,gBAAa,OAAO,QAAQ,MAAM;AAAA,IAGlC,QAAQ;AAAA,IACR,cACC;AAAA,MAAC;AAAA;AAAA,QAGC,OAAO;AAAA,QACP,UAAU;AAAA,QACV,UAAU,CAAC,WAAW;AACpB,mBAAS,IAAI;AACb,gBAAM,UAAU,OAAO,MAAM;AAC7B,qBAAW,OAAO;AAClB,qBAAW,OAAO;AAAA,QACpB;AAAA,QACA,QAAQ,MAAM,SAAS,SAAS,KAAK;AAAA,QACrC;AAAA,QACA,QAAQ,QAAQ;AAAA,QAChB,aAAa;AAAA;AAAA,IACf;AAAA,KAEJ;AAEJ;AAKA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,MAAI,CAAC,KAAK,OAAQ,QAAO,gCAAG,UAAS;AACrC,SACE,oBAAC,gBAAa,MAAY,SAAkB,WAAU,gBACnD,UACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/amount-input.tsx"],"sourcesContent":["import { useId, useMemo, useRef } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport type { ReactNode, Ref } from \"react\";\nimport { CurrencyOptionList, getCurrency } from \"./currency-option-list\";\nimport { useComboboxCore } from \"./combobox-core\";\nimport {\n FIELD_BASE,\n FIELD_DISPLAY,\n FIELD_INVALID,\n FLOATING_INPUT_CLASS,\n FloatingField,\n} from \"./field-base\";\nimport { cn } from \"../lib/cn\";\nimport { currencyMinorDigits } from \"../lib/format\";\nimport { roundHalfAway } from \"../lib/round\";\nimport { CalculatorButton, type CalculatorButtonLabels } from \"./calculator\";\nimport { NumberPadSheet, type NumberPadSheetLabels } from \"./numpad-sheet\";\nimport {\n DEFAULT_COMMON_LABELS,\n DEFAULT_CURRENCY_LABELS,\n useKitLabels,\n useKitLocale,\n type CurrencyLabels,\n} from \"../i18n/kit-labels\";\nimport {\n commitExpression,\n evaluateExpression,\n formatResult,\n isBareAmount,\n looksLikeExpression,\n sanitizeLive,\n splitLeadingSign,\n} from \"../lib/calc\";\nimport {\n FieldCaption,\n LockedReason,\n mergeRefs,\n type DisabledReasonDisplay,\n type LockReason,\n} from \"./field-parts\";\nimport { useEndWidth, useNumericField } from \"./numeric-field\";\nimport type { CommitScope } from \"./write-lock\";\n\n/** {@link AmountInput}'s props — exported since 0.34 (refactor audit 2026-10, API-9): a\n * wrapper typed itself off `ComponentProps<typeof AmountInput>` until then. */\nexport interface AmountInputProps {\n value: string;\n onChange: (value: string) => void;\n currency?: string;\n onCurrencyChange?: (code: string) => void;\n placeholder?: string;\n label?: ReactNode;\n disabled?: boolean;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /**\n * What is wrong with the amount, in the caller's own words — {@link Input}'s `error`\n * (keksdose K4: \"exceeds the outstanding balance\" was a loose `<p>` beside the field\n * that nothing pointed at). Rendered under the field, after a text `hint`; merged into\n * `aria-describedby` after the caller's ids and the hint's; implies `invalid`, so the\n * field paints as well as announces. `null`, `false` and `\"\"` are no message.\n * {@link MoneyField} takes it too.\n */\n error?: ReactNode;\n /**\n * Show the desktop calculator trigger (default `true`). `false` for an amount in an\n * ephemeral close-on-blur editor — a budget's assigned cell, a VAT cell (keksdose K6)\n * — where a click on the icon blurs the field and tears the editor down before the\n * popover can open. Typing a calculation (\"200+50\", then Enter) still evaluates, and\n * a phone keeps its numpad, exactly as {@link NumberInput}'s `calculator={false}`.\n */\n calculator?: boolean;\n /** The field's WRAPPER — width, a margin, a flex share. The `<input>` is\n * `inputClassName`'s. */\n className?: string;\n /**\n * Classes for the `<input>` itself — {@link NumberInput}'s and {@link Input}'s prop of\n * the same name, merged the same way: after everything the field sets for LOOKS — the\n * base classes, the plain end padding, the display shape's centring and the `tone`\n * colour — so it can restyle the figure (`text-end` for a money column whose decimal\n * points line up, `font-medium`, a tighter `py-1` or a symmetric `px-2` in a table\n * cell, `text-transparent` while a figure is being re-fetched), and before what the\n * field needs to WORK: the end padding the calculator and the currency chip reserve,\n * and the invalid border. Neither of those can be taken away by accident — a caller's\n * `px-2` keeps its start edge and the digits still stop short of the chip, and a\n * borderless cell's `border-transparent` still turns red when the value is wrong.\n *\n * keksdose G7: the invoice's VAT cell right-aligns its figure, and with only\n * `className` (the wrapper) it reached the element through `[&_input]:text-end` — a\n * descendant selector that depends on the field's inner markup, which the kit is free\n * to change, and that a reader of the call site has to decode. {@link MoneyField}\n * passes it through, and `RhfMoneyField` takes it too.\n *\n * keksdose 0.24: until then it sat BEFORE the plain end padding (`pe-3`) and the tone,\n * so the budget's assigned cell could not make its padding symmetric (`px-2` came out\n * `px-2 pe-3`) and the holdings price could not hide an outflow-toned figure while\n * re-fetching — both were back on `[&_input]:` selectors on the wrapper.\n */\n inputClassName?: string;\n id?: string;\n /** Names the field when it has no visible `label` (a table cell, the display shape). */\n \"aria-label\"?: string;\n /**\n * Set on the `<input>`, with `id` above. Declared so `Field`'s render-prop spread —\n * `{(ids) => <AmountInput {...ids} … />}` — is typed and reaches the input: the\n * hint and error are described, a required amount is announced as required, and\n * `aria-invalid` paints {@link FIELD_INVALID} the way `invalid` does.\n */\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean | \"true\" | \"false\";\n \"aria-required\"?: boolean | \"true\" | \"false\";\n /**\n * BCP 47 tag for this field — {@link NumberInput}'s `locale` (0.34, DUP-10): the decimal\n * mark the field SHOWS and reads typing in (\"1,5\" for fr-CH, \"1.5\" for de-CH, as `Intl`\n * decides), and the language of the currency picker's search. Default the\n * `<UiKitProvider locale>`, else the runtime's. `value` and `onChange` stay\n * dot-decimal.\n */\n locale?: string;\n /** {@link NumberInput}'s `hint`, the same rule: a {@link FieldHint} \"?\" rides the\n * label's own line, beside the label (not at the far end, where the calculator and\n * the currency chip live); plain TEXT (a string or a number) is a caption UNDER\n * the field, attached through `aria-describedby` after the caller's own. A phone's\n * `variant=\"display\"` has no visible label, so a FieldHint is dropped there; a\n * caption still shows.\n *\n * Since 0.34 a FieldHint is that caption at Large and on a touch screen, as on\n * NumberInput since 0.32 (`useInlineHint`, docs/text-size-harmonization.md §4: a fact\n * a finger cannot hover open is printed). A `HelpPopover` — help, not a fact (§10.23)\n * — stays on the label line at every size. */\n hint?: ReactNode;\n /** Every user-facing string this component and the two it composes own, so a\n * translating host can supply its own. Each key optional, and each a per-field\n * override of the kit-wide translation in `<UiKitProvider labels>`: `currency`\n * and `currencySearch` of its `currency` namespace, the rest of `calculator`.\n * `currency` names the picker chip, composed with the selected code through\n * `common.fieldValue`; the rest are pass-through. */\n labels?: {\n currency?: string;\n currencySearch?: string;\n /** Names the calculator TRIGGER this component renders. `calculator` below\n * names the controls inside the popover it opens. */\n calculatorTrigger?: string;\n pad?: NumberPadSheetLabels;\n calculator?: CalculatorButtonLabels;\n };\n /** Translated currency names for the chip's picker, keyed by ISO code. The same\n * sparse override `CurrencySelect` takes, and for the same reason: the names in\n * `CURRENCIES` are shipped data, so without this they are the one English word\n * left in a translated row. Not part of `labels` because it is keyed by DATA\n * rather than by a fixed set of slots, and an app passes the same map to both\n * pickers. */\n currencyNames?: Record<string, string>;\n /** Offer only these ISO codes in the chip's list, in this order — `CurrencySelect`'s\n * `options`, since the chip renders CurrencySelect's list (round 0.34 Wave 2, DUP-4).\n * Default every currency the kit knows. */\n currencyOptions?: string[];\n /** Focus the field on mount — on mobile this also opens the numpad sheet, so a\n * new-transaction form can jump straight to amount entry (feedback #70). */\n autoFocus?: boolean;\n /**\n * Tint the typed figure by what it will DO (Keksdose feedback #167).\n *\n * The direction is chosen with a toggle beside the field rather than typed, so\n * the digits alone say nothing about which way the money goes — on the one screen\n * where getting that backwards is the expensive mistake. Colour says it\n * continuously, and it costs no layout. It stays the MAIN indication (live #201\n * rework: *\"The main indication shall still be the color\"*); {@link negative}\n * renders the sign as a second, quieter signal in front of the figure.\n *\n * Never the ONLY signal: the toggle it mirrors is right there, labelled, so this\n * is reinforcement rather than the sole carrier of the meaning.\n */\n tone?: \"neutral\" | \"outflow\" | \"inflow\";\n /**\n * The SIGN of the figure, owned by the caller's direction control (Keksdose live\n * #201 rework: *\"Outflow should be negative and inflow positive … the sign shall\n * be displayed but not necessarily be typed in\"*).\n *\n * `value` stays the MAGNITUDE. The minus is glued on at render time and stripped\n * off again before anything is reported back, so the caller never sees its own\n * prefix echoed and no code path can end up applying it twice. That is the whole\n * cure: there is exactly ONE place the sign lives, and it is not the text.\n *\n * Because it is rendered rather than stored it cannot be deleted (the next render\n * puts it back), a select-all-and-retype keeps the direction, and the caret needs\n * no minding.\n *\n * Since 0.15.5 it is drawn on its own too, for a read-only or disabled signed figure\n * (an \"Items total\" of −5.18): no `onNegativeChange` needed just to show the minus.\n */\n negative?: boolean;\n /**\n * A sign the user TYPED, or a calculation that resolved to a signed number.\n *\n * SET, never flip. A \"-\" means *\"this is an outflow\"*, so typing it twice says the\n * same thing twice — which is exactly what the rework asks for (*\"Subtracting\n * values twice resulting in inflow -> outflow and back to inflow seems not\n * reasonable\"*). \"+\" says the other direction.\n *\n * Its presence is what ARMS the whole sign behaviour. A field with no direction\n * control — an account's starting balance, a loan payment, a holding's cost —\n * passes neither prop and keeps a text that is the whole truth, minus included.\n */\n onNegativeChange?: (negative: boolean) => void;\n /**\n * How the field presents itself ON A PHONE (Keksdose feedback #176).\n *\n * `\"field\"` (default) is the labelled, bordered input used everywhere else.\n *\n * `\"display\"` keeps every mechanic — the same `<input>`, the same numpad sheet,\n * the same currency picker, the same commit/blur contract — and only drops the\n * chrome: no border, no fill, no floating label, the figure set at display size.\n * On a form whose whole point is one number, a bordered `text-sm` box draws the\n * amount at the same weight as the memo beside it; this makes it the headline\n * instead. It stays fully editable — the underline and the caret are what say so.\n *\n * Phone-only by construction: it keys off the same breakpoint as the numpad, so\n * from `md` up the field is byte-for-byte the normal one and a desktop grid keeps\n * its column rhythm.\n */\n variant?: \"field\" | \"display\";\n /**\n * Where the figure sits in its row, for `variant=\"display\"` only (Keksdose\n * feedback #176 rework).\n *\n * `\"start\"` (default) keeps it flush left, in the reading column the fields\n * below it share — and it is what the entry forms use, because a figure that\n * starts at a known edge is legible at any width: when the value outgrows the\n * field, the digits that scroll out of sight are the trailing ones, not the\n * magnitude (Keksdose feedback #430 rework).\n *\n * `\"center\"` makes it a centred headline. It centres in the width that REMAINS\n * after the trailing currency control, not in the whole box: the control is\n * pinned to the right edge, so a plain `text-center` would centre the figure\n * under it and the last digits would sit behind the chip. This used to mirror\n * the control's reservation onto the left instead, which centred correctly but\n * spent twice the control's width on padding — fatal on a 375px screen, where\n * it left a 36px figure 16px to live in.\n */\n align?: \"start\" | \"center\";\n /**\n * Decimals the committed amount is rounded to (kastlan 0.12: \"12.345\" and a\n * calculator's \"100/3\" reached a `Numeric(10,2)` column unrounded and failed with a\n * 422). Default: the currency's minor unit, from `Intl` (CHF and EUR 2, JPY 0). With\n * no `currency`, nothing is rounded unless this is set. Rounding is half away from\n * zero (12.345 → 12.35, -12.345 → -12.35) and happens when the figure settles: on\n * blur, on Enter, and on every result the calculator writes back. Keystrokes are left\n * alone, so \"12.3\" can still become \"12.34\".\n *\n * ⚠️ **A unit price or a rate needs `digits`.** The default is right for an amount of\n * money and silently wrong for a price per unit: a fund's NAV of 123.4567 or fuel at\n * 1.789 €/l is stored as 123.46 / 1.79, and no test fails (keksdose G2, a\n * `Numeric(18,6)` holding price and a `Numeric(18,4)` unit price). Pass the column's\n * scale: `digits={4}`, `digits={6}`.\n *\n * **Set `digits` for any sub-currency scale** — not only a price: any field whose\n * column holds more decimals than the currency's minor unit. A split line stored at\n * the ledger's 4dp (`Numeric(18,4)`) and loaded as 12.3456 is SHOWN as 12.35, and\n * committed as 12.35 as soon as the user tabs through it (blur settles) — so the form\n * no longer equals what the server holds: the lines stop summing to the 4dp total,\n * and Save is held (keksdose live #240). With a `currency`, every commit rounds to that currency's\n * minor unit unless `digits` says otherwise: pass the column's scale (`digits={4}`).\n */\n digits?: number;\n /** The smallest amount the field settles on. A lower figure is raised to it when it\n * settles, like `digits`. Compared with the signed figure. */\n min?: number;\n /** The largest amount the field settles on (a deposit release capped at the\n * balance). A higher figure is lowered to it when it settles. */\n max?: number;\n /**\n * The SETTLED figure, dot-decimal, sign included — fired on blur, on Enter, on the\n * numpad's \"=\" and on every result the calculator writes back, never on a keystroke\n * (\"1200+\" is not a figure yet). `onChange` still reports every keystroke; this is\n * for a host that stores a number and must not see drafts (kastlan 52; see\n * {@link MoneyField}, which is built on it).\n */\n onCommit?: (value: string) => void;\n /**\n * Why the amount cannot be changed — {@link NumberInput}'s `disabledReason` (0.34,\n * round 0.34 C2), for an amount that SAVES itself: a budget row's assigned cell, a\n * price committed on blur. `disabled` takes the field out of the tab order, so the\n * reason never reached a keyboard.\n *\n * With a reason the field stays in the tab order and shows its figure, `readOnly` (the\n * settled grey FIELD_BASE gives a `[readonly]` field) and `aria-disabled`. Nothing\n * changes the amount: the calculator and the phone's numpad are not offered, the\n * currency chip is a read-out rather than a picker, and neither blur nor Enter\n * settles — so `onChange`, `onCommit`, `onNegativeChange` and `onCurrencyChange` are\n * never called. Enter is swallowed, so the field does not submit the form around it.\n * The reason is a line under the field at Large and on a touch screen, else in the kit\n * {@link Tooltip} (`disabledReasonDisplay`), and on the input's `aria-describedby`,\n * between the caption and the error. Wins over `disabled`. {@link MoneyField} and\n * `RhfMoneyField` take it too.\n */\n disabledReason?: ReactNode;\n /**\n * Where the reason shows — {@link Button}'s `disabledReasonDisplay`: by default a line\n * under the field at Large and on a touch screen, the tooltip otherwise (§4 \"No fact\n * only in a tooltip\"; DUP-3, refactor audit 2026-10).\n */\n disabledReasonDisplay?: DisabledReasonDisplay;\n /**\n * This amount COMMITS — {@link Button}'s `commit`, NumberInput's: under a locked\n * {@link WriteLockProvider} it is locked the `disabledReason` way with the lock's reason\n * (which wins over its own). An amount that only reaches the server through its form's\n * Save leaves this off and stays editable under the lock; the Save takes `commit`. No\n * provider, or an unlocked one: no effect.\n */\n commit?: CommitScope;\n /** The `<input>`. A React 19 ref prop since 0.34 (MOD-4, refactor audit 2026-10); it\n * was `forwardRef`. */\n ref?: Ref<HTMLInputElement>;\n}\n\n\n/**\n * A settled figure, rounded to `digits` (half away from zero) and clamped to\n * `min`/`max`. Only a plain number is touched. A half-typed draft or an expression\n * comes back as it was. Rounding is `lib/round.ts`'s, shared with `roundToCurrency`\n * (BUG-11: this copy blanked \"0.0000001\" and a 22-digit figure on blur).\n */\nfunction settleAmount(text: string, digits: number | undefined, min?: number, max?: number): string {\n const t = text.trim();\n if (!/^-?\\d*\\.?\\d*$/.test(t) || !/\\d/.test(t)) return text;\n let n = Number(t);\n if (!Number.isFinite(n)) return text;\n if (digits !== undefined) n = roundHalfAway(n, digits);\n if (min !== undefined && n < min) n = min;\n if (max !== undefined && n > max) n = max;\n const out = formatResult(n);\n // Unchanged figures keep their own spelling (\"12.50\" stays \"12.50\").\n return Number(out) === Number(t) ? text : out;\n}\n\n// The locale's decimal mark and the grouping parse (kastlan 40, keksdose G1) live in\n// `lib/decimal-marks.ts`, read through the engine NumberInput and this field share\n// (`numeric-field.ts`, DUP-10).\n\n// The consuming app's ONE money palette (`--money-expense` / `--money-income`),\n// not a bespoke rose/emerald pairing: a figure being typed has to wear the same\n// colour the same figure will wear once it is a row in the table behind the form\n// (Keksdose dev#434). The utilities are unlayered and theme-aware, so no `dark:`\n// variant is needed and they win over the field's own text colour regardless of\n// where `cn` puts them.\nconst TONE_CLASS: Record<\"neutral\" | \"outflow\" | \"inflow\", string> = {\n neutral: \"\",\n outflow: \"text-money-neg\",\n inflow: \"text-money-pos\",\n};\n\n// The shared chrome-less treatment at money size. `tabular-nums` so digits don't\n// reflow the figure as they are typed; FIELD_DISPLAY's own muted placeholder\n// colour is what keeps an EMPTY form from painting its zero in the direction tint\n// (`tone` is computed from 0, which reads as an inflow).\nconst DISPLAY_INPUT_CLASS = cn(\n FIELD_DISPLAY,\n \"text-4xl font-semibold leading-tight tracking-tight tabular-nums\",\n);\n\n/**\n * Is `text` the ANSWER to `previous`, or something typed OVER it?\n *\n * \"The old text was a sum and the new one is bare\" cannot tell those apart, and both\n * gestures are ordinary: select-all-and-retype after a typo, or backspacing \"-20+\"\n * back down to a fresh figure. Read as an answer, they move the direction chip — so\n * an outflow of 7 quietly booked +7.00 (live #201 rework).\n *\n * The question that does separate them is arithmetic, not shape: evaluate what the\n * text replaced and see whether this IS that number. \"-12+30\" → \"18\" still is, so a\n * sum that comes out positive still takes the chip with it; \"-20+50\" → \"7\" is not,\n * and \"-20+\" evaluates to nothing at all.\n */\nfunction isResultOf(previous: string, text: string, settle: (text: string) => string): boolean {\n const n = evaluateExpression(previous);\n // Compared settled, since the field rounds what the calculator hands it.\n return n !== null && settle(formatResult(n)) === text.trim();\n}\n\nexport function AmountInput(props: AmountInputProps) {\n const { ref, value, onChange, currency, onCurrencyChange, placeholder, label, className, inputClassName, id, \"aria-label\": ariaLabel, \"aria-required\": ariaRequired, autoFocus, tone = \"neutral\", negative = false, onNegativeChange, align = \"start\", labels, currencyNames, currencyOptions, digits: digitsProp, min, max, onCommit, disabledReasonDisplay } = props;\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n // The sign is DISPLAYED, not stored (live #201 rework). `value` is the\n // magnitude; the minus is glued on here and taken off again in handleText, so\n // the two can never disagree and the caller can never double-apply it. Only in\n // front of a bare amount: an expression being typed (\"12-30\") owns its own\n // minus and has to survive keystroke-for-keystroke.\n const signOwned = onNegativeChange !== undefined;\n // The sign is DRAWN whenever `negative` says so, handler or not (keksdose live #366):\n // a read-only or disabled total (\"−5.18\") used to need a dummy `onNegativeChange`\n // just to show its minus. Without the handler there is nothing to toggle — a typed\n // minus simply stays in the text, as in any field without a direction control.\n const shown = negative && isBareAmount(value) ? `-${value}` : value;\n // What the user SEES is `shown` with the locale's decimal mark (kastlan 40: a\n // fr-CH user typed \"1,5\" and watched it turn into \"1.5\" under their fingers). Display only — `value`, `onChange`, the sign split and the settle all\n // stay dot-decimal, because that string is the contract: RhfMoneyField's\n // `parseAmount`, every app's `Number(value)` and the calculator's evaluator read\n // it. The way back is free: {@link sanitizeLive} already folds a typed \",\" into\n // \".\", so a comma typed, pasted or tapped on the numpad lands as a dot.\n //\n // One character for one character, and no digit grouping: the caret stays where\n // the typist put it, and \"1.000\" cannot be read back as a thousand in one locale\n // and as one in the other. de-CH and it-CH are \".\" — CLDR says so, and this\n // follows `Intl` rather than a guess about a country. The field's own `locale`,\n // else the provider's (0.34, DUP-10).\n const locale = useKitLocale(props.locale);\n // Decimals the figure settles to: `digits`, else the currency's minor unit.\n const digits = digitsProp ?? currencyMinorDigits(currency);\n const settle = (text: string) => settleAmount(text, digits, min, max);\n // The engine NumberInput shares (DUP-10): the lock (focusable, `readOnly`, nothing\n // changes or settles — see `disabledReason`), the hint — a FieldHint is its words at\n // Large and on touch, §4 — the error, the description's order, the typist's draft\n // in the locale's mark, the calculator and the numpad. On a phone the OS keyboard\n // is suppressed for the numpad sheet (feedback #334), and the display shape keys off\n // the SAME phone layout, so the two can never drift apart on the breakpoint.\n //\n // A value the HOST set (not one typed here) is shown at the currency's minor unit\n // while the field is not being edited: an FX estimate of 93.4213 showed four\n // decimals (keksdose live #356). Display only — `value` is the host's, untouched.\n const numeric = useNumericField(props, {\n settle,\n display: (focused) => (focused ? shown : settleAmount(shown, digits)),\n });\n const { lock, locked, off, isMobile, asDisplay, showCalc, showNumpad, setFocused, mark, draft, setDraft, derived } =\n numeric;\n const invalid = numeric.isInvalid;\n // A locked chip is a read-out: picking a currency is a change too.\n const editable = !!onCurrencyChange && !locked;\n // Room for the trailing controls — the calculator and the currency chip — once\n // measured, as NumberInput reserves its own (keksdose live #367, DUP-10): their\n // width, the track's `end-1` inset in the boxed shape, and NumberInput's 4px gap.\n // Before that (the first paint, and wherever there is no layout) the classes below\n // stand in. showCalc is always false on a phone, so the display shape only has to\n // clear the chip, by its own width rather than the boxed shape's room (feedback #430\n // rework: on a 375px screen 16px decide between a readable figure and a clipped one).\n const hasEnd = showCalc || Boolean(currency);\n const [endRef, endWidth] = useEndWidth(hasEnd);\n const trailingRoom = asDisplay\n ? currency ? (editable ? \"pe-16\" : \"pe-12\") : undefined\n : showCalc\n ? currency ? (editable ? \"pe-24\" : \"pe-16\") : \"pe-10\"\n : currency ? (editable ? \"pe-20\" : \"pe-14\") : undefined;\n const innerRef = useRef<HTMLInputElement>(null);\n const setRefs = useMemo(() => mergeRefs(innerRef, ref), [ref]);\n // While the typist is typing, the field shows THEIR text (\"1.234,5\" stays exactly\n // that), not the value re-spelt: re-spelling turned a grouping \".\" into a \",\" under\n // their fingers, after which no rule could tell the two apart (keksdose G1). The\n // draft only while it says what the field holds AND holds nothing the live\n // sanitising would drop — a letter, a second decimal point (see `showsTyped`); a\n // value set from outside, a calculator result or a commit shows the derived spelling.\n const display =\n draft === null\n ? derived\n : (numeric.typedFor(shown) ??\n // The caller owns the sign: the typed \"12\" is shown as the \"-12\" it is.\n (signOwned && negative && shown.startsWith(\"-\") && numeric.typedFor(shown.slice(1)) !== null\n ? `-${draft}`\n : derived));\n // Every route into the field — typing, the numpad sheet, the desktop\n // calculator, the blur/Enter commit — funnels through here, so the split is\n // written once and the four entry paths cannot drift.\n //\n // `previous` is the text this one REPLACES, and it is what says whether a bare\n // figure arriving here is an answer or a magnitude. For the three paths that\n // edit the field's own text that is simply what the field was showing; the\n // desktop calculator keeps its expression in a popover the field never sees,\n // so it passes it in (see `CalculatorButton`'s `onChange`).\n const handleText = (raw: string, previous: string = shown) => {\n const text = sanitizeLive(raw);\n if (!signOwned) {\n onChange(text);\n return;\n }\n const { sign, rest } = splitLeadingSign(text);\n if (sign) {\n // SET, not flip: re-reporting the same sign on every keystroke is a no-op.\n onNegativeChange(sign === \"-\");\n } else if (looksLikeExpression(previous) && isBareAmount(text) && isResultOf(previous, text, settle)) {\n // A calculation that just RESOLVED states its sign in both directions. The\n // figure it ran on is the SIGNED one the user could see — \"-12+30\" is +18 —\n // so a positive result has to move the chip too, or the field would answer\n // that sum with \"-18\" and contradict the arithmetic it just showed.\n //\n // Only when it really resolved, though: see {@link isResultOf}. A bare figure\n // arriving on top of an expression is far more often a replacement than an\n // answer, and reading it as an answer flips the direction of money.\n onNegativeChange(false);\n }\n onChange(sign ? rest : text);\n };\n const commit = () => {\n setDraft(null);\n const settled = settle(commitExpression(shown));\n handleText(settled);\n onCommit?.(settled);\n };\n const typed = (raw: string) => handleText(numeric.read(raw));\n // The currency list is CurrencySelect's (round 0.34 Wave 2, DUP-4) on the picker\n // family's core: the chip was a hand copy of it and had drifted (no wrap at Large, no\n // `options` subset, no check mark, no listbox id, no #308 width), and both were plain\n // buttons under a listbox promise. `filter: false`: the list filters its own rows.\n const core = useComboboxCore<string>({ filter: false, backCloses: true });\n // `chipRef`: the chip the currency list hangs off (Keksdose dev#548: portalled, so the\n // panel needs a real trigger rect rather than a relative parent). It is also where\n // Escape and a pick hand focus back (round 0.34 BUG-1): Safari does not focus a\n // clicked button, so \"whatever held focus\" is not the chip.\n const { open, setOpen, closeToTrigger, triggerRef: chipRef } = core;\n const listboxId = `${generatedId}-currencies`;\n // A lock arriving while the list is up closes it, as on CountrySelect — adjusted\n // while rendering, so no frame shows a list that can no longer be used.\n if (!editable && open) setOpen(false);\n\n // The currency chip's strings are the `currency` namespace — the same two\n // `CurrencySelect` resolves, under this component's older key names. The\n // calculator and the numpad resolve `calculator` themselves; `labels.calculator`\n // and `labels.pad` are handed straight through to them as overrides.\n // The two strings read out first, so the memo depends on them and not on the\n // caller's `labels` object (a new one every render) — what the React Compiler infers.\n const currencyLabel = labels?.currency;\n const currencySearchLabel = labels?.currencySearch;\n const currencyOverrides = useMemo(() => {\n const out: Partial<CurrencyLabels> = {};\n if (currencyLabel !== undefined) out.currency = currencyLabel;\n if (currencySearchLabel !== undefined) out.search = currencySearchLabel;\n return out;\n }, [currencyLabel, currencySearchLabel]);\n const currencyText = useKitLabels(\"currency\", DEFAULT_CURRENCY_LABELS, currencyOverrides);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n\n const selected = getCurrency(currency);\n\n return (\n <div className={cn(\"w-full\", className)}>\n {/* Inner relative box holds the input + its absolutely-positioned\n trailing controls (calculator / currency), so those stay anchored to\n the INPUT even when the mobile math bar is rendered below (#334). It is\n the kit's FloatingField, which draws the label — floating, or sr-only in\n the display shape — and puts a FieldHint on the label's line, as it does\n for NumberInput. */}\n {/* Locked, the field sits in the reason's frame (LockedReason: the line, or the\n Tooltip), as NumberInput does; the root above keeps `className`, so nothing\n reflows. */}\n <LockedOrNot lock={lock} display={disabledReasonDisplay}>\n <FloatingField\n className=\"w-full\"\n htmlFor={fieldId}\n label={label}\n srOnlyLabel={asDisplay}\n hint={numeric.hint.labelHint}\n >\n <input\n ref={setRefs}\n id={fieldId}\n aria-label={ariaLabel}\n type=\"text\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- opt-in per call site (feedback #70)\n autoFocus={autoFocus}\n // On mobile suppress the OS keyboard so our numpad sheet owns entry; the\n // field keeps focus/caret. Desktop keeps the native decimal keypad.\n inputMode={isMobile ? \"none\" : \"decimal\"}\n autoComplete=\"off\"\n disabled={off}\n // Locked: focusable, `readOnly`, `aria-disabled` — see `disabledReason`.\n readOnly={locked || undefined}\n aria-disabled={locked || undefined}\n // The floating-label pattern needs a blank placeholder for its\n // peer-placeholder-shown trick. The display shape has no floating label,\n // so it spends the placeholder on what an empty borderless form actually\n // needs: a zero to aim at, at full size. The caller supplies it because\n // only the app knows the locale's decimal separator.\n placeholder={asDisplay ? (placeholder ?? \"0\") : label !== undefined ? \" \" : placeholder}\n value={display}\n onChange={(e) => {\n if (!locked) typed(e.target.value);\n }}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n // Nothing settles under the lock — not even a draft typed before it arrived,\n // which stays in the field for when it lifts.\n if (!locked) commit();\n setFocused(false);\n }}\n onKeyDown={(e) => {\n if (e.key !== \"Enter\") return;\n // Locked: Enter submits no form and settles nothing.\n if (locked) e.preventDefault();\n else commit();\n }}\n className={cn(\n // With a label, use the floating-input padding (pt-4 pb-1) like every\n // other labelled field so the value sits BELOW the floated label rather\n // than vertically centred where it overlaps the resting label\n // (feedback #314). FLOATING_INPUT_CLASS already bundles the peer +\n // transparent-placeholder bits.\n asDisplay ? DISPLAY_INPUT_CLASS : label !== undefined ? FLOATING_INPUT_CLASS : FIELD_BASE,\n // The plain end padding, with nothing trailing: cosmetic, so the caller's\n // to change (keksdose 0.24 — a symmetric `px-2` in a budget cell).\n !trailingRoom && (asDisplay ? \"pe-0\" : \"pe-3\"),\n // Centred display shape: centre in what is LEFT of the currency chip.\n // `text-center` alone would centre the figure in the whole box, i.e.\n // partly underneath the chip; the padding below is what takes the chip\n // out of the centring, and nothing is added at the start because a\n // mirrored reservation would spend the width twice (see `align`).\n asDisplay && align === \"center\" && \"text-center\",\n // Over the base class's own text colour.\n TONE_CLASS[tone],\n // The caller's, over all of the above — base, plain padding, alignment and\n // tone — and under only what the field needs to work (see `inputClassName`).\n inputClassName,\n // Room for the trailing controls, after the caller's so a `px-2` cannot run\n // the digits under the chip (NumberInput's order, which reserves its unit\n // and calculator the same way).\n trailingRoom,\n invalid && FIELD_INVALID,\n locked && \"cursor-not-allowed\",\n )}\n // The classes above are the fallback; once measured the field reserves exactly\n // its trailing controls' width, inline so it wins over every class (see\n // `trailingRoom`).\n style={hasEnd && endWidth != null ? { paddingInlineEnd: endWidth + (asDisplay ? 4 : 8) } : undefined}\n aria-invalid={invalid || undefined}\n aria-describedby={numeric.describedBy}\n aria-required={ariaRequired}\n />\n {/* The label is FloatingField's, after these children (the floating trick\n reads the input through `peer-*`). The display shape drops it VISUALLY,\n not from the accessibility tree: a 36px tinted figure at the top of a\n transaction form is legibly the amount, but a screen reader still needs\n the name, and callers that pass `label` without `aria-label` would\n otherwise be left with none. */}\n {/* Trailing controls share one flex track so the calculator icon and the\n currency suffix/picker sit side by side without overlapping. */}\n {/* The display shape has no box to inset from, so the controls align to the\n figure's own end edge and its baseline strip (`bottom-1`, matching the\n input's pb-1) instead of floating inside a field. */}\n <div\n // Measured for the input's end padding (see `trailingRoom`).\n ref={endRef}\n className={cn(\n \"absolute flex items-center gap-0.5\",\n // Logical `end-*`: the chip and the calculator are the figure's trailing\n // controls, so a right-to-left form carries them on the left.\n asDisplay ? \"bottom-1 end-0\" : \"inset-y-1 end-1\",\n )}\n >\n {showCalc && (\n <CalculatorButton\n // The mark the field shows but not the typist's grouping: the evaluator\n // reads either mark, and \"1.234,5\" is two of them. The result comes back\n // dot-decimal.\n value={derived}\n onChange={(result, expression) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled, expression);\n onCommit?.(settled);\n }}\n className=\"px-1.5\"\n aria-label={labels?.calculatorTrigger}\n labels={labels?.calculator}\n />\n )}\n {currency && !editable && (\n <span\n aria-hidden\n className={cn(\n \"pointer-events-none px-1 font-medium text-muted\",\n // A text-xs chip next to a 36px figure reads as a stray footnote.\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n </span>\n )}\n {currency && editable && (\n <button\n ref={chipRef}\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n // A button that opens a listbox, and says so: the chip is a control inside\n // a text field, not a field of its own, so not a combobox.\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={listboxId}\n aria-label={\n // \"Currency: EUR\" through `common.fieldValue`, not a template literal:\n // the colon-and-space is punctuation a translation has to own.\n selected ? common.fieldValue(currencyText.currency, selected.code) : currencyText.currency\n }\n className={cn(\n \"flex items-center gap-1 rounded px-2 py-1 font-medium text-secondary hover:bg-hover\",\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n <ChevronDown className=\"size-3\" />\n </button>\n )}\n </div>\n {editable && (\n <CurrencyOptionList\n core={core}\n listboxId={listboxId}\n value={currency}\n codes={currencyOptions}\n currencyNames={currencyNames}\n locale={locale}\n searchPlaceholder={currencyText.search}\n // The phone sheet's title: what the chip is for.\n sheetTitle={currencyText.currency}\n onChoose={(code) => {\n onCurrencyChange?.(code);\n closeToTrigger();\n }}\n />\n )}\n </FloatingField>\n </LockedOrNot>\n {/* Outside the relative box, as NumberInput's caption is: the trailing\n controls are `inset-y-1` in it and would stretch down over a second line. */}\n <FieldCaption parts={numeric.hint} />\n {/* The news after the standing advice, as Select orders them. The root is\n already a steady box, so the message coming and going remounts nothing. */}\n {numeric.errorEl}\n {showNumpad && (\n <NumberPadSheet\n // Localised like the field it mirrors. Keys are typing, read by the\n // locale's marks like the keyboard's; \"=\" is a result, dot-decimal.\n value={display}\n onChange={typed}\n onResult={(result) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled);\n onCommit?.(settled);\n }}\n onDone={() => innerRef.current?.blur()}\n label={label}\n labels={labels?.pad}\n decimalMark={mark}\n />\n )}\n </div>\n );\n}\n\n/** The field in its lock's {@link LockedReason} while locked, as it is otherwise. A\n * component rather than a ternary so the field's JSX is written once. `block w-full`:\n * the frame's box stands where the field's own did. */\nfunction LockedOrNot({\n lock,\n display,\n children,\n}: {\n lock: LockReason;\n display: DisabledReasonDisplay | undefined;\n children: ReactNode;\n}) {\n if (!lock.locked) return <>{children}</>;\n return (\n <LockedReason lock={lock} display={display} className=\"block w-full\">\n {children}\n </LockedReason>\n );\n}\n"],"mappings":";AAwiBM,SAgNqB,UAhNrB,KA6HI,YA7HJ;AAxiBN,SAAS,OAAO,SAAS,cAAc;AACvC,SAAS,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AAA,cACA,OAAO;AAAA,cACP,OAAO;AAAA,cACP;AAAA,cACA;AAAA,cACA,mBAAmB,aAAa;AAAA,cAEhC,YAAY,aAAa;AAAA,cACzB,UAAU,CAAC,SAAS;AAClB,mCAAmB,IAAI;AACvB,+BAAe;AAAA,cACjB;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IAEF,GACA;AAAA,IAGA,oBAAC,gBAAa,OAAO,QAAQ,MAAM;AAAA,IAGlC,QAAQ;AAAA,IACR,cACC;AAAA,MAAC;AAAA;AAAA,QAGC,OAAO;AAAA,QACP,UAAU;AAAA,QACV,UAAU,CAAC,WAAW;AACpB,mBAAS,IAAI;AACb,gBAAM,UAAU,OAAO,MAAM;AAC7B,qBAAW,OAAO;AAClB,qBAAW,OAAO;AAAA,QACpB;AAAA,QACA,QAAQ,MAAM,SAAS,SAAS,KAAK;AAAA,QACrC;AAAA,QACA,QAAQ,QAAQ;AAAA,QAChB,aAAa;AAAA;AAAA,IACf;AAAA,KAEJ;AAEJ;AAKA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,MAAI,CAAC,KAAK,OAAQ,QAAO,gCAAG,UAAS;AACrC,SACE,oBAAC,gBAAa,MAAY,SAAkB,WAAU,gBACnD,UACH;AAEJ;","names":[]}
@@ -24,9 +24,6 @@ interface CalculatorButtonProps {
24
24
  className?: string;
25
25
  /** The trigger's accessible name; wins over `calculator.open` from the provider. */
26
26
  "aria-label"?: string;
27
- /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).
28
- * Names the trigger only when `aria-label` is absent. */
29
- ariaLabel?: string;
30
27
  /** Screen-reader names for the panel's own controls. `aria-label` above already
31
28
  * covers the trigger; these three were hardcoded English inside the popover,
32
29
  * which a translating host had no way to reach. */
@@ -38,5 +35,5 @@ interface CalculatorButtonProps {
38
35
  * `relative` wrapper, positioned absolutely. The keypad seeds from the current
39
36
  * field value and writes evaluated results straight back through `onChange`.
40
37
  */
41
- export declare function CalculatorButton({ value, onChange, className, "aria-label": ariaLabelAttr, ariaLabel: ariaLabelProp, labels: labelsProp, }: CalculatorButtonProps): import("react").JSX.Element;
38
+ export declare function CalculatorButton({ value, onChange, className, "aria-label": ariaLabel, labels: labelsProp, }: CalculatorButtonProps): import("react").JSX.Element;
42
39
  export {};
@@ -142,11 +142,9 @@ function CalculatorButton({
142
142
  value,
143
143
  onChange,
144
144
  className,
145
- "aria-label": ariaLabelAttr,
146
- ariaLabel: ariaLabelProp,
145
+ "aria-label": ariaLabel,
147
146
  labels: labelsProp
148
147
  }) {
149
- const ariaLabel = ariaLabelAttr ?? ariaLabelProp;
150
148
  const fromProps = useMemo(
151
149
  () => ariaLabel === void 0 ? labelsProp : { ...labelsProp, open: ariaLabel },
152
150
  [ariaLabel, labelsProp]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/calculator.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Calculator as CalculatorIcon, Delete } from \"lucide-react\";\nimport { Popover } from \"./popover\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { evaluateExpression, formatResult, isBareAmount, splitLeadingSign } from \"../lib/calc\";\nimport {\n DEFAULT_CALCULATOR_LABELS,\n useKitLabels,\n type CalculatorLabels,\n} from \"../i18n/kit-labels\";\n\n/** Screen-reader names for the calculator panel's own controls — any part of the\n * kit's `calculator` namespace. Once three optional keys of its own; widened, not\n * replaced, so every object that type-checked before still does. */\nexport type CalculatorButtonLabels = Partial<CalculatorLabels>;\n\ninterface CalculatorButtonProps {\n /** Current field text — seeds the keypad so the user can keep calculating\n * from what's already entered. */\n value: string;\n /**\n * Called with the evaluated result whenever the running expression resolves\n * to a number, so the host field tracks the keypad live.\n *\n * `expression` is the TEXT that result came out of — `\"-42+50\"` for an 8 — and\n * is omitted when there was no calculation (a cleared pad). A host that keeps\n * the sign of its figure OUTSIDE the text (see `AmountInput`'s `negative` /\n * `onNegativeChange`, where a direction toggle owns it) cannot otherwise tell\n * that 8 from a freshly typed one: the first is a sum that came out positive\n * and has to take the direction with it, the second is a magnitude that must\n * leave the direction alone. Hosts whose text carries its own sign can take\n * the one argument and ignore this.\n */\n onChange: (value: string, expression?: string) => void;\n className?: string;\n /** The trigger's accessible name; wins over `calculator.open` from the provider. */\n \"aria-label\"?: string;\n /** @deprecated 0.34 — use `aria-label`; removed in 0.35 (refactor audit 2026-10, API-1).\n * Names the trigger only when `aria-label` is absent. */\n ariaLabel?: string;\n /** Screen-reader names for the panel's own controls. `aria-label` above already\n * covers the trigger; these three were hardcoded English inside the popover,\n * which a translating host had no way to reach. */\n labels?: CalculatorButtonLabels;\n}\n\n/** Keypad layout (4 columns). The final C/= row is rendered separately. `name` is\n * the key of the {@link CalculatorLabels} entry that names a non-digit key; a digit\n * is named by its own glyph. */\ntype Key =\n | { kind: \"ins\"; label: string; ins: string; accent?: boolean; name?: KeyName }\n | { kind: \"back\" };\n\ntype KeyName = \"plus\" | \"minus\" | \"times\" | \"divide\" | \"decimal\";\n\nconst KEYS: Key[] = [\n { kind: \"ins\", label: \"7\", ins: \"7\" },\n { kind: \"ins\", label: \"8\", ins: \"8\" },\n { kind: \"ins\", label: \"9\", ins: \"9\" },\n { kind: \"ins\", label: \"÷\", ins: \"÷\", accent: true, name: \"divide\" },\n { kind: \"ins\", label: \"4\", ins: \"4\" },\n { kind: \"ins\", label: \"5\", ins: \"5\" },\n { kind: \"ins\", label: \"6\", ins: \"6\" },\n { kind: \"ins\", label: \"×\", ins: \"×\", accent: true, name: \"times\" },\n { kind: \"ins\", label: \"1\", ins: \"1\" },\n { kind: \"ins\", label: \"2\", ins: \"2\" },\n { kind: \"ins\", label: \"3\", ins: \"3\" },\n { kind: \"ins\", label: \"−\", ins: \"−\", accent: true, name: \"minus\" },\n { kind: \"ins\", label: \"0\", ins: \"0\" },\n { kind: \"ins\", label: \".\", ins: \".\", name: \"decimal\" },\n { kind: \"back\" },\n { kind: \"ins\", label: \"+\", ins: \"+\", accent: true, name: \"plus\" },\n];\n\n// The kit's one focus frame (text-size §5). Until 0.34 the keys rang in `ring-strong` on\n// `focus:`, so a pointer click left a grey ring on the key it pressed (DOC-7).\nconst KEY_BASE = `flex h-9 items-center justify-center rounded-md text-sm font-medium transition-colors ${FOCUS_RING}`;\n// Two key families, two fills: digits sit on the inset surface and darken on\n// hover, operators sit a step down on `--bg-active` and lift toward that surface —\n// the same split `NumberPadSheet` uses for this keypad on a phone. The tokens\n// flip with the theme, so neither needs a `dark:` twin.\n//\n// 0.33 (docs/colour-roles-harmonization.md §12.2, §12.9): the digits hover onto\n// `--bg-active`, 1.11–1.18:1 from the key — `--bg-hover` is mixed against the card and\n// sat only 1.04:1 from the well, which in light is the page. The operators rest on\n// `--bg-active` rather than `--border`: More contrast steps the border until it is a\n// 3:1 LINE, and as a fill under the label that left 2.2–2.7:1.\nconst KEY_DIGIT = \"bg-surface-2 text-primary hover:bg-active\";\nconst KEY_ACCENT = \"bg-active text-secondary hover:bg-surface-2\";\n\nfunction seed(initial: string): string {\n const t = initial.trim();\n return t === \"-\" ? \"\" : t;\n}\n\nfunction CalculatorPanel({\n initial,\n onChange,\n labels,\n}: {\n initial: string;\n onChange: (value: string, expression?: string) => void;\n labels: CalculatorLabels;\n}) {\n const [expr, setExpr] = useState(() => seed(initial));\n const inputRef = useRef<HTMLInputElement>(null);\n // What the pad SHOWS. Normally the expression it holds — but when the host owns\n // the sign of the figure, the magnitude it hands back is not the whole number:\n // type 50 into a pad opened on an outflow and the host answers \"-50\". Derived\n // rather than stored, so there is no echo to guard against and a host that\n // ignores `onChange` entirely (a static `value`) still sees its own keystrokes:\n // the pad only defers when the host's text is character-for-character its own\n // last number with a minus in front.\n const host = splitLeadingSign(initial.trim());\n const text = host.sign === \"-\" && isBareAmount(expr) && host.rest === expr.trim() ? initial.trim() : expr;\n const result = evaluateExpression(text);\n\n // Focus the display on open so the user can type or hit Enter immediately.\n useEffect(() => {\n inputRef.current?.focus();\n }, []);\n\n // Update the host field whenever the expression resolves to a number; an\n // incomplete expression (e.g. \"12+\") simply leaves the field untouched. The\n // expression rides along with the result — see `onChange` above.\n const apply = (next: string) => {\n setExpr(next);\n const n = evaluateExpression(next);\n if (n !== null) onChange(formatResult(n), next);\n };\n\n const clearAll = () => {\n setExpr(\"\");\n onChange(\"\");\n };\n\n const equals = () => {\n if (result === null) return;\n const out = formatResult(result);\n setExpr(out);\n onChange(out, text);\n };\n\n return (\n <div className=\"space-y-2\">\n <input\n ref={inputRef}\n aria-label={labels.calculation}\n value={text}\n inputMode=\"decimal\"\n onChange={(e) => apply(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n equals();\n }\n }}\n // Arithmetic reads left to right in every script, and a calculator display\n // is right-aligned in every script too — so both stay physical, pinned\n // with `dir=\"ltr\"` rather than mirrored in a right-to-left form.\n dir=\"ltr\"\n className={cn(\"block w-full rounded-md border border-subtle bg-surface px-2 py-1.5 text-right font-mono text-sm text-primary focus:border-strong focus:ring-strong\", FIELD_TOUCH_TEXT)}\n />\n <div dir=\"ltr\" className=\"h-4 pr-1 text-right font-mono text-xs text-placeholder\">\n {result !== null && formatResult(result) !== text.trim() ? `= ${formatResult(result)}` : \"\"}\n </div>\n <div className=\"grid grid-cols-4 gap-1.5\">\n {KEYS.map((key, i) =>\n key.kind === \"back\" ? (\n <button\n key=\"back\"\n type=\"button\"\n aria-label={labels.backspace}\n onClick={() => apply(text.slice(0, -1))}\n className={cn(KEY_BASE, KEY_ACCENT)}\n >\n <Delete className=\"size-4\" />\n </button>\n ) : (\n <button\n key={`${key.ins}-${i}`}\n type=\"button\"\n aria-label={key.name ? labels[key.name] : undefined}\n onClick={() => apply(text + key.ins)}\n className={cn(KEY_BASE, key.accent ? KEY_ACCENT : KEY_DIGIT)}\n >\n {key.label}\n </button>\n ),\n )}\n <button\n type=\"button\"\n // \"C\" is a convention, not a name: read aloud it is the letter.\n aria-label={labels.clear}\n onClick={clearAll}\n className={cn(KEY_BASE, \"col-span-2\", KEY_ACCENT)}\n >\n C\n </button>\n <button\n type=\"button\"\n aria-label={labels.equals}\n onClick={equals}\n className={cn(\n KEY_BASE,\n // The one chip that inverts against the page. There is no hover token for\n // an inverted fill, so the hover is the chip mixed back toward the\n // surface — a step quieter in either theme, and still a colour, so\n // KEY_BASE's `transition-colors` carries it.\n \"col-span-2 bg-inverse text-inverse hover:bg-[color-mix(in_oklab,var(--bg-inverse)_88%,var(--bg-surface))]\",\n )}\n >\n =\n </button>\n </div>\n </div>\n );\n}\n\n/**\n * A calculator icon that opens a small keypad popover anchored to its host\n * field. Designed as a trailing-edge adornment: render it inside the field's\n * `relative` wrapper, positioned absolutely. The keypad seeds from the current\n * field value and writes evaluated results straight back through `onChange`.\n */\nexport function CalculatorButton({\n value,\n onChange,\n className,\n \"aria-label\": ariaLabelAttr,\n ariaLabel: ariaLabelProp,\n labels: labelsProp,\n}: CalculatorButtonProps) {\n // prop > provider > English, with the name prop folded in as the `open` key it has\n // always been. The DOM spelling wins over the deprecated `ariaLabel`.\n const ariaLabel = ariaLabelAttr ?? ariaLabelProp;\n const fromProps = useMemo(\n () => (ariaLabel === undefined ? labelsProp : { ...labelsProp, open: ariaLabel }),\n [ariaLabel, labelsProp],\n );\n const labels = useKitLabels(\"calculator\", DEFAULT_CALCULATOR_LABELS, fromProps);\n return (\n <Popover\n width=\"14rem\"\n labels={{ panel: labels.panel }}\n trigger={({ open, toggle, ref }) => (\n <button\n ref={ref}\n type=\"button\"\n tabIndex={-1}\n onClick={toggle}\n aria-label={labels.open}\n aria-expanded={open}\n className={cn(\n \"flex items-center justify-center text-placeholder transition-colors hover:text-secondary\",\n className,\n )}\n >\n <CalculatorIcon className=\"size-4\" />\n </button>\n )}\n >\n {() => <CalculatorPanel initial={value} onChange={onChange} labels={labels} />}\n </Popover>\n );\n}\n"],"mappings":";AAmJM,cAqBA,YArBA;AA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AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,WAAW;AAAA,EACX,QAAQ;AACV,GAA0B;AAGxB,QAAM,YAAY,iBAAiB;AACnC,QAAM,YAAY;AAAA,IAChB,MAAO,cAAc,SAAY,aAAa,EAAE,GAAG,YAAY,MAAM,UAAU;AAAA,IAC/E,CAAC,WAAW,UAAU;AAAA,EACxB;AACA,QAAM,SAAS,aAAa,cAAc,2BAA2B,SAAS;AAC9E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,QAAQ,EAAE,OAAO,OAAO,MAAM;AAAA,MAC9B,SAAS,CAAC,EAAE,MAAM,QAAQ,IAAI,MAC5B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,MAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS;AAAA,UACT,cAAY,OAAO;AAAA,UACnB,iBAAe;AAAA,UACf,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,UAEA,8BAAC,kBAAe,WAAU,UAAS;AAAA;AAAA,MACrC;AAAA,MAGD,gBAAM,oBAAC,mBAAgB,SAAS,OAAO,UAAoB,QAAgB;AAAA;AAAA,EAC9E;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/calculator.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Calculator as CalculatorIcon, Delete } from \"lucide-react\";\nimport { Popover } from \"./popover\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { evaluateExpression, formatResult, isBareAmount, splitLeadingSign } from \"../lib/calc\";\nimport {\n DEFAULT_CALCULATOR_LABELS,\n useKitLabels,\n type CalculatorLabels,\n} from \"../i18n/kit-labels\";\n\n/** Screen-reader names for the calculator panel's own controls — any part of the\n * kit's `calculator` namespace. Once three optional keys of its own; widened, not\n * replaced, so every object that type-checked before still does. */\nexport type CalculatorButtonLabels = Partial<CalculatorLabels>;\n\ninterface CalculatorButtonProps {\n /** Current field text — seeds the keypad so the user can keep calculating\n * from what's already entered. */\n value: string;\n /**\n * Called with the evaluated result whenever the running expression resolves\n * to a number, so the host field tracks the keypad live.\n *\n * `expression` is the TEXT that result came out of — `\"-42+50\"` for an 8 — and\n * is omitted when there was no calculation (a cleared pad). A host that keeps\n * the sign of its figure OUTSIDE the text (see `AmountInput`'s `negative` /\n * `onNegativeChange`, where a direction toggle owns it) cannot otherwise tell\n * that 8 from a freshly typed one: the first is a sum that came out positive\n * and has to take the direction with it, the second is a magnitude that must\n * leave the direction alone. Hosts whose text carries its own sign can take\n * the one argument and ignore this.\n */\n onChange: (value: string, expression?: string) => void;\n className?: string;\n /** The trigger's accessible name; wins over `calculator.open` from the provider. */\n \"aria-label\"?: string;\n /** Screen-reader names for the panel's own controls. `aria-label` above already\n * covers the trigger; these three were hardcoded English inside the popover,\n * which a translating host had no way to reach. */\n labels?: CalculatorButtonLabels;\n}\n\n/** Keypad layout (4 columns). The final C/= row is rendered separately. `name` is\n * the key of the {@link CalculatorLabels} entry that names a non-digit key; a digit\n * is named by its own glyph. */\ntype Key =\n | { kind: \"ins\"; label: string; ins: string; accent?: boolean; name?: KeyName }\n | { kind: \"back\" };\n\ntype KeyName = \"plus\" | \"minus\" | \"times\" | \"divide\" | \"decimal\";\n\nconst KEYS: Key[] = [\n { kind: \"ins\", label: \"7\", ins: \"7\" },\n { kind: \"ins\", label: \"8\", ins: \"8\" },\n { kind: \"ins\", label: \"9\", ins: \"9\" },\n { kind: \"ins\", label: \"÷\", ins: \"÷\", accent: true, name: \"divide\" },\n { kind: \"ins\", label: \"4\", ins: \"4\" },\n { kind: \"ins\", label: \"5\", ins: \"5\" },\n { kind: \"ins\", label: \"6\", ins: \"6\" },\n { kind: \"ins\", label: \"×\", ins: \"×\", accent: true, name: \"times\" },\n { kind: \"ins\", label: \"1\", ins: \"1\" },\n { kind: \"ins\", label: \"2\", ins: \"2\" },\n { kind: \"ins\", label: \"3\", ins: \"3\" },\n { kind: \"ins\", label: \"−\", ins: \"−\", accent: true, name: \"minus\" },\n { kind: \"ins\", label: \"0\", ins: \"0\" },\n { kind: \"ins\", label: \".\", ins: \".\", name: \"decimal\" },\n { kind: \"back\" },\n { kind: \"ins\", label: \"+\", ins: \"+\", accent: true, name: \"plus\" },\n];\n\n// The kit's one focus frame (text-size §5). Until 0.34 the keys rang in `ring-strong` on\n// `focus:`, so a pointer click left a grey ring on the key it pressed (DOC-7).\nconst KEY_BASE = `flex h-9 items-center justify-center rounded-md text-sm font-medium transition-colors ${FOCUS_RING}`;\n// Two key families, two fills: digits sit on the inset surface and darken on\n// hover, operators sit a step down on `--bg-active` and lift toward that surface —\n// the same split `NumberPadSheet` uses for this keypad on a phone. The tokens\n// flip with the theme, so neither needs a `dark:` twin.\n//\n// 0.33 (docs/colour-roles-harmonization.md §12.2, §12.9): the digits hover onto\n// `--bg-active`, 1.11–1.18:1 from the key — `--bg-hover` is mixed against the card and\n// sat only 1.04:1 from the well, which in light is the page. The operators rest on\n// `--bg-active` rather than `--border`: More contrast steps the border until it is a\n// 3:1 LINE, and as a fill under the label that left 2.2–2.7:1.\nconst KEY_DIGIT = \"bg-surface-2 text-primary hover:bg-active\";\nconst KEY_ACCENT = \"bg-active text-secondary hover:bg-surface-2\";\n\nfunction seed(initial: string): string {\n const t = initial.trim();\n return t === \"-\" ? \"\" : t;\n}\n\nfunction CalculatorPanel({\n initial,\n onChange,\n labels,\n}: {\n initial: string;\n onChange: (value: string, expression?: string) => void;\n labels: CalculatorLabels;\n}) {\n const [expr, setExpr] = useState(() => seed(initial));\n const inputRef = useRef<HTMLInputElement>(null);\n // What the pad SHOWS. Normally the expression it holds — but when the host owns\n // the sign of the figure, the magnitude it hands back is not the whole number:\n // type 50 into a pad opened on an outflow and the host answers \"-50\". Derived\n // rather than stored, so there is no echo to guard against and a host that\n // ignores `onChange` entirely (a static `value`) still sees its own keystrokes:\n // the pad only defers when the host's text is character-for-character its own\n // last number with a minus in front.\n const host = splitLeadingSign(initial.trim());\n const text = host.sign === \"-\" && isBareAmount(expr) && host.rest === expr.trim() ? initial.trim() : expr;\n const result = evaluateExpression(text);\n\n // Focus the display on open so the user can type or hit Enter immediately.\n useEffect(() => {\n inputRef.current?.focus();\n }, []);\n\n // Update the host field whenever the expression resolves to a number; an\n // incomplete expression (e.g. \"12+\") simply leaves the field untouched. The\n // expression rides along with the result — see `onChange` above.\n const apply = (next: string) => {\n setExpr(next);\n const n = evaluateExpression(next);\n if (n !== null) onChange(formatResult(n), next);\n };\n\n const clearAll = () => {\n setExpr(\"\");\n onChange(\"\");\n };\n\n const equals = () => {\n if (result === null) return;\n const out = formatResult(result);\n setExpr(out);\n onChange(out, text);\n };\n\n return (\n <div className=\"space-y-2\">\n <input\n ref={inputRef}\n aria-label={labels.calculation}\n value={text}\n inputMode=\"decimal\"\n onChange={(e) => apply(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n equals();\n }\n }}\n // Arithmetic reads left to right in every script, and a calculator display\n // is right-aligned in every script too — so both stay physical, pinned\n // with `dir=\"ltr\"` rather than mirrored in a right-to-left form.\n dir=\"ltr\"\n className={cn(\"block w-full rounded-md border border-subtle bg-surface px-2 py-1.5 text-right font-mono text-sm text-primary focus:border-strong focus:ring-strong\", FIELD_TOUCH_TEXT)}\n />\n <div dir=\"ltr\" className=\"h-4 pr-1 text-right font-mono text-xs text-placeholder\">\n {result !== null && formatResult(result) !== text.trim() ? `= ${formatResult(result)}` : \"\"}\n </div>\n <div className=\"grid grid-cols-4 gap-1.5\">\n {KEYS.map((key, i) =>\n key.kind === \"back\" ? (\n <button\n key=\"back\"\n type=\"button\"\n aria-label={labels.backspace}\n onClick={() => apply(text.slice(0, -1))}\n className={cn(KEY_BASE, KEY_ACCENT)}\n >\n <Delete className=\"size-4\" />\n </button>\n ) : (\n <button\n key={`${key.ins}-${i}`}\n type=\"button\"\n aria-label={key.name ? labels[key.name] : undefined}\n onClick={() => apply(text + key.ins)}\n className={cn(KEY_BASE, key.accent ? KEY_ACCENT : KEY_DIGIT)}\n >\n {key.label}\n </button>\n ),\n )}\n <button\n type=\"button\"\n // \"C\" is a convention, not a name: read aloud it is the letter.\n aria-label={labels.clear}\n onClick={clearAll}\n className={cn(KEY_BASE, \"col-span-2\", KEY_ACCENT)}\n >\n C\n </button>\n <button\n type=\"button\"\n aria-label={labels.equals}\n onClick={equals}\n className={cn(\n KEY_BASE,\n // The one chip that inverts against the page. There is no hover token for\n // an inverted fill, so the hover is the chip mixed back toward the\n // surface — a step quieter in either theme, and still a colour, so\n // KEY_BASE's `transition-colors` carries it.\n \"col-span-2 bg-inverse text-inverse hover:bg-[color-mix(in_oklab,var(--bg-inverse)_88%,var(--bg-surface))]\",\n )}\n >\n =\n </button>\n </div>\n </div>\n );\n}\n\n/**\n * A calculator icon that opens a small keypad popover anchored to its host\n * field. Designed as a trailing-edge adornment: render it inside the field's\n * `relative` wrapper, positioned absolutely. The keypad seeds from the current\n * field value and writes evaluated results straight back through `onChange`.\n */\nexport function CalculatorButton({\n value,\n onChange,\n className,\n \"aria-label\": ariaLabel,\n labels: labelsProp,\n}: CalculatorButtonProps) {\n // prop > provider > English, with the name prop folded in as the `open` key it has\n // always been.\n const fromProps = useMemo(\n () => (ariaLabel === undefined ? labelsProp : { ...labelsProp, open: ariaLabel }),\n [ariaLabel, labelsProp],\n );\n const labels = useKitLabels(\"calculator\", DEFAULT_CALCULATOR_LABELS, fromProps);\n return (\n <Popover\n width=\"14rem\"\n labels={{ panel: labels.panel }}\n trigger={({ open, toggle, ref }) => (\n <button\n ref={ref}\n type=\"button\"\n tabIndex={-1}\n onClick={toggle}\n aria-label={labels.open}\n aria-expanded={open}\n className={cn(\n \"flex items-center justify-center text-placeholder transition-colors hover:text-secondary\",\n className,\n )}\n >\n <CalculatorIcon className=\"size-4\" />\n </button>\n )}\n >\n {() => <CalculatorPanel initial={value} onChange={onChange} labels={labels} />}\n </Popover>\n );\n}\n"],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AAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,QAAQ;AACV,GAA0B;AAGxB,QAAM,YAAY;AAAA,IAChB,MAAO,cAAc,SAAY,aAAa,EAAE,GAAG,YAAY,MAAM,UAAU;AAAA,IAC/E,CAAC,WAAW,UAAU;AAAA,EACxB;AACA,QAAM,SAAS,aAAa,cAAc,2BAA2B,SAAS;AAC9E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,QAAQ,EAAE,OAAO,OAAO,MAAM;AAAA,MAC9B,SAAS,CAAC,EAAE,MAAM,QAAQ,IAAI,MAC5B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,MAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS;AAAA,UACT,cAAY,OAAO;AAAA,UACnB,iBAAe;AAAA,UACf,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,UAEA,8BAAC,kBAAe,WAAU,UAAS;AAAA;AAAA,MACrC;AAAA,MAGD,gBAAM,oBAAC,mBAAgB,SAAS,OAAO,UAAoB,QAAgB;AAAA;AAAA,EAC9E;AAEJ;","names":[]}
@@ -1,39 +1,2 @@
1
- import * as core from "./chart-zoom-core.js";
2
1
  export { SharedXZoom } from "./chart-zoom-core.js";
3
2
  export type { ZoomAxes, ZoomAxesSetting, ZoomBinding, ZoomDrag, ZoomFitSeries, ZoomFitSource, ZoomRow, ZoomSelection, ZoomState, ZoomTarget, } from "./chart-zoom-core.js";
4
- /** @deprecated 0.34 — a series without `axis` is on the chart's single y axis, `"y"`;
5
- * removed in 0.35 (API-6b). */
6
- export declare const DEFAULT_Y_AXIS = "y";
7
- /** @deprecated 0.34 — SeriesChart's zoom, which reads it; removed in 0.35 (API-6b). */
8
- export declare const ZOOM_SQUARE_ENOUGH = 0.5;
9
- /** @deprecated 0.34 — SeriesChart's zoom, which reads it; removed in 0.35 (API-6b). */
10
- export declare const ZOOM_MIN_DRAG = 0.02;
11
- /** @deprecated 0.34 — SeriesChart's zoom, which reads a drag this way; removed in 0.35
12
- * (API-6b). */
13
- export declare const zoomAxesFor: typeof core.zoomAxesFor;
14
- /** @deprecated 0.34 — SeriesChart's zoom, which reads a drag this way; removed in 0.35
15
- * (API-6b). */
16
- export declare const selectionFromDrag: typeof core.selectionFromDrag;
17
- /** @deprecated 0.34 — SeriesChart fits its axes with it; removed in 0.35 (API-6b). */
18
- export declare const axisExtent: typeof core.axisExtent;
19
- /** @deprecated 0.34 — SeriesChart's zoom, which refits the axes a drag did not name;
20
- * removed in 0.35 (API-6b). */
21
- export declare const fitYToX: typeof core.fitYToX;
22
- /** @deprecated 0.34 — SeriesChart's zoom, which refits the axes a drag did not name;
23
- * removed in 0.35 (API-6b). */
24
- export declare const fitXToY: typeof core.fitXToY;
25
- /** @deprecated 0.34 — SeriesChart's zoom, which keeps its own state; removed in 0.35
26
- * (API-6b). */
27
- export declare const NO_ZOOM: core.ZoomState;
28
- /** @deprecated 0.34 — SeriesChart's zoom, which keeps its own state; removed in 0.35
29
- * (API-6b). */
30
- export declare const zoomAfter: typeof core.zoomAfter;
31
- /** @deprecated 0.34 — SeriesChart's zoom, which keeps its own state; removed in 0.35
32
- * (API-6b). */
33
- export declare const zoomDomains: typeof core.zoomDomains;
34
- /** @deprecated 0.34 — SeriesChart's `zoomAxes` prop, which says what its default is;
35
- * removed in 0.35 (API-6b). */
36
- export declare const defaultZoomAxes: typeof core.defaultZoomAxes;
37
- /** @deprecated 0.34 — SeriesChart, which is a chart wrapped in it, and SharedXZoom;
38
- * removed in 0.35 (API-6b). */
39
- export declare const withChartZoom: typeof core.withChartZoom;
@@ -1,33 +1,6 @@
1
1
  "use client";
2
- import * as core from "./chart-zoom-core.js";
3
2
  import { SharedXZoom } from "./chart-zoom-core.js";
4
- const DEFAULT_Y_AXIS = core.DEFAULT_Y_AXIS;
5
- const ZOOM_SQUARE_ENOUGH = core.ZOOM_SQUARE_ENOUGH;
6
- const ZOOM_MIN_DRAG = core.ZOOM_MIN_DRAG;
7
- const zoomAxesFor = core.zoomAxesFor;
8
- const selectionFromDrag = core.selectionFromDrag;
9
- const axisExtent = core.axisExtent;
10
- const fitYToX = core.fitYToX;
11
- const fitXToY = core.fitXToY;
12
- const NO_ZOOM = core.NO_ZOOM;
13
- const zoomAfter = core.zoomAfter;
14
- const zoomDomains = core.zoomDomains;
15
- const defaultZoomAxes = core.defaultZoomAxes;
16
- const withChartZoom = core.withChartZoom;
17
3
  export {
18
- DEFAULT_Y_AXIS,
19
- NO_ZOOM,
20
- SharedXZoom,
21
- ZOOM_MIN_DRAG,
22
- ZOOM_SQUARE_ENOUGH,
23
- axisExtent,
24
- defaultZoomAxes,
25
- fitXToY,
26
- fitYToX,
27
- selectionFromDrag,
28
- withChartZoom,
29
- zoomAfter,
30
- zoomAxesFor,
31
- zoomDomains
4
+ SharedXZoom
32
5
  };
33
6
  //# sourceMappingURL=chart-zoom.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/chart-zoom.tsx"],"sourcesContent":["// Drag-to-zoom for cartesian charts — the public face of ./chart-zoom-core, which holds\n// the HOC, the shared x window and the arithmetic (its header says how a drag picks its\n// axes). `SeriesChart` is how an app zooms; `SharedXZoom` gives a column of charts one x\n// window.\n//\n// 0.34 (refactor audit 2026-10, API-6b = MOD-10): the arithmetic and the HOC leave the\n// public surface in 0.35. They were exported because lenkbank's, later Kurvenschmiede's,\n// own tests used them; no file in any of the three apps names one today. The kit's own\n// modules import them from the core, so their removal is the block below.\nimport * as core from \"./chart-zoom-core\";\n\nexport { SharedXZoom } from \"./chart-zoom-core\";\nexport type {\n ZoomAxes,\n ZoomAxesSetting,\n ZoomBinding,\n ZoomDrag,\n ZoomFitSeries,\n ZoomFitSource,\n ZoomRow,\n ZoomSelection,\n ZoomState,\n ZoomTarget,\n} from \"./chart-zoom-core\";\n\n/* ── Deprecated 0.34, removed in 0.35 ─────────────────────────────────────\n * Each is the core's own value under its old public name: SeriesChart draws the zoom\n * these compute, and a chart's `zoomAxes` prop is what an app sets. */\n\n/** @deprecated 0.34 — a series without `axis` is on the chart's single y axis, `\"y\"`;\n * removed in 0.35 (API-6b). */\nexport const DEFAULT_Y_AXIS = core.DEFAULT_Y_AXIS;\n/** @deprecated 0.34 — SeriesChart's zoom, which reads it; removed in 0.35 (API-6b). */\nexport const ZOOM_SQUARE_ENOUGH = core.ZOOM_SQUARE_ENOUGH;\n/** @deprecated 0.34 — SeriesChart's zoom, which reads it; removed in 0.35 (API-6b). */\nexport const ZOOM_MIN_DRAG = core.ZOOM_MIN_DRAG;\n/** @deprecated 0.34 — SeriesChart's zoom, which reads a drag this way; removed in 0.35\n * (API-6b). */\nexport const zoomAxesFor = core.zoomAxesFor;\n/** @deprecated 0.34 — SeriesChart's zoom, which reads a drag this way; removed in 0.35\n * (API-6b). */\nexport const selectionFromDrag = core.selectionFromDrag;\n/** @deprecated 0.34 — SeriesChart fits its axes with it; removed in 0.35 (API-6b). */\nexport const axisExtent = core.axisExtent;\n/** @deprecated 0.34 — SeriesChart's zoom, which refits the axes a drag did not name;\n * removed in 0.35 (API-6b). */\nexport const fitYToX = core.fitYToX;\n/** @deprecated 0.34 — SeriesChart's zoom, which refits the axes a drag did not name;\n * removed in 0.35 (API-6b). */\nexport const fitXToY = core.fitXToY;\n/** @deprecated 0.34 — SeriesChart's zoom, which keeps its own state; removed in 0.35\n * (API-6b). */\nexport const NO_ZOOM = core.NO_ZOOM;\n/** @deprecated 0.34 — SeriesChart's zoom, which keeps its own state; removed in 0.35\n * (API-6b). */\nexport const zoomAfter = core.zoomAfter;\n/** @deprecated 0.34 — SeriesChart's zoom, which keeps its own state; removed in 0.35\n * (API-6b). */\nexport const zoomDomains = core.zoomDomains;\n/** @deprecated 0.34 — SeriesChart's `zoomAxes` prop, which says what its default is;\n * removed in 0.35 (API-6b). */\nexport const defaultZoomAxes = core.defaultZoomAxes;\n/** @deprecated 0.34 — SeriesChart, which is a chart wrapped in it, and SharedXZoom;\n * removed in 0.35 (API-6b). */\nexport const withChartZoom = core.withChartZoom;\n"],"mappings":";AASA,YAAY,UAAU;AAEtB,SAAS,mBAAmB;AAoBrB,MAAM,iBAAiB,KAAK;AAE5B,MAAM,qBAAqB,KAAK;AAEhC,MAAM,gBAAgB,KAAK;AAG3B,MAAM,cAAc,KAAK;AAGzB,MAAM,oBAAoB,KAAK;AAE/B,MAAM,aAAa,KAAK;AAGxB,MAAM,UAAU,KAAK;AAGrB,MAAM,UAAU,KAAK;AAGrB,MAAM,UAAU,KAAK;AAGrB,MAAM,YAAY,KAAK;AAGvB,MAAM,cAAc,KAAK;AAGzB,MAAM,kBAAkB,KAAK;AAG7B,MAAM,gBAAgB,KAAK;","names":[]}
1
+ {"version":3,"sources":["../../src/components/chart-zoom.tsx"],"sourcesContent":["// Drag-to-zoom for cartesian charts — the public face of ./chart-zoom-core, which holds\n// the HOC, the shared x window and the arithmetic (its header says how a drag picks its\n// axes). `SeriesChart` is how an app zooms; `SharedXZoom` gives a column of charts one x\n// window.\n//\n// Those two and the zoom's types are all that is public. The arithmetic and the HOC were\n// too until 0.35 (refactor audit 2026-10, API-6b = MOD-10; deprecated in 0.34): exported\n// because lenkbank's, later Kurvenschmiede's, own tests used them, and named by no file in\n// any of the three apps since. The kit's own modules import them from the core.\nexport { SharedXZoom } from \"./chart-zoom-core\";\nexport type {\n ZoomAxes,\n ZoomAxesSetting,\n ZoomBinding,\n ZoomDrag,\n ZoomFitSeries,\n ZoomFitSource,\n ZoomRow,\n ZoomSelection,\n ZoomState,\n ZoomTarget,\n} from \"./chart-zoom-core\";\n"],"mappings":";AASA,SAAS,mBAAmB;","names":[]}
@@ -15,10 +15,6 @@ export interface ChipInputLabels {
15
15
  duplicate: (value: string) => string;
16
16
  }
17
17
  export { DEFAULT_CHIP_INPUT_LABELS };
18
- /** @deprecated 0.34 — `useKitLabels("chipInput", DEFAULT_CHIP_INPUT_LABELS, labels)`, which
19
- * the provider reaches too, or ChipInput's own `labels`; removed in 0.35 (refactor audit
20
- * 2026-10, API-6a). A merge from before the provider, which no kit component calls. */
21
- export declare function resolveChipInputLabels(labels?: Partial<ChipInputLabels>): ChipInputLabels;
22
18
  /**
23
19
  * `onChange` is the field's own — the whole LIST, not a DOM event — so the wrapper
24
20
  * div's `onChange` is omitted rather than shadowed. `placeholder` is likewise this
@@ -10,9 +10,6 @@ import { FIELD_ERROR_CLASS, mergeRefs } from "./field-parts.js";
10
10
  import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
11
11
  import { DEFAULT_CHIP_INPUT_LABELS } from "./chip-labels.js";
12
12
  import { Chip } from "./chip.js";
13
- function resolveChipInputLabels(labels) {
14
- return labels ? { ...DEFAULT_CHIP_INPUT_LABELS, ...labels } : DEFAULT_CHIP_INPUT_LABELS;
15
- }
16
13
  function ChipInput({
17
14
  value,
18
15
  onChange,
@@ -218,7 +215,6 @@ function ChipInput({
218
215
  }
219
216
  export {
220
217
  ChipInput,
221
- DEFAULT_CHIP_INPUT_LABELS,
222
- resolveChipInputLabels
218
+ DEFAULT_CHIP_INPUT_LABELS
223
219
  };
224
220
  //# sourceMappingURL=chip-input.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/chip-input.tsx"],"sourcesContent":["// A field whose value is a list, entered as chips. Moved out of chip.tsx as it was\n// (MOD-9, refactor audit 2026-10). It renders `Chip`, so chip.tsx re-exports only its\n// TYPES: re-exporting `ChipInput` itself would make chip ⇄ chip-input a runtime cycle\n// (check:graph, import-x/no-cycle). The barrel exports this module.\nimport { useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { isImeEnter } from \"../lib/ime\";\nimport { claimEscape } from \"../hooks/use-dismiss\";\nimport { FIELD_INVALID, FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { FIELD_ERROR_CLASS, mergeRefs } from \"./field-parts\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_CHIP_INPUT_LABELS } from \"./chip-labels\";\nimport { Chip, type ChipSize, type ChipTone } from \"./chip\";\n\n/* ── ChipInput ────────────────────────────────────────────────────────────── */\n\nexport interface ChipInputLabels {\n /** Announced after a value is added. Receives the value. */\n added: (value: string) => string;\n /** Announced after a value is removed. Receives the value. */\n removed: (value: string) => string;\n /** Accessible name for each chip's dismiss button. */\n remove: string;\n /** Shown when `max` is reached. Receives the limit. */\n atLimit: (max: number) => string;\n /** Shown when a duplicate is rejected. Receives the value. */\n duplicate: (value: string) => string;\n}\n\n// Defined in ./chip-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_CHIP_INPUT_LABELS };\n\n/** @deprecated 0.34 — `useKitLabels(\"chipInput\", DEFAULT_CHIP_INPUT_LABELS, labels)`, which\n * the provider reaches too, or ChipInput's own `labels`; removed in 0.35 (refactor audit\n * 2026-10, API-6a). A merge from before the provider, which no kit component calls. */\nexport function resolveChipInputLabels(labels?: Partial<ChipInputLabels>): ChipInputLabels {\n return labels ? { ...DEFAULT_CHIP_INPUT_LABELS, ...labels } : DEFAULT_CHIP_INPUT_LABELS;\n}\n\n/**\n * `onChange` is the field's own — the whole LIST, not a DOM event — so the wrapper\n * div's `onChange` is omitted rather than shadowed. `placeholder` is likewise this\n * component's, forwarded to the inner `<input>`; the div has none of its own.\n */\nexport interface ChipInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\" | \"placeholder\" | \"children\"> {\n value: string[];\n onChange: (next: string[]) => void;\n placeholder?: string;\n /** Visible label, rendered above the field: a ReactNode, as on every kit field (a\n * string until 0.34, refactor audit 2026-10, API-9). Without one, name the field with\n * `aria-label`. */\n label?: ReactNode;\n /** Reject or rewrite a value on commit. Return a string to reject WITH that message. */\n validate?: (raw: string) => string | null;\n /** Characters that commit the current text, besides Enter. Default: comma. */\n separators?: string[];\n allowDuplicates?: boolean;\n max?: number;\n tone?: ChipTone;\n size?: ChipSize;\n disabled?: boolean;\n invalid?: boolean;\n /** Error text. Wires `aria-describedby` and implies `invalid`. */\n error?: ReactNode;\n labels?: LabelOverride<ChipInputLabels>;\n className?: string;\n /** The `<input>` the next value is typed into — the element that takes focus, which\n * react-hook-form's focus-on-error calls `focus()` on (API-3, refactor audit 2026-10).\n * Not the wrapper, which takes the rest of the props. */\n ref?: Ref<HTMLInputElement>;\n}\n\n/**\n * A field whose value is a LIST, entered as chips.\n *\n * The keyboard model is the whole component; the pills are the easy part. Per the WAI\n * pattern for a \"tag\" input:\n *\n * Enter, or any separator commit the typed text\n * Backspace on empty text move focus to the last chip (does NOT delete it)\n * ← → while on a chip move between chips, in reading order (mirrored in RTL)\n * Backspace / Delete remove the focused chip, focus its neighbour\n * Escape clear what is typed but keep the committed chips\n * paste splits on the separators, so a pasted CSV becomes chips\n *\n * The Backspace-on-empty behaviour is the one worth arguing about. Deleting immediately\n * is more common and is a trap: it is a destructive action with no feedback on a key\n * people hit by reflex, and the value it destroys may have taken a while to type. Moving\n * focus first makes the second Backspace a deliberate one, and it is what lets a\n * keyboard user reach a chip at all.\n */\nexport function ChipInput({\n value,\n onChange,\n placeholder,\n label,\n validate,\n separators = [\",\"],\n allowDuplicates = false,\n max,\n tone = \"neutral\",\n size = \"md\",\n disabled = false,\n invalid = false,\n error,\n labels,\n className,\n \"aria-label\": ariaLabelAttr,\n ref,\n ...rest\n}: ChipInputProps) {\n // `labels` over the provider's `chipInput` over English.\n const text = useKitLabels(\"chipInput\", DEFAULT_CHIP_INPUT_LABELS, labels);\n // A batch of pasted values is announced as one list, joined the way the language\n // joins a list in a sentence (\"a, b and c added\") — hence the long conjunction,\n // where a trigger's summary would use the narrow one.\n const locale = useKitLocale();\n const [draft, setDraft] = useState(\"\");\n const [message, setMessage] = useState(\"\");\n // The last refusal, shown under the field until the next edit. The live region alone\n // told only a screen-reader user why Enter did nothing; everyone else saw the text\n // simply stay put.\n const [rejected, setRejected] = useState<string | null>(null);\n const [focusedChip, setFocusedChip] = useState<number | null>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n // The field's own handle on its input (focus after a chip goes) and the caller's `ref`.\n const setInput = useMemo(() => mergeRefs(inputRef, ref), [ref]);\n const chipRefs = useRef<Array<HTMLElement | null>>([]);\n const id = useId();\n const listId = `${id}-list`;\n const errorId = `${id}-error`;\n const rejectedId = `${id}-rejected`;\n const isInvalid = invalid || !!error;\n const describedBy = [error ? errorId : null, rejected ? rejectedId : null]\n .filter(Boolean)\n .join(\" \");\n\n const focusChip = (index: number | null) => {\n setFocusedChip(index);\n if (index === null) inputRef.current?.focus();\n else chipRefs.current[index]?.focus();\n };\n\n /**\n * Try to add every candidate, as ONE change.\n *\n * Batched rather than looped for a reason that bites immediately: `commit` closes over\n * `value`, so calling it once per pasted item makes every call compute its result from\n * the list as it was BEFORE the paste, and each `onChange` overwrites the last. A\n * pasted \"one,two,three\" left only \"three\". Accumulating locally and emitting once is\n * also the correct behaviour for an undo stack — a paste is one action.\n */\n const commitMany = (raws: string[]): { added: string[]; rejection: string | null } => {\n const next = [...value];\n const added: string[] = [];\n let rejection: string | null = null;\n\n for (const raw of raws) {\n const candidate = raw.trim();\n if (!candidate) continue;\n if (max !== undefined && next.length >= max) {\n rejection ??= text.atLimit(max);\n break;\n }\n if (!allowDuplicates && next.includes(candidate)) {\n rejection ??= text.duplicate(candidate);\n continue;\n }\n const invalidReason = validate?.(candidate);\n if (invalidReason) {\n rejection ??= invalidReason;\n continue;\n }\n next.push(candidate);\n added.push(candidate);\n }\n\n if (added.length) onChange(next);\n // A rejection is the more useful thing to say: \"three added\" is obvious from the\n // chips appearing, whereas \"already in the list\" is the only sign of what did not.\n const addedList = new Intl.ListFormat(locale, { type: \"conjunction\", style: \"long\" });\n setMessage(rejection ?? (added.length ? text.added(addedList.format(added)) : \"\"));\n setRejected(rejection);\n return { added, rejection };\n };\n\n const commit = (raw: string): boolean => commitMany([raw]).added.length > 0;\n\n const removeAt = (index: number) => {\n const removed = value[index];\n onChange(value.filter((_, i) => i !== index));\n setMessage(text.removed(removed));\n setRejected(null);\n // Focus the neighbour that takes its place, or the input when the list empties —\n // dropping focus to <body> here is how a keyboard user loses the field entirely.\n const next = index >= value.length - 1 ? null : index;\n requestAnimationFrame(() => focusChip(value.length - 1 === 0 ? null : next));\n };\n\n const onInputKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n // The Enter that confirms an IME composition is the IME's: it commits no chip\n // and submits no form (BUG-9).\n if (isImeEnter(e)) return;\n // Only when there is something to commit: an empty Enter belongs to the form.\n if (draft.trim()) {\n e.preventDefault();\n if (commit(draft)) setDraft(\"\");\n }\n return;\n }\n if (separators.includes(e.key)) {\n e.preventDefault();\n if (commit(draft)) setDraft(\"\");\n return;\n }\n // Clearing the draft is this field's Escape, not a dialog's around it: claimed, so\n // the dialog stays — the same in a Modal and a FullBleedDialog, which read it\n // differently until 0.34 (Wave 2, DUP-1). With nothing typed the key goes on.\n if (e.key === \"Escape\" && draft) {\n claimEscape(e);\n setDraft(\"\");\n return;\n }\n if (e.key === \"Backspace\" && !draft && value.length) {\n e.preventDefault();\n focusChip(value.length - 1);\n }\n };\n\n const onChipKeyDown = (e: KeyboardEvent<HTMLElement>, index: number) => {\n if (e.key === \"Backspace\" || e.key === \"Delete\") {\n e.preventDefault();\n removeAt(index);\n return;\n }\n // ←/→ follow the reading direction, not DOM order: in RTL the previous chip is to\n // the RIGHT, and ArrowLeft moves on towards the input.\n const step = horizontalStep(e.key, e.currentTarget);\n if (step === -1 && index > 0) {\n e.preventDefault();\n focusChip(index - 1);\n return;\n }\n if (step === 1) {\n e.preventDefault();\n focusChip(index === value.length - 1 ? null : index + 1);\n return;\n }\n // Back to the input, a step inside the field: claimed like the draft's (DUP-1).\n if (e.key === \"Escape\") {\n claimEscape(e);\n focusChip(null);\n }\n };\n\n return (\n // The rest lands on the OUTER box — the thing a `data-tour` step or a test id\n // wants to point at — while the accessible name below goes on the `<input>`,\n // because that is what a screen-reader user actually lands in. Spreading the two\n // to the same element would have named a decorative wrapper and left the field\n // anonymous.\n <div {...rest} className={cn(\"space-y-1\", className)}>\n {label && (\n <label htmlFor={`${id}-input`} className=\"block text-sm text-secondary\">\n {label}\n </label>\n )}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- a\n pointer convenience that widens the input's hit area to the whole field; the\n keyboard path is the <input> itself, which is in the tab order. */}\n <div\n // `relative` so the live region below can be `sr-only` without escaping to the\n // initial containing block and inflating the document height.\n className={cn(\n \"relative flex flex-wrap items-center gap-1.5 rounded-md border border-subtle bg-surface px-2 py-1.5 shadow-sm\",\n \"focus-within:border-brand focus-within:ring-1 focus-within:ring-brand\",\n disabled && \"cursor-default bg-surface-2\",\n isInvalid && FIELD_INVALID,\n )}\n onClick={() => !disabled && inputRef.current?.focus()}\n >\n {/* `display: contents` on the wrappers so the chips participate in the field's\n own flex wrap rather than forming a nested row. The list semantics are\n restored with explicit roles, because `contents` removes the ul/li boxes from\n the accessibility tree in several engines. */}\n {/* eslint-disable-next-line jsx-a11y/no-redundant-roles -- NOT redundant here: the\n `contents` display below removes the ul and li boxes from the box tree, and\n several engines drop the list semantics with them. The explicit role is what\n puts \"list, 3 items\" back. */}\n <ul id={listId} role=\"list\" className=\"contents\">\n {value.map((v, i) => (\n <li key={`${v}-${i}`} role=\"presentation\" className=\"contents\">\n <Chip\n ref={(el: HTMLElement | null) => {\n chipRefs.current[i] = el;\n }}\n tone={tone}\n size={size}\n disabled={disabled}\n removeLabel={text.remove}\n onRemove={disabled ? undefined : () => removeAt(i)}\n // A ROVING tabIndex: only the focused chip is tabbable, so Tab leaves\n // the field instead of walking through every value in it — the reason a\n // list of twenty tags is otherwise a twenty-stop detour for a keyboard.\n tabIndex={focusedChip === i ? 0 : -1}\n role=\"listitem\"\n aria-label={v}\n onKeyDown={(e) => onChipKeyDown(e, i)}\n onFocus={() => setFocusedChip(i)}\n data-chip-index={i}\n >\n {v}\n </Chip>\n </li>\n ))}\n </ul>\n <input\n id={`${id}-input`}\n ref={setInput}\n value={draft}\n onChange={(e) => {\n setDraft(e.target.value);\n setMessage(\"\");\n setRejected(null);\n }}\n onKeyDown={onInputKeyDown}\n onBlur={() => {\n // Commit on blur: a value typed and then clicked away from is a value the\n // user meant to add, and losing it silently is the commonest complaint\n // about this pattern.\n if (draft.trim() && commit(draft)) setDraft(\"\");\n }}\n onPaste={(e) => {\n const pasted = e.clipboardData.getData(\"text\");\n const pattern = new RegExp(`[${separators.map((s) => `\\\\${s}`).join(\"\")}\\n\\r]`);\n if (!pattern.test(pasted)) return;\n e.preventDefault();\n if (commitMany(pasted.split(pattern)).added.length) setDraft(\"\");\n }}\n placeholder={value.length ? undefined : placeholder}\n disabled={disabled}\n // A visible `label` is already wired through `htmlFor`, so adding a name\n // here would give the field two.\n aria-label={label ? undefined : ariaLabelAttr}\n aria-describedby={describedBy || undefined}\n aria-invalid={isInvalid || !!rejected || undefined}\n // `w-0` with flex-1: without a width the browser's default input size (20\n // characters) became the field's minimum width and pushed it past a 240 px\n // phone at 150 % (0.32's screenshot run).\n className={cn(\"w-0 min-w-[6rem] flex-1 bg-transparent py-0.5 text-sm text-primary outline-none placeholder:text-placeholder disabled:cursor-default\", FIELD_TOUCH_TEXT)}\n />\n {/* Additions, removals and rejections move no focus, so nothing would announce\n them. `sr-only-fixed` rather than `sr-only`: this sits inside a consumer's\n markup and must not extend the document height. */}\n <span role=\"status\" aria-live=\"polite\" aria-atomic className=\"sr-only-fixed\">\n {message}\n </span>\n </div>\n {/* Every field's error type (DUP-8: these were `text-xs`); the root's `space-y-1`\n spaces them, so not the class's own `mt-1` as well. */}\n {error && (\n <p id={errorId} className={cn(FIELD_ERROR_CLASS, \"mt-0\")}>\n {error}\n </p>\n )}\n {rejected && (\n <p id={rejectedId} className={cn(FIELD_ERROR_CLASS, \"mt-0\")} data-chip-input-rejected=\"\">\n {rejected}\n </p>\n )}\n </div>\n );\n}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AAK,OAAO,KAAK,EAAG,UAAS,EAAE;AAAA,gBAChD;AAAA,gBACA,SAAS,CAAC,MAAM;AACd,wBAAM,SAAS,EAAE,cAAc,QAAQ,MAAM;AAC7C,wBAAM,UAAU,IAAI,OAAO,IAAI,WAAW,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC;AAAA,IAAO;AAC9E,sBAAI,CAAC,QAAQ,KAAK,MAAM,EAAG;AAC3B,oBAAE,eAAe;AACjB,sBAAI,WAAW,OAAO,MAAM,OAAO,CAAC,EAAE,MAAM,OAAQ,UAAS,EAAE;AAAA,gBACjE;AAAA,gBACA,aAAa,MAAM,SAAS,SAAY;AAAA,gBACxC;AAAA,gBAGA,cAAY,QAAQ,SAAY;AAAA,gBAChC,oBAAkB,eAAe;AAAA,gBACjC,gBAAc,aAAa,CAAC,CAAC,YAAY;AAAA,gBAIzC,WAAW,GAAG,wIAAwI,gBAAgB;AAAA;AAAA,YACxK;AAAA,YAIA,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,eAAW,MAAC,WAAU,iBAC1D,mBACH;AAAA;AAAA;AAAA,MACF;AAAA,MAGC,SACC,oBAAC,OAAE,IAAI,SAAS,WAAW,GAAG,mBAAmB,MAAM,GACpD,iBACH;AAAA,MAED,YACC,oBAAC,OAAE,IAAI,YAAY,WAAW,GAAG,mBAAmB,MAAM,GAAG,4BAAyB,IACnF,oBACH;AAAA,OAEJ;AAAA;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/chip-input.tsx"],"sourcesContent":["// A field whose value is a list, entered as chips. Moved out of chip.tsx as it was\n// (MOD-9, refactor audit 2026-10). It renders `Chip`, so chip.tsx re-exports only its\n// TYPES: re-exporting `ChipInput` itself would make chip ⇄ chip-input a runtime cycle\n// (check:graph, import-x/no-cycle). The barrel exports this module.\nimport { useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { isImeEnter } from \"../lib/ime\";\nimport { claimEscape } from \"../hooks/use-dismiss\";\nimport { FIELD_INVALID, FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { FIELD_ERROR_CLASS, mergeRefs } from \"./field-parts\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_CHIP_INPUT_LABELS } from \"./chip-labels\";\nimport { Chip, type ChipSize, type ChipTone } from \"./chip\";\n\n/* ── ChipInput ────────────────────────────────────────────────────────────── */\n\nexport interface ChipInputLabels {\n /** Announced after a value is added. Receives the value. */\n added: (value: string) => string;\n /** Announced after a value is removed. Receives the value. */\n removed: (value: string) => string;\n /** Accessible name for each chip's dismiss button. */\n remove: string;\n /** Shown when `max` is reached. Receives the limit. */\n atLimit: (max: number) => string;\n /** Shown when a duplicate is rejected. Receives the value. */\n duplicate: (value: string) => string;\n}\n\n// Defined in ./chip-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_CHIP_INPUT_LABELS };\n\n/**\n * `onChange` is the field's own — the whole LIST, not a DOM event — so the wrapper\n * div's `onChange` is omitted rather than shadowed. `placeholder` is likewise this\n * component's, forwarded to the inner `<input>`; the div has none of its own.\n */\nexport interface ChipInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\" | \"placeholder\" | \"children\"> {\n value: string[];\n onChange: (next: string[]) => void;\n placeholder?: string;\n /** Visible label, rendered above the field: a ReactNode, as on every kit field (a\n * string until 0.34, refactor audit 2026-10, API-9). Without one, name the field with\n * `aria-label`. */\n label?: ReactNode;\n /** Reject or rewrite a value on commit. Return a string to reject WITH that message. */\n validate?: (raw: string) => string | null;\n /** Characters that commit the current text, besides Enter. Default: comma. */\n separators?: string[];\n allowDuplicates?: boolean;\n max?: number;\n tone?: ChipTone;\n size?: ChipSize;\n disabled?: boolean;\n invalid?: boolean;\n /** Error text. Wires `aria-describedby` and implies `invalid`. */\n error?: ReactNode;\n labels?: LabelOverride<ChipInputLabels>;\n className?: string;\n /** The `<input>` the next value is typed into — the element that takes focus, which\n * react-hook-form's focus-on-error calls `focus()` on (API-3, refactor audit 2026-10).\n * Not the wrapper, which takes the rest of the props. */\n ref?: Ref<HTMLInputElement>;\n}\n\n/**\n * A field whose value is a LIST, entered as chips.\n *\n * The keyboard model is the whole component; the pills are the easy part. Per the WAI\n * pattern for a \"tag\" input:\n *\n * Enter, or any separator commit the typed text\n * Backspace on empty text move focus to the last chip (does NOT delete it)\n * ← → while on a chip move between chips, in reading order (mirrored in RTL)\n * Backspace / Delete remove the focused chip, focus its neighbour\n * Escape clear what is typed but keep the committed chips\n * paste splits on the separators, so a pasted CSV becomes chips\n *\n * The Backspace-on-empty behaviour is the one worth arguing about. Deleting immediately\n * is more common and is a trap: it is a destructive action with no feedback on a key\n * people hit by reflex, and the value it destroys may have taken a while to type. Moving\n * focus first makes the second Backspace a deliberate one, and it is what lets a\n * keyboard user reach a chip at all.\n */\nexport function ChipInput({\n value,\n onChange,\n placeholder,\n label,\n validate,\n separators = [\",\"],\n allowDuplicates = false,\n max,\n tone = \"neutral\",\n size = \"md\",\n disabled = false,\n invalid = false,\n error,\n labels,\n className,\n \"aria-label\": ariaLabelAttr,\n ref,\n ...rest\n}: ChipInputProps) {\n // `labels` over the provider's `chipInput` over English.\n const text = useKitLabels(\"chipInput\", DEFAULT_CHIP_INPUT_LABELS, labels);\n // A batch of pasted values is announced as one list, joined the way the language\n // joins a list in a sentence (\"a, b and c added\") — hence the long conjunction,\n // where a trigger's summary would use the narrow one.\n const locale = useKitLocale();\n const [draft, setDraft] = useState(\"\");\n const [message, setMessage] = useState(\"\");\n // The last refusal, shown under the field until the next edit. The live region alone\n // told only a screen-reader user why Enter did nothing; everyone else saw the text\n // simply stay put.\n const [rejected, setRejected] = useState<string | null>(null);\n const [focusedChip, setFocusedChip] = useState<number | null>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n // The field's own handle on its input (focus after a chip goes) and the caller's `ref`.\n const setInput = useMemo(() => mergeRefs(inputRef, ref), [ref]);\n const chipRefs = useRef<Array<HTMLElement | null>>([]);\n const id = useId();\n const listId = `${id}-list`;\n const errorId = `${id}-error`;\n const rejectedId = `${id}-rejected`;\n const isInvalid = invalid || !!error;\n const describedBy = [error ? errorId : null, rejected ? rejectedId : null]\n .filter(Boolean)\n .join(\" \");\n\n const focusChip = (index: number | null) => {\n setFocusedChip(index);\n if (index === null) inputRef.current?.focus();\n else chipRefs.current[index]?.focus();\n };\n\n /**\n * Try to add every candidate, as ONE change.\n *\n * Batched rather than looped for a reason that bites immediately: `commit` closes over\n * `value`, so calling it once per pasted item makes every call compute its result from\n * the list as it was BEFORE the paste, and each `onChange` overwrites the last. A\n * pasted \"one,two,three\" left only \"three\". Accumulating locally and emitting once is\n * also the correct behaviour for an undo stack — a paste is one action.\n */\n const commitMany = (raws: string[]): { added: string[]; rejection: string | null } => {\n const next = [...value];\n const added: string[] = [];\n let rejection: string | null = null;\n\n for (const raw of raws) {\n const candidate = raw.trim();\n if (!candidate) continue;\n if (max !== undefined && next.length >= max) {\n rejection ??= text.atLimit(max);\n break;\n }\n if (!allowDuplicates && next.includes(candidate)) {\n rejection ??= text.duplicate(candidate);\n continue;\n }\n const invalidReason = validate?.(candidate);\n if (invalidReason) {\n rejection ??= invalidReason;\n continue;\n }\n next.push(candidate);\n added.push(candidate);\n }\n\n if (added.length) onChange(next);\n // A rejection is the more useful thing to say: \"three added\" is obvious from the\n // chips appearing, whereas \"already in the list\" is the only sign of what did not.\n const addedList = new Intl.ListFormat(locale, { type: \"conjunction\", style: \"long\" });\n setMessage(rejection ?? (added.length ? text.added(addedList.format(added)) : \"\"));\n setRejected(rejection);\n return { added, rejection };\n };\n\n const commit = (raw: string): boolean => commitMany([raw]).added.length > 0;\n\n const removeAt = (index: number) => {\n const removed = value[index];\n onChange(value.filter((_, i) => i !== index));\n setMessage(text.removed(removed));\n setRejected(null);\n // Focus the neighbour that takes its place, or the input when the list empties —\n // dropping focus to <body> here is how a keyboard user loses the field entirely.\n const next = index >= value.length - 1 ? null : index;\n requestAnimationFrame(() => focusChip(value.length - 1 === 0 ? null : next));\n };\n\n const onInputKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n // The Enter that confirms an IME composition is the IME's: it commits no chip\n // and submits no form (BUG-9).\n if (isImeEnter(e)) return;\n // Only when there is something to commit: an empty Enter belongs to the form.\n if (draft.trim()) {\n e.preventDefault();\n if (commit(draft)) setDraft(\"\");\n }\n return;\n }\n if (separators.includes(e.key)) {\n e.preventDefault();\n if (commit(draft)) setDraft(\"\");\n return;\n }\n // Clearing the draft is this field's Escape, not a dialog's around it: claimed, so\n // the dialog stays — the same in a Modal and a FullBleedDialog, which read it\n // differently until 0.34 (Wave 2, DUP-1). With nothing typed the key goes on.\n if (e.key === \"Escape\" && draft) {\n claimEscape(e);\n setDraft(\"\");\n return;\n }\n if (e.key === \"Backspace\" && !draft && value.length) {\n e.preventDefault();\n focusChip(value.length - 1);\n }\n };\n\n const onChipKeyDown = (e: KeyboardEvent<HTMLElement>, index: number) => {\n if (e.key === \"Backspace\" || e.key === \"Delete\") {\n e.preventDefault();\n removeAt(index);\n return;\n }\n // ←/→ follow the reading direction, not DOM order: in RTL the previous chip is to\n // the RIGHT, and ArrowLeft moves on towards the input.\n const step = horizontalStep(e.key, e.currentTarget);\n if (step === -1 && index > 0) {\n e.preventDefault();\n focusChip(index - 1);\n return;\n }\n if (step === 1) {\n e.preventDefault();\n focusChip(index === value.length - 1 ? null : index + 1);\n return;\n }\n // Back to the input, a step inside the field: claimed like the draft's (DUP-1).\n if (e.key === \"Escape\") {\n claimEscape(e);\n focusChip(null);\n }\n };\n\n return (\n // The rest lands on the OUTER box — the thing a `data-tour` step or a test id\n // wants to point at — while the accessible name below goes on the `<input>`,\n // because that is what a screen-reader user actually lands in. Spreading the two\n // to the same element would have named a decorative wrapper and left the field\n // anonymous.\n <div {...rest} className={cn(\"space-y-1\", className)}>\n {label && (\n <label htmlFor={`${id}-input`} className=\"block text-sm text-secondary\">\n {label}\n </label>\n )}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- a\n pointer convenience that widens the input's hit area to the whole field; the\n keyboard path is the <input> itself, which is in the tab order. */}\n <div\n // `relative` so the live region below can be `sr-only` without escaping to the\n // initial containing block and inflating the document height.\n className={cn(\n \"relative flex flex-wrap items-center gap-1.5 rounded-md border border-subtle bg-surface px-2 py-1.5 shadow-sm\",\n \"focus-within:border-brand focus-within:ring-1 focus-within:ring-brand\",\n disabled && \"cursor-default bg-surface-2\",\n isInvalid && FIELD_INVALID,\n )}\n onClick={() => !disabled && inputRef.current?.focus()}\n >\n {/* `display: contents` on the wrappers so the chips participate in the field's\n own flex wrap rather than forming a nested row. The list semantics are\n restored with explicit roles, because `contents` removes the ul/li boxes from\n the accessibility tree in several engines. */}\n {/* eslint-disable-next-line jsx-a11y/no-redundant-roles -- NOT redundant here: the\n `contents` display below removes the ul and li boxes from the box tree, and\n several engines drop the list semantics with them. The explicit role is what\n puts \"list, 3 items\" back. */}\n <ul id={listId} role=\"list\" className=\"contents\">\n {value.map((v, i) => (\n <li key={`${v}-${i}`} role=\"presentation\" className=\"contents\">\n <Chip\n ref={(el: HTMLElement | null) => {\n chipRefs.current[i] = el;\n }}\n tone={tone}\n size={size}\n disabled={disabled}\n removeLabel={text.remove}\n onRemove={disabled ? undefined : () => removeAt(i)}\n // A ROVING tabIndex: only the focused chip is tabbable, so Tab leaves\n // the field instead of walking through every value in it — the reason a\n // list of twenty tags is otherwise a twenty-stop detour for a keyboard.\n tabIndex={focusedChip === i ? 0 : -1}\n role=\"listitem\"\n aria-label={v}\n onKeyDown={(e) => onChipKeyDown(e, i)}\n onFocus={() => setFocusedChip(i)}\n data-chip-index={i}\n >\n {v}\n </Chip>\n </li>\n ))}\n </ul>\n <input\n id={`${id}-input`}\n ref={setInput}\n value={draft}\n onChange={(e) => {\n setDraft(e.target.value);\n setMessage(\"\");\n setRejected(null);\n }}\n onKeyDown={onInputKeyDown}\n onBlur={() => {\n // Commit on blur: a value typed and then clicked away from is a value the\n // user meant to add, and losing it silently is the commonest complaint\n // about this pattern.\n if (draft.trim() && commit(draft)) setDraft(\"\");\n }}\n onPaste={(e) => {\n const pasted = e.clipboardData.getData(\"text\");\n const pattern = new RegExp(`[${separators.map((s) => `\\\\${s}`).join(\"\")}\\n\\r]`);\n if (!pattern.test(pasted)) return;\n e.preventDefault();\n if (commitMany(pasted.split(pattern)).added.length) setDraft(\"\");\n }}\n placeholder={value.length ? undefined : placeholder}\n disabled={disabled}\n // A visible `label` is already wired through `htmlFor`, so adding a name\n // here would give the field two.\n aria-label={label ? undefined : ariaLabelAttr}\n aria-describedby={describedBy || undefined}\n aria-invalid={isInvalid || !!rejected || undefined}\n // `w-0` with flex-1: without a width the browser's default input size (20\n // characters) became the field's minimum width and pushed it past a 240 px\n // phone at 150 % (0.32's screenshot run).\n className={cn(\"w-0 min-w-[6rem] flex-1 bg-transparent py-0.5 text-sm text-primary outline-none placeholder:text-placeholder disabled:cursor-default\", FIELD_TOUCH_TEXT)}\n />\n {/* Additions, removals and rejections move no focus, so nothing would announce\n them. `sr-only-fixed` rather than `sr-only`: this sits inside a consumer's\n markup and must not extend the document height. */}\n <span role=\"status\" aria-live=\"polite\" aria-atomic className=\"sr-only-fixed\">\n {message}\n </span>\n </div>\n {/* Every field's error type (DUP-8: these were `text-xs`); the root's `space-y-1`\n spaces them, so not the class's own `mt-1` as well. */}\n {error && (\n <p id={errorId} className={cn(FIELD_ERROR_CLASS, \"mt-0\")}>\n {error}\n </p>\n )}\n {rejected && (\n <p id={rejectedId} className={cn(FIELD_ERROR_CLASS, \"mt-0\")} data-chip-input-rejected=\"\">\n {rejected}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";AAoQQ,cAOF,YAPE;AAhQR,SAAS,OAAO,SAAS,QAAQ,gBAAgB;AAEjD,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CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC;AAAA,IAAO;AAC9E,sBAAI,CAAC,QAAQ,KAAK,MAAM,EAAG;AAC3B,oBAAE,eAAe;AACjB,sBAAI,WAAW,OAAO,MAAM,OAAO,CAAC,EAAE,MAAM,OAAQ,UAAS,EAAE;AAAA,gBACjE;AAAA,gBACA,aAAa,MAAM,SAAS,SAAY;AAAA,gBACxC;AAAA,gBAGA,cAAY,QAAQ,SAAY;AAAA,gBAChC,oBAAkB,eAAe;AAAA,gBACjC,gBAAc,aAAa,CAAC,CAAC,YAAY;AAAA,gBAIzC,WAAW,GAAG,wIAAwI,gBAAgB;AAAA;AAAA,YACxK;AAAA,YAIA,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,eAAW,MAAC,WAAU,iBAC1D,mBACH;AAAA;AAAA;AAAA,MACF;AAAA,MAGC,SACC,oBAAC,OAAE,IAAI,SAAS,WAAW,GAAG,mBAAmB,MAAM,GACpD,iBACH;AAAA,MAED,YACC,oBAAC,OAAE,IAAI,YAAY,WAAW,GAAG,mBAAmB,MAAM,GAAG,4BAAyB,IACnF,oBACH;AAAA,OAEJ;AAAA;AAEJ;","names":[]}
@@ -97,7 +97,7 @@ export interface ComboboxProps extends Omit<ComponentPropsWithoutRef<"div">, "id
97
97
  closeLabel?: string;
98
98
  /**
99
99
  * The phone sheet's heading — and, as a string, the dialog's accessible name — for a
100
- * field whose label is drawn by someone else: a form's `FormLabel` above it,
100
+ * field whose label is drawn by someone else: a bound field's label above it,
101
101
  * which `RhfTextCombobox` hands over here (0.24). Default: `label`. Without either, the
102
102
  * full-screen sheet opened untitled and unnamed, the one screen on a phone that has to
103
103
  * say what it is asking for (live #200).