@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,15 +1,19 @@
1
1
  import 'react';
2
- export { P as DEFAULT_FILE_PICKER_LABELS, ae as FileButton, af as FileButtonProps, bu as FilePickHandler, ah as FilePickerLabels, ai as FileRejection, aj as FileRejectionReason, ak as FileScreenOptions, bf as UseFilePickerOptions, bg as UseFilePickerReturn, bv as formatAccept, bw as judgePick, bj as matchesAccept, bx as screenFiles, by as summariseRejections, bm as useFilePicker } from '../kit-labels-D1J2_jyD.js';
3
- import './data-table-labels.js';
2
+ export { a6 as DEFAULT_FILE_PICKER_LABELS, aN as FileButton, aO as FileButtonProps, ch as FilePickHandler, aQ as FilePickerLabels, aR as FileRejection, aS as FileRejectionReason, aT as FileScreenOptions, b$ as UseFilePickerOptions, c0 as UseFilePickerReturn, cj as formatAccept, ck as judgePick, c3 as matchesAccept, cl as screenFiles, cm as summariseRejections, c8 as useFilePicker } from '../feedback-BxeQVzwq.js';
3
+ import '../feedback-attachment-fGAzZPf0.js';
4
+ import '../feedback/feedback-inbox.js';
5
+ import 'lucide-react';
6
+ import './tooltip.js';
7
+ import '../hooks/use-anchored-rect.js';
8
+ import '../lib/clipping.js';
9
+ import '../data-table-labels-B7OdnM0S.js';
10
+ import './data-table-sort.js';
11
+ import './swipeable-row.js';
4
12
  import './mini-calendar.js';
5
13
  import './calendar-heatmap.js';
6
14
  import './popover.js';
7
15
  import './chip.js';
8
- import 'lucide-react';
9
16
  import './field-sync.js';
10
- import './tooltip.js';
11
- import '../hooks/use-anchored-rect.js';
12
- import '../lib/clipping.js';
13
17
  import '../wizard/types.js';
14
18
  import '../tour/tour.js';
15
19
  import '../search/command-palette.js';
@@ -23,7 +27,6 @@ import './sparkline.js';
23
27
  import './stat-tile.js';
24
28
  import './signature-pad.js';
25
29
  import './password-strength.js';
26
- import './danger-confirm.js';
27
30
  import './swatch-picker.js';
28
31
  import './tile-radio.js';
29
32
  import './icon-picker.js';
@@ -31,11 +34,7 @@ import './dialog-frame.js';
31
34
  import './modal.js';
32
35
  import '../hooks/use-search-param-state.js';
33
36
  import './measured-grid.js';
34
- import '../feedback-attachment-WFiXJ8We.js';
35
- import '../feedback/feedback-thread.js';
36
- import '../feedback/feedback-inbox.js';
37
37
  import './account-settings-labels.js';
38
- import './confirm-dialog.js';
39
38
  import './floating-panel.js';
40
39
  import './bulk-action-bar.js';
41
40
  import './list.js';
@@ -54,11 +53,17 @@ import './write-lock.js';
54
53
  import './legal.js';
55
54
  import './account-chips.js';
56
55
  import '../lib/format.js';
57
- import '../data-table-3mi2R3so.js';
58
- import './data-table-sort.js';
59
- import './swipeable-row.js';
60
56
  import './reauth-dialog.js';
61
57
  import './server-wake.js';
62
58
  import '../lib/server-wake.js';
63
59
  import './translation-review-labels.js';
64
60
  import '../lib/translation-review.js';
61
+ import './country-select.js';
62
+ import './inline-edit-field.js';
63
+ import '../lib/iban.js';
64
+ import '../lib/phone.js';
65
+ import './sign-chip.js';
66
+ import './column-mapper.js';
67
+ import '../lib/column-mapping.js';
68
+ import '../lib/table-text.js';
69
+ import './field-parts.js';
@@ -6,6 +6,7 @@ import { useAnnounce } from "../hooks/use-announce.js";
6
6
  import { useKitFileLabels, useKitLabels } from "../i18n/kit-labels.js";
7
7
  import { Button, Spinner } from "./ui.js";
8
8
  import { Tooltip } from "./tooltip.js";
9
+ import { useCommitReason } from "./write-lock.js";
9
10
  const DEFAULT_FILE_PICKER_LABELS = {
10
11
  rejectedType: (name) => `\u201C${name}\u201D is not a supported file type`,
11
12
  rejectedTypeOnly: (accept) => `Only ${accept} files`,
@@ -160,6 +161,9 @@ function useFilePicker({
160
161
  element
161
162
  };
162
163
  }
164
+ function hasReason(reason) {
165
+ return reason !== void 0 && reason !== null && reason !== false && reason !== "";
166
+ }
163
167
  const FileButton = forwardRef(function FileButton2({
164
168
  accept,
165
169
  multiple,
@@ -176,6 +180,8 @@ const FileButton = forwardRef(function FileButton2({
176
180
  droppable,
177
181
  showFileName = false,
178
182
  disabled,
183
+ disabledReason: ownDisabledReason,
184
+ commit,
179
185
  children,
180
186
  className,
181
187
  onClick,
@@ -185,7 +191,10 @@ const FileButton = forwardRef(function FileButton2({
185
191
  onDrop,
186
192
  ...rest
187
193
  }, ref) {
194
+ const disabledReason = useCommitReason(commit, ownDisabledReason);
195
+ const locked = hasReason(disabledReason);
188
196
  const inert = Boolean(disabled || pending);
197
+ const refusing = inert || locked;
189
198
  const [picked, setPicked] = useState([]);
190
199
  const pickedId = useId();
191
200
  const pickerLabels = useKitLabels("filePicker", DEFAULT_FILE_PICKER_LABELS, labels);
@@ -204,7 +213,7 @@ const FileButton = forwardRef(function FileButton2({
204
213
  onPick,
205
214
  onReject,
206
215
  labels,
207
- disabled: inert
216
+ disabled: refusing
208
217
  });
209
218
  const pickedText = picked.length === 0 ? "" : picked.length === 1 ? picked[0].name : pickerLabels.selected(picked.length, picked[0].name);
210
219
  const [dragOver, setDragOver] = useState(false);
@@ -214,13 +223,13 @@ const FileButton = forwardRef(function FileButton2({
214
223
  onDragEnter?.(e);
215
224
  if (!hasFiles(e)) return;
216
225
  e.preventDefault();
217
- if (!inert) setDragOver(true);
226
+ if (!refusing) setDragOver(true);
218
227
  },
219
228
  onDragOver: (e) => {
220
229
  onDragOver?.(e);
221
230
  if (!hasFiles(e)) return;
222
231
  e.preventDefault();
223
- e.dataTransfer.dropEffect = inert ? "none" : "copy";
232
+ e.dataTransfer.dropEffect = refusing ? "none" : "copy";
224
233
  },
225
234
  onDragLeave: (e) => {
226
235
  onDragLeave?.(e);
@@ -244,6 +253,7 @@ const FileButton = forwardRef(function FileButton2({
244
253
  ...dropHandlers,
245
254
  type: "button",
246
255
  disabled: inert,
256
+ disabledReason: locked ? disabledReason : void 0,
247
257
  "aria-busy": pending || void 0,
248
258
  "aria-describedby": showFileName && pickedText ? [rest["aria-describedby"], pickedId].filter(Boolean).join(" ") : rest["aria-describedby"],
249
259
  "data-drag-over": dragOver || void 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/file-button.tsx"],"sourcesContent":["import { forwardRef, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, DragEvent, ReactElement, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitFileLabels, useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, Spinner } from \"./ui\";\nimport { Tooltip } from \"./tooltip\";\n\n/**\n * A button that opens the file picker — the shape all three apps kept writing by hand\n * as a `<Button>` plus a hidden `<input type=\"file\">` plus a ref between them (seven\n * copies in keksdose, two each in kastlan and lenkbank).\n *\n * Every copy had to remember the same four things, and each one forgot at least one:\n *\n * 1. **Reset the input after every pick.** A file input fires `change` only when its\n * value CHANGES, so picking the same file twice in a row — the retry after a failed\n * upload, the second photo of the same receipt — did nothing at all, which reads as\n * a broken button. `value = \"\"` after each pick; always, not per call site.\n * 2. **`type=\"button\"`.** `<Button>` does not set it, and inside a form a bare button\n * submits the form before the picker opens.\n * 3. **Check the file.** `accept` filters the DIALOG, not the result: the dialog's\n * \"All files\" switch, a drop, and a mobile share sheet all hand over whatever the\n * user chose. So `accept` is re-checked here, along with `maxSize`, `maxFiles` and\n * an optional `isValid`.\n * 4. **Say no without a toast.** A rejection is reported through `onReject`, with a\n * translated message per file, and spoken through a live region — the kit does not\n * decide how an app surfaces errors (keksdose's proposal §1 asked for exactly that).\n *\n * The part that is not a button — the hidden input, the check, the announcement — is\n * {@link useFilePicker}, for the case where the thing that opens the picker is someone\n * else's control (a card's \"Add\" action, a menu item, a second button for the camera).\n */\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the file pickers ({@link FileButton}, `FileDropzone`) render or speak.\n * Messages are functions of the file name so a translation can put it anywhere. */\nexport interface FilePickerLabels {\n /** The file's type is not in `accept`, when no `accept` is known to name (see\n * `rejectedTypeOnly`). */\n rejectedType: (name: string) => string;\n /** The file's type is not in `accept`, naming what IS accepted: `accept`'s tokens,\n * lower-cased and joined with \", \" (`\".csv\"` => \"Only .csv files\"). Used whenever\n * `accept` is set — kastlan kept a custom `isValid` + `invalidMessage` per form only\n * to say this, and `accept` already knows it. */\n rejectedTypeOnly: (accept: string, name: string) => string;\n /** The file is larger than `maxSize`; `maxSize` arrives formatted (\"5 MB\"). */\n rejectedSize: (name: string, maxSize: string) => string;\n /** The file was one too many for `maxFiles`. */\n rejectedCount: (name: string, maxFiles: number) => string;\n /** `isValid` said no and the caller gave no `invalidMessage`. */\n rejectedInvalid: (name: string) => string;\n /** Spoken instead of the per-file message when more than one file was refused. */\n rejectedMany: (count: number) => string;\n /** Spoken (and shown, on a dropzone) when `onPick` refused the WHOLE pick.\n * Receives the number of files in it. */\n rejectedPick: (count: number) => string;\n /** Spoken after a pick the component itself echoes (the dropzone). */\n selected: (count: number, firstName: string) => string;\n /** The dropzone's remove button for one file. */\n remove: (name: string) => string;\n /** The dropzone's remove-everything button in `multiple` mode. */\n clearAll: string;\n /** Spoken after a remove / clear, since the button that was pressed is gone. */\n removed: (name: string) => string;\n cleared: string;\n /** The dropzone's accessible name, when the host passes no `dropLabel`. */\n dropzone: string;\n /** The dropzone's Browse button, when the host passes no `browseLabel`. */\n browse: string;\n /** What an empty single-file dropzone says (no `emptyLabel` given). */\n empty: string;\n /** …and an empty `multiple` one. */\n emptyMultiple: string;\n /** The dropzone's second line (no `hint` given). Receives `accept` as a person\n * reads it (`\".pdf, image/png\"`), or `\"\"` when anything goes. */\n hint: (accept: string) => string;\n /** What a `busy` dropzone says in place of its body (\"Uploading…\"). */\n busy: string;\n}\n\nexport const DEFAULT_FILE_PICKER_LABELS: FilePickerLabels = {\n rejectedType: (name) => `“${name}” is not a supported file type`,\n rejectedTypeOnly: (accept) => `Only ${accept} files`,\n rejectedSize: (name, maxSize) => `“${name}” is larger than ${maxSize}`,\n rejectedCount: (name, maxFiles) =>\n `“${name}” was not added: at most ${maxFiles} ${maxFiles === 1 ? \"file\" : \"files\"}`,\n rejectedInvalid: (name) => `“${name}” cannot be used here`,\n rejectedMany: (count) => `${count} files were not added`,\n rejectedPick: (count) =>\n count === 1 ? \"The file was not added\" : `None of the ${count} files were added`,\n selected: (count, firstName) => (count === 1 ? `“${firstName}” selected` : `${count} files selected`),\n remove: (name) => `Remove “${name}”`,\n clearAll: \"Remove all files\",\n removed: (name) => `“${name}” removed`,\n cleared: \"All files removed\",\n dropzone: \"File upload\",\n browse: \"Browse\",\n empty: \"Drop a file here\",\n emptyMultiple: \"Drop files here\",\n hint: (accept) => (accept ? `Accepted: ${accept}` : \"Any file type\"),\n busy: \"Uploading…\",\n};\n\n/* ── Screening ───────────────────────────────────────────────────────────── */\n\nexport type FileRejectionReason = \"type\" | \"size\" | \"count\" | \"invalid\";\n\n/** One file the picker refused, and why. `message` is already translated (see\n * {@link FilePickerLabels}, or the caller's `invalidMessage`), so a host that just\n * wants to show it can render `rejections[0].message` as is. */\nexport interface FileRejection {\n file: File;\n reason: FileRejectionReason;\n message: string;\n}\n\n/**\n * Does `file` satisfy an `accept` string, the way the browser's dialog reads it?\n * Comma-separated tokens: `.ext` (case-insensitive suffix of the name), `type/*`\n * (a MIME family) or an exact MIME type. An empty or absent `accept` takes anything.\n *\n * A file with no `type` — common for `.step`, `.dat`, anything the OS has no MIME\n * mapping for — can only match by extension, which is why lenkbank lists `.stp` AND\n * `model/step`: that is how `accept` has to be written for the dialog anyway.\n */\nexport function matchesAccept(file: File, accept: string | undefined): boolean {\n const tokens = (accept ?? \"\")\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n // An EMPTY type is the browser saying \"I don't know\", not \"it's something else\": HEIC\n // photos on Windows without the codec arrive with `type === \"\"`. Refusing them\n // (0.6.0) refused iPhone photos the picker itself had just offered (keksdose). So a\n // missing type is inferred from the extension where that is unambiguous, and a file\n // whose type cannot be known at all is given the benefit of the doubt — nothing here\n // proves it does not match, and the server validates what it receives anyway.\n const type = (file.type || typeFromExtension(name) || \"\").toLowerCase();\n if (!type && !tokens.every((t) => t.startsWith(\".\"))) return true;\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (!type) return false;\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\n/** MIME types for the extensions a browser most often leaves untyped. */\nconst EXTENSION_TYPES: Record<string, string> = {\n heic: \"image/heic\",\n heif: \"image/heif\",\n avif: \"image/avif\",\n webp: \"image/webp\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n png: \"image/png\",\n gif: \"image/gif\",\n pdf: \"application/pdf\",\n csv: \"text/csv\",\n txt: \"text/plain\",\n};\n\nfunction typeFromExtension(name: string): string | undefined {\n const dot = name.lastIndexOf(\".\");\n return dot === -1 ? undefined : EXTENSION_TYPES[name.slice(dot + 1)];\n}\n\n/** @internal `\" .PDF, image/png ,\"` => `\".pdf, image/png\"` — `accept` as a person reads\n * it. Also the dropzone's default hint. */\nexport function formatAccept(accept: string): string {\n return accept\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean)\n .join(\", \");\n}\n\n/** What the pickers screen a pick with. All optional; nothing set accepts everything. */\nexport interface FileScreenOptions {\n accept?: string;\n /** Bytes. Larger files are refused with reason `\"size\"`. */\n maxSize?: number;\n /** How many files one pick may deliver. The rest are refused with reason `\"count\"`\n * — first come, first kept. For a running cap (\"at most 5 attachments\") pass what\n * is LEFT: `maxFiles={5 - attachments.length}`. */\n maxFiles?: number;\n /** The caller's own check, after `accept` and `maxSize`. */\n isValid?: (file: File) => boolean;\n /** The message for an `isValid` refusal; `labels.rejectedInvalid` otherwise. */\n invalidMessage?: string;\n}\n\n/** @internal Split a pick into the files that pass and the ones that do not. */\nexport function screenFiles(\n files: readonly File[],\n opts: FileScreenOptions,\n labels: FilePickerLabels,\n formatSize: (bytes: number) => string,\n): { accepted: File[]; rejected: FileRejection[] } {\n const accepted: File[] = [];\n const rejected: FileRejection[] = [];\n // Name what `accept` takes (\"Only .csv files\") — unless the host translated\n // `rejectedType` but not yet `rejectedTypeOnly`: its own sentence beats an English one.\n const acceptText = opts.accept ? formatAccept(opts.accept) : \"\";\n const useOnly =\n acceptText !== \"\" &&\n (labels.rejectedTypeOnly !== DEFAULT_FILE_PICKER_LABELS.rejectedTypeOnly ||\n labels.rejectedType === DEFAULT_FILE_PICKER_LABELS.rejectedType);\n const typeMessage = (name: string) =>\n useOnly ? labels.rejectedTypeOnly(acceptText, name) : labels.rejectedType(name);\n for (const file of files) {\n let reason: FileRejectionReason | null = null;\n if (!matchesAccept(file, opts.accept)) reason = \"type\";\n else if (opts.maxSize !== undefined && file.size > opts.maxSize) reason = \"size\";\n else if (opts.isValid && !opts.isValid(file)) reason = \"invalid\";\n // Count last, and only against files that passed everything else: a refused\n // file should not use up one of the slots a good one could have had.\n else if (opts.maxFiles !== undefined && accepted.length >= opts.maxFiles) reason = \"count\";\n if (reason === null) {\n accepted.push(file);\n continue;\n }\n const message =\n reason === \"type\"\n ? typeMessage(file.name)\n : reason === \"size\"\n ? labels.rejectedSize(file.name, formatSize(opts.maxSize ?? 0))\n : reason === \"count\"\n ? labels.rejectedCount(file.name, Math.max(0, opts.maxFiles ?? 0))\n : (opts.invalidMessage ?? labels.rejectedInvalid(file.name));\n rejected.push({ file, reason, message });\n }\n return { accepted, rejected };\n}\n\n/**\n * Judges a pick as a whole — keksdose's \"refuse the pick if any file is bad\", which\n * with `onFiles` + `onReject` alone had to be rebuilt from two calls in a microtask.\n *\n * Called ONCE per pick, after screening and before `onFiles` / `onReject`, with both\n * halves (either may be empty). Return `false` to refuse the whole pick: the accepted\n * files are not delivered, `onReject` still receives what screening refused, and one\n * sentence (`labels.rejectedPick`) is spoken for the pick instead of a per-file one.\n * Return nothing to let the pick through as usual.\n *\n * ```tsx\n * onPick={(ok, bad) => bad.length === 0 || false} // all or nothing\n * ```\n */\nexport type FilePickHandler = (accepted: File[], rejected: FileRejection[]) => boolean | void;\n\n/** @internal The shared tail of both pickers: run `onPick`, and say whether the pick\n * stands. A pick with nothing accepted has nothing to refuse, so `false` there is\n * treated as no verdict and the usual per-file messages are kept. */\nexport function judgePick(\n onPick: FilePickHandler | undefined,\n accepted: File[],\n rejected: FileRejection[],\n): boolean {\n if (!onPick) return true;\n return onPick(accepted, rejected) !== false || accepted.length === 0;\n}\n\n/** One sentence for a whole batch of refusals: the file's own message for one, a\n * count for several — reading out five sentences in a row helps nobody. */\nexport function summariseRejections(rejected: readonly FileRejection[], labels: FilePickerLabels): string {\n if (rejected.length === 0) return \"\";\n if (rejected.length === 1) return rejected[0].message;\n return labels.rejectedMany(rejected.length);\n}\n\n/* ── useFilePicker ───────────────────────────────────────────────────────── */\n\nexport interface UseFilePickerOptions extends FileScreenOptions {\n /** Let one pick deliver several files. Without it a drop of several keeps the first. */\n multiple?: boolean;\n /**\n * Ask a phone for its camera instead of the file chooser: `\"environment\"` is the\n * back camera, `\"user\"` the front. A HINT — desktop browsers ignore it, and Chrome\n * drops it when `multiple` is also set (a camera cannot deliver a list), which is why\n * keksdose's camera input has no `multiple`. Pass one or the other.\n */\n capture?: boolean | \"user\" | \"environment\";\n /** The files that passed, in pick order. Never called with an empty array.\n * Optional since 0.7 for a caller that takes the pick through `onPick` alone. */\n onFiles?: (files: File[]) => void;\n /** See {@link FilePickHandler}: the whole pick at once, with the power to refuse it. */\n onPick?: FilePickHandler;\n /** The files that did not, with a translated message each. The refusals are also\n * spoken through a live region, so this is for SHOWING them, not for a11y. */\n onReject?: (rejections: FileRejection[]) => void;\n /** `open()` and `take()` do nothing while set. */\n disabled?: boolean;\n /** Per-instance overrides of the `filePicker` label namespace. */\n labels?: Partial<FilePickerLabels>;\n}\n\nexport interface UseFilePickerReturn {\n /** Open the system picker. Call it from a click handler — browsers only open a file\n * dialog in response to a user gesture. */\n open: () => void;\n /** Screen and deliver files that arrived some other way — a drop, a paste. Honours\n * `multiple` (only the first file without it) and every check. */\n take: (files: ArrayLike<File> | null | undefined) => void;\n /** The hidden input and the live region. Render it once, anywhere — it takes no\n * space and needs no positioned ancestor. */\n element: ReactElement;\n}\n\n/**\n * The headless half of {@link FileButton}: a hidden file input you can open from any\n * control, with the reset, the screening and the announcement built in.\n *\n * ```tsx\n * const picker = useFilePicker({ accept: \".pdf\", onFiles: ([f]) => upload(f) });\n * return <>{picker.element}<DetailTableCard onAdd={picker.open} … /></>;\n * ```\n */\nexport function useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n disabled,\n labels: labelsProp,\n}: UseFilePickerOptions): UseFilePickerReturn {\n const inputRef = useRef<HTMLInputElement>(null);\n const labels = useKitLabels(\"filePicker\", DEFAULT_FILE_PICKER_LABELS, labelsProp);\n const fileText = useKitFileLabels();\n // Assertive: a refusal is a failure the user has to hear before they move on, and\n // it is the only thing this region ever says.\n const { announce, regionProps } = useAnnounce({ politeness: \"assertive\" });\n\n const take = (list: ArrayLike<File> | null | undefined) => {\n if (disabled || !list || list.length === 0) return;\n const all = Array.from(list);\n const files = multiple ? all : all.slice(0, 1);\n const { accepted, rejected } = screenFiles(\n files,\n // A single-file picker holds one file by definition; `maxFiles` is a multi-mode\n // cap and would only ever say \"0\" there if a caller passed it by mistake.\n { accept, maxSize, maxFiles: multiple ? maxFiles : undefined, isValid, invalidMessage },\n labels,\n fileText.size,\n );\n if (!judgePick(onPick, accepted, rejected)) {\n if (rejected.length > 0) onReject?.(rejected);\n announce(labels.rejectedPick(files.length));\n return;\n }\n if (accepted.length > 0) onFiles?.(accepted);\n if (rejected.length > 0) {\n onReject?.(rejected);\n announce(summariseRejections(rejected, labels));\n }\n };\n\n const element = (\n <>\n <input\n ref={inputRef}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n capture={capture}\n disabled={disabled}\n // `hidden` (display: none), not `sr-only`: the control a user reaches is the\n // button, and a second, nameless tab stop for the same action is noise. A\n // display:none file input still opens on `.click()` in every current browser —\n // and, unlike `sr-only`, it cannot escape to the initial containing block and\n // stretch the page (see the note in `file-dropzone.tsx`).\n className=\"hidden\"\n tabIndex={-1}\n aria-hidden\n onChange={(e) => {\n // Copy BEFORE the reset: `files` is a live view of the input's value, and\n // clearing the value empties it.\n const picked = Array.from(e.currentTarget.files ?? []);\n e.currentTarget.value = \"\";\n take(picked);\n }}\n />\n <span {...regionProps} />\n </>\n );\n\n return {\n open: () => {\n if (!disabled) inputRef.current?.click();\n },\n take,\n element,\n };\n}\n\n/* ── FileButton ──────────────────────────────────────────────────────────── */\n\ntype ButtonOwnProps = ComponentPropsWithoutRef<typeof Button>;\n\nexport interface FileButtonProps\n extends Omit<UseFilePickerOptions, \"disabled\">,\n // `onDrop` & co. stay the caller's own when `droppable` is off; `type` is fixed to\n // \"button\" (see 2. above) — a file trigger never submits a form.\n Omit<ButtonOwnProps, \"type\" | \"children\" | \"accept\" | \"capture\" | \"multiple\"> {\n /** The button's content — usually an icon and a word. It is the accessible name. */\n children: ReactNode;\n /** Busy: disabled, `aria-busy`, and a spinner before the content — for \"uploading\". */\n pending?: boolean;\n /** Also accept files dropped ON the button (lenkbank's \"drop onto the button\").\n * Off by default: a button that silently takes drops is a surprise on a page that\n * has a real drop target elsewhere. */\n droppable?: boolean;\n /**\n * Show what was picked beside the button: the file's name, or \"3 files selected\"\n * (`filePicker.selected`) for several — a native `<input type=\"file\">` says this,\n * and a bare button that takes a file and says nothing leaves the user to trust it.\n * The read-out is a polite live region and describes the button, so it is heard\n * when it changes and again on focus. It holds the last ACCEPTED pick: a refused\n * file leaves it as it was. Off by default, so the button's layout is unchanged.\n */\n showFileName?: boolean;\n}\n\n/**\n * {@link useFilePicker} behind a {@link Button}: `variant` and every other button prop\n * pass through, and the ref is the `<button>` (so `ref.current.click()` opens the\n * picker from elsewhere too).\n *\n * ```tsx\n * <FileButton accept=\"image/*,application/pdf\" capture=\"environment\" variant=\"secondary\"\n * maxSize={10_000_000} onFiles={([f]) => upload(f)} onReject={([r]) => setError(r.message)}>\n * <Camera aria-hidden /> Photograph receipt\n * </FileButton>\n * ```\n */\nexport const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(function FileButton(\n {\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n labels,\n pending,\n droppable,\n showFileName = false,\n disabled,\n children,\n className,\n onClick,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n ...rest\n },\n ref,\n) {\n const inert = Boolean(disabled || pending);\n const [picked, setPicked] = useState<readonly File[]>([]);\n const pickedId = useId();\n const pickerLabels = useKitLabels(\"filePicker\", DEFAULT_FILE_PICKER_LABELS, labels);\n const picker = useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles: showFileName\n ? (files) => {\n setPicked(files);\n onFiles?.(files);\n }\n : onFiles,\n onPick,\n onReject,\n labels,\n disabled: inert,\n });\n const pickedText =\n picked.length === 0 ? \"\" : picked.length === 1 ? picked[0].name : pickerLabels.selected(picked.length, picked[0].name);\n const [dragOver, setDragOver] = useState(false);\n\n const hasFiles = (e: DragEvent) => Array.from(e.dataTransfer?.types ?? []).includes(\"Files\");\n // Only when `droppable`: otherwise the caller's own handlers are passed untouched.\n const dropHandlers = droppable\n ? {\n onDragEnter: (e: DragEvent<HTMLButtonElement>) => {\n onDragEnter?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n if (!inert) setDragOver(true);\n },\n onDragOver: (e: DragEvent<HTMLButtonElement>) => {\n onDragOver?.(e);\n if (!hasFiles(e)) return;\n // Always cancel for a file drag, busy or not: an uncancelled drop makes the\n // browser NAVIGATE to the file, which loses the page.\n e.preventDefault();\n e.dataTransfer.dropEffect = inert ? \"none\" : \"copy\";\n },\n onDragLeave: (e: DragEvent<HTMLButtonElement>) => {\n onDragLeave?.(e);\n if (e.currentTarget.contains(e.relatedTarget as Node | null)) return;\n setDragOver(false);\n },\n onDrop: (e: DragEvent<HTMLButtonElement>) => {\n onDrop?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n setDragOver(false);\n picker.take(e.dataTransfer.files);\n },\n }\n : { onDragEnter, onDragOver, onDragLeave, onDrop };\n\n // `Button` is a plain function component; under React 19 `ref` is an ordinary prop\n // and reaches the `<button>` through its `...rest`. Its props type just does not\n // declare it, hence the widening here rather than a second button implementation.\n const refProp = { ref } as { ref?: Ref<HTMLButtonElement> };\n\n const button = (\n <Button\n {...rest}\n {...refProp}\n {...dropHandlers}\n type=\"button\"\n disabled={inert}\n aria-busy={pending || undefined}\n aria-describedby={\n showFileName && pickedText\n ? [rest[\"aria-describedby\"], pickedId].filter(Boolean).join(\" \")\n : rest[\"aria-describedby\"]\n }\n data-drag-over={dragOver || undefined}\n className={cn(\n // A live drag gets the focus ring's colour as a ring: \"let go here\", in the\n // same vocabulary the button already uses for \"you are here\".\n dragOver && \"ring-2 ring-[var(--brand)]\",\n // Beside a long file name it is the NAME that gives way, never the button.\n showFileName && \"shrink-0\",\n className,\n )}\n onClick={(e) => {\n onClick?.(e);\n if (!e.defaultPrevented) picker.open();\n }}\n >\n {/* `label={null}`: the spinner is decoration here — `aria-busy` says the same\n thing on the button, and a spoken \"Loading\" would run into its name. */}\n {pending && <Spinner label={null} className=\"size-4\" />}\n {children}\n </Button>\n );\n\n if (!showFileName) {\n return (\n <>\n {button}\n {picker.element}\n </>\n );\n }\n return (\n // One inline row, so the name sits beside the button wherever the button sits; the\n // name truncates rather than pushing the row wider, and the full list is in the\n // kit's own Tooltip — not a native `title` (0.16.0 shipped one: the one-tooltip rule\n // since keksdose dev#523, and a title never opens on touch). Lazy, so the closed\n // bubble adds nothing to the read-out's text.\n <span className=\"inline-flex max-w-full min-w-0 items-center gap-2\">\n {button}\n {/* The live region is the OUTER span and never remounts: a Tooltip with an empty\n label renders no wrapper, so wrapping the region itself would swap its element\n the moment the first file arrives — and a fresh live region may not announce. */}\n <span\n id={pickedId}\n aria-live=\"polite\"\n data-slot=\"file-button-name\"\n className=\"flex min-w-0 text-sm text-[var(--text-secondary)]\"\n >\n <Tooltip label={picked.map((f) => f.name).join(\", \")} lazy className=\"min-w-0\">\n <span className=\"block truncate\">{pickedText}</span>\n </Tooltip>\n </span>\n {picker.element}\n </span>\n );\n});\nFileButton.displayName = \"FileButton\";\n"],"mappings":";AA+WI,mBACE,KADF;AA/WJ,SAAS,YAAY,OAAO,QAAQ,gBAAgB;AAEpD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,oBAAoB;AAC/C,SAAS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E,KAAK,IAAI,GAAG,MAAI,MAAC,WAAU,WACnE,8BAAC,UAAK,WAAU,kBAAkB,sBAAW,GAC/C;AAAA;AAAA,MACF;AAAA,MACC,OAAO;AAAA,OACV;AAAA;AAEJ,CAAC;AACD,WAAW,cAAc;","names":["FileButton"]}
1
+ {"version":3,"sources":["../../src/components/file-button.tsx"],"sourcesContent":["import { forwardRef, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, DragEvent, ReactElement, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitFileLabels, useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, Spinner } from \"./ui\";\nimport { Tooltip } from \"./tooltip\";\nimport { useCommitReason } from \"./write-lock\";\n\n/**\n * A button that opens the file picker — the shape all three apps kept writing by hand\n * as a `<Button>` plus a hidden `<input type=\"file\">` plus a ref between them (seven\n * copies in keksdose, two each in kastlan and lenkbank).\n *\n * Every copy had to remember the same four things, and each one forgot at least one:\n *\n * 1. **Reset the input after every pick.** A file input fires `change` only when its\n * value CHANGES, so picking the same file twice in a row — the retry after a failed\n * upload, the second photo of the same receipt — did nothing at all, which reads as\n * a broken button. `value = \"\"` after each pick; always, not per call site.\n * 2. **`type=\"button\"`.** `<Button>` does not set it, and inside a form a bare button\n * submits the form before the picker opens.\n * 3. **Check the file.** `accept` filters the DIALOG, not the result: the dialog's\n * \"All files\" switch, a drop, and a mobile share sheet all hand over whatever the\n * user chose. So `accept` is re-checked here, along with `maxSize`, `maxFiles` and\n * an optional `isValid`.\n * 4. **Say no without a toast.** A rejection is reported through `onReject`, with a\n * translated message per file, and spoken through a live region — the kit does not\n * decide how an app surfaces errors (keksdose's proposal §1 asked for exactly that).\n *\n * The part that is not a button — the hidden input, the check, the announcement — is\n * {@link useFilePicker}, for the case where the thing that opens the picker is someone\n * else's control (a card's \"Add\" action, a menu item, a second button for the camera).\n */\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the file pickers ({@link FileButton}, `FileDropzone`) render or speak.\n * Messages are functions of the file name so a translation can put it anywhere. */\nexport interface FilePickerLabels {\n /** The file's type is not in `accept`, when no `accept` is known to name (see\n * `rejectedTypeOnly`). */\n rejectedType: (name: string) => string;\n /** The file's type is not in `accept`, naming what IS accepted: `accept`'s tokens,\n * lower-cased and joined with \", \" (`\".csv\"` => \"Only .csv files\"). Used whenever\n * `accept` is set — kastlan kept a custom `isValid` + `invalidMessage` per form only\n * to say this, and `accept` already knows it. */\n rejectedTypeOnly: (accept: string, name: string) => string;\n /** The file is larger than `maxSize`; `maxSize` arrives formatted (\"5 MB\"). */\n rejectedSize: (name: string, maxSize: string) => string;\n /** The file was one too many for `maxFiles`. */\n rejectedCount: (name: string, maxFiles: number) => string;\n /** `isValid` said no and the caller gave no `invalidMessage`. */\n rejectedInvalid: (name: string) => string;\n /** Spoken instead of the per-file message when more than one file was refused. */\n rejectedMany: (count: number) => string;\n /** Spoken (and shown, on a dropzone) when `onPick` refused the WHOLE pick.\n * Receives the number of files in it. */\n rejectedPick: (count: number) => string;\n /** Spoken after a pick the component itself echoes (the dropzone). */\n selected: (count: number, firstName: string) => string;\n /** The dropzone's remove button for one file. */\n remove: (name: string) => string;\n /** The dropzone's remove-everything button in `multiple` mode. */\n clearAll: string;\n /** Spoken after a remove / clear, since the button that was pressed is gone. */\n removed: (name: string) => string;\n cleared: string;\n /** The dropzone's accessible name, when the host passes no `dropLabel`. */\n dropzone: string;\n /** The dropzone's Browse button, when the host passes no `browseLabel`. */\n browse: string;\n /** What an empty single-file dropzone says (no `emptyLabel` given). */\n empty: string;\n /** …and an empty `multiple` one. */\n emptyMultiple: string;\n /** The dropzone's second line (no `hint` given). Receives `accept` as a person\n * reads it (`\".pdf, image/png\"`), or `\"\"` when anything goes. */\n hint: (accept: string) => string;\n /** What a `busy` dropzone says in place of its body (\"Uploading…\"). */\n busy: string;\n}\n\nexport const DEFAULT_FILE_PICKER_LABELS: FilePickerLabels = {\n rejectedType: (name) => `“${name}” is not a supported file type`,\n rejectedTypeOnly: (accept) => `Only ${accept} files`,\n rejectedSize: (name, maxSize) => `“${name}” is larger than ${maxSize}`,\n rejectedCount: (name, maxFiles) =>\n `“${name}” was not added: at most ${maxFiles} ${maxFiles === 1 ? \"file\" : \"files\"}`,\n rejectedInvalid: (name) => `“${name}” cannot be used here`,\n rejectedMany: (count) => `${count} files were not added`,\n rejectedPick: (count) =>\n count === 1 ? \"The file was not added\" : `None of the ${count} files were added`,\n selected: (count, firstName) => (count === 1 ? `“${firstName}” selected` : `${count} files selected`),\n remove: (name) => `Remove “${name}”`,\n clearAll: \"Remove all files\",\n removed: (name) => `“${name}” removed`,\n cleared: \"All files removed\",\n dropzone: \"File upload\",\n browse: \"Browse\",\n empty: \"Drop a file here\",\n emptyMultiple: \"Drop files here\",\n hint: (accept) => (accept ? `Accepted: ${accept}` : \"Any file type\"),\n busy: \"Uploading…\",\n};\n\n/* ── Screening ───────────────────────────────────────────────────────────── */\n\nexport type FileRejectionReason = \"type\" | \"size\" | \"count\" | \"invalid\";\n\n/** One file the picker refused, and why. `message` is already translated (see\n * {@link FilePickerLabels}, or the caller's `invalidMessage`), so a host that just\n * wants to show it can render `rejections[0].message` as is. */\nexport interface FileRejection {\n file: File;\n reason: FileRejectionReason;\n message: string;\n}\n\n/**\n * Does `file` satisfy an `accept` string, the way the browser's dialog reads it?\n * Comma-separated tokens: `.ext` (case-insensitive suffix of the name), `type/*`\n * (a MIME family) or an exact MIME type. An empty or absent `accept` takes anything.\n *\n * A file with no `type` — common for `.step`, `.dat`, anything the OS has no MIME\n * mapping for — can only match by extension, which is why lenkbank lists `.stp` AND\n * `model/step`: that is how `accept` has to be written for the dialog anyway.\n */\nexport function matchesAccept(file: File, accept: string | undefined): boolean {\n const tokens = (accept ?? \"\")\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n // An EMPTY type is the browser saying \"I don't know\", not \"it's something else\": HEIC\n // photos on Windows without the codec arrive with `type === \"\"`. Refusing them\n // (0.6.0) refused iPhone photos the picker itself had just offered (keksdose). So a\n // missing type is inferred from the extension where that is unambiguous, and a file\n // whose type cannot be known at all is given the benefit of the doubt — nothing here\n // proves it does not match, and the server validates what it receives anyway.\n const type = (file.type || typeFromExtension(name) || \"\").toLowerCase();\n if (!type && !tokens.every((t) => t.startsWith(\".\"))) return true;\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (!type) return false;\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\n/** MIME types for the extensions a browser most often leaves untyped. */\nconst EXTENSION_TYPES: Record<string, string> = {\n heic: \"image/heic\",\n heif: \"image/heif\",\n avif: \"image/avif\",\n webp: \"image/webp\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n png: \"image/png\",\n gif: \"image/gif\",\n pdf: \"application/pdf\",\n csv: \"text/csv\",\n txt: \"text/plain\",\n};\n\nfunction typeFromExtension(name: string): string | undefined {\n const dot = name.lastIndexOf(\".\");\n return dot === -1 ? undefined : EXTENSION_TYPES[name.slice(dot + 1)];\n}\n\n/** @internal `\" .PDF, image/png ,\"` => `\".pdf, image/png\"` — `accept` as a person reads\n * it. Also the dropzone's default hint. */\nexport function formatAccept(accept: string): string {\n return accept\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean)\n .join(\", \");\n}\n\n/** What the pickers screen a pick with. All optional; nothing set accepts everything. */\nexport interface FileScreenOptions {\n accept?: string;\n /** Bytes. Larger files are refused with reason `\"size\"`. */\n maxSize?: number;\n /** How many files one pick may deliver. The rest are refused with reason `\"count\"`\n * — first come, first kept. For a running cap (\"at most 5 attachments\") pass what\n * is LEFT: `maxFiles={5 - attachments.length}`. */\n maxFiles?: number;\n /** The caller's own check, after `accept` and `maxSize`. */\n isValid?: (file: File) => boolean;\n /** The message for an `isValid` refusal; `labels.rejectedInvalid` otherwise. */\n invalidMessage?: string;\n}\n\n/** @internal Split a pick into the files that pass and the ones that do not. */\nexport function screenFiles(\n files: readonly File[],\n opts: FileScreenOptions,\n labels: FilePickerLabels,\n formatSize: (bytes: number) => string,\n): { accepted: File[]; rejected: FileRejection[] } {\n const accepted: File[] = [];\n const rejected: FileRejection[] = [];\n // Name what `accept` takes (\"Only .csv files\") — unless the host translated\n // `rejectedType` but not yet `rejectedTypeOnly`: its own sentence beats an English one.\n const acceptText = opts.accept ? formatAccept(opts.accept) : \"\";\n const useOnly =\n acceptText !== \"\" &&\n (labels.rejectedTypeOnly !== DEFAULT_FILE_PICKER_LABELS.rejectedTypeOnly ||\n labels.rejectedType === DEFAULT_FILE_PICKER_LABELS.rejectedType);\n const typeMessage = (name: string) =>\n useOnly ? labels.rejectedTypeOnly(acceptText, name) : labels.rejectedType(name);\n for (const file of files) {\n let reason: FileRejectionReason | null = null;\n if (!matchesAccept(file, opts.accept)) reason = \"type\";\n else if (opts.maxSize !== undefined && file.size > opts.maxSize) reason = \"size\";\n else if (opts.isValid && !opts.isValid(file)) reason = \"invalid\";\n // Count last, and only against files that passed everything else: a refused\n // file should not use up one of the slots a good one could have had.\n else if (opts.maxFiles !== undefined && accepted.length >= opts.maxFiles) reason = \"count\";\n if (reason === null) {\n accepted.push(file);\n continue;\n }\n const message =\n reason === \"type\"\n ? typeMessage(file.name)\n : reason === \"size\"\n ? labels.rejectedSize(file.name, formatSize(opts.maxSize ?? 0))\n : reason === \"count\"\n ? labels.rejectedCount(file.name, Math.max(0, opts.maxFiles ?? 0))\n : (opts.invalidMessage ?? labels.rejectedInvalid(file.name));\n rejected.push({ file, reason, message });\n }\n return { accepted, rejected };\n}\n\n/**\n * Judges a pick as a whole — keksdose's \"refuse the pick if any file is bad\", which\n * with `onFiles` + `onReject` alone had to be rebuilt from two calls in a microtask.\n *\n * Called ONCE per pick, after screening and before `onFiles` / `onReject`, with both\n * halves (either may be empty). Return `false` to refuse the whole pick: the accepted\n * files are not delivered, `onReject` still receives what screening refused, and one\n * sentence (`labels.rejectedPick`) is spoken for the pick instead of a per-file one.\n * Return nothing to let the pick through as usual.\n *\n * ```tsx\n * onPick={(ok, bad) => bad.length === 0 || false} // all or nothing\n * ```\n */\nexport type FilePickHandler = (accepted: File[], rejected: FileRejection[]) => boolean | void;\n\n/** @internal The shared tail of both pickers: run `onPick`, and say whether the pick\n * stands. A pick with nothing accepted has nothing to refuse, so `false` there is\n * treated as no verdict and the usual per-file messages are kept. */\nexport function judgePick(\n onPick: FilePickHandler | undefined,\n accepted: File[],\n rejected: FileRejection[],\n): boolean {\n if (!onPick) return true;\n return onPick(accepted, rejected) !== false || accepted.length === 0;\n}\n\n/** One sentence for a whole batch of refusals: the file's own message for one, a\n * count for several — reading out five sentences in a row helps nobody. */\nexport function summariseRejections(rejected: readonly FileRejection[], labels: FilePickerLabels): string {\n if (rejected.length === 0) return \"\";\n if (rejected.length === 1) return rejected[0].message;\n return labels.rejectedMany(rejected.length);\n}\n\n/* ── useFilePicker ───────────────────────────────────────────────────────── */\n\nexport interface UseFilePickerOptions extends FileScreenOptions {\n /** Let one pick deliver several files. Without it a drop of several keeps the first. */\n multiple?: boolean;\n /**\n * Ask a phone for its camera instead of the file chooser: `\"environment\"` is the\n * back camera, `\"user\"` the front. A HINT — desktop browsers ignore it, and Chrome\n * drops it when `multiple` is also set (a camera cannot deliver a list), which is why\n * keksdose's camera input has no `multiple`. Pass one or the other.\n */\n capture?: boolean | \"user\" | \"environment\";\n /** The files that passed, in pick order. Never called with an empty array.\n * Optional since 0.7 for a caller that takes the pick through `onPick` alone. */\n onFiles?: (files: File[]) => void;\n /** See {@link FilePickHandler}: the whole pick at once, with the power to refuse it. */\n onPick?: FilePickHandler;\n /** The files that did not, with a translated message each. The refusals are also\n * spoken through a live region, so this is for SHOWING them, not for a11y. */\n onReject?: (rejections: FileRejection[]) => void;\n /** `open()` and `take()` do nothing while set. */\n disabled?: boolean;\n /** Per-instance overrides of the `filePicker` label namespace. */\n labels?: Partial<FilePickerLabels>;\n}\n\nexport interface UseFilePickerReturn {\n /** Open the system picker. Call it from a click handler — browsers only open a file\n * dialog in response to a user gesture. */\n open: () => void;\n /** Screen and deliver files that arrived some other way — a drop, a paste. Honours\n * `multiple` (only the first file without it) and every check. */\n take: (files: ArrayLike<File> | null | undefined) => void;\n /** The hidden input and the live region. Render it once, anywhere — it takes no\n * space and needs no positioned ancestor. */\n element: ReactElement;\n}\n\n/**\n * The headless half of {@link FileButton}: a hidden file input you can open from any\n * control, with the reset, the screening and the announcement built in.\n *\n * ```tsx\n * const picker = useFilePicker({ accept: \".pdf\", onFiles: ([f]) => upload(f) });\n * return <>{picker.element}<DetailTableCard onAdd={picker.open} … /></>;\n * ```\n */\nexport function useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n disabled,\n labels: labelsProp,\n}: UseFilePickerOptions): UseFilePickerReturn {\n const inputRef = useRef<HTMLInputElement>(null);\n const labels = useKitLabels(\"filePicker\", DEFAULT_FILE_PICKER_LABELS, labelsProp);\n const fileText = useKitFileLabels();\n // Assertive: a refusal is a failure the user has to hear before they move on, and\n // it is the only thing this region ever says.\n const { announce, regionProps } = useAnnounce({ politeness: \"assertive\" });\n\n const take = (list: ArrayLike<File> | null | undefined) => {\n if (disabled || !list || list.length === 0) return;\n const all = Array.from(list);\n const files = multiple ? all : all.slice(0, 1);\n const { accepted, rejected } = screenFiles(\n files,\n // A single-file picker holds one file by definition; `maxFiles` is a multi-mode\n // cap and would only ever say \"0\" there if a caller passed it by mistake.\n { accept, maxSize, maxFiles: multiple ? maxFiles : undefined, isValid, invalidMessage },\n labels,\n fileText.size,\n );\n if (!judgePick(onPick, accepted, rejected)) {\n if (rejected.length > 0) onReject?.(rejected);\n announce(labels.rejectedPick(files.length));\n return;\n }\n if (accepted.length > 0) onFiles?.(accepted);\n if (rejected.length > 0) {\n onReject?.(rejected);\n announce(summariseRejections(rejected, labels));\n }\n };\n\n const element = (\n <>\n <input\n ref={inputRef}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n capture={capture}\n disabled={disabled}\n // `hidden` (display: none), not `sr-only`: the control a user reaches is the\n // button, and a second, nameless tab stop for the same action is noise. A\n // display:none file input still opens on `.click()` in every current browser —\n // and, unlike `sr-only`, it cannot escape to the initial containing block and\n // stretch the page (see the note in `file-dropzone.tsx`).\n className=\"hidden\"\n tabIndex={-1}\n aria-hidden\n onChange={(e) => {\n // Copy BEFORE the reset: `files` is a live view of the input's value, and\n // clearing the value empties it.\n const picked = Array.from(e.currentTarget.files ?? []);\n e.currentTarget.value = \"\";\n take(picked);\n }}\n />\n <span {...regionProps} />\n </>\n );\n\n return {\n open: () => {\n if (!disabled) inputRef.current?.click();\n },\n take,\n element,\n };\n}\n\n/* ── FileButton ──────────────────────────────────────────────────────────── */\n\ntype ButtonOwnProps = ComponentPropsWithoutRef<typeof Button>;\n\nexport interface FileButtonProps\n extends Omit<UseFilePickerOptions, \"disabled\">,\n // `onDrop` & co. stay the caller's own when `droppable` is off; `type` is fixed to\n // \"button\" (see 2. above) — a file trigger never submits a form.\n Omit<ButtonOwnProps, \"type\" | \"children\" | \"accept\" | \"capture\" | \"multiple\"> {\n /** The button's content — usually an icon and a word. It is the accessible name. */\n children: ReactNode;\n /** Busy: disabled, `aria-busy`, and a spinner before the content — for \"uploading\". */\n pending?: boolean;\n /** Also accept files dropped ON the button (lenkbank's \"drop onto the button\").\n * Off by default: a button that silently takes drops is a surprise on a page that\n * has a real drop target elsewhere. */\n droppable?: boolean;\n /**\n * Show what was picked beside the button: the file's name, or \"3 files selected\"\n * (`filePicker.selected`) for several — a native `<input type=\"file\">` says this,\n * and a bare button that takes a file and says nothing leaves the user to trust it.\n * The read-out is a polite live region and describes the button, so it is heard\n * when it changes and again on focus. It holds the last ACCEPTED pick: a refused\n * file leaves it as it was. Off by default, so the button's layout is unchanged.\n */\n showFileName?: boolean;\n /**\n * Why picking is not available — {@link Button}'s `disabledReason`, with the picker's\n * half added (keksdose K3): the button is `aria-disabled` but stays focusable, the\n * reason is in the kit Tooltip and its description, a click opens no picker, and a\n * `droppable` button takes no drop (the drag is still cancelled, so the browser does\n * not navigate to the file). Wins over `disabled`, as on Button.\n */\n disabledReason?: ReactNode;\n /**\n * This pick COMMITS — an upload that starts on pick, an attachment saved at once.\n * Under a locked {@link WriteLockProvider} it takes the `disabledReason` path with\n * the lock's reason (which wins over one of its own). No provider, or an unlocked\n * one: no effect. A picker that only fills a form the user saves later is not a\n * commit, and is left live — the form's Save carries the lock.\n */\n commit?: boolean;\n}\n\n/** A reason that is really there — `null`, `false` and `\"\"` are no reason. */\nfunction hasReason(reason: ReactNode): boolean {\n return reason !== undefined && reason !== null && reason !== false && reason !== \"\";\n}\n\n/**\n * {@link useFilePicker} behind a {@link Button}: `variant` and every other button prop\n * pass through, and the ref is the `<button>` (so `ref.current.click()` opens the\n * picker from elsewhere too).\n *\n * ```tsx\n * <FileButton accept=\"image/*,application/pdf\" capture=\"environment\" variant=\"secondary\"\n * maxSize={10_000_000} onFiles={([f]) => upload(f)} onReject={([r]) => setError(r.message)}>\n * <Camera aria-hidden /> Photograph receipt\n * </FileButton>\n * ```\n */\nexport const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(function FileButton(\n {\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n labels,\n pending,\n droppable,\n showFileName = false,\n disabled,\n disabledReason: ownDisabledReason,\n commit,\n children,\n className,\n onClick,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n ...rest\n },\n ref,\n) {\n const disabledReason = useCommitReason(commit, ownDisabledReason);\n const locked = hasReason(disabledReason);\n const inert = Boolean(disabled || pending);\n // What takes no files: busy, disabled, or locked with a reason. Kept apart from\n // `inert`, which is what reaches the button's NATIVE `disabled` — a locked button\n // stays focusable (Button's `disabledReason` path), so `locked` must not get there.\n const refusing = inert || locked;\n const [picked, setPicked] = useState<readonly File[]>([]);\n const pickedId = useId();\n const pickerLabels = useKitLabels(\"filePicker\", DEFAULT_FILE_PICKER_LABELS, labels);\n const picker = useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles: showFileName\n ? (files) => {\n setPicked(files);\n onFiles?.(files);\n }\n : onFiles,\n onPick,\n onReject,\n labels,\n disabled: refusing,\n });\n const pickedText =\n picked.length === 0 ? \"\" : picked.length === 1 ? picked[0].name : pickerLabels.selected(picked.length, picked[0].name);\n const [dragOver, setDragOver] = useState(false);\n\n const hasFiles = (e: DragEvent) => Array.from(e.dataTransfer?.types ?? []).includes(\"Files\");\n // Only when `droppable`: otherwise the caller's own handlers are passed untouched.\n const dropHandlers = droppable\n ? {\n onDragEnter: (e: DragEvent<HTMLButtonElement>) => {\n onDragEnter?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n if (!refusing) setDragOver(true);\n },\n onDragOver: (e: DragEvent<HTMLButtonElement>) => {\n onDragOver?.(e);\n if (!hasFiles(e)) return;\n // Always cancel for a file drag, busy or not: an uncancelled drop makes the\n // browser NAVIGATE to the file, which loses the page.\n e.preventDefault();\n e.dataTransfer.dropEffect = refusing ? \"none\" : \"copy\";\n },\n onDragLeave: (e: DragEvent<HTMLButtonElement>) => {\n onDragLeave?.(e);\n if (e.currentTarget.contains(e.relatedTarget as Node | null)) return;\n setDragOver(false);\n },\n onDrop: (e: DragEvent<HTMLButtonElement>) => {\n onDrop?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n setDragOver(false);\n picker.take(e.dataTransfer.files);\n },\n }\n : { onDragEnter, onDragOver, onDragLeave, onDrop };\n\n // `Button` is a plain function component; under React 19 `ref` is an ordinary prop\n // and reaches the `<button>` through its `...rest`. Its props type just does not\n // declare it, hence the widening here rather than a second button implementation.\n const refProp = { ref } as { ref?: Ref<HTMLButtonElement> };\n\n const button = (\n <Button\n {...rest}\n {...refProp}\n {...dropHandlers}\n type=\"button\"\n disabled={inert}\n // Resolved here rather than passed on as `commit`: the picker above has to know\n // it is locked too, and one resolution keeps the two from disagreeing.\n disabledReason={locked ? disabledReason : undefined}\n aria-busy={pending || undefined}\n aria-describedby={\n showFileName && pickedText\n ? [rest[\"aria-describedby\"], pickedId].filter(Boolean).join(\" \")\n : rest[\"aria-describedby\"]\n }\n data-drag-over={dragOver || undefined}\n className={cn(\n // A live drag gets the focus ring's colour as a ring: \"let go here\", in the\n // same vocabulary the button already uses for \"you are here\".\n dragOver && \"ring-2 ring-[var(--brand)]\",\n // Beside a long file name it is the NAME that gives way, never the button.\n showFileName && \"shrink-0\",\n className,\n )}\n onClick={(e) => {\n onClick?.(e);\n if (!e.defaultPrevented) picker.open();\n }}\n >\n {/* `label={null}`: the spinner is decoration here — `aria-busy` says the same\n thing on the button, and a spoken \"Loading\" would run into its name. */}\n {pending && <Spinner label={null} className=\"size-4\" />}\n {children}\n </Button>\n );\n\n if (!showFileName) {\n return (\n <>\n {button}\n {picker.element}\n </>\n );\n }\n return (\n // One inline row, so the name sits beside the button wherever the button sits; the\n // name truncates rather than pushing the row wider, and the full list is in the\n // kit's own Tooltip — not a native `title` (0.16.0 shipped one: the one-tooltip rule\n // since keksdose dev#523, and a title never opens on touch). Lazy, so the closed\n // bubble adds nothing to the read-out's text.\n <span className=\"inline-flex max-w-full min-w-0 items-center gap-2\">\n {button}\n {/* The live region is the OUTER span and never remounts: a Tooltip with an empty\n label renders no wrapper, so wrapping the region itself would swap its element\n the moment the first file arrives — and a fresh live region may not announce. */}\n <span\n id={pickedId}\n aria-live=\"polite\"\n data-slot=\"file-button-name\"\n className=\"flex min-w-0 text-sm text-[var(--text-secondary)]\"\n >\n <Tooltip label={picked.map((f) => f.name).join(\", \")} lazy className=\"min-w-0\">\n <span className=\"block truncate\">{pickedText}</span>\n </Tooltip>\n </span>\n {picker.element}\n </span>\n );\n});\nFileButton.displayName = \"FileButton\";\n"],"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;AAAA,mBAAW,oBAAC,WAAQ,OAAO,MAAM,WAAU,UAAS;AAAA,QACpD;AAAA;AAAA;AAAA,EACH;AAGF,MAAI,CAAC,cAAc;AACjB,WACE,iCACG;AAAA;AAAA,MACA,OAAO;AAAA,OACV;AAAA,EAEJ;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAME,qBAAC,UAAK,WAAU,qDACb;AAAA;AAAA,MAID;AAAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,aAAU;AAAA,UACV,aAAU;AAAA,UACV,WAAU;AAAA,UAEV,8BAAC,WAAQ,OAAO,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI,GAAG,MAAI,MAAC,WAAU,WACnE,8BAAC,UAAK,WAAU,kBAAkB,sBAAW,GAC/C;AAAA;AAAA,MACF;AAAA,MACC,OAAO;AAAA,OACV;AAAA;AAEJ,CAAC;AACD,WAAW,cAAc;","names":["FileButton"]}
@@ -1,16 +1,20 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentPropsWithoutRef, ReactNode } from 'react';
3
- import { ai as FileRejection, bu as FilePickHandler, ah as FilePickerLabels } from '../kit-labels-D1J2_jyD.js';
4
- import './data-table-labels.js';
3
+ import { aR as FileRejection, ch as FilePickHandler, aQ as FilePickerLabels } from '../feedback-BxeQVzwq.js';
4
+ import '../feedback-attachment-fGAzZPf0.js';
5
+ import '../feedback/feedback-inbox.js';
6
+ import 'lucide-react';
7
+ import './tooltip.js';
8
+ import '../hooks/use-anchored-rect.js';
9
+ import '../lib/clipping.js';
10
+ import '../data-table-labels-B7OdnM0S.js';
11
+ import './data-table-sort.js';
12
+ import './swipeable-row.js';
5
13
  import './mini-calendar.js';
6
14
  import './calendar-heatmap.js';
7
15
  import './popover.js';
8
16
  import './chip.js';
9
- import 'lucide-react';
10
17
  import './field-sync.js';
11
- import './tooltip.js';
12
- import '../hooks/use-anchored-rect.js';
13
- import '../lib/clipping.js';
14
18
  import '../wizard/types.js';
15
19
  import '../tour/tour.js';
16
20
  import '../search/command-palette.js';
@@ -24,7 +28,6 @@ import './sparkline.js';
24
28
  import './stat-tile.js';
25
29
  import './signature-pad.js';
26
30
  import './password-strength.js';
27
- import './danger-confirm.js';
28
31
  import './swatch-picker.js';
29
32
  import './tile-radio.js';
30
33
  import './icon-picker.js';
@@ -32,11 +35,7 @@ import './dialog-frame.js';
32
35
  import './modal.js';
33
36
  import '../hooks/use-search-param-state.js';
34
37
  import './measured-grid.js';
35
- import '../feedback-attachment-WFiXJ8We.js';
36
- import '../feedback/feedback-thread.js';
37
- import '../feedback/feedback-inbox.js';
38
38
  import './account-settings-labels.js';
39
- import './confirm-dialog.js';
40
39
  import './floating-panel.js';
41
40
  import './bulk-action-bar.js';
42
41
  import './list.js';
@@ -55,14 +54,20 @@ import './write-lock.js';
55
54
  import './legal.js';
56
55
  import './account-chips.js';
57
56
  import '../lib/format.js';
58
- import '../data-table-3mi2R3so.js';
59
- import './data-table-sort.js';
60
- import './swipeable-row.js';
61
57
  import './reauth-dialog.js';
62
58
  import './server-wake.js';
63
59
  import '../lib/server-wake.js';
64
60
  import './translation-review-labels.js';
65
61
  import '../lib/translation-review.js';
62
+ import './country-select.js';
63
+ import './inline-edit-field.js';
64
+ import '../lib/iban.js';
65
+ import '../lib/phone.js';
66
+ import './sign-chip.js';
67
+ import './column-mapper.js';
68
+ import '../lib/column-mapping.js';
69
+ import '../lib/table-text.js';
70
+ import './field-parts.js';
66
71
 
67
72
  /**
68
73
  * Where a refused file's message goes.
@@ -82,6 +87,11 @@ interface FileDropzoneState {
82
87
  dragOver: boolean;
83
88
  disabled: boolean;
84
89
  busy: boolean;
90
+ /** 0.22: locked with a reason (`disabledReason`, or `commit` under a locked
91
+ * {@link WriteLockProvider}) — takes no files, like `disabled`. */
92
+ locked: boolean;
93
+ /** The reason while `locked`, for a custom body to show; `undefined` otherwise. */
94
+ disabledReason: ReactNode | undefined;
85
95
  /** What is chosen: `files` in multiple mode, `[file]` or `[]` in single mode. */
86
96
  files: readonly File[];
87
97
  /** The inline refusal, when `rejectionFeedback="inline"` has one to show. */
@@ -185,6 +195,22 @@ interface FileDropzoneProps extends Omit<ComponentPropsWithoutRef<"div">, "onInv
185
195
  * text. The other half of why keksdose's invoice zone was hand-rolled.
186
196
  */
187
197
  busy?: boolean;
198
+ /**
199
+ * Why the zone is not taking files — the write lock's sentence, a quota, a closed
200
+ * period (keksdose K3). Takes no drop, no picker and no removal, like `disabled`, and
201
+ * SAYS so: the Browse button (and every remove button) stays focusable,
202
+ * `aria-disabled`, with the reason in the kit Tooltip and its description, the zone's
203
+ * group is described by it, and the default body shows it where the hint was. Not
204
+ * dimmed: what is chosen stays readable. Wins over `disabled`'s silent look.
205
+ */
206
+ disabledReason?: ReactNode;
207
+ /**
208
+ * This zone COMMITS — an upload that starts on drop. Under a locked
209
+ * {@link WriteLockProvider} it takes the `disabledReason` path with the lock's
210
+ * reason (which wins over one of its own). No provider, or an unlocked one: no
211
+ * effect. A zone that only stages a file for a form saved later is not a commit.
212
+ */
213
+ commit?: boolean;
188
214
  /**
189
215
  * Replace the zone's body — the icon, the text and the chosen-file list — with your
190
216
  * own, given the zone's state: keksdose's spinner-plus-"uploading", its multi-shot
@@ -203,6 +229,6 @@ interface FileDropzoneProps extends Omit<ComponentPropsWithoutRef<"div">, "onInv
203
229
  * `rejectionFeedback`; the chosen file(s) are echoed with their size, otherwise
204
230
  * `emptyLabel` + `hint` describe what to drop. For a trigger with no drop area, see
205
231
  * `FileButton`. */
206
- declare function FileDropzone({ file, onFileSelected, multiple, files, onFilesSelected, onClear, onRemove, accept, isValid, invalidMessage, maxSize, maxFiles, onInvalid, onReject, onPick, rejectionFeedback, labels: labelsProp, dropLabel: dropLabelProp, browseLabel: browseLabelProp, emptyLabel: emptyLabelProp, hint: hintProp, disabled, busy, renderBody, className, "aria-label": ariaLabel, "aria-describedby": describedByProp, ...rest }: FileDropzoneProps): react.JSX.Element;
232
+ declare function FileDropzone({ file, onFileSelected, multiple, files, onFilesSelected, onClear, onRemove, accept, isValid, invalidMessage, maxSize, maxFiles, onInvalid, onReject, onPick, rejectionFeedback, labels: labelsProp, dropLabel: dropLabelProp, browseLabel: browseLabelProp, emptyLabel: emptyLabelProp, hint: hintProp, disabled, busy, disabledReason: ownDisabledReason, commit, renderBody, className, "aria-label": ariaLabel, "aria-describedby": describedByProp, ...rest }: FileDropzoneProps): react.JSX.Element;
207
233
 
208
234
  export { FileDropzone, type FileDropzoneProps, type FileDropzoneRejectionFeedback, type FileDropzoneState };
@@ -15,6 +15,7 @@ import {
15
15
  } from "./file-button.js";
16
16
  import { useDragTarget } from "../hooks/use-file-drop.js";
17
17
  import { toast } from "./toast.js";
18
+ import { useCommitReason } from "./write-lock.js";
18
19
  function FileDropzone({
19
20
  file,
20
21
  onFileSelected,
@@ -39,6 +40,8 @@ function FileDropzone({
39
40
  hint: hintProp,
40
41
  disabled,
41
42
  busy,
43
+ disabledReason: ownDisabledReason,
44
+ commit,
42
45
  renderBody,
43
46
  className,
44
47
  "aria-label": ariaLabel,
@@ -46,7 +49,10 @@ function FileDropzone({
46
49
  ...rest
47
50
  }) {
48
51
  const [error, setError] = useState(null);
49
- const inert = Boolean(disabled || busy);
52
+ const disabledReason = useCommitReason(commit, ownDisabledReason);
53
+ const locked = hasReason(disabledReason);
54
+ const inert = Boolean(disabled || busy) || locked;
55
+ const reasonId = useId();
50
56
  const [fileInput, setFileInput] = useState(null);
51
57
  const browseRef = useRef(null);
52
58
  const errorId = useId();
@@ -111,7 +117,10 @@ function FileDropzone({
111
117
  };
112
118
  const chosen = multiple ? files ?? [] : file ? [file] : [];
113
119
  const showError = feedback === "inline" && error !== null;
114
- const describedBy = cn(describedByProp, showError && errorId) || void 0;
120
+ const describedBy = cn(describedByProp, showError && errorId, locked && reasonId) || void 0;
121
+ const controlDisabled = Boolean(disabled || busy);
122
+ const controlReason = locked ? disabledReason : void 0;
123
+ const reasonLine = locked && /* @__PURE__ */ jsx("div", { "data-slot": "file-dropzone-reason", className: "text-xs text-[var(--text-muted)]", children: disabledReason });
115
124
  return /* @__PURE__ */ jsxs(Fragment, { children: [
116
125
  /* @__PURE__ */ jsxs(
117
126
  "div",
@@ -126,7 +135,7 @@ function FileDropzone({
126
135
  "aria-label": ariaLabel ?? dropLabel,
127
136
  "aria-describedby": describedBy,
128
137
  "data-invalid": showError || void 0,
129
- "aria-disabled": disabled || void 0,
138
+ "aria-disabled": disabled || locked || void 0,
130
139
  "aria-busy": busy || void 0,
131
140
  "data-drag-over": dragOver || void 0,
132
141
  className: cn(
@@ -147,7 +156,7 @@ function FileDropzone({
147
156
  // danger border until the next good pick.
148
157
  // Inert zones keep the resting hairline and lose the hover pull: a border that
149
158
  // answers the pointer promises a drop the zone will refuse.
150
- disabled ? "cursor-not-allowed border-[var(--border)] opacity-60" : busy ? "cursor-progress border-[var(--border)]" : dragOver ? "cursor-pointer border-[var(--border-strong)] bg-[var(--bg-active)]" : showError ? "cursor-pointer border-[var(--danger-border-strong)]" : "cursor-pointer border-[var(--border)] hover:border-[var(--border-strong)]",
159
+ disabled ? "cursor-not-allowed border-[var(--border)] opacity-60" : busy ? "cursor-progress border-[var(--border)]" : locked ? "cursor-not-allowed border-[var(--border)]" : dragOver ? "cursor-pointer border-[var(--border-strong)] bg-[var(--bg-active)]" : showError ? "cursor-pointer border-[var(--danger-border-strong)]" : "cursor-pointer border-[var(--border)] hover:border-[var(--border-strong)]",
151
160
  className
152
161
  ),
153
162
  children: [
@@ -155,6 +164,8 @@ function FileDropzone({
155
164
  dragOver,
156
165
  disabled: Boolean(disabled),
157
166
  busy: Boolean(busy),
167
+ locked,
168
+ disabledReason: locked ? disabledReason : void 0,
158
169
  files: chosen,
159
170
  error: showError ? error : null,
160
171
  open,
@@ -164,32 +175,36 @@ function FileDropzone({
164
175
  /* @__PURE__ */ jsx("div", { className: "text-sm text-[var(--text-secondary)]", children: labels.busy })
165
176
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
166
177
  /* @__PURE__ */ jsx(Upload, { "aria-hidden": true, className: "size-5 text-[var(--text-muted)]" }),
167
- multiple && chosen.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "flex w-full max-w-sm flex-col gap-1 text-start", children: chosen.map((f, i) => /* @__PURE__ */ jsxs(
168
- "li",
169
- {
170
- className: "flex items-center gap-2 text-sm text-[var(--text-secondary)]",
171
- children: [
172
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate font-medium", children: f.name }),
173
- /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-[var(--text-muted)]", children: fileText.size(f.size) }),
174
- onRemove && /* @__PURE__ */ jsx(
175
- IconButton,
176
- {
177
- type: "button",
178
- size: "sm",
179
- disabled: inert,
180
- "aria-label": labels.remove(f.name),
181
- onClick: (e) => {
182
- e.stopPropagation();
183
- onRemove(f, i);
184
- afterRemoval(labels.removed(f.name));
185
- },
186
- children: /* @__PURE__ */ jsx(X, { "aria-hidden": true })
187
- }
188
- )
189
- ]
190
- },
191
- `${f.name}-${f.size}-${i}`
192
- )) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
178
+ multiple && chosen.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
179
+ /* @__PURE__ */ jsx("ul", { className: "flex w-full max-w-sm flex-col gap-1 text-start", children: chosen.map((f, i) => /* @__PURE__ */ jsxs(
180
+ "li",
181
+ {
182
+ className: "flex items-center gap-2 text-sm text-[var(--text-secondary)]",
183
+ children: [
184
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate font-medium", children: f.name }),
185
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-[var(--text-muted)]", children: fileText.size(f.size) }),
186
+ onRemove && /* @__PURE__ */ jsx(
187
+ IconButton,
188
+ {
189
+ type: "button",
190
+ size: "sm",
191
+ disabled: controlDisabled,
192
+ disabledReason: controlReason,
193
+ "aria-label": labels.remove(f.name),
194
+ onClick: (e) => {
195
+ e.stopPropagation();
196
+ onRemove(f, i);
197
+ afterRemoval(labels.removed(f.name));
198
+ },
199
+ children: /* @__PURE__ */ jsx(X, { "aria-hidden": true })
200
+ }
201
+ )
202
+ ]
203
+ },
204
+ `${f.name}-${f.size}-${i}`
205
+ )) }),
206
+ reasonLine
207
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
193
208
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-[var(--text-secondary)]", children: [
194
209
  !multiple && file ? /* @__PURE__ */ jsx("span", { className: "font-medium", children: file.name }) : emptyLabel,
195
210
  !multiple && file && onClear && /* @__PURE__ */ jsx(
@@ -197,7 +212,8 @@ function FileDropzone({
197
212
  {
198
213
  type: "button",
199
214
  size: "sm",
200
- disabled: inert,
215
+ disabled: controlDisabled,
216
+ disabledReason: controlReason,
201
217
  "aria-label": labels.remove(file.name),
202
218
  onClick: (e) => {
203
219
  e.stopPropagation();
@@ -208,7 +224,8 @@ function FileDropzone({
208
224
  }
209
225
  )
210
226
  ] }),
211
- /* @__PURE__ */ jsx("div", { className: "text-xs text-[var(--text-muted)]", children: file && !multiple ? fileText.size(file.size) : hint })
227
+ locked && !(file && !multiple) ? reasonLine : /* @__PURE__ */ jsx("div", { className: "text-xs text-[var(--text-muted)]", children: file && !multiple ? fileText.size(file.size) : hint }),
228
+ locked && file && !multiple && reasonLine
212
229
  ] })
213
230
  ] }),
214
231
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-center gap-2", children: [
@@ -218,7 +235,8 @@ function FileDropzone({
218
235
  ref: browseRef,
219
236
  type: "button",
220
237
  variant: "secondary",
221
- disabled: inert,
238
+ disabled: controlDisabled,
239
+ disabledReason: controlReason,
222
240
  onClick: (e) => {
223
241
  e.stopPropagation();
224
242
  open();
@@ -231,7 +249,8 @@ function FileDropzone({
231
249
  {
232
250
  type: "button",
233
251
  variant: "ghost",
234
- disabled: inert,
252
+ disabled: controlDisabled,
253
+ disabledReason: controlReason,
235
254
  onClick: (e) => {
236
255
  e.stopPropagation();
237
256
  onClear();
@@ -242,6 +261,7 @@ function FileDropzone({
242
261
  )
243
262
  ] }),
244
263
  showError && /* @__PURE__ */ jsx("p", { id: errorId, className: "text-xs text-[var(--danger)]", children: error }),
264
+ locked && /* @__PURE__ */ jsx("span", { id: reasonId, hidden: true, children: disabledReason }),
245
265
  /* @__PURE__ */ jsx(
246
266
  "input",
247
267
  {
@@ -266,6 +286,9 @@ function FileDropzone({
266
286
  /* @__PURE__ */ jsx("span", { ...alert.regionProps })
267
287
  ] });
268
288
  }
289
+ function hasReason(reason) {
290
+ return reason !== void 0 && reason !== null && reason !== false && reason !== "";
291
+ }
269
292
  function fromControl(e) {
270
293
  const target = e.target;
271
294
  const control = target?.closest?.("button, a[href], input, select, textarea, label, [role='button']");