@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
@@ -0,0 +1,403 @@
1
+ import { createContext, useId } from "react";
2
+ import type { ComponentPropsWithoutRef, ReactNode } from "react";
3
+ import { cn } from "../lib/cn";
4
+ import { Tooltip } from "./tooltip";
5
+ import { useCommitReason } from "./write-lock";
6
+ import { hasMessage, mergeDescribedBy } from "./choice-parts";
7
+
8
+ /**
9
+ * The pieces of a field's anatomy the kit's fields share — the static label, the hint
10
+ * (caption or "?"), the caption and the error under a field, the label strip over a
11
+ * bare group, the write lock on a control that saves itself. Private to the package —
12
+ * not re-exported from the barrel, except `FieldLabel` and `FLOATING_LABEL_STATIC`,
13
+ * which ui.tsx re-exports as it always has.
14
+ *
15
+ * One file since 0.23: until then the pickers' half (`field-anatomy.tsx`: the date and
16
+ * month pickers, whose trigger is a button in a wrapper of their own, and the groups
17
+ * with no field box) sat beside this one with its own copies of `isTextHint` and the
18
+ * caption class (keksdose K4: "uniform field anatomy … today it is a patchwork").
19
+ *
20
+ * Nothing here imports `ui.tsx`: `ui.tsx` imports this, and so do the combobox family,
21
+ * the pickers and the native choice controls — the lint's no-cycle rule holds it.
22
+ */
23
+
24
+ /* ── the static label ─────────────────────────────────────────────────────── */
25
+
26
+ // The TYPE of the small static label, without any placement. Split out so the
27
+ // label and anything sharing its line (see `hint` on {@link FloatingField}) are
28
+ // laid out by one flex row instead of by two absolute offsets guessing at the
29
+ // same baseline — which is what put dev#468's "?" three pixels above the word it
30
+ // belongs to.
31
+ export const STATIC_LABEL_TYPE =
32
+ "text-[11px] leading-tight text-[var(--text-muted)] peer-disabled:opacity-50";
33
+
34
+ // A field that always has a value (select / dropdown trigger) keeps the label
35
+ // permanently in the floated position — small, in the top strip, value below.
36
+ export const FLOATING_LABEL_STATIC = cn(
37
+ "pointer-events-none absolute start-3 top-1",
38
+ STATIC_LABEL_TYPE,
39
+ "max-w-[calc(100%-1.5rem)] truncate",
40
+ );
41
+
42
+ /**
43
+ * The floating label for a custom-dropdown trigger (a `<span>`, since the trigger is a
44
+ * button not a labelable input). Same placement as {@link FloatingField}'s static label,
45
+ * so every labelled field lines up. Render inside a `relative` wrapper, before the trigger.
46
+ */
47
+ export interface FieldLabelProps extends ComponentPropsWithoutRef<"span"> {
48
+ children: ReactNode;
49
+ }
50
+
51
+ export function FieldLabel({ children, className, ...rest }: FieldLabelProps) {
52
+ return (
53
+ <span {...rest} className={cn(FLOATING_LABEL_STATIC, "z-10", className)}>
54
+ {children}
55
+ </span>
56
+ );
57
+ }
58
+
59
+ /* ── hint ─────────────────────────────────────────────────────────────────── */
60
+
61
+ /**
62
+ * Whether a `hint` is a CAPTION (plain text: a non-empty string or a number) or
63
+ * something for the label line (a {@link FieldHint} "?", or any other node).
64
+ *
65
+ * The rule {@link Select} and `NumberInput` already keep: the label line is 11px of
66
+ * strip shared with the label, and a sentence placed there ran over the label and into
67
+ * the value; a "?" under the field would be a button floating free of the label it
68
+ * explains.
69
+ */
70
+ export function isTextHint(hint: ReactNode): hint is string | number {
71
+ return (typeof hint === "string" && hint !== "") || typeof hint === "number";
72
+ }
73
+
74
+ /** The caption under a field — Select's and NumberInput's type, so every field's
75
+ * standing advice reads alike. */
76
+ export const FIELD_CAPTION_CLASS = "mt-1 text-[11px] leading-tight text-[var(--text-muted)]";
77
+
78
+ export interface FieldHintParts {
79
+ /** The caller's `aria-describedby` with the caption's id appended — standing
80
+ * advice first; the error (the news) is appended after this by the field. */
81
+ describedBy: string | undefined;
82
+ /** The caption's id while there is one. */
83
+ captionId: string | undefined;
84
+ /** The caption itself, or `undefined` for a hint that is not text. */
85
+ captionText: string | number | undefined;
86
+ /** A non-text hint (a FieldHint) for the label line — or, on a field with no label
87
+ * line, the end edge outside the box. `undefined` when there is none. */
88
+ labelHint: ReactNode | undefined;
89
+ }
90
+
91
+ /**
92
+ * Split a field's `hint` into the caption under it (attached with `aria-describedby`)
93
+ * or the "?" on its label line. See {@link isTextHint}.
94
+ */
95
+ export function useFieldHint(hint: ReactNode, describedBy: string | undefined): FieldHintParts {
96
+ const captionId = useId();
97
+ const text = isTextHint(hint);
98
+ return {
99
+ describedBy: text ? mergeDescribedBy(describedBy, captionId) : describedBy,
100
+ captionId: text ? captionId : undefined,
101
+ captionText: text ? hint : undefined,
102
+ labelHint: !text && hasMessage(hint) ? hint : undefined,
103
+ };
104
+ }
105
+
106
+ /** The caption under a field, as {@link Select} draws its own. */
107
+ export function FieldCaption({ parts, className }: { parts: FieldHintParts; className?: string }) {
108
+ if (parts.captionText === undefined) return null;
109
+ return (
110
+ <p id={parts.captionId} className={cn(FIELD_CAPTION_CLASS, className)}>
111
+ {parts.captionText}
112
+ </p>
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Classes that take a static floating label (`FLOATING_LABEL_STATIC`: `FieldLabel`,
118
+ * `ComboboxFieldLabel`) out of its own absolute slot and into a {@link StaticLabelRow}.
119
+ * `static` wins over `absolute` through `cn`'s merge; `min-w-0` lets it truncate in
120
+ * the row.
121
+ */
122
+ export const LABEL_IN_ROW = "static min-w-0";
123
+
124
+ /**
125
+ * A static label and its "?" on one line, in the top strip of a field that lays out its
126
+ * own label — the combobox family, which cannot use {@link FloatingField} because the
127
+ * trigger, the anchored panel and the label hang off a box of their own.
128
+ *
129
+ * FloatingField's static row, with one difference: it stops at `end-9`, the column the
130
+ * chevron (or the clear "×") takes, so a long label truncates before it rather than
131
+ * putting the "?" on top of the chevron. The hint keeps its width; the label gives way.
132
+ */
133
+ export function StaticLabelRow({ hint, children }: { hint: ReactNode; children: ReactNode }) {
134
+ return (
135
+ <div className="pointer-events-none absolute start-3 end-9 top-1 z-10 flex items-center gap-1">
136
+ {children}
137
+ <span className="pointer-events-auto flex shrink-0 items-center">{hint}</span>
138
+ </div>
139
+ );
140
+ }
141
+
142
+ /**
143
+ * A field with no label line and a FieldHint "?": the hint at the end edge, OUTSIDE the
144
+ * box, as an unlabelled {@link Select} has placed it since 0.15.5. Without a hint the
145
+ * field is returned exactly as it was, so the wrapper costs nothing where it does not
146
+ * apply.
147
+ */
148
+ export function EndHintRow({
149
+ hint,
150
+ className,
151
+ children,
152
+ }: {
153
+ hint: ReactNode | undefined;
154
+ className?: string;
155
+ children: ReactNode;
156
+ }) {
157
+ if (hint === undefined) return <>{children}</>;
158
+ return (
159
+ <div className={cn("flex items-center gap-1.5", className)}>
160
+ <div className="min-w-0 flex-1">{children}</div>
161
+ <span className="flex shrink-0 items-center">{hint}</span>
162
+ </div>
163
+ );
164
+ }
165
+
166
+ /* ── the write lock on a control that saves itself (keksdose K3) ───────────── */
167
+
168
+ export interface LockReason {
169
+ /** The reason in force — the lock's (with `commit` under a locked
170
+ * `WriteLockProvider`), else the control's own `disabledReason`. */
171
+ reason: ReactNode;
172
+ /** There is a reason: the control is locked the focusable way. */
173
+ locked: boolean;
174
+ /** The id of the reason's hidden copy, for the control's `aria-describedby`. */
175
+ reasonId: string;
176
+ }
177
+
178
+ /**
179
+ * {@link Button}'s `commit` + `disabledReason`, for a control that IS its own commit — a
180
+ * switch, a checkbox or a select that saves on change, a list row whose click writes.
181
+ * The lock's reason wins over the control's own (`useCommitReason`).
182
+ */
183
+ export function useLockReason(commit: boolean | undefined, disabledReason: ReactNode): LockReason {
184
+ const reason = useCommitReason(commit, disabledReason);
185
+ const reasonId = useId();
186
+ return { reason, locked: hasMessage(reason), reasonId };
187
+ }
188
+
189
+ /**
190
+ * The kit {@link Tooltip} around a locked control, with a `hidden` copy of the reason for
191
+ * the control's `aria-describedby` — Button's anatomy. The control goes in a FRAGMENT so
192
+ * the Tooltip does not also clone its bubble's id into the description: the hidden copy
193
+ * already describes it, and the same sentence twice would be read on every focus.
194
+ *
195
+ * `className` is the wrapper's, which becomes the outermost element while locked — a
196
+ * control moves its own layout classes here so a lock does not reflow the form.
197
+ */
198
+ export function LockedReason({
199
+ lock,
200
+ className,
201
+ children,
202
+ }: {
203
+ lock: LockReason;
204
+ className?: string;
205
+ children: ReactNode;
206
+ }) {
207
+ return (
208
+ <Tooltip label={lock.reason} className={className}>
209
+ <>
210
+ {children}
211
+ <span id={lock.reasonId} hidden>
212
+ {lock.reason}
213
+ </span>
214
+ </>
215
+ </Tooltip>
216
+ );
217
+ }
218
+
219
+ /* ── groups ───────────────────────────────────────────────────────────────── */
220
+
221
+ /**
222
+ * Set by {@link CheckboxGroup}: its legend carries the one required star, so a box
223
+ * inside it keeps the native `required` (a form still refuses an empty set) but draws no
224
+ * star of its own — four stars on four languages would read as four separate demands.
225
+ * ChoiceCardGroup's `InGroupContext`, for the plain checkbox.
226
+ */
227
+ export const RequiredStarOnLegend = createContext(false);
228
+
229
+ /* ── fields not built on FloatingField: pickers and bare groups ──────────── */
230
+
231
+ /** `undefined`, `null`, `false` and `""` are what a caller's `cond && "…"` evaluates to
232
+ * when there is nothing to say; none of them is content. A numeric `0` is. */
233
+ export function hasContent(node: ReactNode): boolean {
234
+ return node !== undefined && node !== null && node !== false && node !== "";
235
+ }
236
+
237
+ const FIELD_ERROR_CLASS = "mt-1 text-[11px] leading-tight text-[var(--danger)]";
238
+
239
+ export interface FieldMessages {
240
+ /** `invalid`, a message, or an `aria-invalid` from outside (a form library). */
241
+ isInvalid: boolean;
242
+ /** The caller's description, then the caption, then the error — the standing
243
+ * advice before the news, as `useFieldError` in ui.tsx orders them. */
244
+ describedBy: string | undefined;
245
+ /** The caption and the error, for under the field; `null` when there is neither. */
246
+ below: ReactNode;
247
+ /** The hint for the LABEL line (a `FieldHint`), or `undefined` when the hint is a
248
+ * caption or there is none. */
249
+ labelHint: ReactNode;
250
+ }
251
+
252
+ /** `hint` / `error` / `invalid` resolved the way `Select` resolves them. */
253
+ export function useFieldMessages({
254
+ hint,
255
+ error,
256
+ invalid,
257
+ describedBy,
258
+ ariaInvalid,
259
+ }: {
260
+ hint?: ReactNode;
261
+ error?: ReactNode;
262
+ invalid?: boolean;
263
+ describedBy?: string;
264
+ ariaInvalid?: unknown;
265
+ }): FieldMessages {
266
+ const hintId = useId();
267
+ const errorId = useId();
268
+ const textHint = isTextHint(hint);
269
+ const hasError = hasContent(error);
270
+ return {
271
+ isInvalid: Boolean(invalid) || hasError || ariaInvalid === true || ariaInvalid === "true",
272
+ describedBy:
273
+ [describedBy, textHint && hintId, hasError && errorId].filter(Boolean).join(" ") || undefined,
274
+ below:
275
+ textHint || hasError ? (
276
+ <>
277
+ {textHint && (
278
+ <p id={hintId} className={FIELD_CAPTION_CLASS}>
279
+ {hint}
280
+ </p>
281
+ )}
282
+ {hasError && (
283
+ <p id={errorId} className={FIELD_ERROR_CLASS}>
284
+ {error}
285
+ </p>
286
+ )}
287
+ </>
288
+ ) : null,
289
+ labelHint: !textHint && hasContent(hint) ? hint : undefined,
290
+ };
291
+ }
292
+
293
+ /**
294
+ * The field and what is under it, as one box — `FieldGroup` in ui.tsx, for the same
295
+ * reasons written there. Nothing of its own while there is nothing under the field and
296
+ * the caller passed no `error` key (the DOM is exactly what it was before these props);
297
+ * once `error` is passed the box is kept even with no message, so the trigger is never
298
+ * reparented — and remounted, losing focus — as the message comes and goes.
299
+ */
300
+ export function FieldBox({
301
+ below,
302
+ reserve,
303
+ children,
304
+ }: {
305
+ below: ReactNode;
306
+ reserve: boolean;
307
+ children: ReactNode;
308
+ }) {
309
+ if (below === null && !reserve) return <>{children}</>;
310
+ return (
311
+ <div>
312
+ {children}
313
+ {below}
314
+ </div>
315
+ );
316
+ }
317
+
318
+ /**
319
+ * The static label in a trigger field's top strip — a {@link FieldLabel}, or, with a
320
+ * `FieldHint`, the label and its "?" laid out on ONE flex row (dev#468: two absolute
321
+ * offsets guessing at the same baseline put the "?" three pixels above its word).
322
+ * `FloatingField`'s static-label row, except that it stops at `end-9`: the date and
323
+ * month triggers keep that column (`pe-9`) for the calendar glyph or the clear ×, and a
324
+ * long label truncates before it rather than putting the "?" on top of it.
325
+ */
326
+ export function FieldLabelLine({ label, hint }: { label: ReactNode; hint?: ReactNode }) {
327
+ if (!hasContent(hint)) return <FieldLabel>{label}</FieldLabel>;
328
+ return (
329
+ // `z-10` as FieldLabel has it: the trigger after it is `relative` and would paint
330
+ // over the row (and take the "?"'s hover) otherwise.
331
+ <div className="pointer-events-none absolute start-3 end-9 top-1 z-10 flex items-center gap-1">
332
+ <FieldLabel className="static min-w-0 max-w-full">{label}</FieldLabel>
333
+ <span className="pointer-events-auto flex shrink-0 items-center">{hint}</span>
334
+ </div>
335
+ );
336
+ }
337
+
338
+ /**
339
+ * How tall the strip over a bare group is — the values {@link FieldStrip}'s `pad` takes,
340
+ * public since 0.23 (keksdose G8), so the names say what the CONTENT needs rather than
341
+ * which kit group first needed it (until 0.23 they were `toggle` and `tiles`).
342
+ *
343
+ * - `"field"` — 16px. keksdose's `ClearedStatusPicker` (live #288 rework, #431,
344
+ * measured): *"16px of label strip plus a 26px group is exactly a labelled Input"*,
345
+ * so a status group in a row of 42px fields ends where they end. The label's line
346
+ * box runs into the group's top hairline, but the ACTIVE fill — the thing feedback
347
+ * #117 was about — starts at 19px, below the label's 17.75px. For content with a
348
+ * border and an inset of its own; ToggleGroup's `labelPlacement="strip"`.
349
+ * - `"clear"` — 20px, keksdose's `FlagPicker` and location field (`pt-5`). A tile has
350
+ * no inset fill: its selection IS its frame, a 2px dark border-and-ring from the
351
+ * tile's top edge, so the tile has to start below the whole label line — and so does
352
+ * anything else with no inset: a map, a row of buttons, a line of text. SwatchPicker,
353
+ * IconPicker, and FieldStrip's default.
354
+ */
355
+ export const LABEL_STRIP_PAD = { field: "pt-4", clear: "pt-5" } as const;
356
+
357
+ /**
358
+ * The 11px label (and its `FieldHint`) over a group that is NOT a field — keksdose K2:
359
+ * a segmented control or a row of swatches standing in a form row beside labelled
360
+ * inputs, whose label must sit on the same line as theirs (`top-1`, `inset-x-3`, the
361
+ * type of a field's static label) without the group growing a field's border round
362
+ * it. `id` goes on the label so the group can be `aria-labelledby` it.
363
+ *
364
+ * `relative` is load-bearing twice over: the row is positioned against it, and a
365
+ * caller's `sr-only` label cannot escape it (sr-only-containment).
366
+ *
367
+ * Any other attribute (`rest`) lands on the wrapper — {@link FieldStrip} makes it the
368
+ * `role="group"` its label names. The kit's own groups pass none, so their wrapper is
369
+ * the bare box it was in 0.22.
370
+ */
371
+ export function LabelStrip({
372
+ labelId,
373
+ label,
374
+ hint,
375
+ disabled,
376
+ pad,
377
+ className,
378
+ children,
379
+ ...rest
380
+ }: Omit<ComponentPropsWithoutRef<"div">, "children"> & {
381
+ labelId: string;
382
+ label: ReactNode;
383
+ hint?: ReactNode;
384
+ /** Dim the label with its group, as `peer-disabled:` dims a field's own. */
385
+ disabled?: boolean;
386
+ pad: keyof typeof LABEL_STRIP_PAD;
387
+ children: ReactNode;
388
+ }) {
389
+ return (
390
+ <div {...rest} className={cn("relative min-w-0", LABEL_STRIP_PAD[pad], className)}>
391
+ <div className="pointer-events-none absolute inset-x-3 top-1 flex items-center gap-1">
392
+ {/* `static`: FieldLabel positions itself absolutely; here the ROW is
393
+ positioned, so the label and its "?" are centred on one line by the flex
394
+ layout (dev#468). */}
395
+ <FieldLabel id={labelId} className={cn("static min-w-0 max-w-full", disabled && "opacity-50")}>
396
+ {label}
397
+ </FieldLabel>
398
+ {hasContent(hint) && <span className="pointer-events-auto flex shrink-0 items-center">{hint}</span>}
399
+ </div>
400
+ {children}
401
+ </div>
402
+ );
403
+ }
@@ -0,0 +1,149 @@
1
+ import { useId } from "react";
2
+ import type { ComponentPropsWithoutRef, ReactNode } from "react";
3
+ import { LabelStrip, useFieldMessages } from "./field-parts";
4
+
5
+ /**
6
+ * How far down the content starts, under the 11px label — see {@link FieldStripProps.pad}.
7
+ *
8
+ * - `"clear"` (default) — 20px: the content starts below the label's whole line box.
9
+ * - `"field"` — 16px: the strip plus a 26px bordered control is exactly a labelled
10
+ * {@link Input}'s 42px.
11
+ */
12
+ export type FieldStripPad = "clear" | "field";
13
+
14
+ /** What a {@link FieldStrip} hands render-prop children. */
15
+ export interface FieldStripIds {
16
+ /** The label's id — for content that names ITSELF by the label (`aria-labelledby`)
17
+ * under `group={false}`, or anything else that has to point at it. */
18
+ labelId: string;
19
+ /** The ids of the caption and the error while they are on screen, else `undefined`.
20
+ * The group is described by them already; spread this on the content under
21
+ * `group={false}`, where there is no group to describe. */
22
+ describedBy: string | undefined;
23
+ }
24
+
25
+ export interface FieldStripProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
26
+ /** The 11px static label, on the line a labelled field's label sits on. */
27
+ label: ReactNode;
28
+ /**
29
+ * Field anatomy, as on {@link Input}: plain text is a caption under the content (and
30
+ * describes the group); a {@link FieldHint} "?" rides the label line.
31
+ */
32
+ hint?: ReactNode;
33
+ /** A message under the content, in `--danger`, describing the group. `null`,
34
+ * `false` and `""` are no error. The content's own controls are the caller's to
35
+ * mark `aria-invalid`; a `group` cannot be. */
36
+ error?: ReactNode;
37
+ /**
38
+ * Dims the label with the content, as a disabled field's label dims. The content is
39
+ * the caller's: disable (or hide) its controls yourself — keksdose's location cell
40
+ * turns its map into a picture and drops its buttons, which no flag here could guess.
41
+ */
42
+ disabled?: boolean;
43
+ /**
44
+ * How tall the strip is — what the content needs, measured in keksdose (`pt-5` /
45
+ * `pt-4`, the 0.22 `LABEL_STRIP_PAD`):
46
+ *
47
+ * - `"clear"` (default) — 20px. The content starts below the label's whole line box
48
+ * (4px down, 13.75px tall). For content with no inset of its own: a map, a row of
49
+ * buttons, a pill, a line of text, a row of tiles whose selection is their frame
50
+ * (SwatchPicker, IconPicker).
51
+ * - `"field"` — 16px. The strip plus a 26px bordered control (1 + 2 + 20 + 2 + 1) is
52
+ * exactly a labelled Input's 42px, so the row's bottom edges line up. The label's
53
+ * line box runs 1.75px into the control's top hairline, so only content with an
54
+ * inset of its own keeps clear of it — the segmented group's 2px moat
55
+ * (ToggleGroup's `labelPlacement="strip"`).
56
+ *
57
+ * A responsive strip is a `className`: it merges after the pad, so keksdose's status
58
+ * cell writes `className="pt-5 @3xl:pt-4"` (20px on a phone, 16px in the desktop row).
59
+ */
60
+ pad?: FieldStripPad;
61
+ /**
62
+ * The wrapper is a `role="group"` named by the label (default), so a screen reader
63
+ * entering the map or the first button hears "Location, group" — what the visible
64
+ * label tells a sighted reader the content is about.
65
+ *
66
+ * `false` for content that is a labelled group ITSELF (a `role="radiogroup"` of the
67
+ * app's own, a TileRadioGroup's container, a fieldset): a group inside a group, both
68
+ * named "Pattern", is read twice. The wrapper is then a plain box, and the content
69
+ * takes the name from the render-prop's `labelId` (and the caption and error from
70
+ * its `describedBy`).
71
+ */
72
+ group?: boolean;
73
+ /** The content. A function receives {@link FieldStripIds}. */
74
+ children: ReactNode | ((ids: FieldStripIds) => ReactNode);
75
+ }
76
+
77
+ /**
78
+ * The kit's label strip for content of your own — keksdose G8.
79
+ *
80
+ * 0.22 gave three groups a strip label (keksdose K2): ToggleGroup's
81
+ * `labelPlacement="strip"`, SwatchPicker's and IconPicker's `label`. Each draws the
82
+ * 11px label (and its `FieldHint`) on the same line as the labelled fields beside it,
83
+ * over content WITHOUT a field's border round it. keksdose's transaction row has one
84
+ * cell left that is not one of those groups: the location — a map, a "Locate me" and a
85
+ * "Search" button — still built by hand as a `relative` cell, a floated `FieldLabel`
86
+ * and a `pt-5` box (transaction-location-field.tsx), and so is the reconciled-status
87
+ * stand-in (cleared-status-toggle.tsx, `ClearedStatusLocked`). This is the strip on its
88
+ * own, the same component the three groups draw theirs with:
89
+ *
90
+ * ```tsx
91
+ * <FieldStrip label={t("transactions.location")} className={className}>
92
+ * <div className="space-y-2">
93
+ * <PinMap … />
94
+ * <div className="flex flex-wrap gap-2"><Button …>Locate me</Button>…</div>
95
+ * </div>
96
+ * </FieldStrip>
97
+ * ```
98
+ *
99
+ * The label sits where a field's static label sits (`top-1`, `inset-x-3`, 11px in a
100
+ * `leading-tight` line); the content starts `pad` down, full width. `className` styles
101
+ * the wrapper — the grid or flex item in the caller's row — and merges after the pad.
102
+ *
103
+ * Not a {@link Field}: that one sets a 14px label ABOVE its control, in flow, for a form
104
+ * that labels its fields that way. This is for a row whose fields float their labels
105
+ * inside them, where a label above would be the only one of its kind.
106
+ */
107
+ export function FieldStrip({
108
+ label,
109
+ hint,
110
+ error,
111
+ disabled = false,
112
+ pad = "clear",
113
+ group = true,
114
+ className,
115
+ children,
116
+ ...rest
117
+ }: FieldStripProps) {
118
+ const labelId = useId();
119
+ const messages = useFieldMessages({ hint, error });
120
+ const content = typeof children === "function" ? children({ labelId, describedBy: messages.describedBy }) : children;
121
+ // The caller's own description first, then the caption, then the error — the order
122
+ // every kit field reads them in.
123
+ const groupDescribedBy = [rest["aria-describedby"], messages.describedBy].filter(Boolean).join(" ") || undefined;
124
+ return (
125
+ <LabelStrip
126
+ {...rest}
127
+ {...(group
128
+ ? {
129
+ role: "group",
130
+ // An explicit name wins, as on the kit's labelled groups.
131
+ "aria-labelledby":
132
+ rest["aria-label"] === undefined && rest["aria-labelledby"] === undefined
133
+ ? labelId
134
+ : rest["aria-labelledby"],
135
+ "aria-describedby": groupDescribedBy,
136
+ }
137
+ : null)}
138
+ labelId={labelId}
139
+ label={label}
140
+ hint={messages.labelHint}
141
+ disabled={disabled}
142
+ pad={pad}
143
+ className={className}
144
+ >
145
+ {content}
146
+ {messages.below}
147
+ </LabelStrip>
148
+ );
149
+ }
@@ -5,6 +5,7 @@ import { useAnnounce } from "../hooks/use-announce";
5
5
  import { useKitFileLabels, useKitLabels } from "../i18n/kit-labels";
6
6
  import { Button, Spinner } from "./ui";
7
7
  import { Tooltip } from "./tooltip";
8
+ import { useCommitReason } from "./write-lock";
8
9
 
9
10
  /**
10
11
  * A button that opens the file picker — the shape all three apps kept writing by hand
@@ -428,6 +429,27 @@ export interface FileButtonProps
428
429
  * file leaves it as it was. Off by default, so the button's layout is unchanged.
429
430
  */
430
431
  showFileName?: boolean;
432
+ /**
433
+ * Why picking is not available — {@link Button}'s `disabledReason`, with the picker's
434
+ * half added (keksdose K3): the button is `aria-disabled` but stays focusable, the
435
+ * reason is in the kit Tooltip and its description, a click opens no picker, and a
436
+ * `droppable` button takes no drop (the drag is still cancelled, so the browser does
437
+ * not navigate to the file). Wins over `disabled`, as on Button.
438
+ */
439
+ disabledReason?: ReactNode;
440
+ /**
441
+ * This pick COMMITS — an upload that starts on pick, an attachment saved at once.
442
+ * Under a locked {@link WriteLockProvider} it takes the `disabledReason` path with
443
+ * the lock's reason (which wins over one of its own). No provider, or an unlocked
444
+ * one: no effect. A picker that only fills a form the user saves later is not a
445
+ * commit, and is left live — the form's Save carries the lock.
446
+ */
447
+ commit?: boolean;
448
+ }
449
+
450
+ /** A reason that is really there — `null`, `false` and `""` are no reason. */
451
+ function hasReason(reason: ReactNode): boolean {
452
+ return reason !== undefined && reason !== null && reason !== false && reason !== "";
431
453
  }
432
454
 
433
455
  /**
@@ -459,6 +481,8 @@ export const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(functio
459
481
  droppable,
460
482
  showFileName = false,
461
483
  disabled,
484
+ disabledReason: ownDisabledReason,
485
+ commit,
462
486
  children,
463
487
  className,
464
488
  onClick,
@@ -470,7 +494,13 @@ export const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(functio
470
494
  },
471
495
  ref,
472
496
  ) {
497
+ const disabledReason = useCommitReason(commit, ownDisabledReason);
498
+ const locked = hasReason(disabledReason);
473
499
  const inert = Boolean(disabled || pending);
500
+ // What takes no files: busy, disabled, or locked with a reason. Kept apart from
501
+ // `inert`, which is what reaches the button's NATIVE `disabled` — a locked button
502
+ // stays focusable (Button's `disabledReason` path), so `locked` must not get there.
503
+ const refusing = inert || locked;
474
504
  const [picked, setPicked] = useState<readonly File[]>([]);
475
505
  const pickedId = useId();
476
506
  const pickerLabels = useKitLabels("filePicker", DEFAULT_FILE_PICKER_LABELS, labels);
@@ -491,7 +521,7 @@ export const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(functio
491
521
  onPick,
492
522
  onReject,
493
523
  labels,
494
- disabled: inert,
524
+ disabled: refusing,
495
525
  });
496
526
  const pickedText =
497
527
  picked.length === 0 ? "" : picked.length === 1 ? picked[0].name : pickerLabels.selected(picked.length, picked[0].name);
@@ -505,7 +535,7 @@ export const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(functio
505
535
  onDragEnter?.(e);
506
536
  if (!hasFiles(e)) return;
507
537
  e.preventDefault();
508
- if (!inert) setDragOver(true);
538
+ if (!refusing) setDragOver(true);
509
539
  },
510
540
  onDragOver: (e: DragEvent<HTMLButtonElement>) => {
511
541
  onDragOver?.(e);
@@ -513,7 +543,7 @@ export const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(functio
513
543
  // Always cancel for a file drag, busy or not: an uncancelled drop makes the
514
544
  // browser NAVIGATE to the file, which loses the page.
515
545
  e.preventDefault();
516
- e.dataTransfer.dropEffect = inert ? "none" : "copy";
546
+ e.dataTransfer.dropEffect = refusing ? "none" : "copy";
517
547
  },
518
548
  onDragLeave: (e: DragEvent<HTMLButtonElement>) => {
519
549
  onDragLeave?.(e);
@@ -542,6 +572,9 @@ export const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(functio
542
572
  {...dropHandlers}
543
573
  type="button"
544
574
  disabled={inert}
575
+ // Resolved here rather than passed on as `commit`: the picker above has to know
576
+ // it is locked too, and one resolution keeps the two from disagreeing.
577
+ disabledReason={locked ? disabledReason : undefined}
545
578
  aria-busy={pending || undefined}
546
579
  aria-describedby={
547
580
  showFileName && pickedText