@eifi1/ui-kit 0.49.0 → 0.50.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 (144) hide show
  1. package/README.md +11 -7
  2. package/dist/admin/user-roster.d.ts +16 -10
  3. package/dist/admin/user-roster.js +7 -3
  4. package/dist/admin/user-roster.js.map +1 -1
  5. package/dist/auth/verify-email.d.ts +9 -1
  6. package/dist/auth/verify-email.js +3 -1
  7. package/dist/auth/verify-email.js.map +1 -1
  8. package/dist/components/amount-input.d.ts +2 -1
  9. package/dist/components/amount-input.js +3 -2
  10. package/dist/components/amount-input.js.map +1 -1
  11. package/dist/components/autocomplete.js +1 -0
  12. package/dist/components/autocomplete.js.map +1 -1
  13. package/dist/components/combobox-core.js +1 -0
  14. package/dist/components/combobox-core.js.map +1 -1
  15. package/dist/components/combobox-suggestions.js +1 -0
  16. package/dist/components/combobox-suggestions.js.map +1 -1
  17. package/dist/components/currency-select.d.ts +28 -2
  18. package/dist/components/currency-select.js +56 -10
  19. package/dist/components/currency-select.js.map +1 -1
  20. package/dist/components/data-table-mobile.d.ts +11 -2
  21. package/dist/components/data-table-mobile.js +62 -8
  22. package/dist/components/data-table-mobile.js.map +1 -1
  23. package/dist/components/data-table-row.d.ts +1 -1
  24. package/dist/components/data-table-row.js.map +1 -1
  25. package/dist/components/data-table.js +3 -1
  26. package/dist/components/data-table.js.map +1 -1
  27. package/dist/components/dropdown.js +1 -0
  28. package/dist/components/dropdown.js.map +1 -1
  29. package/dist/components/full-bleed-dialog.js +1 -0
  30. package/dist/components/full-bleed-dialog.js.map +1 -1
  31. package/dist/components/modal.js +1 -0
  32. package/dist/components/modal.js.map +1 -1
  33. package/dist/components/number-input.d.ts +2 -1
  34. package/dist/components/number-input.js +6 -2
  35. package/dist/components/number-input.js.map +1 -1
  36. package/dist/components/numpad-sheet.js +2 -0
  37. package/dist/components/numpad-sheet.js.map +1 -1
  38. package/dist/components/picker-sheet.js +2 -0
  39. package/dist/components/picker-sheet.js.map +1 -1
  40. package/dist/components/popover.js +1 -0
  41. package/dist/components/popover.js.map +1 -1
  42. package/dist/eslint/index.js +1 -1
  43. package/dist/i18n/defaults.js +2 -0
  44. package/dist/i18n/defaults.js.map +1 -1
  45. package/dist/i18n/german.js +14 -1
  46. package/dist/i18n/german.js.map +1 -1
  47. package/dist/i18n/kit-labels.d.ts +3 -0
  48. package/dist/i18n/kit-labels.js.map +1 -1
  49. package/dist/i18n/locales/en.js +16 -1
  50. package/dist/i18n/locales/en.js.map +3 -3
  51. package/dist/i18n/locales/es.js +14 -1
  52. package/dist/i18n/locales/es.js.map +1 -1
  53. package/dist/i18n/locales/fr.js +14 -1
  54. package/dist/i18n/locales/fr.js.map +1 -1
  55. package/dist/i18n/locales/hu.js +14 -1
  56. package/dist/i18n/locales/hu.js.map +1 -1
  57. package/dist/i18n/locales/it.js +14 -1
  58. package/dist/i18n/locales/it.js.map +1 -1
  59. package/dist/i18n/locales/zh.js +14 -1
  60. package/dist/i18n/locales/zh.js.map +1 -1
  61. package/dist/i18n/review.js +1 -0
  62. package/dist/i18n/review.js.map +1 -1
  63. package/dist/lib/data-attributes.d.ts +11 -0
  64. package/dist/lib/data-attributes.js +10 -0
  65. package/dist/lib/data-attributes.js.map +1 -0
  66. package/dist/lib/format.d.ts +1 -0
  67. package/dist/lib/format.js +2 -0
  68. package/dist/lib/format.js.map +1 -1
  69. package/dist/lib/minus.d.ts +10 -0
  70. package/dist/lib/minus.js.map +1 -1
  71. package/dist/testing/react.d.ts +25 -0
  72. package/dist/testing/react.js +19 -0
  73. package/dist/testing/react.js.map +1 -0
  74. package/dist/tour/tour-dock.d.ts +42 -0
  75. package/dist/tour/tour-dock.js +80 -0
  76. package/dist/tour/tour-dock.js.map +1 -0
  77. package/dist/tour/tour-gates.d.ts +71 -0
  78. package/dist/tour/tour-gates.js +114 -0
  79. package/dist/tour/tour-gates.js.map +1 -0
  80. package/dist/tour/tour-guide-button.d.ts +27 -0
  81. package/dist/tour/tour-guide-button.js +45 -0
  82. package/dist/tour/tour-guide-button.js.map +1 -0
  83. package/dist/tour/tour-guide-labels.d.ts +8 -0
  84. package/dist/tour/tour-guide-labels.js +9 -0
  85. package/dist/tour/tour-guide-labels.js.map +1 -0
  86. package/dist/tour/tour-labels.js +9 -1
  87. package/dist/tour/tour-labels.js.map +1 -1
  88. package/dist/tour/tour.d.ts +133 -9
  89. package/dist/tour/tour.js +594 -70
  90. package/dist/tour/tour.js.map +1 -1
  91. package/dist/tour/use-tour-url-sync.d.ts +5 -2
  92. package/dist/tour/use-tour-url-sync.js +7 -1
  93. package/dist/tour/use-tour-url-sync.js.map +1 -1
  94. package/dist/tour.d.ts +2 -0
  95. package/dist/tour.js +3 -0
  96. package/dist/tour.js.map +1 -1
  97. package/dist/wizard/stepper-nav.js +15 -2
  98. package/dist/wizard/stepper-nav.js.map +1 -1
  99. package/dist/wizard/types.d.ts +11 -0
  100. package/dist/wizard/types.js.map +1 -1
  101. package/dist/wizard/use-wizard.js +11 -5
  102. package/dist/wizard/use-wizard.js.map +1 -1
  103. package/package.json +9 -1
  104. package/src/admin/user-roster.tsx +22 -12
  105. package/src/auth/verify-email.tsx +10 -0
  106. package/src/components/amount-input.tsx +5 -4
  107. package/src/components/autocomplete.tsx +2 -0
  108. package/src/components/combobox-core.tsx +2 -0
  109. package/src/components/combobox-suggestions.tsx +2 -0
  110. package/src/components/currency-select.tsx +95 -6
  111. package/src/components/data-table-mobile.tsx +99 -8
  112. package/src/components/data-table-row.tsx +1 -0
  113. package/src/components/data-table.tsx +9 -1
  114. package/src/components/dropdown.tsx +2 -0
  115. package/src/components/full-bleed-dialog.tsx +3 -0
  116. package/src/components/modal.tsx +3 -0
  117. package/src/components/number-input.tsx +8 -3
  118. package/src/components/numpad-sheet.tsx +4 -0
  119. package/src/components/picker-sheet.tsx +4 -0
  120. package/src/components/popover.tsx +2 -0
  121. package/src/i18n/defaults.ts +2 -0
  122. package/src/i18n/german.ts +13 -0
  123. package/src/i18n/kit-labels.tsx +3 -0
  124. package/src/i18n/locales/es.ts +13 -0
  125. package/src/i18n/locales/fr.ts +13 -0
  126. package/src/i18n/locales/hu.ts +13 -0
  127. package/src/i18n/locales/it.ts +13 -0
  128. package/src/i18n/locales/zh.ts +13 -0
  129. package/src/i18n/review.ts +1 -0
  130. package/src/lib/data-attributes.ts +14 -0
  131. package/src/lib/format.ts +2 -0
  132. package/src/lib/minus.ts +10 -0
  133. package/src/testing/react.ts +59 -0
  134. package/src/tour/tour-dock.ts +132 -0
  135. package/src/tour/tour-gates.ts +195 -0
  136. package/src/tour/tour-guide-button.tsx +64 -0
  137. package/src/tour/tour-guide-labels.ts +15 -0
  138. package/src/tour/tour-labels.ts +8 -0
  139. package/src/tour/tour.tsx +949 -86
  140. package/src/tour/use-tour-url-sync.ts +14 -4
  141. package/src/tour.ts +3 -0
  142. package/src/wizard/stepper-nav.tsx +23 -3
  143. package/src/wizard/types.ts +12 -0
  144. package/src/wizard/use-wizard.ts +16 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/combobox-core.tsx"],"sourcesContent":["import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type {\n ComponentPropsWithoutRef,\n Dispatch,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n RefObject,\n SetStateAction,\n} from \"react\";\nimport { Check, Plus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { CLIPS_ATTRIBUTE } from \"../lib/clipping\";\nimport { DropdownSearchHeader } from \"./dropdown\";\nimport { PickerSheet, SHEET_ROW_CLASS } from \"./picker-sheet\";\nimport { usePhoneLayout, useRemPx } from \"../hooks/use-breakpoint\";\nimport { FLOATING_LABEL_STATIC } from \"./field-parts\";\nimport { Spinner } from \"./spinner\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\nimport { type AnchorRect } from \"../hooks/use-anchored-rect\";\nimport { anchoredInline, useAnchoredPanel, viewportSize, type AnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { pressInside, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { isImeEnter } from \"../lib/ime\";\nimport { foldForSearch } from \"../lib/text-match\";\nimport { DEFAULT_COMBOBOX_LABELS, useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { hasContent } from \"../lib/presence\";\n\n/**\n * What an entity picker hands `onChange` when it is cleared — `clearValue` on\n * {@link EntityCombobox} and {@link InlineEntityCombobox}. `null` by default.\n *\n * A closed set rather than any value, on purpose: every member is something no\n * option can be (an option's value is a `string | number`, and `\"\"` is never a real\n * id), so the picker can also READ it back — a field whose `value` is the clear\n * value shows as empty, with no clear button, exactly as `null` does. An arbitrary\n * sentinel could collide with an id and would make that read ambiguous.\n *\n * No `undefined`: a prop set to `undefined` is a prop not passed, so it would read as\n * the default and emit `null` — the one outcome the caller had asked not to get.\n */\nexport type ComboClearValue = null | \"\";\n\nexport interface ComboOption<V extends string | number> {\n value: V;\n label: string;\n sublabel?: string;\n icon?: ReactNode;\n /**\n * Section this option belongs to. Where a consumer renders it as a heading with the\n * members indented beneath — {@link InlineEntityCombobox} does — this is a genuine\n * grouping, not decoration: the name appears once per section rather than trailing\n * every row in small grey type, which is barely legible on a phone (feedback #136).\n * The heading stays at the top of the list while its rows scroll beneath it.\n *\n * NOT searched (0.40, kk run 79): a group is where a row is filed, not what it is\n * called — with first-letter groups (\"A\", \"B\", … \"#\"), typing \"a\" matched every row\n * filed under A. Searching a category's name means putting it in `sublabel`.\n */\n group?: string;\n /**\n * Shown but not takeable: rendered dimmed with `aria-disabled`, passed over by the\n * arrow keys, and a click or Enter on it does nothing. For a row whose existence is\n * the information — a write-locked result, an account that is closed — where\n * leaving it out would read as \"there is no such thing\". Say WHY in `sublabel`: a\n * hover tooltip is the one explanation a phone cannot show.\n *\n * Honoured by {@link Autocomplete}, {@link InlineEntityCombobox} and the panel\n * pickers ({@link EntityCombobox}, {@link MultiEntityCombobox}); on those an already\n * chosen disabled option stays chosen — the row only refuses to be toggled.\n */\n disabled?: boolean;\n}\n\n/** A row the user may take — present and not {@link ComboOption.disabled}. */\nexport const isOptionEnabled = (o: { disabled?: boolean } | undefined): boolean =>\n o !== undefined && !o.disabled;\n\n/**\n * The next takeable row from `from`, stepping `dir` — what the arrow keys use so a\n * disabled row is passed over, as the APG allows. Stays on `from` at the end of the\n * list (the family's arrows clamp rather than wrap) and answers `-1` when `from` is\n * not a row and there is nothing to step to.\n */\nexport function stepEnabled(\n rows: readonly { disabled?: boolean }[],\n from: number,\n dir: 1 | -1,\n): number {\n for (let i = from + dir; i >= 0 && i < rows.length; i += dir) {\n if (!rows[i].disabled) return i;\n }\n return from >= 0 && from < rows.length ? from : -1;\n}\n\n/** `i` when that row is takeable, else the nearest takeable one after it, else\n * before it, else `-1`. For a highlight that starts on a fixed index (the panel\n * pickers open on row 0) and must never rest on a disabled row. */\nexport function settleEnabled(rows: readonly { disabled?: boolean }[], i: number): number {\n if (i < 0 || i >= rows.length) return -1;\n if (!rows[i].disabled) return i;\n const after = stepEnabled(rows, i, 1);\n if (after !== i) return after;\n const before = stepEnabled(rows, i, -1);\n return before !== i ? before : -1;\n}\n\n/** Classes a disabled row adds over its normal ones — dimmed, no hover, the\n * kit's soft-disabled look (`DangerConfirm`, `SignaturePad`). */\nexport const DISABLED_ROW_CLASS = \"cursor-not-allowed opacity-50 hover:bg-transparent\";\n\n/**\n * Whether an entity picker offers its create row — one rule for\n * {@link EntityCombobox}, {@link MultiEntityCombobox} and {@link InlineEntityCombobox}.\n *\n * With a query: while the trimmed query names no option exactly (case-insensitive) —\n * an exact hit is a record the list is already showing, and a second way to \"make\" it\n * would mint a duplicate. With NO query: only when the caller named the row for that\n * case (`createEmptyLabel`) — a row reading `Create “”` says nothing, and the kit cannot\n * know the noun (\"Create cash account\") that would make it say something (keksdose G9).\n *\n * `names` is what the query is compared against: the loaded rows for a panel picker\n * (its async list is all it knows), every option for the inline one.\n */\nexport function offersCreate(\n onCreate: unknown,\n query: string,\n names: readonly string[],\n createEmptyLabel: string | undefined,\n): boolean {\n if (!onCreate) return false;\n if (!query) return Boolean(createEmptyLabel);\n const q = query.toLowerCase();\n return !names.some((n) => n.toLowerCase() === q);\n}\n\n/**\n * {@link EndHintRow}'s `hint` and `className` for a combobox-family field, keeping the\n * 0.22 rule (keksdose): a field that was passed `hint` at all — even `undefined` — keeps\n * ONE box, so a hint coming and going never rebuilds the control under the cursor.\n *\n * A text hint is a caption after the control and never moved it; the case this covers\n * is the \"?\" (a {@link FieldHint}) on a field with no label line, which sits at the end\n * edge in a row of its own. Without this the row existed only while the \"?\" did, and\n * the control was re-parented — remounted, focus and caret lost — each time it came or\n * went. With `hint` passed the row stays, its end slot empty and its gap closed, so\n * nothing on screen moves either.\n */\nexport function endHintRowProps(\n hintPassed: boolean,\n hasLabel: boolean,\n labelHint: ReactNode | undefined,\n): { hint: ReactNode | undefined; className?: string } {\n if (hasLabel) return { hint: undefined };\n if (labelHint !== undefined) return { hint: labelHint };\n return hintPassed ? { hint: null, className: \"gap-0\" } : { hint: undefined };\n}\n\n/**\n * The family's floating label, as a real `<label for>` (lenkbank): the input is then\n * named the way {@link Input}'s is, so `getByLabelText` and any helper that walks\n * `<label htmlFor>` finds it. Same placement and type as {@link FieldLabel}, which\n * stays a `<span>` for the TRIGGER pickers — a `<button>` is labelable, but those\n * compose their own \"label: value\" name. `pointer-events-none` (from the class)\n * keeps a press on it landing on the field under it, as before.\n */\nexport function ComboboxFieldLabel({\n htmlFor,\n className,\n children,\n ...rest\n}: ComponentPropsWithoutRef<\"label\"> & { htmlFor: string }) {\n return (\n <label {...rest} htmlFor={htmlFor} className={cn(FLOATING_LABEL_STATIC, \"z-10\", className)}>\n {children}\n </label>\n );\n}\n\n/**\n * Where a combobox's rows come from, and how a query narrows them. Shared by the\n * trigger pickers ({@link useComboboxCore}) and the inline {@link Autocomplete}, so\n * the two cannot drift in what a failed lookup or a too-short query does.\n */\nexport interface OptionSourceOptions<V extends string | number> {\n /** Already-loaded options (client-side filtered unless `filter` is false), also\n * used to resolve labels. */\n options?: ComboOption<V>[];\n /** Async option source, debounced and race-safe; stale responses are ignored,\n * and a rejection is caught and reported as `failed`. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** External loading flag, OR-ed with the internal async state. */\n loading?: boolean;\n /**\n * Narrow `options` by the query (label/sublabel substring, folded for search: no case,\n * no accents, the locale's case rules — \"zurich\" finds Zürich, DUP-5). Default `true`.\n *\n * `false` shows `options` exactly as given, in the given order — for a list the\n * caller has already searched and ranked on a server (Keksdose's geocoder), which a\n * second, client-side substring filter could only get wrong: a provider that\n * matches \"Bahnhofstr.\" to \"Bahnhofstrasse\" is right, and a label filter would\n * throw that row away.\n */\n filter?: boolean;\n /**\n * Below this many (trimmed) characters nothing is offered and `loadOptions` is not\n * called. Default `0` — the pickers list everything on open. Set it for a source\n * that is costly or rate-limited: one letter against a geocoder matches half a\n * continent, and a request per opened panel is a request nobody asked for.\n */\n minChars?: number;\n /** Quiet time after the last keystroke before `loadOptions` runs. Default 150 ms. */\n debounceMs?: number;\n}\n\nexport interface OptionSource<V extends string | number> {\n results: ComboOption<V>[];\n busy: boolean;\n /** The last lookup for this query REJECTED. The rows are emptied with it: results\n * from an earlier query under a failed one would read as the answer to it. */\n failed: boolean;\n /** The query is shorter than `minChars`, so nothing was asked. */\n tooShort: boolean;\n}\n\n/**\n * The rows half of a combobox: client-side filtering, or a debounced, race-safe\n * `loadOptions` with its loading and failure states.\n *\n * `active` gates the async side — a closed list asks nothing. Loading is DERIVED\n * (\"the settled answer is for a different query\") rather than flagged on in the\n * effect, so there is no render between a keystroke and the debounce in which an\n * empty list could claim \"No results\" for a question still being asked.\n */\nexport function useOptionSource<V extends string | number>({\n options,\n loadOptions,\n loading,\n filter = true,\n minChars = 0,\n debounceMs = 150,\n query,\n active,\n}: OptionSourceOptions<V> & { query: string; active: boolean }): OptionSource<V> {\n const isAsync = typeof loadOptions === \"function\";\n const tooShort = query.trim().length < minChars;\n const [settled, setSettled] = useState<{\n query: string | null;\n results: ComboOption<V>[];\n failed: boolean;\n }>({ query: null, results: [], failed: false });\n const loadRef = useRef(loadOptions);\n useEffect(() => {\n loadRef.current = loadOptions;\n });\n const reqId = useRef(0);\n\n useEffect(() => {\n // Bumped even when nothing is asked, so a request still in flight from a longer\n // query cannot land after the user has deleted back below `minChars`.\n const id = ++reqId.current;\n if (!active || !isAsync || tooShort) return;\n const t = setTimeout(\n async () => {\n try {\n const r = await loadRef.current!(query);\n if (reqId.current === id) setSettled({ query, results: r, failed: false });\n } catch {\n // The one path the old `try/finally` had no answer for: the list kept the\n // previous query's rows and said nothing (Keksdose proposal §2).\n if (reqId.current === id) setSettled({ query, results: [], failed: true });\n }\n },\n query ? debounceMs : 0,\n );\n return () => clearTimeout(t);\n }, [query, active, isAsync, tooShort, debounceMs]);\n\n // Folded as every kit list folds (DUP-5, refactor audit 2026-10): plain `toLowerCase`\n // here meant \"zurich\" found no Zürich in kastlan's eighteen entity pickers, and the\n // Turkish \"ı\" no \"IRMAK\".\n const locale = useKitLocale();\n const clientResults = useMemo(() => {\n if (isAsync) return [];\n const src = options ?? [];\n const q = foldForSearch(query.trim(), locale);\n if (!filter || !q) return src;\n const hit = (s: string | undefined) => s !== undefined && foldForSearch(s, locale).includes(q);\n return src.filter((o) => hit(o.label) || hit(o.sublabel));\n }, [isAsync, options, query, filter, locale]);\n\n const pending = isAsync && active && !tooShort && settled.query !== query;\n const failed = isAsync && !tooShort && settled.failed;\n return {\n results: tooShort ? [] : isAsync ? (failed ? [] : settled.results) : clientResults,\n busy: Boolean(loading) || pending,\n failed: failed && !pending,\n tooShort,\n };\n}\n\nexport interface ComboboxCoreOptions<V extends string | number> extends OptionSourceOptions<V> {\n /**\n * Back closes the open anchored list, not the page or the dialog behind it — the rule\n * `useDropdown` keeps for its lists (keksdose live #309 rework). Default `false`, as the\n * entity pickers have always been; CurrencySelect, MultiSelect, GroupedPicker and\n * AmountInput's currency chip, which came over from `useDropdown` (DUP-4), pass `true`\n * so they keep it. On a phone the `PickerSheet` registers Back itself.\n */\n backCloses?: boolean;\n}\n\nexport interface ComboboxCore<V extends string | number> {\n triggerRef: RefObject<HTMLButtonElement | null>;\n panelRef: RefObject<HTMLDivElement | null>;\n inputRef: RefObject<HTMLInputElement | null>;\n open: boolean;\n setOpen: Dispatch<SetStateAction<boolean>>;\n query: string;\n setQuery: Dispatch<SetStateAction<string>>;\n active: number;\n setActive: Dispatch<SetStateAction<number>>;\n results: ComboOption<V>[];\n busy: boolean;\n /** See {@link OptionSource}. */\n failed: boolean;\n tooShort: boolean;\n minChars: number;\n rect: AnchorRect | null;\n /** Where the dropdown goes, clamped to the visible viewport (feedback #135). */\n placement: AnchoredPanel;\n /** Put an option in the label cache, so {@link ComboboxCore.resolve} still knows a\n * value the caller just chose after the result list has moved on. */\n rememberOption: (o: ComboOption<V>) => void;\n resolve: (v: V) => ComboOption<V> | null;\n /** Close and hand focus back to the trigger — the keyboard paths only. See\n * {@link useDropdown} for why a pointer dismissal must not do this. */\n closeToTrigger: () => void;\n}\n\n/**\n * Shared plumbing for the entity pickers: open/query/active state, portalled\n * anchoring + outside-click/Escape dismissal, focus-on-open, a debounced\n * race-safe async (or client-side) result list, and a label cache so a selected\n * value still renders its label after the async list has moved on. The single-\n * and multi-value comboboxes render their triggers on top of this and share\n * {@link ComboboxPanel} for the dropdown.\n */\nexport function useComboboxCore<V extends string | number>({\n options,\n minChars = 0,\n backCloses = false,\n ...source\n}: ComboboxCoreOptions<V>): ComboboxCore<V> {\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState(\"\");\n const [active, setActive] = useState(0);\n\n const close = () => setOpen(false);\n // Escape unmounts the panel the user is typing in; without this the browser drops\n // focus on <body>, so the caret disappears and the next Tab restarts at the top of\n // the page. A pointer dismissal deliberately does NOT do this — the press has\n // already decided where focus belongs.\n const closeToTrigger = () => {\n setOpen(false);\n triggerRef.current?.focus();\n };\n // Placement, not just the anchor rect: the panel has to dodge the on-screen\n // keyboard its own search box summons (feedback #135).\n const placement = useAnchoredPanel(triggerRef, open);\n const rect = placement.rect;\n // Outside-click dismissal belongs to the ANCHORED panel, and only to it. On a\n // phone `ComboboxPanel` renders a full-screen `PickerSheet` instead (live #200),\n // portalled to <body> and carrying its own ways out — the close X, Escape, and\n // Back through `useOverlayHistory` — so there is no outside left to press.\n //\n // Leaving the listener on there was not merely redundant, it was the bug:\n // `panelRef` is attached to the desktop panel alone, so with the sheet up every\n // press inside it answered \"outside\". While `useOutsideClick` listened for\n // `mousedown` the rows survived by accident — they commit on `onMouseDown` too,\n // and won the race — but `pointerdown` PRECEDES `mousedown`, so the sheet closed\n // at finger-down and the commit landed on an unmounted tree: a tapped row kept the\n // old value, and tapping the search box or the X was equally fatal. `PickerSheet`\n // stops `mousedown` for exactly this reason, but that guard was written for\n // `useDropdown`'s listener and never covered this hook.\n const isPhone = usePhoneLayout();\n useOutsideClick([triggerRef, panelRef], close, open && !isPhone);\n // A layer on the Escape stack while the anchored panel is open (Wave 2, DUP-1), so a\n // dialog around the picker closes only after it (BUG-1). `ComboboxPanel` takes the key\n // where focus is. On a phone the `PickerSheet` is the layer, as it is the outside.\n useDismissLayer(open && !isPhone, closeToTrigger);\n // See `backCloses`. The same close path a pointer dismissal takes.\n useOverlayHistory(backCloses && open && !isPhone, close);\n\n // Reset the query each time the panel opens, and the highlighted row whenever the\n // visible set changes (a new query, or the panel opening or closing). Adjusted while\n // rendering against the previous values rather than in an effect, so the render that\n // opens the panel already searches for \"\" and highlights the first row.\n const [prevOpen, setPrevOpen] = useState(open);\n const [prevQuery, setPrevQuery] = useState(query);\n if (open !== prevOpen || query !== prevQuery) {\n const opened = open && !prevOpen;\n setPrevOpen(open);\n setPrevQuery(opened ? \"\" : query);\n if (opened) setQuery(\"\");\n setActive(0);\n }\n\n // Focus the search box each time the panel opens.\n useEffect(() => {\n if (!open) return;\n const id = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(id);\n }, [open]);\n\n // Debounced, race-safe async search (only when loadOptions is provided) or the\n // client-side filter — see {@link useOptionSource}.\n const { results, busy, failed, tooShort } = useOptionSource<V>({\n ...source,\n options,\n minChars,\n query,\n active: open,\n });\n\n // Accumulate every option we've seen so a selected value can render its label\n // even after the async list has moved on to other query results.\n const cacheRef = useRef(new Map<V, ComboOption<V>>());\n useEffect(() => {\n for (const o of options ?? []) cacheRef.current.set(o.value, o);\n for (const o of results) cacheRef.current.set(o.value, o);\n }, [options, results]);\n const resolve = (v: V): ComboOption<V> | null =>\n options?.find((o) => o.value === v) ?? cacheRef.current.get(v) ?? null;\n const rememberOption = (o: ComboOption<V>) => {\n cacheRef.current.set(o.value, o);\n };\n\n return {\n triggerRef,\n panelRef,\n inputRef,\n open,\n setOpen,\n query,\n setQuery,\n active,\n setActive,\n results,\n busy,\n failed,\n tooShort,\n minChars,\n rect,\n placement,\n rememberOption,\n resolve,\n closeToTrigger,\n };\n}\n\n// The family's `error` is every field's `useFieldError` (field-parts) since 0.34 — the\n// restatement that stood here ignored a form library's `aria-invalid` (DUP-8).\n\n/** The anchored suggestion list's box and rows — one look for {@link Combobox},\n * {@link InlineEntityCombobox} and {@link Autocomplete}. */\n/**\n * A group's heading in a picker list stays at the top of the list while its rows scroll\n * under it (kk run 79 gap 3): with first-letter groups over two hundred payees, the\n * heading is the one thing that says where in the alphabet the thumb is. Opaque — the\n * list's own `bg-surface` — so the rows pass beneath it rather than through it. Shared\n * by every list that heads groups (the panel and the sheet, `Combobox`, `Autocomplete`,\n * `InlineEntityCombobox`).\n */\nexport const GROUP_HEADING_STICKY = \"sticky top-0 z-10 bg-surface\";\n\nexport const SUGGESTION_LIST_CLASS =\n \"max-h-64 overflow-y-auto rounded-md border border-subtle bg-surface py-1 shadow-lg\";\n\n// One line at Normal; from Large up a long suggestion wraps and its row grows (text size\n// §10.17, round 0.34 T1), like every other option list of the kit.\nexport const suggestionRowClass = (isActive: boolean) =>\n cn(\n \"block w-full truncate-until-large px-3 py-1.5 text-start text-sm text-primary\",\n isActive ? \"bg-active\" : \"hover:bg-hover\",\n );\n\n/**\n * Keep the option the keyboard is on inside the visible part of the list.\n *\n * `aria-activedescendant` moves a highlight WITHOUT moving focus, which is the whole\n * point of it — and the cost is that the browser scrolls nothing on its own. In a\n * panel capped at a few hundred pixels over an account list two hundred long, Down\n * walked the highlight straight out of the box and the list sat still.\n *\n * Optional-called because jsdom does not implement `scrollIntoView`: three consumers\n * run this component in their own suites, and a picker that throws there is a worse\n * trade than a list that does not scroll in a test.\n */\nexport function useActiveOptionScroll(activeId: string | undefined): void {\n useEffect(() => {\n if (!activeId) return;\n document.getElementById(activeId)?.scrollIntoView?.({ block: \"nearest\" });\n }, [activeId]);\n}\n\n/** The anchored panel's least width, in rem: 220 px at Normal (§3.2). */\nconst PANEL_MIN_REM = 13.75;\n\n/** The room the anchored panel keeps from either edge of the glass, in px —\n * `anchoredInline`'s default. */\nconst PANEL_EDGE = 8;\n\n/**\n * How wide the anchored panel is. The phone sheet is the screen's width whatever this\n * says.\n */\nexport interface ComboboxPanelWidth {\n /** The least width, in rem — never under the trigger's own. Default 13.75 (220 px at\n * Normal, §3.2). */\n minRem?: number;\n /**\n * As wide as the rows make it (`max-content`), between the least width and `maxRem`,\n * instead of exactly the least — measured, so the clamp to the glass still knows it.\n * CurrencySelect's list grows to show the full currency names (feedback #308);\n * MultiSelect's rows to show their hints (keksdose #147). A `w-*` class in the panel's\n * `className` does not apply: the panel is portalled to <body>, where `w-full` would be\n * the screen.\n */\n fit?: boolean;\n /** With `fit`, the most it grows to, in rem. Default: the glass. */\n maxRem?: number;\n}\n\nexport interface ComboboxPanelProps<V extends string | number>\n extends ComponentPropsWithoutRef<\"div\"> {\n core: ComboboxCore<V>;\n /** What the trigger's `aria-controls` names. Owned by the component that renders\n * the trigger, not by the core: one id has to reach both, and only one of them\n * can be the origin. */\n listboxId: string;\n /** Default: `combobox.search` from the {@link UiKitProvider}, else English. */\n searchPlaceholder?: string;\n /** Default: `combobox.noResults` from the {@link UiKitProvider}, else English. */\n emptyLabel?: string;\n multi?: boolean;\n isSelected: (v: V) => boolean;\n onChoose: (o: ComboOption<V>) => void;\n showCreate: boolean;\n onCreate: () => void;\n createContent: ReactNode;\n /**\n * The create row is shown but not takeable, and this says why — the lock's reason\n * when the picker's `createCommit` meets a locked {@link WriteLockProvider}. Rendered\n * as the row's second line rather than a tooltip, as {@link ComboOption.disabled}\n * asks of every disabled row: a hover is the one explanation a phone cannot show.\n */\n createDisabledReason?: ReactNode;\n /** What the sheet calls itself on a phone — the field's label. Ignored on\n * desktop, where the panel sits under the field that already says it. */\n sheetTitle?: ReactNode;\n closeLabel?: string;\n /** Default: `combobox.loadError` from the {@link UiKitProvider}, else English. */\n loadErrorLabel?: string;\n /**\n * What a row shows in place of its label and sublabel — for a row that says more than\n * two strings: CurrencySelect's symbol, code and name side by side. The option's\n * `icon`, the multi checkbox and the check mark stay the panel's. Its text is the\n * option's accessible name, so separate the parts with a space.\n */\n renderOption?: (o: ComboOption<V>) => ReactNode;\n /** Controls between the search box and the list, in the anchored panel and the phone\n * sheet alike — MultiSelect's \"Select all\" and \"Clear\". */\n toolbar?: ReactNode;\n /** See {@link ComboboxPanelWidth}. */\n width?: ComboboxPanelWidth;\n /** Which of the trigger's edges the anchored panel hangs from, by reading direction.\n * Default `start`; `end` grows the panel toward the start, so a field with content\n * after it is not pushed past the page (CurrencySelect, feedback #308). */\n align?: \"start\" | \"end\";\n /**\n * Lay the rows out in columns, one block per `group`, with the group's name above it —\n * GroupedPicker's panel (feedback #267/#276): a large grouped set reads as a sheet of\n * short lists side by side rather than one long one. Each block is a `role=\"group\"`\n * named by its heading. The arrow keys walk the rows in reading order, down each\n * column. The phone sheet keeps one column with headings.\n */\n columns?: boolean;\n}\n\n/**\n * The portalled dropdown (search header + result rows + optional create row)\n * shared by the single- and multi-value comboboxes. Start-aligned to the trigger\n * and sized to its width; `multi` swaps the trailing check for a leading\n * checkbox. `onChoose` decides whether to close (single) or stay open (multi).\n *\n * ## The ARIA, which is `CommandPalette`'s\n *\n * This rendered a `role=\"listbox\"` of `role=\"option\"` rows and stopped there, so a\n * reader was handed a text box and silence: the highlight the arrow keys move lived\n * only in a background colour, and nothing tied the box being typed in to the list\n * being filtered. `CommandPalette` has had the whole model since it was written —\n * `aria-controls` from the field to the list, `aria-activedescendant` naming the row\n * the keyboard is on — and it was the only thing in the package that did.\n *\n * Two distinct states, deliberately not conflated:\n * - `aria-selected` is CHOSEN. It is the check mark, and in `multi` the checkbox.\n * - `aria-activedescendant` is where the KEYBOARD is. Announcing that as selected\n * would tell a reader that the row they are merely passing over is the answer.\n *\n * `role=\"option\"` sits on the `<button>`, not on the `<li>` around it, for the same\n * reason it does in `CommandPalette`: an option may not contain a separately\n * focusable control, and the button is the thing a pointer presses. The rows are\n * `tabIndex={-1}` because focus never leaves the search box — that is what\n * `aria-activedescendant` is FOR.\n */\nexport function ComboboxPanel<V extends string | number>({\n core,\n listboxId,\n searchPlaceholder,\n emptyLabel,\n multi,\n isSelected,\n onChoose,\n showCreate,\n onCreate,\n createContent,\n createDisabledReason,\n sheetTitle,\n closeLabel,\n loadErrorLabel,\n renderOption,\n toolbar,\n width,\n align = \"start\",\n columns,\n className,\n style,\n ...rest\n}: ComboboxPanelProps<V>) {\n const createLocked = hasContent(createDisabledReason);\n const {\n rect,\n placement,\n panelRef,\n inputRef,\n query,\n setQuery,\n results,\n busy,\n failed,\n tooShort,\n active,\n setActive,\n closeToTrigger,\n } = core;\n // The phone gets a full-screen sheet instead of an anchored panel (live #200).\n // Same core, same results, same handlers — only the container differs, so the\n // two presentations cannot drift in what they offer.\n const isPhone = usePhoneLayout();\n // Every row the keyboard can land on, the create row included — passed over, like a\n // disabled option, while a write lock holds it.\n const rows: readonly { disabled?: boolean }[] = showCreate\n ? [...results, { disabled: createLocked }]\n : results;\n const rowCount = rows.length;\n const optionId = (index: number) => `${listboxId}-option-${index}`;\n // The core opens on row 0 and knows nothing of `disabled`; the highlight is settled\n // HERE, derived, so it can never rest on a row that cannot be taken — whatever the\n // async list turned out to hold.\n const current = settleEnabled(rows, active);\n const activeId = current >= 0 ? optionId(current) : undefined;\n useActiveOptionScroll(activeId);\n // The consumers resolve their own props against the provider already; this is\n // for the loading row, which no consumer names, and for a caller that renders the\n // panel directly and leaves the two optional strings out.\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS);\n // Portalled to <body>, the panel leaves the subtree its `dir` came from — so the\n // direction is read off the trigger and put back on the panel below.\n const dir = useAnchorDir(core.triggerRef, core.open);\n const remPx = useRemPx();\n // A `fit` panel's measured width — what it takes to keep it on the glass (see\n // `ComboboxPanelWidth.fit`). Observed rather than read once: the rows change under the\n // search, and a filtered list of short names is a narrower panel. `null` where nothing\n // is laid out (jsdom), and the least width is used.\n const fit = width?.fit === true && !isPhone;\n const [fitWidth, setFitWidth] = useState<number | null>(null);\n const placed = core.open && rect !== null;\n useLayoutEffect(() => {\n const el = panelRef.current;\n if (!fit || !placed || !el || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(() => {\n const measured = el.getBoundingClientRect().width;\n setFitWidth(measured > 0 ? measured : null);\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, [fit, placed, panelRef]);\n\n // The WAI-ARIA APG's listbox keyboard, in full: Up/Down step, Home/End jump, Enter\n // commits, Tab leaves, Escape closes. On the panel's search box — in the anchored\n // panel and, through `onSearchKeyDown`, in the phone sheet's header (BUG-5).\n const onKeyDown = (e: ReactKeyboardEvent) => {\n // Escape goes to the top of the kit's Escape stack — this list, which opened over\n // any dialog it sits in — and stops HERE (round 0.34 BUG-1, Wave 2 DUP-1). The\n // panel's events travel up the React tree through that dialog, portal or not, and\n // one press used to close the dialog and throw the form away, list still open.\n if (takeEscape(e)) return;\n // The Enter that confirms an IME composition is the IME's (BUG-9).\n if (isImeEnter(e)) return;\n // Disabled rows are passed over (`stepEnabled`), and each step starts from the\n // SETTLED highlight, not the raw index, so the first Down from a disabled row 0\n // goes to the row after the one already shown as highlighted.\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActive(stepEnabled(rows, current, 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActive(current < 0 ? -1 : stepEnabled(rows, current, -1));\n } else if (e.key === \"Home\") {\n e.preventDefault();\n setActive(stepEnabled(rows, -1, 1));\n } else if (e.key === \"End\") {\n e.preventDefault();\n setActive(stepEnabled(rows, rowCount, -1));\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n if (current < 0) return;\n if (current < results.length) onChoose(results[current]);\n else if (showCreate && !createLocked) onCreate();\n } else if (e.key === \"Tab\" && !isPhone) {\n // The panel is PORTALLED to <body>, so the browser's own Tab would move from\n // here to whatever follows the portal — i.e. off the end of the document. The\n // trade is one extra Tab (trigger, then onward) against never stranding focus\n // at the bottom of the page. The phone sheet is a dialog, and its trap keeps Tab.\n e.preventDefault();\n closeToTrigger();\n }\n };\n\n // What the list holds, said in ONE place that is both on screen and a polite\n // live region. Focus stays in the search box, so the list changing under it was\n // silent — a reader typed and heard nothing back, and a failed lookup was the same\n // silence as a slow one. Outside the listbox, which may own only options.\n //\n // Three different empties, and only one of them is \"nothing matched\": a lookup\n // that failed must not claim there is nothing to find, and a query under\n // `minChars` was never asked. With rows showing, the count is for the reader only.\n const message: ReactNode =\n busy && results.length === 0 ? (\n // The ellipsis is the picture; the words are for a reader, who otherwise met\n // an empty-looking list with a lone \"…\" in it — or, in most readers, nothing\n // at all, since punctuation alone is skipped.\n <>\n <span aria-hidden>…</span>\n <span className=\"sr-only\">{labels.loading}</span>\n </>\n ) : busy ? (\n // Loading with the LAST query's rows still up. This was `null`, so a refetch —\n // a new query, or a caller's `loading` while it reloads — looked exactly like a\n // finished list: rows that were about to be replaced, with nothing saying so.\n // A line of its own under the rows, in words, so it reads without the spinner.\n <span className=\"flex items-center gap-2\">\n <Spinner label={null} className=\"size-3.5 border\" />\n {labels.loading}\n </span>\n ) : results.length === 0 && !showCreate ? (\n failed ? (\n (loadErrorLabel ?? labels.loadError)\n ) : tooShort ? (\n labels.minChars(core.minChars)\n ) : (\n (emptyLabel ?? labels.noResults)\n )\n ) : null;\n // `relative` so the sr-only text has a local containing block (see\n // sr-only-containment.test).\n const announcement = (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className={cn(\n \"relative\",\n message !== null && cn(\"py-2 text-sm\", isPhone ? \"px-4\" : \"px-3\"),\n failed ? \"text-danger\" : \"text-muted\",\n )}\n >\n {message ??\n (results.length > 0 && (\n <span className=\"sr-only\">{labels.resultCount(results.length)}</span>\n ))}\n </div>\n );\n\n if (!core.open || typeof document === \"undefined\") return null;\n\n // One option row — the same in both containers and in both layouts.\n const optionRow = (o: ComboOption<V>, i: number) => {\n const selected = isSelected(o.value);\n return (\n <li role=\"presentation\">\n <button\n type=\"button\"\n id={optionId(i)}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={o.disabled || undefined}\n tabIndex={-1}\n onMouseDown={(e) => {\n e.preventDefault();\n if (!o.disabled) onChoose(o);\n }}\n onMouseEnter={() => {\n if (!o.disabled) setActive(i);\n }}\n className={cn(\n isPhone\n ? SHEET_ROW_CLASS\n : columns\n ? // A cell of a column (GroupedPicker): tighter, so four columns fit.\n \"flex w-full items-center gap-1.5 rounded px-1.5 py-0.5 text-start text-sm\"\n : \"flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm\",\n // The row the arrows are on shows it on a phone too: the sheet takes\n // the keyboard (BUG-5), and a tablet or a desktop at Large has one.\n o.disabled\n ? DISABLED_ROW_CLASS\n : i === current\n ? \"bg-active\"\n : !isPhone && \"hover:bg-hover\",\n // After SHEET_ROW_CLASS, so its hover is the one cancelled.\n o.disabled && isPhone && DISABLED_ROW_CLASS,\n )}\n >\n {multi && (\n <span\n // The checkbox is a PICTURE of `aria-selected` above, so a reader\n // that met both would be told twice.\n aria-hidden\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded border\",\n selected\n ? \"border-[var(--bg-inverse)] bg-inverse text-inverse\"\n : \"border-strong bg-surface\",\n )}\n >\n {selected && <Check className=\"size-3\" />}\n </span>\n )}\n {o.icon && <span className=\"shrink-0\">{o.icon}</span>}\n {renderOption ? (\n <span className=\"flex min-w-0 flex-1 items-center gap-2\">{renderOption(o)}</span>\n ) : (\n /* Label and sublabel wrap from Large up (text size §10.17, round 0.34 T1). */\n <span className=\"min-w-0 flex-1\">\n <span className={cn(\"block truncate-until-large text-primary\", columns && selected && \"font-medium\")}>\n {o.label}\n </span>\n {o.sublabel && (\n <span className=\"block truncate-until-large text-xs text-placeholder\">{o.sublabel}</span>\n )}\n </span>\n )}\n {!multi && selected && <Check className=\"size-4 shrink-0 text-brand\" />}\n </button>\n </li>\n );\n };\n\n const createRow = showCreate && (\n <li role=\"presentation\">\n <button\n type=\"button\"\n id={optionId(results.length)}\n role=\"option\"\n // Never chosen — it is an action, and it disappears the moment it has\n // been taken. Whether the keyboard is ON it is `aria-activedescendant`'s\n // job to say.\n aria-selected={false}\n aria-disabled={createLocked || undefined}\n tabIndex={-1}\n onMouseDown={(e) => {\n e.preventDefault();\n if (!createLocked) onCreate();\n }}\n onMouseEnter={() => {\n if (!createLocked) setActive(results.length);\n }}\n className={cn(\n isPhone\n ? SHEET_ROW_CLASS\n : \"flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm\",\n \"text-secondary\",\n createLocked\n ? DISABLED_ROW_CLASS\n : current === results.length\n ? \"bg-active\"\n : !isPhone && \"hover:bg-hover\",\n // After SHEET_ROW_CLASS, so its hover is the one cancelled.\n createLocked && isPhone && DISABLED_ROW_CLASS,\n )}\n >\n <Plus className=\"size-4 shrink-0\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate-until-large\">{createContent}</span>\n {createLocked && (\n <span className=\"block truncate-until-large text-xs text-placeholder\">\n {createDisabledReason}\n </span>\n )}\n </span>\n </button>\n </li>\n );\n\n // In columns, a block per run of one group; `results` keeps its source order, so a\n // run is the rows up to the next change of group.\n const blocks: { group: string; rows: { o: ComboOption<V>; i: number }[] }[] = [];\n if (columns && !isPhone) {\n results.forEach((o, i) => {\n const group = o.group ?? \"\";\n const last = blocks[blocks.length - 1];\n if (last && last.group === group) last.rows.push({ o, i });\n else blocks.push({ group, rows: [{ o, i }] });\n });\n }\n\n const list = (\n <ul\n id={listboxId}\n role=\"listbox\"\n aria-multiselectable={multi}\n // The rows are provisional while a lookup is in flight — whether or not the\n // previous query's are still showing.\n aria-busy={busy || undefined}\n // It scrolls, and says so where jsdom can see it (see `CLIPS_ATTRIBUTE`): a\n // Tooltip in a row then portals out in a test exactly as it does in the\n // browser, instead of joining the option's accessible name (keksdose E8).\n {...{ [CLIPS_ATTRIBUTE]: \"\" }}\n className={cn(\n \"min-h-0 flex-1 overflow-y-auto\",\n columns && !isPhone ? \"columns-2 gap-4 p-3 md:columns-3 xl:columns-4\" : \"py-1\",\n isPhone && \"flex-none\",\n )}\n >\n {columns && !isPhone\n ? blocks.map((block) => (\n // A column block: its heading is a picture of the group's name, which the\n // `role=\"group\"` carries for a reader — the listbox may own options and\n // groups, and a heading of loose text in it is neither.\n <li key={`${block.group}|${block.rows[0].i}`} role=\"presentation\" className=\"mb-3 break-inside-avoid\">\n {block.group && (\n <div aria-hidden className=\"mb-1 text-xs font-semibold uppercase tracking-wide text-muted\">\n {block.group}\n </div>\n )}\n <ul role=\"group\" aria-label={block.group || undefined} className=\"space-y-0.5\">\n {block.rows.map(({ o, i }) => (\n <Fragment key={`${o.group ?? \"\"}|${String(o.value)}`}>{optionRow(o, i)}</Fragment>\n ))}\n </ul>\n </li>\n ))\n : results.map((o, i) => {\n // One heading per group rather than a grey suffix on every row (#136), and\n // the thing the native <select>'s <optgroup> used to give the account\n // picker for free (live #200). `results` keeps its source order, so a\n // boundary is simply \"different from the row above\".\n const startsGroup = o.group != null && o.group !== results[i - 1]?.group;\n return (\n // Keyed by group AND value: an option may deliberately appear twice —\n // Keksdose repeats recently-used categories in a \"Recent\" group at the\n // top (live #203) — and a bare value key would collide.\n <Fragment key={`${o.group ?? \"\"}|${String(o.value)}`}>\n {startsGroup && (\n <li\n role=\"presentation\"\n className={cn(\n GROUP_HEADING_STICKY,\n \"font-semibold uppercase tracking-wide text-muted\",\n isPhone ? \"px-4 pb-1 pt-3 text-xs\" : \"px-3 pb-0.5 pt-2 text-caption first:pt-1\",\n )}\n >\n {o.group}\n </li>\n )}\n {optionRow(o, i)}\n </Fragment>\n );\n })}\n {createRow}\n </ul>\n );\n\n // The search box is NAMED, not only prompted: a placeholder is gone the moment a\n // character is typed, and jsdom's readers and some real ones never took it for a name\n // (BUG-12: GroupedPicker's filter had \"no name beyond its placeholder\").\n const searchText = searchPlaceholder ?? labels.search;\n\n if (isPhone) {\n return (\n <PickerSheet\n // First, so the sheet's own props below win: `rest` is typed as div\n // attributes, and the DOM's `title` is a tooltip string where the sheet's is\n // its heading — one name, two meanings, and the sheet's is the one the caller\n // asked for.\n {...rest}\n className={className}\n style={style}\n open\n onClose={() => core.setOpen(false)}\n title={sheetTitle}\n query={query}\n onQueryChange={setQuery}\n searchPlaceholder={searchText}\n searchLabel={searchText}\n inputRef={inputRef}\n closeLabel={closeLabel}\n // The sheet's search box is in its HEADER, outside the list: the keys go to it\n // there, and it names the list and the active row (BUG-5). A div around the list\n // used to catch them, and never did — focus is in the box, not in the list.\n onSearchKeyDown={onKeyDown}\n listboxId={listboxId}\n activeId={activeId}\n // A multi list stays open as rows are ticked, so the sheet needs a way out\n // that is not the X in its corner: the kit's sticky \"Done\" (keksdose #412).\n // A single pick closes the sheet itself.\n done={multi}\n >\n {toolbar}\n <div className=\"relative\">\n {list}\n {announcement}\n </div>\n </PickerSheet>\n );\n }\n\n if (!rect) return null;\n // The panel hangs from the trigger's START edge (or, `align=\"end\"`, its end): its left\n // in a left-to-right form, its right in a right-to-left one, at least 13.75rem wide\n // (220 px at Normal, in rem so its text keeps its room at Large, §3.2; `width.minRem`)\n // and never wider than the glass — and clamped to the glass, which in a left-to-right\n // form it never was (Wave 2, DUP-7). It is placed by the edge it hangs from, so a `fit`\n // panel grows away from the trigger's edge before its width is measured; a box hung by\n // its `right` is measured from inside any scrollbar, as the glass's width is.\n const glass = viewportSize().width - 2 * PANEL_EDGE;\n const least = Math.min(Math.max(rect.width, (width?.minRem ?? PANEL_MIN_REM) * remPx), glass);\n const most = Math.max(least, Math.min(width?.maxRem !== undefined ? width.maxRem * remPx : glass, glass));\n const panelWidth = fit ? Math.min(Math.max(fitWidth ?? least, least), most) : least;\n const at = anchoredInline(rect, panelWidth, { dir, align, edge: PANEL_EDGE });\n const inline = (dir === \"rtl\") === (align === \"start\") ? { right: at.right } : { left: at.left };\n\n return createPortal(\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused\n itself: it catches the listbox keys bubbling from the search <input> inside it,\n which holds focus while the panel is open. */\n <div\n // Spread FIRST: `onKeyDown` below is the listbox keyboard (Up/Down/Home/End/\n // Enter/Tab) and the placement is measured rather than chosen, so neither is a\n // caller's to replace by accident — while a `data-*` anchor or an\n // `aria-describedby` has nothing to collide with.\n {...rest}\n ref={panelRef}\n dir={dir}\n onKeyDown={onKeyDown}\n // A press in a panel opened from a row is inside this list for the core's outside\n // press, though portalled elsewhere (dev#623).\n onPointerDownCapture={(e) => {\n rest.onPointerDownCapture?.(e);\n pressInside(panelRef)?.(e);\n }}\n // `placement` keeps the panel inside the region actually on screen: on a phone\n // the search box below pulls up the keyboard, and a panel pinned under a\n // low trigger would otherwise sit entirely behind it (feedback #135). Flipped\n // above, it hangs from its bottom edge, so a list shorter than its cap still meets\n // the trigger (keksdose K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: placement.above ? undefined : placement.top,\n bottom: placement.above ? placement.bottom : undefined,\n ...inline,\n // A `fit` panel takes its width from its rows between the two bounds; any other\n // is exactly the least width.\n ...(fit ? { width: \"max-content\", minWidth: least, maxWidth: most } : { width: panelWidth }),\n maxHeight: placement.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col rounded-md border border-subtle bg-surface shadow-lg\",\n className,\n )}\n >\n <DropdownSearchHeader\n query={query}\n onQueryChange={setQuery}\n inputRef={inputRef}\n placeholder={searchText}\n aria-label={searchText}\n // Focus is in this box while the list is up, so this is what has to name the\n // list and the row the arrows are on.\n listboxId={listboxId}\n activeId={activeId}\n />\n {toolbar}\n {/* One list, two containers: the desktop panel and the phone sheet render\n the same rows through the same handlers (live #200). */}\n {list}\n {announcement}\n </div>,\n document.body,\n );\n}\n"],"mappings":";AA6KI,SAukBE,UAvkBF,KAukBE,YAvkBF;AA7KJ,SAAS,YAAAA,WAAU,WAAW,iBAAiB,SAAS,QAAQ,gBAAgB;AAChF,SAAS,oBAAoB;AAS7B,SAAS,OAAO,YAAY;AAC5B,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,aAAa,uBAAuB;AAC7C,SAAS,gBAAgB,gBAAgB;AACzC,SAAS,6BAA6B;AACtC,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,kBAAkB,oBAAwC;AACnF,SAAS,aAAa,YAAY,iBAAiB,uBAAuB;AAC1E,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB,cAAc,oBAAoB;AACpE,SAAS,kBAAkB;AAiDpB,MAAM,kBAAkB,CAAC,MAC9B,MAAM,UAAa,CAAC,EAAE;AAQjB,SAAS,YACd,MACA,MACA,KACQ;AACR,WAAS,IAAI,OAAO,KAAK,KAAK,KAAK,IAAI,KAAK,QAAQ,KAAK,KAAK;AAC5D,QAAI,CAAC,KAAK,CAAC,EAAE,SAAU,QAAO;AAAA,EAChC;AACA,SAAO,QAAQ,KAAK,OAAO,KAAK,S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AM,KAAK,eAAe,MAAM,YAAY,EAAE,KAAK,OAAO,MAAM,WAAW,CAAC;AAC5E,QAAM,SAAU,QAAQ,WAAY,UAAU,WAAW,EAAE,OAAO,GAAG,MAAM,IAAI,EAAE,MAAM,GAAG,KAAK;AAE/F,SAAO;AAAA;AAAA;AAAA;AAAA,IAIL;AAAA,MAAC;AAAA;AAAA,QAKE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QAGA,sBAAsB,CAAC,MAAM;AAC3B,eAAK,uBAAuB,CAAC;AAC7B,sBAAY,QAAQ,IAAI,CAAC;AAAA,QAC3B;AAAA,QAMA,OAAO;AAAA,UACL,GAAG;AAAA,UACH,UAAU;AAAA,UACV,KAAK,UAAU,QAAQ,SAAY,UAAU;AAAA,UAC7C,QAAQ,UAAU,QAAQ,UAAU,SAAS;AAAA,UAC7C,GAAG;AAAA;AAAA;AAAA,UAGH,GAAI,MAAM,EAAE,OAAO,eAAe,UAAU,OAAO,UAAU,KAAK,IAAI,EAAE,OAAO,WAAW;AAAA,UAC1F,WAAW,UAAU;AAAA,QACvB;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,QAEA;AAAA;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,eAAe;AAAA,cACf;AAAA,cACA,aAAa;AAAA,cACb,cAAY;AAAA,cAGZ;AAAA,cACA;AAAA;AAAA,UACF;AAAA,UACC;AAAA,UAGA;AAAA,UACA;AAAA;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":["Fragment"]}
1
+ {"version":3,"sources":["../../src/components/combobox-core.tsx"],"sourcesContent":["import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type {\n ComponentPropsWithoutRef,\n Dispatch,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n RefObject,\n SetStateAction,\n} from \"react\";\nimport { Check, Plus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { CLIPS_ATTRIBUTE } from \"../lib/clipping\";\nimport { DropdownSearchHeader } from \"./dropdown\";\nimport { PickerSheet, SHEET_ROW_CLASS } from \"./picker-sheet\";\nimport { usePhoneLayout, useRemPx } from \"../hooks/use-breakpoint\";\nimport { FLOATING_LABEL_STATIC } from \"./field-parts\";\nimport { Spinner } from \"./spinner\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\nimport { type AnchorRect } from \"../hooks/use-anchored-rect\";\nimport { anchoredInline, useAnchoredPanel, viewportSize, type AnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { pressInside, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { isImeEnter } from \"../lib/ime\";\nimport { foldForSearch } from \"../lib/text-match\";\nimport { DEFAULT_COMBOBOX_LABELS, useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { hasContent } from \"../lib/presence\";\n\n/**\n * What an entity picker hands `onChange` when it is cleared — `clearValue` on\n * {@link EntityCombobox} and {@link InlineEntityCombobox}. `null` by default.\n *\n * A closed set rather than any value, on purpose: every member is something no\n * option can be (an option's value is a `string | number`, and `\"\"` is never a real\n * id), so the picker can also READ it back — a field whose `value` is the clear\n * value shows as empty, with no clear button, exactly as `null` does. An arbitrary\n * sentinel could collide with an id and would make that read ambiguous.\n *\n * No `undefined`: a prop set to `undefined` is a prop not passed, so it would read as\n * the default and emit `null` — the one outcome the caller had asked not to get.\n */\nexport type ComboClearValue = null | \"\";\n\nexport interface ComboOption<V extends string | number> {\n value: V;\n label: string;\n sublabel?: string;\n icon?: ReactNode;\n /**\n * Section this option belongs to. Where a consumer renders it as a heading with the\n * members indented beneath — {@link InlineEntityCombobox} does — this is a genuine\n * grouping, not decoration: the name appears once per section rather than trailing\n * every row in small grey type, which is barely legible on a phone (feedback #136).\n * The heading stays at the top of the list while its rows scroll beneath it.\n *\n * NOT searched (0.40, kk run 79): a group is where a row is filed, not what it is\n * called — with first-letter groups (\"A\", \"B\", … \"#\"), typing \"a\" matched every row\n * filed under A. Searching a category's name means putting it in `sublabel`.\n */\n group?: string;\n /**\n * Shown but not takeable: rendered dimmed with `aria-disabled`, passed over by the\n * arrow keys, and a click or Enter on it does nothing. For a row whose existence is\n * the information — a write-locked result, an account that is closed — where\n * leaving it out would read as \"there is no such thing\". Say WHY in `sublabel`: a\n * hover tooltip is the one explanation a phone cannot show.\n *\n * Honoured by {@link Autocomplete}, {@link InlineEntityCombobox} and the panel\n * pickers ({@link EntityCombobox}, {@link MultiEntityCombobox}); on those an already\n * chosen disabled option stays chosen — the row only refuses to be toggled.\n */\n disabled?: boolean;\n}\n\n/** A row the user may take — present and not {@link ComboOption.disabled}. */\nexport const isOptionEnabled = (o: { disabled?: boolean } | undefined): boolean =>\n o !== undefined && !o.disabled;\n\n/**\n * The next takeable row from `from`, stepping `dir` — what the arrow keys use so a\n * disabled row is passed over, as the APG allows. Stays on `from` at the end of the\n * list (the family's arrows clamp rather than wrap) and answers `-1` when `from` is\n * not a row and there is nothing to step to.\n */\nexport function stepEnabled(\n rows: readonly { disabled?: boolean }[],\n from: number,\n dir: 1 | -1,\n): number {\n for (let i = from + dir; i >= 0 && i < rows.length; i += dir) {\n if (!rows[i].disabled) return i;\n }\n return from >= 0 && from < rows.length ? from : -1;\n}\n\n/** `i` when that row is takeable, else the nearest takeable one after it, else\n * before it, else `-1`. For a highlight that starts on a fixed index (the panel\n * pickers open on row 0) and must never rest on a disabled row. */\nexport function settleEnabled(rows: readonly { disabled?: boolean }[], i: number): number {\n if (i < 0 || i >= rows.length) return -1;\n if (!rows[i].disabled) return i;\n const after = stepEnabled(rows, i, 1);\n if (after !== i) return after;\n const before = stepEnabled(rows, i, -1);\n return before !== i ? before : -1;\n}\n\n/** Classes a disabled row adds over its normal ones — dimmed, no hover, the\n * kit's soft-disabled look (`DangerConfirm`, `SignaturePad`). */\nexport const DISABLED_ROW_CLASS = \"cursor-not-allowed opacity-50 hover:bg-transparent\";\n\n/**\n * Whether an entity picker offers its create row — one rule for\n * {@link EntityCombobox}, {@link MultiEntityCombobox} and {@link InlineEntityCombobox}.\n *\n * With a query: while the trimmed query names no option exactly (case-insensitive) —\n * an exact hit is a record the list is already showing, and a second way to \"make\" it\n * would mint a duplicate. With NO query: only when the caller named the row for that\n * case (`createEmptyLabel`) — a row reading `Create “”` says nothing, and the kit cannot\n * know the noun (\"Create cash account\") that would make it say something (keksdose G9).\n *\n * `names` is what the query is compared against: the loaded rows for a panel picker\n * (its async list is all it knows), every option for the inline one.\n */\nexport function offersCreate(\n onCreate: unknown,\n query: string,\n names: readonly string[],\n createEmptyLabel: string | undefined,\n): boolean {\n if (!onCreate) return false;\n if (!query) return Boolean(createEmptyLabel);\n const q = query.toLowerCase();\n return !names.some((n) => n.toLowerCase() === q);\n}\n\n/**\n * {@link EndHintRow}'s `hint` and `className` for a combobox-family field, keeping the\n * 0.22 rule (keksdose): a field that was passed `hint` at all — even `undefined` — keeps\n * ONE box, so a hint coming and going never rebuilds the control under the cursor.\n *\n * A text hint is a caption after the control and never moved it; the case this covers\n * is the \"?\" (a {@link FieldHint}) on a field with no label line, which sits at the end\n * edge in a row of its own. Without this the row existed only while the \"?\" did, and\n * the control was re-parented — remounted, focus and caret lost — each time it came or\n * went. With `hint` passed the row stays, its end slot empty and its gap closed, so\n * nothing on screen moves either.\n */\nexport function endHintRowProps(\n hintPassed: boolean,\n hasLabel: boolean,\n labelHint: ReactNode | undefined,\n): { hint: ReactNode | undefined; className?: string } {\n if (hasLabel) return { hint: undefined };\n if (labelHint !== undefined) return { hint: labelHint };\n return hintPassed ? { hint: null, className: \"gap-0\" } : { hint: undefined };\n}\n\n/**\n * The family's floating label, as a real `<label for>` (lenkbank): the input is then\n * named the way {@link Input}'s is, so `getByLabelText` and any helper that walks\n * `<label htmlFor>` finds it. Same placement and type as {@link FieldLabel}, which\n * stays a `<span>` for the TRIGGER pickers — a `<button>` is labelable, but those\n * compose their own \"label: value\" name. `pointer-events-none` (from the class)\n * keeps a press on it landing on the field under it, as before.\n */\nexport function ComboboxFieldLabel({\n htmlFor,\n className,\n children,\n ...rest\n}: ComponentPropsWithoutRef<\"label\"> & { htmlFor: string }) {\n return (\n <label {...rest} htmlFor={htmlFor} className={cn(FLOATING_LABEL_STATIC, \"z-10\", className)}>\n {children}\n </label>\n );\n}\n\n/**\n * Where a combobox's rows come from, and how a query narrows them. Shared by the\n * trigger pickers ({@link useComboboxCore}) and the inline {@link Autocomplete}, so\n * the two cannot drift in what a failed lookup or a too-short query does.\n */\nexport interface OptionSourceOptions<V extends string | number> {\n /** Already-loaded options (client-side filtered unless `filter` is false), also\n * used to resolve labels. */\n options?: ComboOption<V>[];\n /** Async option source, debounced and race-safe; stale responses are ignored,\n * and a rejection is caught and reported as `failed`. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** External loading flag, OR-ed with the internal async state. */\n loading?: boolean;\n /**\n * Narrow `options` by the query (label/sublabel substring, folded for search: no case,\n * no accents, the locale's case rules — \"zurich\" finds Zürich, DUP-5). Default `true`.\n *\n * `false` shows `options` exactly as given, in the given order — for a list the\n * caller has already searched and ranked on a server (Keksdose's geocoder), which a\n * second, client-side substring filter could only get wrong: a provider that\n * matches \"Bahnhofstr.\" to \"Bahnhofstrasse\" is right, and a label filter would\n * throw that row away.\n */\n filter?: boolean;\n /**\n * Below this many (trimmed) characters nothing is offered and `loadOptions` is not\n * called. Default `0` — the pickers list everything on open. Set it for a source\n * that is costly or rate-limited: one letter against a geocoder matches half a\n * continent, and a request per opened panel is a request nobody asked for.\n */\n minChars?: number;\n /** Quiet time after the last keystroke before `loadOptions` runs. Default 150 ms. */\n debounceMs?: number;\n}\n\nexport interface OptionSource<V extends string | number> {\n results: ComboOption<V>[];\n busy: boolean;\n /** The last lookup for this query REJECTED. The rows are emptied with it: results\n * from an earlier query under a failed one would read as the answer to it. */\n failed: boolean;\n /** The query is shorter than `minChars`, so nothing was asked. */\n tooShort: boolean;\n}\n\n/**\n * The rows half of a combobox: client-side filtering, or a debounced, race-safe\n * `loadOptions` with its loading and failure states.\n *\n * `active` gates the async side — a closed list asks nothing. Loading is DERIVED\n * (\"the settled answer is for a different query\") rather than flagged on in the\n * effect, so there is no render between a keystroke and the debounce in which an\n * empty list could claim \"No results\" for a question still being asked.\n */\nexport function useOptionSource<V extends string | number>({\n options,\n loadOptions,\n loading,\n filter = true,\n minChars = 0,\n debounceMs = 150,\n query,\n active,\n}: OptionSourceOptions<V> & { query: string; active: boolean }): OptionSource<V> {\n const isAsync = typeof loadOptions === \"function\";\n const tooShort = query.trim().length < minChars;\n const [settled, setSettled] = useState<{\n query: string | null;\n results: ComboOption<V>[];\n failed: boolean;\n }>({ query: null, results: [], failed: false });\n const loadRef = useRef(loadOptions);\n useEffect(() => {\n loadRef.current = loadOptions;\n });\n const reqId = useRef(0);\n\n useEffect(() => {\n // Bumped even when nothing is asked, so a request still in flight from a longer\n // query cannot land after the user has deleted back below `minChars`.\n const id = ++reqId.current;\n if (!active || !isAsync || tooShort) return;\n const t = setTimeout(\n async () => {\n try {\n const r = await loadRef.current!(query);\n if (reqId.current === id) setSettled({ query, results: r, failed: false });\n } catch {\n // The one path the old `try/finally` had no answer for: the list kept the\n // previous query's rows and said nothing (Keksdose proposal §2).\n if (reqId.current === id) setSettled({ query, results: [], failed: true });\n }\n },\n query ? debounceMs : 0,\n );\n return () => clearTimeout(t);\n }, [query, active, isAsync, tooShort, debounceMs]);\n\n // Folded as every kit list folds (DUP-5, refactor audit 2026-10): plain `toLowerCase`\n // here meant \"zurich\" found no Zürich in kastlan's eighteen entity pickers, and the\n // Turkish \"ı\" no \"IRMAK\".\n const locale = useKitLocale();\n const clientResults = useMemo(() => {\n if (isAsync) return [];\n const src = options ?? [];\n const q = foldForSearch(query.trim(), locale);\n if (!filter || !q) return src;\n const hit = (s: string | undefined) => s !== undefined && foldForSearch(s, locale).includes(q);\n return src.filter((o) => hit(o.label) || hit(o.sublabel));\n }, [isAsync, options, query, filter, locale]);\n\n const pending = isAsync && active && !tooShort && settled.query !== query;\n const failed = isAsync && !tooShort && settled.failed;\n return {\n results: tooShort ? [] : isAsync ? (failed ? [] : settled.results) : clientResults,\n busy: Boolean(loading) || pending,\n failed: failed && !pending,\n tooShort,\n };\n}\n\nexport interface ComboboxCoreOptions<V extends string | number> extends OptionSourceOptions<V> {\n /**\n * Back closes the open anchored list, not the page or the dialog behind it — the rule\n * `useDropdown` keeps for its lists (keksdose live #309 rework). Default `false`, as the\n * entity pickers have always been; CurrencySelect, MultiSelect, GroupedPicker and\n * AmountInput's currency chip, which came over from `useDropdown` (DUP-4), pass `true`\n * so they keep it. On a phone the `PickerSheet` registers Back itself.\n */\n backCloses?: boolean;\n}\n\nexport interface ComboboxCore<V extends string | number> {\n triggerRef: RefObject<HTMLButtonElement | null>;\n panelRef: RefObject<HTMLDivElement | null>;\n inputRef: RefObject<HTMLInputElement | null>;\n open: boolean;\n setOpen: Dispatch<SetStateAction<boolean>>;\n query: string;\n setQuery: Dispatch<SetStateAction<string>>;\n active: number;\n setActive: Dispatch<SetStateAction<number>>;\n results: ComboOption<V>[];\n busy: boolean;\n /** See {@link OptionSource}. */\n failed: boolean;\n tooShort: boolean;\n minChars: number;\n rect: AnchorRect | null;\n /** Where the dropdown goes, clamped to the visible viewport (feedback #135). */\n placement: AnchoredPanel;\n /** Put an option in the label cache, so {@link ComboboxCore.resolve} still knows a\n * value the caller just chose after the result list has moved on. */\n rememberOption: (o: ComboOption<V>) => void;\n resolve: (v: V) => ComboOption<V> | null;\n /** Close and hand focus back to the trigger — the keyboard paths only. See\n * {@link useDropdown} for why a pointer dismissal must not do this. */\n closeToTrigger: () => void;\n}\n\n/**\n * Shared plumbing for the entity pickers: open/query/active state, portalled\n * anchoring + outside-click/Escape dismissal, focus-on-open, a debounced\n * race-safe async (or client-side) result list, and a label cache so a selected\n * value still renders its label after the async list has moved on. The single-\n * and multi-value comboboxes render their triggers on top of this and share\n * {@link ComboboxPanel} for the dropdown.\n */\nexport function useComboboxCore<V extends string | number>({\n options,\n minChars = 0,\n backCloses = false,\n ...source\n}: ComboboxCoreOptions<V>): ComboboxCore<V> {\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState(\"\");\n const [active, setActive] = useState(0);\n\n const close = () => setOpen(false);\n // Escape unmounts the panel the user is typing in; without this the browser drops\n // focus on <body>, so the caret disappears and the next Tab restarts at the top of\n // the page. A pointer dismissal deliberately does NOT do this — the press has\n // already decided where focus belongs.\n const closeToTrigger = () => {\n setOpen(false);\n triggerRef.current?.focus();\n };\n // Placement, not just the anchor rect: the panel has to dodge the on-screen\n // keyboard its own search box summons (feedback #135).\n const placement = useAnchoredPanel(triggerRef, open);\n const rect = placement.rect;\n // Outside-click dismissal belongs to the ANCHORED panel, and only to it. On a\n // phone `ComboboxPanel` renders a full-screen `PickerSheet` instead (live #200),\n // portalled to <body> and carrying its own ways out — the close X, Escape, and\n // Back through `useOverlayHistory` — so there is no outside left to press.\n //\n // Leaving the listener on there was not merely redundant, it was the bug:\n // `panelRef` is attached to the desktop panel alone, so with the sheet up every\n // press inside it answered \"outside\". While `useOutsideClick` listened for\n // `mousedown` the rows survived by accident — they commit on `onMouseDown` too,\n // and won the race — but `pointerdown` PRECEDES `mousedown`, so the sheet closed\n // at finger-down and the commit landed on an unmounted tree: a tapped row kept the\n // old value, and tapping the search box or the X was equally fatal. `PickerSheet`\n // stops `mousedown` for exactly this reason, but that guard was written for\n // `useDropdown`'s listener and never covered this hook.\n const isPhone = usePhoneLayout();\n useOutsideClick([triggerRef, panelRef], close, open && !isPhone);\n // A layer on the Escape stack while the anchored panel is open (Wave 2, DUP-1), so a\n // dialog around the picker closes only after it (BUG-1). `ComboboxPanel` takes the key\n // where focus is. On a phone the `PickerSheet` is the layer, as it is the outside.\n useDismissLayer(open && !isPhone, closeToTrigger);\n // See `backCloses`. The same close path a pointer dismissal takes.\n useOverlayHistory(backCloses && open && !isPhone, close);\n\n // Reset the query each time the panel opens, and the highlighted row whenever the\n // visible set changes (a new query, or the panel opening or closing). Adjusted while\n // rendering against the previous values rather than in an effect, so the render that\n // opens the panel already searches for \"\" and highlights the first row.\n const [prevOpen, setPrevOpen] = useState(open);\n const [prevQuery, setPrevQuery] = useState(query);\n if (open !== prevOpen || query !== prevQuery) {\n const opened = open && !prevOpen;\n setPrevOpen(open);\n setPrevQuery(opened ? \"\" : query);\n if (opened) setQuery(\"\");\n setActive(0);\n }\n\n // Focus the search box each time the panel opens.\n useEffect(() => {\n if (!open) return;\n const id = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(id);\n }, [open]);\n\n // Debounced, race-safe async search (only when loadOptions is provided) or the\n // client-side filter — see {@link useOptionSource}.\n const { results, busy, failed, tooShort } = useOptionSource<V>({\n ...source,\n options,\n minChars,\n query,\n active: open,\n });\n\n // Accumulate every option we've seen so a selected value can render its label\n // even after the async list has moved on to other query results.\n const cacheRef = useRef(new Map<V, ComboOption<V>>());\n useEffect(() => {\n for (const o of options ?? []) cacheRef.current.set(o.value, o);\n for (const o of results) cacheRef.current.set(o.value, o);\n }, [options, results]);\n const resolve = (v: V): ComboOption<V> | null =>\n options?.find((o) => o.value === v) ?? cacheRef.current.get(v) ?? null;\n const rememberOption = (o: ComboOption<V>) => {\n cacheRef.current.set(o.value, o);\n };\n\n return {\n triggerRef,\n panelRef,\n inputRef,\n open,\n setOpen,\n query,\n setQuery,\n active,\n setActive,\n results,\n busy,\n failed,\n tooShort,\n minChars,\n rect,\n placement,\n rememberOption,\n resolve,\n closeToTrigger,\n };\n}\n\n// The family's `error` is every field's `useFieldError` (field-parts) since 0.34 — the\n// restatement that stood here ignored a form library's `aria-invalid` (DUP-8).\n\n/** The anchored suggestion list's box and rows — one look for {@link Combobox},\n * {@link InlineEntityCombobox} and {@link Autocomplete}. */\n/**\n * A group's heading in a picker list stays at the top of the list while its rows scroll\n * under it (kk run 79 gap 3): with first-letter groups over two hundred payees, the\n * heading is the one thing that says where in the alphabet the thumb is. Opaque — the\n * list's own `bg-surface` — so the rows pass beneath it rather than through it. Shared\n * by every list that heads groups (the panel and the sheet, `Combobox`, `Autocomplete`,\n * `InlineEntityCombobox`).\n */\nexport const GROUP_HEADING_STICKY = \"sticky top-0 z-10 bg-surface\";\n\nexport const SUGGESTION_LIST_CLASS =\n \"max-h-64 overflow-y-auto rounded-md border border-subtle bg-surface py-1 shadow-lg\";\n\n// One line at Normal; from Large up a long suggestion wraps and its row grows (text size\n// §10.17, round 0.34 T1), like every other option list of the kit.\nexport const suggestionRowClass = (isActive: boolean) =>\n cn(\n \"block w-full truncate-until-large px-3 py-1.5 text-start text-sm text-primary\",\n isActive ? \"bg-active\" : \"hover:bg-hover\",\n );\n\n/**\n * Keep the option the keyboard is on inside the visible part of the list.\n *\n * `aria-activedescendant` moves a highlight WITHOUT moving focus, which is the whole\n * point of it — and the cost is that the browser scrolls nothing on its own. In a\n * panel capped at a few hundred pixels over an account list two hundred long, Down\n * walked the highlight straight out of the box and the list sat still.\n *\n * Optional-called because jsdom does not implement `scrollIntoView`: three consumers\n * run this component in their own suites, and a picker that throws there is a worse\n * trade than a list that does not scroll in a test.\n */\nexport function useActiveOptionScroll(activeId: string | undefined): void {\n useEffect(() => {\n if (!activeId) return;\n document.getElementById(activeId)?.scrollIntoView?.({ block: \"nearest\" });\n }, [activeId]);\n}\n\n/** The anchored panel's least width, in rem: 220 px at Normal (§3.2). */\nconst PANEL_MIN_REM = 13.75;\n\n/** The room the anchored panel keeps from either edge of the glass, in px —\n * `anchoredInline`'s default. */\nconst PANEL_EDGE = 8;\n\n/**\n * How wide the anchored panel is. The phone sheet is the screen's width whatever this\n * says.\n */\nexport interface ComboboxPanelWidth {\n /** The least width, in rem — never under the trigger's own. Default 13.75 (220 px at\n * Normal, §3.2). */\n minRem?: number;\n /**\n * As wide as the rows make it (`max-content`), between the least width and `maxRem`,\n * instead of exactly the least — measured, so the clamp to the glass still knows it.\n * CurrencySelect's list grows to show the full currency names (feedback #308);\n * MultiSelect's rows to show their hints (keksdose #147). A `w-*` class in the panel's\n * `className` does not apply: the panel is portalled to <body>, where `w-full` would be\n * the screen.\n */\n fit?: boolean;\n /** With `fit`, the most it grows to, in rem. Default: the glass. */\n maxRem?: number;\n}\n\nexport interface ComboboxPanelProps<V extends string | number>\n extends ComponentPropsWithoutRef<\"div\"> {\n core: ComboboxCore<V>;\n /** What the trigger's `aria-controls` names. Owned by the component that renders\n * the trigger, not by the core: one id has to reach both, and only one of them\n * can be the origin. */\n listboxId: string;\n /** Default: `combobox.search` from the {@link UiKitProvider}, else English. */\n searchPlaceholder?: string;\n /** Default: `combobox.noResults` from the {@link UiKitProvider}, else English. */\n emptyLabel?: string;\n multi?: boolean;\n isSelected: (v: V) => boolean;\n onChoose: (o: ComboOption<V>) => void;\n showCreate: boolean;\n onCreate: () => void;\n createContent: ReactNode;\n /**\n * The create row is shown but not takeable, and this says why — the lock's reason\n * when the picker's `createCommit` meets a locked {@link WriteLockProvider}. Rendered\n * as the row's second line rather than a tooltip, as {@link ComboOption.disabled}\n * asks of every disabled row: a hover is the one explanation a phone cannot show.\n */\n createDisabledReason?: ReactNode;\n /** What the sheet calls itself on a phone — the field's label. Ignored on\n * desktop, where the panel sits under the field that already says it. */\n sheetTitle?: ReactNode;\n closeLabel?: string;\n /** Default: `combobox.loadError` from the {@link UiKitProvider}, else English. */\n loadErrorLabel?: string;\n /**\n * What a row shows in place of its label and sublabel — for a row that says more than\n * two strings: CurrencySelect's symbol, code and name side by side. The option's\n * `icon`, the multi checkbox and the check mark stay the panel's. Its text is the\n * option's accessible name, so separate the parts with a space.\n */\n renderOption?: (o: ComboOption<V>) => ReactNode;\n /** Controls between the search box and the list, in the anchored panel and the phone\n * sheet alike — MultiSelect's \"Select all\" and \"Clear\". */\n toolbar?: ReactNode;\n /** See {@link ComboboxPanelWidth}. */\n width?: ComboboxPanelWidth;\n /** Which of the trigger's edges the anchored panel hangs from, by reading direction.\n * Default `start`; `end` grows the panel toward the start, so a field with content\n * after it is not pushed past the page (CurrencySelect, feedback #308). */\n align?: \"start\" | \"end\";\n /**\n * Lay the rows out in columns, one block per `group`, with the group's name above it —\n * GroupedPicker's panel (feedback #267/#276): a large grouped set reads as a sheet of\n * short lists side by side rather than one long one. Each block is a `role=\"group\"`\n * named by its heading. The arrow keys walk the rows in reading order, down each\n * column. The phone sheet keeps one column with headings.\n */\n columns?: boolean;\n}\n\n/**\n * The portalled dropdown (search header + result rows + optional create row)\n * shared by the single- and multi-value comboboxes. Start-aligned to the trigger\n * and sized to its width; `multi` swaps the trailing check for a leading\n * checkbox. `onChoose` decides whether to close (single) or stay open (multi).\n *\n * ## The ARIA, which is `CommandPalette`'s\n *\n * This rendered a `role=\"listbox\"` of `role=\"option\"` rows and stopped there, so a\n * reader was handed a text box and silence: the highlight the arrow keys move lived\n * only in a background colour, and nothing tied the box being typed in to the list\n * being filtered. `CommandPalette` has had the whole model since it was written —\n * `aria-controls` from the field to the list, `aria-activedescendant` naming the row\n * the keyboard is on — and it was the only thing in the package that did.\n *\n * Two distinct states, deliberately not conflated:\n * - `aria-selected` is CHOSEN. It is the check mark, and in `multi` the checkbox.\n * - `aria-activedescendant` is where the KEYBOARD is. Announcing that as selected\n * would tell a reader that the row they are merely passing over is the answer.\n *\n * `role=\"option\"` sits on the `<button>`, not on the `<li>` around it, for the same\n * reason it does in `CommandPalette`: an option may not contain a separately\n * focusable control, and the button is the thing a pointer presses. The rows are\n * `tabIndex={-1}` because focus never leaves the search box — that is what\n * `aria-activedescendant` is FOR.\n */\nexport function ComboboxPanel<V extends string | number>({\n core,\n listboxId,\n searchPlaceholder,\n emptyLabel,\n multi,\n isSelected,\n onChoose,\n showCreate,\n onCreate,\n createContent,\n createDisabledReason,\n sheetTitle,\n closeLabel,\n loadErrorLabel,\n renderOption,\n toolbar,\n width,\n align = \"start\",\n columns,\n className,\n style,\n ...rest\n}: ComboboxPanelProps<V>) {\n const createLocked = hasContent(createDisabledReason);\n const {\n rect,\n placement,\n panelRef,\n inputRef,\n query,\n setQuery,\n results,\n busy,\n failed,\n tooShort,\n active,\n setActive,\n closeToTrigger,\n } = core;\n // The phone gets a full-screen sheet instead of an anchored panel (live #200).\n // Same core, same results, same handlers — only the container differs, so the\n // two presentations cannot drift in what they offer.\n const isPhone = usePhoneLayout();\n // Every row the keyboard can land on, the create row included — passed over, like a\n // disabled option, while a write lock holds it.\n const rows: readonly { disabled?: boolean }[] = showCreate\n ? [...results, { disabled: createLocked }]\n : results;\n const rowCount = rows.length;\n const optionId = (index: number) => `${listboxId}-option-${index}`;\n // The core opens on row 0 and knows nothing of `disabled`; the highlight is settled\n // HERE, derived, so it can never rest on a row that cannot be taken — whatever the\n // async list turned out to hold.\n const current = settleEnabled(rows, active);\n const activeId = current >= 0 ? optionId(current) : undefined;\n useActiveOptionScroll(activeId);\n // The consumers resolve their own props against the provider already; this is\n // for the loading row, which no consumer names, and for a caller that renders the\n // panel directly and leaves the two optional strings out.\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS);\n // Portalled to <body>, the panel leaves the subtree its `dir` came from — so the\n // direction is read off the trigger and put back on the panel below.\n const dir = useAnchorDir(core.triggerRef, core.open);\n const remPx = useRemPx();\n // A `fit` panel's measured width — what it takes to keep it on the glass (see\n // `ComboboxPanelWidth.fit`). Observed rather than read once: the rows change under the\n // search, and a filtered list of short names is a narrower panel. `null` where nothing\n // is laid out (jsdom), and the least width is used.\n const fit = width?.fit === true && !isPhone;\n const [fitWidth, setFitWidth] = useState<number | null>(null);\n const placed = core.open && rect !== null;\n useLayoutEffect(() => {\n const el = panelRef.current;\n if (!fit || !placed || !el || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(() => {\n const measured = el.getBoundingClientRect().width;\n setFitWidth(measured > 0 ? measured : null);\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, [fit, placed, panelRef]);\n\n // The WAI-ARIA APG's listbox keyboard, in full: Up/Down step, Home/End jump, Enter\n // commits, Tab leaves, Escape closes. On the panel's search box — in the anchored\n // panel and, through `onSearchKeyDown`, in the phone sheet's header (BUG-5).\n const onKeyDown = (e: ReactKeyboardEvent) => {\n // Escape goes to the top of the kit's Escape stack — this list, which opened over\n // any dialog it sits in — and stops HERE (round 0.34 BUG-1, Wave 2 DUP-1). The\n // panel's events travel up the React tree through that dialog, portal or not, and\n // one press used to close the dialog and throw the form away, list still open.\n if (takeEscape(e)) return;\n // The Enter that confirms an IME composition is the IME's (BUG-9).\n if (isImeEnter(e)) return;\n // Disabled rows are passed over (`stepEnabled`), and each step starts from the\n // SETTLED highlight, not the raw index, so the first Down from a disabled row 0\n // goes to the row after the one already shown as highlighted.\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActive(stepEnabled(rows, current, 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActive(current < 0 ? -1 : stepEnabled(rows, current, -1));\n } else if (e.key === \"Home\") {\n e.preventDefault();\n setActive(stepEnabled(rows, -1, 1));\n } else if (e.key === \"End\") {\n e.preventDefault();\n setActive(stepEnabled(rows, rowCount, -1));\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n if (current < 0) return;\n if (current < results.length) onChoose(results[current]);\n else if (showCreate && !createLocked) onCreate();\n } else if (e.key === \"Tab\" && !isPhone) {\n // The panel is PORTALLED to <body>, so the browser's own Tab would move from\n // here to whatever follows the portal — i.e. off the end of the document. The\n // trade is one extra Tab (trigger, then onward) against never stranding focus\n // at the bottom of the page. The phone sheet is a dialog, and its trap keeps Tab.\n e.preventDefault();\n closeToTrigger();\n }\n };\n\n // What the list holds, said in ONE place that is both on screen and a polite\n // live region. Focus stays in the search box, so the list changing under it was\n // silent — a reader typed and heard nothing back, and a failed lookup was the same\n // silence as a slow one. Outside the listbox, which may own only options.\n //\n // Three different empties, and only one of them is \"nothing matched\": a lookup\n // that failed must not claim there is nothing to find, and a query under\n // `minChars` was never asked. With rows showing, the count is for the reader only.\n const message: ReactNode =\n busy && results.length === 0 ? (\n // The ellipsis is the picture; the words are for a reader, who otherwise met\n // an empty-looking list with a lone \"…\" in it — or, in most readers, nothing\n // at all, since punctuation alone is skipped.\n <>\n <span aria-hidden>…</span>\n <span className=\"sr-only\">{labels.loading}</span>\n </>\n ) : busy ? (\n // Loading with the LAST query's rows still up. This was `null`, so a refetch —\n // a new query, or a caller's `loading` while it reloads — looked exactly like a\n // finished list: rows that were about to be replaced, with nothing saying so.\n // A line of its own under the rows, in words, so it reads without the spinner.\n <span className=\"flex items-center gap-2\">\n <Spinner label={null} className=\"size-3.5 border\" />\n {labels.loading}\n </span>\n ) : results.length === 0 && !showCreate ? (\n failed ? (\n (loadErrorLabel ?? labels.loadError)\n ) : tooShort ? (\n labels.minChars(core.minChars)\n ) : (\n (emptyLabel ?? labels.noResults)\n )\n ) : null;\n // `relative` so the sr-only text has a local containing block (see\n // sr-only-containment.test).\n const announcement = (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className={cn(\n \"relative\",\n message !== null && cn(\"py-2 text-sm\", isPhone ? \"px-4\" : \"px-3\"),\n failed ? \"text-danger\" : \"text-muted\",\n )}\n >\n {message ??\n (results.length > 0 && (\n <span className=\"sr-only\">{labels.resultCount(results.length)}</span>\n ))}\n </div>\n );\n\n if (!core.open || typeof document === \"undefined\") return null;\n\n // One option row — the same in both containers and in both layouts.\n const optionRow = (o: ComboOption<V>, i: number) => {\n const selected = isSelected(o.value);\n return (\n <li role=\"presentation\">\n <button\n type=\"button\"\n id={optionId(i)}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={o.disabled || undefined}\n tabIndex={-1}\n onMouseDown={(e) => {\n e.preventDefault();\n if (!o.disabled) onChoose(o);\n }}\n onMouseEnter={() => {\n if (!o.disabled) setActive(i);\n }}\n className={cn(\n isPhone\n ? SHEET_ROW_CLASS\n : columns\n ? // A cell of a column (GroupedPicker): tighter, so four columns fit.\n \"flex w-full items-center gap-1.5 rounded px-1.5 py-0.5 text-start text-sm\"\n : \"flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm\",\n // The row the arrows are on shows it on a phone too: the sheet takes\n // the keyboard (BUG-5), and a tablet or a desktop at Large has one.\n o.disabled\n ? DISABLED_ROW_CLASS\n : i === current\n ? \"bg-active\"\n : !isPhone && \"hover:bg-hover\",\n // After SHEET_ROW_CLASS, so its hover is the one cancelled.\n o.disabled && isPhone && DISABLED_ROW_CLASS,\n )}\n >\n {multi && (\n <span\n // The checkbox is a PICTURE of `aria-selected` above, so a reader\n // that met both would be told twice.\n aria-hidden\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded border\",\n selected\n ? \"border-[var(--bg-inverse)] bg-inverse text-inverse\"\n : \"border-strong bg-surface\",\n )}\n >\n {selected && <Check className=\"size-3\" />}\n </span>\n )}\n {o.icon && <span className=\"shrink-0\">{o.icon}</span>}\n {renderOption ? (\n <span className=\"flex min-w-0 flex-1 items-center gap-2\">{renderOption(o)}</span>\n ) : (\n /* Label and sublabel wrap from Large up (text size §10.17, round 0.34 T1). */\n <span className=\"min-w-0 flex-1\">\n <span className={cn(\"block truncate-until-large text-primary\", columns && selected && \"font-medium\")}>\n {o.label}\n </span>\n {o.sublabel && (\n <span className=\"block truncate-until-large text-xs text-placeholder\">{o.sublabel}</span>\n )}\n </span>\n )}\n {!multi && selected && <Check className=\"size-4 shrink-0 text-brand\" />}\n </button>\n </li>\n );\n };\n\n const createRow = showCreate && (\n <li role=\"presentation\">\n <button\n type=\"button\"\n id={optionId(results.length)}\n role=\"option\"\n // Never chosen — it is an action, and it disappears the moment it has\n // been taken. Whether the keyboard is ON it is `aria-activedescendant`'s\n // job to say.\n aria-selected={false}\n aria-disabled={createLocked || undefined}\n tabIndex={-1}\n onMouseDown={(e) => {\n e.preventDefault();\n if (!createLocked) onCreate();\n }}\n onMouseEnter={() => {\n if (!createLocked) setActive(results.length);\n }}\n className={cn(\n isPhone\n ? SHEET_ROW_CLASS\n : \"flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm\",\n \"text-secondary\",\n createLocked\n ? DISABLED_ROW_CLASS\n : current === results.length\n ? \"bg-active\"\n : !isPhone && \"hover:bg-hover\",\n // After SHEET_ROW_CLASS, so its hover is the one cancelled.\n createLocked && isPhone && DISABLED_ROW_CLASS,\n )}\n >\n <Plus className=\"size-4 shrink-0\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate-until-large\">{createContent}</span>\n {createLocked && (\n <span className=\"block truncate-until-large text-xs text-placeholder\">\n {createDisabledReason}\n </span>\n )}\n </span>\n </button>\n </li>\n );\n\n // In columns, a block per run of one group; `results` keeps its source order, so a\n // run is the rows up to the next change of group.\n const blocks: { group: string; rows: { o: ComboOption<V>; i: number }[] }[] = [];\n if (columns && !isPhone) {\n results.forEach((o, i) => {\n const group = o.group ?? \"\";\n const last = blocks[blocks.length - 1];\n if (last && last.group === group) last.rows.push({ o, i });\n else blocks.push({ group, rows: [{ o, i }] });\n });\n }\n\n const list = (\n <ul\n id={listboxId}\n role=\"listbox\"\n aria-multiselectable={multi}\n // The rows are provisional while a lookup is in flight — whether or not the\n // previous query's are still showing.\n aria-busy={busy || undefined}\n // It scrolls, and says so where jsdom can see it (see `CLIPS_ATTRIBUTE`): a\n // Tooltip in a row then portals out in a test exactly as it does in the\n // browser, instead of joining the option's accessible name (keksdose E8).\n {...{ [CLIPS_ATTRIBUTE]: \"\" }}\n className={cn(\n \"min-h-0 flex-1 overflow-y-auto\",\n columns && !isPhone ? \"columns-2 gap-4 p-3 md:columns-3 xl:columns-4\" : \"py-1\",\n isPhone && \"flex-none\",\n )}\n >\n {columns && !isPhone\n ? blocks.map((block) => (\n // A column block: its heading is a picture of the group's name, which the\n // `role=\"group\"` carries for a reader — the listbox may own options and\n // groups, and a heading of loose text in it is neither.\n <li key={`${block.group}|${block.rows[0].i}`} role=\"presentation\" className=\"mb-3 break-inside-avoid\">\n {block.group && (\n <div aria-hidden className=\"mb-1 text-xs font-semibold uppercase tracking-wide text-muted\">\n {block.group}\n </div>\n )}\n <ul role=\"group\" aria-label={block.group || undefined} className=\"space-y-0.5\">\n {block.rows.map(({ o, i }) => (\n <Fragment key={`${o.group ?? \"\"}|${String(o.value)}`}>{optionRow(o, i)}</Fragment>\n ))}\n </ul>\n </li>\n ))\n : results.map((o, i) => {\n // One heading per group rather than a grey suffix on every row (#136), and\n // the thing the native <select>'s <optgroup> used to give the account\n // picker for free (live #200). `results` keeps its source order, so a\n // boundary is simply \"different from the row above\".\n const startsGroup = o.group != null && o.group !== results[i - 1]?.group;\n return (\n // Keyed by group AND value: an option may deliberately appear twice —\n // Keksdose repeats recently-used categories in a \"Recent\" group at the\n // top (live #203) — and a bare value key would collide.\n <Fragment key={`${o.group ?? \"\"}|${String(o.value)}`}>\n {startsGroup && (\n <li\n role=\"presentation\"\n className={cn(\n GROUP_HEADING_STICKY,\n \"font-semibold uppercase tracking-wide text-muted\",\n isPhone ? \"px-4 pb-1 pt-3 text-xs\" : \"px-3 pb-0.5 pt-2 text-caption first:pt-1\",\n )}\n >\n {o.group}\n </li>\n )}\n {optionRow(o, i)}\n </Fragment>\n );\n })}\n {createRow}\n </ul>\n );\n\n // The search box is NAMED, not only prompted: a placeholder is gone the moment a\n // character is typed, and jsdom's readers and some real ones never took it for a name\n // (BUG-12: GroupedPicker's filter had \"no name beyond its placeholder\").\n const searchText = searchPlaceholder ?? labels.search;\n\n if (isPhone) {\n return (\n <PickerSheet\n // First, so the sheet's own props below win: `rest` is typed as div\n // attributes, and the DOM's `title` is a tooltip string where the sheet's is\n // its heading — one name, two meanings, and the sheet's is the one the caller\n // asked for.\n {...rest}\n className={className}\n style={style}\n open\n onClose={() => core.setOpen(false)}\n title={sheetTitle}\n query={query}\n onQueryChange={setQuery}\n searchPlaceholder={searchText}\n searchLabel={searchText}\n inputRef={inputRef}\n closeLabel={closeLabel}\n // The sheet's search box is in its HEADER, outside the list: the keys go to it\n // there, and it names the list and the active row (BUG-5). A div around the list\n // used to catch them, and never did — focus is in the box, not in the list.\n onSearchKeyDown={onKeyDown}\n listboxId={listboxId}\n activeId={activeId}\n // A multi list stays open as rows are ticked, so the sheet needs a way out\n // that is not the X in its corner: the kit's sticky \"Done\" (keksdose #412).\n // A single pick closes the sheet itself.\n done={multi}\n >\n {toolbar}\n <div className=\"relative\">\n {list}\n {announcement}\n </div>\n </PickerSheet>\n );\n }\n\n if (!rect) return null;\n // The panel hangs from the trigger's START edge (or, `align=\"end\"`, its end): its left\n // in a left-to-right form, its right in a right-to-left one, at least 13.75rem wide\n // (220 px at Normal, in rem so its text keeps its room at Large, §3.2; `width.minRem`)\n // and never wider than the glass — and clamped to the glass, which in a left-to-right\n // form it never was (Wave 2, DUP-7). It is placed by the edge it hangs from, so a `fit`\n // panel grows away from the trigger's edge before its width is measured; a box hung by\n // its `right` is measured from inside any scrollbar, as the glass's width is.\n const glass = viewportSize().width - 2 * PANEL_EDGE;\n const least = Math.min(Math.max(rect.width, (width?.minRem ?? PANEL_MIN_REM) * remPx), glass);\n const most = Math.max(least, Math.min(width?.maxRem !== undefined ? width.maxRem * remPx : glass, glass));\n const panelWidth = fit ? Math.min(Math.max(fitWidth ?? least, least), most) : least;\n const at = anchoredInline(rect, panelWidth, { dir, align, edge: PANEL_EDGE });\n const inline = (dir === \"rtl\") === (align === \"start\") ? { right: at.right } : { left: at.left };\n\n return createPortal(\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused\n itself: it catches the listbox keys bubbling from the search <input> inside it,\n which holds focus while the panel is open. */\n <div\n // Spread FIRST: `onKeyDown` below is the listbox keyboard (Up/Down/Home/End/\n // Enter/Tab) and the placement is measured rather than chosen, so neither is a\n // caller's to replace by accident — while a `data-*` anchor or an\n // `aria-describedby` has nothing to collide with.\n {...rest}\n ref={panelRef}\n // A kit layer, for the tour's layer order (0.50, docs/tours-harmonization.md §11.6).\n data-kit-layer=\"\"\n dir={dir}\n onKeyDown={onKeyDown}\n // A press in a panel opened from a row is inside this list for the core's outside\n // press, though portalled elsewhere (dev#623).\n onPointerDownCapture={(e) => {\n rest.onPointerDownCapture?.(e);\n pressInside(panelRef)?.(e);\n }}\n // `placement` keeps the panel inside the region actually on screen: on a phone\n // the search box below pulls up the keyboard, and a panel pinned under a\n // low trigger would otherwise sit entirely behind it (feedback #135). Flipped\n // above, it hangs from its bottom edge, so a list shorter than its cap still meets\n // the trigger (keksdose K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: placement.above ? undefined : placement.top,\n bottom: placement.above ? placement.bottom : undefined,\n ...inline,\n // A `fit` panel takes its width from its rows between the two bounds; any other\n // is exactly the least width.\n ...(fit ? { width: \"max-content\", minWidth: least, maxWidth: most } : { width: panelWidth }),\n maxHeight: placement.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col rounded-md border border-subtle bg-surface shadow-lg\",\n className,\n )}\n >\n <DropdownSearchHeader\n query={query}\n onQueryChange={setQuery}\n inputRef={inputRef}\n placeholder={searchText}\n aria-label={searchText}\n // Focus is in this box while the list is up, so this is what has to name the\n // list and the row the arrows are on.\n listboxId={listboxId}\n activeId={activeId}\n />\n {toolbar}\n {/* One list, two containers: the desktop panel and the phone sheet render\n the same rows through the same handlers (live #200). */}\n {list}\n {announcement}\n </div>,\n document.body,\n );\n}\n"],"mappings":";AA6KI,SAukBE,UAvkBF,KAukBE,YAvkBF;AA7KJ,SAAS,YAAAA,WAAU,WAAW,iBAAiB,SAAS,QAAQ,gBAAgB;AAChF,SAAS,oBAAoB;AAS7B,SAAS,OAAO,YAAY;AAC5B,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,aAAa,uBAAuB;AAC7C,SAAS,gBAAgB,gBAAgB;AACzC,SAAS,6BAA6B;AACtC,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,kBAAkB,oBAAwC;AACnF,SAAS,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;AAAA,cACf;AAAA,cACA,aAAa;AAAA,cACb,cAAY;AAAA,cAGZ;AAAA,cACA;AAAA;AAAA,UACF;AAAA,UACC;AAAA,UAGA;AAAA,UACA;AAAA;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":["Fragment"]}
@@ -34,6 +34,7 @@ function SuggestionList({
34
34
  "div",
35
35
  {
36
36
  ref: panelRef,
37
+ "data-kit-layer": "",
37
38
  className: "fixed z-50",
38
39
  dir,
39
40
  style: { ...above ? { bottom } : { top }, left: rect.left, width: rect.width },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/combobox-suggestions.tsx"],"sourcesContent":["// What the two TYPED comboboxes share — Combobox (free text) and InlineEntityCombobox\n// (an option id): the portalled suggestion list, the focus-open guard against a mouse's\n// back button, and the write lock's Enter. Moved out of combobox.tsx with the split of\n// InlineEntityCombobox into its own module (MOD-9, refactor audit 2026-10), so neither\n// imports the other. Internal: no name here is part of the package.\nimport { useRef } from \"react\";\nimport type { ReactNode, RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\nimport { SUGGESTION_LIST_CLASS, suggestionRowClass } from \"./combobox-core\";\n\n// One look for both combobox flavors — the suggestion list and its rows\n// must stay pixel-identical between the free-text and the id-keyed variant (and\n// `Autocomplete`, which shares them from the core).\nconst LIST_CLASS = SUGGESTION_LIST_CLASS;\n\n/**\n * \"This focus came from a mouse button that is not the left one\" — for the two\n * fields (Combobox, InlineEntityCombobox), which open their list ON FOCUS.\n *\n * Keksdose live #309 rework: *\"When clicking the mouse back button now while hovering\n * one of the selects it opens the select as long as I am holding the button down and\n * closes select after releasing.\"* A mouse's BACK button focuses whatever it is\n * pressed over, exactly as the left one does — the browser only reserves the\n * NAVIGATION for itself — so a field that opens on focus opened a list for a gesture\n * that means \"go back\", and the release then navigated out from under it. Measured on\n * his own budget: `mousePressed button=back` over the transfer form's account field\n * left `aria-expanded=true`, and the release took the whole add card with it.\n *\n * The press is recorded and read by the focus that the SAME press causes: focus is\n * mousedown's default action, dispatched inside the same task, so the flag is always\n * read before the `setTimeout` below can drop it. And it is always dropped — a press\n * that focuses nothing (the pointer was over a disabled field, the button was\n * released elsewhere) must not leave a latch that swallows the next Tab.\n *\n * Only the OPEN is suppressed, never the navigation: Back still goes back, which is\n * the whole of what the button was pressed for.\n */\nexport function usePrimaryPressOnly() {\n const auxPress = useRef(false);\n return {\n onMouseDown: (e: { button: number }) => {\n if (e.button === 0) return;\n auxPress.current = true;\n setTimeout(() => {\n auxPress.current = false;\n }, 0);\n },\n /** True while handling the focus a non-primary press just caused. */\n fromAuxButton: () => auxPress.current,\n };\n}\n\n/**\n * The desktop suggestion list, PORTALLED and anchored to the field.\n *\n * It used to be an `absolute` `<ul>` inside the field's own wrapper, and that is\n * Keksdose live #295: *\"Category select inside the list is not readable. Some sort\n * of z indexes issue?\"*. It was not z-index — a stacking context can be out-ranked,\n * but `overflow` cannot be argued with. The receipt's line table sits in a card\n * carrying `overflow-clip`, so a list opened from the last visible row was cut off\n * at the card's edge: measured at 256px tall with 150px of it painted.\n *\n * Every other panel in this package already learned this — `DropdownPanel`'s\n * `anchorRef` form, the calculator popover, the tooltip — so this reuses the same\n * hook rather than inventing a second placement. What that buys beyond the clip:\n * the list flips above the field when there is no room below, and it caps its own\n * height against the VISIBLE viewport, which on a phone means the on-screen\n * keyboard (see {@link useAnchoredPanel}).\n *\n * `panelRef` is not optional plumbing. Portalled, the list is no longer a\n * descendant of the wrapper, so {@link useDropdown}'s outside-click test answers\n * \"outside\" for a click on the list itself — the first option a user picked would\n * close the dropdown having picked nothing.\n */\nexport function SuggestionList({\n id,\n anchorRef,\n panelRef,\n children,\n}: {\n /** What the field's `aria-controls` names. */\n id: string;\n anchorRef: RefObject<HTMLElement | null>;\n panelRef: RefObject<HTMLDivElement | null>;\n children: ReactNode;\n}) {\n const { rect, top, bottom, maxHeight, above } = useAnchoredPanel(anchorRef, true, { preferredHeight: 256 });\n const dir = useAnchorDir(anchorRef, true);\n if (!rect) return null;\n return createPortal(\n <div\n ref={panelRef}\n // z-50, not the old z-30: the list is a child of <body> now, so it is\n // competing with the app's own overlays rather than with its own siblings.\n className=\"fixed z-50\"\n // Portalled out of the form's `dir`; the field's is put back. The list is\n // exactly the field's width, so `left` places it in either direction.\n dir={dir}\n // Flipped above, the list hangs from its bottom edge: it filters as the user\n // types, and a short one placed by `top` floated above the field (keksdose K1).\n style={{ ...(above ? { bottom } : { top }), left: rect.left, width: rect.width }}\n >\n <ul id={id} role=\"listbox\" data-clips=\"\" className={LIST_CLASS} style={{ maxHeight }}>\n {children}\n </ul>\n </div>,\n document.body,\n );\n}\n\nexport const rowClass = suggestionRowClass;\n\n/**\n * The write lock on the two TYPED fields — {@link Button}'s `disabledReason`\n * path, for an input (keksdose G2).\n *\n * `readOnly` rather than `disabled`, as everywhere the kit locks a field: still focusable,\n * so the reason in the Tooltip reaches a keyboard; refusing keys, so nothing typed can\n * become a value; and FIELD_BASE paints a `[readonly]` field in the settled grey a\n * disabled one wears. No list opens, by focus, click, chevron or arrow — and Enter is\n * swallowed, so a locked field does not submit the form around it either (Select's\n * lock, `LOCKED_SELECT_KEYS`). Every other key is left alone: the arrows and Home/End\n * still move the caret through a long value someone is trying to read.\n */\nexport function lockedKeyDown(e: { key: string; preventDefault: () => void }) {\n if (e.key === \"Enter\") e.preventDefault();\n}\n"],"mappings":";AAwGM;AAnGN,SAAS,cAAc;AAEvB,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB,0BAA0B;AAK1D,MAAM,aAAa;AAwBZ,SAAS,sBAAsB;AACpC,QAAM,WAAW,OAAO,KAAK;AAC7B,SAAO;AAAA,IACL,aAAa,CAAC,MAA0B;AACtC,UAAI,EAAE,WAAW,EAAG;AACpB,eAAS,UAAU;AACnB,iBAAW,MAAM;AACf,iBAAS,UAAU;AAAA,MACrB,GAAG,CAAC;AAAA,IACN;AAAA;AAAA,IAEA,eAAe,MAAM,SAAS;AAAA,EAChC;AACF;AAwBO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AACD,QAAM,EAAE,MAAM,KAAK,QAAQ,WAAW,MAAM,IAAI,iBAAiB,WAAW,MAAM,EAAE,iBAAiB,IAAI,CAAC;AAC1G,QAAM,MAAM,aAAa,WAAW,IAAI;AACxC,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO;AAAA,IACL;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QAGL,WAAU;AAAA,QAGV;AAAA,QAGA,OAAO,EAAE,GAAI,QAAQ,EAAE,OAAO,IAAI,EAAE,IAAI,GAAI,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM;AAAA,QAE/E,8BAAC,QAAG,IAAQ,MAAK,WAAU,cAAW,IAAG,WAAW,YAAY,OAAO,EAAE,UAAU,GAChF,UACH;AAAA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAEO,MAAM,WAAW;AAcjB,SAAS,cAAc,GAAgD;AAC5E,MAAI,EAAE,QAAQ,QAAS,GAAE,eAAe;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../src/components/combobox-suggestions.tsx"],"sourcesContent":["// What the two TYPED comboboxes share — Combobox (free text) and InlineEntityCombobox\n// (an option id): the portalled suggestion list, the focus-open guard against a mouse's\n// back button, and the write lock's Enter. Moved out of combobox.tsx with the split of\n// InlineEntityCombobox into its own module (MOD-9, refactor audit 2026-10), so neither\n// imports the other. Internal: no name here is part of the package.\nimport { useRef } from \"react\";\nimport type { ReactNode, RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\nimport { SUGGESTION_LIST_CLASS, suggestionRowClass } from \"./combobox-core\";\n\n// One look for both combobox flavors — the suggestion list and its rows\n// must stay pixel-identical between the free-text and the id-keyed variant (and\n// `Autocomplete`, which shares them from the core).\nconst LIST_CLASS = SUGGESTION_LIST_CLASS;\n\n/**\n * \"This focus came from a mouse button that is not the left one\" — for the two\n * fields (Combobox, InlineEntityCombobox), which open their list ON FOCUS.\n *\n * Keksdose live #309 rework: *\"When clicking the mouse back button now while hovering\n * one of the selects it opens the select as long as I am holding the button down and\n * closes select after releasing.\"* A mouse's BACK button focuses whatever it is\n * pressed over, exactly as the left one does — the browser only reserves the\n * NAVIGATION for itself — so a field that opens on focus opened a list for a gesture\n * that means \"go back\", and the release then navigated out from under it. Measured on\n * his own budget: `mousePressed button=back` over the transfer form's account field\n * left `aria-expanded=true`, and the release took the whole add card with it.\n *\n * The press is recorded and read by the focus that the SAME press causes: focus is\n * mousedown's default action, dispatched inside the same task, so the flag is always\n * read before the `setTimeout` below can drop it. And it is always dropped — a press\n * that focuses nothing (the pointer was over a disabled field, the button was\n * released elsewhere) must not leave a latch that swallows the next Tab.\n *\n * Only the OPEN is suppressed, never the navigation: Back still goes back, which is\n * the whole of what the button was pressed for.\n */\nexport function usePrimaryPressOnly() {\n const auxPress = useRef(false);\n return {\n onMouseDown: (e: { button: number }) => {\n if (e.button === 0) return;\n auxPress.current = true;\n setTimeout(() => {\n auxPress.current = false;\n }, 0);\n },\n /** True while handling the focus a non-primary press just caused. */\n fromAuxButton: () => auxPress.current,\n };\n}\n\n/**\n * The desktop suggestion list, PORTALLED and anchored to the field.\n *\n * It used to be an `absolute` `<ul>` inside the field's own wrapper, and that is\n * Keksdose live #295: *\"Category select inside the list is not readable. Some sort\n * of z indexes issue?\"*. It was not z-index — a stacking context can be out-ranked,\n * but `overflow` cannot be argued with. The receipt's line table sits in a card\n * carrying `overflow-clip`, so a list opened from the last visible row was cut off\n * at the card's edge: measured at 256px tall with 150px of it painted.\n *\n * Every other panel in this package already learned this — `DropdownPanel`'s\n * `anchorRef` form, the calculator popover, the tooltip — so this reuses the same\n * hook rather than inventing a second placement. What that buys beyond the clip:\n * the list flips above the field when there is no room below, and it caps its own\n * height against the VISIBLE viewport, which on a phone means the on-screen\n * keyboard (see {@link useAnchoredPanel}).\n *\n * `panelRef` is not optional plumbing. Portalled, the list is no longer a\n * descendant of the wrapper, so {@link useDropdown}'s outside-click test answers\n * \"outside\" for a click on the list itself — the first option a user picked would\n * close the dropdown having picked nothing.\n */\nexport function SuggestionList({\n id,\n anchorRef,\n panelRef,\n children,\n}: {\n /** What the field's `aria-controls` names. */\n id: string;\n anchorRef: RefObject<HTMLElement | null>;\n panelRef: RefObject<HTMLDivElement | null>;\n children: ReactNode;\n}) {\n const { rect, top, bottom, maxHeight, above } = useAnchoredPanel(anchorRef, true, { preferredHeight: 256 });\n const dir = useAnchorDir(anchorRef, true);\n if (!rect) return null;\n return createPortal(\n <div\n ref={panelRef}\n // A kit layer, for the tour's layer order (0.50, docs/tours-harmonization.md §11.6).\n data-kit-layer=\"\"\n // z-50, not the old z-30: the list is a child of <body> now, so it is\n // competing with the app's own overlays rather than with its own siblings.\n className=\"fixed z-50\"\n // Portalled out of the form's `dir`; the field's is put back. The list is\n // exactly the field's width, so `left` places it in either direction.\n dir={dir}\n // Flipped above, the list hangs from its bottom edge: it filters as the user\n // types, and a short one placed by `top` floated above the field (keksdose K1).\n style={{ ...(above ? { bottom } : { top }), left: rect.left, width: rect.width }}\n >\n <ul id={id} role=\"listbox\" data-clips=\"\" className={LIST_CLASS} style={{ maxHeight }}>\n {children}\n </ul>\n </div>,\n document.body,\n );\n}\n\nexport const rowClass = suggestionRowClass;\n\n/**\n * The write lock on the two TYPED fields — {@link Button}'s `disabledReason`\n * path, for an input (keksdose G2).\n *\n * `readOnly` rather than `disabled`, as everywhere the kit locks a field: still focusable,\n * so the reason in the Tooltip reaches a keyboard; refusing keys, so nothing typed can\n * become a value; and FIELD_BASE paints a `[readonly]` field in the settled grey a\n * disabled one wears. No list opens, by focus, click, chevron or arrow — and Enter is\n * swallowed, so a locked field does not submit the form around it either (Select's\n * lock, `LOCKED_SELECT_KEYS`). Every other key is left alone: the arrows and Home/End\n * still move the caret through a long value someone is trying to read.\n */\nexport function lockedKeyDown(e: { key: string; preventDefault: () => void }) {\n if (e.key === \"Enter\") e.preventDefault();\n}\n"],"mappings":";AA0GM;AArGN,SAAS,cAAc;AAEvB,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB,0BAA0B;AAK1D,MAAM,aAAa;AAwBZ,SAAS,sBAAsB;AACpC,QAAM,WAAW,OAAO,KAAK;AAC7B,SAAO;AAAA,IACL,aAAa,CAAC,MAA0B;AACtC,UAAI,EAAE,WAAW,EAAG;AACpB,eAAS,UAAU;AACnB,iBAAW,MAAM;AACf,iBAAS,UAAU;AAAA,MACrB,GAAG,CAAC;AAAA,IACN;AAAA;AAAA,IAEA,eAAe,MAAM,SAAS;AAAA,EAChC;AACF;AAwBO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AACD,QAAM,EAAE,MAAM,KAAK,QAAQ,WAAW,MAAM,IAAI,iBAAiB,WAAW,MAAM,EAAE,iBAAiB,IAAI,CAAC;AAC1G,QAAM,MAAM,aAAa,WAAW,IAAI;AACxC,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO;AAAA,IACL;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QAEL,kBAAe;AAAA,QAGf,WAAU;AAAA,QAGV;AAAA,QAGA,OAAO,EAAE,GAAI,QAAQ,EAAE,OAAO,IAAI,EAAE,IAAI,GAAI,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM;AAAA,QAE/E,8BAAC,QAAG,IAAQ,MAAK,WAAU,cAAW,IAAG,WAAW,YAAY,OAAO,EAAE,UAAU,GAChF,UACH;AAAA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAEO,MAAM,WAAW;AAcjB,SAAS,cAAc,GAAgD;AAC5E,MAAI,EAAE,QAAQ,QAAS,GAAE,eAAe;AAC1C;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import type { ComponentPropsWithoutRef, ReactNode, Ref } from "react";
2
- import { type FieldHelpProps } from "./field-parts.js";
2
+ import { type DisabledReasonDisplay, type FieldHelpProps } from "./field-parts.js";
3
+ import type { CommitScope } from "./write-lock.js";
3
4
  import { CURRENCIES, CurrencyFlag, currencyName, getCurrency, type CurrencyFlagProps, type CurrencyOption } from "./currency-option-list.js";
4
5
  export { CURRENCIES, CurrencyFlag, currencyName, getCurrency };
5
6
  export type { CurrencyFlagProps, CurrencyOption };
@@ -66,9 +67,34 @@ export interface CurrencySelectProps extends Omit<ComponentPropsWithoutRef<"div"
66
67
  * filter that only matches the hidden English name is worse than no filter.
67
68
  */
68
69
  currencyNames?: Record<string, string>;
70
+ /** As {@link Select}'s: no focus, no list, the settled look, no chevron. */
71
+ disabled?: boolean;
72
+ /**
73
+ * Why the currency cannot be changed — {@link Select}'s `disabledReason` (keksdose,
74
+ * 2026-10-23: a budget's currency for a guest or a viewer, and while offline, which
75
+ * keksdose drew as a one-option `Select` to keep the reason and lost the flag). The
76
+ * trigger stays focusable and `aria-disabled` (never the `disabled` attribute), keeps
77
+ * its flag and code, opens nothing, and `onChange` is never called; the reason is a
78
+ * line under the field at Large and on a touch screen, else in the kit
79
+ * {@link Tooltip} (`disabledReasonDisplay`), and on the trigger's `aria-describedby`
80
+ * (after a caption, before an error). It wears the settled look of a disabled field
81
+ * and drops its chevron, as a locked Select does. It wins over `disabled`.
82
+ */
83
+ disabledReason?: ReactNode;
84
+ /** Where the reason shows — {@link Select}'s `disabledReasonDisplay`: a line under the
85
+ * field at Large and on a touch screen by default, the tooltip otherwise. */
86
+ disabledReasonDisplay?: DisabledReasonDisplay;
87
+ /**
88
+ * This picker COMMITS — choosing saves. Under a locked {@link WriteLockProvider} it is
89
+ * locked the `disabledReason` way with the lock's reason (which wins over its own).
90
+ * No provider, or an unlocked one: no effect. {@link Select}'s `commit`. A currency
91
+ * field inside a form with its own Save stays editable under the lock — leave this off
92
+ * there, and put `commit` on the Save.
93
+ */
94
+ commit?: CommitScope;
69
95
  /** The TRIGGER — the focusable `<button>` — as a React 19 ref prop, as on
70
96
  * {@link MultiSelect} and {@link CountrySelect}: react-hook-form's focus-on-error
71
97
  * calls `focus()` on it (0.34, API-3, refactor audit 2026-10). Not the wrapper. */
72
98
  ref?: Ref<HTMLButtonElement>;
73
99
  }
74
- export declare function CurrencySelect({ value, onChange, placeholder, className, label, options, invalid, error, hint, help, labels, currencyNames, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ref, ...rest }: CurrencySelectProps): import("react").JSX.Element;
100
+ export declare function CurrencySelect({ value, onChange, placeholder, className, label, options, invalid, error, hint, help, labels, currencyNames, disabled, disabledReason, disabledReasonDisplay, commit, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ref, ...rest }: CurrencySelectProps): import("react").JSX.Element;
@@ -3,7 +3,13 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useCallback, useId } from "react";
4
4
  import { FieldChevron, FIELD_TRIGGER, FIELD_INVALID, FIELD_FLOATING_PAD } from "./field-base.js";
5
5
  import { FieldLabel } from "./field-parts.js";
6
- import { assignRef, EndHintRow, useFieldMessages } from "./field-parts.js";
6
+ import {
7
+ assignRef,
8
+ EndHintRow,
9
+ LockedReason,
10
+ useFieldMessages,
11
+ useLockReason
12
+ } from "./field-parts.js";
7
13
  import { cn } from "../lib/cn.js";
8
14
  import { useComboboxCore } from "./combobox-core.js";
9
15
  import {
@@ -32,6 +38,10 @@ function CurrencySelect({
32
38
  help,
33
39
  labels,
34
40
  currencyNames,
41
+ disabled,
42
+ disabledReason,
43
+ disabledReasonDisplay,
44
+ commit,
35
45
  "aria-label": ariaLabel,
36
46
  "aria-describedby": ariaDescribedBy,
37
47
  "aria-invalid": ariaInvalid,
@@ -51,6 +61,10 @@ function CurrencySelect({
51
61
  const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
52
62
  const locale = useKitLocale();
53
63
  const selected = getCurrency(value);
64
+ const lock = useLockReason(commit, disabledReason);
65
+ const locked = lock.locked;
66
+ const inert = locked || Boolean(disabled);
67
+ if (inert && open) setOpen(false);
54
68
  const listboxId = `${useId()}-listbox`;
55
69
  const field = useFieldMessages({
56
70
  hint,
@@ -59,7 +73,9 @@ function CurrencySelect({
59
73
  error,
60
74
  invalid,
61
75
  describedBy: ariaDescribedBy,
62
- ariaInvalid
76
+ ariaInvalid,
77
+ // A lock's reason sits between the caption and the error, as on Select.
78
+ reasonId: locked && lock.reasonId
63
79
  });
64
80
  const { labelHint, describedBy, isInvalid } = field;
65
81
  const fieldName = typeof label === "string" ? label : text.currency;
@@ -70,8 +86,17 @@ function CurrencySelect({
70
86
  ref: setTrigger,
71
87
  type: "button",
72
88
  "aria-label": name,
73
- onClick: () => setOpen((v) => !v),
89
+ disabled: locked ? void 0 : disabled,
90
+ "aria-disabled": locked || void 0,
91
+ onClick: (e) => {
92
+ if (inert) {
93
+ e.preventDefault();
94
+ return;
95
+ }
96
+ setOpen((v) => !v);
97
+ },
74
98
  onKeyDown: (e) => {
99
+ if (inert) return;
75
100
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
76
101
  e.preventDefault();
77
102
  setOpen(true);
@@ -83,16 +108,36 @@ function CurrencySelect({
83
108
  "aria-expanded": open,
84
109
  "aria-invalid": isInvalid || void 0,
85
110
  "aria-describedby": describedBy,
86
- className: cn(FIELD_TRIGGER, "pe-9", label !== void 0 && FIELD_FLOATING_PAD, isInvalid && FIELD_INVALID),
111
+ className: cn(
112
+ FIELD_TRIGGER,
113
+ "pe-9",
114
+ label !== void 0 && FIELD_FLOATING_PAD,
115
+ // FIELD_BASE's `disabled:` look, for a trigger locked without being `disabled`
116
+ // (the `:disabled` variants cannot match it) — Select's FIELD_LOCKED. No hover:
117
+ // nothing here answers a press.
118
+ locked && "cursor-not-allowed bg-surface-2 text-muted hover:bg-surface-2",
119
+ isInvalid && FIELD_INVALID
120
+ ),
87
121
  children: [
88
- /* @__PURE__ */ jsx("span", { className: cn("flex items-center gap-2 min-w-0", selected ? "text-primary" : "text-placeholder"), children: selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
89
- /* @__PURE__ */ jsx(CurrencyFlag, { country: selected.country }),
90
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: selected.code })
91
- ] }) : placeholder ?? text.currency }),
92
- /* @__PURE__ */ jsx(FieldChevron, {})
122
+ /* @__PURE__ */ jsx(
123
+ "span",
124
+ {
125
+ className: cn(
126
+ "flex items-center gap-2 min-w-0",
127
+ // The settled look reaches the code too: `text-primary` here would outweigh it.
128
+ !selected ? "text-placeholder" : inert ? "text-muted" : "text-primary"
129
+ ),
130
+ children: selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
131
+ /* @__PURE__ */ jsx(CurrencyFlag, { country: selected.country }),
132
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: selected.code })
133
+ ] }) : placeholder ?? text.currency
134
+ }
135
+ ),
136
+ !inert && /* @__PURE__ */ jsx(FieldChevron, {})
93
137
  ]
94
138
  }
95
139
  );
140
+ const control = locked ? /* @__PURE__ */ jsx(LockedReason, { lock, display: disabledReasonDisplay, className: "flex w-full items-stretch", children: trigger }) : trigger;
96
141
  return (
97
142
  // The wrapper takes `rest`; the trigger takes the name. This field's label is a
98
143
  // floating <span> rather than a <label for>, so a caller who wants the control to
@@ -108,7 +153,7 @@ function CurrencySelect({
108
153
  /* @__PURE__ */ jsx("span", { className: "pointer-events-auto flex shrink-0 items-center", children: labelHint })
109
154
  ] })
110
155
  )),
111
- /* @__PURE__ */ jsx(EndHintRow, { hint: label === void 0 ? labelHint : void 0, children: trigger }),
156
+ /* @__PURE__ */ jsx(EndHintRow, { hint: label === void 0 ? labelHint : void 0, children: control }),
112
157
  field.below,
113
158
  /* @__PURE__ */ jsx(
114
159
  CurrencyOptionList,
@@ -122,6 +167,7 @@ function CurrencySelect({
122
167
  searchPlaceholder: text.search,
123
168
  sheetTitle: label ?? text.currency,
124
169
  onChoose: (code) => {
170
+ if (inert) return;
125
171
  onChange(code);
126
172
  closeToTrigger();
127
173
  }