@eifi1/ui-kit 0.46.1 → 0.48.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 (216) hide show
  1. package/README.md +8 -6
  2. package/dist/admin/admin-sections.d.ts +8 -0
  3. package/dist/admin/admin-sections.js +2 -1
  4. package/dist/admin/admin-sections.js.map +1 -1
  5. package/dist/auth/verify-email.d.ts +9 -1
  6. package/dist/auth/verify-email.js +22 -13
  7. package/dist/auth/verify-email.js.map +1 -1
  8. package/dist/components/alert-banner.d.ts +29 -1
  9. package/dist/components/alert-banner.js +84 -7
  10. package/dist/components/alert-banner.js.map +1 -1
  11. package/dist/components/button-look.d.ts +4 -0
  12. package/dist/components/button-look.js +2 -0
  13. package/dist/components/button-look.js.map +1 -1
  14. package/dist/components/combobox-core.js +5 -1
  15. package/dist/components/combobox-core.js.map +1 -1
  16. package/dist/components/data-table-column-settings.d.ts +6 -1
  17. package/dist/components/data-table-column-settings.js +12 -2
  18. package/dist/components/data-table-column-settings.js.map +1 -1
  19. package/dist/components/data-table-fit.d.ts +44 -0
  20. package/dist/components/data-table-fit.js +103 -0
  21. package/dist/components/data-table-fit.js.map +1 -0
  22. package/dist/components/data-table-groups.d.ts +95 -0
  23. package/dist/components/data-table-groups.js +165 -0
  24. package/dist/components/data-table-groups.js.map +1 -0
  25. package/dist/components/data-table-head.js +3 -1
  26. package/dist/components/data-table-head.js.map +1 -1
  27. package/dist/components/data-table-labels.d.ts +7 -0
  28. package/dist/components/data-table-labels.js +3 -0
  29. package/dist/components/data-table-labels.js.map +1 -1
  30. package/dist/components/data-table-leading-row.d.ts +17 -0
  31. package/dist/components/data-table-leading-row.js +41 -0
  32. package/dist/components/data-table-leading-row.js.map +1 -0
  33. package/dist/components/data-table-resize.js +1 -1
  34. package/dist/components/data-table-resize.js.map +1 -1
  35. package/dist/components/data-table.d.ts +78 -2
  36. package/dist/components/data-table.js +355 -247
  37. package/dist/components/data-table.js.map +1 -1
  38. package/dist/components/disclosure.d.ts +3 -1
  39. package/dist/components/disclosure.js +10 -4
  40. package/dist/components/disclosure.js.map +1 -1
  41. package/dist/components/dropdown.js +8 -1
  42. package/dist/components/dropdown.js.map +1 -1
  43. package/dist/components/floating-panel.d.ts +14 -1
  44. package/dist/components/floating-panel.js +7 -2
  45. package/dist/components/floating-panel.js.map +1 -1
  46. package/dist/components/hover-menu.js +5 -1
  47. package/dist/components/hover-menu.js.map +1 -1
  48. package/dist/components/icon-button.js +2 -1
  49. package/dist/components/icon-button.js.map +1 -1
  50. package/dist/components/popover.js +5 -1
  51. package/dist/components/popover.js.map +1 -1
  52. package/dist/components/row-actions.d.ts +25 -0
  53. package/dist/components/row-actions.js +13 -3
  54. package/dist/components/row-actions.js.map +1 -1
  55. package/dist/components/table-skeleton.d.ts +35 -0
  56. package/dist/components/table-skeleton.js +75 -0
  57. package/dist/components/table-skeleton.js.map +1 -0
  58. package/dist/components/tabs.d.ts +22 -16
  59. package/dist/components/tabs.js +47 -31
  60. package/dist/components/tabs.js.map +1 -1
  61. package/dist/components/ui-labels.js +1 -1
  62. package/dist/components/ui-labels.js.map +1 -1
  63. package/dist/components/use-table-state.d.ts +8 -7
  64. package/dist/components/use-table-state.js +37 -3
  65. package/dist/components/use-table-state.js.map +1 -1
  66. package/dist/data-table.d.ts +1 -0
  67. package/dist/data-table.js.map +1 -1
  68. package/dist/eslint/index.js +1 -1
  69. package/dist/feedback/feedback-attachment-download.d.ts +19 -0
  70. package/dist/feedback/feedback-attachment-download.js +59 -0
  71. package/dist/feedback/feedback-attachment-download.js.map +1 -0
  72. package/dist/feedback/feedback-comment-thread.d.ts +17 -6
  73. package/dist/feedback/feedback-comment-thread.js +21 -2
  74. package/dist/feedback/feedback-comment-thread.js.map +1 -1
  75. package/dist/feedback/feedback-entry-file.d.ts +61 -0
  76. package/dist/feedback/feedback-entry-file.js +76 -0
  77. package/dist/feedback/feedback-entry-file.js.map +1 -0
  78. package/dist/feedback/feedback-public-list.d.ts +18 -5
  79. package/dist/feedback/feedback-public-list.js +8 -0
  80. package/dist/feedback/feedback-public-list.js.map +1 -1
  81. package/dist/feedback/feedback-public-types.d.ts +7 -2
  82. package/dist/feedback/feedback-replies.d.ts +26 -9
  83. package/dist/feedback/feedback-replies.js +20 -10
  84. package/dist/feedback/feedback-replies.js.map +1 -1
  85. package/dist/feedback/feedback-row-detail-labels.js +0 -1
  86. package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
  87. package/dist/feedback/feedback-row-detail.d.ts +23 -10
  88. package/dist/feedback/feedback-row-detail.js +10 -54
  89. package/dist/feedback/feedback-row-detail.js.map +1 -1
  90. package/dist/feedback/feedback-table.d.ts +5 -0
  91. package/dist/feedback/feedback-table.js +30 -7
  92. package/dist/feedback/feedback-table.js.map +1 -1
  93. package/dist/feedback.d.ts +1 -0
  94. package/dist/feedback.js +1 -0
  95. package/dist/feedback.js.map +1 -1
  96. package/dist/hooks/use-dismiss.d.ts +30 -1
  97. package/dist/hooks/use-dismiss.js +30 -2
  98. package/dist/hooks/use-dismiss.js.map +1 -1
  99. package/dist/i18n/german.js +7 -7
  100. package/dist/i18n/german.js.map +1 -1
  101. package/dist/i18n/kit-labels.d.ts +4 -0
  102. package/dist/i18n/kit-labels.js.map +1 -1
  103. package/dist/i18n/locales/en.js +7 -7
  104. package/dist/i18n/locales/en.js.map +2 -2
  105. package/dist/i18n/locales/es.js +7 -7
  106. package/dist/i18n/locales/es.js.map +1 -1
  107. package/dist/i18n/locales/fr.js +7 -7
  108. package/dist/i18n/locales/fr.js.map +1 -1
  109. package/dist/i18n/locales/hu.js +7 -7
  110. package/dist/i18n/locales/hu.js.map +1 -1
  111. package/dist/i18n/locales/it.js +7 -7
  112. package/dist/i18n/locales/it.js.map +1 -1
  113. package/dist/i18n/locales/zh.js +7 -7
  114. package/dist/i18n/locales/zh.js.map +1 -1
  115. package/dist/i18n/review.js +0 -1
  116. package/dist/i18n/review.js.map +1 -1
  117. package/dist/i18n/shared-labels.js +3 -1
  118. package/dist/i18n/shared-labels.js.map +1 -1
  119. package/dist/index.d.ts +4 -4
  120. package/dist/index.js +13 -4
  121. package/dist/index.js.map +1 -1
  122. package/dist/lib/float-clearance.d.ts +8 -0
  123. package/dist/lib/float-clearance.js +29 -0
  124. package/dist/lib/float-clearance.js.map +1 -0
  125. package/dist/notifications/device-zone-report.d.ts +1 -1
  126. package/dist/notifications/device-zone-report.js.map +1 -1
  127. package/dist/notifications/notification-types.d.ts +0 -3
  128. package/dist/notifications/notifications-labels.d.ts +2 -15
  129. package/dist/notifications/notifications-labels.js +0 -4
  130. package/dist/notifications/notifications-labels.js.map +1 -1
  131. package/dist/notifications/quiet-hours-setting.d.ts +3 -8
  132. package/dist/notifications/quiet-hours-setting.js +8 -3
  133. package/dist/notifications/quiet-hours-setting.js.map +1 -1
  134. package/dist/settings/settings-catalogue.d.ts +10 -0
  135. package/dist/settings/settings-catalogue.js.map +1 -1
  136. package/dist/settings/settings-layout.js +10 -3
  137. package/dist/settings/settings-layout.js.map +1 -1
  138. package/dist/shell/app-shell.d.ts +5 -0
  139. package/dist/shell/app-shell.js +5 -3
  140. package/dist/shell/app-shell.js.map +1 -1
  141. package/dist/shell/option-switcher-menu.d.ts +2 -0
  142. package/dist/shell/option-switcher-menu.js +6 -2
  143. package/dist/shell/option-switcher-menu.js.map +1 -1
  144. package/dist/shell/topbar-action-menu.js +2 -1
  145. package/dist/shell/topbar-action-menu.js.map +1 -1
  146. package/dist/shell/topbar-controls.js +5 -3
  147. package/dist/shell/topbar-controls.js.map +1 -1
  148. package/dist/theme/theme-store.d.ts +4 -4
  149. package/dist/theme/theme-store.js +1 -0
  150. package/dist/theme/theme-store.js.map +1 -1
  151. package/dist/tour/tour.js +1 -0
  152. package/dist/tour/tour.js.map +1 -1
  153. package/package.json +2 -2
  154. package/src/admin/admin-sections.tsx +8 -0
  155. package/src/auth/verify-email.tsx +34 -9
  156. package/src/components/alert-banner.tsx +131 -7
  157. package/src/components/button-look.ts +6 -0
  158. package/src/components/combobox-core.tsx +7 -1
  159. package/src/components/data-table-column-settings.tsx +23 -2
  160. package/src/components/data-table-fit.ts +187 -0
  161. package/src/components/data-table-groups.tsx +275 -0
  162. package/src/components/data-table-head.tsx +4 -1
  163. package/src/components/data-table-labels.ts +13 -0
  164. package/src/components/data-table-leading-row.tsx +55 -0
  165. package/src/components/data-table-resize.ts +2 -1
  166. package/src/components/data-table.tsx +274 -45
  167. package/src/components/disclosure.tsx +22 -5
  168. package/src/components/dropdown.tsx +11 -1
  169. package/src/components/floating-panel.tsx +24 -1
  170. package/src/components/hover-menu.tsx +6 -1
  171. package/src/components/icon-button.tsx +3 -3
  172. package/src/components/popover.tsx +7 -1
  173. package/src/components/row-actions.tsx +42 -3
  174. package/src/components/table-skeleton.tsx +133 -0
  175. package/src/components/tabs.tsx +102 -50
  176. package/src/components/ui-labels.ts +1 -1
  177. package/src/components/use-table-state.ts +54 -3
  178. package/src/data-table.ts +2 -0
  179. package/src/feedback/feedback-attachment-download.tsx +77 -0
  180. package/src/feedback/feedback-comment-thread.tsx +42 -7
  181. package/src/feedback/feedback-entry-file.tsx +150 -0
  182. package/src/feedback/feedback-public-list.tsx +25 -4
  183. package/src/feedback/feedback-public-types.ts +7 -2
  184. package/src/feedback/feedback-replies.tsx +46 -19
  185. package/src/feedback/feedback-row-detail-labels.ts +0 -1
  186. package/src/feedback/feedback-row-detail.tsx +35 -86
  187. package/src/feedback/feedback-table.tsx +33 -1
  188. package/src/feedback.ts +1 -0
  189. package/src/hooks/use-dismiss.ts +65 -3
  190. package/src/i18n/german.ts +6 -6
  191. package/src/i18n/kit-labels.tsx +4 -0
  192. package/src/i18n/locales/es.ts +6 -6
  193. package/src/i18n/locales/fr.ts +6 -6
  194. package/src/i18n/locales/hu.ts +6 -6
  195. package/src/i18n/locales/it.ts +6 -6
  196. package/src/i18n/locales/zh.ts +6 -6
  197. package/src/i18n/review.ts +0 -1
  198. package/src/i18n/shared-labels.ts +2 -0
  199. package/src/index.ts +13 -3
  200. package/src/lib/float-clearance.ts +54 -0
  201. package/src/notifications/device-zone-report.ts +1 -1
  202. package/src/notifications/notification-types.ts +0 -3
  203. package/src/notifications/notifications-labels.ts +2 -19
  204. package/src/notifications/quiet-hours-setting.tsx +16 -11
  205. package/src/settings/settings-catalogue.ts +10 -0
  206. package/src/settings/settings-layout.tsx +18 -4
  207. package/src/shell/app-shell.tsx +17 -3
  208. package/src/shell/option-switcher-menu.tsx +16 -4
  209. package/src/shell/topbar-action-menu.tsx +22 -10
  210. package/src/shell/topbar-controls.tsx +18 -12
  211. package/src/theme/theme-store.ts +13 -5
  212. package/src/tour/tour.tsx +5 -0
  213. package/dist/notifications/time-zone-select.d.ts +0 -54
  214. package/dist/notifications/time-zone-select.js +0 -71
  215. package/dist/notifications/time-zone-select.js.map +0 -1
  216. package/src/notifications/time-zone-select.tsx +0 -125
@@ -203,7 +203,9 @@ export interface DisclosureProps extends Omit<ComponentPropsWithRef<"div">, "tit
203
203
  * ```
204
204
  */
205
205
  controls?: string;
206
- /** The body. Not rendered in trigger-only mode ({@link DisclosureProps.controls}). */
206
+ /** The body. Not rendered in trigger-only mode ({@link DisclosureProps.controls}),
207
+ * nor when there is none (0.48): no children, no empty box under the header.
208
+ * `null`, `false`, `undefined` and an empty fragment (`<></>`) count as none. */
207
209
  children?: ReactNode;
208
210
  }
209
211
  /**
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect, useId, useState } from "react";
3
+ import { Children, Fragment, isValidElement, useEffect, useId, useState } from "react";
4
4
  import { ChevronDown } from "lucide-react";
5
5
  import { cn } from "../lib/cn.js";
6
6
  import { FOCUS_RING } from "./focus-ring.js";
@@ -72,7 +72,8 @@ function Disclosure({
72
72
  const chevronAtEnd = chevronAt === "end";
73
73
  const chevronAfterTitle = chevronAt === "after-title";
74
74
  const triggerOnly = controls !== void 0;
75
- const joined = open && !triggerOnly;
75
+ const hasBody = !triggerOnly && hasBodyContent(children);
76
+ const joined = open && hasBody;
76
77
  const hasTrailing = trailing !== void 0 && trailing !== null && trailing !== false;
77
78
  const trailingInside = hasTrailing && trailingInTrigger;
78
79
  const trailingBeside = hasTrailing && !trailingInTrigger;
@@ -88,7 +89,7 @@ function Disclosure({
88
89
  ...extraTriggerProps,
89
90
  type: "button",
90
91
  "aria-expanded": open,
91
- "aria-controls": triggerOnly ? controls || void 0 : bodyId,
92
+ "aria-controls": triggerOnly ? controls || void 0 : hasBody ? bodyId : void 0,
92
93
  disabled,
93
94
  onClick: toggle,
94
95
  "data-disclosure-trigger": "",
@@ -159,7 +160,7 @@ function Disclosure({
159
160
  ]
160
161
  }
161
162
  ) : header,
162
- !triggerOnly && /* @__PURE__ */ jsx(Collapse, { id: bodyId, open, keepMounted, children: /* @__PURE__ */ jsx("div", { className: cn(card ? "space-y-3 px-4 pb-4" : !menu && "space-y-2 pt-2", bodyClassName), children }) })
163
+ hasBody && /* @__PURE__ */ jsx(Collapse, { id: bodyId, open, keepMounted, children: /* @__PURE__ */ jsx("div", { className: cn(card ? "space-y-3 px-4 pb-4" : !menu && "space-y-2 pt-2", bodyClassName), children }) })
163
164
  ]
164
165
  }
165
166
  );
@@ -181,6 +182,11 @@ function Chevron({
181
182
  }
182
183
  );
183
184
  }
185
+ function hasBodyContent(children) {
186
+ return Children.toArray(children).some(
187
+ (child) => isValidElement(child) && child.type === Fragment ? hasBodyContent(child.props.children) : child !== ""
188
+ );
189
+ }
184
190
  export {
185
191
  Collapse,
186
192
  Disclosure
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/disclosure.tsx"],"sourcesContent":["import { useEffect, useId, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactNode } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { FOCUS_RING } from \"./focus-ring\";\n// Read at the moment of closing, as `useCloseTransition` does: the setting can change\n// under a long-lived page.\nimport { skipsExitAnimation } from \"../hooks/use-close-transition\";\n\n/** How long the fold takes, in ms. The same number as the `duration-200` below and as\n * the unmount timer, because they are the same movement. */\nconst COLLAPSE_MS = 200;\n\n/**\n * `extends` the div's props so an `id` (what a trigger's `aria-controls` points at), a\n * `data-tour` anchor or a test id reaches the element that folds.\n */\nexport interface CollapseProps extends ComponentPropsWithRef<\"div\"> {\n open: boolean;\n /**\n * Keep the children mounted while shut (hidden and `inert`) instead of unmounting\n * them once the fold has finished closing.\n *\n * Off by default, and that default is a behaviour contract rather than a\n * performance note: Lenkbank's disclosure bodies FETCH, and a body that only exists\n * while open is what stops a closed card asking — without every caller carrying its\n * own `enabled: open`. On for a body whose state must outlive a close (a half-typed\n * form) or that must be found by the browser's find-in-page.\n */\n keepMounted?: boolean;\n children: ReactNode;\n}\n\n/**\n * The fold on its own: content that opens and shuts in place, animated to a height\n * nobody measured.\n *\n * THE TECHNIQUE is `AppShell`'s sidebar group's, lifted out so there is one copy of it.\n * A `grid-template-rows` transition from `0fr` to `1fr` is the one way to animate to a\n * content-sized height without measuring it — so a chart that resizes inside it, or a\n * translated line that wraps, is still exactly as tall as it needs. `visibility` rides\n * the same transition, so a shut body leaves the accessibility tree only once it has\n * finished closing; `inert` takes it out of the tab order immediately.\n *\n * THE CHILDREN are unmounted once closed (see {@link CollapseProps.keepMounted}), but\n * only once the track has finished closing: the track is what animates, so the\n * children have to survive the movement that hides them. Under reduced motion they\n * go at once — there is no movement to wait for — and the opening half is silenced by\n * `motion-reduce:transition-none`, since tokens.css only silences the overlay\n * animations by name.\n *\n * Padding and margins belong on a child: on this element, or the clipping one inside\n * it, they would hold the row open by that much.\n */\nexport function Collapse({ open, keepMounted = false, children, className, style, ...rest }: CollapseProps) {\n // Whether the children are still on their way out. Adjusted DURING render when\n // `open` flips (React's \"storing information from previous renders\"), so a close\n // under reduced motion unmounts in the same render that shut it — a test, and a\n // screen reader, see the body go on the click — and a re-open mid-fold simply\n // cancels the linger.\n const [lingering, setLingering] = useState(false);\n const [prevOpen, setPrevOpen] = useState(open);\n if (open !== prevOpen) {\n setPrevOpen(open);\n setLingering(!open && !skipsExitAnimation());\n }\n useEffect(() => {\n if (!lingering) return;\n const timer = setTimeout(() => setLingering(false), COLLAPSE_MS);\n return () => clearTimeout(timer);\n }, [lingering]);\n\n const mounted = open || lingering || keepMounted;\n\n return (\n <div\n {...rest}\n inert={!open}\n className={cn(\n \"grid transition-[grid-template-rows,visibility] duration-200 ease-out motion-reduce:transition-none\",\n className,\n )}\n // Inline rather than `grid-rows-[…]` classes: a caller's `className` must not be\n // able to pin the track open, and the two values ARE the state.\n style={{ ...style, gridTemplateRows: open ? \"1fr\" : \"0fr\", visibility: open ? \"visible\" : \"hidden\" }}\n >\n <div\n className={cn(\n \"min-h-0 overflow-hidden transition-opacity duration-200 ease-out motion-reduce:transition-none\",\n open ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n {mounted && children}\n </div>\n </div>\n );\n}\n\n/**\n * What {@link DisclosureProps.triggerProps} may put on the header button: its own\n * attributes and handlers, and any `data-*`. Not the ones the disclosure owns —\n * `aria-expanded`, `aria-controls`, `disabled`, `onClick`, `type` and the content — nor\n * `className`, which is {@link DisclosureProps.headerClassName}.\n */\nexport type DisclosureTriggerProps = Omit<\n ComponentPropsWithoutRef<\"button\">,\n \"type\" | \"aria-expanded\" | \"aria-controls\" | \"disabled\" | \"onClick\" | \"children\" | \"className\"\n> & { [data: `data-${string}`]: string | number | boolean | undefined };\n\n/**\n * `title` is omitted from the div's own props because this component already owns the\n * name: here it is the header's content (and a ReactNode), not the browser's tooltip.\n * Everything else reaches the outer element.\n */\nexport interface DisclosureProps extends Omit<ComponentPropsWithRef<\"div\">, \"title\"> {\n /** What the header says. A node, so a status chip or a count can sit in it. */\n title: ReactNode;\n /** The smaller line under the title — what is inside, for a reader deciding whether\n * to open it. */\n hint?: ReactNode;\n /**\n * Who decides whether this one is open. Left out, the disclosure decides for itself,\n * which is what one standing on its own wants. Passed, the caller does — a set of\n * which one is open at a time, or an open state kept in the URL so the view can be\n * linked to. There is no accordion component: \"one open at a time\" is a few lines in\n * the caller and it usually owns a URL parameter, which is app state.\n */\n open?: boolean;\n /** Whether an UNCONTROLLED disclosure starts open. Ignored when `open` is passed. */\n defaultOpen?: boolean;\n /** Called with the next state on every toggle, controlled or not. */\n onOpenChange?: (open: boolean) => void;\n /**\n * `card` (default) draws the kit's `Card` surface round header and body, with the\n * chevron trailing the header and turning over — the \"section that opens\" of a\n * settings or analysis page. `bare` draws nothing: a leading chevron that turns\n * down, for an inline \"Show 3 hidden accounts\" inside something that already has\n * its own surface.\n *\n * `menu` is a row of a `HoverMenu`: the top bar's menu-item look\n * (`TOPBAR_MENU_ITEM_CLASS` — full-width, `px-3 py-2`, regular weight, square, the\n * hover wash with the text colour left alone), an INSET focus ring so the menu's\n * clipping edge cannot cut it off, the chevron at the end (`chevronPosition`\n * defaults to `end` here) and a body with no padding of its own, so the sub-list's\n * rows sit flush like the rows around them. keksdose's account menu opens its\n * language sub-list this way, and on `bare` it took four header overrides and a\n * body one to get there (account-menu.tsx).\n */\n variant?: \"card\" | \"bare\" | \"menu\";\n /**\n * Where a `bare` disclosure draws its chevron. `start` (default) is the leading\n * chevron that turns from the reading direction to down. `end` puts it at the far\n * end of the row, pointing down and turning up as the card's does — keksdose's\n * account menu, whose language sub-list reads \"Language 🇩🇪 ⌄\" with the chevron\n * after the flag, like every other menu row with a sub-list. With `trailing`, the\n * chevron follows it, as on a card. A `card` always has it at the end, so this is\n * ignored there. A `menu` defaults to `end`, like the menu rows around it.\n *\n * `after-title` sits it right after the title's text, pointing down and turning up —\n * \"Net profit ⌄ ······ 1,234.50\", Lenkbank's result rows, where the far end of the\n * row belongs to a figure (see {@link trailingInTrigger}) and a leading chevron\n * would push every label off the column the non-expandable rows' labels start on.\n * Not a card's: its chevron keeps the end.\n */\n chevronPosition?: \"start\" | \"end\" | \"after-title\";\n /**\n * Wrap the header button in a heading of this level. The WAI-ARIA disclosure pattern\n * puts the button INSIDE the heading when the disclosure titles a section, so the\n * page's heading outline still lists it. Off by default: an inline \"show more\" is\n * not a section.\n */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n /** See {@link CollapseProps.keepMounted}. */\n keepMounted?: boolean;\n disabled?: boolean;\n /** Extra classes for the header button. */\n headerClassName?: string;\n /**\n * Attributes for the header BUTTON — the outer props go to the wrapping div — such as\n * an `aria-label`, an `id` or a `data-*` test hook. A function of the open state\n * when they depend on it: keksdose's budget table names each group's toggle\n * \"Expand group Food\" / \"Collapse group Food\", because the visible title is only the\n * group's name:\n *\n * ```tsx\n * triggerProps={(open) => ({ \"aria-label\": t(open ? \"collapseGroup\" : \"expandGroup\", { name }) })}\n * ```\n *\n * An `aria-label` REPLACES the title as the button's name, so it must still contain\n * the title's words (WCAG 2.5.3, label in name). See {@link DisclosureTriggerProps}\n * for what the disclosure keeps for itself.\n */\n triggerProps?: DisclosureTriggerProps | ((open: boolean) => DisclosureTriggerProps);\n /** Extra classes for the body's wrapper — where its padding and spacing live. */\n bodyClassName?: string;\n /**\n * Content at the far end of the header row, beside the title: a count, a date, a\n * status chip, an action button. It is a SIBLING of the header button, never inside\n * it — a button may not contain another interactive element, and a count inside it\n * would also be read as part of the button's name. The header button still spans\n * the row under it (a stretched hit area), so clicking the empty space or the\n * card's chevron still toggles, while whatever sits in `trailing` gets its own\n * clicks. With `trailing`, the card's chevron moves after it, to the row's end.\n *\n * Unless {@link trailingInTrigger} is set, which moves it INTO the button.\n */\n trailing?: ReactNode;\n /**\n * Render {@link trailing} inside the header button instead of beside it, so the\n * whole row — figure included — is one click target and the figure is part of the\n * button's accessible name: \"Net profit 1,234.50, collapsed\" rather than a button\n * called \"Net profit\" next to an unexplained number.\n *\n * Lenkbank's result rows (features/steering/results-panel.tsx) are the case: label,\n * chevron, and the value at the far end, all one `<button>`, because a result row\n * has nothing else it could mean.\n *\n * ⚠️ Only for NON-interactive content — a count, a figure, a status chip. A button\n * may not contain another interactive element; an action belongs in the default,\n * sibling `trailing`. The content is rendered in a `<span>`, so keep it phrasing\n * content too (no `div`s).\n */\n trailingInTrigger?: boolean;\n /**\n * Trigger-only mode: the id of an element the CALLER renders elsewhere — the hidden\n * rows of a table, a panel in another column — which this header shows and hides.\n * The header's `aria-controls` points at it and the disclosure renders no body of\n * its own (`children`, `bodyClassName` and `keepMounted` are ignored). Pair it with\n * `open` / `onOpenChange`: the caller owns the state, since the caller renders what\n * it governs.\n *\n * It is an IDREF LIST, as `aria-controls` is: several space-separated ids when what\n * folds is several elements — a budget group's category rows, each its own `<li>`,\n * siblings of this header (keksdose's budget-mobile-list joins their ids with\n * `\" \"`). It may be the EMPTY string: trigger-only mode with nothing to point at yet\n * (a group whose rows are all filtered away, rows that are not rendered while shut).\n * The header then carries no `aria-controls` at all rather than an empty one, and\n * still toggles.\n *\n * A table's leading row — keksdose's \"Upcoming\" toggle over the scheduled rows of\n * its transactions table — is this mode too: the rows it folds are the TABLE's, so\n * the disclosure is only the header, and the table renders or drops them from the\n * same state.\n *\n * ```tsx\n * <DataTable\n * rows={showFuture ? [...scheduled, ...posted] : posted}\n * leadingRow={\n * <Disclosure\n * variant=\"bare\"\n * title={upcomingLabel}\n * open={showFuture}\n * onOpenChange={setShowFuture}\n * // The scheduled rows' ids while they are rendered; \"\" while they are not.\n * controls={showFuture ? scheduled.map((tx) => `row-s${tx.id}`).join(\" \") : \"\"}\n * headerClassName=\"px-3 py-2\"\n * />\n * }\n * …\n * />\n * ```\n */\n controls?: string;\n /** The body. Not rendered in trigger-only mode ({@link DisclosureProps.controls}). */\n children?: ReactNode;\n}\n\n/**\n * A section that opens in place: a header button with `aria-expanded` and\n * `aria-controls`, and a {@link Collapse} under it.\n *\n * Both apps had written this by hand — Lenkbank as a shared `CollapsibleCard` with ten\n * importers, Keksdose three separate times (accounts, twice; the support panel) — and\n * the copies had drifted: none of Keksdose's animated, and all three swapped a\n * `ChevronRight` for a `ChevronDown` rather than turning one. Here the chevron is one\n * icon that rotates, so the change of state is one element moving rather than two\n * trading places.\n *\n * The body is unmounted while shut; see {@link CollapseProps.keepMounted} for why that\n * is the default and when to opt out.\n */\nexport function Disclosure({\n title,\n hint,\n open: controlled,\n defaultOpen = false,\n onOpenChange,\n variant = \"card\",\n chevronPosition,\n headingAs: Heading,\n keepMounted,\n disabled,\n headerClassName,\n triggerProps,\n bodyClassName,\n trailing,\n trailingInTrigger = false,\n controls,\n className,\n children,\n ...rest\n}: DisclosureProps) {\n const [own, setOwn] = useState(defaultOpen);\n const open = controlled ?? own;\n const bodyId = useId();\n const card = variant === \"card\";\n const menu = variant === \"menu\";\n // The card's chevron trails always; a menu row's unless asked otherwise; a bare\n // one only when asked to.\n const chevronAt = card ? \"end\" : (chevronPosition ?? (menu ? \"end\" : \"start\"));\n const chevronAtEnd = chevronAt === \"end\";\n const chevronAfterTitle = chevronAt === \"after-title\";\n const triggerOnly = controls !== undefined;\n // The card's header squares its lower corners only when a body opens under it.\n const joined = open && !triggerOnly;\n const hasTrailing = trailing !== undefined && trailing !== null && trailing !== false;\n // `trailing` beside the button, which then stretches under it; inside the button,\n // the row is simply the button.\n const trailingInside = hasTrailing && trailingInTrigger;\n const trailingBeside = hasTrailing && !trailingInTrigger;\n\n const toggle = () => {\n const next = !open;\n if (controlled === undefined) setOwn(next);\n onOpenChange?.(next);\n };\n\n const extraTriggerProps = typeof triggerProps === \"function\" ? triggerProps(open) : triggerProps;\n\n const button = (\n <button\n {...extraTriggerProps}\n type=\"button\"\n aria-expanded={open}\n // `||`: an empty `controls` is trigger-only with nothing to name, not `aria-controls=\"\"`.\n aria-controls={triggerOnly ? controls || undefined : bodyId}\n disabled={disabled}\n onClick={toggle}\n data-disclosure-trigger=\"\"\n className={cn(\n \"flex w-full gap-2 text-start outline-none disabled:cursor-not-allowed disabled:opacity-50\",\n trailingBeside\n ? // Stretched over the whole header row (the row is `relative`), so the space\n // round `trailing` and the card's chevron still toggle; the ring and the\n // card's hover paint on the stretched area / the row, not the text box.\n cn(\n \"min-w-0 flex-1 after:absolute after:inset-0 after:content-['']\",\n \"focus-visible:after:ring-focus focus-visible:after:ring-inset focus-visible:after:ring-brand\",\n card ? cn(\"after:rounded-lg\", joined && \"after:rounded-b-none\") : !menu && \"after:rounded-sm\",\n )\n : FOCUS_RING,\n card\n ? cn(\n \"items-center justify-between rounded-lg p-4\",\n trailingBeside ? \"pe-0\" : \"hover:bg-hover focus-visible:ring-inset\",\n joined && \"rounded-b-none\",\n )\n : menu\n ? // TOPBAR_MENU_ITEM_CLASS's row, spelled out rather than imported: a\n // component does not reach up into the shell. A test holds the two to\n // the same classes.\n \"items-center justify-between gap-3 px-3 py-2 text-sm text-secondary hover:bg-hover focus-visible:ring-inset\"\n : \"items-center rounded-sm text-sm font-medium text-secondary hover:text-primary\",\n headerClassName,\n )}\n >\n {chevronAt === \"start\" && <Chevron open={open} leading />}\n {/* `flex-1`: the title takes the row, so whatever a caller puts at its end sits\n at the header's far edge. */}\n <span className=\"min-w-0 flex-1\">\n {chevronAfterTitle ? (\n // The chevron hugs the text, however long the translation: the text wraps\n // before the chevron is pushed away from it.\n <span className=\"flex items-center gap-1\">\n <span className=\"min-w-0\">{title}</span>\n <Chevron open={open} small />\n </span>\n ) : (\n <span className={cn(\"block\", card && \"text-sm font-semibold text-primary\")}>{title}</span>\n )}\n {hint !== undefined && (\n <span className=\"mt-0.5 block text-xs font-normal text-muted\">{hint}</span>\n )}\n </span>\n {/* The space is for the accessible name — \"Net profit 1,234.50\", not\n \"Net profit1,234.50\"; between flex items it renders as nothing. */}\n {trailingInside && \" \"}\n {trailingInside && (\n <span data-disclosure-trailing=\"\" className=\"flex shrink-0 items-center gap-2\">\n {trailing}\n </span>\n )}\n {chevronAtEnd && !trailingBeside && <Chevron open={open} small={!card} />}\n </button>\n );\n\n // Preflight already makes h1–h6 inherit size and weight, so the heading adds\n // structure and nothing visible.\n const header = Heading ? <Heading className={trailingBeside ? \"min-w-0 flex-1\" : undefined}>{button}</Heading> : button;\n\n return (\n <div\n {...rest}\n className={cn(card && \"rounded-lg border border-subtle bg-surface shadow-sm\", className)}\n >\n {trailingBeside ? (\n <div\n className={cn(\n \"relative flex items-center gap-2\",\n card &&\n cn(\n \"rounded-lg pe-4 has-[[data-disclosure-trigger]:enabled:hover]:bg-hover\",\n joined && \"rounded-b-none\",\n ),\n )}\n >\n {header}\n {/* Positioned, so it paints over the stretched button and takes its own\n clicks; the chevron is not, so a click on it lands on the button. */}\n <div className=\"relative flex shrink-0 items-center gap-2\">{trailing}</div>\n {chevronAtEnd && <Chevron open={open} small={!card} />}\n </div>\n ) : (\n header\n )}\n {!triggerOnly && (\n <Collapse id={bodyId} open={open} keepMounted={keepMounted}>\n <div className={cn(card ? \"space-y-3 px-4 pb-4\" : !menu && \"space-y-2 pt-2\", bodyClassName)}>{children}</div>\n </Collapse>\n )}\n </div>\n );\n}\n\n/**\n * One icon for both variants, turned rather than swapped. `leading` (bare) points it\n * along the reading direction while shut — right in LTR, left in RTL — and down when\n * open; trailing (card) points down while shut and up when open, which is the card\n * header's convention. Rotation, not a mirrored glyph, so RTL needs one opposite angle\n * and no `scale` composing with the turn.\n */\nfunction Chevron({\n open,\n leading = false,\n small = leading,\n}: {\n open: boolean;\n leading?: boolean;\n /** The bare variant's size, which a bare chevron keeps at either end of its row. */\n small?: boolean;\n}) {\n return (\n <ChevronDown\n aria-hidden\n className={cn(\n \"shrink-0 text-muted transition-transform duration-200 ease-out motion-reduce:transition-none\",\n small ? \"size-3.5\" : \"size-4\",\n leading ? !open && \"-rotate-90 rtl:rotate-90\" : open && \"rotate-180\",\n )}\n />\n );\n}\n"],"mappings":";AAuFM,cA+RI,YA/RJ;AAvFN,SAAS,WAAW,OAAO,gBAAgB;AAE3C,SAAS,mBAAmB;AAE5B,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAG3B,SAAS,0BAA0B;AAInC,MAAM,cAAc;AA2Cb,SAAS,SAAS,EAAE,MAAM,cAAc,OAAO,UAAU,WAAW,OAAO,GAAG,KAAK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ement, useEffect, useId, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactNode } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { FOCUS_RING } from \"./focus-ring\";\n// Read at the moment of closing, as `useCloseTransition` does: the setting can change\n// under a long-lived page.\nimport { skipsExitAnimation } from \"../hooks/use-close-transition\";\n\n/** How long the fold takes, in ms. The same number as the `duration-200` below and as\n * the unmount timer, because they are the same movement. */\nconst COLLAPSE_MS = 200;\n\n/**\n * `extends` the div's props so an `id` (what a trigger's `aria-controls` points at), a\n * `data-tour` anchor or a test id reaches the element that folds.\n */\nexport interface CollapseProps extends ComponentPropsWithRef<\"div\"> {\n open: boolean;\n /**\n * Keep the children mounted while shut (hidden and `inert`) instead of unmounting\n * them once the fold has finished closing.\n *\n * Off by default, and that default is a behaviour contract rather than a\n * performance note: Lenkbank's disclosure bodies FETCH, and a body that only exists\n * while open is what stops a closed card asking — without every caller carrying its\n * own `enabled: open`. On for a body whose state must outlive a close (a half-typed\n * form) or that must be found by the browser's find-in-page.\n */\n keepMounted?: boolean;\n children: ReactNode;\n}\n\n/**\n * The fold on its own: content that opens and shuts in place, animated to a height\n * nobody measured.\n *\n * THE TECHNIQUE is `AppShell`'s sidebar group's, lifted out so there is one copy of it.\n * A `grid-template-rows` transition from `0fr` to `1fr` is the one way to animate to a\n * content-sized height without measuring it — so a chart that resizes inside it, or a\n * translated line that wraps, is still exactly as tall as it needs. `visibility` rides\n * the same transition, so a shut body leaves the accessibility tree only once it has\n * finished closing; `inert` takes it out of the tab order immediately.\n *\n * THE CHILDREN are unmounted once closed (see {@link CollapseProps.keepMounted}), but\n * only once the track has finished closing: the track is what animates, so the\n * children have to survive the movement that hides them. Under reduced motion they\n * go at once — there is no movement to wait for — and the opening half is silenced by\n * `motion-reduce:transition-none`, since tokens.css only silences the overlay\n * animations by name.\n *\n * Padding and margins belong on a child: on this element, or the clipping one inside\n * it, they would hold the row open by that much.\n */\nexport function Collapse({ open, keepMounted = false, children, className, style, ...rest }: CollapseProps) {\n // Whether the children are still on their way out. Adjusted DURING render when\n // `open` flips (React's \"storing information from previous renders\"), so a close\n // under reduced motion unmounts in the same render that shut it — a test, and a\n // screen reader, see the body go on the click — and a re-open mid-fold simply\n // cancels the linger.\n const [lingering, setLingering] = useState(false);\n const [prevOpen, setPrevOpen] = useState(open);\n if (open !== prevOpen) {\n setPrevOpen(open);\n setLingering(!open && !skipsExitAnimation());\n }\n useEffect(() => {\n if (!lingering) return;\n const timer = setTimeout(() => setLingering(false), COLLAPSE_MS);\n return () => clearTimeout(timer);\n }, [lingering]);\n\n const mounted = open || lingering || keepMounted;\n\n return (\n <div\n {...rest}\n inert={!open}\n className={cn(\n \"grid transition-[grid-template-rows,visibility] duration-200 ease-out motion-reduce:transition-none\",\n className,\n )}\n // Inline rather than `grid-rows-[…]` classes: a caller's `className` must not be\n // able to pin the track open, and the two values ARE the state.\n style={{ ...style, gridTemplateRows: open ? \"1fr\" : \"0fr\", visibility: open ? \"visible\" : \"hidden\" }}\n >\n <div\n className={cn(\n \"min-h-0 overflow-hidden transition-opacity duration-200 ease-out motion-reduce:transition-none\",\n open ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n {mounted && children}\n </div>\n </div>\n );\n}\n\n/**\n * What {@link DisclosureProps.triggerProps} may put on the header button: its own\n * attributes and handlers, and any `data-*`. Not the ones the disclosure owns —\n * `aria-expanded`, `aria-controls`, `disabled`, `onClick`, `type` and the content — nor\n * `className`, which is {@link DisclosureProps.headerClassName}.\n */\nexport type DisclosureTriggerProps = Omit<\n ComponentPropsWithoutRef<\"button\">,\n \"type\" | \"aria-expanded\" | \"aria-controls\" | \"disabled\" | \"onClick\" | \"children\" | \"className\"\n> & { [data: `data-${string}`]: string | number | boolean | undefined };\n\n/**\n * `title` is omitted from the div's own props because this component already owns the\n * name: here it is the header's content (and a ReactNode), not the browser's tooltip.\n * Everything else reaches the outer element.\n */\nexport interface DisclosureProps extends Omit<ComponentPropsWithRef<\"div\">, \"title\"> {\n /** What the header says. A node, so a status chip or a count can sit in it. */\n title: ReactNode;\n /** The smaller line under the title — what is inside, for a reader deciding whether\n * to open it. */\n hint?: ReactNode;\n /**\n * Who decides whether this one is open. Left out, the disclosure decides for itself,\n * which is what one standing on its own wants. Passed, the caller does — a set of\n * which one is open at a time, or an open state kept in the URL so the view can be\n * linked to. There is no accordion component: \"one open at a time\" is a few lines in\n * the caller and it usually owns a URL parameter, which is app state.\n */\n open?: boolean;\n /** Whether an UNCONTROLLED disclosure starts open. Ignored when `open` is passed. */\n defaultOpen?: boolean;\n /** Called with the next state on every toggle, controlled or not. */\n onOpenChange?: (open: boolean) => void;\n /**\n * `card` (default) draws the kit's `Card` surface round header and body, with the\n * chevron trailing the header and turning over — the \"section that opens\" of a\n * settings or analysis page. `bare` draws nothing: a leading chevron that turns\n * down, for an inline \"Show 3 hidden accounts\" inside something that already has\n * its own surface.\n *\n * `menu` is a row of a `HoverMenu`: the top bar's menu-item look\n * (`TOPBAR_MENU_ITEM_CLASS` — full-width, `px-3 py-2`, regular weight, square, the\n * hover wash with the text colour left alone), an INSET focus ring so the menu's\n * clipping edge cannot cut it off, the chevron at the end (`chevronPosition`\n * defaults to `end` here) and a body with no padding of its own, so the sub-list's\n * rows sit flush like the rows around them. keksdose's account menu opens its\n * language sub-list this way, and on `bare` it took four header overrides and a\n * body one to get there (account-menu.tsx).\n */\n variant?: \"card\" | \"bare\" | \"menu\";\n /**\n * Where a `bare` disclosure draws its chevron. `start` (default) is the leading\n * chevron that turns from the reading direction to down. `end` puts it at the far\n * end of the row, pointing down and turning up as the card's does — keksdose's\n * account menu, whose language sub-list reads \"Language 🇩🇪 ⌄\" with the chevron\n * after the flag, like every other menu row with a sub-list. With `trailing`, the\n * chevron follows it, as on a card. A `card` always has it at the end, so this is\n * ignored there. A `menu` defaults to `end`, like the menu rows around it.\n *\n * `after-title` sits it right after the title's text, pointing down and turning up —\n * \"Net profit ⌄ ······ 1,234.50\", Lenkbank's result rows, where the far end of the\n * row belongs to a figure (see {@link trailingInTrigger}) and a leading chevron\n * would push every label off the column the non-expandable rows' labels start on.\n * Not a card's: its chevron keeps the end.\n */\n chevronPosition?: \"start\" | \"end\" | \"after-title\";\n /**\n * Wrap the header button in a heading of this level. The WAI-ARIA disclosure pattern\n * puts the button INSIDE the heading when the disclosure titles a section, so the\n * page's heading outline still lists it. Off by default: an inline \"show more\" is\n * not a section.\n */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n /** See {@link CollapseProps.keepMounted}. */\n keepMounted?: boolean;\n disabled?: boolean;\n /** Extra classes for the header button. */\n headerClassName?: string;\n /**\n * Attributes for the header BUTTON — the outer props go to the wrapping div — such as\n * an `aria-label`, an `id` or a `data-*` test hook. A function of the open state\n * when they depend on it: keksdose's budget table names each group's toggle\n * \"Expand group Food\" / \"Collapse group Food\", because the visible title is only the\n * group's name:\n *\n * ```tsx\n * triggerProps={(open) => ({ \"aria-label\": t(open ? \"collapseGroup\" : \"expandGroup\", { name }) })}\n * ```\n *\n * An `aria-label` REPLACES the title as the button's name, so it must still contain\n * the title's words (WCAG 2.5.3, label in name). See {@link DisclosureTriggerProps}\n * for what the disclosure keeps for itself.\n */\n triggerProps?: DisclosureTriggerProps | ((open: boolean) => DisclosureTriggerProps);\n /** Extra classes for the body's wrapper — where its padding and spacing live. */\n bodyClassName?: string;\n /**\n * Content at the far end of the header row, beside the title: a count, a date, a\n * status chip, an action button. It is a SIBLING of the header button, never inside\n * it — a button may not contain another interactive element, and a count inside it\n * would also be read as part of the button's name. The header button still spans\n * the row under it (a stretched hit area), so clicking the empty space or the\n * card's chevron still toggles, while whatever sits in `trailing` gets its own\n * clicks. With `trailing`, the card's chevron moves after it, to the row's end.\n *\n * Unless {@link trailingInTrigger} is set, which moves it INTO the button.\n */\n trailing?: ReactNode;\n /**\n * Render {@link trailing} inside the header button instead of beside it, so the\n * whole row — figure included — is one click target and the figure is part of the\n * button's accessible name: \"Net profit 1,234.50, collapsed\" rather than a button\n * called \"Net profit\" next to an unexplained number.\n *\n * Lenkbank's result rows (features/steering/results-panel.tsx) are the case: label,\n * chevron, and the value at the far end, all one `<button>`, because a result row\n * has nothing else it could mean.\n *\n * ⚠️ Only for NON-interactive content — a count, a figure, a status chip. A button\n * may not contain another interactive element; an action belongs in the default,\n * sibling `trailing`. The content is rendered in a `<span>`, so keep it phrasing\n * content too (no `div`s).\n */\n trailingInTrigger?: boolean;\n /**\n * Trigger-only mode: the id of an element the CALLER renders elsewhere — the hidden\n * rows of a table, a panel in another column — which this header shows and hides.\n * The header's `aria-controls` points at it and the disclosure renders no body of\n * its own (`children`, `bodyClassName` and `keepMounted` are ignored). Pair it with\n * `open` / `onOpenChange`: the caller owns the state, since the caller renders what\n * it governs.\n *\n * It is an IDREF LIST, as `aria-controls` is: several space-separated ids when what\n * folds is several elements — a budget group's category rows, each its own `<li>`,\n * siblings of this header (keksdose's budget-mobile-list joins their ids with\n * `\" \"`). It may be the EMPTY string: trigger-only mode with nothing to point at yet\n * (a group whose rows are all filtered away, rows that are not rendered while shut).\n * The header then carries no `aria-controls` at all rather than an empty one, and\n * still toggles.\n *\n * A table's leading row — keksdose's \"Upcoming\" toggle over the scheduled rows of\n * its transactions table — is this mode too: the rows it folds are the TABLE's, so\n * the disclosure is only the header, and the table renders or drops them from the\n * same state.\n *\n * ```tsx\n * <DataTable\n * rows={showFuture ? [...scheduled, ...posted] : posted}\n * leadingRow={\n * <Disclosure\n * variant=\"bare\"\n * title={upcomingLabel}\n * open={showFuture}\n * onOpenChange={setShowFuture}\n * // The scheduled rows' ids while they are rendered; \"\" while they are not.\n * controls={showFuture ? scheduled.map((tx) => `row-s${tx.id}`).join(\" \") : \"\"}\n * headerClassName=\"px-3 py-2\"\n * />\n * }\n * …\n * />\n * ```\n */\n controls?: string;\n /** The body. Not rendered in trigger-only mode ({@link DisclosureProps.controls}),\n * nor when there is none (0.48): no children, no empty box under the header.\n * `null`, `false`, `undefined` and an empty fragment (`<></>`) count as none. */\n children?: ReactNode;\n}\n\n/**\n * A section that opens in place: a header button with `aria-expanded` and\n * `aria-controls`, and a {@link Collapse} under it.\n *\n * Both apps had written this by hand — Lenkbank as a shared `CollapsibleCard` with ten\n * importers, Keksdose three separate times (accounts, twice; the support panel) — and\n * the copies had drifted: none of Keksdose's animated, and all three swapped a\n * `ChevronRight` for a `ChevronDown` rather than turning one. Here the chevron is one\n * icon that rotates, so the change of state is one element moving rather than two\n * trading places.\n *\n * The body is unmounted while shut; see {@link CollapseProps.keepMounted} for why that\n * is the default and when to opt out.\n */\nexport function Disclosure({\n title,\n hint,\n open: controlled,\n defaultOpen = false,\n onOpenChange,\n variant = \"card\",\n chevronPosition,\n headingAs: Heading,\n keepMounted,\n disabled,\n headerClassName,\n triggerProps,\n bodyClassName,\n trailing,\n trailingInTrigger = false,\n controls,\n className,\n children,\n ...rest\n}: DisclosureProps) {\n const [own, setOwn] = useState(defaultOpen);\n const open = controlled ?? own;\n const bodyId = useId();\n const card = variant === \"card\";\n const menu = variant === \"menu\";\n // The card's chevron trails always; a menu row's unless asked otherwise; a bare\n // one only when asked to.\n const chevronAt = card ? \"end\" : (chevronPosition ?? (menu ? \"end\" : \"start\"));\n const chevronAtEnd = chevronAt === \"end\";\n const chevronAfterTitle = chevronAt === \"after-title\";\n const triggerOnly = controls !== undefined;\n // 0.48 (keksdose dev #603): no children, no body — an empty padded box under the\n // header made an open disclosure 8px taller than a shut one, and its `aria-controls`\n // named a region with nothing in it. `null`, `false` and `undefined` are nothing, and\n // so is a fragment of nothing (`cond ? <X /> : <></>`, keksdose N1).\n const hasBody = !triggerOnly && hasBodyContent(children);\n // The card's header squares its lower corners only when a body opens under it.\n const joined = open && hasBody;\n const hasTrailing = trailing !== undefined && trailing !== null && trailing !== false;\n // `trailing` beside the button, which then stretches under it; inside the button,\n // the row is simply the button.\n const trailingInside = hasTrailing && trailingInTrigger;\n const trailingBeside = hasTrailing && !trailingInTrigger;\n\n const toggle = () => {\n const next = !open;\n if (controlled === undefined) setOwn(next);\n onOpenChange?.(next);\n };\n\n const extraTriggerProps = typeof triggerProps === \"function\" ? triggerProps(open) : triggerProps;\n\n const button = (\n <button\n {...extraTriggerProps}\n type=\"button\"\n aria-expanded={open}\n // `||`: an empty `controls` is trigger-only with nothing to name, not `aria-controls=\"\"`.\n aria-controls={triggerOnly ? controls || undefined : hasBody ? bodyId : undefined}\n disabled={disabled}\n onClick={toggle}\n data-disclosure-trigger=\"\"\n className={cn(\n \"flex w-full gap-2 text-start outline-none disabled:cursor-not-allowed disabled:opacity-50\",\n trailingBeside\n ? // Stretched over the whole header row (the row is `relative`), so the space\n // round `trailing` and the card's chevron still toggle; the ring and the\n // card's hover paint on the stretched area / the row, not the text box.\n cn(\n \"min-w-0 flex-1 after:absolute after:inset-0 after:content-['']\",\n \"focus-visible:after:ring-focus focus-visible:after:ring-inset focus-visible:after:ring-brand\",\n card ? cn(\"after:rounded-lg\", joined && \"after:rounded-b-none\") : !menu && \"after:rounded-sm\",\n )\n : FOCUS_RING,\n card\n ? cn(\n \"items-center justify-between rounded-lg p-4\",\n trailingBeside ? \"pe-0\" : \"hover:bg-hover focus-visible:ring-inset\",\n joined && \"rounded-b-none\",\n )\n : menu\n ? // TOPBAR_MENU_ITEM_CLASS's row, spelled out rather than imported: a\n // component does not reach up into the shell. A test holds the two to\n // the same classes.\n \"items-center justify-between gap-3 px-3 py-2 text-sm text-secondary hover:bg-hover focus-visible:ring-inset\"\n : \"items-center rounded-sm text-sm font-medium text-secondary hover:text-primary\",\n headerClassName,\n )}\n >\n {chevronAt === \"start\" && <Chevron open={open} leading />}\n {/* `flex-1`: the title takes the row, so whatever a caller puts at its end sits\n at the header's far edge. */}\n <span className=\"min-w-0 flex-1\">\n {chevronAfterTitle ? (\n // The chevron hugs the text, however long the translation: the text wraps\n // before the chevron is pushed away from it.\n <span className=\"flex items-center gap-1\">\n <span className=\"min-w-0\">{title}</span>\n <Chevron open={open} small />\n </span>\n ) : (\n <span className={cn(\"block\", card && \"text-sm font-semibold text-primary\")}>{title}</span>\n )}\n {hint !== undefined && (\n <span className=\"mt-0.5 block text-xs font-normal text-muted\">{hint}</span>\n )}\n </span>\n {/* The space is for the accessible name — \"Net profit 1,234.50\", not\n \"Net profit1,234.50\"; between flex items it renders as nothing. */}\n {trailingInside && \" \"}\n {trailingInside && (\n <span data-disclosure-trailing=\"\" className=\"flex shrink-0 items-center gap-2\">\n {trailing}\n </span>\n )}\n {chevronAtEnd && !trailingBeside && <Chevron open={open} small={!card} />}\n </button>\n );\n\n // Preflight already makes h1–h6 inherit size and weight, so the heading adds\n // structure and nothing visible.\n const header = Heading ? <Heading className={trailingBeside ? \"min-w-0 flex-1\" : undefined}>{button}</Heading> : button;\n\n return (\n <div\n {...rest}\n className={cn(card && \"rounded-lg border border-subtle bg-surface shadow-sm\", className)}\n >\n {trailingBeside ? (\n <div\n className={cn(\n \"relative flex items-center gap-2\",\n card &&\n cn(\n \"rounded-lg pe-4 has-[[data-disclosure-trigger]:enabled:hover]:bg-hover\",\n joined && \"rounded-b-none\",\n ),\n )}\n >\n {header}\n {/* Positioned, so it paints over the stretched button and takes its own\n clicks; the chevron is not, so a click on it lands on the button. */}\n <div className=\"relative flex shrink-0 items-center gap-2\">{trailing}</div>\n {chevronAtEnd && <Chevron open={open} small={!card} />}\n </div>\n ) : (\n header\n )}\n {hasBody && (\n <Collapse id={bodyId} open={open} keepMounted={keepMounted}>\n <div className={cn(card ? \"space-y-3 px-4 pb-4\" : !menu && \"space-y-2 pt-2\", bodyClassName)}>{children}</div>\n </Collapse>\n )}\n </div>\n );\n}\n\n/**\n * One icon for both variants, turned rather than swapped. `leading` (bare) points it\n * along the reading direction while shut — right in LTR, left in RTL — and down when\n * open; trailing (card) points down while shut and up when open, which is the card\n * header's convention. Rotation, not a mirrored glyph, so RTL needs one opposite angle\n * and no `scale` composing with the turn.\n */\nfunction Chevron({\n open,\n leading = false,\n small = leading,\n}: {\n open: boolean;\n leading?: boolean;\n /** The bare variant's size, which a bare chevron keeps at either end of its row. */\n small?: boolean;\n}) {\n return (\n <ChevronDown\n aria-hidden\n className={cn(\n \"shrink-0 text-muted transition-transform duration-200 ease-out motion-reduce:transition-none\",\n small ? \"size-3.5\" : \"size-4\",\n leading ? !open && \"-rotate-90 rtl:rotate-90\" : open && \"rotate-180\",\n )}\n />\n );\n}\n\n/** Whether `children` holds anything to draw: `null`/`false`/`undefined`/`\"\"` are nothing,\n * and a fragment counts by what is in it (an empty `<></>` is nothing). */\nfunction hasBodyContent(children: ReactNode): boolean {\n return Children.toArray(children).some((child) =>\n isValidElement<{ children?: ReactNode }>(child) && child.type === Fragment\n ? hasBodyContent(child.props.children)\n : child !== \"\",\n );\n}\n"],"mappings":";AAuFM,cAsSI,YAtSJ;AAvFN,SAAS,UAAU,UAAU,gBAAgB,WAAW,OAAO,gBAAgB;AAE/E,SAAS,mBAAmB;AAE5B,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAG3B,SAAS,0BAA0B;AAInC,MAAM,cAAc;AA2Cb,SAAS,SAAS,EAAE,MAAM,cAAc,OAAO,UAAU,WAAW,OAAO,GAAG,KAAK,GAAkB;AAM1G,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,IAAI;AAC7C,MAAI,SAAS,UAAU;AACrB,gBAAY,IAAI;AAChB,iBAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC;AAAA,EAC7C;AACA,YAAU,MAAM;AACd,QAAI,CAAC,UAAW;AAChB,UAAM,QAAQ,WAAW,MAAM,aAAa,KAAK,GAAG,WAAW;AAC/D,WAAO,MAAM,aAAa,KAAK;AAAA,EACjC,GAAG,CAAC,SAAS,CAAC;AAEd,QAAM,UAAU,QAAQ,aAAa;AAErC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,CAAC;AAAA,MACR,WAAW;AAAA,QACT;A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ACC;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA,QACE;AAAA,gBACE;AAAA,gBACA,UAAU;AAAA,cACZ;AAAA,YACJ;AAAA,YAEC;AAAA;AAAA,cAGD,oBAAC,SAAI,WAAU,6CAA6C,oBAAS;AAAA,cACpE,gBAAgB,oBAAC,WAAQ,MAAY,OAAO,CAAC,MAAM;AAAA;AAAA;AAAA,QACtD,IAEA;AAAA,QAED,WACC,oBAAC,YAAS,IAAI,QAAQ,MAAY,aAChC,8BAAC,SAAI,WAAW,GAAG,OAAO,wBAAwB,CAAC,QAAQ,kBAAkB,aAAa,GAAI,UAAS,GACzG;AAAA;AAAA;AAAA,EAEJ;AAEJ;AASA,SAAS,QAAQ;AAAA,EACf;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AACV,GAKG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW;AAAA,MACX,WAAW;AAAA,QACT;AAAA,QACA,QAAQ,aAAa;AAAA,QACrB,UAAU,CAAC,QAAQ,6BAA6B,QAAQ;AAAA,MAC1D;AAAA;AAAA,EACF;AAEJ;AAIA,SAAS,eAAe,UAA8B;AACpD,SAAO,SAAS,QAAQ,QAAQ,EAAE;AAAA,IAAK,CAAC,UACtC,eAAyC,KAAK,KAAK,MAAM,SAAS,WAC9D,eAAe,MAAM,MAAM,QAAQ,IACnC,UAAU;AAAA,EAChB;AACF;","names":[]}
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { createPortal } from "react-dom";
5
5
  import { Search } from "lucide-react";
6
6
  import { anchoredInline, useAnchoredPanel } from "../hooks/use-anchored-panel.js";
7
- import { runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from "../hooks/use-dismiss.js";
7
+ import { pressInside, runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from "../hooks/use-dismiss.js";
8
8
  import { useOverlayHistory } from "../hooks/use-overlay-history.js";
9
9
  import { cn } from "../lib/cn.js";
10
10
  import { FIELD_TOUCH_TEXT } from "./field-base.js";
@@ -144,6 +144,11 @@ function DropdownPanel({
144
144
  runOwnKeyDown(e, onKeyDown, panelRef && listLayers.get(panelRef));
145
145
  takeEscape(e);
146
146
  };
147
+ const markInside = pressInside(panelRef);
148
+ const handlePointerDownCapture = (e) => {
149
+ rest.onPointerDownCapture?.(e);
150
+ markInside?.(e);
151
+ };
147
152
  const body = /* @__PURE__ */ jsxs(Fragment, { children: [
148
153
  header,
149
154
  /* @__PURE__ */ jsxs("ul", { ...listProps, className: cn("overflow-y-auto py-1", listProps?.className), children: [
@@ -161,6 +166,7 @@ function DropdownPanel({
161
166
  style,
162
167
  ref: setPanel,
163
168
  onKeyDown: handleKeyDown,
169
+ onPointerDownCapture: handlePointerDownCapture,
164
170
  className: cn(
165
171
  "absolute z-30 mt-1 rounded-md border border-subtle bg-surface shadow-lg",
166
172
  "[&>ul]:max-h-64",
@@ -183,6 +189,7 @@ function DropdownPanel({
183
189
  ref: setPanel,
184
190
  dir,
185
191
  onKeyDown: handleKeyDown,
192
+ onPointerDownCapture: handlePointerDownCapture,
186
193
  style: {
187
194
  ...style,
188
195
  position: "fixed",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n ComponentPropsWithRef,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n Ref,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { anchoredInline, useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport type { DismissLayer } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { mergeRefs } from \"./field-parts\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/** Each list's Escape layer, filed under the refs {@link useDropdown} and\n * {@link useDropdownSearch} hand out (`panelRef`, `inputRef`), for the panel and the\n * search box those refs are passed to — see \"The caller's own handler\" on\n * {@link useDropdown} (round 0.35 R2). Weak: a list's refs go with its component. */\nconst listLayers = new WeakMap<object, DismissLayer>();\n\n/**\n * Open state + close-on-outside-click for a custom dropdown — the two input-shaped\n * comboboxes, and an app's own panel. (MultiSelect, CurrencySelect, GroupedPicker and\n * AmountInput's currency picker moved onto `useComboboxCore` + `ComboboxPanel` in round\n * 0.34, Wave 2 DUP-4, for the phone sheet and the portal.) Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. An open list is a layer on the kit's\n * one Escape stack ({@link useDismissLayer}), as `Modal`, `Popover` and\n * `useComboboxCore` are, so the package keeps one answer to \"what does Escape do\".\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they hand it back to\n * whatever held focus when the list opened, which is the control that was pressed.\n *\n * ## Escape inside a dialog (round 0.34 BUG-1, Wave 2 DUP-1)\n *\n * One press in an open list inside a `Modal` or a `FullBleedDialog` used to close the\n * DIALOG, form and all, and leave the list open: the dialog took Escape in its own\n * `onKeyDown` before a document listener could. On the stack the list is above the\n * dialog, so the list closes and the dialog stays. {@link DropdownPanel} and\n * {@link DropdownSearchHeader} take the key on their own elements, where focus is,\n * and stop it there — so a caller passes nothing new, AmountInput's currency chip\n * included.\n *\n * ## The caller's own handler (round 0.35 R2)\n *\n * A caller's `onKeyDown` on {@link DropdownPanel} or {@link DropdownSearchHeader} hears\n * Escape only while this list is the layer on top — the rule the dialogs got first. A\n * tooltip over a row takes that press first, and the next one is the handler's, whose\n * `preventDefault()` still keeps the list. The two find the list's layer through the\n * refs this hook hands out — the panel through `panelRef`, the search box through\n * {@link useDropdownSearch}'s `inputRef` — so a caller passes nothing new. One handed\n * neither (an un-anchored panel may leave `panelRef` off) hears every key, as before.\n *\n * `escapeLayer: false` is for a caller that registers its own layer: the editable\n * comboboxes, whose list can be \"open\" with nothing in it to show — an Escape there\n * belongs to the dialog.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n escapeLayer = true,\n}: { backCloses?: boolean; panelIsSheet?: boolean; escapeLayer?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n // Where focus was as the list opened — the trigger focus goes back to when the\n // caller attached none. Read in an effect, before `useDropdownSearch`'s frame moves\n // focus into the search box.\n const openerRef = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (!open) return;\n const el = document.activeElement;\n openerRef.current = el instanceof HTMLElement && el !== document.body ? el : null;\n }, [open]);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document, and inside a dialog the next Escape goes\n // nowhere. Whoever closed the list with a key gets focus handed back to the trigger\n // they opened it from.\n const closeToTrigger = useCallback(() => {\n setOpen(false);\n const back = triggerRef.current ?? openerRef.current;\n if (back?.isConnected) back.focus();\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n // See \"Escape inside a dialog\" above.\n const layer = useDismissLayer(open && escapeLayer, closeToTrigger);\n // Filed under `panelRef` for the panel's own handler — \"The caller's own handler\" above.\n useEffect(() => {\n listLayers.set(panelRef, layer);\n }, [panelRef, layer]);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } =\n useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n // The list's layer again, under `inputRef` for the search box's handler (round 0.35\n // R2). `useDropdown`'s effect, which runs first, has filed it under `panelRef`.\n useEffect(() => {\n const layer = listLayers.get(panelRef);\n if (layer) listLayers.set(inputRef, layer);\n }, [panelRef]);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps\n extends Omit<ComponentPropsWithRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is.\n * Escape closes the list (the topmost layer on the kit's Escape stack); call\n * `preventDefault()` on it here to keep it. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div\n {...rest}\n className={cn(\n \"flex items-center gap-2 border-b border-subtle px-2 py-1.5\",\n className,\n )}\n >\n <Search className=\"size-4 text-placeholder\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={(e) => {\n // The caller's handler hears Escape only while the list is on top (round 0.35\n // R2) — the layer filed under `inputRef`, when {@link useDropdownSearch} made it.\n runOwnKeyDown(e, onKeyDown, listLayers.get(inputRef));\n // Focus is in this box while the list is up, so this is where Escape lands\n // first — see \"Escape inside a dialog\" on {@link useDropdown}.\n takeEscape(e);\n }}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n // FIELD_TOUCH_TEXT: a search box is a field — at least 16 px on touch, or iOS zooms\n // the page the moment a picker opens and focuses it (§10.1).\n className={cn(\n \"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-placeholder text-primary\",\n FOCUS_RING,\n FIELD_TOUCH_TEXT,\n )}\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. Escape\n * anywhere in the panel, on a row as in the search box, closes the list rather than\n * a dialog around it. It is also how the panel finds the list's Escape layer, for\n * its `onKeyDown` (round 0.35 R2: see \"The caller's own handler\" there). */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting, by the\n * trigger's reading direction — `end` is the right edge in a left-to-right form and\n * the left one in a right-to-left form. Default `end`. The physical `left` / `right`\n * went in 0.35 (round 0.35 R1, refactor audit 2026-10, API-6e): `right` is `end` in a\n * left-to-right page, `left` is `start`. */\n align?: \"start\" | \"end\";\n children: ReactNode;\n /** The panel, where the rest of the props go (0.34, API-2, refactor audit 2026-10) —\n * merged with `panelRef`, so the outside-click still sees it. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n onKeyDown,\n ref,\n ...rest\n}: DropdownPanelProps) {\n const setPanel = useMemo(() => mergeRefs(panelRef, ref), [panelRef, ref]);\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n // A row the keyboard reached by Tab holds focus too, and its Escape has to close the\n // list as the search box's does (BUG-1). The caller's handler first, as everywhere.\n const handleKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {\n // It hears Escape only while the list is on top, a tooltip over a row taking the\n // press first (round 0.35 R2) — the layer filed under `panelRef`, when handed one.\n runOwnKeyDown(e, onKeyDown, panelRef && listLayers.get(panelRef));\n takeEscape(e);\n };\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-muted\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n style={style}\n ref={setPanel}\n onKeyDown={handleKeyDown}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-subtle bg-surface shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped to the glass as `Popover` is (Wave 2, DUP-7): the panel may leave the\n // trigger's edge to stay on screen, because a list half off the viewport is the bug\n // this exists for. The portal leaves the subtree the trigger's `dir` came from, so it\n // is read off the trigger — for the alignment here, and for the panel's own `dir`\n // below, without which a right-to-left form got a left-to-right list.\n const { left } = anchoredInline(rect, width, { dir, align });\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n ref={setPanel}\n dir={dir}\n onKeyDown={handleKeyDown}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so these values are the panel's own. Flipped above, it hangs from its\n // bottom edge, so a list shorter than its cap still meets the trigger (keksdose\n // K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: anchored.above ? undefined : anchored.top,\n bottom: anchored.above ? anchored.bottom : undefined,\n left,\n width,\n maxHeight: anchored.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AA4PI,SA0HA,UAnHE,KAPF;AA5PJ,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AASlE,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,eAAe,YAAY,iBAAiB,uBAAuB;AAE5E,SAAS,yBAAyB;AAClC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAM7B,MAAM,aAAa,oBAAI,QAA8B;AAsF9C,SAAS,YAAoD;AAAA,EAClE,aAAa;AAAA,EACb,eAAe,CAAC;AAAA,EAChB,cAAc;AAChB,IAA6E,CAAC,GAAG;AAC/E,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,aAAa,OAAU,IAAI;AAGjC,QAAM,aAAa,OAA0B,IAAI;AAKjD,QAAM,WAAW,OAAuB,IAAI;AAI5C,QAAM,YAAY,OAA2B,IAAI;AACjD,YAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,UAAM,KAAK,SAAS;AACpB,cAAU,UAAU,cAAc,eAAe,OAAO,SAAS,OAAO,KAAK;AAAA,EAC/E,GAAG,CAAC,IAAI,CAAC;AACT,QAAM,QAAQ,YAAY,MAAM,QAAQ,KAAK,GAAG,CAAC,CAAC;AAMlD,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,MAAK,gBAAe,WAAU,gCAA+B,oBAEjE;AAAA,OAEJ;AAAA,KACF;AAGF,MAAI,CAAC,WAAW;AACd;AAAA;AAAA,MAEE;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,UACA,KAAK;AAAA,UACL,WAAW;AAAA,UACX,WAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UAEC;AAAA;AAAA,MACH;AAAA;AAAA,EAEJ;AAEA,QAAM,OAAO,SAAS;AACtB,MAAI,CAAC,KAAM,QAAO;AAMlB,QAAM,EAAE,KAAK,IAAI,eAAe,MAAM,OAAO,EAAE,KAAK,MAAM,CAAC;AAC3D,SAAO;AAAA;AAAA,IAEL;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL;AAAA,QACA,WAAW;AAAA,QAMX,OAAO;AAAA,UACL,GAAG;AAAA,UACH,UAAU;AAAA,UACV,KAAK,SAAS,QAAQ,SAAY,SAAS;AAAA,UAC3C,QAAQ,SAAS,QAAQ,SAAS,SAAS;AAAA,UAC3C;AAAA,UACA;AAAA,UACA,WAAW,SAAS;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACT;AAAA;AAAA;AAAA,UAGA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
1
+ {"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n ComponentPropsWithRef,\n KeyboardEvent as ReactKeyboardEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n Ref,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { anchoredInline, useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { pressInside, runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport type { DismissLayer } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { mergeRefs } from \"./field-parts\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/** Each list's Escape layer, filed under the refs {@link useDropdown} and\n * {@link useDropdownSearch} hand out (`panelRef`, `inputRef`), for the panel and the\n * search box those refs are passed to — see \"The caller's own handler\" on\n * {@link useDropdown} (round 0.35 R2). Weak: a list's refs go with its component. */\nconst listLayers = new WeakMap<object, DismissLayer>();\n\n/**\n * Open state + close-on-outside-click for a custom dropdown — the two input-shaped\n * comboboxes, and an app's own panel. (MultiSelect, CurrencySelect, GroupedPicker and\n * AmountInput's currency picker moved onto `useComboboxCore` + `ComboboxPanel` in round\n * 0.34, Wave 2 DUP-4, for the phone sheet and the portal.) Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. An open list is a layer on the kit's\n * one Escape stack ({@link useDismissLayer}), as `Modal`, `Popover` and\n * `useComboboxCore` are, so the package keeps one answer to \"what does Escape do\".\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they hand it back to\n * whatever held focus when the list opened, which is the control that was pressed.\n *\n * ## Escape inside a dialog (round 0.34 BUG-1, Wave 2 DUP-1)\n *\n * One press in an open list inside a `Modal` or a `FullBleedDialog` used to close the\n * DIALOG, form and all, and leave the list open: the dialog took Escape in its own\n * `onKeyDown` before a document listener could. On the stack the list is above the\n * dialog, so the list closes and the dialog stays. {@link DropdownPanel} and\n * {@link DropdownSearchHeader} take the key on their own elements, where focus is,\n * and stop it there — so a caller passes nothing new, AmountInput's currency chip\n * included.\n *\n * ## The caller's own handler (round 0.35 R2)\n *\n * A caller's `onKeyDown` on {@link DropdownPanel} or {@link DropdownSearchHeader} hears\n * Escape only while this list is the layer on top — the rule the dialogs got first. A\n * tooltip over a row takes that press first, and the next one is the handler's, whose\n * `preventDefault()` still keeps the list. The two find the list's layer through the\n * refs this hook hands out — the panel through `panelRef`, the search box through\n * {@link useDropdownSearch}'s `inputRef` — so a caller passes nothing new. One handed\n * neither (an un-anchored panel may leave `panelRef` off) hears every key, as before.\n *\n * `escapeLayer: false` is for a caller that registers its own layer: the editable\n * comboboxes, whose list can be \"open\" with nothing in it to show — an Escape there\n * belongs to the dialog.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n escapeLayer = true,\n}: { backCloses?: boolean; panelIsSheet?: boolean; escapeLayer?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n // Where focus was as the list opened — the trigger focus goes back to when the\n // caller attached none. Read in an effect, before `useDropdownSearch`'s frame moves\n // focus into the search box.\n const openerRef = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (!open) return;\n const el = document.activeElement;\n openerRef.current = el instanceof HTMLElement && el !== document.body ? el : null;\n }, [open]);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document, and inside a dialog the next Escape goes\n // nowhere. Whoever closed the list with a key gets focus handed back to the trigger\n // they opened it from.\n const closeToTrigger = useCallback(() => {\n setOpen(false);\n const back = triggerRef.current ?? openerRef.current;\n if (back?.isConnected) back.focus();\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n // See \"Escape inside a dialog\" above.\n const layer = useDismissLayer(open && escapeLayer, closeToTrigger);\n // Filed under `panelRef` for the panel's own handler — \"The caller's own handler\" above.\n useEffect(() => {\n listLayers.set(panelRef, layer);\n }, [panelRef, layer]);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } =\n useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n // The list's layer again, under `inputRef` for the search box's handler (round 0.35\n // R2). `useDropdown`'s effect, which runs first, has filed it under `panelRef`.\n useEffect(() => {\n const layer = listLayers.get(panelRef);\n if (layer) listLayers.set(inputRef, layer);\n }, [panelRef]);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps\n extends Omit<ComponentPropsWithRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is.\n * Escape closes the list (the topmost layer on the kit's Escape stack); call\n * `preventDefault()` on it here to keep it. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div\n {...rest}\n className={cn(\n \"flex items-center gap-2 border-b border-subtle px-2 py-1.5\",\n className,\n )}\n >\n <Search className=\"size-4 text-placeholder\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={(e) => {\n // The caller's handler hears Escape only while the list is on top (round 0.35\n // R2) — the layer filed under `inputRef`, when {@link useDropdownSearch} made it.\n runOwnKeyDown(e, onKeyDown, listLayers.get(inputRef));\n // Focus is in this box while the list is up, so this is where Escape lands\n // first — see \"Escape inside a dialog\" on {@link useDropdown}.\n takeEscape(e);\n }}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n // FIELD_TOUCH_TEXT: a search box is a field — at least 16 px on touch, or iOS zooms\n // the page the moment a picker opens and focuses it (§10.1).\n className={cn(\n \"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-placeholder text-primary\",\n FOCUS_RING,\n FIELD_TOUCH_TEXT,\n )}\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. Escape\n * anywhere in the panel, on a row as in the search box, closes the list rather than\n * a dialog around it. It is also how the panel finds the list's Escape layer, for\n * its `onKeyDown` (round 0.35 R2: see \"The caller's own handler\" there). */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting, by the\n * trigger's reading direction — `end` is the right edge in a left-to-right form and\n * the left one in a right-to-left form. Default `end`. The physical `left` / `right`\n * went in 0.35 (round 0.35 R1, refactor audit 2026-10, API-6e): `right` is `end` in a\n * left-to-right page, `left` is `start`. */\n align?: \"start\" | \"end\";\n children: ReactNode;\n /** The panel, where the rest of the props go (0.34, API-2, refactor audit 2026-10) —\n * merged with `panelRef`, so the outside-click still sees it. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n onKeyDown,\n ref,\n ...rest\n}: DropdownPanelProps) {\n const setPanel = useMemo(() => mergeRefs(panelRef, ref), [panelRef, ref]);\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n // A row the keyboard reached by Tab holds focus too, and its Escape has to close the\n // list as the search box's does (BUG-1). The caller's handler first, as everywhere.\n const handleKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {\n // It hears Escape only while the list is on top, a tooltip over a row taking the\n // press first (round 0.35 R2) — the layer filed under `panelRef`, when handed one.\n runOwnKeyDown(e, onKeyDown, panelRef && listLayers.get(panelRef));\n takeEscape(e);\n };\n // A press in a panel opened from a row (a popover, its lists) is inside the list for\n // `useDropdown`'s outside press, though portalled elsewhere (dev#623).\n const markInside = pressInside(panelRef);\n const handlePointerDownCapture = (e: ReactPointerEvent<HTMLDivElement>) => {\n rest.onPointerDownCapture?.(e);\n markInside?.(e);\n };\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-muted\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n style={style}\n ref={setPanel}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-subtle bg-surface shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped to the glass as `Popover` is (Wave 2, DUP-7): the panel may leave the\n // trigger's edge to stay on screen, because a list half off the viewport is the bug\n // this exists for. The portal leaves the subtree the trigger's `dir` came from, so it\n // is read off the trigger — for the alignment here, and for the panel's own `dir`\n // below, without which a right-to-left form got a left-to-right list.\n const { left } = anchoredInline(rect, width, { dir, align });\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n ref={setPanel}\n dir={dir}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so these values are the panel's own. Flipped above, it hangs from its\n // bottom edge, so a list shorter than its cap still meets the trigger (keksdose\n // K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: anchored.above ? undefined : anchored.top,\n bottom: anchored.above ? anchored.bottom : undefined,\n left,\n width,\n maxHeight: anchored.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AA6PI,SAiIA,UA1HE,KAPF;AA7PJ,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAUlE,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,aAAa,eAAe,YAAY,iBAAiB,uBAAuB;AAEzF,SAAS,yBAAyB;AAClC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAM7B,MAAM,aAAa,oBAAI,QAA8B;AAsF9C,SAAS,YAAoD;AAAA,EAClE,aAAa;AAAA,EACb,eAAe,CAAC;AAAA,EAChB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A,UAC3C,QAAQ,SAAS,QAAQ,SAAS,SAAS;AAAA,UAC3C;AAAA,UACA;AAAA,UACA,WAAW,SAAS;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACT;AAAA;AAAA;AAAA,UAGA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
@@ -114,6 +114,11 @@ export interface FloatingActionButtonProps extends Omit<ButtonHTMLAttributes<HTM
114
114
  *
115
115
  * While mounted it reports its box (`lib/floating-stack.ts`), so `ServerWakeNotice`
116
116
  * stacks above it rather than over it.
117
+ *
118
+ * 0.48: while mounted, `hidden` or not, it also publishes the room it takes above the
119
+ * nav (`offset` + 3rem + a 0.5rem gap) as `--app-float-clearance` on `<html>` (the
120
+ * largest of several wins), and `AppShell` pads its `<main>` past it on a phone, so the
121
+ * page's last row no longer ends under the button (keksdose dev#612).
117
122
  */
118
123
  export declare function FloatingActionButton({ label, icon, corner, offset, nativeTitle, pressed, extended, live, variant, tooltip, tooltipSide, className, style, type, title, ref, ...rest }: FloatingActionButtonProps): import("react").JSX.Element;
119
124
  export interface FloatingPanelProps {
@@ -152,6 +157,14 @@ export interface FloatingPanelProps {
152
157
  className?: string;
153
158
  /** Extra classes for the scrolling body. */
154
159
  bodyClassName?: string;
160
+ /**
161
+ * 0.48: take the FAB and the panel off screen while keeping both mounted — the open
162
+ * state and the bottom room (`--app-float-clearance`) stay, and an open panel is back
163
+ * when this turns `false`. keksdose's assistant launcher steps aside while an editor
164
+ * or a modal covers its corner (dev#612); unmounting it instead would give the room
165
+ * back and shorten the page under the reader's thumb.
166
+ */
167
+ hidden?: boolean;
155
168
  children: ReactNode;
156
169
  }
157
170
  /**
@@ -186,7 +199,7 @@ export interface FloatingPanelProps {
186
199
  * panel unmounts when closed; an app that must keep a draft across a close keeps it in
187
200
  * its own state, where it also survives a reload.
188
201
  */
189
- export declare function FloatingPanel({ title, fabLabel, fabIcon, open: openProp, defaultOpen, onOpenChange, corner, offset, fabNativeTitle, fabTooltip, closeLabel, initialFocus, className, bodyClassName, children, }: FloatingPanelProps): import("react").JSX.Element;
202
+ export declare function FloatingPanel({ title, fabLabel, fabIcon, open: openProp, defaultOpen, onOpenChange, corner, offset, fabNativeTitle, fabTooltip, closeLabel, initialFocus, className, bodyClassName, hidden, children, }: FloatingPanelProps): import("react").JSX.Element;
190
203
  export interface FloatingActionGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
191
204
  /** Name the group ("Register actions"); a reader then introduces the members as one
192
205
  * set. A group with no name is one more unlabelled wrapper. */
@@ -7,6 +7,7 @@ import { cn } from "../lib/cn.js";
7
7
  import { FOCUS_RING } from "./focus-ring.js";
8
8
  import { dirOf } from "../lib/direction.js";
9
9
  import { registerFloating } from "../lib/floating-stack.js";
10
+ import { useFloatClearance } from "../lib/float-clearance.js";
10
11
  import { isComposing } from "../lib/ime.js";
11
12
  import { takeEscape } from "../hooks/use-dismiss.js";
12
13
  import { useKitLabels, useKitLink } from "../i18n/kit-labels.js";
@@ -57,6 +58,7 @@ function FloatingActionButton({
57
58
  const wrapped = tip !== void 0 && tip !== null;
58
59
  const [fixed, setFixed] = useState(null);
59
60
  useEffect(() => fixed ? registerFloating(fixed) : void 0, [fixed]);
61
+ useFloatClearance(offset);
60
62
  const buttonRef = useCallback(
61
63
  (node) => {
62
64
  assignRef(ref, node);
@@ -135,6 +137,7 @@ function FloatingPanel({
135
137
  initialFocus,
136
138
  className,
137
139
  bodyClassName,
140
+ hidden = false,
138
141
  children
139
142
  }) {
140
143
  const labels = useKitLabels(
@@ -193,15 +196,16 @@ function FloatingPanel({
193
196
  offset,
194
197
  nativeTitle: fabNativeTitle,
195
198
  tooltip: fabTooltip,
199
+ hidden: hidden || void 0,
196
200
  "aria-expanded": open,
197
- "aria-controls": open ? panelId : void 0,
201
+ "aria-controls": open && !hidden ? panelId : void 0,
198
202
  onClick: () => {
199
203
  focusInside.current = false;
200
204
  setOpen(!open);
201
205
  }
202
206
  }
203
207
  ),
204
- open && typeof document !== "undefined" && createPortal(
208
+ open && !hidden && typeof document !== "undefined" && createPortal(
205
209
  // A container for Escape bubbling up from anything inside it, as a dialog is.
206
210
  // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
207
211
  /* @__PURE__ */ jsxs(
@@ -271,6 +275,7 @@ function FloatingActionGroup({
271
275
  ...rest
272
276
  }) {
273
277
  const [marker, dir] = usePortalDir();
278
+ useFloatClearance(offset, "2px");
274
279
  return /* @__PURE__ */ jsxs(Fragment, { children: [
275
280
  /* @__PURE__ */ jsx("span", { ref: marker, hidden: true }),
276
281
  typeof document !== "undefined" && createPortal(