@eifi1/ui-kit 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +82 -38
  2. package/dist/billing/billing-banner.d.ts +5 -2
  3. package/dist/billing/billing-banner.js.map +1 -1
  4. package/dist/billing/plan-limit-notice.d.ts +5 -2
  5. package/dist/billing/plan-limit-notice.js.map +1 -1
  6. package/dist/chart.js.map +1 -1
  7. package/dist/components/amount-input.d.ts +0 -3
  8. package/dist/components/amount-input.js +2 -2
  9. package/dist/components/amount-input.js.map +1 -1
  10. package/dist/components/calculator.d.ts +1 -4
  11. package/dist/components/calculator.js +1 -3
  12. package/dist/components/calculator.js.map +1 -1
  13. package/dist/components/chart-zoom.d.ts +0 -37
  14. package/dist/components/chart-zoom.js +1 -28
  15. package/dist/components/chart-zoom.js.map +1 -1
  16. package/dist/components/chip-input.d.ts +0 -4
  17. package/dist/components/chip-input.js +1 -5
  18. package/dist/components/chip-input.js.map +1 -1
  19. package/dist/components/combobox.d.ts +1 -1
  20. package/dist/components/combobox.js.map +1 -1
  21. package/dist/components/copy-button.d.ts +5 -1
  22. package/dist/components/copy-button.js.map +1 -1
  23. package/dist/components/currency-option-list.d.ts +3 -8
  24. package/dist/components/currency-option-list.js +1 -29
  25. package/dist/components/currency-option-list.js.map +1 -1
  26. package/dist/components/danger-confirm.d.ts +3 -3
  27. package/dist/components/danger-confirm.js.map +1 -1
  28. package/dist/components/data-table-filter-popover.d.ts +1 -1
  29. package/dist/components/data-table-filter-popover.js +1 -1
  30. package/dist/components/data-table-filter-popover.js.map +1 -1
  31. package/dist/components/data-table-labels.d.ts +1 -42
  32. package/dist/components/data-table-labels.js +2 -31
  33. package/dist/components/data-table-labels.js.map +1 -1
  34. package/dist/components/data-table-shared.d.ts +17 -1
  35. package/dist/components/data-table-shared.js +22 -0
  36. package/dist/components/data-table-shared.js.map +1 -1
  37. package/dist/components/data-table.d.ts +12 -2
  38. package/dist/components/data-table.js +18 -14
  39. package/dist/components/data-table.js.map +1 -1
  40. package/dist/components/dialog-frame.d.ts +3 -1
  41. package/dist/components/dialog-frame.js.map +1 -1
  42. package/dist/components/dropdown.d.ts +18 -15
  43. package/dist/components/dropdown.js +11 -3
  44. package/dist/components/dropdown.js.map +1 -1
  45. package/dist/components/entity-combobox.d.ts +1 -1
  46. package/dist/components/entity-combobox.js.map +1 -1
  47. package/dist/components/field-base.d.ts +0 -5
  48. package/dist/components/field-base.js +0 -5
  49. package/dist/components/field-base.js.map +1 -1
  50. package/dist/components/field-parts.d.ts +3 -11
  51. package/dist/components/field-parts.js +1 -9
  52. package/dist/components/field-parts.js.map +1 -1
  53. package/dist/components/field-strip.d.ts +8 -23
  54. package/dist/components/field-strip.js +24 -22
  55. package/dist/components/field-strip.js.map +1 -1
  56. package/dist/components/field-sync.d.ts +0 -4
  57. package/dist/components/field-sync.js +0 -4
  58. package/dist/components/field-sync.js.map +1 -1
  59. package/dist/components/field.d.ts +4 -4
  60. package/dist/components/field.js.map +1 -1
  61. package/dist/components/full-bleed-dialog.js +2 -2
  62. package/dist/components/full-bleed-dialog.js.map +1 -1
  63. package/dist/components/hover-menu.d.ts +6 -13
  64. package/dist/components/hover-menu.js +3 -3
  65. package/dist/components/hover-menu.js.map +1 -1
  66. package/dist/components/inline-entity-combobox.d.ts +1 -1
  67. package/dist/components/inline-entity-combobox.js.map +1 -1
  68. package/dist/components/modal.d.ts +9 -1
  69. package/dist/components/modal.js +7 -4
  70. package/dist/components/modal.js.map +1 -1
  71. package/dist/components/multi-select.d.ts +5 -16
  72. package/dist/components/multi-select.js +5 -10
  73. package/dist/components/multi-select.js.map +1 -1
  74. package/dist/components/number-input.d.ts +0 -3
  75. package/dist/components/number-input.js +2 -4
  76. package/dist/components/number-input.js.map +1 -1
  77. package/dist/components/popover.js +2 -2
  78. package/dist/components/popover.js.map +1 -1
  79. package/dist/components/series-chart.js.map +1 -1
  80. package/dist/components/server-wake.d.ts +0 -6
  81. package/dist/components/server-wake.js.map +1 -1
  82. package/dist/components/settings-fields.d.ts +4 -2
  83. package/dist/components/settings-fields.js.map +1 -1
  84. package/dist/components/stat-tile.d.ts +8 -2
  85. package/dist/components/stat-tile.js.map +1 -1
  86. package/dist/components/swipeable-row.d.ts +2 -17
  87. package/dist/components/swipeable-row.js +11 -16
  88. package/dist/components/swipeable-row.js.map +1 -1
  89. package/dist/components/tooltip.d.ts +9 -1
  90. package/dist/components/tooltip.js +20 -5
  91. package/dist/components/tooltip.js.map +1 -1
  92. package/dist/components/translation-review.d.ts +10 -2
  93. package/dist/components/translation-review.js +11 -3
  94. package/dist/components/translation-review.js.map +1 -1
  95. package/dist/components/use-table-state.d.ts +31 -3
  96. package/dist/components/use-table-state.js +53 -8
  97. package/dist/components/use-table-state.js.map +1 -1
  98. package/dist/components/user-avatar.d.ts +2 -2
  99. package/dist/components/user-avatar.js.map +1 -1
  100. package/dist/components/wizard-stepper.d.ts +1 -4
  101. package/dist/components/wizard-stepper.js +2 -3
  102. package/dist/components/wizard-stepper.js.map +1 -1
  103. package/dist/currencies.d.ts +23 -0
  104. package/dist/currencies.js +38 -0
  105. package/dist/currencies.js.map +1 -0
  106. package/dist/demo/demo-banner.d.ts +7 -2
  107. package/dist/demo/demo-banner.js.map +1 -1
  108. package/dist/eslint/index.d.ts +83 -0
  109. package/dist/eslint/index.js +69 -0
  110. package/dist/eslint/index.js.map +1 -0
  111. package/dist/eslint/role-utilities.d.ts +48 -0
  112. package/dist/eslint/role-utilities.generated.d.ts +2 -0
  113. package/dist/eslint/role-utilities.generated.js +143 -0
  114. package/dist/eslint/role-utilities.generated.js.map +1 -0
  115. package/dist/eslint/role-utilities.js +43 -0
  116. package/dist/eslint/role-utilities.js.map +1 -0
  117. package/dist/feedback/feedback-menu.d.ts +2 -2
  118. package/dist/feedback/feedback-menu.js.map +1 -1
  119. package/dist/feedback/feedback-thread.d.ts +3 -8
  120. package/dist/feedback/feedback-thread.js +0 -2
  121. package/dist/feedback/feedback-thread.js.map +1 -1
  122. package/dist/hooks/use-dismiss.d.ts +16 -3
  123. package/dist/hooks/use-dismiss.js +14 -2
  124. package/dist/hooks/use-dismiss.js.map +1 -1
  125. package/dist/i18n/kit-labels.d.ts +14 -4
  126. package/dist/i18n/kit-labels.js.map +1 -1
  127. package/dist/i18n/locales/en.js +1 -1
  128. package/dist/i18n/locales/en.js.map +2 -2
  129. package/dist/i18n/locales/fr.js +3 -2
  130. package/dist/i18n/locales/fr.js.map +1 -1
  131. package/dist/i18n/locales/it.js +3 -2
  132. package/dist/i18n/locales/it.js.map +1 -1
  133. package/dist/index.d.ts +2 -1
  134. package/dist/index.js +2 -2
  135. package/dist/index.js.map +1 -1
  136. package/dist/lib/refs.d.ts +13 -0
  137. package/dist/lib/refs.js +15 -0
  138. package/dist/lib/refs.js.map +1 -0
  139. package/dist/rhf/fields.d.ts +10 -10
  140. package/dist/rhf/fields.js.map +1 -1
  141. package/dist/rhf/form-core.d.ts +5 -4
  142. package/dist/rhf/form-core.js.map +1 -1
  143. package/dist/rhf/form.d.ts +7 -36
  144. package/dist/rhf/form.js +1 -16
  145. package/dist/rhf/form.js.map +1 -1
  146. package/dist/rhf/line-items.d.ts +1 -1
  147. package/dist/rhf/line-items.js.map +1 -1
  148. package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
  149. package/dist/rhf.js.map +1 -1
  150. package/dist/shell/option-switcher-menu.d.ts +5 -17
  151. package/dist/shell/option-switcher-menu.js +1 -3
  152. package/dist/shell/option-switcher-menu.js.map +1 -1
  153. package/dist/shell/role-switcher.d.ts +1 -4
  154. package/dist/shell/role-switcher.js +2 -3
  155. package/dist/shell/role-switcher.js.map +1 -1
  156. package/dist/shell/topbar-action-menu.d.ts +7 -19
  157. package/dist/shell/topbar-action-menu.js +1 -3
  158. package/dist/shell/topbar-action-menu.js.map +1 -1
  159. package/dist/shell/topbar-controls.d.ts +3 -12
  160. package/dist/shell/topbar-controls.js +6 -9
  161. package/dist/shell/topbar-controls.js.map +1 -1
  162. package/dist/testing/index.d.ts +1 -1
  163. package/dist/testing/index.js +2 -0
  164. package/dist/testing/index.js.map +1 -1
  165. package/dist/testing/viewport.d.ts +25 -2
  166. package/dist/testing/viewport.js +61 -10
  167. package/dist/testing/viewport.js.map +1 -1
  168. package/dist/theme/palette-presets.d.ts +0 -7
  169. package/dist/theme/palette-presets.js +0 -279
  170. package/dist/theme/palette-presets.js.map +1 -1
  171. package/dist/wizard/types.d.ts +0 -5
  172. package/dist/wizard/types.js +1 -5
  173. package/dist/wizard/types.js.map +1 -1
  174. package/package.json +9 -1
  175. package/src/billing/billing-banner.tsx +5 -2
  176. package/src/billing/plan-limit-notice.tsx +5 -2
  177. package/src/chart.ts +5 -3
  178. package/src/components/amount-input.tsx +2 -6
  179. package/src/components/calculator.tsx +2 -7
  180. package/src/components/chart-zoom.tsx +4 -47
  181. package/src/components/chip-input.tsx +0 -7
  182. package/src/components/combobox.tsx +1 -1
  183. package/src/components/copy-button.tsx +5 -1
  184. package/src/components/currency-option-list.tsx +8 -42
  185. package/src/components/danger-confirm.tsx +3 -3
  186. package/src/components/data-table-filter-popover.tsx +2 -1
  187. package/src/components/data-table-labels.ts +2 -84
  188. package/src/components/data-table-shared.tsx +55 -2
  189. package/src/components/data-table.tsx +29 -17
  190. package/src/components/dialog-frame.tsx +3 -1
  191. package/src/components/dropdown.tsx +42 -18
  192. package/src/components/entity-combobox.tsx +1 -1
  193. package/src/components/field-base.tsx +0 -11
  194. package/src/components/field-parts.tsx +5 -19
  195. package/src/components/field-strip.tsx +9 -25
  196. package/src/components/field-sync.tsx +0 -7
  197. package/src/components/field.tsx +4 -4
  198. package/src/components/full-bleed-dialog.tsx +4 -3
  199. package/src/components/hover-menu.tsx +12 -16
  200. package/src/components/inline-entity-combobox.tsx +1 -1
  201. package/src/components/modal.tsx +20 -4
  202. package/src/components/multi-select.tsx +13 -30
  203. package/src/components/number-input.tsx +3 -8
  204. package/src/components/popover.tsx +5 -3
  205. package/src/components/series-chart.tsx +1 -1
  206. package/src/components/server-wake.tsx +0 -6
  207. package/src/components/settings-fields.tsx +4 -2
  208. package/src/components/stat-tile.tsx +8 -2
  209. package/src/components/swipeable-row.tsx +15 -37
  210. package/src/components/tooltip.tsx +37 -6
  211. package/src/components/translation-review.tsx +25 -7
  212. package/src/components/use-table-state.ts +91 -10
  213. package/src/components/user-avatar.tsx +2 -2
  214. package/src/components/wizard-stepper.tsx +2 -6
  215. package/src/currencies.ts +70 -0
  216. package/src/demo/demo-banner.tsx +7 -2
  217. package/src/eslint/index.ts +161 -0
  218. package/src/eslint/role-utilities.generated.ts +146 -0
  219. package/src/eslint/role-utilities.ts +99 -0
  220. package/src/feedback/feedback-menu.tsx +2 -2
  221. package/src/feedback/feedback-thread.tsx +3 -8
  222. package/src/hooks/use-dismiss.ts +39 -4
  223. package/src/i18n/kit-labels.tsx +15 -5
  224. package/src/i18n/locales/fr.ts +3 -2
  225. package/src/i18n/locales/it.ts +3 -2
  226. package/src/index.ts +3 -1
  227. package/src/lib/refs.ts +22 -0
  228. package/src/rhf/fields.tsx +10 -10
  229. package/src/rhf/form-core.tsx +5 -4
  230. package/src/rhf/form.tsx +7 -43
  231. package/src/rhf/line-items.tsx +1 -1
  232. package/src/rhf/use-rhf-wizard-step.ts +4 -4
  233. package/src/rhf.ts +3 -2
  234. package/src/shell/option-switcher-menu.tsx +5 -22
  235. package/src/shell/role-switcher.tsx +2 -6
  236. package/src/shell/topbar-action-menu.tsx +7 -24
  237. package/src/shell/topbar-controls.tsx +6 -18
  238. package/src/testing/index.ts +3 -1
  239. package/src/testing/viewport.ts +125 -19
  240. package/src/theme/palette-presets.ts +7 -293
  241. package/src/wizard/types.ts +0 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/feedback-thread.tsx"],"sourcesContent":["import { useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { ReactNode, Ref, RefObject } from \"react\";\nimport { ImageIcon, ImageOff, Paperclip, Send } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatDate, formatRelativeTime } from \"../lib/format\";\nimport { hasContent } from \"../lib/presence\";\nimport { Button } from \"../components/button\";\nimport { EmptyState } from \"../components/empty-state\";\nimport { Spinner } from \"../components/spinner\";\nimport { Textarea } from \"../components/textarea\";\nimport type { CharacterCountLabels } from \"../components/field-base\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { useWriteLock } from \"../components/write-lock\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { useKitFileLabels, useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { FeedbackAttachmentField } from \"./feedback-attachment\";\nimport type { FeedbackAttachmentFieldSingleProps } from \"./feedback-attachment\";\nimport type { FeedbackNoteAttachment } from \"./feedback-inbox\";\nimport type { FeedbackAttachmentLabels } from \"./feedback-dialog\";\nimport {\n DEFAULT_FEEDBACK_COMPOSER_LABELS,\n DEFAULT_FEEDBACK_THREAD_LABELS,\n} from \"./feedback-thread-labels\";\n\n/**\n * The conversation under a report: who said what, when, with what attached — and the\n * box to answer in.\n *\n * Both apps had written it by hand. kastlan's feedback page grew a comment list of\n * bordered boxes with `slate-*` literals (feedback-page.tsx, \"keksdose left this\n * unbuilt\"), and keksdose built the same thing a second time for support\n * (support-thread.tsx) with sides, bubbles and a composer that clears only what it\n * sent. This is that second one, generalised: the kit owns the look and the\n * behaviour, the app owns the data, the upload and every word it does not share.\n *\n * **Own vs other** is the caller's per message (`own`), not a comparison the kit makes\n * against a user id: whose message sits at the END side depends on who is reading,\n * and only the app knows that (keksdose's support thread labelled a member's question\n * \"Du\" in the admin panel the first time round, by reading the wrong field).\n *\n * **Redaction.** A thread is somebody's words about their own data — exactly what a\n * host's demo / screen-share mode blurs. Bodies, authors and attachments carry\n * `data-private` (the attribute `Tooltip redact` and `StatTile sensitive` use) unless\n * `redact={false}`.\n *\n * **RTL.** Sides are logical — `justify-end` is the reading end, and the bubble's\n * tucked corner is `rounded-ee` / `rounded-es` — and each body is `dir=\"auto\"`, so a\n * Hebrew reply in an English thread (or the reverse) lays out as its own language.\n *\n * **A chat, too** (keksdose G4/G5). keksdose's support chat is the same conversation\n * read the chat way: status lines between the messages (\"Closed automatically\",\n * \"Reopened\"), a day line where the date changes, clock times under it, Enter to send\n * and several files uploaded ahead of the send. Each of those is an opt-in here\n * (`kind: \"event\"`, `daySeparators`, `timeFormat=\"clock\"`, `sendOn=\"enter\"`,\n * `attachmentSlot` + `canSend`), so the feedback thread's defaults stay as they were.\n */\n\n/* ── Labels ───────────────────────────────────────────────────────────────── */\n\n/** The `feedbackThread` namespace of `<UiKitProvider labels>`. */\nexport interface FeedbackThreadLabels {\n /** Accessible name of the message list. */\n thread: string;\n empty: string;\n loading: string;\n /** Author line of an `own` message that has no `author` of its own. */\n you: string;\n /** The badge beside a `staff` author. */\n staff: string;\n /** Accessible name of a message's attachment list. */\n attachments: string;\n}\n\n// Defined in ./feedback-thread-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_THREAD_LABELS };\n\n/** The `feedbackComposer` namespace of `<UiKitProvider labels>`. The attach buttons'\n * words are `feedbackAttachment`'s, shared with the dialog and the note editor. */\nexport interface FeedbackComposerLabels {\n /** Accessible name of the text box. */\n field: string;\n placeholder: string;\n send: string;\n /** The shortcut line, given the platform's modifier (\"Ctrl\" or \"⌘\"). */\n sendHint: (modifier: string) => string;\n /** The shortcut line under `sendOn=\"enter\"` (keksdose G5): Enter sends, so say how a\n * new line is made. */\n sendHintEnter: string;\n}\n\n// Defined in ./feedback-thread-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_COMPOSER_LABELS };\n\n/* ── Thread ───────────────────────────────────────────────────────────────── */\n\nexport interface FeedbackThreadAttachment {\n id?: string | number;\n name: string;\n /** Where to open it. Left out, the attachment is listed by name only. */\n url?: string;\n /** MIME type; an `image/*` with a `url` is shown as a thumbnail. */\n type?: string;\n /** Bytes, shown beside a non-image. */\n size?: number;\n}\n\nexport interface FeedbackThreadMessage {\n /** Leave out, or `\"message\"`. `\"event\"` is a {@link FeedbackThreadEvent}. */\n kind?: \"message\";\n id: string | number;\n /** Who wrote it. Left out on an `own` message, it reads \"You\". */\n author?: ReactNode;\n /** A `Date`, an ISO string or epoch ms. */\n createdAt: Date | string | number;\n body: string;\n attachments?: readonly FeedbackThreadAttachment[];\n /** Written by whoever is reading: sits at the end side, in the brand tint. */\n own?: boolean;\n /** Written by the team rather than a user: gets the \"Staff\" badge. */\n staff?: boolean;\n}\n\n/**\n * A line in the thread that nobody wrote — \"Closed automatically\", \"Marked as\n * resolved\", \"Reopened\" — drawn centred and muted with its time, no author, no side,\n * no bubble.\n *\n * keksdose G4: its support chat interleaves these with the messages, and as a message\n * they came out as a bubble from nobody at the start side, which reads as the member\n * having said \"resolved\". Word it for the READER, as with `own`: the app knows whether\n * \"you reopened it\" or \"Anna reopened it\" is true for the person looking.\n *\n * The text is the app's, not somebody's words about their data, so it is NOT tagged\n * `data-private`; one that names a person can wrap the name in its own\n * `<span data-private>` (`body` is a node for that reason).\n */\nexport interface FeedbackThreadEvent {\n kind: \"event\";\n id: string | number;\n /** A `Date`, an ISO string or epoch ms. */\n createdAt: Date | string | number;\n body: ReactNode;\n}\n\n/** One row of a {@link FeedbackThread}: a message, or an event line between them. */\nexport type FeedbackThreadItem = FeedbackThreadMessage | FeedbackThreadEvent;\n\nexport interface FeedbackThreadProps {\n /** Oldest first. Event lines ({@link FeedbackThreadEvent}) sit among the messages. */\n messages: readonly FeedbackThreadItem[];\n loading?: boolean;\n /** Replaces the default \"No comments yet\". */\n empty?: ReactNode;\n /**\n * Draw one attachment yourself — for files behind auth, which a plain `<img src>`\n * cannot fetch (kastlan's `AuthedImage`), or a lightbox. The default is a thumbnail\n * link for an image with a `url`, a file link otherwise.\n */\n renderAttachment?: (attachment: FeedbackThreadAttachment, message: FeedbackThreadMessage) => ReactNode;\n /** Tag bodies, authors and attachments `data-private`. Default true. */\n redact?: boolean;\n /**\n * How a row's time reads. `\"relative\"` (default): \"5 minutes ago\", a date past six\n * days — right for a report's comments, read days apart. `\"clock\"`: the time of day\n * in the locale (\"14:05\", \"2:05 PM\") — the chat look, keksdose G4; pair it with\n * `daySeparators`, which say which day that clock time is on. Either way the full\n * date and time is in the Tooltip.\n */\n timeFormat?: \"relative\" | \"clock\";\n /**\n * A centred day line before the first row and wherever the next row is on another\n * calendar day (the device's zone): \"Today\", \"Yesterday\", else the date — keksdose\n * G4. \"Today\" / \"Yesterday\" are `Intl.RelativeTimeFormat`'s own words in the kit\n * locale, so there is no label to translate. Default false.\n */\n daySeparators?: boolean;\n /** \"Now\" for the relative times and the day lines — pin it in tests and stories.\n * Default: the clock. */\n now?: Date | number;\n /** Overrides the provider's locale for the times. */\n locale?: string;\n labels?: LabelOverride<FeedbackThreadLabels>;\n className?: string;\n}\n\nexport function FeedbackThread({\n messages,\n loading = false,\n empty,\n renderAttachment,\n redact = true,\n now,\n locale: localeProp,\n timeFormat = \"relative\",\n daySeparators = false,\n labels: labelsProp,\n className,\n}: FeedbackThreadProps) {\n const labels = useKitLabels(\"feedbackThread\", DEFAULT_FEEDBACK_THREAD_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const file = useKitFileLabels();\n const priv = redact ? \"\" : undefined;\n const clock = useMinuteClock(now === undefined);\n const reference = now === undefined ? clock : +now;\n\n if (loading && messages.length === 0) {\n return <Skeleton lines={3} label={labels.loading} className={className} />;\n }\n if (messages.length === 0) {\n return (\n <EmptyState\n variant=\"inline\"\n size=\"sm\"\n title={empty ?? labels.empty}\n className={cn(\"justify-start\", className)}\n />\n );\n }\n\n // Per row, the calendar day of the last readable date up to it — what a day line\n // compares against.\n const days: (number | null)[] = [];\n for (const message of messages) {\n const date = toDate(message.createdAt);\n days.push(date ? dayNumber(date) : (days.at(-1) ?? null));\n }\n\n return (\n <ol aria-label={labels.thread} aria-busy={loading || undefined} className={cn(\"space-y-3\", className)}>\n {messages.flatMap((message, index) => {\n const date = toDate(message.createdAt);\n const time = date && (\n // The kit's Tooltip, not a native title: one tooltip look app-wide\n // (keksdose F0 / dev#523).\n <Tooltip label={new Intl.DateTimeFormat(locale, { dateStyle: \"full\", timeStyle: \"short\" }).format(date)}>\n <time dateTime={date.toISOString()} className=\"tabular-nums\">\n {timeFormat === \"clock\"\n ? formatDate(date, \"time\", { locale })\n : formatRelativeTime(date, {\n now: reference,\n locale,\n // Past the kit's day steps it is a date: \"2 weeks ago\" makes\n // the reader do arithmetic the date already did.\n absoluteAfterDays: 6.5,\n })}\n </time>\n </Tooltip>\n );\n const rows: ReactNode[] = [];\n const day = date && dayNumber(date);\n // Against the last row WITH a readable date: an unparseable one neither starts\n // a day nor hides the next change.\n if (daySeparators && date && day !== days[index - 1]) {\n rows.push(<DaySeparator key={`day-${message.id}`} date={date} now={reference} locale={locale} />);\n }\n if (message.kind === \"event\") {\n // A list item like the rest, so \"Reopened\" is read in its place, but not an\n // article: an article is somebody's post, and this has no author.\n rows.push(\n <li\n key={message.id}\n data-event=\"\"\n className=\"flex flex-wrap items-baseline justify-center gap-x-2 px-4 text-center text-xs text-muted\"\n >\n <span>{message.body}</span>\n {time && <span className=\"text-caption\">{time}</span>}\n </li>,\n );\n return rows;\n }\n const author = message.author ?? (message.own ? labels.you : null);\n const attachments = message.attachments ?? [];\n rows.push(\n <li\n key={message.id}\n className={cn(\"flex\", message.own ? \"justify-end\" : \"justify-start\")}\n data-own={message.own ? \"\" : undefined}\n >\n <article\n className={cn(\n \"max-w-[85%] min-w-0 rounded-lg px-3 py-2 text-sm\",\n message.own\n ? \"rounded-ee-sm bg-brand-soft\"\n : \"rounded-es-sm bg-surface-2\",\n )}\n >\n <header className=\"mb-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-caption text-muted\">\n {author != null && (\n <span data-private={priv} className=\"font-medium text-secondary\">\n {author}\n </span>\n )}\n {message.staff && (\n <span className=\"rounded border border-subtle bg-surface px-1 text-micro font-medium uppercase tracking-wide text-secondary\">\n {labels.staff}\n </span>\n )}\n {time}\n </header>\n {message.body && (\n <p\n data-private={priv}\n dir=\"auto\"\n className=\"whitespace-pre-wrap break-words text-start text-primary\"\n >\n {message.body}\n </p>\n )}\n {attachments.length > 0 && (\n <ul aria-label={labels.attachments} data-private={priv} className=\"mt-2 flex flex-wrap gap-2\">\n {attachments.map((attachment, index) => (\n <li key={attachment.id ?? `${index}-${attachment.name}`} className=\"min-w-0\">\n {renderAttachment ? (\n renderAttachment(attachment, message)\n ) : (\n <DefaultAttachment attachment={attachment} size={file.size} />\n )}\n </li>\n ))}\n </ul>\n )}\n </article>\n </li>,\n );\n return rows;\n })}\n </ol>\n );\n}\n\nfunction DefaultAttachment({\n attachment,\n size,\n}: {\n attachment: FeedbackThreadAttachment;\n size: (bytes: number) => string;\n}) {\n const { name, url, type } = attachment;\n if (url && type?.startsWith(\"image/\")) return <ImageThumbnail url={url} name={name} />;\n const content = (\n <>\n <Paperclip className=\"size-3.5 shrink-0\" aria-hidden />\n {/* A file name wraps from Large up, as the attachments of the composer do (text\n size §10.17; round 0.34 T1: the sweep read \"export-20…\"). */}\n <span className=\"min-w-0 truncate-until-large\">{name}</span>\n {attachment.size !== undefined && (\n <span className=\"shrink-0 text-muted\">{size(attachment.size)}</span>\n )}\n </>\n );\n const chip =\n \"inline-flex max-w-full items-center gap-1 rounded border border-subtle bg-surface px-2 py-1 text-xs text-secondary\";\n return url ? (\n <a href={url} target=\"_blank\" rel=\"noopener noreferrer\" className={cn(chip, \"hover:bg-hover\")}>\n {content}\n </a>\n ) : (\n <span className={chip}>{content}</span>\n );\n}\n\n/** An image attachment's thumbnail. The box is drawn before the picture arrives —\n * `loading=\"lazy\"` leaves it empty until it nears the viewport, and a URL that has\n * expired never fills it — and an empty bordered square read as a broken layout, not\n * as a picture. So the box carries an image glyph underneath until the picture\n * covers it, and swaps it for a broken-image glyph when the load fails. */\nfunction ImageThumbnail({ url, name }: { url: string; name: string }) {\n // Keyed on the URL, so a message whose attachment is replaced tries the new one.\n const [failedUrl, setFailedUrl] = useState<string | null>(null);\n const failed = failedUrl === url;\n const Glyph = failed ? ImageOff : ImageIcon;\n return (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"relative block h-20 w-20 overflow-hidden rounded border border-subtle bg-surface-2\"\n >\n <Glyph aria-hidden className=\"absolute inset-0 m-auto size-6 text-muted\" />\n {!failed && (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- load/error are resource events, not interactions\n <img\n src={url}\n alt={name}\n loading=\"lazy\"\n onError={() => setFailedUrl(url)}\n className=\"relative h-full w-full object-cover\"\n />\n )}\n {/* The <img> and its alt are gone once it failed; the link still needs a name. */}\n {failed && <span className=\"sr-only\">{name}</span>}\n </a>\n );\n}\n\n/** The time, refreshed once a minute while `active`, so \"2 minutes ago\" does not stay\n * \"just now\" on a page left open. Read in state rather than in render, which must be\n * pure. */\nfunction useMinuteClock(active: boolean): number {\n const [time, setTime] = useState(() => Date.now());\n useEffect(() => {\n if (!active) return;\n const id = setInterval(() => setTime(Date.now()), 60_000);\n return () => clearInterval(id);\n }, [active]);\n return time;\n}\n\n/** The local calendar day as one number (20260926), for \"same day?\" and keys. */\nfunction dayNumber(date: Date): number {\n return date.getFullYear() * 10_000 + (date.getMonth() + 1) * 100 + date.getDate();\n}\n\n/**\n * The day line of `daySeparators` (keksdose G4): \"Today\" / \"Yesterday\" from\n * `Intl.RelativeTimeFormat` (`numeric: \"auto\"`) — the locale's own words, capitalised\n * for a line that stands alone (\"heute\" → \"Heute\"; a script without case is left as\n * is) — else the weekday and date, with the year only when it is not this one.\n *\n * Counted in calendar days, not 24-hour spans: 23:50 yesterday is \"Yesterday\" at\n * 00:10 today.\n */\nfunction DaySeparator({ date, now, locale }: { date: Date; now: number; locale: string | undefined }) {\n const today = new Date(now);\n const days = Math.round(\n (Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) -\n Date.UTC(today.getFullYear(), today.getMonth(), today.getDate())) /\n 86_400_000,\n );\n let label: string;\n if (days === 0 || days === -1) {\n const word = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" }).format(days + 0, \"day\");\n label = word.charAt(0).toLocaleUpperCase(locale) + word.slice(1);\n } else {\n label = formatDate(\n date,\n {\n weekday: \"long\",\n day: \"numeric\",\n month: \"long\",\n ...(date.getFullYear() === today.getFullYear() ? null : { year: \"numeric\" }),\n },\n { locale },\n );\n }\n const y = String(date.getFullYear()).padStart(4, \"0\");\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return (\n <li data-day-separator=\"\" className=\"flex items-center gap-3 py-1 text-xs text-muted\">\n <span aria-hidden className=\"h-px flex-1 bg-[var(--border)]\" />\n <time dateTime={`${y}-${m}-${d}`} className=\"font-medium\">\n {label}\n </time>\n <span aria-hidden className=\"h-px flex-1 bg-[var(--border)]\" />\n </li>\n );\n}\n\nfunction toDate(value: Date | string | number): Date | null {\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\n/* ── Composer ─────────────────────────────────────────────────────────────── */\n\n/** What the composer's attach control takes — {@link FeedbackNoteAttachment} with the\n * labels optional, since the field reads `feedbackAttachment` from the provider, and\n * `onError` the field's own (0.23.0): it is handed the refused file and the limit too\n * (`FeedbackAttachmentErrorInfo`), and a `(kind) => …` handler still fits. Since\n * 0.24.0 also the field's `buttonVariant` / `buttonSize`, for a composer whose row\n * wants smaller or quieter attach buttons than the bordered `md` default. */\nexport type FeedbackComposerAttachment = Omit<FeedbackNoteAttachment, \"labels\" | \"onError\"> & {\n labels?: LabelOverride<FeedbackAttachmentLabels>;\n onError?: FeedbackAttachmentFieldSingleProps[\"onError\"];\n} & Pick<FeedbackAttachmentFieldSingleProps, \"buttonVariant\" | \"buttonSize\">;\n\n/**\n * What a render-prop {@link FeedbackComposerProps.attachmentSlot} is handed (0.24.0,\n * keksdose).\n *\n * keksdose's support chat put `<FeedbackAttachmentField refs>` in the slot and a\n * screenshot pasted into the reply box never reached it: the box is the field's\n * sibling, so the paste bubbles to their common parent — the composer's root — and the\n * field hears it only through `pasteFrom`, which needs that root. The composer kept it\n * to itself, so keksdose wrapped the whole composer in a ref'd `<div>` of its own just\n * to have an element to hand over.\n */\nexport interface FeedbackComposerSlotContext {\n /**\n * The composer's root, round the text box and this slot — the field's `pasteFrom`,\n * as it is: `pasteFrom={slot.root}`.\n *\n * A ref, not the element, because `pasteFrom` is one: the field reads `.current` in\n * an effect, and the slot renders INSIDE this root, so the two are committed together\n * and React attaches the root before any effect of the slot's runs — the first paste\n * after the first paint already lands. The element itself would be `null` on the\n * first render (it does not exist yet) and could only arrive by a second render\n * through state; the ref is the same object every render, so the field's listener is\n * added once and never re-added.\n *\n * With the built-in `attachment` on as well, it listens on this root too: hand the\n * root to one field only, or an image pasted once is attached twice.\n */\n root: RefObject<HTMLElement | null>;\n /** The composer's `pending` — a send is in flight. For the field's `disabled`\n * (keksdose G5b): the message carries the attachments as they were at the press. */\n pending: boolean;\n}\n\nexport interface FeedbackComposerProps {\n /**\n * Send the comment. Return the promise: the box clears when it RESOLVES, and only of\n * what was sent — text typed while it was in flight stays. A rejection keeps\n * everything for a retry (surface the error yourself; the composer stays quiet).\n *\n * `attachment` is the built-in field's one picture. Files the host uploaded ahead\n * (`attachmentSlot`) are the host's state, read by the host here — and `body` may be\n * `\"\"` when `canSend` let an attachments-only message go.\n */\n onSend: (body: string, attachment: File | null) => void | Promise<unknown>;\n /** The send is in flight: a spinner on the button and no second send. */\n pending?: boolean;\n /** Offer one picture with the comment (file, paste or `onCaptureScreenshot`).\n * `true` for the defaults. Left out, the composer is text only. */\n attachment?: boolean | FeedbackComposerAttachment;\n /**\n * The host's own attach control, in the row with Send where the built-in field sits\n * (after it, if both are on) — keksdose G5: its support chat uploads up to N files\n * AHEAD of the send and sends their refs, which one `File` in `onSend` cannot carry.\n * The slot is the host's picker plus the chips of what is uploaded; the upload, the\n * refs and clearing them once `onSend` resolves stay with the host. Pair it with\n * `canSend`.\n *\n * A node, or (0.24.0) a function of {@link FeedbackComposerSlotContext} that returns\n * one — for a field that wants the composer's root as its `pasteFrom`, so a\n * screenshot pasted into the box reaches it, and `pending` for its `disabled`:\n *\n * ```tsx\n * attachmentSlot={({ root, pending }) => (\n * <FeedbackAttachmentField refs pasteFrom={root} disabled={pending} … />\n * )}\n * ```\n *\n * Called once per render of the composer, and not at all while `disabledReason`\n * stands in for it.\n */\n attachmentSlot?: ReactNode | ((slot: FeedbackComposerSlotContext) => ReactNode);\n /**\n * Whether Send is enabled, over the composer's own rule (some text in the box) —\n * for state the composer cannot see, i.e. `attachmentSlot`'s (keksdose G5): `true`\n * with files ready makes an empty draft sendable (`onSend(\"\", null)`), `false` while\n * an upload is still running holds even a written reply back. Left out, the text\n * decides. `pending` blocks a send either way, as does a draft past `maxLength`.\n */\n canSend?: boolean;\n /**\n * Which key sends. `\"mod-enter\"` (default): Ctrl/⌘+Enter, the report dialog's and\n * note editor's shortcut, with plain Enter a new line — feedback is written in\n * paragraphs. `\"enter\"`: the chat way (keksdose G5) — Enter sends, Shift+Enter is a\n * new line, Ctrl/⌘+Enter still sends; an Enter that confirms an IME composition\n * (Japanese, Chinese input) is the IME's, never a send.\n */\n sendOn?: \"mod-enter\" | \"enter\";\n /** Rendered INSTEAD of the composer — the thread is closed, or read-only for this\n * reader. */\n disabledReason?: ReactNode;\n /**\n * Send COMMITS (0.33.1, kastlan's assistant): under a locked {@link WriteLockProvider}\n * Send is disabled the `disabledReason` way — focusable, the lock's reason in its\n * tooltip and description, as on {@link Button}'s `commit` — and neither Enter nor\n * Ctrl/⌘+Enter sends. The box stays editable and the draft stays: nothing in it\n * reaches the server until Send, and the lock may lift. No provider, or an unlocked\n * one: no effect. A {@link CommitScope}: kastlan's assistant answers under the demo\n * and not under a lapsed plan (its backend's 402), so it passes\n * `commit={{ except: [\"demo\"] }}` where it read `useWriteLock` and fed `canSend` and a\n * reason by hand. Not the prop above: that one replaces the box, this one keeps it.\n */\n commit?: CommitScope;\n rows?: number;\n /**\n * The longest draft the box takes, in UTF-16 code units as the browser counts — the\n * server's limit, so a reply too long for it is cut off while it is typed rather than\n * refused by a 422 after the press (keksdose G6: its support replies are capped at\n * 4,000 on the server, and its other text fields already count against that with\n * Textarea's `maxLength` + `showCount` since 0.22; the reply box, a composer, could\n * not). The box's own `maxLength`, so typing and pasting stop at it.\n *\n * {@link FeedbackComposerHandle.insertText} is not stopped by it — the browser limits\n * typing, not a script — and a canned reply is not cut mid-sentence to fit. A draft\n * past the limit therefore holds Send back (whatever `canSend` says, as `pending`\n * does) until it is trimmed; with `showCount` the counter, red at the limit, says by\n * how much.\n */\n maxLength?: number;\n /**\n * A live \"12/4000\" under the box, with `maxLength` — Textarea's `showCount`, the same\n * counter (keksdose G6): the count is part of the box's description, read with it on\n * focus, and a polite live region speaks only on entering the last stretch and at the\n * limit, never per keystroke. Under `size=\"sm\"` the hidden send hint stays the box's\n * description too, before the count. Ignored without `maxLength`.\n */\n showCount?: boolean;\n /** The counter's words — the `characterCount` namespace, as on Textarea. */\n countLabels?: Partial<CharacterCountLabels>;\n /**\n * The box's hint, over the `placeholder` label — keksdose F9: an admin answering a\n * support ticket is asked something else (\"Reply to Anna…\") than a member adding to\n * their own report, and one provider-wide label cannot say both.\n */\n placeholder?: string;\n /**\n * The draft, controlled — for a host that keeps it itself (saves it per ticket,\n * prefills a template). Left out, the composer keeps its own. Either way a send\n * that resolves clears only what was sent: controlled, that is an\n * `onValueChange(\"\")` the host receives like any keystroke, and only if the draft\n * is still the one that went out.\n */\n value?: string;\n /** Every change to the draft — typing, {@link FeedbackComposerHandle.insertText}, the\n * clear after a send. Required to change a controlled `value`. */\n onValueChange?: (value: string) => void;\n /** {@link FeedbackComposerHandle}: put text into the draft from outside (canned-reply\n * chips) or focus the box. */\n ref?: Ref<FeedbackComposerHandle>;\n labels?: LabelOverride<FeedbackComposerLabels>;\n className?: string;\n /**\n * `\"sm\"` for a narrow host — keksdose's assistant launcher, a small floating panel\n * (0.22): a small Send button, and the send hint (\"Enter to send, Shift + Enter for a\n * new line\") hidden from view but kept as the box's description, so a keyboard or\n * screen-reader user still learns the shortcut. Default `\"md\"`.\n */\n size?: \"md\" | \"sm\";\n /**\n * On the composer's root — the box, or the `disabledReason` line in its place —\n * with any `data-*` attribute beside it (keksdose K17). keksdose's assistant tour\n * points at the chat box with `[data-tour=\"assistant-ask\"]`, and a composer that\n * dropped every attribute it was not told about left the anchor nowhere: the\n * assistant kept its hand-built box rather than lose the tour step.\n */\n id?: string;\n /** `data-*` attributes for the root, as `id` — a tour anchor, a test id. */\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined;\n}\n\n/**\n * What a {@link FeedbackComposer} `ref` holds.\n *\n * keksdose F9: the support admin answers the same five questions all day and wants\n * chips above the box (\"Thanks, fixed in the next release\") that drop their text in\n * where the caret is. A controlled `value` alone cannot do that well — the host sees\n * the string, not the caret, so it could only append — so the composer, which owns\n * the textarea, does the splice.\n */\nexport interface FeedbackComposerHandle {\n /**\n * Insert `text` at the caret, replacing any selection (the caret the box last had:\n * a click on a chip blurs it, and the selection survives the blur), then focus the\n * box with the caret after the inserted text so the reply can go on. Nothing is\n * added around it — put a space or a newline in `text` if the reply needs one. A\n * no-op while `disabledReason` replaces the box.\n */\n insertText: (text: string) => void;\n focus: () => void;\n}\n\nconst noSubscribe = () => () => {};\nconst isApple = () =>\n typeof navigator !== \"undefined\" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent);\n\n/**\n * The answer box under a {@link FeedbackThread}: a textarea, an optional picture,\n * and Send — Ctrl/⌘+Enter sends, the shortcut the report dialog and the note editor\n * use, so the habit carries across the feature. Plain Enter is a new line: feedback is\n * written in paragraphs, unlike a chat — which `sendOn=\"enter\"` is for (keksdose G5).\n *\n * Named for what it is since 0.22 (keksdose K17): the component was never\n * feedback-specific — a textarea, an optional picture or a host's upload slot, Send,\n * `sendOn=\"enter\"` for the chat way — and keksdose's assistant and support chat are\n * chats, not reports. `FeedbackComposer` is its old name, deprecated in 0.34.\n */\nexport function ChatComposer({\n onSend,\n pending = false,\n attachment,\n attachmentSlot,\n canSend: canSendProp,\n sendOn = \"mod-enter\",\n disabledReason,\n commit,\n rows = 3,\n maxLength,\n showCount,\n countLabels,\n placeholder,\n value,\n onValueChange,\n ref,\n labels: labelsProp,\n className,\n id,\n size = \"md\",\n ...rest\n}: FeedbackComposerProps) {\n const labels = useKitLabels(\"feedbackComposer\", DEFAULT_FEEDBACK_COMPOSER_LABELS, labelsProp);\n // The lock as Send sees it, with its scope (§12.36). Send's Button reads the same\n // through its own `commit`; this holds the keyboard's send back with it.\n const lock = useWriteLock(commit ?? false);\n const rootAttributes = { id, ...dataAttributes(rest) };\n const hintId = useId();\n const [ownDraft, setOwnDraft] = useState(\"\");\n const controlled = value !== undefined;\n const draft = controlled ? value : ownDraft;\n const [file, setFile] = useState<File | null>(null);\n const root = useRef<HTMLDivElement>(null);\n const box = useRef<HTMLTextAreaElement>(null);\n // The draft as of the last commit. The send's `.then` and `insertText` run after\n // renders their closure did not see — text typed while the send was in flight, a\n // second chip clicked before the first one's render — and must not act on a stale\n // string (for a controlled draft there is no updater function to lean on).\n const latest = useRef(draft);\n useLayoutEffect(() => {\n latest.current = draft;\n });\n // Where the caret goes once an inserted text has rendered.\n const caret = useRef<number | null>(null);\n useLayoutEffect(() => {\n const el = box.current;\n if (caret.current === null || !el) return;\n el.focus();\n el.setSelectionRange(caret.current, caret.current);\n caret.current = null;\n });\n\n const setDraft = (next: string) => {\n latest.current = next;\n if (!controlled) setOwnDraft(next);\n onValueChange?.(next);\n };\n\n useImperativeHandle(ref, () => ({\n insertText: (text) => {\n const el = box.current;\n if (!el) return;\n const current = latest.current;\n // A second insert before the first has rendered goes after the first, not at the\n // textarea's not-yet-moved caret. Otherwise the textarea's selection, which may\n // be past the end of a controlled value the host has just shortened: clamp it.\n const pending = caret.current;\n const start = Math.min(pending ?? el.selectionStart ?? current.length, current.length);\n const end = pending ?? Math.max(start, Math.min(el.selectionEnd ?? start, current.length));\n caret.current = start + text.length;\n setDraft(current.slice(0, start) + text + current.slice(end));\n },\n focus: () => box.current?.focus(),\n }));\n // The server snapshot is \"Ctrl\"; the client corrects it after hydration.\n const modifier = useSyncExternalStore(\n noSubscribe,\n () => (isApple() ? \"⌘\" : \"Ctrl\"),\n () => \"Ctrl\",\n );\n\n // The kit's one presence rule (DUP-11): `\"\"` is no reason either, so it keeps the box.\n if (hasContent(disabledReason)) {\n return (\n <p {...rootAttributes} className={cn(\"text-xs text-muted\", className)}>\n {disabledReason}\n </p>\n );\n }\n\n // Longer than `maxLength` only through `insertText` or a controlled value (typing\n // stops at it): the server would refuse it, so it does not go.\n const tooLong = maxLength !== undefined && draft.length > maxLength;\n const canSend = (canSendProp ?? draft.trim().length > 0) && !pending && !tooLong && !lock.locked;\n const send = () => {\n if (!canSend) return;\n const sentDraft = draft;\n const sentFile = file;\n Promise.resolve(onSend(draft.trim(), file))\n .then(() => {\n if (latest.current === sentDraft) setDraft(\"\");\n setFile((current) => (current === sentFile ? null : current));\n })\n .catch(() => {});\n };\n\n const config = attachment === true ? {} : attachment || null;\n // The slot is handed the ref OBJECT, for a field's `pasteFrom`, which reads `.current`\n // in an effect once the root is attached — nothing reads it during this render (see\n // FeedbackComposerSlotContext.root).\n const slot =\n typeof attachmentSlot === \"function\"\n ? // eslint-disable-next-line react-hooks/refs -- handed on for an effect, not read here\n attachmentSlot({ root, pending })\n : attachmentSlot;\n\n return (\n <div {...rootAttributes} ref={root} className={cn(\"space-y-2\", className)}>\n <Textarea\n rows={rows}\n dir=\"auto\"\n aria-label={labels.field}\n // Textarea puts the counter's description after this one, so under \"sm\" the box\n // reads \"Enter to send… 12 of 4000 characters\".\n aria-describedby={size === \"sm\" ? hintId : undefined}\n maxLength={maxLength}\n // Passed only when given: Textarea keeps a wrapper for a `showCount` it was\n // handed at all, and a composer without one keeps the DOM it had.\n {...(showCount !== undefined ? { showCount } : null)}\n countLabels={countLabels}\n ref={box}\n placeholder={placeholder ?? labels.placeholder}\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\") return;\n const mod = event.ctrlKey || event.metaKey;\n // Under \"enter\": plain Enter sends, Shift+Enter falls through to the\n // textarea's new line, and an Enter that ends an IME composition is the\n // IME's (keyCode 229 is how Safari reports it after the composition ended).\n const chat =\n sendOn === \"enter\" &&\n !event.shiftKey &&\n !event.altKey &&\n !event.nativeEvent.isComposing &&\n event.keyCode !== 229;\n if (mod || chat) {\n event.preventDefault();\n send();\n }\n }}\n />\n <div className=\"flex flex-wrap items-end justify-between gap-2\">\n {config || slot != null ? (\n <div className=\"flex min-w-0 flex-wrap items-end gap-2\">\n {config && (\n <FeedbackAttachmentField\n value={file}\n onChange={setFile}\n labels={config.labels}\n accept={config.accept}\n maxBytes={config.maxBytes}\n onError={config.onError}\n onCaptureScreenshot={config.onCaptureScreenshot}\n buttonVariant={config.buttonVariant}\n buttonSize={config.buttonSize}\n // The box is this field's sibling; a paste in it bubbles to `root`.\n pasteFrom={root}\n />\n )}\n {slot}\n </div>\n ) : (\n <span />\n )}\n <div className=\"ms-auto flex items-center gap-2\">\n <span\n id={hintId}\n className={size === \"sm\" ? \"sr-only\" : \"text-xs text-placeholder\"}\n >\n {sendOn === \"enter\" ? labels.sendHintEnter : labels.sendHint(modifier)}\n </span>\n <Button\n onClick={send}\n disabled={!canSend}\n commit={commit}\n aria-busy={pending || undefined}\n size={size === \"sm\" ? \"sm\" : undefined}\n >\n {pending ? (\n <Spinner label={null} className=\"size-4\" />\n ) : (\n <Send className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n )}\n {labels.send}\n </Button>\n </div>\n </div>\n </div>\n );\n}\n\n/** The `data-*` entries of a rest-props object, and nothing else: whatever a caller\n * spread in that the composer does not know is not the root's to receive. */\nfunction dataAttributes(props: object): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) if (key.startsWith(\"data-\")) out[key] = value;\n return out;\n}\n\n/**\n * @deprecated 0.34 — `ChatComposer`, the same function under the name that is not about\n * feedback; removed in 0.35 (refactor audit 2026-10, API-6d). keksdose's support thread\n * is the one app site.\n */\nexport const FeedbackComposer = ChatComposer;\n/** {@link FeedbackComposerProps}, for {@link ChatComposer}. */\nexport type ChatComposerProps = FeedbackComposerProps;\n/** {@link FeedbackComposerHandle}, for {@link ChatComposer}. */\nexport type ChatComposerHandle = FeedbackComposerHandle;\n/** {@link FeedbackComposerLabels}, for {@link ChatComposer} — still the `feedbackComposer`\n * namespace of the provider. */\nexport type ChatComposerLabels = FeedbackComposerLabels;\n/** {@link FeedbackComposerSlotContext}, for {@link ChatComposer}'s `attachmentSlot`. */\nexport type ChatComposerSlotContext = FeedbackComposerSlotContext;\n"],"mappings":";AA+MW,SAsIP,UAtIO,KAqDC,YArDD;AA/MX,SAAS,WAAW,OAAO,qBAAqB,iBAAiB,QAAQ,UAAU,4BAA4B;AAE/G,SAAS,WAAW,UAAU,WAAW,YAAY;AACrD,SAAS,UAAU;AACnB,SAAS,YAAY,0BAA0B;AAC/C,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAEzB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAE7B,SAAS,kBAAkB,cAAc,oBAAwC;AACjF,SAAS,+BAA+B;AAIxC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAmKA,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR;AACF,GAAwB;AACtB,QAAM,SAAS,aAAa,kBAAkB,gCAAgC,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KAAK,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,IAAI,WAAW,OAAO,EAAG,KAAI,GAAG,IAAI;AAC1F,SAAO;AACT;AAOO,MAAM,mBAAmB;","names":["index","pending"]}
1
+ {"version":3,"sources":["../../src/feedback/feedback-thread.tsx"],"sourcesContent":["import { useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { ReactNode, Ref, RefObject } from \"react\";\nimport { ImageIcon, ImageOff, Paperclip, Send } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatDate, formatRelativeTime } from \"../lib/format\";\nimport { hasContent } from \"../lib/presence\";\nimport { Button } from \"../components/button\";\nimport { EmptyState } from \"../components/empty-state\";\nimport { Spinner } from \"../components/spinner\";\nimport { Textarea } from \"../components/textarea\";\nimport type { CharacterCountLabels } from \"../components/field-base\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { useWriteLock } from \"../components/write-lock\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { useKitFileLabels, useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { FeedbackAttachmentField } from \"./feedback-attachment\";\nimport type { FeedbackAttachmentFieldSingleProps } from \"./feedback-attachment\";\nimport type { FeedbackNoteAttachment } from \"./feedback-inbox\";\nimport type { FeedbackAttachmentLabels } from \"./feedback-dialog\";\nimport {\n DEFAULT_FEEDBACK_COMPOSER_LABELS,\n DEFAULT_FEEDBACK_THREAD_LABELS,\n} from \"./feedback-thread-labels\";\n\n/**\n * The conversation under a report: who said what, when, with what attached — and the\n * box to answer in.\n *\n * Both apps had written it by hand. kastlan's feedback page grew a comment list of\n * bordered boxes with `slate-*` literals (feedback-page.tsx, \"keksdose left this\n * unbuilt\"), and keksdose built the same thing a second time for support\n * (support-thread.tsx) with sides, bubbles and a composer that clears only what it\n * sent. This is that second one, generalised: the kit owns the look and the\n * behaviour, the app owns the data, the upload and every word it does not share.\n *\n * **Own vs other** is the caller's per message (`own`), not a comparison the kit makes\n * against a user id: whose message sits at the END side depends on who is reading,\n * and only the app knows that (keksdose's support thread labelled a member's question\n * \"Du\" in the admin panel the first time round, by reading the wrong field).\n *\n * **Redaction.** A thread is somebody's words about their own data — exactly what a\n * host's demo / screen-share mode blurs. Bodies, authors and attachments carry\n * `data-private` (the attribute `Tooltip redact` and `StatTile sensitive` use) unless\n * `redact={false}`.\n *\n * **RTL.** Sides are logical — `justify-end` is the reading end, and the bubble's\n * tucked corner is `rounded-ee` / `rounded-es` — and each body is `dir=\"auto\"`, so a\n * Hebrew reply in an English thread (or the reverse) lays out as its own language.\n *\n * **A chat, too** (keksdose G4/G5). keksdose's support chat is the same conversation\n * read the chat way: status lines between the messages (\"Closed automatically\",\n * \"Reopened\"), a day line where the date changes, clock times under it, Enter to send\n * and several files uploaded ahead of the send. Each of those is an opt-in here\n * (`kind: \"event\"`, `daySeparators`, `timeFormat=\"clock\"`, `sendOn=\"enter\"`,\n * `attachmentSlot` + `canSend`), so the feedback thread's defaults stay as they were.\n */\n\n/* ── Labels ───────────────────────────────────────────────────────────────── */\n\n/** The `feedbackThread` namespace of `<UiKitProvider labels>`. */\nexport interface FeedbackThreadLabels {\n /** Accessible name of the message list. */\n thread: string;\n empty: string;\n loading: string;\n /** Author line of an `own` message that has no `author` of its own. */\n you: string;\n /** The badge beside a `staff` author. */\n staff: string;\n /** Accessible name of a message's attachment list. */\n attachments: string;\n}\n\n// Defined in ./feedback-thread-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_THREAD_LABELS };\n\n/** The `feedbackComposer` namespace of `<UiKitProvider labels>`. The attach buttons'\n * words are `feedbackAttachment`'s, shared with the dialog and the note editor. */\nexport interface FeedbackComposerLabels {\n /** Accessible name of the text box. */\n field: string;\n placeholder: string;\n send: string;\n /** The shortcut line, given the platform's modifier (\"Ctrl\" or \"⌘\"). */\n sendHint: (modifier: string) => string;\n /** The shortcut line under `sendOn=\"enter\"` (keksdose G5): Enter sends, so say how a\n * new line is made. */\n sendHintEnter: string;\n}\n\n// Defined in ./feedback-thread-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_COMPOSER_LABELS };\n\n/* ── Thread ───────────────────────────────────────────────────────────────── */\n\nexport interface FeedbackThreadAttachment {\n id?: string | number;\n name: string;\n /** Where to open it. Left out, the attachment is listed by name only. */\n url?: string;\n /** MIME type; an `image/*` with a `url` is shown as a thumbnail. */\n type?: string;\n /** Bytes, shown beside a non-image. */\n size?: number;\n}\n\nexport interface FeedbackThreadMessage {\n /** Leave out, or `\"message\"`. `\"event\"` is a {@link FeedbackThreadEvent}. */\n kind?: \"message\";\n id: string | number;\n /** Who wrote it. Left out on an `own` message, it reads \"You\". */\n author?: ReactNode;\n /** A `Date`, an ISO string or epoch ms. */\n createdAt: Date | string | number;\n body: string;\n attachments?: readonly FeedbackThreadAttachment[];\n /** Written by whoever is reading: sits at the end side, in the brand tint. */\n own?: boolean;\n /** Written by the team rather than a user: gets the \"Staff\" badge. */\n staff?: boolean;\n}\n\n/**\n * A line in the thread that nobody wrote — \"Closed automatically\", \"Marked as\n * resolved\", \"Reopened\" — drawn centred and muted with its time, no author, no side,\n * no bubble.\n *\n * keksdose G4: its support chat interleaves these with the messages, and as a message\n * they came out as a bubble from nobody at the start side, which reads as the member\n * having said \"resolved\". Word it for the READER, as with `own`: the app knows whether\n * \"you reopened it\" or \"Anna reopened it\" is true for the person looking.\n *\n * The text is the app's, not somebody's words about their data, so it is NOT tagged\n * `data-private`; one that names a person can wrap the name in its own\n * `<span data-private>` (`body` is a node for that reason).\n */\nexport interface FeedbackThreadEvent {\n kind: \"event\";\n id: string | number;\n /** A `Date`, an ISO string or epoch ms. */\n createdAt: Date | string | number;\n body: ReactNode;\n}\n\n/** One row of a {@link FeedbackThread}: a message, or an event line between them. */\nexport type FeedbackThreadItem = FeedbackThreadMessage | FeedbackThreadEvent;\n\nexport interface FeedbackThreadProps {\n /** Oldest first. Event lines ({@link FeedbackThreadEvent}) sit among the messages. */\n messages: readonly FeedbackThreadItem[];\n loading?: boolean;\n /** Replaces the default \"No comments yet\". */\n empty?: ReactNode;\n /**\n * Draw one attachment yourself — for files behind auth, which a plain `<img src>`\n * cannot fetch (kastlan's `AuthedImage`), or a lightbox. The default is a thumbnail\n * link for an image with a `url`, a file link otherwise.\n */\n renderAttachment?: (attachment: FeedbackThreadAttachment, message: FeedbackThreadMessage) => ReactNode;\n /** Tag bodies, authors and attachments `data-private`. Default true. */\n redact?: boolean;\n /**\n * How a row's time reads. `\"relative\"` (default): \"5 minutes ago\", a date past six\n * days — right for a report's comments, read days apart. `\"clock\"`: the time of day\n * in the locale (\"14:05\", \"2:05 PM\") — the chat look, keksdose G4; pair it with\n * `daySeparators`, which say which day that clock time is on. Either way the full\n * date and time is in the Tooltip.\n */\n timeFormat?: \"relative\" | \"clock\";\n /**\n * A centred day line before the first row and wherever the next row is on another\n * calendar day (the device's zone): \"Today\", \"Yesterday\", else the date — keksdose\n * G4. \"Today\" / \"Yesterday\" are `Intl.RelativeTimeFormat`'s own words in the kit\n * locale, so there is no label to translate. Default false.\n */\n daySeparators?: boolean;\n /** \"Now\" for the relative times and the day lines — pin it in tests and stories.\n * Default: the clock. */\n now?: Date | number;\n /** Overrides the provider's locale for the times. */\n locale?: string;\n labels?: LabelOverride<FeedbackThreadLabels>;\n className?: string;\n}\n\nexport function FeedbackThread({\n messages,\n loading = false,\n empty,\n renderAttachment,\n redact = true,\n now,\n locale: localeProp,\n timeFormat = \"relative\",\n daySeparators = false,\n labels: labelsProp,\n className,\n}: FeedbackThreadProps) {\n const labels = useKitLabels(\"feedbackThread\", DEFAULT_FEEDBACK_THREAD_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const file = useKitFileLabels();\n const priv = redact ? \"\" : undefined;\n const clock = useMinuteClock(now === undefined);\n const reference = now === undefined ? clock : +now;\n\n if (loading && messages.length === 0) {\n return <Skeleton lines={3} label={labels.loading} className={className} />;\n }\n if (messages.length === 0) {\n return (\n <EmptyState\n variant=\"inline\"\n size=\"sm\"\n title={empty ?? labels.empty}\n className={cn(\"justify-start\", className)}\n />\n );\n }\n\n // Per row, the calendar day of the last readable date up to it — what a day line\n // compares against.\n const days: (number | null)[] = [];\n for (const message of messages) {\n const date = toDate(message.createdAt);\n days.push(date ? dayNumber(date) : (days.at(-1) ?? null));\n }\n\n return (\n <ol aria-label={labels.thread} aria-busy={loading || undefined} className={cn(\"space-y-3\", className)}>\n {messages.flatMap((message, index) => {\n const date = toDate(message.createdAt);\n const time = date && (\n // The kit's Tooltip, not a native title: one tooltip look app-wide\n // (keksdose F0 / dev#523).\n <Tooltip label={new Intl.DateTimeFormat(locale, { dateStyle: \"full\", timeStyle: \"short\" }).format(date)}>\n <time dateTime={date.toISOString()} className=\"tabular-nums\">\n {timeFormat === \"clock\"\n ? formatDate(date, \"time\", { locale })\n : formatRelativeTime(date, {\n now: reference,\n locale,\n // Past the kit's day steps it is a date: \"2 weeks ago\" makes\n // the reader do arithmetic the date already did.\n absoluteAfterDays: 6.5,\n })}\n </time>\n </Tooltip>\n );\n const rows: ReactNode[] = [];\n const day = date && dayNumber(date);\n // Against the last row WITH a readable date: an unparseable one neither starts\n // a day nor hides the next change.\n if (daySeparators && date && day !== days[index - 1]) {\n rows.push(<DaySeparator key={`day-${message.id}`} date={date} now={reference} locale={locale} />);\n }\n if (message.kind === \"event\") {\n // A list item like the rest, so \"Reopened\" is read in its place, but not an\n // article: an article is somebody's post, and this has no author.\n rows.push(\n <li\n key={message.id}\n data-event=\"\"\n className=\"flex flex-wrap items-baseline justify-center gap-x-2 px-4 text-center text-xs text-muted\"\n >\n <span>{message.body}</span>\n {time && <span className=\"text-caption\">{time}</span>}\n </li>,\n );\n return rows;\n }\n const author = message.author ?? (message.own ? labels.you : null);\n const attachments = message.attachments ?? [];\n rows.push(\n <li\n key={message.id}\n className={cn(\"flex\", message.own ? \"justify-end\" : \"justify-start\")}\n data-own={message.own ? \"\" : undefined}\n >\n <article\n className={cn(\n \"max-w-[85%] min-w-0 rounded-lg px-3 py-2 text-sm\",\n message.own\n ? \"rounded-ee-sm bg-brand-soft\"\n : \"rounded-es-sm bg-surface-2\",\n )}\n >\n <header className=\"mb-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-caption text-muted\">\n {author != null && (\n <span data-private={priv} className=\"font-medium text-secondary\">\n {author}\n </span>\n )}\n {message.staff && (\n <span className=\"rounded border border-subtle bg-surface px-1 text-micro font-medium uppercase tracking-wide text-secondary\">\n {labels.staff}\n </span>\n )}\n {time}\n </header>\n {message.body && (\n <p\n data-private={priv}\n dir=\"auto\"\n className=\"whitespace-pre-wrap break-words text-start text-primary\"\n >\n {message.body}\n </p>\n )}\n {attachments.length > 0 && (\n <ul aria-label={labels.attachments} data-private={priv} className=\"mt-2 flex flex-wrap gap-2\">\n {attachments.map((attachment, index) => (\n <li key={attachment.id ?? `${index}-${attachment.name}`} className=\"min-w-0\">\n {renderAttachment ? (\n renderAttachment(attachment, message)\n ) : (\n <DefaultAttachment attachment={attachment} size={file.size} />\n )}\n </li>\n ))}\n </ul>\n )}\n </article>\n </li>,\n );\n return rows;\n })}\n </ol>\n );\n}\n\nfunction DefaultAttachment({\n attachment,\n size,\n}: {\n attachment: FeedbackThreadAttachment;\n size: (bytes: number) => string;\n}) {\n const { name, url, type } = attachment;\n if (url && type?.startsWith(\"image/\")) return <ImageThumbnail url={url} name={name} />;\n const content = (\n <>\n <Paperclip className=\"size-3.5 shrink-0\" aria-hidden />\n {/* A file name wraps from Large up, as the attachments of the composer do (text\n size §10.17; round 0.34 T1: the sweep read \"export-20…\"). */}\n <span className=\"min-w-0 truncate-until-large\">{name}</span>\n {attachment.size !== undefined && (\n <span className=\"shrink-0 text-muted\">{size(attachment.size)}</span>\n )}\n </>\n );\n const chip =\n \"inline-flex max-w-full items-center gap-1 rounded border border-subtle bg-surface px-2 py-1 text-xs text-secondary\";\n return url ? (\n <a href={url} target=\"_blank\" rel=\"noopener noreferrer\" className={cn(chip, \"hover:bg-hover\")}>\n {content}\n </a>\n ) : (\n <span className={chip}>{content}</span>\n );\n}\n\n/** An image attachment's thumbnail. The box is drawn before the picture arrives —\n * `loading=\"lazy\"` leaves it empty until it nears the viewport, and a URL that has\n * expired never fills it — and an empty bordered square read as a broken layout, not\n * as a picture. So the box carries an image glyph underneath until the picture\n * covers it, and swaps it for a broken-image glyph when the load fails. */\nfunction ImageThumbnail({ url, name }: { url: string; name: string }) {\n // Keyed on the URL, so a message whose attachment is replaced tries the new one.\n const [failedUrl, setFailedUrl] = useState<string | null>(null);\n const failed = failedUrl === url;\n const Glyph = failed ? ImageOff : ImageIcon;\n return (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"relative block h-20 w-20 overflow-hidden rounded border border-subtle bg-surface-2\"\n >\n <Glyph aria-hidden className=\"absolute inset-0 m-auto size-6 text-muted\" />\n {!failed && (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- load/error are resource events, not interactions\n <img\n src={url}\n alt={name}\n loading=\"lazy\"\n onError={() => setFailedUrl(url)}\n className=\"relative h-full w-full object-cover\"\n />\n )}\n {/* The <img> and its alt are gone once it failed; the link still needs a name. */}\n {failed && <span className=\"sr-only\">{name}</span>}\n </a>\n );\n}\n\n/** The time, refreshed once a minute while `active`, so \"2 minutes ago\" does not stay\n * \"just now\" on a page left open. Read in state rather than in render, which must be\n * pure. */\nfunction useMinuteClock(active: boolean): number {\n const [time, setTime] = useState(() => Date.now());\n useEffect(() => {\n if (!active) return;\n const id = setInterval(() => setTime(Date.now()), 60_000);\n return () => clearInterval(id);\n }, [active]);\n return time;\n}\n\n/** The local calendar day as one number (20260926), for \"same day?\" and keys. */\nfunction dayNumber(date: Date): number {\n return date.getFullYear() * 10_000 + (date.getMonth() + 1) * 100 + date.getDate();\n}\n\n/**\n * The day line of `daySeparators` (keksdose G4): \"Today\" / \"Yesterday\" from\n * `Intl.RelativeTimeFormat` (`numeric: \"auto\"`) — the locale's own words, capitalised\n * for a line that stands alone (\"heute\" → \"Heute\"; a script without case is left as\n * is) — else the weekday and date, with the year only when it is not this one.\n *\n * Counted in calendar days, not 24-hour spans: 23:50 yesterday is \"Yesterday\" at\n * 00:10 today.\n */\nfunction DaySeparator({ date, now, locale }: { date: Date; now: number; locale: string | undefined }) {\n const today = new Date(now);\n const days = Math.round(\n (Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) -\n Date.UTC(today.getFullYear(), today.getMonth(), today.getDate())) /\n 86_400_000,\n );\n let label: string;\n if (days === 0 || days === -1) {\n const word = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" }).format(days + 0, \"day\");\n label = word.charAt(0).toLocaleUpperCase(locale) + word.slice(1);\n } else {\n label = formatDate(\n date,\n {\n weekday: \"long\",\n day: \"numeric\",\n month: \"long\",\n ...(date.getFullYear() === today.getFullYear() ? null : { year: \"numeric\" }),\n },\n { locale },\n );\n }\n const y = String(date.getFullYear()).padStart(4, \"0\");\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return (\n <li data-day-separator=\"\" className=\"flex items-center gap-3 py-1 text-xs text-muted\">\n <span aria-hidden className=\"h-px flex-1 bg-[var(--border)]\" />\n <time dateTime={`${y}-${m}-${d}`} className=\"font-medium\">\n {label}\n </time>\n <span aria-hidden className=\"h-px flex-1 bg-[var(--border)]\" />\n </li>\n );\n}\n\nfunction toDate(value: Date | string | number): Date | null {\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\n/* ── Composer ─────────────────────────────────────────────────────────────── */\n\n/** What the composer's attach control takes — {@link FeedbackNoteAttachment} with the\n * labels optional, since the field reads `feedbackAttachment` from the provider, and\n * `onError` the field's own (0.23.0): it is handed the refused file and the limit too\n * (`FeedbackAttachmentErrorInfo`), and a `(kind) => …` handler still fits. Since\n * 0.24.0 also the field's `buttonVariant` / `buttonSize`, for a composer whose row\n * wants smaller or quieter attach buttons than the bordered `md` default. */\nexport type FeedbackComposerAttachment = Omit<FeedbackNoteAttachment, \"labels\" | \"onError\"> & {\n labels?: LabelOverride<FeedbackAttachmentLabels>;\n onError?: FeedbackAttachmentFieldSingleProps[\"onError\"];\n} & Pick<FeedbackAttachmentFieldSingleProps, \"buttonVariant\" | \"buttonSize\">;\n\n/**\n * What a render-prop {@link FeedbackComposerProps.attachmentSlot} is handed (0.24.0,\n * keksdose).\n *\n * keksdose's support chat put `<FeedbackAttachmentField refs>` in the slot and a\n * screenshot pasted into the reply box never reached it: the box is the field's\n * sibling, so the paste bubbles to their common parent — the composer's root — and the\n * field hears it only through `pasteFrom`, which needs that root. The composer kept it\n * to itself, so keksdose wrapped the whole composer in a ref'd `<div>` of its own just\n * to have an element to hand over.\n */\nexport interface FeedbackComposerSlotContext {\n /**\n * The composer's root, round the text box and this slot — the field's `pasteFrom`,\n * as it is: `pasteFrom={slot.root}`.\n *\n * A ref, not the element, because `pasteFrom` is one: the field reads `.current` in\n * an effect, and the slot renders INSIDE this root, so the two are committed together\n * and React attaches the root before any effect of the slot's runs — the first paste\n * after the first paint already lands. The element itself would be `null` on the\n * first render (it does not exist yet) and could only arrive by a second render\n * through state; the ref is the same object every render, so the field's listener is\n * added once and never re-added.\n *\n * With the built-in `attachment` on as well, it listens on this root too: hand the\n * root to one field only, or an image pasted once is attached twice.\n */\n root: RefObject<HTMLElement | null>;\n /** The composer's `pending` — a send is in flight. For the field's `disabled`\n * (keksdose G5b): the message carries the attachments as they were at the press. */\n pending: boolean;\n}\n\nexport interface FeedbackComposerProps {\n /**\n * Send the comment. Return the promise: the box clears when it RESOLVES, and only of\n * what was sent — text typed while it was in flight stays. A rejection keeps\n * everything for a retry (surface the error yourself; the composer stays quiet).\n *\n * `attachment` is the built-in field's one picture. Files the host uploaded ahead\n * (`attachmentSlot`) are the host's state, read by the host here — and `body` may be\n * `\"\"` when `canSend` let an attachments-only message go.\n */\n onSend: (body: string, attachment: File | null) => void | Promise<unknown>;\n /** The send is in flight: a spinner on the button and no second send. */\n pending?: boolean;\n /** Offer one picture with the comment (file, paste or `onCaptureScreenshot`).\n * `true` for the defaults. Left out, the composer is text only. */\n attachment?: boolean | FeedbackComposerAttachment;\n /**\n * The host's own attach control, in the row with Send where the built-in field sits\n * (after it, if both are on) — keksdose G5: its support chat uploads up to N files\n * AHEAD of the send and sends their refs, which one `File` in `onSend` cannot carry.\n * The slot is the host's picker plus the chips of what is uploaded; the upload, the\n * refs and clearing them once `onSend` resolves stay with the host. Pair it with\n * `canSend`.\n *\n * A node, or (0.24.0) a function of {@link FeedbackComposerSlotContext} that returns\n * one — for a field that wants the composer's root as its `pasteFrom`, so a\n * screenshot pasted into the box reaches it, and `pending` for its `disabled`:\n *\n * ```tsx\n * attachmentSlot={({ root, pending }) => (\n * <FeedbackAttachmentField refs pasteFrom={root} disabled={pending} … />\n * )}\n * ```\n *\n * Called once per render of the composer, and not at all while `disabledReason`\n * stands in for it.\n */\n attachmentSlot?: ReactNode | ((slot: FeedbackComposerSlotContext) => ReactNode);\n /**\n * Whether Send is enabled, over the composer's own rule (some text in the box) —\n * for state the composer cannot see, i.e. `attachmentSlot`'s (keksdose G5): `true`\n * with files ready makes an empty draft sendable (`onSend(\"\", null)`), `false` while\n * an upload is still running holds even a written reply back. Left out, the text\n * decides. `pending` blocks a send either way, as does a draft past `maxLength`.\n */\n canSend?: boolean;\n /**\n * Which key sends. `\"mod-enter\"` (default): Ctrl/⌘+Enter, the report dialog's and\n * note editor's shortcut, with plain Enter a new line — feedback is written in\n * paragraphs. `\"enter\"`: the chat way (keksdose G5) — Enter sends, Shift+Enter is a\n * new line, Ctrl/⌘+Enter still sends; an Enter that confirms an IME composition\n * (Japanese, Chinese input) is the IME's, never a send.\n */\n sendOn?: \"mod-enter\" | \"enter\";\n /** Rendered INSTEAD of the composer — the thread is closed, or read-only for this\n * reader. */\n disabledReason?: ReactNode;\n /**\n * Send COMMITS (0.33.1, kastlan's assistant): under a locked {@link WriteLockProvider}\n * Send is disabled the `disabledReason` way — focusable, the lock's reason in its\n * tooltip and description, as on {@link Button}'s `commit` — and neither Enter nor\n * Ctrl/⌘+Enter sends. The box stays editable and the draft stays: nothing in it\n * reaches the server until Send, and the lock may lift. No provider, or an unlocked\n * one: no effect. A {@link CommitScope}: kastlan's assistant answers under the demo\n * and not under a lapsed plan (its backend's 402), so it passes\n * `commit={{ except: [\"demo\"] }}` where it read `useWriteLock` and fed `canSend` and a\n * reason by hand. Not the prop above: that one replaces the box, this one keeps it.\n */\n commit?: CommitScope;\n rows?: number;\n /**\n * The longest draft the box takes, in UTF-16 code units as the browser counts — the\n * server's limit, so a reply too long for it is cut off while it is typed rather than\n * refused by a 422 after the press (keksdose G6: its support replies are capped at\n * 4,000 on the server, and its other text fields already count against that with\n * Textarea's `maxLength` + `showCount` since 0.22; the reply box, a composer, could\n * not). The box's own `maxLength`, so typing and pasting stop at it.\n *\n * {@link FeedbackComposerHandle.insertText} is not stopped by it — the browser limits\n * typing, not a script — and a canned reply is not cut mid-sentence to fit. A draft\n * past the limit therefore holds Send back (whatever `canSend` says, as `pending`\n * does) until it is trimmed; with `showCount` the counter, red at the limit, says by\n * how much.\n */\n maxLength?: number;\n /**\n * A live \"12/4000\" under the box, with `maxLength` — Textarea's `showCount`, the same\n * counter (keksdose G6): the count is part of the box's description, read with it on\n * focus, and a polite live region speaks only on entering the last stretch and at the\n * limit, never per keystroke. Under `size=\"sm\"` the hidden send hint stays the box's\n * description too, before the count. Ignored without `maxLength`.\n */\n showCount?: boolean;\n /** The counter's words — the `characterCount` namespace, as on Textarea. */\n countLabels?: Partial<CharacterCountLabels>;\n /**\n * The box's hint, over the `placeholder` label — keksdose F9: an admin answering a\n * support ticket is asked something else (\"Reply to Anna…\") than a member adding to\n * their own report, and one provider-wide label cannot say both.\n */\n placeholder?: string;\n /**\n * The draft, controlled — for a host that keeps it itself (saves it per ticket,\n * prefills a template). Left out, the composer keeps its own. Either way a send\n * that resolves clears only what was sent: controlled, that is an\n * `onValueChange(\"\")` the host receives like any keystroke, and only if the draft\n * is still the one that went out.\n */\n value?: string;\n /** Every change to the draft — typing, {@link FeedbackComposerHandle.insertText}, the\n * clear after a send. Required to change a controlled `value`. */\n onValueChange?: (value: string) => void;\n /** {@link FeedbackComposerHandle}: put text into the draft from outside (canned-reply\n * chips) or focus the box. */\n ref?: Ref<FeedbackComposerHandle>;\n labels?: LabelOverride<FeedbackComposerLabels>;\n className?: string;\n /**\n * `\"sm\"` for a narrow host — keksdose's assistant launcher, a small floating panel\n * (0.22): a small Send button, and the send hint (\"Enter to send, Shift + Enter for a\n * new line\") hidden from view but kept as the box's description, so a keyboard or\n * screen-reader user still learns the shortcut. Default `\"md\"`.\n */\n size?: \"md\" | \"sm\";\n /**\n * On the composer's root — the box, or the `disabledReason` line in its place —\n * with any `data-*` attribute beside it (keksdose K17). keksdose's assistant tour\n * points at the chat box with `[data-tour=\"assistant-ask\"]`, and a composer that\n * dropped every attribute it was not told about left the anchor nowhere: the\n * assistant kept its hand-built box rather than lose the tour step.\n */\n id?: string;\n /** `data-*` attributes for the root, as `id` — a tour anchor, a test id. */\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined;\n}\n\n/**\n * What a {@link ChatComposer} `ref` holds.\n *\n * keksdose F9: the support admin answers the same five questions all day and wants\n * chips above the box (\"Thanks, fixed in the next release\") that drop their text in\n * where the caret is. A controlled `value` alone cannot do that well — the host sees\n * the string, not the caret, so it could only append — so the composer, which owns\n * the textarea, does the splice.\n */\nexport interface FeedbackComposerHandle {\n /**\n * Insert `text` at the caret, replacing any selection (the caret the box last had:\n * a click on a chip blurs it, and the selection survives the blur), then focus the\n * box with the caret after the inserted text so the reply can go on. Nothing is\n * added around it — put a space or a newline in `text` if the reply needs one. A\n * no-op while `disabledReason` replaces the box.\n */\n insertText: (text: string) => void;\n focus: () => void;\n}\n\nconst noSubscribe = () => () => {};\nconst isApple = () =>\n typeof navigator !== \"undefined\" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent);\n\n/**\n * The answer box under a {@link FeedbackThread}: a textarea, an optional picture,\n * and Send — Ctrl/⌘+Enter sends, the shortcut the report dialog and the note editor\n * use, so the habit carries across the feature. Plain Enter is a new line: feedback is\n * written in paragraphs, unlike a chat — which `sendOn=\"enter\"` is for (keksdose G5).\n *\n * Named for what it is since 0.22 (keksdose K17): the component was never\n * feedback-specific — a textarea, an optional picture or a host's upload slot, Send,\n * `sendOn=\"enter\"` for the chat way — and keksdose's assistant and support chat are\n * chats, not reports. `FeedbackComposer`, its old name, was removed in 0.35 (refactor\n * audit 2026-10, API-6d; deprecated in 0.34); its types keep theirs.\n */\nexport function ChatComposer({\n onSend,\n pending = false,\n attachment,\n attachmentSlot,\n canSend: canSendProp,\n sendOn = \"mod-enter\",\n disabledReason,\n commit,\n rows = 3,\n maxLength,\n showCount,\n countLabels,\n placeholder,\n value,\n onValueChange,\n ref,\n labels: labelsProp,\n className,\n id,\n size = \"md\",\n ...rest\n}: FeedbackComposerProps) {\n const labels = useKitLabels(\"feedbackComposer\", DEFAULT_FEEDBACK_COMPOSER_LABELS, labelsProp);\n // The lock as Send sees it, with its scope (§12.36). Send's Button reads the same\n // through its own `commit`; this holds the keyboard's send back with it.\n const lock = useWriteLock(commit ?? false);\n const rootAttributes = { id, ...dataAttributes(rest) };\n const hintId = useId();\n const [ownDraft, setOwnDraft] = useState(\"\");\n const controlled = value !== undefined;\n const draft = controlled ? value : ownDraft;\n const [file, setFile] = useState<File | null>(null);\n const root = useRef<HTMLDivElement>(null);\n const box = useRef<HTMLTextAreaElement>(null);\n // The draft as of the last commit. The send's `.then` and `insertText` run after\n // renders their closure did not see — text typed while the send was in flight, a\n // second chip clicked before the first one's render — and must not act on a stale\n // string (for a controlled draft there is no updater function to lean on).\n const latest = useRef(draft);\n useLayoutEffect(() => {\n latest.current = draft;\n });\n // Where the caret goes once an inserted text has rendered.\n const caret = useRef<number | null>(null);\n useLayoutEffect(() => {\n const el = box.current;\n if (caret.current === null || !el) return;\n el.focus();\n el.setSelectionRange(caret.current, caret.current);\n caret.current = null;\n });\n\n const setDraft = (next: string) => {\n latest.current = next;\n if (!controlled) setOwnDraft(next);\n onValueChange?.(next);\n };\n\n useImperativeHandle(ref, () => ({\n insertText: (text) => {\n const el = box.current;\n if (!el) return;\n const current = latest.current;\n // A second insert before the first has rendered goes after the first, not at the\n // textarea's not-yet-moved caret. Otherwise the textarea's selection, which may\n // be past the end of a controlled value the host has just shortened: clamp it.\n const pending = caret.current;\n const start = Math.min(pending ?? el.selectionStart ?? current.length, current.length);\n const end = pending ?? Math.max(start, Math.min(el.selectionEnd ?? start, current.length));\n caret.current = start + text.length;\n setDraft(current.slice(0, start) + text + current.slice(end));\n },\n focus: () => box.current?.focus(),\n }));\n // The server snapshot is \"Ctrl\"; the client corrects it after hydration.\n const modifier = useSyncExternalStore(\n noSubscribe,\n () => (isApple() ? \"⌘\" : \"Ctrl\"),\n () => \"Ctrl\",\n );\n\n // The kit's one presence rule (DUP-11): `\"\"` is no reason either, so it keeps the box.\n if (hasContent(disabledReason)) {\n return (\n <p {...rootAttributes} className={cn(\"text-xs text-muted\", className)}>\n {disabledReason}\n </p>\n );\n }\n\n // Longer than `maxLength` only through `insertText` or a controlled value (typing\n // stops at it): the server would refuse it, so it does not go.\n const tooLong = maxLength !== undefined && draft.length > maxLength;\n const canSend = (canSendProp ?? draft.trim().length > 0) && !pending && !tooLong && !lock.locked;\n const send = () => {\n if (!canSend) return;\n const sentDraft = draft;\n const sentFile = file;\n Promise.resolve(onSend(draft.trim(), file))\n .then(() => {\n if (latest.current === sentDraft) setDraft(\"\");\n setFile((current) => (current === sentFile ? null : current));\n })\n .catch(() => {});\n };\n\n const config = attachment === true ? {} : attachment || null;\n // The slot is handed the ref OBJECT, for a field's `pasteFrom`, which reads `.current`\n // in an effect once the root is attached — nothing reads it during this render (see\n // FeedbackComposerSlotContext.root).\n const slot =\n typeof attachmentSlot === \"function\"\n ? // eslint-disable-next-line react-hooks/refs -- handed on for an effect, not read here\n attachmentSlot({ root, pending })\n : attachmentSlot;\n\n return (\n <div {...rootAttributes} ref={root} className={cn(\"space-y-2\", className)}>\n <Textarea\n rows={rows}\n dir=\"auto\"\n aria-label={labels.field}\n // Textarea puts the counter's description after this one, so under \"sm\" the box\n // reads \"Enter to send… 12 of 4000 characters\".\n aria-describedby={size === \"sm\" ? hintId : undefined}\n maxLength={maxLength}\n // Passed only when given: Textarea keeps a wrapper for a `showCount` it was\n // handed at all, and a composer without one keeps the DOM it had.\n {...(showCount !== undefined ? { showCount } : null)}\n countLabels={countLabels}\n ref={box}\n placeholder={placeholder ?? labels.placeholder}\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\") return;\n const mod = event.ctrlKey || event.metaKey;\n // Under \"enter\": plain Enter sends, Shift+Enter falls through to the\n // textarea's new line, and an Enter that ends an IME composition is the\n // IME's (keyCode 229 is how Safari reports it after the composition ended).\n const chat =\n sendOn === \"enter\" &&\n !event.shiftKey &&\n !event.altKey &&\n !event.nativeEvent.isComposing &&\n event.keyCode !== 229;\n if (mod || chat) {\n event.preventDefault();\n send();\n }\n }}\n />\n <div className=\"flex flex-wrap items-end justify-between gap-2\">\n {config || slot != null ? (\n <div className=\"flex min-w-0 flex-wrap items-end gap-2\">\n {config && (\n <FeedbackAttachmentField\n value={file}\n onChange={setFile}\n labels={config.labels}\n accept={config.accept}\n maxBytes={config.maxBytes}\n onError={config.onError}\n onCaptureScreenshot={config.onCaptureScreenshot}\n buttonVariant={config.buttonVariant}\n buttonSize={config.buttonSize}\n // The box is this field's sibling; a paste in it bubbles to `root`.\n pasteFrom={root}\n />\n )}\n {slot}\n </div>\n ) : (\n <span />\n )}\n <div className=\"ms-auto flex items-center gap-2\">\n <span\n id={hintId}\n className={size === \"sm\" ? \"sr-only\" : \"text-xs text-placeholder\"}\n >\n {sendOn === \"enter\" ? labels.sendHintEnter : labels.sendHint(modifier)}\n </span>\n <Button\n onClick={send}\n disabled={!canSend}\n commit={commit}\n aria-busy={pending || undefined}\n size={size === \"sm\" ? \"sm\" : undefined}\n >\n {pending ? (\n <Spinner label={null} className=\"size-4\" />\n ) : (\n <Send className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n )}\n {labels.send}\n </Button>\n </div>\n </div>\n </div>\n );\n}\n\n/** The `data-*` entries of a rest-props object, and nothing else: whatever a caller\n * spread in that the composer does not know is not the root's to receive. */\nfunction dataAttributes(props: object): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) if (key.startsWith(\"data-\")) out[key] = value;\n return out;\n}\n\n/** {@link FeedbackComposerProps}, for {@link ChatComposer}. */\nexport type ChatComposerProps = FeedbackComposerProps;\n/** {@link FeedbackComposerHandle}, for {@link ChatComposer}. */\nexport type ChatComposerHandle = FeedbackComposerHandle;\n/** {@link FeedbackComposerLabels}, for {@link ChatComposer} — still the `feedbackComposer`\n * namespace of the provider. */\nexport type ChatComposerLabels = FeedbackComposerLabels;\n/** {@link FeedbackComposerSlotContext}, for {@link ChatComposer}'s `attachmentSlot`. */\nexport type ChatComposerSlotContext = FeedbackComposerSlotContext;\n"],"mappings":";AA+MW,SAsIP,UAtIO,KAqDC,YArDD;AA/MX,SAAS,WAAW,OAAO,qBAAqB,iBAAiB,QAAQ,UAAU,4BAA4B;AAE/G,SAAS,WAAW,UAAU,WAAW,YAAY;AACrD,SAAS,UAAU;AACnB,SAAS,YAAY,0BAA0B;AAC/C,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAEzB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAE7B,SAAS,kBAAkB,cAAc,oBAAwC;AACjF,SAAS,+BAA+B;AAIxC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAmKA,SAAS,eAAe;AAAA,EAC7B;AA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EzC,oBAAC,QAAK,WAAU,2BAA0B,eAAW,MAAC;AAAA,cAEvD,OAAO;AAAA;AAAA;AAAA,QACV;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;AAIA,SAAS,eAAe,OAAwC;AAC9D,QAAM,MAA+B,CAAC;AACtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,IAAI,WAAW,OAAO,EAAG,KAAI,GAAG,IAAI;AAC1F,SAAO;AACT;","names":["index","pending"]}
@@ -1,4 +1,11 @@
1
1
  import type { KeyboardEvent as ReactKeyboardEvent, RefObject } from "react";
2
+ /** A layer's handler, read through a ref so the stack holds one stable entry per open. */
3
+ interface Layer {
4
+ escape: (e: KeyboardEvent) => void;
5
+ }
6
+ /** What {@link useDismissLayer} hands back: its layer while open, for
7
+ * {@link runOwnKeyDown} to tell whether that layer is the one on top. */
8
+ export type DismissLayer = RefObject<Layer | null>;
2
9
  /**
3
10
  * An Escape layer on the stack while `open`: the topmost layer is handed the next
4
11
  * Escape and calls `onEscape`, every layer under it waits its turn. A list opened inside
@@ -7,9 +14,9 @@ import type { KeyboardEvent as ReactKeyboardEvent, RefObject } from "react";
7
14
  * Where focus can be INSIDE the layer, its element's `onKeyDown` calls
8
15
  * {@link takeEscape} too, so the key stops there — see the module note. `onEscape` is
9
16
  * read live, so it need not be memoised; the layer is pushed and popped only when
10
- * `open` flips.
17
+ * `open` flips. The layer it returns is for the owner's {@link runOwnKeyDown}.
11
18
  */
12
- export declare function useDismissLayer(open: boolean, onEscape: (e: KeyboardEvent) => void): void;
19
+ export declare function useDismissLayer(open: boolean, onEscape: (e: KeyboardEvent) => void): DismissLayer;
13
20
  /**
14
21
  * For a layer's own element, in its `onKeyDown`: hands an Escape on its way up to the
15
22
  * topmost layer — this one, unless something opened over it without taking focus (a
@@ -27,8 +34,13 @@ export declare function claimEscape(e: KeyboardEvent | ReactKeyboardEvent): void
27
34
  * Runs a layer owner's own key handler — a dialog's `onKeyDown` prop — and turns a
28
35
  * `preventDefault()` it makes on Escape into a claim: the one way, beside
29
36
  * {@link claimEscape}, to keep a layer open.
37
+ *
38
+ * Given the owner's `layer` (what {@link useDismissLayer} returned), an Escape that went
39
+ * down while another layer was above that one skips the handler: the press is the
40
+ * layer's on top, and the owner hears the next (0.35, KS). Without it, or while the
41
+ * owner's layer is not open, the handler sees every key, as before.
30
42
  */
31
- export declare function runOwnKeyDown<E extends ReactKeyboardEvent>(e: E, handler: ((e: E) => void) | undefined): void;
43
+ export declare function runOwnKeyDown<E extends ReactKeyboardEvent>(e: E, handler: ((e: E) => void) | undefined, layer?: DismissLayer): void;
32
44
  /**
33
45
  * Calls `handler` on an Escape while `enabled` — as an Escape layer. Since 0.34 this is
34
46
  * {@link useDismissLayer} with its arguments the other way round: it hears the key only
@@ -58,3 +70,4 @@ export declare function useEscapeKey(handler: () => void, enabled?: boolean): vo
58
70
  * them.
59
71
  */
60
72
  export declare function useOutsideClick(refs: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[], handler: () => void, enabled?: boolean): void;
73
+ export {};
@@ -43,15 +43,21 @@ function pop(layer) {
43
43
  }
44
44
  function useDismissLayer(open, onEscape) {
45
45
  const handlerRef = useRef(onEscape);
46
+ const layerRef = useRef(null);
46
47
  useEffect(() => {
47
48
  handlerRef.current = onEscape;
48
49
  });
49
50
  useEffect(() => {
50
51
  if (!open || typeof document === "undefined") return;
51
52
  const layer = { escape: (e) => handlerRef.current(e) };
53
+ layerRef.current = layer;
52
54
  push(layer);
53
- return () => pop(layer);
55
+ return () => {
56
+ pop(layer);
57
+ layerRef.current = null;
58
+ };
54
59
  }, [open]);
60
+ return layerRef;
55
61
  }
56
62
  function takeEscape(e) {
57
63
  return handOver(e, true);
@@ -60,12 +66,18 @@ function claimEscape(e) {
60
66
  claimed.add(nativeOf(e));
61
67
  e.preventDefault();
62
68
  }
63
- function runOwnKeyDown(e, handler) {
69
+ function runOwnKeyDown(e, handler, layer) {
64
70
  if (!handler) return;
71
+ if (layer && aboveOwner(e, layer.current)) return;
65
72
  const before = e.defaultPrevented;
66
73
  handler(e);
67
74
  if (e.key === "Escape" && !before && e.defaultPrevented) claimed.add(nativeOf(e));
68
75
  }
76
+ function aboveOwner(e, owner) {
77
+ const flight = inFlight;
78
+ if (e.key !== "Escape" || !owner || !flight || flight.event !== nativeOf(e)) return false;
79
+ return flight.layer !== owner && layers.includes(owner);
80
+ }
69
81
  function useEscapeKey(handler, enabled = true) {
70
82
  useDismissLayer(enabled, handler);
71
83
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/use-dismiss.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent, RefObject } from \"react\";\nimport { isComposing } from \"../lib/ime\";\n\n/*\n * # One Escape stack (round 0.34 Wave 2, DUP-1)\n *\n * Escape closes the TOPMOST thing on screen, and only that: a list open in a dialog\n * closes and the dialog stays; the next press closes the dialog.\n *\n * \"Who owns Escape\" used to be decided five ways. The anchored pickers listened on the\n * document; Modal, FullBleedDialog, PickerSheet and Popover closed in their own panel's\n * `onKeyDown` and stopped the key; CommandPalette closed without stopping it. A dialog's\n * handler sits earlier on the key's path than any document listener, so Escape in an\n * open list inside a Modal closed the MODAL and threw the form away (BUG-1, sev 4,\n * kastlan's lease dialog), and HoverMenu, the numpad and a tooltip could not be\n * dismissed inside a dialog at all. And Modal and FullBleedDialog disagreed on when a\n * child had \"claimed\" the key: a ChipInput clearing its draft kept a Modal open and\n * closed a FullBleedDialog.\n *\n * Now every overlay and picker pushes a layer while it is open ({@link useDismissLayer}),\n * last in, first out, the way `use-overlay-history` stacks the Back gesture. One\n * capture-phase listener on the document notes which layer is on top as each Escape\n * goes down — before any handler on the page runs, so a layer that closes on the way\n * cannot pass the key on to the one beneath it. That layer, and only that one, is\n * handed the key:\n *\n * - at the first layer element the key passes on its way back up ({@link takeEscape},\n * which Modal's panel, a picker's search box and the rest call from their\n * `onKeyDown`). The key is stopped there, so nothing around the layers — a\n * FloatingPanel, an app's own panel — closes with it;\n * - or, when focus is in none of them (a hover menu, a tooltip, the numpad over its\n * field, a press on the page), at the document once the key has been everywhere else.\n *\n * Layers stack in the order they OPEN, which is the order their effects run. Two that\n * open in the same commit stack child first — the one case that order gets wrong, and\n * one no overlay in the kit does: each opens on a press, after whatever it sits in.\n *\n * ## Claiming the key: one rule\n *\n * An Escape that means \"undo this step\" is not a dismissal: ChipInput clearing its\n * draft, InlineEditField cancelling its edit, the date picker's month grid going back to\n * the days. Those call {@link claimEscape}, and no layer is handed the key. The only\n * other claim is the layer owner's OWN handler — a dialog's `onKeyDown` prop calling\n * `preventDefault()` on Escape (a busy reauth dialog holding itself open, Kurvenschmiede's\n * gear wizard asking first), through {@link runOwnKeyDown}. A `preventDefault()`\n * anywhere else claims nothing: a search box keeping Chromium from clearing itself\n * must not hold a dialog open (FullBleedDialog's 0.8.0 fix, which Modal never had).\n *\n * A handler that STOPS the key before it reaches a layer element has taken it too —\n * that is the DOM, and it is what the kit's cell editors and confirm buttons do.\n */\n\n/** A layer's handler, read through a ref so the stack holds one stable entry per open. */\ninterface Layer {\n escape: (e: KeyboardEvent) => void;\n}\n\n/** Open layers, oldest first. Module-level, because the order is ACROSS instances. */\nconst layers: Layer[] = [];\n\n/** Escapes a claimant has taken — see {@link claimEscape}. Weak: an event is garbage\n * once its dispatch is over. */\nconst claimed = new WeakSet<Event>();\n\n/** The Escape on its way through the page: the layer that was topmost as it went down,\n * and whether that layer has been handed it yet. */\nlet inFlight: { event: KeyboardEvent; layer: Layer; done: boolean } | null = null;\n\nfunction nativeOf(e: KeyboardEvent | ReactKeyboardEvent): KeyboardEvent {\n return \"nativeEvent\" in e ? e.nativeEvent : e;\n}\n\nfunction onCapture(e: KeyboardEvent): void {\n if (e.key !== \"Escape\") return;\n // An Escape inside an IME composition cancels the composition and nothing else.\n const top = isComposing(e) ? undefined : layers[layers.length - 1];\n inFlight = top ? { event: e, layer: top, done: false } : null;\n}\n\n/** The fallback: no layer element was on the key's path, or none took it. */\nfunction onBubble(e: KeyboardEvent): void {\n handOver(e, false);\n}\n\nfunction handOver(e: KeyboardEvent | ReactKeyboardEvent, stop: boolean): boolean {\n const native = nativeOf(e);\n const flight = inFlight;\n if (native.key !== \"Escape\" || !flight || flight.event !== native || flight.done) return false;\n if (claimed.has(native)) return false;\n flight.done = true;\n // Consumed: a type=\"search\" box does not clear itself as well, and a handler further\n // out that checks `defaultPrevented` (FloatingPanel, an app's own panel) leaves it.\n e.preventDefault();\n if (stop) e.stopPropagation();\n // A layer that closed on the way, by a handler of its own, has had its Escape.\n if (layers.includes(flight.layer)) flight.layer.escape(native);\n return true;\n}\n\nfunction push(layer: Layer): void {\n if (layers.length === 0) {\n document.addEventListener(\"keydown\", onCapture, true);\n document.addEventListener(\"keydown\", onBubble);\n }\n layers.push(layer);\n}\n\nfunction pop(layer: Layer): void {\n const at = layers.indexOf(layer);\n if (at >= 0) layers.splice(at, 1);\n if (layers.length > 0) return;\n document.removeEventListener(\"keydown\", onCapture, true);\n document.removeEventListener(\"keydown\", onBubble);\n inFlight = null;\n}\n\n/**\n * An Escape layer on the stack while `open`: the topmost layer is handed the next\n * Escape and calls `onEscape`, every layer under it waits its turn. A list opened inside\n * a dialog is above the dialog; a popover opened from a list, above the list.\n *\n * Where focus can be INSIDE the layer, its element's `onKeyDown` calls\n * {@link takeEscape} too, so the key stops there — see the module note. `onEscape` is\n * read live, so it need not be memoised; the layer is pushed and popped only when\n * `open` flips.\n */\nexport function useDismissLayer(open: boolean, onEscape: (e: KeyboardEvent) => void): void {\n const handlerRef = useRef(onEscape);\n // Written in an effect, not during render, so it satisfies react-hooks/refs: a\n // render that React starts and then discards — a transition, a Suspense retry —\n // would otherwise leave this holding a handler from a tree that never committed,\n // and the stack would go on to call it. Keydown events fire after the commit, so\n // the ref is always current by the time one arrives.\n useEffect(() => {\n handlerRef.current = onEscape;\n });\n useEffect(() => {\n if (!open || typeof document === \"undefined\") return;\n const layer: Layer = { escape: (e) => handlerRef.current(e) };\n push(layer);\n return () => pop(layer);\n }, [open]);\n}\n\n/**\n * For a layer's own element, in its `onKeyDown`: hands an Escape on its way up to the\n * topmost layer — this one, unless something opened over it without taking focus (a\n * tooltip, the numpad) — and stops it here. True when it did; false for any other key,\n * a claimed Escape, or one already handed over.\n */\nexport function takeEscape(e: KeyboardEvent | ReactKeyboardEvent): boolean {\n return handOver(e, true);\n}\n\n/**\n * For an Escape that means \"undo this step\", not \"close\": the key is the caller's, and\n * no layer is handed it. `preventDefault()`s it as well, so a handler further out that\n * checks `defaultPrevented` leaves it alone, as before.\n */\nexport function claimEscape(e: KeyboardEvent | ReactKeyboardEvent): void {\n claimed.add(nativeOf(e));\n e.preventDefault();\n}\n\n/**\n * Runs a layer owner's own key handler — a dialog's `onKeyDown` prop — and turns a\n * `preventDefault()` it makes on Escape into a claim: the one way, beside\n * {@link claimEscape}, to keep a layer open.\n */\nexport function runOwnKeyDown<E extends ReactKeyboardEvent>(e: E, handler: ((e: E) => void) | undefined): void {\n if (!handler) return;\n const before = e.defaultPrevented;\n handler(e);\n if (e.key === \"Escape\" && !before && e.defaultPrevented) claimed.add(nativeOf(e));\n}\n\n/**\n * Calls `handler` on an Escape while `enabled` — as an Escape layer. Since 0.34 this is\n * {@link useDismissLayer} with its arguments the other way round: it hears the key only\n * while nothing opened above it, and inside a dialog it no longer loses the key to the\n * dialog (Wave 2, DUP-1). `handler` is read live, so it need not be memoised.\n */\nexport function useEscapeKey(handler: () => void, enabled = true): void {\n useDismissLayer(enabled, handler);\n}\n\n/**\n * Calls `handler` on a press that lands outside every supplied element, while\n * `enabled` — the outside-click-to-close half of the same dismissal story. Pass one\n * ref or several (trigger + panel); a press inside any of them is ignored. Refs and\n * `handler` are read live, so an inline `[triggerRef, panelRef]` array is fine and\n * won't churn the listener.\n *\n * **`pointerdown`, not `mousedown`** — one event covering mouse, touch and pen.\n * This listened for `mousedown` alone, which on a touch platform is a SYNTHESISED\n * event: the browser emits it for most taps, which is why nothing obviously broke,\n * but the synthesis is not guaranteed. A tap that begins a scroll, or one that lands\n * on an element which preventDefaults the touch sequence, may never produce one — and\n * on a phone-first PWA whose pickers, menus and flyouts all dismiss through this hook,\n * inheriting that is worse than choosing it.\n *\n * The one behaviour this changes deliberately: a touch-drag that starts outside an\n * open panel now dismisses it at touch-down, where before it did not dismiss at all\n * (a drag synthesises no mousedown). That matches every other platform surface, and\n * the anchored panels re-measure on scroll precisely because the page moves under\n * them.\n */\nexport function useOutsideClick(\n refs: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[],\n handler: () => void,\n enabled = true,\n): void {\n const refsRef = useRef(refs);\n const handlerRef = useRef(handler);\n // In an effect rather than during render — see the note in useDismissLayer.\n useEffect(() => {\n refsRef.current = refs;\n handlerRef.current = handler;\n });\n useEffect(() => {\n if (!enabled) return;\n const onPointerDown = (e: Event) => {\n const target = e.target as Node;\n const list = Array.isArray(refsRef.current) ? refsRef.current : [refsRef.current];\n for (const r of list) {\n if (r.current?.contains(target)) return;\n }\n handlerRef.current();\n };\n document.addEventListener(\"pointerdown\", onPointerDown);\n return () => document.removeEventListener(\"pointerdown\", onPointerDown);\n }, [enabled]);\n}\n"],"mappings":";AAAA,SAAS,WAAW,cAAc;AAElC,SAAS,mBAAmB;AAyD5B,MAAM,SAAkB,CAAC;AAIzB,MAAM,UAAU,oBAAI,QAAe;AAInC,IAAI,WAAyE;AAE7E,SAAS,SAAS,GAAsD;AACtE,SAAO,iBAAiB,IAAI,EAAE,cAAc;AAC9C;AAEA,SAAS,UAAU,GAAwB;AACzC,MAAI,EAAE,QAAQ,SAAU;AAExB,QAAM,MAAM,YAAY,CAAC,IAAI,SAAY,OAAO,OAAO,SAAS,CAAC;AACjE,aAAW,MAAM,EAAE,OAAO,GAAG,OAAO,KAAK,MAAM,MAAM,IAAI;AAC3D;AAGA,SAAS,SAAS,GAAwB;AACxC,WAAS,GAAG,KAAK;AACnB;AAEA,SAAS,SAAS,GAAuC,MAAwB;AAC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,SAA6C;AAC7G,MAAI,CAAC,QAAS;AACd,QAAM,SAAS,EAAE;AACjB,UAAQ,CAAC;AACT,MAAI,EAAE,QAAQ,YAAY,CAAC,UAAU,EAAE,iBAAkB,SAAQ,IAAI,SAAS,CAAC,CAAC;AAClF;AAQO,SAAS,aAAa,SAAqB,UAAU,MAAY;AACtE,kBAAgB,SAAS,OAAO;AAClC;AAuBO,SAAS,gBACd,MACA,SACA,UAAU,MACJ;AACN,QAAM,UAAU,OAAO,IAAI;AAC3B,QAAM,aAAa,OAAO,OAAO;AAEjC,YAAU,MAAM;AACd,YAAQ,UAAU;AAClB,eAAW,UAAU;AAAA,EACvB,CAAC;AACD,YAAU,MAAM;AACd,QAAI,CAAC,QAAS;AACd,UAAM,gBAAgB,CAAC,MAAa;AAClC,YAAM,SAAS,EAAE;AACjB,YAAM,OAAO,MAAM,QAAQ,QAAQ,OAAO,IAAI,QAAQ,UAAU,CAAC,QAAQ,OAAO;AAChF,iBAAW,KAAK,MAAM;AACpB,YAAI,EAAE,SAAS,SAAS,MAAM,EAAG;AAAA,MACnC;AACA,iBAAW,QAAQ;AAAA,IACrB;AACA,aAAS,iBAAiB,eAAe,aAAa;AACtD,WAAO,MAAM,SAAS,oBAAoB,eAAe,aAAa;AAAA,EACxE,GAAG,CAAC,OAAO,CAAC;AACd;","names":[]}
1
+ {"version":3,"sources":["../../src/hooks/use-dismiss.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent, RefObject } from \"react\";\nimport { isComposing } from \"../lib/ime\";\n\n/*\n * # One Escape stack (round 0.34 Wave 2, DUP-1)\n *\n * Escape closes the TOPMOST thing on screen, and only that: a list open in a dialog\n * closes and the dialog stays; the next press closes the dialog.\n *\n * \"Who owns Escape\" used to be decided five ways. The anchored pickers listened on the\n * document; Modal, FullBleedDialog, PickerSheet and Popover closed in their own panel's\n * `onKeyDown` and stopped the key; CommandPalette closed without stopping it. A dialog's\n * handler sits earlier on the key's path than any document listener, so Escape in an\n * open list inside a Modal closed the MODAL and threw the form away (BUG-1, sev 4,\n * kastlan's lease dialog), and HoverMenu, the numpad and a tooltip could not be\n * dismissed inside a dialog at all. And Modal and FullBleedDialog disagreed on when a\n * child had \"claimed\" the key: a ChipInput clearing its draft kept a Modal open and\n * closed a FullBleedDialog.\n *\n * Now every overlay and picker pushes a layer while it is open ({@link useDismissLayer}),\n * last in, first out, the way `use-overlay-history` stacks the Back gesture. One\n * capture-phase listener on the document notes which layer is on top as each Escape\n * goes down — before any handler on the page runs, so a layer that closes on the way\n * cannot pass the key on to the one beneath it. That layer, and only that one, is\n * handed the key:\n *\n * - at the first layer element the key passes on its way back up ({@link takeEscape},\n * which Modal's panel, a picker's search box and the rest call from their\n * `onKeyDown`). The key is stopped there, so nothing around the layers — a\n * FloatingPanel, an app's own panel — closes with it;\n * - or, when focus is in none of them (a hover menu, a tooltip, the numpad over its\n * field, a press on the page), at the document once the key has been everywhere else.\n *\n * Layers stack in the order they OPEN, which is the order their effects run. Two that\n * open in the same commit stack child first — the one case that order gets wrong, and\n * one no overlay in the kit does: each opens on a press, after whatever it sits in.\n *\n * ## Claiming the key: one rule\n *\n * An Escape that means \"undo this step\" is not a dismissal: ChipInput clearing its\n * draft, InlineEditField cancelling its edit, the date picker's month grid going back to\n * the days. Those call {@link claimEscape}, and no layer is handed the key. The only\n * other claim is the layer owner's OWN handler — a dialog's `onKeyDown` prop calling\n * `preventDefault()` on Escape (a busy reauth dialog holding itself open, Kurvenschmiede's\n * gear wizard asking first), through {@link runOwnKeyDown}. A `preventDefault()`\n * anywhere else claims nothing: a search box keeping Chromium from clearing itself\n * must not hold a dialog open (FullBleedDialog's 0.8.0 fix, which Modal never had).\n *\n * The owner's handler hears Escape only while its own layer is on top (0.35, KS). It\n * runs before the stack is asked, so with a tooltip, a hover menu or a list open over\n * the dialog and focus on the panel, the gear wizard asked \"Discard this gear?\" and the\n * tooltip stayed. Now the layer above takes that press, and the next one is the\n * owner's. Every other key reaches the handler as before.\n *\n * A handler that STOPS the key before it reaches a layer element has taken it too —\n * that is the DOM, and it is what the kit's cell editors and confirm buttons do.\n */\n\n/** A layer's handler, read through a ref so the stack holds one stable entry per open. */\ninterface Layer {\n escape: (e: KeyboardEvent) => void;\n}\n\n/** What {@link useDismissLayer} hands back: its layer while open, for\n * {@link runOwnKeyDown} to tell whether that layer is the one on top. */\nexport type DismissLayer = RefObject<Layer | null>;\n\n/** Open layers, oldest first. Module-level, because the order is ACROSS instances. */\nconst layers: Layer[] = [];\n\n/** Escapes a claimant has taken — see {@link claimEscape}. Weak: an event is garbage\n * once its dispatch is over. */\nconst claimed = new WeakSet<Event>();\n\n/** The Escape on its way through the page: the layer that was topmost as it went down,\n * and whether that layer has been handed it yet. */\nlet inFlight: { event: KeyboardEvent; layer: Layer; done: boolean } | null = null;\n\nfunction nativeOf(e: KeyboardEvent | ReactKeyboardEvent): KeyboardEvent {\n return \"nativeEvent\" in e ? e.nativeEvent : e;\n}\n\nfunction onCapture(e: KeyboardEvent): void {\n if (e.key !== \"Escape\") return;\n // An Escape inside an IME composition cancels the composition and nothing else.\n const top = isComposing(e) ? undefined : layers[layers.length - 1];\n inFlight = top ? { event: e, layer: top, done: false } : null;\n}\n\n/** The fallback: no layer element was on the key's path, or none took it. */\nfunction onBubble(e: KeyboardEvent): void {\n handOver(e, false);\n}\n\nfunction handOver(e: KeyboardEvent | ReactKeyboardEvent, stop: boolean): boolean {\n const native = nativeOf(e);\n const flight = inFlight;\n if (native.key !== \"Escape\" || !flight || flight.event !== native || flight.done) return false;\n if (claimed.has(native)) return false;\n flight.done = true;\n // Consumed: a type=\"search\" box does not clear itself as well, and a handler further\n // out that checks `defaultPrevented` (FloatingPanel, an app's own panel) leaves it.\n e.preventDefault();\n if (stop) e.stopPropagation();\n // A layer that closed on the way, by a handler of its own, has had its Escape.\n if (layers.includes(flight.layer)) flight.layer.escape(native);\n return true;\n}\n\nfunction push(layer: Layer): void {\n if (layers.length === 0) {\n document.addEventListener(\"keydown\", onCapture, true);\n document.addEventListener(\"keydown\", onBubble);\n }\n layers.push(layer);\n}\n\nfunction pop(layer: Layer): void {\n const at = layers.indexOf(layer);\n if (at >= 0) layers.splice(at, 1);\n if (layers.length > 0) return;\n document.removeEventListener(\"keydown\", onCapture, true);\n document.removeEventListener(\"keydown\", onBubble);\n inFlight = null;\n}\n\n/**\n * An Escape layer on the stack while `open`: the topmost layer is handed the next\n * Escape and calls `onEscape`, every layer under it waits its turn. A list opened inside\n * a dialog is above the dialog; a popover opened from a list, above the list.\n *\n * Where focus can be INSIDE the layer, its element's `onKeyDown` calls\n * {@link takeEscape} too, so the key stops there — see the module note. `onEscape` is\n * read live, so it need not be memoised; the layer is pushed and popped only when\n * `open` flips. The layer it returns is for the owner's {@link runOwnKeyDown}.\n */\nexport function useDismissLayer(open: boolean, onEscape: (e: KeyboardEvent) => void): DismissLayer {\n const handlerRef = useRef(onEscape);\n const layerRef = useRef<Layer | null>(null);\n // Written in an effect, not during render, so it satisfies react-hooks/refs: a\n // render that React starts and then discards — a transition, a Suspense retry —\n // would otherwise leave this holding a handler from a tree that never committed,\n // and the stack would go on to call it. Keydown events fire after the commit, so\n // the ref is always current by the time one arrives.\n useEffect(() => {\n handlerRef.current = onEscape;\n });\n useEffect(() => {\n if (!open || typeof document === \"undefined\") return;\n const layer: Layer = { escape: (e) => handlerRef.current(e) };\n layerRef.current = layer;\n push(layer);\n return () => {\n pop(layer);\n layerRef.current = null;\n };\n }, [open]);\n return layerRef;\n}\n\n/**\n * For a layer's own element, in its `onKeyDown`: hands an Escape on its way up to the\n * topmost layer — this one, unless something opened over it without taking focus (a\n * tooltip, the numpad) — and stops it here. True when it did; false for any other key,\n * a claimed Escape, or one already handed over.\n */\nexport function takeEscape(e: KeyboardEvent | ReactKeyboardEvent): boolean {\n return handOver(e, true);\n}\n\n/**\n * For an Escape that means \"undo this step\", not \"close\": the key is the caller's, and\n * no layer is handed it. `preventDefault()`s it as well, so a handler further out that\n * checks `defaultPrevented` leaves it alone, as before.\n */\nexport function claimEscape(e: KeyboardEvent | ReactKeyboardEvent): void {\n claimed.add(nativeOf(e));\n e.preventDefault();\n}\n\n/**\n * Runs a layer owner's own key handler — a dialog's `onKeyDown` prop — and turns a\n * `preventDefault()` it makes on Escape into a claim: the one way, beside\n * {@link claimEscape}, to keep a layer open.\n *\n * Given the owner's `layer` (what {@link useDismissLayer} returned), an Escape that went\n * down while another layer was above that one skips the handler: the press is the\n * layer's on top, and the owner hears the next (0.35, KS). Without it, or while the\n * owner's layer is not open, the handler sees every key, as before.\n */\nexport function runOwnKeyDown<E extends ReactKeyboardEvent>(\n e: E,\n handler: ((e: E) => void) | undefined,\n layer?: DismissLayer,\n): void {\n if (!handler) return;\n if (layer && aboveOwner(e, layer.current)) return;\n const before = e.defaultPrevented;\n handler(e);\n if (e.key === \"Escape\" && !before && e.defaultPrevented) claimed.add(nativeOf(e));\n}\n\n/** Whether this Escape went down with a layer above `owner` — the topmost one then was\n * another, and `owner` is on the stack. An Escape the stack did not note (one inside an\n * IME composition) is nobody else's. */\nfunction aboveOwner(e: ReactKeyboardEvent, owner: Layer | null): boolean {\n const flight = inFlight;\n if (e.key !== \"Escape\" || !owner || !flight || flight.event !== nativeOf(e)) return false;\n return flight.layer !== owner && layers.includes(owner);\n}\n\n/**\n * Calls `handler` on an Escape while `enabled` — as an Escape layer. Since 0.34 this is\n * {@link useDismissLayer} with its arguments the other way round: it hears the key only\n * while nothing opened above it, and inside a dialog it no longer loses the key to the\n * dialog (Wave 2, DUP-1). `handler` is read live, so it need not be memoised.\n */\nexport function useEscapeKey(handler: () => void, enabled = true): void {\n useDismissLayer(enabled, handler);\n}\n\n/**\n * Calls `handler` on a press that lands outside every supplied element, while\n * `enabled` — the outside-click-to-close half of the same dismissal story. Pass one\n * ref or several (trigger + panel); a press inside any of them is ignored. Refs and\n * `handler` are read live, so an inline `[triggerRef, panelRef]` array is fine and\n * won't churn the listener.\n *\n * **`pointerdown`, not `mousedown`** — one event covering mouse, touch and pen.\n * This listened for `mousedown` alone, which on a touch platform is a SYNTHESISED\n * event: the browser emits it for most taps, which is why nothing obviously broke,\n * but the synthesis is not guaranteed. A tap that begins a scroll, or one that lands\n * on an element which preventDefaults the touch sequence, may never produce one — and\n * on a phone-first PWA whose pickers, menus and flyouts all dismiss through this hook,\n * inheriting that is worse than choosing it.\n *\n * The one behaviour this changes deliberately: a touch-drag that starts outside an\n * open panel now dismisses it at touch-down, where before it did not dismiss at all\n * (a drag synthesises no mousedown). That matches every other platform surface, and\n * the anchored panels re-measure on scroll precisely because the page moves under\n * them.\n */\nexport function useOutsideClick(\n refs: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[],\n handler: () => void,\n enabled = true,\n): void {\n const refsRef = useRef(refs);\n const handlerRef = useRef(handler);\n // In an effect rather than during render — see the note in useDismissLayer.\n useEffect(() => {\n refsRef.current = refs;\n handlerRef.current = handler;\n });\n useEffect(() => {\n if (!enabled) return;\n const onPointerDown = (e: Event) => {\n const target = e.target as Node;\n const list = Array.isArray(refsRef.current) ? refsRef.current : [refsRef.current];\n for (const r of list) {\n if (r.current?.contains(target)) return;\n }\n handlerRef.current();\n };\n document.addEventListener(\"pointerdown\", onPointerDown);\n return () => document.removeEventListener(\"pointerdown\", onPointerDown);\n }, [enabled]);\n}\n"],"mappings":";AAAA,SAAS,WAAW,cAAc;AAElC,SAAS,mBAAmB;AAmE5B,MAAM,SAAkB,CAAC;AAIzB,MAAM,UAAU,oBAAI,QAAe;AAInC,IAAI,WAAyE;AAE7E,SAAS,SAAS,GAAsD;AACtE,SAAO,iBAAiB,IAAI,EAAE,cAAc;AAC9C;AAEA,SAAS,UAAU,GAAwB;AACzC,MAAI,EAAE,QAAQ,SAAU;AAExB,QAAM,MAAM,YAAY,CAAC,IAAI,SAAY,OAAO,OAAO,SAAS,CAAC;AACjE,aAAW,MAAM,EAAE,OAAO,GAAG,OAAO,KAAK,MAAM,MAAM,IAAI;AAC3D;AAGA,SAAS,SAAS,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}
@@ -562,10 +562,20 @@ export interface UiKitProviderProps {
562
562
  * the language.
563
563
  */
564
564
  export declare function UiKitProvider({ labels, locale, weekStartsOn, linkComponent, chartTooltipPlacement, formatDate, tableStorageKeyPrefix, children, }: UiKitProviderProps): import("react").JSX.Element;
565
- /** What the nearest provider says about one namespace — `undefined` outside one.
566
- * For a component whose own resolver does more than a merge (the data table
567
- * derives `columnsCount` from `columns`): feed `{ ...overrides, ...props }` to it. */
568
- export declare function useKitLabelOverrides<K extends keyof UiKitLabels>(ns: K): Partial<UiKitLabels[K]> | undefined;
565
+ /**
566
+ * What the nearest provider says about one namespace — `undefined` outside one. Nested
567
+ * providers' words come merged, at every depth; no English default is filled in.
568
+ *
569
+ * A {@link LabelOverride}, partial at every depth, like the components' `labels` props
570
+ * that take it: a provider that names one key of a section (`accountSettings.passkeys`)
571
+ * or one preset (`dataTable.presets`) hands over just that (round 0.35 R3 — until then
572
+ * it was typed partial at the top only, so a nested section read as complete).
573
+ *
574
+ * For a component whose own resolver does more than a merge (the data table derives
575
+ * `columnsCount` from `columns`): merge the component's prop over it — a record key by
576
+ * key — and feed the result to that resolver.
577
+ */
578
+ export declare function useKitLabelOverrides<K extends keyof UiKitLabels>(ns: K): LabelOverride<UiKitLabels[K]> | undefined;
569
579
  /**
570
580
  * One namespace, resolved: `defaults`, then the provider, then the component's own
571
581
  * `prop`. Record-valued keys are merged key by key at each step — so `prop` is a