@eifi1/ui-kit 0.21.0 → 0.23.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 (320) hide show
  1. package/README.md +42 -25
  2. package/dist/chart.d.ts +19 -14
  3. package/dist/components/account-chips.d.ts +10 -3
  4. package/dist/components/account-chips.js +5 -2
  5. package/dist/components/account-chips.js.map +1 -1
  6. package/dist/components/account-settings.d.ts +33 -2
  7. package/dist/components/account-settings.js +43 -21
  8. package/dist/components/account-settings.js.map +1 -1
  9. package/dist/components/amount-input.d.ts +53 -14
  10. package/dist/components/amount-input.js +17 -28
  11. package/dist/components/amount-input.js.map +1 -1
  12. package/dist/components/autocomplete.d.ts +29 -0
  13. package/dist/components/autocomplete.js +134 -104
  14. package/dist/components/autocomplete.js.map +1 -1
  15. package/dist/components/button-group.d.ts +19 -14
  16. package/dist/components/calculator.d.ts +19 -14
  17. package/dist/components/checkbox-group.d.ts +104 -0
  18. package/dist/components/checkbox-group.js +111 -0
  19. package/dist/components/checkbox-group.js.map +1 -0
  20. package/dist/components/checkbox.d.ts +19 -0
  21. package/dist/components/checkbox.js +30 -7
  22. package/dist/components/checkbox.js.map +1 -1
  23. package/dist/components/chip.d.ts +18 -0
  24. package/dist/components/chip.js +47 -10
  25. package/dist/components/chip.js.map +1 -1
  26. package/dist/components/column-mapper.d.ts +182 -0
  27. package/dist/components/column-mapper.js +375 -0
  28. package/dist/components/column-mapper.js.map +1 -0
  29. package/dist/components/combobox-core.d.ts +39 -2
  30. package/dist/components/combobox-core.js +29 -6
  31. package/dist/components/combobox-core.js.map +1 -1
  32. package/dist/components/combobox.d.ts +91 -2
  33. package/dist/components/combobox.js +454 -308
  34. package/dist/components/combobox.js.map +1 -1
  35. package/dist/components/confirm-dialog.d.ts +69 -161
  36. package/dist/components/confirm-dialog.js +7 -8
  37. package/dist/components/confirm-dialog.js.map +1 -1
  38. package/dist/components/copy-button.d.ts +16 -11
  39. package/dist/components/country-select.d.ts +167 -0
  40. package/dist/components/country-select.js +293 -0
  41. package/dist/components/country-select.js.map +1 -0
  42. package/dist/components/currency-select.d.ts +17 -1
  43. package/dist/components/currency-select.js +56 -23
  44. package/dist/components/currency-select.js.map +1 -1
  45. package/dist/components/danger-confirm.d.ts +69 -166
  46. package/dist/components/danger-confirm.js +144 -50
  47. package/dist/components/danger-confirm.js.map +1 -1
  48. package/dist/components/data-table-cells.d.ts +1 -2
  49. package/dist/components/data-table-filter-popover.d.ts +1 -2
  50. package/dist/components/data-table-filters.d.ts +1 -2
  51. package/dist/components/data-table-labels.d.ts +4 -97
  52. package/dist/components/data-table-labels.js +9 -1
  53. package/dist/components/data-table-labels.js.map +1 -1
  54. package/dist/components/data-table-pagination.d.ts +3 -1
  55. package/dist/components/data-table.d.ts +1 -2
  56. package/dist/components/data-table.js +98 -3
  57. package/dist/components/data-table.js.map +1 -1
  58. package/dist/components/date-picker.d.ts +66 -5
  59. package/dist/components/date-picker.js +378 -66
  60. package/dist/components/date-picker.js.map +1 -1
  61. package/dist/components/entity-combobox.d.ts +42 -1
  62. package/dist/components/entity-combobox.js +154 -113
  63. package/dist/components/entity-combobox.js.map +1 -1
  64. package/dist/components/facing-pair.d.ts +19 -14
  65. package/dist/components/field-parts.d.ts +224 -0
  66. package/dist/components/field-parts.js +156 -0
  67. package/dist/components/field-parts.js.map +1 -0
  68. package/dist/components/field-strip.d.ts +105 -0
  69. package/dist/components/field-strip.js +46 -0
  70. package/dist/components/field-strip.js.map +1 -0
  71. package/dist/components/file-button.d.ts +19 -14
  72. package/dist/components/file-button.js +13 -3
  73. package/dist/components/file-button.js.map +1 -1
  74. package/dist/components/file-dropzone.d.ts +41 -15
  75. package/dist/components/file-dropzone.js +57 -34
  76. package/dist/components/file-dropzone.js.map +1 -1
  77. package/dist/components/form-actions.d.ts +18 -13
  78. package/dist/components/form-actions.js +69 -5
  79. package/dist/components/form-actions.js.map +1 -1
  80. package/dist/components/iban-input.d.ts +69 -0
  81. package/dist/components/iban-input.js +125 -0
  82. package/dist/components/iban-input.js.map +1 -0
  83. package/dist/components/icon-picker.d.ts +21 -2
  84. package/dist/components/icon-picker.js +19 -4
  85. package/dist/components/icon-picker.js.map +1 -1
  86. package/dist/components/inline-edit-field.d.ts +167 -0
  87. package/dist/components/inline-edit-field.js +293 -0
  88. package/dist/components/inline-edit-field.js.map +1 -0
  89. package/dist/components/language-select.d.ts +130 -0
  90. package/dist/components/language-select.js +18 -0
  91. package/dist/components/language-select.js.map +1 -0
  92. package/dist/components/line-items.d.ts +25 -3
  93. package/dist/components/line-items.js +55 -46
  94. package/dist/components/line-items.js.map +1 -1
  95. package/dist/components/list.d.ts +25 -0
  96. package/dist/components/list.js +16 -5
  97. package/dist/components/list.js.map +1 -1
  98. package/dist/components/money-field.d.ts +32 -14
  99. package/dist/components/money-field.js.map +1 -1
  100. package/dist/components/month-picker.d.ts +52 -4
  101. package/dist/components/month-picker.js +291 -86
  102. package/dist/components/month-picker.js.map +1 -1
  103. package/dist/components/multi-entity-combobox.d.ts +26 -1
  104. package/dist/components/multi-entity-combobox.js +143 -102
  105. package/dist/components/multi-entity-combobox.js.map +1 -1
  106. package/dist/components/multi-select.d.ts +8 -1
  107. package/dist/components/multi-select.js +9 -4
  108. package/dist/components/multi-select.js.map +1 -1
  109. package/dist/components/number-field.d.ts +34 -19
  110. package/dist/components/number-field.js +6 -20
  111. package/dist/components/number-field.js.map +1 -1
  112. package/dist/components/number-input.d.ts +79 -19
  113. package/dist/components/number-input.js +90 -38
  114. package/dist/components/number-input.js.map +1 -1
  115. package/dist/components/numpad-sheet.d.ts +19 -14
  116. package/dist/components/one-time-code-input.d.ts +100 -0
  117. package/dist/components/one-time-code-input.js +137 -0
  118. package/dist/components/one-time-code-input.js.map +1 -0
  119. package/dist/components/phone-input.d.ts +69 -0
  120. package/dist/components/phone-input.js +171 -0
  121. package/dist/components/phone-input.js.map +1 -0
  122. package/dist/components/reauth-dialog.d.ts +2 -2
  123. package/dist/components/reauth-dialog.js +6 -8
  124. package/dist/components/reauth-dialog.js.map +1 -1
  125. package/dist/components/series-chart.d.ts +19 -14
  126. package/dist/components/settings-fields.d.ts +19 -14
  127. package/dist/components/share-card.d.ts +16 -11
  128. package/dist/components/sign-chip.d.ts +66 -0
  129. package/dist/components/sign-chip.js +39 -0
  130. package/dist/components/sign-chip.js.map +1 -0
  131. package/dist/components/swatch-picker.d.ts +43 -2
  132. package/dist/components/swatch-picker.js +80 -32
  133. package/dist/components/swatch-picker.js.map +1 -1
  134. package/dist/components/switch.d.ts +19 -0
  135. package/dist/components/switch.js +24 -6
  136. package/dist/components/switch.js.map +1 -1
  137. package/dist/components/text-link.d.ts +18 -13
  138. package/dist/components/tile-radio.d.ts +88 -13
  139. package/dist/components/tile-radio.js +28 -11
  140. package/dist/components/tile-radio.js.map +1 -1
  141. package/dist/components/time-input.d.ts +24 -15
  142. package/dist/components/time-input.js.map +1 -1
  143. package/dist/components/toggle-group.d.ts +47 -1
  144. package/dist/components/toggle-group.js +110 -69
  145. package/dist/components/toggle-group.js.map +1 -1
  146. package/dist/components/trigger-aria.d.ts +3 -0
  147. package/dist/components/trigger-aria.js +3 -1
  148. package/dist/components/trigger-aria.js.map +1 -1
  149. package/dist/components/ui.d.ts +16 -11
  150. package/dist/components/ui.js +284 -88
  151. package/dist/components/ui.js.map +1 -1
  152. package/dist/components/use-table-state.d.ts +1 -2
  153. package/dist/{data-table-3mi2R3so.d.ts → data-table-labels-B7OdnM0S.d.ts} +140 -3
  154. package/dist/data-table.d.ts +1 -2
  155. package/dist/data-table.js +2 -1
  156. package/dist/data-table.js.map +1 -1
  157. package/dist/feedback/feedback-attachment.d.ts +1 -1
  158. package/dist/feedback/feedback-attachment.js +348 -41
  159. package/dist/feedback/feedback-attachment.js.map +1 -1
  160. package/dist/feedback/feedback-dialog.d.ts +1 -1
  161. package/dist/feedback/feedback-dialog.js.map +1 -1
  162. package/dist/feedback/feedback-inbox.d.ts +3 -2
  163. package/dist/feedback/feedback-inbox.js.map +1 -1
  164. package/dist/feedback/feedback-thread.d.ts +68 -253
  165. package/dist/feedback/feedback-thread.js +46 -10
  166. package/dist/feedback/feedback-thread.js.map +1 -1
  167. package/dist/{kit-labels-D1J2_jyD.d.ts → feedback-BxeQVzwq.d.ts} +1206 -20
  168. package/dist/{feedback-attachment-WFiXJ8We.d.ts → feedback-attachment-fGAzZPf0.d.ts} +178 -11
  169. package/dist/feedback.d.ts +66 -2
  170. package/dist/hooks/use-file-drop.d.ts +19 -14
  171. package/dist/i18n/defaults.d.ts +19 -14
  172. package/dist/i18n/defaults.js +19 -2
  173. package/dist/i18n/defaults.js.map +1 -1
  174. package/dist/i18n/german.d.ts +19 -14
  175. package/dist/i18n/german.js +84 -5
  176. package/dist/i18n/german.js.map +1 -1
  177. package/dist/i18n/kit-labels.d.ts +15 -10
  178. package/dist/i18n/kit-labels.js +8 -2
  179. package/dist/i18n/kit-labels.js.map +1 -1
  180. package/dist/i18n/languages.d.ts +19 -14
  181. package/dist/i18n/locales/de-CH.d.ts +19 -14
  182. package/dist/i18n/locales/en.d.ts +19 -14
  183. package/dist/i18n/locales/en.js +16 -0
  184. package/dist/i18n/locales/en.js.map +1 -1
  185. package/dist/i18n/locales/es.d.ts +19 -14
  186. package/dist/i18n/locales/es.js +83 -5
  187. package/dist/i18n/locales/es.js.map +1 -1
  188. package/dist/i18n/locales/fr.d.ts +19 -14
  189. package/dist/i18n/locales/fr.js +82 -5
  190. package/dist/i18n/locales/fr.js.map +1 -1
  191. package/dist/i18n/locales/hu.d.ts +19 -14
  192. package/dist/i18n/locales/hu.js +85 -5
  193. package/dist/i18n/locales/hu.js.map +1 -1
  194. package/dist/i18n/locales/it.d.ts +19 -14
  195. package/dist/i18n/locales/it.js +84 -5
  196. package/dist/i18n/locales/it.js.map +1 -1
  197. package/dist/i18n/locales/zh.d.ts +19 -14
  198. package/dist/i18n/locales/zh.js +80 -5
  199. package/dist/i18n/locales/zh.js.map +1 -1
  200. package/dist/i18n/review.d.ts +19 -14
  201. package/dist/i18n/review.js +27 -1
  202. package/dist/i18n/review.js.map +1 -1
  203. package/dist/index.d.ts +21 -10
  204. package/dist/index.js +73 -2
  205. package/dist/index.js.map +1 -1
  206. package/dist/lib/column-mapping.d.ts +81 -0
  207. package/dist/lib/column-mapping.js +108 -0
  208. package/dist/lib/column-mapping.js.map +1 -0
  209. package/dist/lib/countries.d.ts +43 -0
  210. package/dist/lib/countries.js +39 -0
  211. package/dist/lib/countries.js.map +1 -0
  212. package/dist/lib/decimal-marks.d.ts +46 -0
  213. package/dist/lib/decimal-marks.js +40 -0
  214. package/dist/lib/decimal-marks.js.map +1 -0
  215. package/dist/lib/iban.d.ts +98 -0
  216. package/dist/lib/iban.js +154 -0
  217. package/dist/lib/iban.js.map +1 -0
  218. package/dist/lib/isin.d.ts +30 -0
  219. package/dist/lib/isin.js +36 -0
  220. package/dist/lib/isin.js.map +1 -0
  221. package/dist/lib/phone.d.ts +69 -0
  222. package/dist/lib/phone.js +121 -0
  223. package/dist/lib/phone.js.map +1 -0
  224. package/dist/lib/table-text.d.ts +109 -1
  225. package/dist/lib/table-text.js +122 -1
  226. package/dist/lib/table-text.js.map +1 -1
  227. package/dist/rhf/fields.d.ts +233 -18
  228. package/dist/rhf/fields.js +456 -3
  229. package/dist/rhf/fields.js.map +1 -1
  230. package/dist/rhf/form.d.ts +19 -14
  231. package/dist/rhf.d.ts +22 -15
  232. package/dist/rhf.js.map +1 -1
  233. package/dist/shell/app-shell.d.ts +18 -13
  234. package/dist/shell/top-bar-brand.d.ts +19 -14
  235. package/dist/shell/topbar-action-menu.d.ts +36 -3
  236. package/dist/shell/topbar-action-menu.js +74 -33
  237. package/dist/shell/topbar-action-menu.js.map +1 -1
  238. package/dist/shell.d.ts +18 -13
  239. package/dist/table-text.d.ts +1 -1
  240. package/dist/tour/tour.js +20 -24
  241. package/dist/tour/tour.js.map +1 -1
  242. package/dist/wizard/stepper-nav.d.ts +49 -16
  243. package/dist/wizard/stepper-nav.js +4 -0
  244. package/dist/wizard/stepper-nav.js.map +1 -1
  245. package/dist/wizard.d.ts +19 -14
  246. package/package.json +1 -1
  247. package/src/components/account-chips.tsx +17 -3
  248. package/src/components/account-settings.tsx +92 -26
  249. package/src/components/amount-input.tsx +68 -56
  250. package/src/components/autocomplete.tsx +198 -114
  251. package/src/components/checkbox-group.tsx +229 -0
  252. package/src/components/checkbox.tsx +72 -8
  253. package/src/components/chip.tsx +80 -10
  254. package/src/components/column-mapper.tsx +666 -0
  255. package/src/components/combobox-core.tsx +82 -9
  256. package/src/components/combobox.tsx +661 -340
  257. package/src/components/confirm-dialog.tsx +12 -8
  258. package/src/components/country-select.tsx +556 -0
  259. package/src/components/currency-select.tsx +109 -33
  260. package/src/components/danger-confirm.tsx +429 -82
  261. package/src/components/data-table-labels.ts +16 -1
  262. package/src/components/data-table.tsx +175 -6
  263. package/src/components/date-picker.tsx +595 -71
  264. package/src/components/entity-combobox.tsx +235 -124
  265. package/src/components/field-parts.tsx +403 -0
  266. package/src/components/field-strip.tsx +149 -0
  267. package/src/components/file-button.tsx +36 -3
  268. package/src/components/file-dropzone.tsx +106 -38
  269. package/src/components/form-actions.tsx +147 -6
  270. package/src/components/iban-input.tsx +231 -0
  271. package/src/components/icon-picker.tsx +47 -6
  272. package/src/components/inline-edit-field.tsx +533 -0
  273. package/src/components/language-select.tsx +78 -0
  274. package/src/components/line-items.tsx +35 -2
  275. package/src/components/list.tsx +55 -6
  276. package/src/components/money-field.tsx +13 -0
  277. package/src/components/month-picker.tsx +400 -63
  278. package/src/components/multi-entity-combobox.tsx +207 -120
  279. package/src/components/multi-select.tsx +80 -58
  280. package/src/components/number-field.tsx +28 -46
  281. package/src/components/number-input.tsx +210 -43
  282. package/src/components/one-time-code-input.tsx +288 -0
  283. package/src/components/phone-input.tsx +299 -0
  284. package/src/components/reauth-dialog.tsx +17 -18
  285. package/src/components/sign-chip.tsx +103 -0
  286. package/src/components/swatch-picker.tsx +143 -31
  287. package/src/components/switch.tsx +58 -7
  288. package/src/components/tile-radio.tsx +145 -29
  289. package/src/components/time-input.tsx +8 -1
  290. package/src/components/toggle-group.tsx +206 -73
  291. package/src/components/trigger-aria.ts +5 -0
  292. package/src/components/ui.tsx +479 -138
  293. package/src/data-table.ts +2 -1
  294. package/src/feedback/feedback-attachment.tsx +597 -46
  295. package/src/feedback/feedback-dialog.tsx +9 -3
  296. package/src/feedback/feedback-inbox.tsx +3 -2
  297. package/src/feedback/feedback-thread.tsx +113 -9
  298. package/src/i18n/defaults.ts +18 -1
  299. package/src/i18n/german.ts +89 -0
  300. package/src/i18n/kit-labels.tsx +82 -2
  301. package/src/i18n/locales/en.ts +36 -4
  302. package/src/i18n/locales/es.ts +87 -0
  303. package/src/i18n/locales/fr.ts +87 -0
  304. package/src/i18n/locales/hu.ts +83 -0
  305. package/src/i18n/locales/it.ts +88 -0
  306. package/src/i18n/locales/zh.ts +76 -0
  307. package/src/i18n/review.ts +26 -0
  308. package/src/index.ts +71 -3
  309. package/src/lib/column-mapping.ts +234 -0
  310. package/src/lib/countries.ts +91 -0
  311. package/src/lib/decimal-marks.ts +99 -0
  312. package/src/lib/iban.ts +171 -0
  313. package/src/lib/isin.ts +62 -0
  314. package/src/lib/phone.ts +211 -0
  315. package/src/lib/table-text.ts +271 -0
  316. package/src/rhf/fields.tsx +860 -9
  317. package/src/rhf.ts +3 -1
  318. package/src/shell/topbar-action-menu.tsx +134 -38
  319. package/src/tour/tour.tsx +66 -28
  320. package/src/wizard/stepper-nav.tsx +35 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/chip.tsx"],"sourcesContent":["import { forwardRef, isValidElement, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from \"react\";\nimport { Check, X } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { FIELD_INVALID } from \"./ui\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels, useKitLink, useKitLocale } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer } from \"./text-link\";\n\n/**\n * A chip: a compact pill carrying one value.\n *\n * Three jobs, deliberately one component. A chip can be inert (a tag on a row), a link\n * (a jump to a section), or a toggle (a filter that is on or off) — and the difference is\n * which prop you pass, not which component you pick. Keeping them together is what stops\n * an app growing three near-identical pills that drift apart; it is the shape this kit\n * already uses for `Button`, which is a link when it is given an href.\n *\n * A chip is not a `Button`. It is smaller, it is rounded to a pill, and it reads as a\n * VALUE rather than as an action — which matters because a row of eight buttons says\n * \"choose one of eight things to do\" and a row of eight chips says \"here are eight\n * things\". Using `Button` for both is the mistake this exists to prevent.\n */\n\nexport type ChipTone =\n | \"neutral\"\n | \"brand\"\n | \"danger\"\n | \"warning\"\n | \"success\"\n | \"info\"\n | \"income\"\n | \"expense\"\n | ChipHue;\n/**\n * Categorical hues (0.10.0): colour that says \"a different value\" and nothing more —\n * kastlan's status-badge.tsx paints ~15 enums in 9 Tailwind hues by hand. Four of those\n * nine are semantic and already tones (green = `success`, yellow = `warning`, red =\n * `danger`, gray = `neutral`); these five are the rest, each a `--hue-*` token triple\n * in tokens.css with a light and a dark value. Use a semantic tone when the value HAS a\n * meaning (overdue is `danger`), a hue when it only needs telling apart (sent vs\n * accepted vs invoiced).\n */\nexport type ChipHue = \"blue\" | \"indigo\" | \"purple\" | \"teal\" | \"orange\";\n/** `lg` is the 44px touch target (`min-h-11`) a phone surface wants; `md` is ~28px.\n * `xs` (0.10.0) is 11px type at `px-1.5` — keksdose's goal markers and budget-cell\n * badges, which sit inside a figure's line and must not make it taller. */\nexport type ChipSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n/**\n * How much of the tone the chip wears.\n *\n * - `soft` (default): the tinted surface every chip has had.\n * - `outline`: the tone's border and text on NO surface — keksdose's DEV badge in the\n * account menu and kastlan's 27 shadcn `variant=\"outline\"` badges, which sit on\n * coloured rows where a second tint would muddy the row.\n * - `solid`: the tone as a fill under contrasting text — the \"count\" pill (unread\n * messages, open tasks). It centres its content and sets figures tabular, so a\n * one-digit count is a round dot and \"9\" → \"10\" does not jiggle the row.\n * - `dot` (0.10.0): no pill at all — a dot in the tone's colour before plain text, for\n * a status in a dense list or a table column where eight tinted pills in a column\n * would outshout the figures beside them (kastlan's unit picker already draws its\n * UnitStatus this way, from a separate `dotColor` map).\n */\nexport type ChipVariant = \"soft\" | \"outline\" | \"solid\" | \"dot\";\n/** `pill` (default) is fully rounded; `square` has the small radius of a field or a\n * button — for a chip that sits in a table cell or beside square controls. */\nexport type ChipShape = \"pill\" | \"square\";\n\nconst TONE: Record<ChipTone, { idle: string; selected: string }> = {\n neutral: {\n idle: \"border-[var(--border)] bg-[var(--bg-surface-2)] text-[var(--text-secondary)]\",\n selected: \"border-[var(--border-strong)] bg-[var(--bg-active)] text-[var(--text-primary)]\",\n },\n brand: {\n idle: \"border-[var(--border)] bg-[var(--brand-bg)] text-[var(--brand-muted)]\",\n selected: \"border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-contrast)]\",\n },\n danger: {\n idle: \"border-[var(--danger-border)] bg-[var(--danger-bg)] text-[var(--danger)]\",\n selected: \"border-[var(--danger)] bg-[var(--danger)] text-[var(--danger-contrast)]\",\n },\n warning: {\n idle: \"border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning)]\",\n selected: \"border-[var(--warning)] bg-[var(--warning-bg)] text-[var(--warning)]\",\n },\n success: {\n idle: \"border-[var(--success-border)] bg-[var(--success-bg)] text-[var(--success)]\",\n selected: \"border-[var(--success)] bg-[var(--success-bg)] text-[var(--success)]\",\n },\n info: {\n idle: \"border-[var(--info-border)] bg-[var(--info-bg)] text-[var(--info)]\",\n selected: \"border-[var(--info)] bg-[var(--info-bg)] text-[var(--info)]\",\n },\n // The money pair (Keksdose's direction toggle). Only the TEXT and the BORDER carry\n // the tint, on the neutral chip's own surfaces: the money tokens are chosen for text\n // contrast, and a filled amber pill beside an amber figure reads as one smear.\n // `border-current` takes its hue from the text, so the two cannot drift apart.\n income: {\n idle: \"border-current/40 bg-[var(--bg-surface-2)] text-[var(--money-income)]\",\n selected: \"border-current bg-[var(--bg-active)] text-[var(--money-income)]\",\n },\n expense: {\n idle: \"border-current/40 bg-[var(--bg-surface-2)] text-[var(--money-expense)]\",\n selected: \"border-current bg-[var(--bg-active)] text-[var(--money-expense)]\",\n },\n // The categorical hues: the `info` recipe with its own token triple, so a hue chip\n // and a status chip in one row carry the same weight.\n blue: {\n idle: \"border-[var(--hue-blue-border)] bg-[var(--hue-blue-bg)] text-[var(--hue-blue)]\",\n selected: \"border-[var(--hue-blue)] bg-[var(--hue-blue-bg)] text-[var(--hue-blue)]\",\n },\n indigo: {\n idle: \"border-[var(--hue-indigo-border)] bg-[var(--hue-indigo-bg)] text-[var(--hue-indigo)]\",\n selected: \"border-[var(--hue-indigo)] bg-[var(--hue-indigo-bg)] text-[var(--hue-indigo)]\",\n },\n purple: {\n idle: \"border-[var(--hue-purple-border)] bg-[var(--hue-purple-bg)] text-[var(--hue-purple)]\",\n selected: \"border-[var(--hue-purple)] bg-[var(--hue-purple-bg)] text-[var(--hue-purple)]\",\n },\n teal: {\n idle: \"border-[var(--hue-teal-border)] bg-[var(--hue-teal-bg)] text-[var(--hue-teal)]\",\n selected: \"border-[var(--hue-teal)] bg-[var(--hue-teal-bg)] text-[var(--hue-teal)]\",\n },\n orange: {\n idle: \"border-[var(--hue-orange-border)] bg-[var(--hue-orange-bg)] text-[var(--hue-orange)]\",\n selected: \"border-[var(--hue-orange)] bg-[var(--hue-orange-bg)] text-[var(--hue-orange)]\",\n },\n};\n\n// `outline` idle looks: the tone's border and text, the surface left to whatever the\n// chip sits on. Selected still takes the tone's `selected` look (below), because an\n// outline toggle that stays an outline when on has no visible state.\nconst OUTLINE: Record<ChipTone, string> = {\n neutral: \"border-[var(--border-strong)] bg-transparent text-[var(--text-secondary)]\",\n brand: \"border-[var(--brand)] bg-transparent text-[var(--brand)]\",\n danger: \"border-[var(--danger-border)] bg-transparent text-[var(--danger)]\",\n warning: \"border-[var(--warning-border)] bg-transparent text-[var(--warning)]\",\n success: \"border-[var(--success-border)] bg-transparent text-[var(--success)]\",\n info: \"border-[var(--info-border)] bg-transparent text-[var(--info)]\",\n income: \"border-current/60 bg-transparent text-[var(--money-income)]\",\n expense: \"border-current/60 bg-transparent text-[var(--money-expense)]\",\n blue: \"border-[var(--hue-blue-border)] bg-transparent text-[var(--hue-blue)]\",\n indigo: \"border-[var(--hue-indigo-border)] bg-transparent text-[var(--hue-indigo)]\",\n purple: \"border-[var(--hue-purple-border)] bg-transparent text-[var(--hue-purple)]\",\n teal: \"border-[var(--hue-teal-border)] bg-transparent text-[var(--hue-teal)]\",\n orange: \"border-[var(--hue-orange-border)] bg-transparent text-[var(--hue-orange)]\",\n};\n\n// `solid`: the fill under its contrast pair. Only brand and danger have a declared\n// `-contrast` token; the other hues are 700s in the light theme and 300s in the dark\n// one, so `--text-inverse` (the surface colour) is the side of the pair that contrasts\n// with them in both — which is what the inverse token is for. The border goes\n// transparent rather than away, so a solid chip is exactly as tall as a soft one.\nconst SOLID: Record<ChipTone, string> = {\n neutral: \"border-transparent bg-[var(--bg-inverse)] text-[var(--text-inverse)]\",\n brand: \"border-transparent bg-[var(--brand)] text-[var(--brand-contrast)]\",\n danger: \"border-transparent bg-[var(--danger)] text-[var(--danger-contrast)]\",\n warning: \"border-transparent bg-[var(--warning)] text-[var(--text-inverse)]\",\n success: \"border-transparent bg-[var(--success)] text-[var(--text-inverse)]\",\n info: \"border-transparent bg-[var(--info)] text-[var(--text-inverse)]\",\n income: \"border-transparent bg-[var(--money-income)] text-[var(--text-inverse)]\",\n expense: \"border-transparent bg-[var(--money-expense)] text-[var(--text-inverse)]\",\n blue: \"border-transparent bg-[var(--hue-blue)] text-[var(--text-inverse)]\",\n indigo: \"border-transparent bg-[var(--hue-indigo)] text-[var(--text-inverse)]\",\n purple: \"border-transparent bg-[var(--hue-purple)] text-[var(--text-inverse)]\",\n teal: \"border-transparent bg-[var(--hue-teal)] text-[var(--text-inverse)]\",\n orange: \"border-transparent bg-[var(--hue-orange)] text-[var(--text-inverse)]\",\n};\n\n/** `dot`: the fill of the dot itself — the tone's strongest colour, which is the one\n * chosen to read on the page surface in both themes. Neutral takes the muted ink: a\n * grey dot is \"no particular state\", not a darker black. */\nconst DOT: Record<ChipTone, string> = {\n neutral: \"bg-[var(--text-muted)]\",\n brand: \"bg-[var(--brand)]\",\n danger: \"bg-[var(--danger)]\",\n warning: \"bg-[var(--warning)]\",\n success: \"bg-[var(--success)]\",\n info: \"bg-[var(--info)]\",\n income: \"bg-[var(--money-income)]\",\n expense: \"bg-[var(--money-expense)]\",\n blue: \"bg-[var(--hue-blue)]\",\n indigo: \"bg-[var(--hue-indigo)]\",\n purple: \"bg-[var(--hue-purple)]\",\n teal: \"bg-[var(--hue-teal)]\",\n orange: \"bg-[var(--hue-orange)]\",\n};\n\n/** Per size: the dot's diameter. */\nconst DOT_SIZE: Record<ChipSize, string> = { xs: \"size-1.5\", sm: \"size-2\", md: \"size-2\", lg: \"size-2.5\" };\n\n/** The status-badge type (`caps`): a size step down, heavier and tracked, because\n * capitals at body size shout and capitals untracked run together. Per size, so it\n * replaces the size's own `text-*` through tailwind-merge. */\nconst CAPS: Record<ChipSize, string> = {\n xs: \"text-[10px] font-semibold uppercase tracking-wider\",\n sm: \"text-[10px] font-semibold uppercase tracking-wider\",\n md: \"text-[11px] font-semibold uppercase tracking-wider\",\n lg: \"text-xs font-semibold uppercase tracking-wider\",\n};\n\nfunction surfaceOf(tone: ChipTone, variant: ChipVariant, selected: boolean | undefined): string {\n const palette = TONE[tone];\n if (variant === \"dot\") {\n // No surface and no border colour: the dot carries the tone, the text stays ink.\n // The border goes transparent rather than away, so a dot chip lines up with a pill.\n return selected\n ? \"border-transparent bg-transparent font-medium text-[var(--text-primary)]\"\n : \"border-transparent bg-transparent text-[var(--text-secondary)]\";\n }\n if (variant === \"solid\") {\n // A solid chip is already the strongest look there is, so \"on\" is a ring round it.\n return cn(SOLID[tone], selected && \"ring-2 ring-[var(--border-strong)] ring-offset-1 ring-offset-[var(--bg-surface)]\");\n }\n if (selected) return palette.selected;\n return variant === \"outline\" ? OUTLINE[tone] : palette.idle;\n}\n\n/** What {@link ChipProps.renderLink} is handed: everything the chip would have put on\n * its own `<a>`. Spread it onto your router's link, mapping `href` to what the link\n * calls it — `renderLink={({ href, ...p }) => <Link to={href} {...p} />}`. */\nexport interface ChipLinkProps {\n href: string;\n /** The chip's whole look — keep it, or the pill is a bare link. */\n className: string;\n children: ReactNode;\n /** The chip's forwarded ref. React 19 passes it to a function component as a prop. */\n ref?: Ref<HTMLAnchorElement>;\n \"aria-current\"?: \"true\";\n /**\n * The chip's `onClick`, when it was given one — spread it onto the link with the\n * rest. Carried here so a caller need not close over it twice: keksdose's admin pill\n * in the account menu closes the menu on the way to /admin (account-menu.tsx), and\n * with `onClick` on the Chip its `renderLink` stays the one-liner\n * `({ href, ...p }) => <Link to={href} {...p} />`.\n */\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n id?: string;\n title?: string;\n [key: `aria-${string}`]: string | boolean | number | undefined;\n [key: `data-${string}`]: unknown;\n}\n\n/**\n * `body` is the whole pill when the chip is ONE element. When a link or a button also has\n * a dismiss control, the pill is a wrapper holding two siblings (see the note on\n * {@link Chip}): `split` is then the interactive part's own padding — the full start\n * inset, a short end one before the ×; `tail` is the wrapper's end inset after the ×.\n */\nconst SIZE: Record<\n ChipSize,\n { body: string; split: string; tail: string; icon: string; remove: string }\n> = {\n xs: {\n body: \"gap-1 px-1.5 py-0 text-[11px] leading-4\",\n split: \"gap-1 ps-1.5 pe-0.5 py-0 text-[11px] leading-4\",\n tail: \"pe-1\",\n icon: \"size-3\",\n remove: \"size-2.5\",\n },\n sm: {\n body: \"gap-1 px-2 py-0.5 text-xs\",\n split: \"gap-1 ps-2 pe-1 py-0.5 text-xs\",\n tail: \"pe-1.5\",\n icon: \"size-3\",\n remove: \"size-3\",\n },\n md: {\n body: \"gap-1.5 px-2.5 py-1 text-sm\",\n split: \"gap-1.5 ps-2.5 pe-1.5 py-1 text-sm\",\n tail: \"pe-2\",\n icon: \"size-3.5\",\n remove: \"size-3.5\",\n },\n lg: {\n body: \"min-h-11 gap-2 px-4 py-2 text-sm\",\n split: \"min-h-11 gap-2 ps-4 pe-2 py-2 text-sm\",\n tail: \"min-h-11 pe-3.5\",\n icon: \"size-4\",\n remove: \"size-4\",\n },\n};\n\n/* ── Edge snapping (fractional device-pixel ratios) ──────────────────────────\n *\n * WHY. At a device-pixel ratio of 1.25 (a 125 % Windows display, or 125 % browser\n * zoom) Chrome snaps a box to whole CSS pixels and only then scales it, so a 1px\n * border is 1.25 device pixels wide and starts at a quarter-pixel phase that depends\n * on where the edge lands. A chip's left edge follows whatever stands before it, its\n * right edge follows its own text, so the two land on unrelated phases: one rasterises\n * as a crisp pixel, the other as a two-pixel smear at half strength — and a 60 %-alpha\n * border (`--danger-border`) makes the smeared side read as a THINNER line (keksdose\n * dev #576).\n *\n * WHAT FIXES IT. The two edges rasterise as mirror images exactly when their device\n * positions sum to a whole number: `(2·left + width) · dpr` integral, `left` being the\n * edge's snapped CSS x. Rounding the WIDTH alone to the ratio's grid (4px at 1.25)\n * makes the phases EQUAL, which is not the same thing: measured with keksdose's\n * playwright harness across every left phase at 1.25, width-only rounding mirrored the\n * edges at two of the four phases and left the other two as lopsided as before (mean\n * peak asymmetry 16.5, worse than the unsnapped 10.9 a random width gets by luck); the\n * position-aware width below took it to 0 at every phase. Inset rings, whole-pixel\n * starts, compositing hints and fractional border widths were measured by keksdose\n * and do not help — Chrome rounds a sub-pixel border back up to 1px.\n *\n * So the fix needs the chip's position, which is why it is opt-in (`snapEdges`): it\n * reads layout. Cheaply — every snapped chip on the page shares one ResizeObserver,\n * one `resize` listener and one resolution media query, and a pass is batched into a\n * frame as read-all / write-all, not a forced layout per chip. At an integer ratio,\n * and at a half one (1.5, 2.5: grid 2 — measured symmetric already, both edges a\n * pixel and a half on the same pattern), there is nothing to fix and a pass\n * writes nothing.\n */\n\n/** The smallest whole CSS-pixel count `n` with `n × dpr` whole — 4 at 1.25, 2 at 1.5,\n * 1 at an integer ratio. 0 for a ratio no step up to 4px fits (110 % zoom wants 10px;\n * a chip growing by up to 9px is a layout change, not a hairline fix). */\nfunction chipEdgeGrid(dpr: number): number {\n for (let n = 1; n <= 4; n++) if (Math.abs(n * dpr - Math.round(n * dpr)) < 1e-3) return n;\n return 0;\n}\n\n/**\n * The width (whole CSS px, at least `natural`) that mirrors a box's two edges at\n * `dpr`, for a box whose left edge sits at CSS x `left`. `natural` back when the ratio\n * needs nothing.\n */\nfunction snappedChipEdgeWidth(natural: number, left: number, dpr: number): number {\n const n = chipEdgeGrid(dpr);\n if (n <= 2) return natural;\n const l = Math.round(left);\n // A hair under a whole pixel is that pixel: 59.999 is a 60px chip, not a 61px one.\n let w = Math.ceil(natural - 0.01);\n while ((((2 * l + w) % n) + n) % n !== 0) w++;\n return w;\n}\n\nconst snapped = new Set<HTMLElement>();\n/** The min-width each chip was given by a pass — so a pass only ever clears its own. */\nconst written = new WeakMap<HTMLElement, string>();\nlet snapFrame = 0;\nlet snapObserver: ResizeObserver | null = null;\nlet ratioQuery: MediaQueryList | null = null;\n\nfunction clearOwn(el: HTMLElement) {\n const own = written.get(el);\n if (own !== undefined && el.style.minWidth === own) el.style.minWidth = \"\";\n written.delete(el);\n}\n\n/**\n * Re-snap every chip rendered with `snapEdges`, now. The kit already re-snaps when a\n * chip renders, resizes, or the window or the ratio changes; call this after moving\n * chips some other way (a side panel sliding in beside a table of status chips),\n * since a move is not something an observer can see.\n */\nexport function refreshChipEdges(): void {\n if (snapFrame) {\n cancelAnimationFrame(snapFrame);\n snapFrame = 0;\n }\n if (typeof window === \"undefined\" || !snapped.size) return;\n const dpr = window.devicePixelRatio || 1;\n const els = [...snapped];\n // Write: back to the natural width, so what is read below is the chip, not our pin.\n for (const el of els) clearOwn(el);\n const n = chipEdgeGrid(dpr);\n if (n <= 2) return;\n // A chip whose own end decides where it starts (RTL, `justify-end`) moves when it\n // grows, so a pass re-reads what it wrote and steps on by a pixel until the edges\n // agree — `n` steps cover every residue. Each pass is ONE layout for every chip\n // together. A chip that never agrees (a centred one moves both edges at once) is\n // given its natural width back rather than kept wider for nothing.\n let pending = els;\n for (let pass = 0; pass <= n && pending.length; pass++) {\n const reads = pending.map((el) => {\n const r = el.getBoundingClientRect();\n const label = el.querySelector<HTMLElement>(\".truncate\");\n // Not laid out (a hidden ancestor, jsdom), or truncated at its container's edge,\n // where a wider chip would overflow: leave it alone.\n if (!r.width || (label && label.scrollWidth > label.clientWidth)) return null;\n const width = Math.round(r.width * 64) / 64;\n const target = snappedChipEdgeWidth(width, r.left + window.scrollX, dpr);\n return target === width ? null : target;\n });\n const next: HTMLElement[] = [];\n pending.forEach((el, i) => {\n const target = reads[i];\n if (target == null) return;\n if (pass === n) {\n clearOwn(el);\n return;\n }\n const own = written.get(el);\n const value = `${pass > 0 && own !== undefined ? parseFloat(own) + 1 : target}px`;\n el.style.minWidth = value;\n written.set(el, value);\n next.push(el);\n });\n pending = next;\n }\n}\n\nfunction scheduleChipEdges() {\n if (snapFrame || typeof requestAnimationFrame === \"undefined\") return;\n snapFrame = requestAnimationFrame(() => {\n snapFrame = 0;\n refreshChipEdges();\n });\n}\n\n/** The resolution query for the CURRENT ratio: it stops matching when the ratio\n * changes (a window dragged to another display), which a `resize` need not fire. */\nfunction watchRatio() {\n ratioQuery?.removeEventListener(\"change\", onRatioChange);\n ratioQuery =\n typeof window.matchMedia === \"function\"\n ? window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`)\n : null;\n ratioQuery?.addEventListener(\"change\", onRatioChange);\n}\n\nfunction onRatioChange() {\n watchRatio();\n scheduleChipEdges();\n}\n\nfunction registerSnap(el: HTMLElement) {\n if (snapped.has(el)) return;\n if (!snapped.size) {\n if (typeof ResizeObserver !== \"undefined\") snapObserver = new ResizeObserver(scheduleChipEdges);\n window.addEventListener(\"resize\", scheduleChipEdges);\n watchRatio();\n }\n snapped.add(el);\n snapObserver?.observe(el);\n scheduleChipEdges();\n}\n\nfunction unregisterSnap(el: HTMLElement) {\n if (!snapped.delete(el)) return;\n snapObserver?.unobserve(el);\n clearOwn(el);\n if (snapped.size) return;\n snapObserver?.disconnect();\n snapObserver = null;\n window.removeEventListener(\"resize\", scheduleChipEdges);\n ratioQuery?.removeEventListener(\"change\", onRatioChange);\n ratioQuery = null;\n}\n\n/** The ref a chip hangs on its visible pill, plus a re-snap after every render (its\n * label or its neighbours may have changed). */\nfunction useSnapEdges(on: boolean) {\n const node = useRef<HTMLElement | null>(null);\n const ref = useCallback(\n (el: HTMLElement | null) => {\n if (el === node.current) return;\n const prev = node.current;\n node.current = el;\n // React detaches and re-attaches a ref whose callback changed identity (a\n // consumer's inline ref) — the same element, a moment apart. Unregistering on\n // the detach would clear the pin and paint one frame unsnapped, so the drop\n // waits a microtask and is skipped if the element came straight back.\n if (prev) queueMicrotask(() => node.current !== prev && unregisterSnap(prev));\n if (el && on) registerSnap(el);\n },\n [on],\n );\n useLayoutEffect(() => {\n const el = node.current;\n if (!el) return;\n if (on) {\n registerSnap(el);\n scheduleChipEdges();\n } else unregisterSnap(el);\n });\n return ref;\n}\n\nfunction assignRef<T>(target: Ref<T> | undefined, value: T | null) {\n if (typeof target === \"function\") target(value);\n else if (target) (target as { current: T | null }).current = value;\n}\n\nconst CHIP_PILL = \"inline-flex max-w-full items-center rounded-full border transition-colors\";\n// `focus-visible`, not `focus`: a chip commonly receives focus programmatically (the\n// ChipInput moves focus onto one after a removal) and a ring that appears on a\n// pointer click reads as a stuck selection.\nconst CHIP_RING =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)]\";\nconst CHIP_BASE = `${CHIP_PILL} ${CHIP_RING}`;\n\ninterface ChipBaseProps {\n children: ReactNode;\n tone?: ChipTone;\n size?: ChipSize;\n /** See {@link ChipVariant}. Default `soft`. */\n variant?: ChipVariant;\n /** See {@link ChipShape}. Default `pill`. */\n shape?: ChipShape;\n /**\n * The uppercase, tracked \"status badge\" type — keksdose's ~25 PAID / DRAFT /\n * OVERDUE / ADMIN badges, each spelling `uppercase tracking-wide text-[10px]` by\n * hand. A flag rather than a fourth `variant` because it is TYPE, not surface: a\n * status badge is soft, outlined or solid as the row needs, and a `variant=\"tag\"`\n * would have had to pick one. Screen readers read the text as written, not as\n * drawn, so write it in normal case.\n */\n caps?: boolean;\n /**\n * The leading glyph: a lucide component (`icon={Check}`, drawn at the chip's size), or\n * — since 0.15.4 — a ready element (`icon={<Check className=\"text-[var(--success)]\" />}`)\n * for a glyph whose colour or stroke carries a state; it is sized to the same box\n * (keksdose live #358 built that slot by hand inside `children`).\n */\n icon?: LucideIcon | ReactElement;\n /**\n * Marks the chip as the current one — `aria-current` on a link, `aria-pressed` on a\n * toggle.\n *\n * On an ON/OFF toggle, keep the LABEL the same in both states and let `selected`\n * carry the state. A label that flips with it (\"Skip this month\" / \"Ask again this\n * month\") is announced together with \"pressed\", and then says the opposite of what\n * it does.\n *\n * A control that switches between two NAMED states (outflow ⇄ inflow) is not a\n * toggle but an ACTION button: leave `selected` out, let the visible label and the\n * tone follow the state (\"− Outflow\" / \"+ Inflow\"), and name the action in\n * `aria-label` (\"Direction: outflow — tap for inflow\"). Without `selected` the chip\n * reports no pressed state at all. A fixed label there contradicts the figure beside\n * it — \"+ Outflow\" in green next to an inflow (keksdose #417).\n */\n selected?: boolean;\n /**\n * Checkbox mode (0.10.0), for a toggle chip (`onClick` + `selected`): a small box\n * at the start that shows a tick when `selected`, and the button reports\n * `role=\"checkbox\"` + `aria-checked` instead of `aria-pressed`. For a set of\n * include/exclude choices where \"on\" must read as TICKED, not merely tinted —\n * keksdose's add-group-card (the \"which categories come along\" pills), which put a\n * real `<Checkbox>` inside a `<label>` pill by hand. The box is drawn in both\n * states so ticking one never shifts its label.\n */\n checkbox?: boolean;\n /** Renders a dismiss affordance. Works alongside `href`/`onClick` — see the note below. */\n onRemove?: () => void;\n /** Accessible name for the dismiss button. Default: `common.remove` from the\n * {@link UiKitProvider}, else \"Remove\". */\n removeLabel?: string;\n /** Disables the × ONLY — the chip itself stays a working link or toggle. For the\n * value that may not be removed right now (the last filter of a required set, a\n * tag the user may read but not edit) where `disabled` would also kill the chip's\n * own action. */\n removeDisabled?: boolean;\n disabled?: boolean;\n className?: string;\n /**\n * Roving focus, for a container that manages a row of chips (see {@link ChipInput}).\n * A chip with no `href`/`onClick` is inert and unfocusable by default; give it a\n * `tabIndex` and a `role` and it becomes the thing arrow keys move between.\n */\n tabIndex?: number;\n role?: string;\n onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;\n onFocus?: () => void;\n /** Accessible name, when the visible text is not the whole story. */\n \"aria-label\"?: string;\n /** Any other ARIA attribute — `aria-describedby`, `aria-expanded`, `aria-controls`,\n * `aria-haspopup` — reaches the chip's interactive element. */\n [key: `aria-${string}`]: string | boolean | number | undefined;\n /** A test id, a `data-tour` anchor, or any other data attribute. */\n [key: `data-${string}`]: unknown;\n id?: string;\n /** A native tooltip. For anything a user must read, prefer the kit's `Tooltip`. */\n title?: string;\n /**\n * Even hairlines on fractional-ratio displays (0.18.0). At a device-pixel ratio of\n * 1.25 — a 125 % Windows display, or 125 % zoom — Chrome draws a chip's two 1px\n * side borders on different sub-pixel phases, one crisp and one a half-strength\n * smear that reads as a thinner line (worst on the 60 %-alpha `danger` border).\n * `snapEdges` widens the chip by under 4px, from where it sits, so the two edges\n * rasterise as mirror images, and centres its content in the extra.\n *\n * Off by default: it reads the chip's position (batched for every snapped chip into\n * one pass a frame, through one shared observer), and the fix is only as fresh as the\n * last pass — it re-snaps on render, resize, zoom and ratio change, but not when\n * something else moves the chip; call {@link refreshChipEdges} then. At an integer\n * ratio, and at 1.5, it writes nothing. Turn it on for status chips that sit in a\n * column and are compared side by side; a chip with no visible border (`dot`) has\n * nothing to snap.\n */\n snapEdges?: boolean;\n}\n\n/**\n * A chip is a link OR a button, never both — so the types say so. Before 0.7.0 both were\n * accepted and `onClick` was silently dropped whenever `href` was set. A LINK may still\n * run code on its way (close the menu it sits in): that is an `onClick` typed for the\n * anchor, on the link shape, and the pill stays a link — no `aria-pressed`, no button.\n * That shape wants a definite `href` string, so a bare `onClick` is always the\n * button's, with a button's event.\n */\nexport type ChipProps = ChipBaseProps &\n (\n | {\n /** Renders the chip as a link. */\n href?: string;\n onClick?: never;\n /**\n * Renders the link for `href` — pass your router's `<Link>` here, since a\n * plain `<a>` reloads a single-page app (keksdose's account-menu admin pill).\n * Default: the `<UiKitProvider linkComponent>`, then `<a>`. Ignored without\n * `href`.\n *\n * A render function rather than an `as={Link}`, for three reasons. It is the\n * API `StatTile` already has (`renderLink`), so a consumer learns it once.\n * Router links do not take `href` — react-router's takes `to` — so an `as`\n * would either have to pass props through untyped or teach the kit about one\n * router; here the caller maps `href` onto its own link in one line, fully\n * typed. And it keeps `href` as THE link prop, which is what the `href` /\n * `onClick` exclusion below is typed on: the pill is a link because it has an\n * href, whichever element draws it.\n */\n renderLink?: (props: ChipLinkProps) => ReactElement;\n }\n | {\n /** The link shape again, with an `onClick`. `href` is a required string here,\n * which is what lets TypeScript tell this shape from the button's: a bare\n * `onClick` can only be the button's, and keeps its button event. */\n href: string;\n /** Runs on the link's click, before the navigation — keksdose's admin pill\n * closes the account menu with it. Reaches a `renderLink` link as\n * {@link ChipLinkProps.onClick}. Not called on a disabled chip, which renders\n * no link. */\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n /** See the link shape above. */\n renderLink?: (props: ChipLinkProps) => ReactElement;\n }\n | {\n href?: never;\n renderLink?: never;\n /** Renders the chip as a toggle button. Mutually exclusive with `href`. Receives\n * the click, so a chip inside a clickable row can `stopPropagation()`. */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void;\n }\n );\n\n/**\n * Note on `onRemove` with `href`/`onClick`: a button cannot be nested inside a button or\n * a link, so when both are present the chip renders a wrapper holding TWO siblings — the\n * interactive body and the dismiss control. The WRAPPER is the visual pill (border, tone,\n * `className`) and the two sit inside it, so the × reads as part of the chip; the body's\n * focus ring is drawn on the body alone, and `ref`, `id` and the ARIA props still reach\n * the body — the interactive element.\n */\nexport const Chip = forwardRef<HTMLElement, ChipProps>(function Chip(\n {\n children,\n tone = \"neutral\",\n size = \"md\",\n variant = \"soft\",\n shape = \"pill\",\n caps = false,\n icon: Icon,\n selected,\n checkbox = false,\n href,\n renderLink,\n onClick,\n onRemove,\n removeLabel,\n removeDisabled = false,\n disabled = false,\n className,\n tabIndex,\n role,\n onKeyDown,\n onFocus,\n snapEdges = false,\n ...rest\n },\n ref,\n) {\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS, { remove: removeLabel });\n const kitLink = useKitLink();\n const s = SIZE[size];\n const interactive = !!href || !!onClick;\n // One radius for every rounded piece — the pill, the body inside a split pill, the ×\n // — so a square chip has no round focus ring inside it.\n const radius =\n shape === \"square\" ? (size === \"sm\" || size === \"xs\" ? \"rounded\" : \"rounded-md\") : \"rounded-full\";\n const dot = variant === \"dot\";\n const type = cn(caps && CAPS[size], variant === \"solid\" && \"justify-center tabular-nums\");\n const surface = cn(\n surfaceOf(tone, variant, selected),\n disabled && \"cursor-default opacity-50\",\n );\n const snap = snapEdges && !dot;\n const snapRef = useSnapEdges(snap);\n // The visible pill carries the snap: the whole chip, or the wrapper of a split one\n // (whose body gets the forwarded ref instead).\n const ownRef = useCallback(\n (el: HTMLElement | null) => {\n snapRef(el);\n assignRef(ref, el);\n },\n [snapRef, ref],\n );\n const look = cn(\n CHIP_BASE,\n s.body,\n type,\n radius,\n surface,\n interactive && !disabled && \"cursor-pointer hover:brightness-[0.97] dark:hover:brightness-110\",\n // An inert dot chip is text in a column: no inset, so it aligns with the header.\n dot && !interactive && \"px-0\",\n // The under-4px a snap adds is split between the two sides, not stacked at the end.\n snap && \"justify-center\",\n className,\n );\n\n // The checkbox box, only on the toggle shape it has meaning on.\n const isCheckbox = checkbox && !!onClick && !href;\n const body = (\n <>\n {isCheckbox && (\n <span\n aria-hidden\n data-chip-check=\"\"\n className={cn(\n \"flex shrink-0 items-center justify-center rounded-sm border\",\n s.icon,\n selected ? \"border-current bg-current/15\" : \"border-current/50\",\n )}\n >\n {selected && <Check className=\"size-full\" strokeWidth={3} />}\n </span>\n )}\n {dot && <span aria-hidden data-chip-dot=\"\" className={cn(\"shrink-0 rounded-full\", DOT_SIZE[size], DOT[tone])} />}\n {Icon &&\n (isValidElement(Icon) ? (\n <span aria-hidden className={cn(s.icon, \"inline-flex shrink-0 [&>svg]:size-full\")}>\n {Icon}\n </span>\n ) : (\n <Icon className={cn(s.icon, \"shrink-0\")} aria-hidden />\n ))}\n {/* Text truncates. Mixed children (an icon and a word) sit in a row instead: as a\n plain span, the svg — a block under Tailwind's preflight — stacked above the\n text (keksdose live #358). */}\n <span\n className={cn(\n \"min-w-0\",\n typeof children === \"string\" || typeof children === \"number\"\n ? \"truncate\"\n : \"inline-flex items-center gap-1 [&>svg]:size-[1em] [&>svg]:shrink-0\",\n )}\n >\n {children}\n </span>\n </>\n );\n\n const remove = onRemove ? (\n <button\n type=\"button\"\n // The name carries WHAT is being removed, not just \"Remove\" — a screen-reader user\n // tabbing a row of eight dismiss buttons otherwise hears the same word eight times\n // with no way to tell which one they are on.\n // Composed through `common.fieldValue` because the punctuation between the two\n // halves is the language's, not ours. A chip whose content is not plain text\n // has no value to name, and gets the bare verb rather than a dangling colon.\n aria-label={\n typeof children === \"string\" && children\n ? common.fieldValue(common.remove, children)\n : common.remove\n }\n onClick={(e) => {\n // The chip may itself be a link; removing it must not also follow it.\n e.preventDefault();\n e.stopPropagation();\n onRemove();\n }}\n disabled={disabled || removeDisabled}\n className={cn(\n // Logical margins: the × sits at the END of the pill, which is the left in RTL.\n \"-me-0.5 ms-0.5 shrink-0 p-0.5 transition-colors\",\n shape === \"square\" ? \"rounded-sm\" : \"rounded-full\",\n \"hover:bg-[var(--bg-active)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]\",\n (disabled || removeDisabled) && \"pointer-events-none\",\n // A disabled chip is already dimmed as a whole; dimming the × again on top\n // would take it to a quarter. `removeDisabled` alone dims just the ×.\n removeDisabled && !disabled && \"opacity-40\",\n )}\n >\n <X className={s.remove} aria-hidden />\n </button>\n ) : null;\n\n // ── The combined shape: one pill, two interactive siblings inside it.\n const pill = (inner: ReactNode) => (\n <span ref={snap ? snapRef : undefined} className={cn(CHIP_PILL, s.tail, radius, surface, snap && \"justify-center\", className)}>\n {inner}\n {remove}\n </span>\n );\n // The body inside a pill: no border or surface of its own (the pill has them), a\n // hover wash in the text's own hue so it works on every tone.\n const inner = cn(\n \"inline-flex min-w-0 items-center self-stretch transition-colors\",\n radius,\n CHIP_RING,\n s.split,\n type,\n !disabled && \"cursor-pointer hover:bg-current/10\",\n disabled && \"cursor-default\",\n );\n\n // ── The three shapes.\n if (href && !disabled) {\n // On this shape `onClick` is the link shape's, typed for the anchor.\n const onLinkClick = onClick as ChipLinkProps[\"onClick\"];\n const linkProps: ChipLinkProps = {\n ...rest,\n ref: (remove ? ref : ownRef) as Ref<HTMLAnchorElement>,\n href,\n onClick: onLinkClick,\n \"aria-current\": selected ? \"true\" : undefined,\n className: remove ? inner : look,\n children: body,\n };\n const render = pickLinkRenderer(renderLink, kitLink, href);\n const link = render ? (\n // Through a component rather than called here, so the forwarded ref arrives as\n // an ordinary prop of an element and is never handed to a function mid-render.\n <RenderedLink render={render} {...linkProps} />\n ) : (\n <a\n ref={(remove ? ref : ownRef) as React.Ref<HTMLAnchorElement>}\n href={href}\n aria-current={selected ? \"true\" : undefined}\n onClick={onLinkClick}\n className={remove ? inner : look}\n {...rest}\n >\n {body}\n </a>\n );\n return remove ? pill(link) : link;\n }\n\n // `!href`: a DISABLED link renders no link, and its link-shaped `onClick` must not\n // turn it into a button instead — it falls through to the inert span, as before.\n if (onClick && !href) {\n const onButtonClick = onClick as (event: MouseEvent<HTMLButtonElement>) => void;\n const button = (\n <button\n ref={(remove ? ref : ownRef) as React.Ref<HTMLButtonElement>}\n type=\"button\"\n onClick={onButtonClick}\n disabled={disabled}\n // Only when `selected` is PASSED: a chip with `onClick` and no `selected` is an\n // action button (it does something), not a toggle (it is on or off), and\n // announcing it \"not pressed\" would claim a state it does not have.\n // A checkbox chip says \"checked\", not \"pressed\" — the same state in the words\n // of the control it looks like.\n role={isCheckbox ? \"checkbox\" : undefined}\n aria-pressed={isCheckbox ? undefined : selected}\n aria-checked={isCheckbox ? !!selected : undefined}\n className={remove ? inner : look}\n {...rest}\n >\n {body}\n </button>\n );\n return remove ? pill(button) : button;\n }\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- the handlers are\n the roving-focus hooks, live only when the container passes `role` and `tabIndex`\n (ChipInput does); the role is a prop, so the rule cannot see it. */\n <span\n ref={ownRef as React.Ref<HTMLSpanElement>}\n className={look}\n tabIndex={tabIndex}\n role={role}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n {...rest}\n >\n {body}\n {remove}\n </span>\n );\n});\n\n/** Calls a chip's `renderLink` with the props it was given — see its call site. */\nfunction RenderedLink({\n render,\n ...props\n}: ChipLinkProps & { render: (props: ChipLinkProps) => ReactElement }) {\n return render(props);\n}\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\nexport const DEFAULT_CHIP_INPUT_LABELS: ChipInputLabels = {\n added: (v) => `${v} added`,\n removed: (v) => `${v} removed`,\n remove: \"Remove\",\n atLimit: (max) => `Limit of ${max} reached`,\n duplicate: (v) => `${v} is already in the list`,\n};\n\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. Without one, name the field with\n * `aria-label`. */\n label?: string;\n /**\n * @deprecated Pass `aria-label` instead — the DOM spelling the rest of this kit\n * now uses. Still honoured, and still second to `aria-label` when both are given.\n */\n ariaLabel?: string;\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?: Partial<ChipInputLabels>;\n className?: string;\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 ariaLabel,\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 ...rest\n}: ChipInputProps) {\n // `labels` over the provider's `chipInput` over English — the same order\n // `resolveChipInputLabels` gives outside a provider.\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 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 // 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 if (e.key === \"Escape\" && draft) {\n e.preventDefault();\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 if (e.key === \"Escape\") {\n e.preventDefault();\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-[var(--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-[var(--border)] bg-[var(--bg-surface)] px-2 py-1.5 shadow-sm\",\n \"focus-within:border-[var(--brand)] focus-within:ring-1 focus-within:ring-[var(--brand)]\",\n disabled && \"cursor-default bg-[var(--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={inputRef}\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. Failing that, the DOM spelling wins and\n // the deprecated `ariaLabel` is the fallback.\n aria-label={label ? undefined : (ariaLabelAttr ?? ariaLabel)}\n aria-describedby={describedBy || undefined}\n aria-invalid={isInvalid || !!rejected || undefined}\n className=\"min-w-[6rem] flex-1 bg-transparent py-0.5 text-sm text-[var(--text-primary)] outline-none placeholder:text-[var(--text-placeholder)] disabled:cursor-default\"\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 {error && (\n <p id={errorId} className=\"text-xs text-[var(--danger)]\">\n {error}\n </p>\n )}\n {rejected && (\n <p id={rejectedId} className=\"text-xs text-[var(--danger)]\" data-chip-input-rejected=\"\">\n {rejected}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";AAstBI,mBAWmB,KAXnB;AAttBJ,SAAS,YAAY,gBAAgB,aAAa,OAAO,iBAAiB,QAAQ,gBAAgB;AAElG,SAAS,OAAO,SAAS;AAEzB,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,cAAc,YAAY,oBAAoB;AAC9E,SAAS,wBAAwB;AA6DjC,MAAM,OAA6D;AAAA,EACjE,SAAS;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA,EAGA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACJ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AAS,WAAU,gCACvB,iBACH;AAAA,MAED,YACC,oBAAC,OAAE,IAAI,YAAY,WAAU,gCAA+B,4BAAyB,IAClF,oBACH;AAAA,OAEJ;AAAA;AAEJ;","names":["Chip","inner"]}
1
+ {"version":3,"sources":["../../src/components/chip.tsx"],"sourcesContent":["import { forwardRef, isValidElement, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from \"react\";\nimport { Check, X } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { FIELD_INVALID } from \"./ui\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels, useKitLink, useKitLocale } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer } from \"./text-link\";\nimport { Tooltip } from \"./tooltip\";\nimport { useCommitReason } from \"./write-lock\";\n\n/**\n * A chip: a compact pill carrying one value.\n *\n * Three jobs, deliberately one component. A chip can be inert (a tag on a row), a link\n * (a jump to a section), or a toggle (a filter that is on or off) — and the difference is\n * which prop you pass, not which component you pick. Keeping them together is what stops\n * an app growing three near-identical pills that drift apart; it is the shape this kit\n * already uses for `Button`, which is a link when it is given an href.\n *\n * A chip is not a `Button`. It is smaller, it is rounded to a pill, and it reads as a\n * VALUE rather than as an action — which matters because a row of eight buttons says\n * \"choose one of eight things to do\" and a row of eight chips says \"here are eight\n * things\". Using `Button` for both is the mistake this exists to prevent.\n */\n\nexport type ChipTone =\n | \"neutral\"\n | \"brand\"\n | \"danger\"\n | \"warning\"\n | \"success\"\n | \"info\"\n | \"income\"\n | \"expense\"\n | ChipHue;\n/**\n * Categorical hues (0.10.0): colour that says \"a different value\" and nothing more —\n * kastlan's status-badge.tsx paints ~15 enums in 9 Tailwind hues by hand. Four of those\n * nine are semantic and already tones (green = `success`, yellow = `warning`, red =\n * `danger`, gray = `neutral`); these five are the rest, each a `--hue-*` token triple\n * in tokens.css with a light and a dark value. Use a semantic tone when the value HAS a\n * meaning (overdue is `danger`), a hue when it only needs telling apart (sent vs\n * accepted vs invoiced).\n */\nexport type ChipHue = \"blue\" | \"indigo\" | \"purple\" | \"teal\" | \"orange\";\n/** `lg` is the 44px touch target (`min-h-11`) a phone surface wants; `md` is ~28px.\n * `xs` (0.10.0) is 11px type at `px-1.5` — keksdose's goal markers and budget-cell\n * badges, which sit inside a figure's line and must not make it taller. */\nexport type ChipSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n/**\n * How much of the tone the chip wears.\n *\n * - `soft` (default): the tinted surface every chip has had.\n * - `outline`: the tone's border and text on NO surface — keksdose's DEV badge in the\n * account menu and kastlan's 27 shadcn `variant=\"outline\"` badges, which sit on\n * coloured rows where a second tint would muddy the row.\n * - `solid`: the tone as a fill under contrasting text — the \"count\" pill (unread\n * messages, open tasks). It centres its content and sets figures tabular, so a\n * one-digit count is a round dot and \"9\" → \"10\" does not jiggle the row.\n * - `dot` (0.10.0): no pill at all — a dot in the tone's colour before plain text, for\n * a status in a dense list or a table column where eight tinted pills in a column\n * would outshout the figures beside them (kastlan's unit picker already draws its\n * UnitStatus this way, from a separate `dotColor` map).\n */\nexport type ChipVariant = \"soft\" | \"outline\" | \"solid\" | \"dot\";\n/** `pill` (default) is fully rounded; `square` has the small radius of a field or a\n * button — for a chip that sits in a table cell or beside square controls. */\nexport type ChipShape = \"pill\" | \"square\";\n\nconst TONE: Record<ChipTone, { idle: string; selected: string }> = {\n neutral: {\n idle: \"border-[var(--border)] bg-[var(--bg-surface-2)] text-[var(--text-secondary)]\",\n selected: \"border-[var(--border-strong)] bg-[var(--bg-active)] text-[var(--text-primary)]\",\n },\n brand: {\n idle: \"border-[var(--border)] bg-[var(--brand-bg)] text-[var(--brand-muted)]\",\n selected: \"border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-contrast)]\",\n },\n danger: {\n idle: \"border-[var(--danger-border)] bg-[var(--danger-bg)] text-[var(--danger)]\",\n selected: \"border-[var(--danger)] bg-[var(--danger)] text-[var(--danger-contrast)]\",\n },\n warning: {\n idle: \"border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning)]\",\n selected: \"border-[var(--warning)] bg-[var(--warning-bg)] text-[var(--warning)]\",\n },\n success: {\n idle: \"border-[var(--success-border)] bg-[var(--success-bg)] text-[var(--success)]\",\n selected: \"border-[var(--success)] bg-[var(--success-bg)] text-[var(--success)]\",\n },\n info: {\n idle: \"border-[var(--info-border)] bg-[var(--info-bg)] text-[var(--info)]\",\n selected: \"border-[var(--info)] bg-[var(--info-bg)] text-[var(--info)]\",\n },\n // The money pair (Keksdose's direction toggle). Only the TEXT and the BORDER carry\n // the tint, on the neutral chip's own surfaces: the money tokens are chosen for text\n // contrast, and a filled amber pill beside an amber figure reads as one smear.\n // `border-current` takes its hue from the text, so the two cannot drift apart.\n income: {\n idle: \"border-current/40 bg-[var(--bg-surface-2)] text-[var(--money-income)]\",\n selected: \"border-current bg-[var(--bg-active)] text-[var(--money-income)]\",\n },\n expense: {\n idle: \"border-current/40 bg-[var(--bg-surface-2)] text-[var(--money-expense)]\",\n selected: \"border-current bg-[var(--bg-active)] text-[var(--money-expense)]\",\n },\n // The categorical hues: the `info` recipe with its own token triple, so a hue chip\n // and a status chip in one row carry the same weight.\n blue: {\n idle: \"border-[var(--hue-blue-border)] bg-[var(--hue-blue-bg)] text-[var(--hue-blue)]\",\n selected: \"border-[var(--hue-blue)] bg-[var(--hue-blue-bg)] text-[var(--hue-blue)]\",\n },\n indigo: {\n idle: \"border-[var(--hue-indigo-border)] bg-[var(--hue-indigo-bg)] text-[var(--hue-indigo)]\",\n selected: \"border-[var(--hue-indigo)] bg-[var(--hue-indigo-bg)] text-[var(--hue-indigo)]\",\n },\n purple: {\n idle: \"border-[var(--hue-purple-border)] bg-[var(--hue-purple-bg)] text-[var(--hue-purple)]\",\n selected: \"border-[var(--hue-purple)] bg-[var(--hue-purple-bg)] text-[var(--hue-purple)]\",\n },\n teal: {\n idle: \"border-[var(--hue-teal-border)] bg-[var(--hue-teal-bg)] text-[var(--hue-teal)]\",\n selected: \"border-[var(--hue-teal)] bg-[var(--hue-teal-bg)] text-[var(--hue-teal)]\",\n },\n orange: {\n idle: \"border-[var(--hue-orange-border)] bg-[var(--hue-orange-bg)] text-[var(--hue-orange)]\",\n selected: \"border-[var(--hue-orange)] bg-[var(--hue-orange-bg)] text-[var(--hue-orange)]\",\n },\n};\n\n// `outline` idle looks: the tone's border and text, the surface left to whatever the\n// chip sits on. Selected still takes the tone's `selected` look (below), because an\n// outline toggle that stays an outline when on has no visible state.\nconst OUTLINE: Record<ChipTone, string> = {\n neutral: \"border-[var(--border-strong)] bg-transparent text-[var(--text-secondary)]\",\n brand: \"border-[var(--brand)] bg-transparent text-[var(--brand)]\",\n danger: \"border-[var(--danger-border)] bg-transparent text-[var(--danger)]\",\n warning: \"border-[var(--warning-border)] bg-transparent text-[var(--warning)]\",\n success: \"border-[var(--success-border)] bg-transparent text-[var(--success)]\",\n info: \"border-[var(--info-border)] bg-transparent text-[var(--info)]\",\n income: \"border-current/60 bg-transparent text-[var(--money-income)]\",\n expense: \"border-current/60 bg-transparent text-[var(--money-expense)]\",\n blue: \"border-[var(--hue-blue-border)] bg-transparent text-[var(--hue-blue)]\",\n indigo: \"border-[var(--hue-indigo-border)] bg-transparent text-[var(--hue-indigo)]\",\n purple: \"border-[var(--hue-purple-border)] bg-transparent text-[var(--hue-purple)]\",\n teal: \"border-[var(--hue-teal-border)] bg-transparent text-[var(--hue-teal)]\",\n orange: \"border-[var(--hue-orange-border)] bg-transparent text-[var(--hue-orange)]\",\n};\n\n// `solid`: the fill under its contrast pair. Only brand and danger have a declared\n// `-contrast` token; the other hues are 700s in the light theme and 300s in the dark\n// one, so `--text-inverse` (the surface colour) is the side of the pair that contrasts\n// with them in both — which is what the inverse token is for. The border goes\n// transparent rather than away, so a solid chip is exactly as tall as a soft one.\nconst SOLID: Record<ChipTone, string> = {\n neutral: \"border-transparent bg-[var(--bg-inverse)] text-[var(--text-inverse)]\",\n brand: \"border-transparent bg-[var(--brand)] text-[var(--brand-contrast)]\",\n danger: \"border-transparent bg-[var(--danger)] text-[var(--danger-contrast)]\",\n warning: \"border-transparent bg-[var(--warning)] text-[var(--text-inverse)]\",\n success: \"border-transparent bg-[var(--success)] text-[var(--text-inverse)]\",\n info: \"border-transparent bg-[var(--info)] text-[var(--text-inverse)]\",\n income: \"border-transparent bg-[var(--money-income)] text-[var(--text-inverse)]\",\n expense: \"border-transparent bg-[var(--money-expense)] text-[var(--text-inverse)]\",\n blue: \"border-transparent bg-[var(--hue-blue)] text-[var(--text-inverse)]\",\n indigo: \"border-transparent bg-[var(--hue-indigo)] text-[var(--text-inverse)]\",\n purple: \"border-transparent bg-[var(--hue-purple)] text-[var(--text-inverse)]\",\n teal: \"border-transparent bg-[var(--hue-teal)] text-[var(--text-inverse)]\",\n orange: \"border-transparent bg-[var(--hue-orange)] text-[var(--text-inverse)]\",\n};\n\n/** `dot`: the fill of the dot itself — the tone's strongest colour, which is the one\n * chosen to read on the page surface in both themes. Neutral takes the muted ink: a\n * grey dot is \"no particular state\", not a darker black. */\nconst DOT: Record<ChipTone, string> = {\n neutral: \"bg-[var(--text-muted)]\",\n brand: \"bg-[var(--brand)]\",\n danger: \"bg-[var(--danger)]\",\n warning: \"bg-[var(--warning)]\",\n success: \"bg-[var(--success)]\",\n info: \"bg-[var(--info)]\",\n income: \"bg-[var(--money-income)]\",\n expense: \"bg-[var(--money-expense)]\",\n blue: \"bg-[var(--hue-blue)]\",\n indigo: \"bg-[var(--hue-indigo)]\",\n purple: \"bg-[var(--hue-purple)]\",\n teal: \"bg-[var(--hue-teal)]\",\n orange: \"bg-[var(--hue-orange)]\",\n};\n\n/** Per size: the dot's diameter. */\nconst DOT_SIZE: Record<ChipSize, string> = { xs: \"size-1.5\", sm: \"size-2\", md: \"size-2\", lg: \"size-2.5\" };\n\n/** The status-badge type (`caps`): a size step down, heavier and tracked, because\n * capitals at body size shout and capitals untracked run together. Per size, so it\n * replaces the size's own `text-*` through tailwind-merge. */\nconst CAPS: Record<ChipSize, string> = {\n xs: \"text-[10px] font-semibold uppercase tracking-wider\",\n sm: \"text-[10px] font-semibold uppercase tracking-wider\",\n md: \"text-[11px] font-semibold uppercase tracking-wider\",\n lg: \"text-xs font-semibold uppercase tracking-wider\",\n};\n\nfunction surfaceOf(tone: ChipTone, variant: ChipVariant, selected: boolean | undefined): string {\n const palette = TONE[tone];\n if (variant === \"dot\") {\n // No surface and no border colour: the dot carries the tone, the text stays ink.\n // The border goes transparent rather than away, so a dot chip lines up with a pill.\n return selected\n ? \"border-transparent bg-transparent font-medium text-[var(--text-primary)]\"\n : \"border-transparent bg-transparent text-[var(--text-secondary)]\";\n }\n if (variant === \"solid\") {\n // A solid chip is already the strongest look there is, so \"on\" is a ring round it.\n return cn(SOLID[tone], selected && \"ring-2 ring-[var(--border-strong)] ring-offset-1 ring-offset-[var(--bg-surface)]\");\n }\n if (selected) return palette.selected;\n return variant === \"outline\" ? OUTLINE[tone] : palette.idle;\n}\n\n/** What {@link ChipProps.renderLink} is handed: everything the chip would have put on\n * its own `<a>`. Spread it onto your router's link, mapping `href` to what the link\n * calls it — `renderLink={({ href, ...p }) => <Link to={href} {...p} />}`. */\nexport interface ChipLinkProps {\n href: string;\n /** The chip's whole look — keep it, or the pill is a bare link. */\n className: string;\n children: ReactNode;\n /** The chip's forwarded ref. React 19 passes it to a function component as a prop. */\n ref?: Ref<HTMLAnchorElement>;\n \"aria-current\"?: \"true\";\n /**\n * The chip's `onClick`, when it was given one — spread it onto the link with the\n * rest. Carried here so a caller need not close over it twice: keksdose's admin pill\n * in the account menu closes the menu on the way to /admin (account-menu.tsx), and\n * with `onClick` on the Chip its `renderLink` stays the one-liner\n * `({ href, ...p }) => <Link to={href} {...p} />`.\n */\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n id?: string;\n title?: string;\n [key: `aria-${string}`]: string | boolean | number | undefined;\n [key: `data-${string}`]: unknown;\n}\n\n/**\n * `body` is the whole pill when the chip is ONE element. When a link or a button also has\n * a dismiss control, the pill is a wrapper holding two siblings (see the note on\n * {@link Chip}): `split` is then the interactive part's own padding — the full start\n * inset, a short end one before the ×; `tail` is the wrapper's end inset after the ×.\n */\nconst SIZE: Record<\n ChipSize,\n { body: string; split: string; tail: string; icon: string; remove: string }\n> = {\n xs: {\n body: \"gap-1 px-1.5 py-0 text-[11px] leading-4\",\n split: \"gap-1 ps-1.5 pe-0.5 py-0 text-[11px] leading-4\",\n tail: \"pe-1\",\n icon: \"size-3\",\n remove: \"size-2.5\",\n },\n sm: {\n body: \"gap-1 px-2 py-0.5 text-xs\",\n split: \"gap-1 ps-2 pe-1 py-0.5 text-xs\",\n tail: \"pe-1.5\",\n icon: \"size-3\",\n remove: \"size-3\",\n },\n md: {\n body: \"gap-1.5 px-2.5 py-1 text-sm\",\n split: \"gap-1.5 ps-2.5 pe-1.5 py-1 text-sm\",\n tail: \"pe-2\",\n icon: \"size-3.5\",\n remove: \"size-3.5\",\n },\n lg: {\n body: \"min-h-11 gap-2 px-4 py-2 text-sm\",\n split: \"min-h-11 gap-2 ps-4 pe-2 py-2 text-sm\",\n tail: \"min-h-11 pe-3.5\",\n icon: \"size-4\",\n remove: \"size-4\",\n },\n};\n\n/* ── Edge snapping (fractional device-pixel ratios) ──────────────────────────\n *\n * WHY. At a device-pixel ratio of 1.25 (a 125 % Windows display, or 125 % browser\n * zoom) Chrome snaps a box to whole CSS pixels and only then scales it, so a 1px\n * border is 1.25 device pixels wide and starts at a quarter-pixel phase that depends\n * on where the edge lands. A chip's left edge follows whatever stands before it, its\n * right edge follows its own text, so the two land on unrelated phases: one rasterises\n * as a crisp pixel, the other as a two-pixel smear at half strength — and a 60 %-alpha\n * border (`--danger-border`) makes the smeared side read as a THINNER line (keksdose\n * dev #576).\n *\n * WHAT FIXES IT. The two edges rasterise as mirror images exactly when their device\n * positions sum to a whole number: `(2·left + width) · dpr` integral, `left` being the\n * edge's snapped CSS x. Rounding the WIDTH alone to the ratio's grid (4px at 1.25)\n * makes the phases EQUAL, which is not the same thing: measured with keksdose's\n * playwright harness across every left phase at 1.25, width-only rounding mirrored the\n * edges at two of the four phases and left the other two as lopsided as before (mean\n * peak asymmetry 16.5, worse than the unsnapped 10.9 a random width gets by luck); the\n * position-aware width below took it to 0 at every phase. Inset rings, whole-pixel\n * starts, compositing hints and fractional border widths were measured by keksdose\n * and do not help — Chrome rounds a sub-pixel border back up to 1px.\n *\n * So the fix needs the chip's position, which is why it is opt-in (`snapEdges`): it\n * reads layout. Cheaply — every snapped chip on the page shares one ResizeObserver,\n * one `resize` listener and one resolution media query, and a pass is batched into a\n * frame as read-all / write-all, not a forced layout per chip. At an integer ratio,\n * and at a half one (1.5, 2.5: grid 2 — measured symmetric already, both edges a\n * pixel and a half on the same pattern), there is nothing to fix and a pass\n * writes nothing.\n */\n\n/** The smallest whole CSS-pixel count `n` with `n × dpr` whole — 4 at 1.25, 2 at 1.5,\n * 1 at an integer ratio. 0 for a ratio no step up to 4px fits (110 % zoom wants 10px;\n * a chip growing by up to 9px is a layout change, not a hairline fix). */\nfunction chipEdgeGrid(dpr: number): number {\n for (let n = 1; n <= 4; n++) if (Math.abs(n * dpr - Math.round(n * dpr)) < 1e-3) return n;\n return 0;\n}\n\n/**\n * The width (whole CSS px, at least `natural`) that mirrors a box's two edges at\n * `dpr`, for a box whose left edge sits at CSS x `left`. `natural` back when the ratio\n * needs nothing.\n */\nfunction snappedChipEdgeWidth(natural: number, left: number, dpr: number): number {\n const n = chipEdgeGrid(dpr);\n if (n <= 2) return natural;\n const l = Math.round(left);\n // A hair under a whole pixel is that pixel: 59.999 is a 60px chip, not a 61px one.\n let w = Math.ceil(natural - 0.01);\n while ((((2 * l + w) % n) + n) % n !== 0) w++;\n return w;\n}\n\nconst snapped = new Set<HTMLElement>();\n/** The min-width each chip was given by a pass — so a pass only ever clears its own. */\nconst written = new WeakMap<HTMLElement, string>();\nlet snapFrame = 0;\nlet snapObserver: ResizeObserver | null = null;\nlet ratioQuery: MediaQueryList | null = null;\n\nfunction clearOwn(el: HTMLElement) {\n const own = written.get(el);\n if (own !== undefined && el.style.minWidth === own) el.style.minWidth = \"\";\n written.delete(el);\n}\n\n/**\n * Re-snap every chip rendered with `snapEdges`, now. The kit already re-snaps when a\n * chip renders, resizes, or the window or the ratio changes; call this after moving\n * chips some other way (a side panel sliding in beside a table of status chips),\n * since a move is not something an observer can see.\n */\nexport function refreshChipEdges(): void {\n if (snapFrame) {\n cancelAnimationFrame(snapFrame);\n snapFrame = 0;\n }\n if (typeof window === \"undefined\" || !snapped.size) return;\n const dpr = window.devicePixelRatio || 1;\n const els = [...snapped];\n // Write: back to the natural width, so what is read below is the chip, not our pin.\n for (const el of els) clearOwn(el);\n const n = chipEdgeGrid(dpr);\n if (n <= 2) return;\n // A chip whose own end decides where it starts (RTL, `justify-end`) moves when it\n // grows, so a pass re-reads what it wrote and steps on by a pixel until the edges\n // agree — `n` steps cover every residue. Each pass is ONE layout for every chip\n // together. A chip that never agrees (a centred one moves both edges at once) is\n // given its natural width back rather than kept wider for nothing.\n let pending = els;\n for (let pass = 0; pass <= n && pending.length; pass++) {\n const reads = pending.map((el) => {\n const r = el.getBoundingClientRect();\n const label = el.querySelector<HTMLElement>(\".truncate\");\n // Not laid out (a hidden ancestor, jsdom), or truncated at its container's edge,\n // where a wider chip would overflow: leave it alone.\n if (!r.width || (label && label.scrollWidth > label.clientWidth)) return null;\n const width = Math.round(r.width * 64) / 64;\n const target = snappedChipEdgeWidth(width, r.left + window.scrollX, dpr);\n return target === width ? null : target;\n });\n const next: HTMLElement[] = [];\n pending.forEach((el, i) => {\n const target = reads[i];\n if (target == null) return;\n if (pass === n) {\n clearOwn(el);\n return;\n }\n const own = written.get(el);\n const value = `${pass > 0 && own !== undefined ? parseFloat(own) + 1 : target}px`;\n el.style.minWidth = value;\n written.set(el, value);\n next.push(el);\n });\n pending = next;\n }\n}\n\nfunction scheduleChipEdges() {\n if (snapFrame || typeof requestAnimationFrame === \"undefined\") return;\n snapFrame = requestAnimationFrame(() => {\n snapFrame = 0;\n refreshChipEdges();\n });\n}\n\n/** The resolution query for the CURRENT ratio: it stops matching when the ratio\n * changes (a window dragged to another display), which a `resize` need not fire. */\nfunction watchRatio() {\n ratioQuery?.removeEventListener(\"change\", onRatioChange);\n ratioQuery =\n typeof window.matchMedia === \"function\"\n ? window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`)\n : null;\n ratioQuery?.addEventListener(\"change\", onRatioChange);\n}\n\nfunction onRatioChange() {\n watchRatio();\n scheduleChipEdges();\n}\n\nfunction registerSnap(el: HTMLElement) {\n if (snapped.has(el)) return;\n if (!snapped.size) {\n if (typeof ResizeObserver !== \"undefined\") snapObserver = new ResizeObserver(scheduleChipEdges);\n window.addEventListener(\"resize\", scheduleChipEdges);\n watchRatio();\n }\n snapped.add(el);\n snapObserver?.observe(el);\n scheduleChipEdges();\n}\n\nfunction unregisterSnap(el: HTMLElement) {\n if (!snapped.delete(el)) return;\n snapObserver?.unobserve(el);\n clearOwn(el);\n if (snapped.size) return;\n snapObserver?.disconnect();\n snapObserver = null;\n window.removeEventListener(\"resize\", scheduleChipEdges);\n ratioQuery?.removeEventListener(\"change\", onRatioChange);\n ratioQuery = null;\n}\n\n/** The ref a chip hangs on its visible pill, plus a re-snap after every render (its\n * label or its neighbours may have changed). */\nfunction useSnapEdges(on: boolean) {\n const node = useRef<HTMLElement | null>(null);\n const ref = useCallback(\n (el: HTMLElement | null) => {\n if (el === node.current) return;\n const prev = node.current;\n node.current = el;\n // React detaches and re-attaches a ref whose callback changed identity (a\n // consumer's inline ref) — the same element, a moment apart. Unregistering on\n // the detach would clear the pin and paint one frame unsnapped, so the drop\n // waits a microtask and is skipped if the element came straight back.\n if (prev) queueMicrotask(() => node.current !== prev && unregisterSnap(prev));\n if (el && on) registerSnap(el);\n },\n [on],\n );\n useLayoutEffect(() => {\n const el = node.current;\n if (!el) return;\n if (on) {\n registerSnap(el);\n scheduleChipEdges();\n } else unregisterSnap(el);\n });\n return ref;\n}\n\nfunction assignRef<T>(target: Ref<T> | undefined, value: T | null) {\n if (typeof target === \"function\") target(value);\n else if (target) (target as { current: T | null }).current = value;\n}\n\nconst CHIP_PILL = \"inline-flex max-w-full items-center rounded-full border transition-colors\";\n// `focus-visible`, not `focus`: a chip commonly receives focus programmatically (the\n// ChipInput moves focus onto one after a removal) and a ring that appears on a\n// pointer click reads as a stuck selection.\nconst CHIP_RING =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)]\";\nconst CHIP_BASE = `${CHIP_PILL} ${CHIP_RING}`;\n\ninterface ChipBaseProps {\n children: ReactNode;\n tone?: ChipTone;\n size?: ChipSize;\n /** See {@link ChipVariant}. Default `soft`. */\n variant?: ChipVariant;\n /** See {@link ChipShape}. Default `pill`. */\n shape?: ChipShape;\n /**\n * The uppercase, tracked \"status badge\" type — keksdose's ~25 PAID / DRAFT /\n * OVERDUE / ADMIN badges, each spelling `uppercase tracking-wide text-[10px]` by\n * hand. A flag rather than a fourth `variant` because it is TYPE, not surface: a\n * status badge is soft, outlined or solid as the row needs, and a `variant=\"tag\"`\n * would have had to pick one. Screen readers read the text as written, not as\n * drawn, so write it in normal case.\n */\n caps?: boolean;\n /**\n * The leading glyph: a lucide component (`icon={Check}`, drawn at the chip's size), or\n * — since 0.15.4 — a ready element (`icon={<Check className=\"text-[var(--success)]\" />}`)\n * for a glyph whose colour or stroke carries a state; it is sized to the same box\n * (keksdose live #358 built that slot by hand inside `children`).\n */\n icon?: LucideIcon | ReactElement;\n /**\n * Marks the chip as the current one — `aria-current` on a link, `aria-pressed` on a\n * toggle.\n *\n * On an ON/OFF toggle, keep the LABEL the same in both states and let `selected`\n * carry the state. A label that flips with it (\"Skip this month\" / \"Ask again this\n * month\") is announced together with \"pressed\", and then says the opposite of what\n * it does.\n *\n * A control that switches between two NAMED states (outflow ⇄ inflow) is not a\n * toggle but an ACTION button: leave `selected` out, let the visible label and the\n * tone follow the state (\"− Outflow\" / \"+ Inflow\"), and name the action in\n * `aria-label` (\"Direction: outflow — tap for inflow\"). Without `selected` the chip\n * reports no pressed state at all. A fixed label there contradicts the figure beside\n * it — \"+ Outflow\" in green next to an inflow (keksdose #417).\n */\n selected?: boolean;\n /**\n * Checkbox mode (0.10.0), for a toggle chip (`onClick` + `selected`): a small box\n * at the start that shows a tick when `selected`, and the button reports\n * `role=\"checkbox\"` + `aria-checked` instead of `aria-pressed`. For a set of\n * include/exclude choices where \"on\" must read as TICKED, not merely tinted —\n * keksdose's add-group-card (the \"which categories come along\" pills), which put a\n * real `<Checkbox>` inside a `<label>` pill by hand. The box is drawn in both\n * states so ticking one never shifts its label.\n */\n checkbox?: boolean;\n /** Renders a dismiss affordance. Works alongside `href`/`onClick` — see the note below. */\n onRemove?: () => void;\n /** Accessible name for the dismiss button. Default: `common.remove` from the\n * {@link UiKitProvider}, else \"Remove\". */\n removeLabel?: string;\n /** Disables the × ONLY — the chip itself stays a working link or toggle. For the\n * value that may not be removed right now (the last filter of a required set, a\n * tag the user may read but not edit) where `disabled` would also kill the chip's\n * own action. */\n removeDisabled?: boolean;\n disabled?: boolean;\n className?: string;\n /**\n * Roving focus, for a container that manages a row of chips (see {@link ChipInput}).\n * A chip with no `href`/`onClick` is inert and unfocusable by default; give it a\n * `tabIndex` and a `role` and it becomes the thing arrow keys move between.\n */\n tabIndex?: number;\n role?: string;\n onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;\n onFocus?: () => void;\n /** Accessible name, when the visible text is not the whole story. */\n \"aria-label\"?: string;\n /** Any other ARIA attribute — `aria-describedby`, `aria-expanded`, `aria-controls`,\n * `aria-haspopup` — reaches the chip's interactive element. */\n [key: `aria-${string}`]: string | boolean | number | undefined;\n /** A test id, a `data-tour` anchor, or any other data attribute. */\n [key: `data-${string}`]: unknown;\n id?: string;\n /** A native tooltip. For anything a user must read, prefer the kit's `Tooltip`. */\n title?: string;\n /**\n * Even hairlines on fractional-ratio displays (0.18.0). At a device-pixel ratio of\n * 1.25 — a 125 % Windows display, or 125 % zoom — Chrome draws a chip's two 1px\n * side borders on different sub-pixel phases, one crisp and one a half-strength\n * smear that reads as a thinner line (worst on the 60 %-alpha `danger` border).\n * `snapEdges` widens the chip by under 4px, from where it sits, so the two edges\n * rasterise as mirror images, and centres its content in the extra.\n *\n * Off by default: it reads the chip's position (batched for every snapped chip into\n * one pass a frame, through one shared observer), and the fix is only as fresh as the\n * last pass — it re-snaps on render, resize, zoom and ratio change, but not when\n * something else moves the chip; call {@link refreshChipEdges} then. At an integer\n * ratio, and at 1.5, it writes nothing. Turn it on for status chips that sit in a\n * column and are compared side by side; a chip with no visible border (`dot`) has\n * nothing to snap.\n */\n snapEdges?: boolean;\n}\n\n/**\n * A chip is a link OR a button, never both — so the types say so. Before 0.7.0 both were\n * accepted and `onClick` was silently dropped whenever `href` was set. A LINK may still\n * run code on its way (close the menu it sits in): that is an `onClick` typed for the\n * anchor, on the link shape, and the pill stays a link — no `aria-pressed`, no button.\n * That shape wants a definite `href` string, so a bare `onClick` is always the\n * button's, with a button's event.\n */\nexport type ChipProps = ChipBaseProps &\n (\n | {\n /** Renders the chip as a link. */\n href?: string;\n onClick?: never;\n /**\n * Renders the link for `href` — pass your router's `<Link>` here, since a\n * plain `<a>` reloads a single-page app (keksdose's account-menu admin pill).\n * Default: the `<UiKitProvider linkComponent>`, then `<a>`. Ignored without\n * `href`.\n *\n * A render function rather than an `as={Link}`, for three reasons. It is the\n * API `StatTile` already has (`renderLink`), so a consumer learns it once.\n * Router links do not take `href` — react-router's takes `to` — so an `as`\n * would either have to pass props through untyped or teach the kit about one\n * router; here the caller maps `href` onto its own link in one line, fully\n * typed. And it keeps `href` as THE link prop, which is what the `href` /\n * `onClick` exclusion below is typed on: the pill is a link because it has an\n * href, whichever element draws it.\n */\n renderLink?: (props: ChipLinkProps) => ReactElement;\n commit?: never;\n disabledReason?: never;\n }\n | {\n /** The link shape again, with an `onClick`. `href` is a required string here,\n * which is what lets TypeScript tell this shape from the button's: a bare\n * `onClick` can only be the button's, and keeps its button event. */\n href: string;\n /** Runs on the link's click, before the navigation — keksdose's admin pill\n * closes the account menu with it. Reaches a `renderLink` link as\n * {@link ChipLinkProps.onClick}. Not called on a disabled chip, which renders\n * no link. */\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n /** See the link shape above. */\n renderLink?: (props: ChipLinkProps) => ReactElement;\n commit?: never;\n disabledReason?: never;\n }\n | {\n href?: never;\n renderLink?: never;\n /** Renders the chip as a toggle button. Mutually exclusive with `href`. Receives\n * the click, so a chip inside a clickable row can `stopPropagation()`. */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void;\n /**\n * Why the toggle cannot be pressed right now — {@link Button}'s\n * `disabledReason`, on the chip's button shape (keksdose K3: a filter or flag\n * chip that saves on press, under a read-only lock). The chip stays focusable\n * and `aria-disabled`, a press (and its `onRemove` ×) does nothing, and the\n * reason shows in the kit {@link Tooltip} and describes the chip. Wins over\n * `disabled`. A link chip navigates rather than commits, so it takes neither\n * this nor `commit`; an inert chip has nothing to refuse.\n */\n disabledReason?: ReactNode;\n /** This chip COMMITS — pressing it saves. Under a locked\n * {@link WriteLockProvider} it takes the `disabledReason` path with the lock's\n * reason, as {@link Button}'s `commit` does. */\n commit?: boolean;\n }\n );\n\n/**\n * Note on `onRemove` with `href`/`onClick`: a button cannot be nested inside a button or\n * a link, so when both are present the chip renders a wrapper holding TWO siblings — the\n * interactive body and the dismiss control. The WRAPPER is the visual pill (border, tone,\n * `className`) and the two sit inside it, so the × reads as part of the chip; the body's\n * focus ring is drawn on the body alone, and `ref`, `id` and the ARIA props still reach\n * the body — the interactive element.\n */\nexport const Chip = forwardRef<HTMLElement, ChipProps>(function Chip(\n {\n children,\n tone = \"neutral\",\n size = \"md\",\n variant = \"soft\",\n shape = \"pill\",\n caps = false,\n icon: Icon,\n selected,\n checkbox = false,\n href,\n renderLink,\n onClick,\n onRemove,\n removeLabel,\n removeDisabled = false,\n disabled = false,\n className,\n tabIndex,\n role,\n onKeyDown,\n onFocus,\n snapEdges = false,\n disabledReason: ownDisabledReason,\n commit,\n ...rest\n },\n ref,\n) {\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS, { remove: removeLabel });\n const reasonId = useId();\n const disabledReason = useCommitReason(commit, ownDisabledReason);\n // Only the BUTTON shape commits: a link navigates, an inert chip does nothing.\n const locked = Boolean(onClick) && !href && hasReason(disabledReason);\n const kitLink = useKitLink();\n const s = SIZE[size];\n const interactive = !!href || !!onClick;\n // One radius for every rounded piece — the pill, the body inside a split pill, the ×\n // — so a square chip has no round focus ring inside it.\n const radius =\n shape === \"square\" ? (size === \"sm\" || size === \"xs\" ? \"rounded\" : \"rounded-md\") : \"rounded-full\";\n const dot = variant === \"dot\";\n const type = cn(caps && CAPS[size], variant === \"solid\" && \"justify-center tabular-nums\");\n const surface = cn(\n surfaceOf(tone, variant, selected),\n // A reason wins over `disabled`: the focusable kind of disabled, with the cursor\n // that says \"refused\" rather than \"nothing here\".\n disabled && !locked && \"cursor-default opacity-50\",\n locked && \"cursor-not-allowed opacity-50\",\n );\n const snap = snapEdges && !dot;\n const snapRef = useSnapEdges(snap);\n // The visible pill carries the snap: the whole chip, or the wrapper of a split one\n // (whose body gets the forwarded ref instead).\n const ownRef = useCallback(\n (el: HTMLElement | null) => {\n snapRef(el);\n assignRef(ref, el);\n },\n [snapRef, ref],\n );\n const look = cn(\n CHIP_BASE,\n s.body,\n type,\n radius,\n surface,\n interactive && !disabled && !locked && \"cursor-pointer hover:brightness-[0.97] dark:hover:brightness-110\",\n // An inert dot chip is text in a column: no inset, so it aligns with the header.\n dot && !interactive && \"px-0\",\n // The under-4px a snap adds is split between the two sides, not stacked at the end.\n snap && \"justify-center\",\n className,\n );\n\n // The checkbox box, only on the toggle shape it has meaning on.\n const isCheckbox = checkbox && !!onClick && !href;\n const body = (\n <>\n {isCheckbox && (\n <span\n aria-hidden\n data-chip-check=\"\"\n className={cn(\n \"flex shrink-0 items-center justify-center rounded-sm border\",\n s.icon,\n selected ? \"border-current bg-current/15\" : \"border-current/50\",\n )}\n >\n {selected && <Check className=\"size-full\" strokeWidth={3} />}\n </span>\n )}\n {dot && <span aria-hidden data-chip-dot=\"\" className={cn(\"shrink-0 rounded-full\", DOT_SIZE[size], DOT[tone])} />}\n {Icon &&\n (isValidElement(Icon) ? (\n <span aria-hidden className={cn(s.icon, \"inline-flex shrink-0 [&>svg]:size-full\")}>\n {Icon}\n </span>\n ) : (\n <Icon className={cn(s.icon, \"shrink-0\")} aria-hidden />\n ))}\n {/* Text truncates. Mixed children (an icon and a word) sit in a row instead: as a\n plain span, the svg — a block under Tailwind's preflight — stacked above the\n text (keksdose live #358). */}\n <span\n className={cn(\n \"min-w-0\",\n typeof children === \"string\" || typeof children === \"number\"\n ? \"truncate\"\n : \"inline-flex items-center gap-1 [&>svg]:size-[1em] [&>svg]:shrink-0\",\n )}\n >\n {children}\n </span>\n </>\n );\n\n const remove = onRemove ? (\n <button\n type=\"button\"\n // The name carries WHAT is being removed, not just \"Remove\" — a screen-reader user\n // tabbing a row of eight dismiss buttons otherwise hears the same word eight times\n // with no way to tell which one they are on.\n // Composed through `common.fieldValue` because the punctuation between the two\n // halves is the language's, not ours. A chip whose content is not plain text\n // has no value to name, and gets the bare verb rather than a dangling colon.\n aria-label={\n typeof children === \"string\" && children\n ? common.fieldValue(common.remove, children)\n : common.remove\n }\n onClick={(e) => {\n // The chip may itself be a link; removing it must not also follow it.\n e.preventDefault();\n e.stopPropagation();\n // Removing a value from a chip that commits is a commit too.\n if (locked) return;\n onRemove();\n }}\n disabled={(disabled && !locked) || removeDisabled}\n aria-disabled={locked || undefined}\n aria-describedby={locked ? reasonId : undefined}\n className={cn(\n // Logical margins: the × sits at the END of the pill, which is the left in RTL.\n \"-me-0.5 ms-0.5 shrink-0 p-0.5 transition-colors\",\n shape === \"square\" ? \"rounded-sm\" : \"rounded-full\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]\",\n !locked && \"hover:bg-[var(--bg-active)]\",\n locked && \"cursor-not-allowed\",\n ((disabled && !locked) || removeDisabled) && \"pointer-events-none\",\n // A disabled chip is already dimmed as a whole; dimming the × again on top\n // would take it to a quarter. `removeDisabled` alone dims just the ×.\n removeDisabled && !disabled && \"opacity-40\",\n )}\n >\n <X className={s.remove} aria-hidden />\n </button>\n ) : null;\n\n // ── The combined shape: one pill, two interactive siblings inside it.\n const pill = (inner: ReactNode) => (\n <span ref={snap ? snapRef : undefined} className={cn(CHIP_PILL, s.tail, radius, surface, snap && \"justify-center\", className)}>\n {inner}\n {remove}\n </span>\n );\n // The body inside a pill: no border or surface of its own (the pill has them), a\n // hover wash in the text's own hue so it works on every tone.\n const inner = cn(\n \"inline-flex min-w-0 items-center self-stretch transition-colors\",\n radius,\n CHIP_RING,\n s.split,\n type,\n !disabled && !locked && \"cursor-pointer hover:bg-current/10\",\n disabled && !locked && \"cursor-default\",\n locked && \"cursor-not-allowed\",\n );\n\n // ── The three shapes.\n if (href && !disabled) {\n // On this shape `onClick` is the link shape's, typed for the anchor.\n const onLinkClick = onClick as ChipLinkProps[\"onClick\"];\n const linkProps: ChipLinkProps = {\n ...rest,\n ref: (remove ? ref : ownRef) as Ref<HTMLAnchorElement>,\n href,\n onClick: onLinkClick,\n \"aria-current\": selected ? \"true\" : undefined,\n className: remove ? inner : look,\n children: body,\n };\n const render = pickLinkRenderer(renderLink, kitLink, href);\n const link = render ? (\n // Through a component rather than called here, so the forwarded ref arrives as\n // an ordinary prop of an element and is never handed to a function mid-render.\n <RenderedLink render={render} {...linkProps} />\n ) : (\n <a\n ref={(remove ? ref : ownRef) as React.Ref<HTMLAnchorElement>}\n href={href}\n aria-current={selected ? \"true\" : undefined}\n onClick={onLinkClick}\n className={remove ? inner : look}\n {...rest}\n >\n {body}\n </a>\n );\n return remove ? pill(link) : link;\n }\n\n // `!href`: a DISABLED link renders no link, and its link-shaped `onClick` must not\n // turn it into a button instead — it falls through to the inert span, as before.\n if (onClick && !href) {\n const onButtonClick = onClick as (event: MouseEvent<HTMLButtonElement>) => void;\n const ownDescribedBy = rest[\"aria-describedby\"];\n const button = (\n <button\n ref={(remove ? ref : ownRef) as React.Ref<HTMLButtonElement>}\n type=\"button\"\n onClick={(e) => {\n // Locked: the press is swallowed — the chip saves on press, and a lock that\n // let it through would toggle a state that is never stored.\n if (locked) {\n e.preventDefault();\n return;\n }\n onButtonClick(e);\n }}\n disabled={disabled && !locked}\n // Only when `selected` is PASSED: a chip with `onClick` and no `selected` is an\n // action button (it does something), not a toggle (it is on or off), and\n // announcing it \"not pressed\" would claim a state it does not have.\n // A checkbox chip says \"checked\", not \"pressed\" — the same state in the words\n // of the control it looks like.\n role={isCheckbox ? \"checkbox\" : undefined}\n aria-pressed={isCheckbox ? undefined : selected}\n aria-checked={isCheckbox ? !!selected : undefined}\n className={remove ? inner : look}\n {...rest}\n // After the spread, merged with it: the lock's state and reason are not the\n // caller's to drop by passing an `aria-describedby` of their own.\n aria-disabled={locked || (rest[\"aria-disabled\"] as boolean | \"true\" | \"false\" | undefined)}\n aria-describedby={\n locked ? [ownDescribedBy, reasonId].filter(Boolean).join(\" \") : (ownDescribedBy as string | undefined)\n }\n >\n {body}\n </button>\n );\n const shaped = remove ? pill(button) : button;\n if (!locked) return shaped;\n return (\n // The chip in a FRAGMENT, as a locked Button is: the bubble is visual, and the\n // hidden copy beside it is what the chip (and its ×) is described by.\n <Tooltip label={disabledReason}>\n <>\n {shaped}\n <span id={reasonId} hidden>\n {disabledReason}\n </span>\n </>\n </Tooltip>\n );\n }\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- the handlers are\n the roving-focus hooks, live only when the container passes `role` and `tabIndex`\n (ChipInput does); the role is a prop, so the rule cannot see it. */\n <span\n ref={ownRef as React.Ref<HTMLSpanElement>}\n className={look}\n tabIndex={tabIndex}\n role={role}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n {...rest}\n >\n {body}\n {remove}\n </span>\n );\n});\n\n/** `null`, `false` and `\"\"` are what a `cond && reason` gives on the happy path — no\n * reason, so no lock. */\nfunction hasReason(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n\n/** Calls a chip's `renderLink` with the props it was given — see its call site. */\nfunction RenderedLink({\n render,\n ...props\n}: ChipLinkProps & { render: (props: ChipLinkProps) => ReactElement }) {\n return render(props);\n}\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\nexport const DEFAULT_CHIP_INPUT_LABELS: ChipInputLabels = {\n added: (v) => `${v} added`,\n removed: (v) => `${v} removed`,\n remove: \"Remove\",\n atLimit: (max) => `Limit of ${max} reached`,\n duplicate: (v) => `${v} is already in the list`,\n};\n\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. Without one, name the field with\n * `aria-label`. */\n label?: string;\n /**\n * @deprecated Pass `aria-label` instead — the DOM spelling the rest of this kit\n * now uses. Still honoured, and still second to `aria-label` when both are given.\n */\n ariaLabel?: string;\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?: Partial<ChipInputLabels>;\n className?: string;\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 ariaLabel,\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 ...rest\n}: ChipInputProps) {\n // `labels` over the provider's `chipInput` over English — the same order\n // `resolveChipInputLabels` gives outside a provider.\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 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 // 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 if (e.key === \"Escape\" && draft) {\n e.preventDefault();\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 if (e.key === \"Escape\") {\n e.preventDefault();\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-[var(--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-[var(--border)] bg-[var(--bg-surface)] px-2 py-1.5 shadow-sm\",\n \"focus-within:border-[var(--brand)] focus-within:ring-1 focus-within:ring-[var(--brand)]\",\n disabled && \"cursor-default bg-[var(--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={inputRef}\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. Failing that, the DOM spelling wins and\n // the deprecated `ariaLabel` is the fallback.\n aria-label={label ? undefined : (ariaLabelAttr ?? ariaLabel)}\n aria-describedby={describedBy || undefined}\n aria-invalid={isInvalid || !!rejected || undefined}\n className=\"min-w-[6rem] flex-1 bg-transparent py-0.5 text-sm text-[var(--text-primary)] outline-none placeholder:text-[var(--text-placeholder)] disabled:cursor-default\"\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 {error && (\n <p id={errorId} className=\"text-xs text-[var(--danger)]\">\n {error}\n </p>\n )}\n {rejected && (\n <p id={rejectedId} className=\"text-xs text-[var(--danger)]\" data-chip-input-rejected=\"\">\n {rejected}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";AAmvBI,mBAWmB,KAXnB;AAnvBJ,SAAS,YAAY,gBAAgB,aAAa,OAAO,iBAAiB,QAAQ,gBAAgB;AAElG,SAAS,OAAO,SAAS;AAEzB,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,cAAc,YAAY,oBAAoB;AAC9E,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB,SAAS,uBAAuB;AA6DhC,MAAM,O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9E,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,gBAIA,cAAY,QAAQ,SAAa,iBAAiB;AAAA,gBAClD,oBAAkB,eAAe;AAAA,gBACjC,gBAAc,aAAa,CAAC,CAAC,YAAY;AAAA,gBACzC,WAAU;AAAA;AAAA,YACZ;AAAA,YAIA,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,eAAW,MAAC,WAAU,iBAC1D,mBACH;AAAA;AAAA;AAAA,MACF;AAAA,MACC,SACC,oBAAC,OAAE,IAAI,SAAS,WAAU,gCACvB,iBACH;AAAA,MAED,YACC,oBAAC,OAAE,IAAI,YAAY,WAAU,gCAA+B,4BAAyB,IAClF,oBACH;AAAA,OAEJ;AAAA;AAEJ;","names":["Chip","inner"]}
@@ -0,0 +1,182 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { ColumnRole, ColumnMapperResult, ColumnMapping } from '../lib/column-mapping.js';
4
+ import { TextTable } from '../lib/table-text.js';
5
+
6
+ /**
7
+ * A table pasted, dropped or chosen as a file, and which of its columns plays which
8
+ * part — Kurvenschmiede's columns input and keksdose's bank-file mapping step, once.
9
+ *
10
+ * Kurvenschmiede (`features/control/columns-input.tsx` + `csv.ts`) reads a recorder's
11
+ * export into a playground signal (time, value) and a comparison (time, setpoint,
12
+ * actual): a textarea, a file button, a parse, a select per role, and a line that says
13
+ * which decimal convention was assumed and how many lines were skipped. keksdose
14
+ * (`import-map-step.tsx`) shows a bank's CSV as a table with a role select on every
15
+ * column's header, the file's real values under it, ignored columns dimmed, and what
16
+ * the import still needs named under it. Same problem, two hand-built answers.
17
+ *
18
+ * Two layers, so both shapes fit:
19
+ *
20
+ * * {@link ColumnMapper} — the whole single panel: paste, drop or choose → parse
21
+ * ({@link parseTextTable}: separator, decimal convention, header line, all stated
22
+ * back) → preview with a role per column → `onChange(result)`. Kurvenschmiede's.
23
+ * * {@link ColumnRoleTable} — the preview with the role selects alone, controlled, over
24
+ * rows the caller already has. keksdose's map step, whose rows come from its server's
25
+ * sniff (encodings, quoted multi-line cells, skipped title rows) and whose mapping
26
+ * lives in the wizard's state between steps.
27
+ *
28
+ * The rules under both are headless in `lib/column-mapping.ts`: a role moves rather
29
+ * than doubling up, what is missing is named, and the rows a numeric role cannot read
30
+ * are reported by line number rather than dropped.
31
+ */
32
+ interface ColumnMapperLabels {
33
+ /** The paste box's label. */
34
+ paste: string;
35
+ /** The caption under the paste box. */
36
+ pasteHint: string;
37
+ /** The file button. */
38
+ chooseFile: string;
39
+ /** A chosen or dropped file whose bytes could not be read at all. */
40
+ readError: (name: string) => string;
41
+ /** The checkbox that says whether the first line names the columns. */
42
+ headerRow: string;
43
+ /** What was read: so many columns and rows. */
44
+ summary: (columns: number, rows: number) => string;
45
+ /** The separator that was assumed. */
46
+ separatorSemicolon: string;
47
+ separatorComma: string;
48
+ separatorTab: string;
49
+ separatorSpace: string;
50
+ /** The decimal convention that was assumed — with an example, because "decimal
51
+ * comma" alone is a term, and `1,5` is something a reader recognises. */
52
+ decimalComma: string;
53
+ decimalPoint: string;
54
+ /** The title over the lines that could not be read. */
55
+ unreadCount: (count: number) => string;
56
+ /** One of them. */
57
+ unreadLine: (line: number) => string;
58
+ /** Past the first hundred listed. */
59
+ unreadMore: (count: number) => string;
60
+ /** The text has content, and none of it is a row. */
61
+ noRows: string;
62
+ /** The preview table's name. */
63
+ table: string;
64
+ /** A column the table names no header for. */
65
+ columnN: (n: number) => string;
66
+ /** The role select on a column's header — its accessible name. */
67
+ roleOf: (column: string) => string;
68
+ /** The role select's "no role" option. */
69
+ ignore: string;
70
+ /** A required role in the select. */
71
+ requiredRole: (role: string) => string;
72
+ /** Under the preview, when it shows fewer rows than were read. */
73
+ previewOf: (shown: number, total: number) => string;
74
+ /** A required group's roles, already joined as a list with "or". */
75
+ oneOf: (roles: string) => string;
76
+ /** What the table still needs, already joined as a list with "and". */
77
+ missing: (roles: string) => string;
78
+ }
79
+ declare const DEFAULT_COLUMN_MAPPER_LABELS: ColumnMapperLabels;
80
+ interface ColumnRoleTableProps<R extends string, M extends ColumnMapping<R> = ColumnMapping<R>> {
81
+ /** The columns' names — the file's header line — or `null` for a table without one
82
+ * (each column is then "Column 1", "Column 2", …). */
83
+ header: readonly string[] | null;
84
+ /** The rows to preview, as text. Only the first {@link previewRows} are drawn. */
85
+ rows: readonly (readonly string[])[];
86
+ /** How many columns. Default: the header's length or the widest previewed row. */
87
+ width?: number;
88
+ /** The parts a column can play. */
89
+ roles: readonly ColumnRole<R>[];
90
+ /** Role → column. Any object with the roles as nullable number fields — keksdose's
91
+ * `CsvMapping` as it stands; the other fields are handed back untouched. */
92
+ mapping: M;
93
+ /** The next mapping, with the picked role moved onto its column. */
94
+ onMappingChange: (next: M) => void;
95
+ /** Default 5. */
96
+ previewRows?: number;
97
+ /** How many rows the table has in all, for "The first 5 of 120 rows". Default:
98
+ * `rows.length`. */
99
+ totalRows?: number;
100
+ /** Every role select disabled — keksdose locks them while a re-sniff replaces the
101
+ * table they point into. */
102
+ disabled?: boolean;
103
+ labels?: Partial<ColumnMapperLabels>;
104
+ className?: string;
105
+ }
106
+ /**
107
+ * A table's first rows, with a role select on every column's header.
108
+ *
109
+ * keksdose's mapping step (dev#462: "make it more table like, where the table columns
110
+ * can be chosen from the input and the column data changes with the chosen column
111
+ * header"): the file IS the form. The file's own column name sits on top, verbatim —
112
+ * it is how the reader recognises the column; under it the role, picked in place;
113
+ * under that the column's real values, so a column that is one off shows up here and
114
+ * not after the import. A column with no role says "Ignore" and its values are dimmed:
115
+ * the state that most needs to be visible in a twelve-column bank export.
116
+ *
117
+ * Picking a role another column holds MOVES it ({@link assignColumnRole}). Required
118
+ * roles say so in the list, and what the table still needs is named under it — a
119
+ * required group as "either Amount, Debit or Credit".
120
+ *
121
+ * The table scrolls sideways inside its own box (the kit {@link Table}'s wrapper, a
122
+ * named, keyboard-reachable region while it overflows), so a wide export never widens
123
+ * the page at 390px.
124
+ */
125
+ declare function ColumnRoleTable<R extends string, M extends ColumnMapping<R> = ColumnMapping<R>>({ header, rows, width: widthProp, roles, mapping, onMappingChange, previewRows, totalRows, disabled, labels: labelsProp, className, }: ColumnRoleTableProps<R, M>): react.JSX.Element;
126
+ interface ColumnMapperProps<R extends string> {
127
+ /** The parts the columns play — translated labels, which are required, which must
128
+ * be numbers. See {@link ColumnRole}. */
129
+ roles: readonly ColumnRole<R>[];
130
+ /**
131
+ * The table read through the current mapping, on every change: the text, the header
132
+ * checkbox, a role. `null` while there is no table at all (an empty box). Use it when
133
+ * `result.complete`; until then `result.missing` says what is not placed yet.
134
+ *
135
+ * The rows are strings. A numeric role's cells are guaranteed to read with
136
+ * `tableNumber(cell, result.decimalComma)`; anything else is the caller's to convert.
137
+ */
138
+ onChange: (result: ColumnMapperResult<R> | null) => void;
139
+ /** The paste box's label. Default: `labels.paste`. */
140
+ label?: ReactNode;
141
+ /** The caption under the paste box. Default: `labels.pasteHint`. */
142
+ hint?: ReactNode;
143
+ /** What the file dialog offers, and what a drop is checked against. Default:
144
+ * `.csv,.tsv,.txt,.dat,.asc`. */
145
+ accept?: string;
146
+ /** The largest file taken, in bytes. Default: no limit. */
147
+ maxSize?: number;
148
+ /** Text to start with. `onChange` is called with its result once, on mount. */
149
+ defaultText?: string;
150
+ /** Rows in the preview. Default 5. */
151
+ previewRows?: number;
152
+ /** The first mapping for a new table. Default {@link guessMapping}: a column named
153
+ * like a role gets it, and the required roles left over take the free columns in
154
+ * order. */
155
+ guess?: (table: TextTable) => ColumnMapping<R>;
156
+ disabled?: boolean;
157
+ labels?: Partial<ColumnMapperLabels>;
158
+ className?: string;
159
+ }
160
+ /**
161
+ * Paste, drop or choose a table, see what it was read as, and say which column is
162
+ * which — Kurvenschmiede's playground signal and comparison input as one kit part.
163
+ *
164
+ * Everything the parse assumed is stated, because a guess the reader cannot see is a
165
+ * guess they cannot correct: the shape it found, the separator, the decimal
166
+ * convention ("decimal comma (1,5)"), and every line it could not read, by number and
167
+ * with its text. The header line is a checkbox, since the detection is a guess either
168
+ * way and toggling it does not move a column (the mapping is kept, keksdose's
169
+ * `keepRoles`). A new file is a new table and is mapped afresh; typing that changes the
170
+ * column count re-guesses, because the old indexes point at nothing.
171
+ *
172
+ * A file can be chosen, dropped on the button, or dropped on the paste box — which,
173
+ * left to the browser, would open the file in place of the page. It is read as UTF-8,
174
+ * or as Windows-1252 when it is not UTF-8 ({@link readTextFile}).
175
+ *
176
+ * A two-step wizard that keeps the drop and the mapping apart (keksdose's) uses the
177
+ * parts: {@link parseTextTable} or its own server's sniff, then {@link ColumnRoleTable},
178
+ * then {@link readMappedTable}.
179
+ */
180
+ declare function ColumnMapper<R extends string>({ roles, onChange, label, hint, accept, maxSize, defaultText, previewRows, guess, disabled, labels: labelsProp, className, }: ColumnMapperProps<R>): react.JSX.Element;
181
+
182
+ export { ColumnMapper, type ColumnMapperLabels, type ColumnMapperProps, ColumnRoleTable, type ColumnRoleTableProps, DEFAULT_COLUMN_MAPPER_LABELS };