@eifi1/ui-kit 0.20.1 → 0.22.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 (286) hide show
  1. package/dist/chart.d.ts +10 -8
  2. package/dist/components/account-chips.d.ts +10 -3
  3. package/dist/components/account-chips.js +5 -2
  4. package/dist/components/account-chips.js.map +1 -1
  5. package/dist/components/account-settings.d.ts +33 -2
  6. package/dist/components/account-settings.js +43 -21
  7. package/dist/components/account-settings.js.map +1 -1
  8. package/dist/components/amount-input.d.ts +27 -8
  9. package/dist/components/amount-input.js +15 -28
  10. package/dist/components/amount-input.js.map +1 -1
  11. package/dist/components/autocomplete.d.ts +8 -0
  12. package/dist/components/autocomplete.js +9 -4
  13. package/dist/components/autocomplete.js.map +1 -1
  14. package/dist/components/button-group.d.ts +10 -8
  15. package/dist/components/calculator.d.ts +10 -8
  16. package/dist/components/checkbox-group.d.ts +104 -0
  17. package/dist/components/checkbox-group.js +111 -0
  18. package/dist/components/checkbox-group.js.map +1 -0
  19. package/dist/components/checkbox.d.ts +19 -0
  20. package/dist/components/checkbox.js +30 -7
  21. package/dist/components/checkbox.js.map +1 -1
  22. package/dist/components/chip.d.ts +18 -0
  23. package/dist/components/chip.js +47 -10
  24. package/dist/components/chip.js.map +1 -1
  25. package/dist/components/combobox.d.ts +13 -2
  26. package/dist/components/combobox.js +17 -8
  27. package/dist/components/combobox.js.map +1 -1
  28. package/dist/components/confirm-dialog.d.ts +66 -161
  29. package/dist/components/copy-button.d.ts +10 -8
  30. package/dist/components/country-select.d.ts +124 -0
  31. package/dist/components/country-select.js +237 -0
  32. package/dist/components/country-select.js.map +1 -0
  33. package/dist/components/currency-select.d.ts +17 -1
  34. package/dist/components/currency-select.js +56 -23
  35. package/dist/components/currency-select.js.map +1 -1
  36. package/dist/components/danger-confirm.d.ts +66 -166
  37. package/dist/components/danger-confirm.js +133 -49
  38. package/dist/components/danger-confirm.js.map +1 -1
  39. package/dist/components/data-table-cells.d.ts +1 -2
  40. package/dist/components/data-table-filter-popover.d.ts +1 -2
  41. package/dist/components/data-table-filters.d.ts +1 -2
  42. package/dist/components/data-table-labels.d.ts +4 -97
  43. package/dist/components/data-table-labels.js +9 -1
  44. package/dist/components/data-table-labels.js.map +1 -1
  45. package/dist/components/data-table-pagination.d.ts +3 -1
  46. package/dist/components/data-table.d.ts +1 -2
  47. package/dist/components/data-table.js +98 -3
  48. package/dist/components/data-table.js.map +1 -1
  49. package/dist/components/date-picker.d.ts +25 -5
  50. package/dist/components/date-picker.js +110 -59
  51. package/dist/components/date-picker.js.map +1 -1
  52. package/dist/components/entity-combobox.d.ts +8 -1
  53. package/dist/components/entity-combobox.js +9 -4
  54. package/dist/components/entity-combobox.js.map +1 -1
  55. package/dist/components/facing-pair.d.ts +10 -8
  56. package/dist/components/field-anatomy.d.ts +95 -0
  57. package/dist/components/field-anatomy.js +84 -0
  58. package/dist/components/field-anatomy.js.map +1 -0
  59. package/dist/components/field-parts.d.ts +114 -0
  60. package/dist/components/field-parts.js +72 -0
  61. package/dist/components/field-parts.js.map +1 -0
  62. package/dist/components/file-button.d.ts +10 -8
  63. package/dist/components/file-button.js +13 -3
  64. package/dist/components/file-button.js.map +1 -1
  65. package/dist/components/file-dropzone.d.ts +32 -9
  66. package/dist/components/file-dropzone.js +57 -34
  67. package/dist/components/file-dropzone.js.map +1 -1
  68. package/dist/components/form-actions.d.ts +10 -8
  69. package/dist/components/form-actions.js +61 -3
  70. package/dist/components/form-actions.js.map +1 -1
  71. package/dist/components/hover-menu.d.ts +3 -0
  72. package/dist/components/hover-menu.js +2 -2
  73. package/dist/components/hover-menu.js.map +1 -1
  74. package/dist/components/iban-input.d.ts +66 -0
  75. package/dist/components/iban-input.js +125 -0
  76. package/dist/components/iban-input.js.map +1 -0
  77. package/dist/components/icon-picker.d.ts +12 -2
  78. package/dist/components/icon-picker.js +9 -2
  79. package/dist/components/icon-picker.js.map +1 -1
  80. package/dist/components/inline-edit-field.d.ts +167 -0
  81. package/dist/components/inline-edit-field.js +293 -0
  82. package/dist/components/inline-edit-field.js.map +1 -0
  83. package/dist/components/language-select.d.ts +127 -0
  84. package/dist/components/language-select.js +18 -0
  85. package/dist/components/language-select.js.map +1 -0
  86. package/dist/components/line-items.d.ts +25 -3
  87. package/dist/components/line-items.js +55 -46
  88. package/dist/components/line-items.js.map +1 -1
  89. package/dist/components/list.d.ts +25 -0
  90. package/dist/components/list.js +16 -5
  91. package/dist/components/list.js.map +1 -1
  92. package/dist/components/money-field.d.ts +20 -8
  93. package/dist/components/money-field.js.map +1 -1
  94. package/dist/components/month-picker.d.ts +52 -4
  95. package/dist/components/month-picker.js +290 -86
  96. package/dist/components/month-picker.js.map +1 -1
  97. package/dist/components/multi-select.d.ts +8 -1
  98. package/dist/components/multi-select.js +9 -4
  99. package/dist/components/multi-select.js.map +1 -1
  100. package/dist/components/number-field.d.ts +25 -13
  101. package/dist/components/number-field.js +6 -20
  102. package/dist/components/number-field.js.map +1 -1
  103. package/dist/components/number-input.d.ts +70 -13
  104. package/dist/components/number-input.js +90 -38
  105. package/dist/components/number-input.js.map +1 -1
  106. package/dist/components/numpad-sheet.d.ts +10 -8
  107. package/dist/components/one-time-code-input.d.ts +100 -0
  108. package/dist/components/one-time-code-input.js +137 -0
  109. package/dist/components/one-time-code-input.js.map +1 -0
  110. package/dist/components/phone-input.d.ts +66 -0
  111. package/dist/components/phone-input.js +171 -0
  112. package/dist/components/phone-input.js.map +1 -0
  113. package/dist/components/series-chart.d.ts +10 -8
  114. package/dist/components/settings-fields.d.ts +10 -8
  115. package/dist/components/share-card.d.ts +8 -6
  116. package/dist/components/sign-chip.d.ts +66 -0
  117. package/dist/components/sign-chip.js +39 -0
  118. package/dist/components/sign-chip.js.map +1 -0
  119. package/dist/components/swatch-picker.d.ts +27 -2
  120. package/dist/components/swatch-picker.js +73 -31
  121. package/dist/components/swatch-picker.js.map +1 -1
  122. package/dist/components/switch.d.ts +19 -0
  123. package/dist/components/switch.js +24 -6
  124. package/dist/components/switch.js.map +1 -1
  125. package/dist/components/text-link.d.ts +10 -8
  126. package/dist/components/tile-radio.d.ts +68 -13
  127. package/dist/components/tile-radio.js +3 -3
  128. package/dist/components/tile-radio.js.map +1 -1
  129. package/dist/components/time-input.d.ts +15 -9
  130. package/dist/components/time-input.js.map +1 -1
  131. package/dist/components/toggle-group.d.ts +47 -1
  132. package/dist/components/toggle-group.js +110 -69
  133. package/dist/components/toggle-group.js.map +1 -1
  134. package/dist/components/ui.d.ts +10 -8
  135. package/dist/components/ui.js +280 -78
  136. package/dist/components/ui.js.map +1 -1
  137. package/dist/components/use-table-state.d.ts +1 -2
  138. package/dist/{data-table-3mi2R3so.d.ts → data-table-labels-B7OdnM0S.d.ts} +140 -3
  139. package/dist/data-table.d.ts +1 -2
  140. package/dist/data-table.js +2 -1
  141. package/dist/data-table.js.map +1 -1
  142. package/dist/feedback/feedback-attachment.d.ts +1 -1
  143. package/dist/feedback/feedback-attachment.js +210 -3
  144. package/dist/feedback/feedback-attachment.js.map +1 -1
  145. package/dist/feedback/feedback-dialog.d.ts +1 -1
  146. package/dist/feedback/feedback-dialog.js.map +1 -1
  147. package/dist/feedback/feedback-inbox.d.ts +1 -1
  148. package/dist/feedback/feedback-thread.d.ts +37 -3
  149. package/dist/feedback/feedback-thread.js +38 -9
  150. package/dist/feedback/feedback-thread.js.map +1 -1
  151. package/dist/{feedback-attachment-WFiXJ8We.d.ts → feedback-attachment-NhUm7Zga.d.ts} +70 -5
  152. package/dist/feedback.d.ts +2 -2
  153. package/dist/hooks/use-file-drop.d.ts +10 -8
  154. package/dist/i18n/defaults.d.ts +10 -8
  155. package/dist/i18n/defaults.js +17 -2
  156. package/dist/i18n/defaults.js.map +1 -1
  157. package/dist/i18n/german.d.ts +10 -8
  158. package/dist/i18n/german.js +50 -5
  159. package/dist/i18n/german.js.map +1 -1
  160. package/dist/i18n/kit-labels.d.ts +10 -8
  161. package/dist/i18n/kit-labels.js +8 -2
  162. package/dist/i18n/kit-labels.js.map +1 -1
  163. package/dist/i18n/languages.d.ts +10 -8
  164. package/dist/i18n/locales/de-CH.d.ts +10 -8
  165. package/dist/i18n/locales/en.d.ts +10 -8
  166. package/dist/i18n/locales/en.js +9 -0
  167. package/dist/i18n/locales/en.js.map +1 -1
  168. package/dist/i18n/locales/es.d.ts +10 -8
  169. package/dist/i18n/locales/es.js +48 -5
  170. package/dist/i18n/locales/es.js.map +1 -1
  171. package/dist/i18n/locales/fr.d.ts +10 -8
  172. package/dist/i18n/locales/fr.js +48 -5
  173. package/dist/i18n/locales/fr.js.map +1 -1
  174. package/dist/i18n/locales/hu.d.ts +10 -8
  175. package/dist/i18n/locales/hu.js +49 -5
  176. package/dist/i18n/locales/hu.js.map +1 -1
  177. package/dist/i18n/locales/it.d.ts +10 -8
  178. package/dist/i18n/locales/it.js +49 -5
  179. package/dist/i18n/locales/it.js.map +1 -1
  180. package/dist/i18n/locales/zh.d.ts +10 -8
  181. package/dist/i18n/locales/zh.js +48 -5
  182. package/dist/i18n/locales/zh.js.map +1 -1
  183. package/dist/i18n/review.d.ts +10 -8
  184. package/dist/i18n/review.js +8 -1
  185. package/dist/i18n/review.js.map +1 -1
  186. package/dist/index.d.ts +17 -10
  187. package/dist/index.js +57 -2
  188. package/dist/index.js.map +1 -1
  189. package/dist/{kit-labels-D1J2_jyD.d.ts → kit-labels-R8mIAc9N.d.ts} +811 -8
  190. package/dist/lib/countries.d.ts +43 -0
  191. package/dist/lib/countries.js +39 -0
  192. package/dist/lib/countries.js.map +1 -0
  193. package/dist/lib/decimal-marks.d.ts +46 -0
  194. package/dist/lib/decimal-marks.js +40 -0
  195. package/dist/lib/decimal-marks.js.map +1 -0
  196. package/dist/lib/iban.d.ts +98 -0
  197. package/dist/lib/iban.js +154 -0
  198. package/dist/lib/iban.js.map +1 -0
  199. package/dist/lib/isin.d.ts +30 -0
  200. package/dist/lib/isin.js +36 -0
  201. package/dist/lib/isin.js.map +1 -0
  202. package/dist/lib/phone.d.ts +69 -0
  203. package/dist/lib/phone.js +121 -0
  204. package/dist/lib/phone.js.map +1 -0
  205. package/dist/rhf/fields.d.ts +148 -11
  206. package/dist/rhf/fields.js +332 -3
  207. package/dist/rhf/fields.js.map +1 -1
  208. package/dist/rhf/form.d.ts +10 -8
  209. package/dist/rhf.d.ts +13 -9
  210. package/dist/rhf.js.map +1 -1
  211. package/dist/shell/app-shell.d.ts +10 -8
  212. package/dist/shell/top-bar-brand.d.ts +10 -8
  213. package/dist/shell/topbar-action-menu.d.ts +13 -1
  214. package/dist/shell/topbar-action-menu.js +31 -28
  215. package/dist/shell/topbar-action-menu.js.map +1 -1
  216. package/dist/shell.d.ts +10 -8
  217. package/dist/tour/tour.js +20 -24
  218. package/dist/tour/tour.js.map +1 -1
  219. package/dist/wizard/stepper-nav.d.ts +10 -8
  220. package/dist/wizard.d.ts +10 -8
  221. package/package.json +1 -1
  222. package/src/components/account-chips.tsx +17 -3
  223. package/src/components/account-settings.tsx +92 -26
  224. package/src/components/amount-input.tsx +49 -56
  225. package/src/components/autocomplete.tsx +133 -110
  226. package/src/components/checkbox-group.tsx +229 -0
  227. package/src/components/checkbox.tsx +72 -8
  228. package/src/components/chip.tsx +80 -10
  229. package/src/components/combobox.tsx +292 -253
  230. package/src/components/country-select.tsx +443 -0
  231. package/src/components/currency-select.tsx +109 -33
  232. package/src/components/danger-confirm.tsx +345 -77
  233. package/src/components/data-table-labels.ts +16 -1
  234. package/src/components/data-table.tsx +175 -6
  235. package/src/components/date-picker.tsx +173 -62
  236. package/src/components/entity-combobox.tsx +107 -87
  237. package/src/components/field-anatomy.tsx +190 -0
  238. package/src/components/field-parts.tsx +184 -0
  239. package/src/components/file-button.tsx +36 -3
  240. package/src/components/file-dropzone.tsx +106 -38
  241. package/src/components/form-actions.tsx +115 -2
  242. package/src/components/hover-menu.tsx +7 -4
  243. package/src/components/iban-input.tsx +231 -0
  244. package/src/components/icon-picker.tsx +26 -4
  245. package/src/components/inline-edit-field.tsx +533 -0
  246. package/src/components/language-select.tsx +78 -0
  247. package/src/components/line-items.tsx +35 -2
  248. package/src/components/list.tsx +55 -6
  249. package/src/components/money-field.tsx +10 -0
  250. package/src/components/month-picker.tsx +399 -63
  251. package/src/components/multi-select.tsx +80 -58
  252. package/src/components/number-field.tsx +28 -46
  253. package/src/components/number-input.tsx +210 -43
  254. package/src/components/one-time-code-input.tsx +288 -0
  255. package/src/components/phone-input.tsx +299 -0
  256. package/src/components/sign-chip.tsx +103 -0
  257. package/src/components/swatch-picker.tsx +118 -30
  258. package/src/components/switch.tsx +58 -7
  259. package/src/components/tile-radio.tsx +71 -16
  260. package/src/components/time-input.tsx +8 -1
  261. package/src/components/toggle-group.tsx +206 -73
  262. package/src/components/ui.tsx +472 -105
  263. package/src/data-table.ts +2 -1
  264. package/src/feedback/feedback-attachment.tsx +313 -9
  265. package/src/feedback/feedback-dialog.tsx +2 -0
  266. package/src/feedback/feedback-thread.tsx +66 -5
  267. package/src/i18n/defaults.ts +16 -1
  268. package/src/i18n/german.ts +47 -0
  269. package/src/i18n/kit-labels.tsx +78 -2
  270. package/src/i18n/locales/en.ts +10 -0
  271. package/src/i18n/locales/es.ts +46 -0
  272. package/src/i18n/locales/fr.ts +45 -0
  273. package/src/i18n/locales/hu.ts +46 -0
  274. package/src/i18n/locales/it.ts +47 -0
  275. package/src/i18n/locales/zh.ts +44 -0
  276. package/src/i18n/review.ts +7 -0
  277. package/src/index.ts +53 -3
  278. package/src/lib/countries.ts +91 -0
  279. package/src/lib/decimal-marks.ts +99 -0
  280. package/src/lib/iban.ts +171 -0
  281. package/src/lib/isin.ts +62 -0
  282. package/src/lib/phone.ts +211 -0
  283. package/src/rhf/fields.tsx +606 -9
  284. package/src/rhf.ts +2 -1
  285. package/src/shell/topbar-action-menu.tsx +53 -29
  286. package/src/tour/tour.tsx +66 -28
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/feedback-attachment.tsx"],"sourcesContent":["import { cn } from \"../lib/cn\";\nimport { useEffect, useLayoutEffect, useRef, useState, type ClipboardEvent as ReactClipboardEvent, type RefObject } from \"react\";\nimport { Camera, FileText, Paperclip, X } from \"lucide-react\";\nimport { Button } from \"../components/ui\";\nimport { useKitFileLabels, useKitLabels } from \"../i18n/kit-labels\";\nimport type { FeedbackAttachmentLabels } from \"./feedback-dialog\";\n\nexport const DEFAULT_ATTACHMENT_ACCEPT = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"];\nexport const DEFAULT_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;\n/** How many files `<FeedbackAttachmentField multiple>` takes when `max` is not given\n * (0.15.5). Five photos of one problem is already a lot to look through; a report\n * that needs more is a conversation, which the thread is for. */\nexport const DEFAULT_MAX_ATTACHMENTS = 5;\n\n/**\n * The field's own strings — the `feedbackAttachment` namespace of `<UiKitProvider\n * labels>`. The keys are {@link FeedbackAttachmentLabels}' own, so the `labels` prop\n * (and a whole `FeedbackDialogLabels` handed down by the dialog) merges over them\n * one to one. The optional heading, `attachment`, stays a prop: a note editor puts\n * the buttons straight under its textarea and wants none.\n *\n * Before 0.7.0 the two optional keys fell back to hard-coded English, so a German app\n * that relied on its provider got \"Capture screenshot\" under a German form.\n *\n * The three keys added in 0.15.5 for `multiple` mode are optional, so a complete\n * `UiKitLabels` typed before it still compiles; they fall back to English. So is\n * `attachmentScreenshot` (0.16.0).\n */\nexport interface FeedbackAttachmentFieldLabels {\n attachmentAdd: string;\n attachmentCapture: string;\n attachmentPaste: string;\n attachmentRemove: string;\n /** `multiple` mode: the accessible name of the list of chosen files — and, since\n * 0.16.0, the heading `<FeedbackDialog attachments=\"multiple\">` puts over it. */\n attachmentList?: string;\n /** `multiple` mode (0.16.0): what the screenshot slot's chip is called — \"Screenshot\"\n * rather than the capture's file name (\"screenshot.webp\"), which says nothing a\n * reporter chose. The file name stays as the chip's second line. */\n attachmentScreenshot?: string;\n /** `multiple` mode: one chip's remove button — \"Remove photo.jpg\". Named per file,\n * because five buttons all called \"Remove attachment\" say nothing about which. */\n attachmentRemoveFile?: (name: string) => string;\n /** `multiple` mode: the line shown in place of the add buttons once `max` is reached. */\n attachmentLimit?: (max: number) => string;\n}\n\nexport const DEFAULT_FEEDBACK_ATTACHMENT_LABELS: FeedbackAttachmentFieldLabels = {\n attachmentAdd: \"Attach image\",\n attachmentCapture: \"Capture screenshot\",\n attachmentPaste: \"…or paste a screenshot from the clipboard.\",\n attachmentRemove: \"Remove attachment\",\n attachmentList: \"Attachments\",\n attachmentScreenshot: \"Screenshot\",\n attachmentRemoveFile: (name) => `Remove ${name}`,\n attachmentLimit: (max) =>\n `Up to ${max} ${max === 1 ? \"attachment\" : \"attachments\"} — remove one to add another.`,\n};\n\n/** Why a file was turned away. `\"count\"` only ever comes from `multiple` mode: more\n * files arrived at once than `max` left room for, and the surplus was dropped. */\nexport type FeedbackAttachmentError = \"type\" | \"size\" | \"count\";\n\ninterface FeedbackAttachmentFieldBaseProps {\n /** Prop > `<UiKitProvider labels={{ feedbackAttachment }}>` > English. Optional\n * since 0.7.0; `attachment` (the heading) is only ever read from here. */\n labels?: Partial<FeedbackAttachmentLabels>;\n accept?: string[];\n maxBytes?: number;\n /** Snapshot the app view behind this and return it as a File. A \"Capture\n * screenshot\" button appears only when it is given. */\n onCaptureScreenshot?: () => Promise<File | null>;\n /** Listen for the paste on `document` rather than on this field's own\n * subtree. For a modal, which owns the whole page while it is up. */\n documentPaste?: boolean;\n /** Listen for the paste within this element's subtree rather than this\n * field's own — for a field standing *beside* the text box a paste is made\n * in, whose common parent is where the event bubbles to. Ignored when\n * `documentPaste` is set. */\n pasteFrom?: RefObject<HTMLElement | null>;\n className?: string;\n}\n\n/** One file: choosing a second means removing the first. The field's only mode until 0.15.5. */\nexport interface FeedbackAttachmentFieldSingleProps extends FeedbackAttachmentFieldBaseProps {\n multiple?: false;\n value: File | null;\n onChange: (file: File | null) => void;\n onError?: (kind: \"type\" | \"size\") => void;\n // Multiple-mode props, refused here: without `multiple` they would be silently ignored.\n max?: never;\n screenshot?: never;\n onScreenshotChange?: never;\n}\n\n/**\n * Several files (0.15.5, keksdose dev#578: \"pasted two photos, the second overwrote\n * the first\"). Every way in ADDS — a pick of several files, a paste, a capture — up to\n * `max`, and each file is a removable chip.\n */\nexport interface FeedbackAttachmentFieldMultipleProps extends FeedbackAttachmentFieldBaseProps {\n multiple: true;\n value: File[];\n onChange: (files: File[]) => void;\n /** How many files `value` may hold. Default {@link DEFAULT_MAX_ATTACHMENTS} (5). The\n * add buttons and the paste hint are offered only while there is room. */\n max?: number;\n /** Per file: a rejected one is reported and the others are still added. */\n onError?: (kind: FeedbackAttachmentError) => void;\n /**\n * A separate slot for THE screenshot, outside `value` and `max`. Given\n * `onScreenshotChange`, what `onCaptureScreenshot` returns lands here instead of in\n * `value`, shown as the first chip, and the capture button is offered only while the\n * slot is empty — a second snapshot of the same view is not more evidence. This is\n * how `<FeedbackDialog attachments=\"multiple\">` keeps the screenshot apart from the\n * photos; a form built from the parts can do the same.\n */\n screenshot?: File | null;\n onScreenshotChange?: (file: File | null) => void;\n}\n\nexport type FeedbackAttachmentFieldProps =\n | FeedbackAttachmentFieldSingleProps\n | FeedbackAttachmentFieldMultipleProps;\n\n/**\n * Picking one picture: the file dialog, a capture of the app view, or a paste.\n * With `multiple`, picking several (see {@link FeedbackAttachmentFieldMultipleProps}).\n *\n * Lifted out of {@link FeedbackDialog} so the *reply* half of the feature can\n * have it too (Steering Design feedback #128). A report is a conversation — it\n * is filed, it is answered, and the reporter sends it back saying that is not\n * what they meant — and the screenshot showing what they mean is taken at\n * whichever of those points they looked. Only the first of them had a way to\n * attach one, so everything after it had to be described in words.\n *\n * **Three ways in, and they are three because no one of them covers the others.**\n * The file dialog needs a file on disk; `onCaptureScreenshot` snapshots the\n * *whole* app view; and the clipboard is where a region snip already is on every\n * platform (Steering Design feedback #39). Somebody who wanted to show one panel\n * had to save a crop and then find it again.\n *\n * `documentPaste` and `pasteFrom` decide where the paste is listened for, and\n * it is a real choice rather than a flag with a default. A modal traps focus,\n * so while it is up every paste in the page is meant for it — including one\n * made with nothing in particular focused, which never reaches a React\n * `onPaste` on a child: that is `documentPaste`. An editor **inline on a\n * page** is not that: the page around it has its own fields, so it listens\n * within its own subtree and a paste elsewhere stays where it was aimed. But\n * \"its own subtree\" has to include the text box the paste is actually made in,\n * and that box is this field's *sibling*, not its child — a paste in it bubbles\n * to their common parent and never through here. `pasteFrom` is that parent\n * (Steering Design feedback #140): the element whose subtree is listened to,\n * handed in by whoever renders both the box and this field side by side.\n */\nexport function FeedbackAttachmentField(props: FeedbackAttachmentFieldProps) {\n // Two components rather than one with branches: the modes hold different state\n // (one preview vs. one per chip), and a hook order that depends on a prop is a\n // crash the day a caller flips it.\n return props.multiple ? <MultipleField {...props} /> : <SingleField {...props} />;\n}\n\nfunction SingleField({\n value,\n onChange,\n labels: labelsProp,\n accept = DEFAULT_ATTACHMENT_ACCEPT,\n maxBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onError,\n onCaptureScreenshot,\n documentPaste = false,\n pasteFrom,\n className,\n}: FeedbackAttachmentFieldSingleProps) {\n // The object URL is keyed to the file it was made for, so a stale one (from the\n // previous file, or after `value` is cleared) is never shown — no reset needed.\n const [previewFor, setPreviewFor] = useState<{ file: File; url: string } | null>(null);\n const preview = value && previewFor?.file === value ? previewFor.url : null;\n const fileInputRef = useRef<HTMLInputElement>(null);\n // `file.size` from `<UiKitProvider labels>`, formatted in its locale — see FileDropzone.\n const fileText = useKitFileLabels();\n const text = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n\n // Object-URL preview lifecycle (create on change, revoke on cleanup).\n useEffect(() => {\n if (!value) return;\n const url = URL.createObjectURL(value);\n // The URL is an external resource that must be created and revoked in step\n // with the effect (a render-time `createObjectURL` would leak, and StrictMode's\n // remount would revoke a memoised one out from under the <img>).\n // eslint-disable-next-line react-hooks/set-state-in-effect -- publishing an external resource's handle\n setPreviewFor({ file: value, url });\n return () => URL.revokeObjectURL(url);\n }, [value]);\n\n const pick = (file: File | undefined | null) => {\n if (!file) return;\n const problem = rejection(file, accept, maxBytes);\n if (problem) {\n onError?.(problem);\n return;\n }\n onChange(file);\n };\n\n const onPaste = usePaste(\n (images) => {\n // Clipboard images arrive named \"image.png\" at best and unnamed at worst,\n // and the name is what the inbox shows beside the thumbnail. A name that\n // says where it came from is more use than the browser's.\n const file = images[0];\n pick(new File([file], pastedName(file.type), { type: file.type }));\n },\n documentPaste,\n pasteFrom,\n );\n\n return (\n <div\n // `relative` for the same reason as FileDropzone: the `sr-only` file input below\n // is `position: absolute`, and without a positioned ancestor it is laid out\n // against the initial containing block — extending the DOCUMENT height to its own\n // offset and producing a phantom second scrollbar on any long page.\n className={cn(\"relative\", className)}\n onPaste={onPaste}\n >\n <Heading text={labelsProp?.attachment} />\n {value ? (\n <div className=\"flex items-start gap-2\">\n {value.type.startsWith(\"image/\") && preview ? (\n <img\n src={preview}\n alt={value.name}\n className=\"h-20 w-20 rounded border border-[var(--border)] object-cover\"\n />\n ) : (\n // Non-image attachments (PDF, text) can't preview as an <img>, so\n // show a neutral file tile with the name/size beside it instead.\n <div className=\"flex h-20 w-20 items-center justify-center rounded border border-[var(--border)] text-[var(--text-placeholder)]\">\n <FileText className=\"size-8\" />\n </div>\n )}\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-sm text-[var(--text-secondary)]\">{value.name}</div>\n <div className=\"text-xs text-[var(--text-muted)]\">\n {fileText.size(value.size)}\n </div>\n </div>\n <button\n type=\"button\"\n onClick={() => onChange(null)}\n aria-label={text.attachmentRemove}\n className=\"rounded p-1.5 text-[var(--text-placeholder)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n ) : (\n <div className=\"space-y-1.5\">\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"button\" variant=\"secondary\" onClick={() => fileInputRef.current?.click()}>\n <Paperclip className=\"size-4\" /> {text.attachmentAdd}\n </Button>\n {onCaptureScreenshot && (\n <CaptureButton capture={onCaptureScreenshot} onFile={pick} label={text.attachmentCapture} />\n )}\n </div>\n {/* Said out loud, because a gesture with no affordance is a gesture\n nobody finds. */}\n <p className=\"text-xs text-[var(--text-muted)]\">\n {text.attachmentPaste}\n </p>\n </div>\n )}\n <input\n ref={fileInputRef}\n type=\"file\"\n accept={accept.join(\",\")}\n className=\"sr-only\"\n onChange={(e) => {\n pick(e.target.files?.[0]);\n e.target.value = \"\";\n }}\n />\n </div>\n );\n}\n\nfunction MultipleField({\n value,\n onChange,\n max = DEFAULT_MAX_ATTACHMENTS,\n screenshot = null,\n onScreenshotChange,\n labels: labelsProp,\n accept = DEFAULT_ATTACHMENT_ACCEPT,\n maxBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onError,\n onCaptureScreenshot,\n documentPaste = false,\n pasteFrom,\n className,\n}: FeedbackAttachmentFieldMultipleProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const fileText = useKitFileLabels();\n const text = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n const removeLabel = text.attachmentRemoveFile ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentRemoveFile!;\n const limitLabel = text.attachmentLimit ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentLimit!;\n const screenshotLabel = text.attachmentScreenshot ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentScreenshot!;\n\n // What an add or a remove builds on: the `value` prop, plus whatever this field has\n // already handed to `onChange` since the parent last rendered. The field is\n // controlled, so between an `onChange` and the re-render that brings it back, `value`\n // is stale — and two adds in that gap (two pastes, a paste and a pick, delivered by\n // native listeners whose updates React batches) each spread the SAME old list, and\n // the second dropped the first. Re-synced to the prop after every commit, so a\n // parent that refuses a change (or edits the list itself) is what wins.\n const latest = useRef(value);\n useLayoutEffect(() => {\n latest.current = value;\n });\n const commit = (next: File[]) => {\n latest.current = next;\n onChange(next);\n };\n\n const hasSlot = onScreenshotChange !== undefined;\n const room = Math.max(0, max - value.length);\n // The screenshot slot is its own thing: it neither counts against `max` nor is\n // closed by it, so a full set of photos still leaves the capture on offer.\n const canCapture = !!onCaptureScreenshot && (hasSlot ? !screenshot : room > 0);\n\n const add = (incoming: File[], pasted = false) => {\n const current = latest.current;\n const accepted: File[] = [];\n const taken = new Set([...current, ...(screenshot ? [screenshot] : [])].map((f) => f.name));\n for (const raw of incoming) {\n const problem = rejection(raw, accept, maxBytes);\n if (problem) {\n onError?.(problem);\n continue;\n }\n // Two pastes are two files called \"pasted.png\", and a backend that stores by\n // name keeps one of them — the very loss this mode exists to end. A picked\n // file keeps its own name: it is the user's, and they may look for it.\n const file = pasted ? renamed(raw, uniqueName(pastedName(raw.type), taken)) : raw;\n taken.add(file.name);\n // The same File object twice is one file chosen twice, not two.\n if (!current.includes(file)) accepted.push(file);\n }\n if (accepted.length === 0) return;\n const space = Math.max(0, max - current.length);\n if (accepted.length > space) onError?.(\"count\");\n const kept = accepted.slice(0, space);\n if (kept.length > 0) commit([...current, ...kept]);\n };\n\n const onPaste = usePaste((images) => add(images, true), documentPaste, pasteFrom);\n\n const capture = (file: File) => {\n if (!hasSlot) {\n add([file]);\n return;\n }\n const problem = rejection(file, accept, maxBytes);\n if (problem) onError?.(problem);\n else onScreenshotChange(file);\n };\n\n // Removing a chip removes the button that had focus. Focus goes to the chip that\n // took its place — the next one — and, when it was the last, to the first action\n // button (there is room again, so \"Attach\" is back), else to the chip before it.\n // Applied once the parent has re-rendered with the shorter list: the field is\n // controlled, and focusing before that would land on the chip being removed.\n const pendingFocus = useRef<number | null>(null);\n useEffect(() => {\n const index = pendingFocus.current;\n if (index === null) return;\n pendingFocus.current = null;\n const root = rootRef.current;\n if (!root) return;\n const removes = root.querySelectorAll<HTMLElement>(\"[data-attachment-remove]\");\n const target =\n removes[index] ?? root.querySelector<HTMLElement>(\"[data-attachment-action]\") ?? removes[index - 1];\n target?.focus();\n }, [value, screenshot]);\n\n const chips: Array<{ file: File; screenshot: boolean; name: string; remove: () => void }> = [\n ...(hasSlot && screenshot\n ? [{ file: screenshot, screenshot: true, name: screenshotLabel, remove: () => onScreenshotChange(null) }]\n : []),\n ...value.map((file) => ({\n file,\n screenshot: false,\n name: file.name,\n remove: () => commit(latest.current.filter((f) => f !== file)),\n })),\n ];\n\n return (\n <div ref={rootRef} className={cn(\"relative space-y-2\", className)} onPaste={onPaste}>\n <Heading text={labelsProp?.attachment} className=\"mb-0\" />\n {chips.length > 0 && (\n // One chip per row, full width: wrapped chips of name-dependent widths made a\n // ragged block in a 430px dialog, and a column keeps every name and remove\n // button in the same place — the next chip's button is right under the last.\n <ul aria-label={text.attachmentList} className=\"flex flex-col gap-2\">\n {chips.map((chip, index) => (\n <li\n key={fileKey(chip.file)}\n className=\"flex min-w-0 items-center gap-2 rounded-md border border-[var(--border)] bg-[var(--bg-surface)] p-1\"\n >\n <ChipPreview file={chip.file} screenshot={chip.screenshot} />\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-sm text-[var(--text-secondary)]\">{chip.name}</div>\n <div className=\"truncate text-xs text-[var(--text-muted)]\">\n {/* The screenshot's file name moves down here: still there for the\n reporter who wants to know what will be sent, not its title. */}\n {chip.screenshot ? `${chip.file.name} · ${fileText.size(chip.file.size)}` : fileText.size(chip.file.size)}\n </div>\n </div>\n <button\n type=\"button\"\n data-attachment-remove=\"\"\n onClick={() => {\n pendingFocus.current = index;\n chip.remove();\n }}\n aria-label={removeLabel(chip.name)}\n className=\"shrink-0 rounded p-1.5 text-[var(--text-placeholder)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </button>\n </li>\n ))}\n </ul>\n )}\n {(room > 0 || canCapture) && (\n <div className=\"flex flex-wrap gap-2\">\n {room > 0 && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n data-attachment-action=\"\"\n onClick={() => fileInputRef.current?.click()}\n >\n <Paperclip className=\"size-4\" /> {text.attachmentAdd}\n </Button>\n )}\n {canCapture && onCaptureScreenshot && (\n <CaptureButton\n capture={onCaptureScreenshot}\n onFile={capture}\n label={text.attachmentCapture}\n data-attachment-action=\"\"\n />\n )}\n </div>\n )}\n <p className=\"text-xs text-[var(--text-muted)]\">\n {room > 0 ? text.attachmentPaste : limitLabel(max)}\n </p>\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple={room > 1}\n accept={accept.join(\",\")}\n className=\"sr-only\"\n // Out of the tab order and the accessibility tree: the button above is\n // the way in, and a second, unlabelled \"Choose files\" stop is noise.\n tabIndex={-1}\n aria-hidden\n onChange={(e) => {\n add(Array.from(e.target.files ?? []));\n e.target.value = \"\";\n }}\n />\n </div>\n );\n}\n\nfunction Heading({ text, className }: { text?: string; className?: string }) {\n if (!text) return null;\n return (\n <div className={cn(\"mb-1 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]\", className)}>\n {text}\n </div>\n );\n}\n\nfunction CaptureButton({\n capture,\n onFile,\n label,\n ...rest\n}: {\n capture: () => Promise<File | null>;\n onFile: (file: File) => void;\n label: string;\n \"data-attachment-action\"?: string;\n}) {\n const [capturing, setCapturing] = useState(false);\n return (\n <Button\n type=\"button\"\n variant=\"secondary\"\n disabled={capturing}\n {...rest}\n onClick={() => {\n if (capturing) return;\n setCapturing(true);\n void capture()\n .then((file) => {\n if (file) onFile(file);\n })\n .finally(() => setCapturing(false));\n }}\n >\n <Camera className=\"size-4\" /> {capturing ? \"…\" : label}\n </Button>\n );\n}\n\n/** A chip's picture: the image itself, or a file glyph for anything that is not one.\n * Decorative (`alt=\"\"`) — the name stands beside it. Its own component so the object\n * URL lives exactly as long as the chip: removing the chip unmounts it and revokes. */\nfunction ChipPreview({ file, screenshot }: { file: File; screenshot: boolean }) {\n const isImage = file.type.startsWith(\"image/\");\n const [previewFor, setPreviewFor] = useState<{ file: File; url: string } | null>(null);\n const url = previewFor?.file === file ? previewFor.url : null;\n useEffect(() => {\n if (!isImage) return;\n const next = URL.createObjectURL(file);\n // As in the single field: an external resource created and revoked with the effect.\n // eslint-disable-next-line react-hooks/set-state-in-effect -- publishing an external resource's handle\n setPreviewFor({ file, url: next });\n return () => URL.revokeObjectURL(next);\n }, [file, isImage]);\n\n return (\n <span className=\"relative flex size-12 shrink-0 items-center justify-center overflow-hidden rounded border border-[var(--border)] bg-[var(--bg-surface-2)] text-[var(--text-placeholder)]\">\n {isImage && url ? (\n <img src={url} alt=\"\" className=\"size-full object-cover\" />\n ) : (\n <FileText aria-hidden className=\"size-6\" />\n )}\n {screenshot && (\n // Marks the slot apart from the photos: it is why the capture button is gone.\n <span className=\"absolute bottom-0.5 end-0.5 rounded-sm bg-[var(--bg-surface)] p-0.5 text-[var(--text-secondary)]\">\n <Camera aria-hidden className=\"size-3\" />\n </span>\n )}\n </span>\n );\n}\n\n/** A stable React key per File object — the name is not one (two pastes, two\n * \"pasted.png\" before renaming; the same photo picked from two folders). */\nconst fileKeys = new WeakMap<File, number>();\nlet nextFileKey = 0;\nfunction fileKey(file: File): number {\n let key = fileKeys.get(file);\n if (key === undefined) {\n key = nextFileKey++;\n fileKeys.set(file, key);\n }\n return key;\n}\n\nfunction rejection(file: File, accept: string[], maxBytes: number): \"type\" | \"size\" | null {\n if (!accept.includes(file.type)) return \"type\";\n if (file.size > maxBytes) return \"size\";\n return null;\n}\n\nfunction renamed(file: File, name: string): File {\n return new File([file], name, { type: file.type });\n}\n\n/** `pasted.png`, then `pasted-2.png`, `pasted-3.png`… — the first name not in `taken`. */\nfunction uniqueName(name: string, taken: Set<string>): string {\n if (!taken.has(name)) return name;\n const dot = name.lastIndexOf(\".\");\n const [stem, ext] = dot > 0 ? [name.slice(0, dot), name.slice(dot)] : [name, \"\"];\n let n = 2;\n while (taken.has(`${stem}-${n}${ext}`)) n++;\n return `${stem}-${n}${ext}`;\n}\n\n/**\n * The paste listener both modes share. `onImages` gets every image file on the\n * clipboard (the single field takes the first). It is registered once rather than per\n * render, so it reads the handler — which closes over props that change identity on\n * every render — out of a ref rather than out of its own dependency list. Returns the\n * `onPaste` for the field's root, or `undefined` when listening elsewhere.\n */\nfunction usePaste(\n onImages: (images: File[]) => void,\n documentPaste: boolean,\n pasteFrom: RefObject<HTMLElement | null> | undefined,\n) {\n const latest = useRef(onImages);\n useEffect(() => {\n latest.current = onImages;\n });\n\n // The element listened on, where it is not this field's own subtree: the\n // document for a modal, the given parent for an inline editor. Read inside\n // the effect rather than in render, because a ref's `current` is only set\n // once the parent has mounted — which it has by the time effects run.\n useEffect(() => {\n const target: EventTarget | null = documentPaste ? document : (pasteFrom?.current ?? null);\n if (!target) return;\n const onPaste = (event: Event) => {\n const clipboard = (event as ClipboardEvent).clipboardData;\n takeImages(clipboard, () => event.preventDefault(), latest.current);\n };\n target.addEventListener(\"paste\", onPaste);\n return () => target.removeEventListener(\"paste\", onPaste);\n }, [documentPaste, pasteFrom]);\n\n const listensElsewhere = documentPaste || pasteFrom !== undefined;\n return listensElsewhere\n ? undefined\n : (event: ReactClipboardEvent) => takeImages(event.clipboardData, () => event.preventDefault(), latest.current);\n}\n\nfunction takeImages(clipboard: DataTransfer | null, stop: () => void, onImages: (images: File[]) => void) {\n const images = Array.from(clipboard?.items ?? [])\n .filter((item) => item.kind === \"file\" && item.type.startsWith(\"image/\"))\n .map((item) => item.getAsFile())\n .filter((file): file is File => file !== null);\n if (images.length === 0) return;\n // Only once there IS an image: a paste of text into a field must stay a\n // paste of text, and a clipboard holding both is a copy whose text half is\n // what the field was focused for.\n stop();\n onImages(images);\n}\n\n/** What a pasted image is called once it is an attachment.\n *\n * The extension is read off the mime type rather than assumed to be `.png`:\n * Safari puts TIFF on the clipboard and a file called `pasted.png` that is not\n * a PNG is one the receiving end opens wrong. */\nexport function pastedName(type: string): string {\n const subtype = type.split(\"/\")[1] ?? \"png\";\n // `image/svg+xml` and friends carry a suffix that is not part of the\n // extension, and none of them are in the accepted list anyway.\n return `pasted.${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,UAAM,UAAU,CAAC,UAAiB;AAChC,YAAM,YAAa,MAAyB;AAC5C,iBAAW,WAAW,MAAM,MAAM,eAAe,GAAG,OAAO,OAAO;AAAA,IACpE;AACA,WAAO,iBAAiB,SAAS,OAAO;AACxC,WAAO,MAAM,OAAO,oBAAoB,SAAS,OAAO;AAAA,EAC1D,GAAG,CAAC,eAAe,SAAS,CAAC;AAE7B,QAAM,mBAAmB,iBAAiB,cAAc;AACxD,SAAO,mBACH,SACA,CAAC,UAA+B,WAAW,MAAM,eAAe,MAAM,MAAM,eAAe,GAAG,OAAO,OAAO;AAClH;AAEA,SAAS,WAAW,WAAgC,MAAkB,UAAoC;AACxG,QAAM,SAAS,MAAM,KAAK,WAAW,SAAS,CAAC,CAAC,EAC7C,OAAO,CAAC,SAAS,KAAK,SAAS,UAAU,KAAK,KAAK,WAAW,QAAQ,CAAC,EACvE,IAAI,CAAC,SAAS,KAAK,UAAU,CAAC,EAC9B,OAAO,CAAC,SAAuB,SAAS,IAAI;AAC/C,MAAI,OAAO,WAAW,EAAG;AAIzB,OAAK;AACL,WAAS,MAAM;AACjB;AAOO,SAAS,WAAW,MAAsB;AAC/C,QAAM,UAAU,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK;AAGtC,SAAO,UAAU,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC;AACxC;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/feedback-attachment.tsx"],"sourcesContent":["import { cn } from \"../lib/cn\";\nimport { useEffect, useLayoutEffect, useRef, useState, type ClipboardEvent as ReactClipboardEvent, type RefObject } from \"react\";\nimport { Camera, FileText, Image as ImageIcon, Paperclip, X } from \"lucide-react\";\nimport { Button, Spinner } from \"../components/ui\";\nimport { useKitFileLabels, useKitLabels } from \"../i18n/kit-labels\";\nimport type { FeedbackAttachmentLabels } from \"./feedback-dialog\";\n\nexport const DEFAULT_ATTACHMENT_ACCEPT = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"];\nexport const DEFAULT_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;\n/** How many files `<FeedbackAttachmentField multiple>` takes when `max` is not given\n * (0.15.5). Five photos of one problem is already a lot to look through; a report\n * that needs more is a conversation, which the thread is for. */\nexport const DEFAULT_MAX_ATTACHMENTS = 5;\n\n/**\n * The field's own strings — the `feedbackAttachment` namespace of `<UiKitProvider\n * labels>`. The keys are {@link FeedbackAttachmentLabels}' own, so the `labels` prop\n * (and a whole `FeedbackDialogLabels` handed down by the dialog) merges over them\n * one to one. The optional heading, `attachment`, stays a prop: a note editor puts\n * the buttons straight under its textarea and wants none.\n *\n * Before 0.7.0 the two optional keys fell back to hard-coded English, so a German app\n * that relied on its provider got \"Capture screenshot\" under a German form.\n *\n * The three keys added in 0.15.5 for `multiple` mode are optional, so a complete\n * `UiKitLabels` typed before it still compiles; they fall back to English. So is\n * `attachmentScreenshot` (0.16.0).\n */\nexport interface FeedbackAttachmentFieldLabels {\n attachmentAdd: string;\n attachmentCapture: string;\n attachmentPaste: string;\n attachmentRemove: string;\n /** `multiple` mode: the accessible name of the list of chosen files — and, since\n * 0.16.0, the heading `<FeedbackDialog attachments=\"multiple\">` puts over it. */\n attachmentList?: string;\n /** `multiple` mode (0.16.0): what the screenshot slot's chip is called — \"Screenshot\"\n * rather than the capture's file name (\"screenshot.webp\"), which says nothing a\n * reporter chose. The file name stays as the chip's second line. */\n attachmentScreenshot?: string;\n /** `multiple` mode: one chip's remove button — \"Remove photo.jpg\". Named per file,\n * because five buttons all called \"Remove attachment\" say nothing about which. */\n attachmentRemoveFile?: (name: string) => string;\n /** `multiple` mode: the line shown in place of the add buttons once `max` is reached. */\n attachmentLimit?: (max: number) => string;\n /** `refs` mode (0.22.0, keksdose K16): the second line of a chip whose upload is still\n * running, where an uploaded one shows its size — \"Uploading…\". Optional, like the\n * keys above, so a `UiKitLabels` typed before it still compiles. */\n attachmentUploading?: string;\n}\n\nexport const DEFAULT_FEEDBACK_ATTACHMENT_LABELS: FeedbackAttachmentFieldLabels = {\n attachmentAdd: \"Attach image\",\n attachmentCapture: \"Capture screenshot\",\n attachmentPaste: \"…or paste a screenshot from the clipboard.\",\n attachmentRemove: \"Remove attachment\",\n attachmentList: \"Attachments\",\n attachmentScreenshot: \"Screenshot\",\n attachmentRemoveFile: (name) => `Remove ${name}`,\n attachmentLimit: (max) =>\n `Up to ${max} ${max === 1 ? \"attachment\" : \"attachments\"} — remove one to add another.`,\n attachmentUploading: \"Uploading…\",\n};\n\n/** Why a file was turned away. `\"count\"` only ever comes from `multiple` (and `refs`)\n * mode: more files arrived at once than `max` left room for, and the surplus was\n * dropped. */\nexport type FeedbackAttachmentError = \"type\" | \"size\" | \"count\";\n\n/** `refs` mode's reasons: {@link FeedbackAttachmentError}, or `\"upload\"` — `onUpload`\n * rejected, and what it rejected with is `onError`'s second argument. A type of its\n * own so a host's exhaustive switch over the File modes' reasons stays exhaustive. */\nexport type FeedbackAttachmentRefsError = FeedbackAttachmentError | \"upload\";\n\n/**\n * One uploaded attachment in `refs` mode: what the host's upload answered with. `key`\n * identifies it (a storage key, an upload id) and is what a remove goes by; `name` is\n * what the chip says. `size` (bytes) and `type` (mime) are optional — given, the chip\n * shows the size and an image icon or a file icon accordingly.\n */\nexport interface FeedbackAttachmentRef {\n key: string;\n name: string;\n size?: number;\n type?: string;\n}\n\ninterface FeedbackAttachmentFieldBaseProps {\n /** Prop > `<UiKitProvider labels={{ feedbackAttachment }}>` > English. Optional\n * since 0.7.0; `attachment` (the heading) is only ever read from here. */\n labels?: Partial<FeedbackAttachmentLabels> & Pick<Partial<FeedbackAttachmentFieldLabels>, \"attachmentUploading\">;\n accept?: string[];\n maxBytes?: number;\n /** Snapshot the app view behind this and return it as a File. A \"Capture\n * screenshot\" button appears only when it is given. */\n onCaptureScreenshot?: () => Promise<File | null>;\n /** Listen for the paste on `document` rather than on this field's own\n * subtree. For a modal, which owns the whole page while it is up. */\n documentPaste?: boolean;\n /** Listen for the paste within this element's subtree rather than this\n * field's own — for a field standing *beside* the text box a paste is made\n * in, whose common parent is where the event bubbles to. Ignored when\n * `documentPaste` is set. */\n pasteFrom?: RefObject<HTMLElement | null>;\n className?: string;\n}\n\n/** One file: choosing a second means removing the first. The field's only mode until 0.15.5. */\nexport interface FeedbackAttachmentFieldSingleProps extends FeedbackAttachmentFieldBaseProps {\n multiple?: false;\n refs?: false;\n value: File | null;\n onChange: (file: File | null) => void;\n onError?: (kind: \"type\" | \"size\") => void;\n // Multiple-mode props, refused here: without `multiple` they would be silently ignored.\n max?: never;\n screenshot?: never;\n onScreenshotChange?: never;\n}\n\n/**\n * Several files (0.15.5, keksdose dev#578: \"pasted two photos, the second overwrote\n * the first\"). Every way in ADDS — a pick of several files, a paste, a capture — up to\n * `max`, and each file is a removable chip.\n */\nexport interface FeedbackAttachmentFieldMultipleProps extends FeedbackAttachmentFieldBaseProps {\n multiple: true;\n refs?: false;\n value: File[];\n onChange: (files: File[]) => void;\n /** How many files `value` may hold. Default {@link DEFAULT_MAX_ATTACHMENTS} (5). The\n * add buttons and the paste hint are offered only while there is room. */\n max?: number;\n /** Per file: a rejected one is reported and the others are still added. */\n onError?: (kind: FeedbackAttachmentError) => void;\n /**\n * A separate slot for THE screenshot, outside `value` and `max`. Given\n * `onScreenshotChange`, what `onCaptureScreenshot` returns lands here instead of in\n * `value`, shown as the first chip, and the capture button is offered only while the\n * slot is empty — a second snapshot of the same view is not more evidence. This is\n * how `<FeedbackDialog attachments=\"multiple\">` keeps the screenshot apart from the\n * photos; a form built from the parts can do the same.\n */\n screenshot?: File | null;\n onScreenshotChange?: (file: File | null) => void;\n}\n\n/**\n * Uploaded on pick (0.22.0, keksdose K16). keksdose's support chat uploads each file\n * the moment it is chosen and sends the message with the REFS the uploads answered —\n * a 10 MB screenshot is refused while the reporter is still typing, not when they\n * press Send — so its `AttachmentPicker` could not use this field, whose value is\n * `File`s held until the form is submitted. Here the value is\n * {@link FeedbackAttachmentRef}s: every way in (pick, paste, capture) validates the\n * file as the other modes do, then hands it to `onUpload` and shows a chip with a\n * spinner until it answers; the ref it resolves to joins `value` through `onChange`.\n * A rejection drops the chip and reports `onError(\"upload\", error)`. A chip is removed\n * BY KEY: `onChange` gets the list without it, and `onRemove` the key, for a host that\n * deletes the upload on the server too.\n *\n * Uploads still running count against `max`, so five picks in quick succession cannot\n * overshoot it; they are not in `value` until they land, so a send that reads `value`\n * sends only what has arrived — hold Send back while {@link onUploadingChange} says\n * an upload is running. Several files upload side by side and join in the order they\n * finish. The File modes are unchanged.\n */\nexport interface FeedbackAttachmentFieldRefsProps extends FeedbackAttachmentFieldBaseProps {\n refs: true;\n multiple?: never;\n value: FeedbackAttachmentRef[];\n onChange: (refs: FeedbackAttachmentRef[]) => void;\n /** Upload one file; resolve to its ref, or reject to refuse it. Called once per\n * accepted file, the moment it is chosen. */\n onUpload: (file: File) => Promise<FeedbackAttachmentRef>;\n /** A chip was removed — after `onChange` — with its ref's key. */\n onRemove?: (key: string) => void;\n /** Whether any upload is running: `true` when the first starts, `false` when the\n * last settles — for the host's Send, which should wait. */\n onUploadingChange?: (uploading: boolean) => void;\n /** How many refs `value` may hold, uploads in flight included. Default\n * {@link DEFAULT_MAX_ATTACHMENTS} (5). */\n max?: number;\n /** Per file. `\"upload\"` carries what `onUpload` rejected with. */\n onError?: (kind: FeedbackAttachmentRefsError, error?: unknown) => void;\n screenshot?: never;\n onScreenshotChange?: never;\n}\n\nexport type FeedbackAttachmentFieldProps =\n | FeedbackAttachmentFieldSingleProps\n | FeedbackAttachmentFieldMultipleProps\n | FeedbackAttachmentFieldRefsProps;\n\n/**\n * Picking one picture: the file dialog, a capture of the app view, or a paste.\n * With `multiple`, picking several (see {@link FeedbackAttachmentFieldMultipleProps}).\n *\n * Lifted out of {@link FeedbackDialog} so the *reply* half of the feature can\n * have it too (Steering Design feedback #128). A report is a conversation — it\n * is filed, it is answered, and the reporter sends it back saying that is not\n * what they meant — and the screenshot showing what they mean is taken at\n * whichever of those points they looked. Only the first of them had a way to\n * attach one, so everything after it had to be described in words.\n *\n * **Three ways in, and they are three because no one of them covers the others.**\n * The file dialog needs a file on disk; `onCaptureScreenshot` snapshots the\n * *whole* app view; and the clipboard is where a region snip already is on every\n * platform (Steering Design feedback #39). Somebody who wanted to show one panel\n * had to save a crop and then find it again.\n *\n * `documentPaste` and `pasteFrom` decide where the paste is listened for, and\n * it is a real choice rather than a flag with a default. A modal traps focus,\n * so while it is up every paste in the page is meant for it — including one\n * made with nothing in particular focused, which never reaches a React\n * `onPaste` on a child: that is `documentPaste`. An editor **inline on a\n * page** is not that: the page around it has its own fields, so it listens\n * within its own subtree and a paste elsewhere stays where it was aimed. But\n * \"its own subtree\" has to include the text box the paste is actually made in,\n * and that box is this field's *sibling*, not its child — a paste in it bubbles\n * to their common parent and never through here. `pasteFrom` is that parent\n * (Steering Design feedback #140): the element whose subtree is listened to,\n * handed in by whoever renders both the box and this field side by side.\n */\nexport function FeedbackAttachmentField(props: FeedbackAttachmentFieldProps) {\n // One component per mode rather than one with branches: the modes hold different\n // state (one preview vs. one per chip vs. uploads in flight), and a hook order that\n // depends on a prop is a crash the day a caller flips it.\n if (props.refs) return <RefsField {...props} />;\n return props.multiple ? <MultipleField {...props} /> : <SingleField {...props} />;\n}\n\nfunction SingleField({\n value,\n onChange,\n labels: labelsProp,\n accept = DEFAULT_ATTACHMENT_ACCEPT,\n maxBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onError,\n onCaptureScreenshot,\n documentPaste = false,\n pasteFrom,\n className,\n}: FeedbackAttachmentFieldSingleProps) {\n // The object URL is keyed to the file it was made for, so a stale one (from the\n // previous file, or after `value` is cleared) is never shown — no reset needed.\n const [previewFor, setPreviewFor] = useState<{ file: File; url: string } | null>(null);\n const preview = value && previewFor?.file === value ? previewFor.url : null;\n const fileInputRef = useRef<HTMLInputElement>(null);\n // `file.size` from `<UiKitProvider labels>`, formatted in its locale — see FileDropzone.\n const fileText = useKitFileLabels();\n const text = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n\n // Object-URL preview lifecycle (create on change, revoke on cleanup).\n useEffect(() => {\n if (!value) return;\n const url = URL.createObjectURL(value);\n // The URL is an external resource that must be created and revoked in step\n // with the effect (a render-time `createObjectURL` would leak, and StrictMode's\n // remount would revoke a memoised one out from under the <img>).\n // eslint-disable-next-line react-hooks/set-state-in-effect -- publishing an external resource's handle\n setPreviewFor({ file: value, url });\n return () => URL.revokeObjectURL(url);\n }, [value]);\n\n const pick = (file: File | undefined | null) => {\n if (!file) return;\n const problem = rejection(file, accept, maxBytes);\n if (problem) {\n onError?.(problem);\n return;\n }\n onChange(file);\n };\n\n const onPaste = usePaste(\n (images) => {\n // Clipboard images arrive named \"image.png\" at best and unnamed at worst,\n // and the name is what the inbox shows beside the thumbnail. A name that\n // says where it came from is more use than the browser's.\n const file = images[0];\n pick(new File([file], pastedName(file.type), { type: file.type }));\n },\n documentPaste,\n pasteFrom,\n );\n\n return (\n <div\n // `relative` for the same reason as FileDropzone: the `sr-only` file input below\n // is `position: absolute`, and without a positioned ancestor it is laid out\n // against the initial containing block — extending the DOCUMENT height to its own\n // offset and producing a phantom second scrollbar on any long page.\n className={cn(\"relative\", className)}\n onPaste={onPaste}\n >\n <Heading text={labelsProp?.attachment} />\n {value ? (\n <div className=\"flex items-start gap-2\">\n {value.type.startsWith(\"image/\") && preview ? (\n <img\n src={preview}\n alt={value.name}\n className=\"h-20 w-20 rounded border border-[var(--border)] object-cover\"\n />\n ) : (\n // Non-image attachments (PDF, text) can't preview as an <img>, so\n // show a neutral file tile with the name/size beside it instead.\n <div className=\"flex h-20 w-20 items-center justify-center rounded border border-[var(--border)] text-[var(--text-placeholder)]\">\n <FileText className=\"size-8\" />\n </div>\n )}\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-sm text-[var(--text-secondary)]\">{value.name}</div>\n <div className=\"text-xs text-[var(--text-muted)]\">\n {fileText.size(value.size)}\n </div>\n </div>\n <button\n type=\"button\"\n onClick={() => onChange(null)}\n aria-label={text.attachmentRemove}\n className=\"rounded p-1.5 text-[var(--text-placeholder)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n ) : (\n <div className=\"space-y-1.5\">\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"button\" variant=\"secondary\" onClick={() => fileInputRef.current?.click()}>\n <Paperclip className=\"size-4\" /> {text.attachmentAdd}\n </Button>\n {onCaptureScreenshot && (\n <CaptureButton capture={onCaptureScreenshot} onFile={pick} label={text.attachmentCapture} />\n )}\n </div>\n {/* Said out loud, because a gesture with no affordance is a gesture\n nobody finds. */}\n <p className=\"text-xs text-[var(--text-muted)]\">\n {text.attachmentPaste}\n </p>\n </div>\n )}\n <input\n ref={fileInputRef}\n type=\"file\"\n accept={accept.join(\",\")}\n className=\"sr-only\"\n onChange={(e) => {\n pick(e.target.files?.[0]);\n e.target.value = \"\";\n }}\n />\n </div>\n );\n}\n\nfunction MultipleField({\n value,\n onChange,\n max = DEFAULT_MAX_ATTACHMENTS,\n screenshot = null,\n onScreenshotChange,\n labels: labelsProp,\n accept = DEFAULT_ATTACHMENT_ACCEPT,\n maxBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onError,\n onCaptureScreenshot,\n documentPaste = false,\n pasteFrom,\n className,\n}: FeedbackAttachmentFieldMultipleProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const fileText = useKitFileLabels();\n const text = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n const removeLabel = text.attachmentRemoveFile ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentRemoveFile!;\n const limitLabel = text.attachmentLimit ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentLimit!;\n const screenshotLabel = text.attachmentScreenshot ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentScreenshot!;\n\n // What an add or a remove builds on: the `value` prop, plus whatever this field has\n // already handed to `onChange` since the parent last rendered. The field is\n // controlled, so between an `onChange` and the re-render that brings it back, `value`\n // is stale — and two adds in that gap (two pastes, a paste and a pick, delivered by\n // native listeners whose updates React batches) each spread the SAME old list, and\n // the second dropped the first. Re-synced to the prop after every commit, so a\n // parent that refuses a change (or edits the list itself) is what wins.\n const latest = useRef(value);\n useLayoutEffect(() => {\n latest.current = value;\n });\n const commit = (next: File[]) => {\n latest.current = next;\n onChange(next);\n };\n\n const hasSlot = onScreenshotChange !== undefined;\n const room = Math.max(0, max - value.length);\n // The screenshot slot is its own thing: it neither counts against `max` nor is\n // closed by it, so a full set of photos still leaves the capture on offer.\n const canCapture = !!onCaptureScreenshot && (hasSlot ? !screenshot : room > 0);\n\n const add = (incoming: File[], pasted = false) => {\n const current = latest.current;\n const accepted: File[] = [];\n const taken = new Set([...current, ...(screenshot ? [screenshot] : [])].map((f) => f.name));\n for (const raw of incoming) {\n const problem = rejection(raw, accept, maxBytes);\n if (problem) {\n onError?.(problem);\n continue;\n }\n // Two pastes are two files called \"pasted.png\", and a backend that stores by\n // name keeps one of them — the very loss this mode exists to end. A picked\n // file keeps its own name: it is the user's, and they may look for it.\n const file = pasted ? renamed(raw, uniqueName(pastedName(raw.type), taken)) : raw;\n taken.add(file.name);\n // The same File object twice is one file chosen twice, not two.\n if (!current.includes(file)) accepted.push(file);\n }\n if (accepted.length === 0) return;\n const space = Math.max(0, max - current.length);\n if (accepted.length > space) onError?.(\"count\");\n const kept = accepted.slice(0, space);\n if (kept.length > 0) commit([...current, ...kept]);\n };\n\n const onPaste = usePaste((images) => add(images, true), documentPaste, pasteFrom);\n\n const capture = (file: File) => {\n if (!hasSlot) {\n add([file]);\n return;\n }\n const problem = rejection(file, accept, maxBytes);\n if (problem) onError?.(problem);\n else onScreenshotChange(file);\n };\n\n // Removing a chip removes the button that had focus. Focus goes to the chip that\n // took its place — the next one — and, when it was the last, to the first action\n // button (there is room again, so \"Attach\" is back), else to the chip before it.\n // Applied once the parent has re-rendered with the shorter list: the field is\n // controlled, and focusing before that would land on the chip being removed.\n const pendingFocus = useRef<number | null>(null);\n useEffect(() => {\n const index = pendingFocus.current;\n if (index === null) return;\n pendingFocus.current = null;\n const root = rootRef.current;\n if (!root) return;\n const removes = root.querySelectorAll<HTMLElement>(\"[data-attachment-remove]\");\n const target =\n removes[index] ?? root.querySelector<HTMLElement>(\"[data-attachment-action]\") ?? removes[index - 1];\n target?.focus();\n }, [value, screenshot]);\n\n const chips: Array<{ file: File; screenshot: boolean; name: string; remove: () => void }> = [\n ...(hasSlot && screenshot\n ? [{ file: screenshot, screenshot: true, name: screenshotLabel, remove: () => onScreenshotChange(null) }]\n : []),\n ...value.map((file) => ({\n file,\n screenshot: false,\n name: file.name,\n remove: () => commit(latest.current.filter((f) => f !== file)),\n })),\n ];\n\n return (\n <div ref={rootRef} className={cn(\"relative space-y-2\", className)} onPaste={onPaste}>\n <Heading text={labelsProp?.attachment} className=\"mb-0\" />\n {chips.length > 0 && (\n // One chip per row, full width: wrapped chips of name-dependent widths made a\n // ragged block in a 430px dialog, and a column keeps every name and remove\n // button in the same place — the next chip's button is right under the last.\n <ul aria-label={text.attachmentList} className=\"flex flex-col gap-2\">\n {chips.map((chip, index) => (\n <li\n key={fileKey(chip.file)}\n className=\"flex min-w-0 items-center gap-2 rounded-md border border-[var(--border)] bg-[var(--bg-surface)] p-1\"\n >\n <ChipPreview file={chip.file} screenshot={chip.screenshot} />\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-sm text-[var(--text-secondary)]\">{chip.name}</div>\n <div className=\"truncate text-xs text-[var(--text-muted)]\">\n {/* The screenshot's file name moves down here: still there for the\n reporter who wants to know what will be sent, not its title. */}\n {chip.screenshot ? `${chip.file.name} · ${fileText.size(chip.file.size)}` : fileText.size(chip.file.size)}\n </div>\n </div>\n <button\n type=\"button\"\n data-attachment-remove=\"\"\n onClick={() => {\n pendingFocus.current = index;\n chip.remove();\n }}\n aria-label={removeLabel(chip.name)}\n className=\"shrink-0 rounded p-1.5 text-[var(--text-placeholder)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </button>\n </li>\n ))}\n </ul>\n )}\n {(room > 0 || canCapture) && (\n <div className=\"flex flex-wrap gap-2\">\n {room > 0 && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n data-attachment-action=\"\"\n onClick={() => fileInputRef.current?.click()}\n >\n <Paperclip className=\"size-4\" /> {text.attachmentAdd}\n </Button>\n )}\n {canCapture && onCaptureScreenshot && (\n <CaptureButton\n capture={onCaptureScreenshot}\n onFile={capture}\n label={text.attachmentCapture}\n data-attachment-action=\"\"\n />\n )}\n </div>\n )}\n <p className=\"text-xs text-[var(--text-muted)]\">\n {room > 0 ? text.attachmentPaste : limitLabel(max)}\n </p>\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple={room > 1}\n accept={accept.join(\",\")}\n className=\"sr-only\"\n // Out of the tab order and the accessibility tree: the button above is\n // the way in, and a second, unlabelled \"Choose files\" stop is noise.\n tabIndex={-1}\n aria-hidden\n onChange={(e) => {\n add(Array.from(e.target.files ?? []));\n e.target.value = \"\";\n }}\n />\n </div>\n );\n}\n\n/** A file `refs` mode is uploading: its own id (a ref has no key yet), and the file. */\ninterface Upload {\n id: number;\n file: File;\n}\n\nlet nextUploadId = 0;\n\nfunction RefsField({\n value,\n onChange,\n onUpload,\n onRemove,\n onUploadingChange,\n max = DEFAULT_MAX_ATTACHMENTS,\n labels: labelsProp,\n accept = DEFAULT_ATTACHMENT_ACCEPT,\n maxBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onError,\n onCaptureScreenshot,\n documentPaste = false,\n pasteFrom,\n className,\n}: FeedbackAttachmentFieldRefsProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const fileText = useKitFileLabels();\n const text = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n const removeLabel = text.attachmentRemoveFile ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentRemoveFile!;\n const limitLabel = text.attachmentLimit ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentLimit!;\n const uploadingLabel = text.attachmentUploading ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentUploading!;\n\n // As in `multiple` mode: `value` plus whatever has been handed to `onChange` since\n // the parent last rendered — two uploads landing in one tick must both survive.\n const latest = useRef(value);\n useLayoutEffect(() => {\n latest.current = value;\n });\n const commit = (next: FeedbackAttachmentRef[]) => {\n latest.current = next;\n onChange(next);\n };\n\n const [uploads, setUploads] = useState<Upload[]>([]);\n // The uploads in flight, kept in a ref as well: `add` runs several times before a\n // render when files arrive together, and each must see the others — their count\n // against `max`, their names against a pasted image's.\n const inFlight = useRef<Upload[]>([]);\n // Unmounted (the dialog closed mid-upload): a late answer is not this field's to\n // commit, and setting state on it would be a no-op at best.\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const uploadingChange = useRef(onUploadingChange);\n useEffect(() => {\n uploadingChange.current = onUploadingChange;\n });\n\n const room = Math.max(0, max - value.length - uploads.length);\n\n const start = (file: File) => {\n const upload: Upload = { id: nextUploadId++, file };\n inFlight.current = [...inFlight.current, upload];\n if (inFlight.current.length === 1) uploadingChange.current?.(true);\n setUploads(inFlight.current);\n const settle = () => {\n inFlight.current = inFlight.current.filter((u) => u.id !== upload.id);\n if (!mounted.current) return;\n setUploads(inFlight.current);\n if (inFlight.current.length === 0) uploadingChange.current?.(false);\n };\n let answer: Promise<FeedbackAttachmentRef>;\n try {\n answer = Promise.resolve(onUpload(file));\n } catch (error) {\n answer = Promise.reject(error);\n }\n answer.then(\n (ref) => {\n settle();\n if (mounted.current) commit([...latest.current, ref]);\n },\n (error: unknown) => {\n settle();\n if (mounted.current) onError?.(\"upload\", error);\n },\n );\n };\n\n const add = (incoming: File[], pasted = false) => {\n let space = Math.max(0, max - latest.current.length - inFlight.current.length);\n const taken = new Set([...latest.current.map((r) => r.name), ...inFlight.current.map((u) => u.file.name)]);\n let dropped = false;\n for (const raw of incoming) {\n const problem = rejection(raw, accept, maxBytes);\n if (problem) {\n onError?.(problem);\n continue;\n }\n if (space === 0) {\n dropped = true;\n continue;\n }\n // Pasted images are all \"image.png\" to the clipboard; as in `multiple` mode,\n // each gets a name of its own before it is uploaded under it.\n const file = pasted ? renamed(raw, uniqueName(pastedName(raw.type), taken)) : raw;\n taken.add(file.name);\n space -= 1;\n start(file);\n }\n if (dropped) onError?.(\"count\");\n };\n\n const onPaste = usePaste((images) => add(images, true), documentPaste, pasteFrom);\n\n // Focus after a remove, as in `multiple` mode: the next chip, else the first action.\n const pendingFocus = useRef<number | null>(null);\n useEffect(() => {\n const index = pendingFocus.current;\n if (index === null) return;\n pendingFocus.current = null;\n const root = rootRef.current;\n if (!root) return;\n const removes = root.querySelectorAll<HTMLElement>(\"[data-attachment-remove]\");\n const target =\n removes[index] ?? root.querySelector<HTMLElement>(\"[data-attachment-action]\") ?? removes[index - 1];\n target?.focus();\n }, [value]);\n\n const remove = (key: string, index: number) => {\n pendingFocus.current = index;\n commit(latest.current.filter((r) => r.key !== key));\n onRemove?.(key);\n };\n\n const hasChips = value.length > 0 || uploads.length > 0;\n\n return (\n <div ref={rootRef} className={cn(\"relative space-y-2\", className)} onPaste={onPaste}>\n <Heading text={labelsProp?.attachment} className=\"mb-0\" />\n {hasChips && (\n <ul aria-label={text.attachmentList} className=\"flex flex-col gap-2\">\n {value.map((ref, index) => (\n <li\n key={`ref:${ref.key}`}\n className=\"flex min-w-0 items-center gap-2 rounded-md border border-[var(--border)] bg-[var(--bg-surface)] p-1\"\n >\n <RefGlyph type={ref.type} />\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-sm text-[var(--text-secondary)]\">{ref.name}</div>\n {ref.size !== undefined && (\n <div className=\"truncate text-xs text-[var(--text-muted)]\">{fileText.size(ref.size)}</div>\n )}\n </div>\n <button\n type=\"button\"\n data-attachment-remove=\"\"\n onClick={() => remove(ref.key, index)}\n aria-label={removeLabel(ref.name)}\n className=\"shrink-0 rounded p-1.5 text-[var(--text-placeholder)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </button>\n </li>\n ))}\n {uploads.map((upload) => (\n <li\n key={`upload:${upload.id}`}\n aria-busy=\"true\"\n data-attachment-uploading=\"\"\n className=\"flex min-w-0 items-center gap-2 rounded-md border border-dashed border-[var(--border)] bg-[var(--bg-surface)] p-1\"\n >\n <span className=\"flex size-12 shrink-0 items-center justify-center rounded border border-[var(--border)] bg-[var(--bg-surface-2)] text-[var(--text-placeholder)]\">\n <Spinner label={null} className=\"size-5\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-sm text-[var(--text-secondary)]\">{upload.file.name}</div>\n <div className=\"truncate text-xs text-[var(--text-muted)]\">{uploadingLabel}</div>\n </div>\n </li>\n ))}\n </ul>\n )}\n {room > 0 && (\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n variant=\"secondary\"\n data-attachment-action=\"\"\n onClick={() => fileInputRef.current?.click()}\n >\n <Paperclip className=\"size-4\" /> {text.attachmentAdd}\n </Button>\n {onCaptureScreenshot && (\n <CaptureButton\n capture={onCaptureScreenshot}\n onFile={(file) => add([file])}\n label={text.attachmentCapture}\n data-attachment-action=\"\"\n />\n )}\n </div>\n )}\n <p className=\"text-xs text-[var(--text-muted)]\">{room > 0 ? text.attachmentPaste : limitLabel(max)}</p>\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple={room > 1}\n accept={accept.join(\",\")}\n className=\"sr-only\"\n tabIndex={-1}\n aria-hidden\n onChange={(e) => {\n add(Array.from(e.target.files ?? []));\n e.target.value = \"\";\n }}\n />\n </div>\n );\n}\n\n/** A ref chip's picture. The bytes are on the server, not here, so there is nothing to\n * preview: an image glyph for an image `type`, a file glyph for anything else. */\nfunction RefGlyph({ type }: { type?: string }) {\n return (\n <span className=\"flex size-12 shrink-0 items-center justify-center rounded border border-[var(--border)] bg-[var(--bg-surface-2)] text-[var(--text-placeholder)]\">\n {type?.startsWith(\"image/\") ? <ImageIcon aria-hidden className=\"size-6\" /> : <FileText aria-hidden className=\"size-6\" />}\n </span>\n );\n}\n\nfunction Heading({ text, className }: { text?: string; className?: string }) {\n if (!text) return null;\n return (\n <div className={cn(\"mb-1 text-xs font-medium uppercase tracking-wide text-[var(--text-muted)]\", className)}>\n {text}\n </div>\n );\n}\n\nfunction CaptureButton({\n capture,\n onFile,\n label,\n ...rest\n}: {\n capture: () => Promise<File | null>;\n onFile: (file: File) => void;\n label: string;\n \"data-attachment-action\"?: string;\n}) {\n const [capturing, setCapturing] = useState(false);\n return (\n <Button\n type=\"button\"\n variant=\"secondary\"\n disabled={capturing}\n {...rest}\n onClick={() => {\n if (capturing) return;\n setCapturing(true);\n void capture()\n .then((file) => {\n if (file) onFile(file);\n })\n .finally(() => setCapturing(false));\n }}\n >\n <Camera className=\"size-4\" /> {capturing ? \"…\" : label}\n </Button>\n );\n}\n\n/** A chip's picture: the image itself, or a file glyph for anything that is not one.\n * Decorative (`alt=\"\"`) — the name stands beside it. Its own component so the object\n * URL lives exactly as long as the chip: removing the chip unmounts it and revokes. */\nfunction ChipPreview({ file, screenshot }: { file: File; screenshot: boolean }) {\n const isImage = file.type.startsWith(\"image/\");\n const [previewFor, setPreviewFor] = useState<{ file: File; url: string } | null>(null);\n const url = previewFor?.file === file ? previewFor.url : null;\n useEffect(() => {\n if (!isImage) return;\n const next = URL.createObjectURL(file);\n // As in the single field: an external resource created and revoked with the effect.\n // eslint-disable-next-line react-hooks/set-state-in-effect -- publishing an external resource's handle\n setPreviewFor({ file, url: next });\n return () => URL.revokeObjectURL(next);\n }, [file, isImage]);\n\n return (\n <span className=\"relative flex size-12 shrink-0 items-center justify-center overflow-hidden rounded border border-[var(--border)] bg-[var(--bg-surface-2)] text-[var(--text-placeholder)]\">\n {isImage && url ? (\n <img src={url} alt=\"\" className=\"size-full object-cover\" />\n ) : (\n <FileText aria-hidden className=\"size-6\" />\n )}\n {screenshot && (\n // Marks the slot apart from the photos: it is why the capture button is gone.\n <span className=\"absolute bottom-0.5 end-0.5 rounded-sm bg-[var(--bg-surface)] p-0.5 text-[var(--text-secondary)]\">\n <Camera aria-hidden className=\"size-3\" />\n </span>\n )}\n </span>\n );\n}\n\n/** A stable React key per File object — the name is not one (two pastes, two\n * \"pasted.png\" before renaming; the same photo picked from two folders). */\nconst fileKeys = new WeakMap<File, number>();\nlet nextFileKey = 0;\nfunction fileKey(file: File): number {\n let key = fileKeys.get(file);\n if (key === undefined) {\n key = nextFileKey++;\n fileKeys.set(file, key);\n }\n return key;\n}\n\nfunction rejection(file: File, accept: string[], maxBytes: number): \"type\" | \"size\" | null {\n if (!accept.includes(file.type)) return \"type\";\n if (file.size > maxBytes) return \"size\";\n return null;\n}\n\nfunction renamed(file: File, name: string): File {\n return new File([file], name, { type: file.type });\n}\n\n/** `pasted.png`, then `pasted-2.png`, `pasted-3.png`… — the first name not in `taken`. */\nfunction uniqueName(name: string, taken: Set<string>): string {\n if (!taken.has(name)) return name;\n const dot = name.lastIndexOf(\".\");\n const [stem, ext] = dot > 0 ? [name.slice(0, dot), name.slice(dot)] : [name, \"\"];\n let n = 2;\n while (taken.has(`${stem}-${n}${ext}`)) n++;\n return `${stem}-${n}${ext}`;\n}\n\n/**\n * The paste listener both modes share. `onImages` gets every image file on the\n * clipboard (the single field takes the first). It is registered once rather than per\n * render, so it reads the handler — which closes over props that change identity on\n * every render — out of a ref rather than out of its own dependency list. Returns the\n * `onPaste` for the field's root, or `undefined` when listening elsewhere.\n */\nfunction usePaste(\n onImages: (images: File[]) => void,\n documentPaste: boolean,\n pasteFrom: RefObject<HTMLElement | null> | undefined,\n) {\n const latest = useRef(onImages);\n useEffect(() => {\n latest.current = onImages;\n });\n\n // The element listened on, where it is not this field's own subtree: the\n // document for a modal, the given parent for an inline editor. Read inside\n // the effect rather than in render, because a ref's `current` is only set\n // once the parent has mounted — which it has by the time effects run.\n useEffect(() => {\n const target: EventTarget | null = documentPaste ? document : (pasteFrom?.current ?? null);\n if (!target) return;\n const onPaste = (event: Event) => {\n const clipboard = (event as ClipboardEvent).clipboardData;\n takeImages(clipboard, () => event.preventDefault(), latest.current);\n };\n target.addEventListener(\"paste\", onPaste);\n return () => target.removeEventListener(\"paste\", onPaste);\n }, [documentPaste, pasteFrom]);\n\n const listensElsewhere = documentPaste || pasteFrom !== undefined;\n return listensElsewhere\n ? undefined\n : (event: ReactClipboardEvent) => takeImages(event.clipboardData, () => event.preventDefault(), latest.current);\n}\n\nfunction takeImages(clipboard: DataTransfer | null, stop: () => void, onImages: (images: File[]) => void) {\n const images = Array.from(clipboard?.items ?? [])\n .filter((item) => item.kind === \"file\" && item.type.startsWith(\"image/\"))\n .map((item) => item.getAsFile())\n .filter((file): file is File => file !== null);\n if (images.length === 0) return;\n // Only once there IS an image: a paste of text into a field must stay a\n // paste of text, and a clipboard holding both is a copy whose text half is\n // what the field was focused for.\n stop();\n onImages(images);\n}\n\n/** What a pasted image is called once it is an attachment.\n *\n * The extension is read off the mime type rather than assumed to be `.png`:\n * Safari puts TIFF on the clipboard and a file called `pasted.png` that is not\n * a PNG is one the receiving end opens wrong. */\nexport function pastedName(type: string): string {\n const subtype = type.split(\"/\")[1] ?? \"png\";\n // `image/svg+xml` and friends carry a suffix that is not part of the\n // extension, and none of them are in the accepted list anyway.\n return `pasted.${subtype.split(\"+\")[0]}`;\n}\n"],"mappings":";AAmOyB,cAoFf,YApFe;AAnOzB,SAAS,UAAU;AACnB,SAAS,WAAW,iBAAiB,QAAQ,gBAA4E;AACzH,SAAS,QAAQ,UAAU,SAAS,WAAW,WAAW,SAAS;AACnE,SAAS,QAAQ,eAAe;AAChC,SAAS,kBAAkB,oBAAoB;AAGxC,MAAM,4BAA4B,CA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'react';
2
- export { b as DEFAULT_FEEDBACK_DIALOG_LABELS, j as FeedbackAttachmentLabels, k as FeedbackCategoryOption, l as FeedbackDialog, m as FeedbackDialogLabels, n as FeedbackDialogMultipleProps, o as FeedbackDialogProps, p as FeedbackDialogSingleProps, q as FeedbackDialogTextLabels, r as FeedbackMultipleSubmission, s as FeedbackSubmission } from '../feedback-attachment-WFiXJ8We.js';
2
+ export { b as DEFAULT_FEEDBACK_DIALOG_LABELS, k as FeedbackAttachmentLabels, n as FeedbackCategoryOption, o as FeedbackDialog, p as FeedbackDialogLabels, q as FeedbackDialogMultipleProps, r as FeedbackDialogProps, s as FeedbackDialogSingleProps, t as FeedbackDialogTextLabels, u as FeedbackMultipleSubmission, v as FeedbackSubmission } from '../feedback-attachment-NhUm7Zga.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/feedback-dialog.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Button, Input, PHONE_QUERY, Select, Textarea } from \"../components/ui\";\nimport { Modal } from \"../components/modal\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport {\n DEFAULT_ATTACHMENT_ACCEPT,\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS,\n DEFAULT_MAX_ATTACHMENT_BYTES,\n FeedbackAttachmentField,\n type FeedbackAttachmentError,\n} from \"./feedback-attachment\";\n\nexport interface FeedbackCategoryOption {\n value: string;\n label: string;\n}\n\nexport interface FeedbackAttachmentLabels {\n /** The heading over the field. Optional: a note editor puts the buttons\n * straight under its textarea, where a second heading is noise. */\n attachment?: string;\n attachmentAdd: string;\n /** Label for the \"capture screenshot\" button. Optional — falls back to the provider's\n * `feedbackAttachment.attachmentCapture`, then English. */\n attachmentCapture?: string;\n /** The line under the attachment buttons saying a screenshot can be pasted\n * straight in. Optional — falls back to the provider's `feedbackAttachment`, then English. */\n attachmentPaste?: string;\n attachmentRemove: string;\n /** `multiple` mode (0.15.5): the chip list's accessible name — and, in\n * `<FeedbackDialog attachments=\"multiple\">`, the heading over it (0.16.0). Optional,\n * as are the keys below — they fall back to the provider's `feedbackAttachment`,\n * then English. */\n attachmentList?: string;\n /** `multiple` mode (0.16.0): the screenshot slot's chip title, in place of its file name. */\n attachmentScreenshot?: string;\n /** `multiple` mode: one chip's remove button, given the file's name. */\n attachmentRemoveFile?: (name: string) => string;\n /** `multiple` mode: the line shown once `max` files are attached. */\n attachmentLimit?: (max: number) => string;\n}\n\nexport interface FeedbackDialogLabels extends FeedbackAttachmentLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n attachment: string;\n submitHint: string;\n cancel: string;\n save: string;\n /** @deprecated since 0.16.0 — use `attachmentList`, the one key for the heading and\n * the chip list it names. Still honoured: set, it wins over the provider's\n * `attachmentList` (but not over an `attachmentList` passed beside it). */\n attachments?: string;\n}\n\n/**\n * The dialog's own strings — the `feedbackDialog` namespace of `<UiKitProvider\n * labels>` (0.12.0). The attachment keys are not repeated here: they are the\n * `feedbackAttachment` namespace's, which the field inside already reads.\n *\n * Before, every key was required at the call site, so each app restated ten strings\n * wherever it mounted the dialog (kastlan feedback-button.tsx built the object inline).\n */\nexport interface FeedbackDialogTextLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n /** The body's label when `requireBody={false}`: \"What happened? (optional)\".\n * Optional, so a complete `UiKitLabels` typed before 0.14.2 still compiles. */\n bodyOptional?: string;\n /** The heading over the attachment buttons. */\n attachment: string;\n /** The line beside the buttons naming the shortcut. */\n submitHint: string;\n cancel: string;\n save: string;\n /** @deprecated since 0.16.0 — use `feedbackAttachment.attachmentList`. It and this\n * key were two names for one heading (\"Attachments\" over the chips that list names\n * \"Attachments\"), and a catalogue that translated one left the other English. Still\n * honoured when set: it wins over `feedbackAttachment.attachmentList`. */\n attachments?: string;\n}\n\nexport const DEFAULT_FEEDBACK_DIALOG_LABELS: FeedbackDialogTextLabels = {\n title: \"Send feedback\",\n category: \"Category\",\n subject: \"Subject\",\n body: \"What happened?\",\n bodyOptional: \"What happened? (optional)\",\n attachment: \"Screenshot\",\n // No `attachments`: the multiple-mode heading is `feedbackAttachment.attachmentList`,\n // and a default here would shadow a provider that translated only that one.\n submitHint: \"Ctrl/⌘ + Enter to send\",\n cancel: \"Cancel\",\n save: \"Send\",\n};\n\nexport interface FeedbackSubmission {\n title: string;\n body: string;\n category: string;\n attachment: File | null;\n}\n\n/**\n * What `onSubmit` gets under `attachments=\"multiple\"` (0.15.5): the screenshot and\n * the picked/pasted files apart, because an app files them differently — keksdose\n * attaches the screenshot to the report and the photos as its evidence list. No\n * `attachment`: there is no one file it could name.\n */\nexport interface FeedbackMultipleSubmission {\n title: string;\n body: string;\n category: string;\n /** What `onCaptureScreenshot` returned, or `null` — at most one. */\n screenshot: File | null;\n /** Picked and pasted files, in the order they were added; at most `maxAttachments`. */\n attachments: File[];\n}\n\ninterface FeedbackDialogBaseProps {\n open: boolean;\n onClose: () => void;\n categories: FeedbackCategoryOption[];\n category: string;\n onCategoryChange: (value: string) => void;\n /** Prop > `<UiKitProvider labels={{ feedbackDialog, feedbackAttachment }}>` >\n * English. Optional since 0.12.0; a whole `FeedbackDialogLabels` still fits. */\n labels?: Partial<FeedbackDialogLabels>;\n submitting?: boolean;\n contextSlot?: ReactNode;\n attachmentAccept?: string[];\n maxAttachmentBytes?: number;\n /**\n * Optional: capture a screenshot of the underlying app view and return it as a\n * File. When provided, a \"Capture screenshot\" button is shown next to \"Add\n * attachment\"; the returned file is fed through the same validation + preview.\n */\n onCaptureScreenshot?: () => Promise<File | null>;\n /**\n * `false`: a report with only a subject can be sent, and the body's label says it is\n * optional (`bodyOptional`, unless `labels.body` is passed). Default `true`, the\n * dialog's behaviour until 0.14.2 (keksdose K1: its backend takes title-only reports).\n */\n requireBody?: boolean;\n}\n\n/** One attachment — a screenshot, a picked or a pasted image; a second replaces\n * nothing, it has to wait for the first to be removed. The default. */\nexport interface FeedbackDialogSingleProps extends FeedbackDialogBaseProps {\n attachments?: \"single\";\n onSubmit: (data: FeedbackSubmission) => void | Promise<void>;\n onAttachmentError?: (kind: \"type\" | \"size\") => void;\n /** Multiple mode only — refused here rather than silently ignored. */\n maxAttachments?: never;\n}\n\n/**\n * One screenshot plus up to `maxAttachments` picked or pasted files (0.15.5, keksdose\n * dev#578: \"pasted two photos, the second overwrote the first\"). The capture button is\n * offered while there is no screenshot yet; the add button while there is room.\n */\nexport interface FeedbackDialogMultipleProps extends FeedbackDialogBaseProps {\n attachments: \"multiple\";\n /** Default `DEFAULT_MAX_ATTACHMENTS` (5). The screenshot does not count. */\n maxAttachments?: number;\n onSubmit: (data: FeedbackMultipleSubmission) => void | Promise<void>;\n /** `\"count\"`: more files arrived at once than there was room for; the surplus was dropped. */\n onAttachmentError?: (kind: FeedbackAttachmentError) => void;\n}\n\nexport type FeedbackDialogProps = FeedbackDialogSingleProps | FeedbackDialogMultipleProps;\n\n/**\n * The generic feedback form dialog: category + subject + body + an optional image\n * attachment, with Ctrl/Cmd+Enter to submit. Domain-free — the app supplies the\n * category options, labels and an `onSubmit` that talks to its own backend, plus\n * an optional `contextSlot` for app-specific context (user, current URL, …).\n *\n * **A screenshot can be pasted straight in.** Ctrl/Cmd+V anywhere in the dialog\n * takes an image off the clipboard and makes it the attachment, through the same\n * validation and the same preview as the file picker. It is the gesture the two\n * ways in did not cover: `onCaptureScreenshot` snapshots the *whole* app view,\n * and the file picker needs a file — so somebody who wanted to show one panel,\n * or one region of one, had to save a crop to disk first and then find it again\n * (Steering Design feedback #39). The clipboard is where a region snip already\n * is on every platform.\n *\n * **`attachments=\"multiple\"`** (0.15.5) takes several: every paste and pick adds a\n * chip, and `onSubmit` gets `{ screenshot, attachments }` ({@link\n * FeedbackMultipleSubmission}) instead of `attachment`. Opt-in, so a caller typed\n * against the one-file submission keeps compiling and behaving as before.\n */\nexport function FeedbackDialog(props: FeedbackDialogProps) {\n const {\n open,\n onClose,\n categories,\n category,\n onCategoryChange,\n labels: labelsProp,\n submitting = false,\n contextSlot,\n attachmentAccept = DEFAULT_ATTACHMENT_ACCEPT,\n maxAttachmentBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onCaptureScreenshot,\n requireBody = true,\n } = props;\n const [title, setTitle] = useState(\"\");\n const [body, setBody] = useState(\"\");\n const [attachment, setAttachment] = useState<File | null>(null);\n // `attachments=\"multiple\"` only: the capture, apart from the picked/pasted files.\n const [screenshot, setScreenshot] = useState<File | null>(null);\n const [files, setFiles] = useState<File[]>([]);\n const isMobile = useMediaQuery(PHONE_QUERY, false);\n const labels = useKitLabels(\"feedbackDialog\", DEFAULT_FEEDBACK_DIALOG_LABELS, labelsProp);\n const attachmentText = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n // Under `multiple` the heading is `attachmentList` — a screenshot AND photos — which\n // also names the chip list beneath it: one string, so the two cannot disagree. The\n // deprecated `feedbackDialog.attachments` (prop or provider) still wins over the\n // provider's `attachmentList`, as it did before 0.16.0; an `attachmentList` prop wins\n // over both.\n const listHeading =\n labelsProp?.attachmentList ??\n labels.attachments ??\n attachmentText.attachmentList ??\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentList!;\n // The attachment field resolves its own keys from `feedbackAttachment`; it gets the\n // prop's (so a caller's `attachmentAdd` still wins) plus the resolved heading.\n const attachmentLabels =\n props.attachments === \"multiple\"\n ? { ...labelsProp, attachment: listHeading, attachmentList: listHeading }\n : { ...labelsProp, attachment: labels.attachment };\n\n // Reset the form whenever the dialog is (re)opened — during render, on the\n // closed-to-open transition, so the old draft never paints for a frame.\n const [wasOpen, setWasOpen] = useState(open);\n if (open !== wasOpen) {\n setWasOpen(open);\n if (open) {\n setTitle(\"\");\n setBody(\"\");\n setAttachment(null);\n setScreenshot(null);\n setFiles([]);\n }\n }\n\n // Trimmed: a subject or body of spaces is empty (keksdose's API answers a blank title\n // with a 422, and a blank report is no report).\n const canSubmit = !!title.trim() && (!requireBody || !!body.trim()) && !submitting;\n const trySubmit = () => {\n if (!canSubmit) return;\n if (props.attachments === \"multiple\") {\n void props.onSubmit({ title, body, category, screenshot, attachments: files });\n } else {\n void props.onSubmit({ title, body, category, attachment });\n }\n };\n\n if (!open) return null;\n\n const categoryField = (\n <Select label={labels.category} value={category} onChange={(e) => onCategoryChange(e.target.value)}>\n {categories.map((c) => (\n <option key={c.value} value={c.value}>\n {c.label}\n </option>\n ))}\n </Select>\n );\n // On a phone the subject leads as a heading rather than as the second of two\n // identical boxes under a select (Keksdose feedback #179). `variant=\"display\"`\n // is a no-op above the phone breakpoint, so the desktop dialog is unchanged.\n const subjectField = (\n <Input label={labels.subject} value={title} onChange={(e) => setTitle(e.target.value)} variant=\"display\" />\n );\n const bodyField = (\n <Textarea\n rows={5}\n label={requireBody ? labels.body : (labelsProp?.body ?? labels.bodyOptional ?? labels.body)}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n />\n );\n const fieldProps = {\n labels: attachmentLabels,\n accept: attachmentAccept,\n maxBytes: maxAttachmentBytes,\n onCaptureScreenshot,\n // On `document`, not on the panel: the Modal focuses its own panel on open\n // and traps Tab inside it, so while this dialog is up every paste in the\n // page is meant for it — including the one made with nothing in\n // particular focused, which never reaches a React `onPaste` on a child.\n documentPaste: open,\n };\n const attachmentField =\n props.attachments === \"multiple\" ? (\n <FeedbackAttachmentField\n {...fieldProps}\n multiple\n value={files}\n onChange={setFiles}\n max={props.maxAttachments}\n // The capture goes to its own slot, so it is offered once and never crowds\n // out a photo; a paste is a photo (a region snip is chosen evidence, not \"the\n // screenshot\").\n screenshot={screenshot}\n onScreenshotChange={setScreenshot}\n onError={props.onAttachmentError}\n />\n ) : (\n <FeedbackAttachmentField\n {...fieldProps}\n value={attachment}\n onChange={setAttachment}\n onError={props.onAttachmentError}\n />\n );\n\n return (\n <Modal\n onClose={onClose}\n // The one dialog whose subject is the page behind it (Keksdose dev#460: \"Make\n // the feedback dialog draggable so I can see behind it if it blocks\n // something\") — you are describing what is under it while you type.\n draggable\n onKeyDown={(e) => {\n if ((e.ctrlKey || e.metaKey) && e.key === \"Enter\") {\n e.preventDefault();\n trySubmit();\n }\n }}\n >\n {/* Also the drag handle: pressing anywhere on the panel's own chrome moves it,\n and the heading is the strip a user reaches for. */}\n <h2 className=\"mb-3 text-lg font-semibold\">{labels.title}</h2>\n <div className=\"space-y-3\">\n {isMobile ? (\n // Phone shape, the same reasoning as the transaction editor's (#177):\n // the desktop order is the DATA MODEL's order — category, then subject,\n // then body — but nobody opens this dialog to pick a category. What they\n // came to do is say the thing, so that leads; the classification and the\n // evidence follow, a tier down.\n <>\n {subjectField}\n {bodyField}\n <div className=\"space-y-3 border-t border-[var(--border)] pt-3\">\n {categoryField}\n {attachmentField}\n {contextSlot}\n </div>\n </>\n ) : (\n <>\n {categoryField}\n {subjectField}\n {bodyField}\n {attachmentField}\n {contextSlot}\n </>\n )}\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"text-xs text-[var(--text-placeholder)]\">{labels.submitHint}</div>\n <div className=\"flex gap-2\">\n <Button variant=\"ghost\" onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button onClick={trySubmit} disabled={!canSubmit}>\n {labels.save}\n </Button>\n </div>\n </div>\n </div>\n </Modal>\n );\n}\n"],"mappings":";AA8QQ,SA+EE,UA/EF,KAkFI,YAlFJ;AA9QR,SAAS,gBAAgB;AAEzB,SAAS,QAAQ,OAAO,aAAa,QAAQ,gBAAgB;AAC7D,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA4EA,MAAM,iCAA2D;AAAA,EACtE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,cAAc;AAAA,EACd,YAAY;AAAA;AAAA;AAAA,EAGZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAM;AACR;AAkGO,SAAS,eAA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MAIA,WAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAChB,aAAK,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,SAAS;AACjD,YAAE,eAAe;AACjB,oBAAU;AAAA,QACZ;AAAA,MACF;AAAA,MAIA;AAAA,4BAAC,QAAG,WAAU,8BAA8B,iBAAO,OAAM;AAAA,QACzD,qBAAC,SAAI,WAAU,aACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAMC,iCACG;AAAA;AAAA,cACA;AAAA,cACD,qBAAC,SAAI,WAAU,kDACZ;AAAA;AAAA,gBACA;AAAA,gBACA;AAAA,iBACH;AAAA,eACF;AAAA,cAEA,iCACG;AAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,aACH;AAAA,UAEF,qBAAC,SAAI,WAAU,2CACb;AAAA,gCAAC,SAAI,WAAU,0CAA0C,iBAAO,YAAW;AAAA,YAC3E,qBAAC,SAAI,WAAU,cACb;AAAA,kCAAC,UAAO,SAAQ,SAAQ,SAAS,SAC9B,iBAAO,QACV;AAAA,cACA,oBAAC,UAAO,SAAS,WAAW,UAAU,CAAC,WACpC,iBAAO,MACV;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/feedback-dialog.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Button, Input, PHONE_QUERY, Select, Textarea } from \"../components/ui\";\nimport { Modal } from \"../components/modal\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport {\n DEFAULT_ATTACHMENT_ACCEPT,\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS,\n DEFAULT_MAX_ATTACHMENT_BYTES,\n FeedbackAttachmentField,\n type FeedbackAttachmentError,\n} from \"./feedback-attachment\";\n\nexport interface FeedbackCategoryOption {\n value: string;\n label: string;\n}\n\nexport interface FeedbackAttachmentLabels {\n /** The heading over the field. Optional: a note editor puts the buttons\n * straight under its textarea, where a second heading is noise. */\n attachment?: string;\n attachmentAdd: string;\n /** Label for the \"capture screenshot\" button. Optional — falls back to the provider's\n * `feedbackAttachment.attachmentCapture`, then English. */\n attachmentCapture?: string;\n /** The line under the attachment buttons saying a screenshot can be pasted\n * straight in. Optional — falls back to the provider's `feedbackAttachment`, then English. */\n attachmentPaste?: string;\n attachmentRemove: string;\n /** `multiple` mode (0.15.5): the chip list's accessible name — and, in\n * `<FeedbackDialog attachments=\"multiple\">`, the heading over it (0.16.0). Optional,\n * as are the keys below — they fall back to the provider's `feedbackAttachment`,\n * then English. */\n attachmentList?: string;\n /** `multiple` mode (0.16.0): the screenshot slot's chip title, in place of its file name. */\n attachmentScreenshot?: string;\n /** `multiple` mode: one chip's remove button, given the file's name. */\n attachmentRemoveFile?: (name: string) => string;\n /** `multiple` mode: the line shown once `max` files are attached. */\n attachmentLimit?: (max: number) => string;\n /** `refs` mode (0.22.0): the second line of a chip whose upload is still running. */\n attachmentUploading?: string;\n}\n\nexport interface FeedbackDialogLabels extends FeedbackAttachmentLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n attachment: string;\n submitHint: string;\n cancel: string;\n save: string;\n /** @deprecated since 0.16.0 — use `attachmentList`, the one key for the heading and\n * the chip list it names. Still honoured: set, it wins over the provider's\n * `attachmentList` (but not over an `attachmentList` passed beside it). */\n attachments?: string;\n}\n\n/**\n * The dialog's own strings — the `feedbackDialog` namespace of `<UiKitProvider\n * labels>` (0.12.0). The attachment keys are not repeated here: they are the\n * `feedbackAttachment` namespace's, which the field inside already reads.\n *\n * Before, every key was required at the call site, so each app restated ten strings\n * wherever it mounted the dialog (kastlan feedback-button.tsx built the object inline).\n */\nexport interface FeedbackDialogTextLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n /** The body's label when `requireBody={false}`: \"What happened? (optional)\".\n * Optional, so a complete `UiKitLabels` typed before 0.14.2 still compiles. */\n bodyOptional?: string;\n /** The heading over the attachment buttons. */\n attachment: string;\n /** The line beside the buttons naming the shortcut. */\n submitHint: string;\n cancel: string;\n save: string;\n /** @deprecated since 0.16.0 — use `feedbackAttachment.attachmentList`. It and this\n * key were two names for one heading (\"Attachments\" over the chips that list names\n * \"Attachments\"), and a catalogue that translated one left the other English. Still\n * honoured when set: it wins over `feedbackAttachment.attachmentList`. */\n attachments?: string;\n}\n\nexport const DEFAULT_FEEDBACK_DIALOG_LABELS: FeedbackDialogTextLabels = {\n title: \"Send feedback\",\n category: \"Category\",\n subject: \"Subject\",\n body: \"What happened?\",\n bodyOptional: \"What happened? (optional)\",\n attachment: \"Screenshot\",\n // No `attachments`: the multiple-mode heading is `feedbackAttachment.attachmentList`,\n // and a default here would shadow a provider that translated only that one.\n submitHint: \"Ctrl/⌘ + Enter to send\",\n cancel: \"Cancel\",\n save: \"Send\",\n};\n\nexport interface FeedbackSubmission {\n title: string;\n body: string;\n category: string;\n attachment: File | null;\n}\n\n/**\n * What `onSubmit` gets under `attachments=\"multiple\"` (0.15.5): the screenshot and\n * the picked/pasted files apart, because an app files them differently — keksdose\n * attaches the screenshot to the report and the photos as its evidence list. No\n * `attachment`: there is no one file it could name.\n */\nexport interface FeedbackMultipleSubmission {\n title: string;\n body: string;\n category: string;\n /** What `onCaptureScreenshot` returned, or `null` — at most one. */\n screenshot: File | null;\n /** Picked and pasted files, in the order they were added; at most `maxAttachments`. */\n attachments: File[];\n}\n\ninterface FeedbackDialogBaseProps {\n open: boolean;\n onClose: () => void;\n categories: FeedbackCategoryOption[];\n category: string;\n onCategoryChange: (value: string) => void;\n /** Prop > `<UiKitProvider labels={{ feedbackDialog, feedbackAttachment }}>` >\n * English. Optional since 0.12.0; a whole `FeedbackDialogLabels` still fits. */\n labels?: Partial<FeedbackDialogLabels>;\n submitting?: boolean;\n contextSlot?: ReactNode;\n attachmentAccept?: string[];\n maxAttachmentBytes?: number;\n /**\n * Optional: capture a screenshot of the underlying app view and return it as a\n * File. When provided, a \"Capture screenshot\" button is shown next to \"Add\n * attachment\"; the returned file is fed through the same validation + preview.\n */\n onCaptureScreenshot?: () => Promise<File | null>;\n /**\n * `false`: a report with only a subject can be sent, and the body's label says it is\n * optional (`bodyOptional`, unless `labels.body` is passed). Default `true`, the\n * dialog's behaviour until 0.14.2 (keksdose K1: its backend takes title-only reports).\n */\n requireBody?: boolean;\n}\n\n/** One attachment — a screenshot, a picked or a pasted image; a second replaces\n * nothing, it has to wait for the first to be removed. The default. */\nexport interface FeedbackDialogSingleProps extends FeedbackDialogBaseProps {\n attachments?: \"single\";\n onSubmit: (data: FeedbackSubmission) => void | Promise<void>;\n onAttachmentError?: (kind: \"type\" | \"size\") => void;\n /** Multiple mode only — refused here rather than silently ignored. */\n maxAttachments?: never;\n}\n\n/**\n * One screenshot plus up to `maxAttachments` picked or pasted files (0.15.5, keksdose\n * dev#578: \"pasted two photos, the second overwrote the first\"). The capture button is\n * offered while there is no screenshot yet; the add button while there is room.\n */\nexport interface FeedbackDialogMultipleProps extends FeedbackDialogBaseProps {\n attachments: \"multiple\";\n /** Default `DEFAULT_MAX_ATTACHMENTS` (5). The screenshot does not count. */\n maxAttachments?: number;\n onSubmit: (data: FeedbackMultipleSubmission) => void | Promise<void>;\n /** `\"count\"`: more files arrived at once than there was room for; the surplus was dropped. */\n onAttachmentError?: (kind: FeedbackAttachmentError) => void;\n}\n\nexport type FeedbackDialogProps = FeedbackDialogSingleProps | FeedbackDialogMultipleProps;\n\n/**\n * The generic feedback form dialog: category + subject + body + an optional image\n * attachment, with Ctrl/Cmd+Enter to submit. Domain-free — the app supplies the\n * category options, labels and an `onSubmit` that talks to its own backend, plus\n * an optional `contextSlot` for app-specific context (user, current URL, …).\n *\n * **A screenshot can be pasted straight in.** Ctrl/Cmd+V anywhere in the dialog\n * takes an image off the clipboard and makes it the attachment, through the same\n * validation and the same preview as the file picker. It is the gesture the two\n * ways in did not cover: `onCaptureScreenshot` snapshots the *whole* app view,\n * and the file picker needs a file — so somebody who wanted to show one panel,\n * or one region of one, had to save a crop to disk first and then find it again\n * (Steering Design feedback #39). The clipboard is where a region snip already\n * is on every platform.\n *\n * **`attachments=\"multiple\"`** (0.15.5) takes several: every paste and pick adds a\n * chip, and `onSubmit` gets `{ screenshot, attachments }` ({@link\n * FeedbackMultipleSubmission}) instead of `attachment`. Opt-in, so a caller typed\n * against the one-file submission keeps compiling and behaving as before.\n */\nexport function FeedbackDialog(props: FeedbackDialogProps) {\n const {\n open,\n onClose,\n categories,\n category,\n onCategoryChange,\n labels: labelsProp,\n submitting = false,\n contextSlot,\n attachmentAccept = DEFAULT_ATTACHMENT_ACCEPT,\n maxAttachmentBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onCaptureScreenshot,\n requireBody = true,\n } = props;\n const [title, setTitle] = useState(\"\");\n const [body, setBody] = useState(\"\");\n const [attachment, setAttachment] = useState<File | null>(null);\n // `attachments=\"multiple\"` only: the capture, apart from the picked/pasted files.\n const [screenshot, setScreenshot] = useState<File | null>(null);\n const [files, setFiles] = useState<File[]>([]);\n const isMobile = useMediaQuery(PHONE_QUERY, false);\n const labels = useKitLabels(\"feedbackDialog\", DEFAULT_FEEDBACK_DIALOG_LABELS, labelsProp);\n const attachmentText = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n // Under `multiple` the heading is `attachmentList` — a screenshot AND photos — which\n // also names the chip list beneath it: one string, so the two cannot disagree. The\n // deprecated `feedbackDialog.attachments` (prop or provider) still wins over the\n // provider's `attachmentList`, as it did before 0.16.0; an `attachmentList` prop wins\n // over both.\n const listHeading =\n labelsProp?.attachmentList ??\n labels.attachments ??\n attachmentText.attachmentList ??\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentList!;\n // The attachment field resolves its own keys from `feedbackAttachment`; it gets the\n // prop's (so a caller's `attachmentAdd` still wins) plus the resolved heading.\n const attachmentLabels =\n props.attachments === \"multiple\"\n ? { ...labelsProp, attachment: listHeading, attachmentList: listHeading }\n : { ...labelsProp, attachment: labels.attachment };\n\n // Reset the form whenever the dialog is (re)opened — during render, on the\n // closed-to-open transition, so the old draft never paints for a frame.\n const [wasOpen, setWasOpen] = useState(open);\n if (open !== wasOpen) {\n setWasOpen(open);\n if (open) {\n setTitle(\"\");\n setBody(\"\");\n setAttachment(null);\n setScreenshot(null);\n setFiles([]);\n }\n }\n\n // Trimmed: a subject or body of spaces is empty (keksdose's API answers a blank title\n // with a 422, and a blank report is no report).\n const canSubmit = !!title.trim() && (!requireBody || !!body.trim()) && !submitting;\n const trySubmit = () => {\n if (!canSubmit) return;\n if (props.attachments === \"multiple\") {\n void props.onSubmit({ title, body, category, screenshot, attachments: files });\n } else {\n void props.onSubmit({ title, body, category, attachment });\n }\n };\n\n if (!open) return null;\n\n const categoryField = (\n <Select label={labels.category} value={category} onChange={(e) => onCategoryChange(e.target.value)}>\n {categories.map((c) => (\n <option key={c.value} value={c.value}>\n {c.label}\n </option>\n ))}\n </Select>\n );\n // On a phone the subject leads as a heading rather than as the second of two\n // identical boxes under a select (Keksdose feedback #179). `variant=\"display\"`\n // is a no-op above the phone breakpoint, so the desktop dialog is unchanged.\n const subjectField = (\n <Input label={labels.subject} value={title} onChange={(e) => setTitle(e.target.value)} variant=\"display\" />\n );\n const bodyField = (\n <Textarea\n rows={5}\n label={requireBody ? labels.body : (labelsProp?.body ?? labels.bodyOptional ?? labels.body)}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n />\n );\n const fieldProps = {\n labels: attachmentLabels,\n accept: attachmentAccept,\n maxBytes: maxAttachmentBytes,\n onCaptureScreenshot,\n // On `document`, not on the panel: the Modal focuses its own panel on open\n // and traps Tab inside it, so while this dialog is up every paste in the\n // page is meant for it — including the one made with nothing in\n // particular focused, which never reaches a React `onPaste` on a child.\n documentPaste: open,\n };\n const attachmentField =\n props.attachments === \"multiple\" ? (\n <FeedbackAttachmentField\n {...fieldProps}\n multiple\n value={files}\n onChange={setFiles}\n max={props.maxAttachments}\n // The capture goes to its own slot, so it is offered once and never crowds\n // out a photo; a paste is a photo (a region snip is chosen evidence, not \"the\n // screenshot\").\n screenshot={screenshot}\n onScreenshotChange={setScreenshot}\n onError={props.onAttachmentError}\n />\n ) : (\n <FeedbackAttachmentField\n {...fieldProps}\n value={attachment}\n onChange={setAttachment}\n onError={props.onAttachmentError}\n />\n );\n\n return (\n <Modal\n onClose={onClose}\n // The one dialog whose subject is the page behind it (Keksdose dev#460: \"Make\n // the feedback dialog draggable so I can see behind it if it blocks\n // something\") — you are describing what is under it while you type.\n draggable\n onKeyDown={(e) => {\n if ((e.ctrlKey || e.metaKey) && e.key === \"Enter\") {\n e.preventDefault();\n trySubmit();\n }\n }}\n >\n {/* Also the drag handle: pressing anywhere on the panel's own chrome moves it,\n and the heading is the strip a user reaches for. */}\n <h2 className=\"mb-3 text-lg font-semibold\">{labels.title}</h2>\n <div className=\"space-y-3\">\n {isMobile ? (\n // Phone shape, the same reasoning as the transaction editor's (#177):\n // the desktop order is the DATA MODEL's order — category, then subject,\n // then body — but nobody opens this dialog to pick a category. What they\n // came to do is say the thing, so that leads; the classification and the\n // evidence follow, a tier down.\n <>\n {subjectField}\n {bodyField}\n <div className=\"space-y-3 border-t border-[var(--border)] pt-3\">\n {categoryField}\n {attachmentField}\n {contextSlot}\n </div>\n </>\n ) : (\n <>\n {categoryField}\n {subjectField}\n {bodyField}\n {attachmentField}\n {contextSlot}\n </>\n )}\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"text-xs text-[var(--text-placeholder)]\">{labels.submitHint}</div>\n <div className=\"flex gap-2\">\n <Button variant=\"ghost\" onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button onClick={trySubmit} disabled={!canSubmit}>\n {labels.save}\n </Button>\n </div>\n </div>\n </div>\n </Modal>\n );\n}\n"],"mappings":";AAgRQ,SA+EE,UA/EF,KAkFI,YAlFJ;AAhRR,SAAS,gBAAgB;AAEzB,SAAS,QAAQ,OAAO,aA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Icon } from 'lucide-react';
4
- import { j as FeedbackAttachmentLabels } from '../feedback-attachment-WFiXJ8We.js';
4
+ import { k as FeedbackAttachmentLabels } from '../feedback-attachment-NhUm7Zga.js';
5
5
 
6
6
  /**
7
7
  * The feedback **inbox**, as the parts two apps were each writing separately.
@@ -1,4 +1,4 @@
1
- import { j as FeedbackAttachmentLabels } from '../feedback-attachment-WFiXJ8We.js';
1
+ import { k as FeedbackAttachmentLabels } from '../feedback-attachment-NhUm7Zga.js';
2
2
  import { FeedbackNoteAttachment } from './feedback-inbox.js';
3
3
  import * as react from 'react';
4
4
  import { ReactNode, Ref } from 'react';
@@ -222,6 +222,23 @@ interface FeedbackComposerProps {
222
222
  ref?: Ref<FeedbackComposerHandle>;
223
223
  labels?: Partial<FeedbackComposerLabels>;
224
224
  className?: string;
225
+ /**
226
+ * `"sm"` for a narrow host — keksdose's assistant launcher, a small floating panel
227
+ * (0.22): a small Send button, and the send hint ("Enter to send, Shift + Enter for a
228
+ * new line") hidden from view but kept as the box's description, so a keyboard or
229
+ * screen-reader user still learns the shortcut. Default `"md"`.
230
+ */
231
+ size?: "md" | "sm";
232
+ /**
233
+ * On the composer's root — the box, or the `disabledReason` line in its place —
234
+ * with any `data-*` attribute beside it (keksdose K17). keksdose's assistant tour
235
+ * points at the chat box with `[data-tour="assistant-ask"]`, and a composer that
236
+ * dropped every attribute it was not told about left the anchor nowhere: the
237
+ * assistant kept its hand-built box rather than lose the tour step.
238
+ */
239
+ id?: string;
240
+ /** `data-*` attributes for the root, as `id` — a tour anchor, a test id. */
241
+ [dataAttribute: `data-${string}`]: string | number | boolean | undefined;
225
242
  }
226
243
  /**
227
244
  * What a {@link FeedbackComposer} `ref` holds.
@@ -249,6 +266,23 @@ interface FeedbackComposerHandle {
249
266
  * use, so the habit carries across the feature. Plain Enter is a new line: feedback is
250
267
  * written in paragraphs, unlike a chat — which `sendOn="enter"` is for (keksdose G5).
251
268
  */
252
- declare function FeedbackComposer({ onSend, pending, attachment, attachmentSlot, canSend: canSendProp, sendOn, disabledReason, rows, placeholder, value, onValueChange, ref, labels: labelsProp, className, }: FeedbackComposerProps): react.JSX.Element;
269
+ declare function FeedbackComposer({ onSend, pending, attachment, attachmentSlot, canSend: canSendProp, sendOn, disabledReason, rows, placeholder, value, onValueChange, ref, labels: labelsProp, className, id, size, ...rest }: FeedbackComposerProps): react.JSX.Element;
270
+ /**
271
+ * {@link FeedbackComposer} under a name that is not about feedback (keksdose K17).
272
+ *
273
+ * The component was never feedback-specific: a textarea, an optional picture or a
274
+ * host's upload slot, Send, `sendOn="enter"` for the chat way. keksdose's assistant
275
+ * and support chat are chats, not reports, and an import of `FeedbackComposer` there
276
+ * reads as a mistake to the next person. The same function, not a wrapper, so the
277
+ * two names cannot drift.
278
+ */
279
+ declare const ChatComposer: typeof FeedbackComposer;
280
+ /** {@link FeedbackComposerProps}, for {@link ChatComposer}. */
281
+ type ChatComposerProps = FeedbackComposerProps;
282
+ /** {@link FeedbackComposerHandle}, for {@link ChatComposer}. */
283
+ type ChatComposerHandle = FeedbackComposerHandle;
284
+ /** {@link FeedbackComposerLabels}, for {@link ChatComposer} — still the `feedbackComposer`
285
+ * namespace of the provider. */
286
+ type ChatComposerLabels = FeedbackComposerLabels;
253
287
 
254
- export { DEFAULT_FEEDBACK_COMPOSER_LABELS, DEFAULT_FEEDBACK_THREAD_LABELS, FeedbackComposer, type FeedbackComposerAttachment, type FeedbackComposerHandle, type FeedbackComposerLabels, type FeedbackComposerProps, FeedbackThread, type FeedbackThreadAttachment, type FeedbackThreadEvent, type FeedbackThreadItem, type FeedbackThreadLabels, type FeedbackThreadMessage, type FeedbackThreadProps };
288
+ export { ChatComposer, type ChatComposerHandle, type ChatComposerLabels, type ChatComposerProps, DEFAULT_FEEDBACK_COMPOSER_LABELS, DEFAULT_FEEDBACK_THREAD_LABELS, FeedbackComposer, type FeedbackComposerAttachment, type FeedbackComposerHandle, type FeedbackComposerLabels, type FeedbackComposerProps, FeedbackThread, type FeedbackThreadAttachment, type FeedbackThreadEvent, type FeedbackThreadItem, type FeedbackThreadLabels, type FeedbackThreadMessage, type FeedbackThreadProps };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
3
+ import { useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { ImageIcon, ImageOff, Paperclip, Send } from "lucide-react";
5
5
  import { cn } from "../lib/cn.js";
6
6
  import { formatDate, formatRelativeTime } from "../lib/format.js";
@@ -242,9 +242,14 @@ function FeedbackComposer({
242
242
  onValueChange,
243
243
  ref,
244
244
  labels: labelsProp,
245
- className
245
+ className,
246
+ id,
247
+ size = "md",
248
+ ...rest
246
249
  }) {
247
250
  const labels = useKitLabels("feedbackComposer", DEFAULT_FEEDBACK_COMPOSER_LABELS, labelsProp);
251
+ const rootAttributes = { id, ...dataAttributes(rest) };
252
+ const hintId = useId();
248
253
  const [ownDraft, setOwnDraft] = useState("");
249
254
  const controlled = value !== void 0;
250
255
  const draft = controlled ? value : ownDraft;
@@ -287,7 +292,7 @@ function FeedbackComposer({
287
292
  () => "Ctrl"
288
293
  );
289
294
  if (disabledReason != null && disabledReason !== false) {
290
- return /* @__PURE__ */ jsx("p", { className: cn("text-xs text-[var(--text-muted)]", className), children: disabledReason });
295
+ return /* @__PURE__ */ jsx("p", { ...rootAttributes, className: cn("text-xs text-[var(--text-muted)]", className), children: disabledReason });
291
296
  }
292
297
  const canSend = (canSendProp ?? draft.trim().length > 0) && !pending;
293
298
  const send = () => {
@@ -301,13 +306,14 @@ function FeedbackComposer({
301
306
  });
302
307
  };
303
308
  const config = attachment === true ? {} : attachment || null;
304
- return /* @__PURE__ */ jsxs("div", { ref: root, className: cn("space-y-2", className), children: [
309
+ return /* @__PURE__ */ jsxs("div", { ...rootAttributes, ref: root, className: cn("space-y-2", className), children: [
305
310
  /* @__PURE__ */ jsx(
306
311
  Textarea,
307
312
  {
308
313
  rows,
309
314
  dir: "auto",
310
315
  "aria-label": labels.field,
316
+ "aria-describedby": size === "sm" ? hintId : void 0,
311
317
  ref: box,
312
318
  placeholder: placeholder ?? labels.placeholder,
313
319
  value: draft,
@@ -341,16 +347,39 @@ function FeedbackComposer({
341
347
  attachmentSlot
342
348
  ] }) : /* @__PURE__ */ jsx("span", {}),
343
349
  /* @__PURE__ */ jsxs("div", { className: "ms-auto flex items-center gap-2", children: [
344
- /* @__PURE__ */ jsx("span", { className: "text-xs text-[var(--text-placeholder)]", children: sendOn === "enter" ? labels.sendHintEnter : labels.sendHint(modifier) }),
345
- /* @__PURE__ */ jsxs(Button, { onClick: send, disabled: !canSend, "aria-busy": pending || void 0, children: [
346
- pending ? /* @__PURE__ */ jsx(Spinner, { label: null, className: "size-4" }) : /* @__PURE__ */ jsx(Send, { className: "size-4 rtl:-scale-x-100", "aria-hidden": true }),
347
- labels.send
348
- ] })
350
+ /* @__PURE__ */ jsx(
351
+ "span",
352
+ {
353
+ id: hintId,
354
+ className: size === "sm" ? "sr-only" : "text-xs text-[var(--text-placeholder)]",
355
+ children: sendOn === "enter" ? labels.sendHintEnter : labels.sendHint(modifier)
356
+ }
357
+ ),
358
+ /* @__PURE__ */ jsxs(
359
+ Button,
360
+ {
361
+ onClick: send,
362
+ disabled: !canSend,
363
+ "aria-busy": pending || void 0,
364
+ size: size === "sm" ? "sm" : void 0,
365
+ children: [
366
+ pending ? /* @__PURE__ */ jsx(Spinner, { label: null, className: "size-4" }) : /* @__PURE__ */ jsx(Send, { className: "size-4 rtl:-scale-x-100", "aria-hidden": true }),
367
+ labels.send
368
+ ]
369
+ }
370
+ )
349
371
  ] })
350
372
  ] })
351
373
  ] });
352
374
  }
375
+ function dataAttributes(props) {
376
+ const out = {};
377
+ for (const [key, value] of Object.entries(props)) if (key.startsWith("data-")) out[key] = value;
378
+ return out;
379
+ }
380
+ const ChatComposer = FeedbackComposer;
353
381
  export {
382
+ ChatComposer,
354
383
  DEFAULT_FEEDBACK_COMPOSER_LABELS,
355
384
  DEFAULT_FEEDBACK_THREAD_LABELS,
356
385
  FeedbackComposer,