@k2b/ui 0.55.0 → 0.56.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 (88) hide show
  1. package/dist/browser/actions/Toolbar.js +16 -7
  2. package/dist/browser/actions/Toolbar.js.map +1 -1
  3. package/dist/browser/chat/ChatComposer.js +28 -27
  4. package/dist/browser/chat/ChatComposer.js.map +1 -1
  5. package/dist/browser/content/Lightbox.js +917 -283
  6. package/dist/browser/content/Lightbox.js.map +1 -1
  7. package/dist/browser/content/PdfPages.js +8 -3
  8. package/dist/browser/content/PdfPages.js.map +1 -1
  9. package/dist/browser/content/PdfThumbnails.js +271 -0
  10. package/dist/browser/content/PdfThumbnails.js.map +1 -0
  11. package/dist/browser/content/PdfViewer.js +11 -3
  12. package/dist/browser/content/PdfViewer.js.map +1 -1
  13. package/dist/browser/content/Timeline.js +116 -117
  14. package/dist/browser/content/Timeline.js.map +1 -1
  15. package/dist/browser/content/code-highlight.js +24 -11
  16. package/dist/browser/content/code-highlight.js.map +1 -1
  17. package/dist/browser/content/index.js +5 -1
  18. package/dist/browser/content/index.js.map +1 -1
  19. package/dist/browser/content/lightbox-messages.js +64 -18
  20. package/dist/browser/content/lightbox-messages.js.map +1 -1
  21. package/dist/browser/content/lightbox-renderers.js +6 -0
  22. package/dist/browser/content/lightbox-renderers.js.map +1 -0
  23. package/dist/browser/content/map-view-worker.js +3 -3
  24. package/dist/browser/content/pdf-messages.js +16 -2
  25. package/dist/browser/content/pdf-messages.js.map +1 -1
  26. package/dist/browser/content/pdf-viewer-engine.js +15 -15
  27. package/dist/browser/content/pdf-viewer-worker.js +4 -5
  28. package/dist/browser/feedback/prompt-confirm.js +2 -0
  29. package/dist/browser/feedback/prompt-confirm.js.map +1 -1
  30. package/dist/browser/internal/truncated-title.js +9 -0
  31. package/dist/browser/internal/truncated-title.js.map +1 -0
  32. package/dist/browser/layout/DetailPanel.js +3 -5
  33. package/dist/browser/layout/DetailPanel.js.map +1 -1
  34. package/dist/browser/layout/PanelDialog.js +3 -1
  35. package/dist/browser/layout/PanelDialog.js.map +1 -1
  36. package/dist/ssr/actions/CommandMenu.js +2 -2
  37. package/dist/ssr/actions/CommandMenu.js.map +1 -1
  38. package/dist/ssr/actions/Toolbar.js +16 -7
  39. package/dist/ssr/actions/Toolbar.js.map +1 -1
  40. package/dist/ssr/chat/ChatComposer.js +31 -30
  41. package/dist/ssr/chat/ChatComposer.js.map +1 -1
  42. package/dist/ssr/content/Lightbox.js +659 -150
  43. package/dist/ssr/content/Lightbox.js.map +1 -1
  44. package/dist/ssr/content/PdfPages.js +8 -3
  45. package/dist/ssr/content/PdfPages.js.map +1 -1
  46. package/dist/ssr/content/PdfThumbnails.js +189 -0
  47. package/dist/ssr/content/PdfThumbnails.js.map +1 -0
  48. package/dist/ssr/content/PdfViewer.js +11 -3
  49. package/dist/ssr/content/PdfViewer.js.map +1 -1
  50. package/dist/ssr/content/Timeline.js +2 -5
  51. package/dist/ssr/content/Timeline.js.map +1 -1
  52. package/dist/ssr/content/code-highlight.js +24 -11
  53. package/dist/ssr/content/code-highlight.js.map +1 -1
  54. package/dist/ssr/content/index.js +5 -1
  55. package/dist/ssr/content/index.js.map +1 -1
  56. package/dist/ssr/content/lightbox-messages.js +64 -18
  57. package/dist/ssr/content/lightbox-messages.js.map +1 -1
  58. package/dist/ssr/content/lightbox-renderers.js +6 -0
  59. package/dist/ssr/content/lightbox-renderers.js.map +1 -0
  60. package/dist/ssr/content/pdf-messages.js +16 -2
  61. package/dist/ssr/content/pdf-messages.js.map +1 -1
  62. package/dist/ssr/feedback/prompt-confirm.js +1 -0
  63. package/dist/ssr/feedback/prompt-confirm.js.map +1 -1
  64. package/dist/ssr/inputs/ChoiceInputs.js +2 -2
  65. package/dist/ssr/inputs/ChoiceInputs.js.map +1 -1
  66. package/dist/ssr/inputs/SignatureInput.js +2 -2
  67. package/dist/ssr/inputs/SignatureInput.js.map +1 -1
  68. package/dist/ssr/inputs/markdown/SlashCommands.js +2 -2
  69. package/dist/ssr/inputs/markdown/SlashCommands.js.map +1 -1
  70. package/dist/ssr/internal/truncated-title.js +9 -0
  71. package/dist/ssr/internal/truncated-title.js.map +1 -0
  72. package/dist/ssr/layout/DetailPanel.js +1 -4
  73. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  74. package/dist/ssr/layout/PanelDialog.js +1 -0
  75. package/dist/ssr/layout/PanelDialog.js.map +1 -1
  76. package/dist/styles.css +1 -1
  77. package/dist/types/actions/Toolbar.d.ts +6 -0
  78. package/dist/types/chat/ChatComposer.d.ts +1 -0
  79. package/dist/types/content/Lightbox.d.ts +54 -14
  80. package/dist/types/content/PdfPages.d.ts +7 -1
  81. package/dist/types/content/PdfThumbnails.d.ts +26 -0
  82. package/dist/types/content/PdfViewer.d.ts +12 -3
  83. package/dist/types/content/index.d.ts +4 -2
  84. package/dist/types/content/lightbox-messages.d.ts +31 -8
  85. package/dist/types/content/lightbox-renderers.d.ts +3 -0
  86. package/dist/types/content/pdf-messages.d.ts +7 -0
  87. package/dist/types/internal/truncated-title.d.ts +7 -0
  88. package/package.json +20 -20
@@ -340,7 +340,7 @@ const rovingFocus = (root, orientation) => {
340
340
  * measuring: hiding it, even for a moment, can make the browser drop focus from it or from its open menu. An idle More
341
341
  * stays out of the flow but keeps its box, so its width is always known.
342
342
  */
343
- const measureOverflow = (root, more, actions, available) => {
343
+ const measureOverflow = (root, more, actions, available, pinned = false) => {
344
344
  for (const element of root.querySelectorAll(`[${overflowAttribute}]`)) if (element !== more) reveal(element);
345
345
  root.removeAttribute(compactAttribute);
346
346
  const children = Array.from(root.children).filter(element => element instanceof HTMLElement && element !== more);
@@ -393,10 +393,11 @@ const measureOverflow = (root, more, actions, available) => {
393
393
  const candidates = actions
394
394
  // An action its application hides, even with `visibility: hidden`, must not reappear as a More row.
395
395
  .filter(action => action.props.priority !== undefined && visible(action.element) && getComputedStyle(action.element).visibility !== "hidden").reverse().sort((a, b) => b.props.priority - a.props.priority);
396
- let movedAny = false;
397
- tidy(false);
396
+ // With rarer commands of its own, More always shows and always takes its room.
397
+ let movedAny = pinned;
398
+ tidy(pinned);
398
399
  // Labels go before actions: a toolbar that does not fit with its labels drops them first.
399
- if (used(false) > available && root.querySelector(".k2b-toolbar__action[data-text]")) root.setAttribute(compactAttribute, "");
400
+ if (used(pinned) > available && root.querySelector(".k2b-toolbar__action[data-text]")) root.setAttribute(compactAttribute, "");
400
401
  for (const action of candidates) {
401
402
  if (used(movedAny) <= available) break;
402
403
  hide(action.element);
@@ -433,7 +434,7 @@ export const Toolbar = Object.assign(props => {
433
434
  // Cleared before measuring so the pending `visibility: hidden` does not hide every action from the check
434
435
  // below; the whole measurement still runs before the next paint.
435
436
  root.removeAttribute("data-overflow-pending");
436
- const next = measureOverflow(root, more, ordered, available);
437
+ const next = measureOverflow(root, more, ordered, available, (props.moreItems?.length ?? 0) > 0);
437
438
  setMoved(previous => previous.length === next.length && previous.every((action, index) => action === next[index]) ? previous : next);
438
439
  navigation?.sync();
439
440
  // Focus on an action that moved, on a menu row whose action came back, or on a More that disappeared goes to
@@ -492,7 +493,15 @@ export const Toolbar = Object.assign(props => {
492
493
  mutations.disconnect();
493
494
  });
494
495
  });
495
- const menuItems = () => moved().map(action => action.item);
496
+ // Actions that moved come first, in their order and in a group of their own; the host's rarer commands follow.
497
+ const menuItems = () => {
498
+ const movedItems = moved().map(action => action.item);
499
+ const pinnedItems = props.moreItems ?? [];
500
+ if (!pinnedItems.length) return movedItems;
501
+ return movedItems.length ? [{
502
+ items: movedItems
503
+ }, ...pinnedItems] : [...pinnedItems];
504
+ };
496
505
  const content = _$createComponent(ToolbarOrientationContext.Provider, {
497
506
  value: orientation,
498
507
  get children() {
@@ -530,7 +539,7 @@ export const Toolbar = Object.assign(props => {
530
539
  return messages().moreActions;
531
540
  },
532
541
  get disabled() {
533
- return moved().length === 0;
542
+ return _$memo(() => moved().length === 0)() && !props.moreItems?.length;
534
543
  },
535
544
  get children() {
536
545
  return _$createComponent(Dropdown.Trigger, {
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["actions/Toolbar.tsx"],"sourcesContent":["import { createContext, createEffect, createSignal, type JSX, onCleanup, onMount, Show, sharedConfig, useContext } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { Kbd } from \"../content/Kbd\";\nimport { announce } from \"../feedback/announce\";\nimport { useLocale } from \"../intl/locale\";\nimport { formatShortcut, type KeyboardPlatform, keyboardPlatform } from \"../intl/shortcut\";\nimport { IconButton } from \"./Button\";\nimport { Dropdown, type DropdownAction } from \"./Dropdown\";\nimport { useToolbarMessages } from \"./toolbar-messages\";\n\nexport type ToolbarProps = {\n children: JSX.Element;\n label: string;\n orientation?: \"horizontal\" | \"vertical\";\n wrap?: boolean;\n /** `floating` floats the toolbar at an edge of its column. Defaults to `inline`. */\n variant?: \"inline\" | \"floating\";\n /** The edge a floating toolbar sticks to while its column scrolls. Defaults to `bottom`. */\n edge?: \"top\" | \"bottom\";\n /**\n * `danger` makes a floating toolbar the one red pill of a stopped state, such as an editor that can no longer save.\n * It spans its row in place of the usual pills, and screen readers announce its labels at once. Inline toolbars\n * ignore it.\n */\n tone?: \"danger\";\n class?: string;\n};\n\nexport type ToolbarActionProps = {\n /** Accessible name, tooltip text, and the row label in the More menu. */\n label: string;\n /** Icon class, such as \"ti ti-archive\". */\n icon: string;\n /**\n * Shortcut hint below the icon, tooltip suffix, and aria-keyshortcuts; does not register a shortcut handler.\n * SelectionToolbar's compact actions keep only the tooltip suffix and aria-keyshortcuts.\n */\n keys?: string;\n /** 1 is most important. Larger numbers move first; ties move later DOM actions first. Omit to keep fixed. */\n priority?: number;\n /**\n * Shows the label beside the icon while a floating toolbar has room. When it gets narrow, these labels go first,\n * every action keeps its icon, and only then do actions move into More.\n */\n text?: boolean;\n disabled?: boolean;\n /** Makes the action a toggle and exposes its state as `aria-pressed`, such as Bold over bold text. */\n pressed?: boolean;\n onClick?: () => void;\n};\nexport type ToolbarLabelProps = {\n children: JSX.Element;\n /**\n * Follows the label while it fits, such as the reason after \"Not saved\". A narrow toolbar hides it whole before\n * actions give up their labels; screen readers always read it.\n */\n detail?: JSX.Element;\n class?: string;\n};\n\nexport type ToolbarGroupProps = { children: JSX.Element; label?: string; class?: string };\nexport type ToolbarSeparatorProps = { class?: string };\n\ntype ToolbarComponent = ((props: ToolbarProps) => JSX.Element) & {\n Action: (props: ToolbarActionProps) => JSX.Element;\n Label: (props: ToolbarLabelProps) => JSX.Element;\n Group: (props: ToolbarGroupProps) => JSX.Element;\n Separator: (props: ToolbarSeparatorProps) => JSX.Element;\n Spacer: () => JSX.Element;\n};\n\ntype ToolbarOrientation = NonNullable<ToolbarProps[\"orientation\"]>;\n\nconst defaultToolbarOrientation: () => ToolbarOrientation = () => \"horizontal\";\nconst ToolbarOrientationContext = createContext(defaultToolbarOrientation);\n/** True inside a floating `tone=\"danger\"` toolbar, whose labels announce themselves. */\nconst ToolbarDangerContext = createContext(false);\n/** False where actions are icon-sized, such as SelectionToolbar: no room below the icon for a hint. Package-internal. */\nexport const ToolbarHintsContext = createContext(true);\n\n// `item` is created once per action: the More menu keys its rows by identity, so a remeasure keeps a focused row.\ntype RegisteredAction = { element: HTMLButtonElement; props: ToolbarActionProps; item: DropdownAction };\nconst ToolbarActionsContext = createContext<(action: RegisteredAction) => () => void>();\nconst overflowAttribute = \"data-overflow\";\n/** Set on a floating toolbar whose action labels gave way to icons for lack of room. */\nconst compactAttribute = \"data-compact\";\nconst hide = (element: Element) => element.setAttribute(overflowAttribute, \"hidden\");\nconst reveal = (element: Element) => element.removeAttribute(overflowAttribute);\n\n// ARIA uses language-independent key names, unlike the translated tooltip and caps.\nconst ariaShortcut = (keys: string | undefined, platform: KeyboardPlatform): string | undefined => {\n if (!keys || !formatShortcut(keys, { platform, locale: \"en\" }).keys.length) return undefined;\n const input = keys.trim().toLowerCase();\n const plus = input === \"+\" || input.endsWith(\"++\");\n const parts = (plus ? input.slice(0, -1) : input).split(\"+\");\n // ARIA separates keys with \"+\", so the plus key itself is named \"plus\".\n const key = plus ? \"plus\" : parts.pop() || \"space\";\n if (plus) parts.pop();\n const names: Record<string, string> = {\n mod: platform === \"apple\" ? \"Meta\" : \"Control\",\n ctrl: \"Control\",\n alt: \"Alt\",\n shift: \"Shift\",\n meta: \"Meta\",\n arrowup: \"ArrowUp\",\n arrowdown: \"ArrowDown\",\n arrowleft: \"ArrowLeft\",\n arrowright: \"ArrowRight\",\n escape: \"Escape\",\n esc: \"Escape\",\n backspace: \"Backspace\",\n enter: \"Enter\",\n delete: \"Delete\",\n space: \"Space\",\n tab: \"Tab\",\n home: \"Home\",\n end: \"End\",\n pageup: \"PageUp\",\n pagedown: \"PageDown\",\n plus: \"plus\",\n };\n const final = key.length === 1 || /^f(?:[1-9]|1[0-2])$/.test(key) ? key.toUpperCase() : names[key];\n return final ? [...new Set(parts.map((part) => names[part])), final].join(\"+\") : undefined;\n};\n\nconst ToolbarAction = (props: ToolbarActionProps): JSX.Element => {\n const register = useContext(ToolbarActionsContext);\n const hints = useContext(ToolbarHintsContext);\n const locale = useLocale();\n const [platform, setPlatform] = createSignal<KeyboardPlatform>(isServer || sharedConfig.context ? \"other\" : keyboardPlatform());\n onMount(() => setPlatform(keyboardPlatform()));\n const tooltip = () => {\n const shortcut = props.keys ? formatShortcut(props.keys, { platform: platform(), locale: locale() }).label : \"\";\n return shortcut ? `${props.label} (${shortcut})` : props.label;\n };\n return (\n <IconButton\n ref={(element) => {\n const item: DropdownAction = {\n get label() {\n return props.label;\n },\n get icon() {\n return props.icon;\n },\n get disabled() {\n return props.disabled;\n },\n action: () => props.onClick?.(),\n };\n const unregister = register?.({ element, props, item });\n if (unregister) onCleanup(unregister);\n }}\n class=\"k2b-toolbar__action\"\n label={props.label}\n variant=\"ghost\"\n tooltip={tooltip()}\n aria-keyshortcuts={ariaShortcut(props.keys, platform())}\n aria-pressed={props.pressed === undefined ? undefined : props.pressed ? \"true\" : \"false\"}\n data-priority={props.priority}\n data-text={props.text ? \"\" : undefined}\n disabled={props.disabled}\n onClick={() => props.onClick?.()}\n >\n <i class={props.icon} aria-hidden=\"true\" />\n <Show when={props.text}>\n <span class=\"k2b-toolbar__text\" aria-hidden=\"true\">\n {props.label}\n </span>\n </Show>\n <Show when={hints && props.keys}>{(keys) => <Kbd keys={keys()} class=\"k2b-kbd-hint k2b-toolbar__hint\" />}</Show>\n </IconButton>\n );\n};\n\nconst ToolbarLabel = (props: ToolbarLabelProps): JSX.Element => {\n const danger = useContext(ToolbarDangerContext);\n let label!: HTMLSpanElement;\n // The shared assertive live region exists before the text arrives, so the message is read reliably, also when the\n // pill appears with it or its text changes later.\n onMount(() => {\n if (!danger) return;\n let spoken = \"\";\n const speak = () => {\n const text = label.textContent?.replace(/\\s+/g, \" \").trim() ?? \"\";\n if (text === spoken) return;\n spoken = text;\n announce(text, { politeness: \"assertive\" });\n };\n speak();\n const observer = new MutationObserver(speak);\n observer.observe(label, { childList: true, subtree: true, characterData: true });\n onCleanup(() => observer.disconnect());\n });\n return (\n <span ref={label} class={`k2b-toolbar__label ${props.class ?? \"\"}`} data-detail={props.detail ? \"\" : undefined}>\n <Show when={props.detail} fallback={props.children}>\n <span class=\"k2b-toolbar__label-main\">{props.children}</span>\n <span class=\"k2b-toolbar__label-detail\">{props.detail}</span>\n </Show>\n </span>\n );\n};\n\nconst ToolbarGroup = (props: ToolbarGroupProps): JSX.Element => (\n <div class={`k2b-toolbar__group ${props.class ?? \"\"}`} role=\"group\" aria-label={props.label}>\n {props.children}\n </div>\n);\n\nconst ToolbarSeparator = (props: ToolbarSeparatorProps): JSX.Element => {\n const toolbarOrientation = useContext(ToolbarOrientationContext);\n const separatorOrientation = () => (toolbarOrientation() === \"horizontal\" ? \"vertical\" : \"horizontal\");\n\n return (\n <span\n class={`k2b-toolbar__separator ${props.class ?? \"\"}`}\n role=\"separator\"\n aria-orientation={separatorOrientation()}\n data-orientation={separatorOrientation()}\n />\n );\n};\n\nconst ToolbarSpacer = (): JSX.Element => <span class=\"k2b-toolbar__spacer\" aria-hidden=\"true\" />;\n\nconst rovingFocus = (root: HTMLDivElement, orientation: () => ToolbarOrientation) => {\n let last: HTMLElement | undefined;\n const setLast = (item: HTMLElement | undefined) => {\n if (item === last) return;\n if (last) resizeObserver.unobserve(last);\n last = item;\n if (last) resizeObserver.observe(last);\n };\n const controls = () =>\n Array.from(root.querySelectorAll<HTMLElement>(\"button, a[href], input, select, textarea, [tabindex]\")).filter((item) => {\n if (\n item.matches(\"textarea, select\") ||\n item.isContentEditable ||\n (item.matches(\"input\") && !/^(button|checkbox|reset|submit|image|color|file)$/i.test(item.getAttribute(\"type\") ?? \"text\"))\n )\n return false;\n const nested = item.closest('[role=\"menu\"], [role=\"listbox\"], [role=\"dialog\"], [popover]');\n return !nested || !root.contains(nested);\n });\n const items = () =>\n controls().filter(\n (item) => !item.matches(\":disabled\") && !item.closest('[data-overflow=\"hidden\"]') && item.getClientRects().length > 0,\n );\n const sync = () => {\n // A toolbar that is still hidden, such as a SelectionToolbar about to show, keeps one stop: otherwise Tab right\n // after it shows would pass it before the next measure.\n const shown = items();\n const available = shown.length\n ? shown\n : controls().filter((item) => !item.matches(\":disabled\") && !item.closest('[data-overflow=\"hidden\"]'));\n if (!last || !available.includes(last)) setLast(available[0]);\n for (const item of controls()) item.tabIndex = item === last ? 0 : -1;\n };\n const focusin = (event: FocusEvent) => {\n if (event.target instanceof HTMLElement && items().includes(event.target)) {\n setLast(event.target);\n sync();\n }\n };\n const keydown = (event: KeyboardEvent) => {\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n const available = items();\n const target = event.target;\n if (!(target instanceof HTMLElement) || !available.includes(target)) return;\n const forward = orientation() === \"vertical\" ? \"ArrowDown\" : getComputedStyle(root).direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n const backward = orientation() === \"vertical\" ? \"ArrowUp\" : forward === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n const index = available.indexOf(target);\n const next =\n event.key === \"Home\"\n ? 0\n : event.key === \"End\"\n ? available.length - 1\n : event.key === forward\n ? (index + 1) % available.length\n : event.key === backward\n ? (index + available.length - 1) % available.length\n : -1;\n if (next < 0) return;\n event.preventDefault();\n setLast(available[next]);\n sync();\n last?.focus();\n };\n const observer = new MutationObserver(sync);\n observer.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"disabled\", \"hidden\", \"class\", \"style\", overflowAttribute],\n });\n const resizeObserver = new ResizeObserver(sync);\n resizeObserver.observe(root);\n root.addEventListener(\"focusin\", focusin);\n sync();\n return {\n keydown,\n sync,\n cleanup: () => {\n observer.disconnect();\n resizeObserver.disconnect();\n root.removeEventListener(\"focusin\", focusin);\n },\n };\n};\n\n/**\n * All measurement writes are DOM attributes: reactive writes do not flush during onMount. More is never toggled while\n * measuring: hiding it, even for a moment, can make the browser drop focus from it or from its open menu. An idle More\n * stays out of the flow but keeps its box, so its width is always known.\n */\nconst measureOverflow = (\n root: HTMLDivElement,\n more: HTMLDivElement,\n actions: RegisteredAction[],\n available: number,\n): RegisteredAction[] => {\n for (const element of root.querySelectorAll(`[${overflowAttribute}]`)) if (element !== more) reveal(element);\n root.removeAttribute(compactAttribute);\n const children = Array.from(root.children).filter(\n (element): element is HTMLElement => element instanceof HTMLElement && element !== more,\n );\n const visible = (element: Element) => !element.matches(\"[popover]\") && element.getClientRects().length > 0;\n const separator = (element: Element) => element.classList.contains(\"k2b-toolbar__separator\");\n const item = (element: Element) => !separator(element) && !element.classList.contains(\"k2b-toolbar__spacer\");\n // Separators are tidied in DOM order with More, the last control, counted as shown when `withMore` is set.\n const all = Array.from(root.children).filter((element): element is HTMLElement => element instanceof HTMLElement);\n const tidy = (withMore: boolean) => {\n for (const group of root.querySelectorAll(\".k2b-toolbar__group\")) {\n reveal(group);\n if (!Array.from(group.children).some(visible)) hide(group);\n }\n for (const child of children) if (separator(child)) reveal(child);\n const shown = (element: HTMLElement) => (element === more ? withMore : visible(element));\n let preceding = false;\n for (let index = 0; index < all.length; index++) {\n const child = all[index]!;\n if (!shown(child)) continue;\n if (separator(child)) {\n const following = all.slice(index + 1).some((next) => item(next) && shown(next));\n if (!preceding || !following) hide(child);\n else preceding = false;\n } else if (item(child)) preceding = true;\n }\n };\n const style = getComputedStyle(root);\n const edges = [style.paddingLeft, style.paddingRight, style.borderLeftWidth, style.borderRightWidth].reduce(\n (sum, value) => sum + (Number.parseFloat(value) || 0),\n 0,\n );\n const gap = Number.parseFloat(style.columnGap) || 0;\n // A label may shrink in an overfull pill; measure its untruncated width (up to its cap) so actions move before the\n // count or title truncates.\n const width = (child: HTMLElement) => {\n // Separators carry inline margins, which bounding boxes leave out.\n const childStyle = getComputedStyle(child);\n // A spacer takes whatever room is left, so it needs only its minimum.\n if (child.classList.contains(\"k2b-toolbar__spacer\")) return Number.parseFloat(childStyle.minWidth) || 0;\n const box =\n child.getBoundingClientRect().width +\n (Number.parseFloat(childStyle.marginLeft) || 0) +\n (Number.parseFloat(childStyle.marginRight) || 0);\n if (!child.classList.contains(\"k2b-toolbar__label\")) return box;\n // A detail only takes leftover room: the label needs its main text and padding.\n const main = child.querySelector<HTMLElement>(\":scope > .k2b-toolbar__label-main\");\n if (main)\n return (\n main.scrollWidth +\n (Number.parseFloat(childStyle.paddingLeft) || 0) +\n (Number.parseFloat(childStyle.paddingRight) || 0) +\n (Number.parseFloat(childStyle.marginLeft) || 0) +\n (Number.parseFloat(childStyle.marginRight) || 0)\n );\n const cap = Number.parseFloat(childStyle.maxWidth);\n return Math.max(box, Math.min(child.scrollWidth, Number.isNaN(cap) ? Number.POSITIVE_INFINITY : cap));\n };\n const moreWidth = width(more) + gap;\n const used = (withMore: boolean) => {\n const shown = children.filter(visible);\n return shown.reduce((sum, child) => sum + width(child), edges) + gap * Math.max(0, shown.length - 1) + (withMore ? moreWidth : 0);\n };\n // Stable sort retains DOM order for the menu, but removes later actions first on a priority tie.\n const candidates = actions\n // An action its application hides, even with `visibility: hidden`, must not reappear as a More row.\n .filter(\n (action) =>\n action.props.priority !== undefined && visible(action.element) && getComputedStyle(action.element).visibility !== \"hidden\",\n )\n .reverse()\n .sort((a, b) => b.props.priority! - a.props.priority!);\n let movedAny = false;\n tidy(false);\n // Labels go before actions: a toolbar that does not fit with its labels drops them first.\n if (used(false) > available && root.querySelector(\".k2b-toolbar__action[data-text]\")) root.setAttribute(compactAttribute, \"\");\n for (const action of candidates) {\n if (used(movedAny) <= available) break;\n hide(action.element);\n movedAny = true;\n tidy(true);\n }\n // More changes only here, and only when its state changes.\n if (movedAny) reveal(more);\n else if (!more.hasAttribute(overflowAttribute)) hide(more);\n return actions.filter((action) => action.element.hasAttribute(overflowAttribute));\n};\n\nexport const Toolbar = Object.assign(\n (props: ToolbarProps): JSX.Element => {\n // The variant decides the DOM shape, so it is read once.\n const floating = props.variant === \"floating\";\n const danger = () => (floating && props.tone === \"danger\" ? \"danger\" : undefined);\n const orientation = () => (floating ? \"horizontal\" : (props.orientation ?? \"horizontal\"));\n const messages = useToolbarMessages();\n const actions = new Set<RegisteredAction>();\n const [revision, setRevision] = createSignal(0);\n const [moved, setMoved] = createSignal<RegisteredAction[]>([]);\n let root!: HTMLDivElement;\n let strip: HTMLDivElement | undefined;\n let more: HTMLDivElement | undefined;\n let trigger: HTMLButtonElement | undefined;\n let mounted = false;\n let navigation: ReturnType<typeof rovingFocus> | undefined;\n // Only the floating variant moves actions into More; inline toolbars keep every action in place.\n const measure = () => {\n if (!mounted || !strip || !more) return;\n const style = getComputedStyle(strip);\n const available = strip.clientWidth - Number.parseFloat(style.paddingLeft) - Number.parseFloat(style.paddingRight);\n if (available <= 0) return;\n const ordered = [...actions].sort((a, b) =>\n a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n );\n const focused = document.activeElement;\n // Cleared before measuring so the pending `visibility: hidden` does not hide every action from the check\n // below; the whole measurement still runs before the next paint.\n root.removeAttribute(\"data-overflow-pending\");\n const next = measureOverflow(root, more, ordered, available);\n setMoved((previous) =>\n previous.length === next.length && previous.every((action, index) => action === next[index]) ? previous : next,\n );\n navigation?.sync();\n // Focus on an action that moved, on a menu row whose action came back, or on a More that disappeared goes to\n // More, or to the toolbar's tab stop when nothing is left in More. Inside an effect the menu rows update after\n // this function returns, so the check waits for that flush; a microtask still runs before the next paint.\n queueMicrotask(() => {\n // A toolbar unmounted meanwhile, as its view closes, owns no focus any more.\n if (!mounted) return;\n const lost =\n next.some((action) => action.element === focused) ||\n (focused instanceof HTMLElement && !focused.isConnected) ||\n (focused === trigger && !next.length);\n if (lost) (next.length ? trigger : root.querySelector<HTMLElement>('[tabindex=\"0\"]'))?.focus();\n });\n };\n const register = (action: RegisteredAction) => {\n actions.add(action);\n setRevision((value) => value + 1);\n return () => {\n actions.delete(action);\n setRevision((value) => value + 1);\n };\n };\n if (floating)\n createEffect(() => {\n revision();\n for (const action of actions) {\n // Content and priority changes can affect intrinsic widths as well as menu rows.\n void action.props.priority;\n void action.props.label;\n void action.props.icon;\n void action.props.keys;\n void action.props.text;\n }\n measure();\n });\n onMount(() => {\n mounted = true;\n navigation = rovingFocus(root, orientation);\n onCleanup(() => {\n mounted = false;\n navigation?.cleanup();\n });\n if (!strip) return;\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(strip);\n observer.observe(root);\n const mutations = new MutationObserver(measure);\n // Visibility an application sets also counts. Measurement writes only data attributes, which stay unobserved.\n mutations.observe(root, {\n childList: true,\n subtree: true,\n characterData: true,\n attributes: true,\n attributeFilter: [\"hidden\", \"class\", \"style\"],\n });\n onCleanup(() => {\n observer.disconnect();\n mutations.disconnect();\n });\n });\n const menuItems = (): DropdownAction[] => moved().map((action) => action.item);\n const content = (\n <ToolbarOrientationContext.Provider value={orientation}>\n <ToolbarDangerContext.Provider value={!!danger()}>\n <ToolbarActionsContext.Provider value={floating ? register : undefined}>\n <div\n ref={root}\n onKeyDown={(event) => navigation?.keydown(event)}\n class={`k2b-toolbar ${props.class ?? \"\"}`}\n role=\"toolbar\"\n aria-label={props.label}\n aria-orientation={orientation()}\n data-orientation={orientation()}\n data-variant={floating ? \"floating\" : undefined}\n data-tone={danger()}\n data-wrap={!floating && props.wrap ? \"true\" : undefined}\n data-overflow-pending={floating ? \"\" : undefined}\n >\n {props.children}\n <Show when={floating}>\n <div ref={more} class=\"k2b-toolbar__more\" data-overflow=\"hidden\">\n <Dropdown.Root\n items={menuItems()}\n position=\"top-left\"\n label={messages().moreActions}\n // An open menu closes when its last row returns to the toolbar.\n disabled={moved().length === 0}\n >\n <Dropdown.Trigger ref={trigger} iconOnly label={messages().moreActions}>\n <i class=\"ti ti-dots\" aria-hidden=\"true\" />\n </Dropdown.Trigger>\n </Dropdown.Root>\n </div>\n </Show>\n </div>\n </ToolbarActionsContext.Provider>\n </ToolbarDangerContext.Provider>\n </ToolbarOrientationContext.Provider>\n );\n return floating ? (\n <div ref={strip} class=\"k2b-toolbar-float\" data-edge={props.edge === \"top\" ? \"top\" : undefined} data-tone={danger()}>\n {content}\n </div>\n ) : (\n content\n );\n },\n { Action: ToolbarAction, Label: ToolbarLabel, Group: ToolbarGroup, Separator: ToolbarSeparator, Spacer: ToolbarSpacer },\n) as ToolbarComponent;\n\nexport type ToolbarDockProps = { children: JSX.Element; class?: string };\n\n/**\n * One floating row at the bottom of a column for several floating toolbars: the first sits at the start edge, the last\n * at the end edge, and each moves its own actions into More when the row gets narrow. Content scrolls beneath the row\n * and still ends above it.\n */\nexport const ToolbarDock = (props: ToolbarDockProps): JSX.Element => (\n <div class={props.class ? `k2b-toolbar-dock ${props.class}` : \"k2b-toolbar-dock\"}>{props.children}</div>\n);\n\nexport default Toolbar;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa,EAAE,YAAY,EAAE,YAAY,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,QAAQ,UAAU;AAClI,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,GA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AAI,KAAuB;EAAA;EAAA,uBACkC,KAAK,CAAC,QAAQ;EAAA,mCAArF,KAAK,CAAC,KAAK,GAAG,oBAAoB,KAAK,CAAC,KAAK,EAAE,GAAG,kBAAkB;EAAA;AAAA,IACjF;AAED,eAAe,OAAO;AAAC","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["actions/Toolbar.tsx"],"sourcesContent":["import { createContext, createEffect, createSignal, type JSX, onCleanup, onMount, Show, sharedConfig, useContext } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { Kbd } from \"../content/Kbd\";\nimport { announce } from \"../feedback/announce\";\nimport { useLocale } from \"../intl/locale\";\nimport { formatShortcut, type KeyboardPlatform, keyboardPlatform } from \"../intl/shortcut\";\nimport { IconButton } from \"./Button\";\nimport { Dropdown, type DropdownAction, type DropdownItem } from \"./Dropdown\";\nimport { useToolbarMessages } from \"./toolbar-messages\";\n\nexport type ToolbarProps = {\n children: JSX.Element;\n label: string;\n orientation?: \"horizontal\" | \"vertical\";\n wrap?: boolean;\n /** `floating` floats the toolbar at an edge of its column. Defaults to `inline`. */\n variant?: \"inline\" | \"floating\";\n /** The edge a floating toolbar sticks to while its column scrolls. Defaults to `bottom`. */\n edge?: \"top\" | \"bottom\";\n /**\n * `danger` makes a floating toolbar the one red pill of a stopped state, such as an editor that can no longer save.\n * It spans its row in place of the usual pills, and screen readers announce its labels at once. Inline toolbars\n * ignore it.\n */\n tone?: \"danger\";\n /**\n * Rarer commands of a floating toolbar that always live in More, such as Copy to or Move to trash for a selection.\n * More then always shows; actions that move there on a narrow row come first, these follow in their own group.\n */\n moreItems?: readonly DropdownItem[];\n class?: string;\n};\n\nexport type ToolbarActionProps = {\n /** Accessible name, tooltip text, and the row label in the More menu. */\n label: string;\n /** Icon class, such as \"ti ti-archive\". */\n icon: string;\n /**\n * Shortcut hint below the icon, tooltip suffix, and aria-keyshortcuts; does not register a shortcut handler.\n * SelectionToolbar's compact actions keep only the tooltip suffix and aria-keyshortcuts.\n */\n keys?: string;\n /** 1 is most important. Larger numbers move first; ties move later DOM actions first. Omit to keep fixed. */\n priority?: number;\n /**\n * Shows the label beside the icon while a floating toolbar has room. When it gets narrow, these labels go first,\n * every action keeps its icon, and only then do actions move into More.\n */\n text?: boolean;\n disabled?: boolean;\n /** Makes the action a toggle and exposes its state as `aria-pressed`, such as Bold over bold text. */\n pressed?: boolean;\n onClick?: () => void;\n};\nexport type ToolbarLabelProps = {\n children: JSX.Element;\n /**\n * Follows the label while it fits, such as the reason after \"Not saved\". A narrow toolbar hides it whole before\n * actions give up their labels; screen readers always read it.\n */\n detail?: JSX.Element;\n class?: string;\n};\n\nexport type ToolbarGroupProps = { children: JSX.Element; label?: string; class?: string };\nexport type ToolbarSeparatorProps = { class?: string };\n\ntype ToolbarComponent = ((props: ToolbarProps) => JSX.Element) & {\n Action: (props: ToolbarActionProps) => JSX.Element;\n Label: (props: ToolbarLabelProps) => JSX.Element;\n Group: (props: ToolbarGroupProps) => JSX.Element;\n Separator: (props: ToolbarSeparatorProps) => JSX.Element;\n Spacer: () => JSX.Element;\n};\n\ntype ToolbarOrientation = NonNullable<ToolbarProps[\"orientation\"]>;\n\nconst defaultToolbarOrientation: () => ToolbarOrientation = () => \"horizontal\";\nconst ToolbarOrientationContext = createContext(defaultToolbarOrientation);\n/** True inside a floating `tone=\"danger\"` toolbar, whose labels announce themselves. */\nconst ToolbarDangerContext = createContext(false);\n/** False where actions are icon-sized, such as SelectionToolbar: no room below the icon for a hint. Package-internal. */\nexport const ToolbarHintsContext = createContext(true);\n\n// `item` is created once per action: the More menu keys its rows by identity, so a remeasure keeps a focused row.\ntype RegisteredAction = { element: HTMLButtonElement; props: ToolbarActionProps; item: DropdownAction };\nconst ToolbarActionsContext = createContext<(action: RegisteredAction) => () => void>();\nconst overflowAttribute = \"data-overflow\";\n/** Set on a floating toolbar whose action labels gave way to icons for lack of room. */\nconst compactAttribute = \"data-compact\";\nconst hide = (element: Element) => element.setAttribute(overflowAttribute, \"hidden\");\nconst reveal = (element: Element) => element.removeAttribute(overflowAttribute);\n\n// ARIA uses language-independent key names, unlike the translated tooltip and caps.\nconst ariaShortcut = (keys: string | undefined, platform: KeyboardPlatform): string | undefined => {\n if (!keys || !formatShortcut(keys, { platform, locale: \"en\" }).keys.length) return undefined;\n const input = keys.trim().toLowerCase();\n const plus = input === \"+\" || input.endsWith(\"++\");\n const parts = (plus ? input.slice(0, -1) : input).split(\"+\");\n // ARIA separates keys with \"+\", so the plus key itself is named \"plus\".\n const key = plus ? \"plus\" : parts.pop() || \"space\";\n if (plus) parts.pop();\n const names: Record<string, string> = {\n mod: platform === \"apple\" ? \"Meta\" : \"Control\",\n ctrl: \"Control\",\n alt: \"Alt\",\n shift: \"Shift\",\n meta: \"Meta\",\n arrowup: \"ArrowUp\",\n arrowdown: \"ArrowDown\",\n arrowleft: \"ArrowLeft\",\n arrowright: \"ArrowRight\",\n escape: \"Escape\",\n esc: \"Escape\",\n backspace: \"Backspace\",\n enter: \"Enter\",\n delete: \"Delete\",\n space: \"Space\",\n tab: \"Tab\",\n home: \"Home\",\n end: \"End\",\n pageup: \"PageUp\",\n pagedown: \"PageDown\",\n plus: \"plus\",\n };\n const final = key.length === 1 || /^f(?:[1-9]|1[0-2])$/.test(key) ? key.toUpperCase() : names[key];\n return final ? [...new Set(parts.map((part) => names[part])), final].join(\"+\") : undefined;\n};\n\nconst ToolbarAction = (props: ToolbarActionProps): JSX.Element => {\n const register = useContext(ToolbarActionsContext);\n const hints = useContext(ToolbarHintsContext);\n const locale = useLocale();\n const [platform, setPlatform] = createSignal<KeyboardPlatform>(isServer || sharedConfig.context ? \"other\" : keyboardPlatform());\n onMount(() => setPlatform(keyboardPlatform()));\n const tooltip = () => {\n const shortcut = props.keys ? formatShortcut(props.keys, { platform: platform(), locale: locale() }).label : \"\";\n return shortcut ? `${props.label} (${shortcut})` : props.label;\n };\n return (\n <IconButton\n ref={(element) => {\n const item: DropdownAction = {\n get label() {\n return props.label;\n },\n get icon() {\n return props.icon;\n },\n get disabled() {\n return props.disabled;\n },\n action: () => props.onClick?.(),\n };\n const unregister = register?.({ element, props, item });\n if (unregister) onCleanup(unregister);\n }}\n class=\"k2b-toolbar__action\"\n label={props.label}\n variant=\"ghost\"\n tooltip={tooltip()}\n aria-keyshortcuts={ariaShortcut(props.keys, platform())}\n aria-pressed={props.pressed === undefined ? undefined : props.pressed ? \"true\" : \"false\"}\n data-priority={props.priority}\n data-text={props.text ? \"\" : undefined}\n disabled={props.disabled}\n onClick={() => props.onClick?.()}\n >\n <i class={props.icon} aria-hidden=\"true\" />\n <Show when={props.text}>\n <span class=\"k2b-toolbar__text\" aria-hidden=\"true\">\n {props.label}\n </span>\n </Show>\n <Show when={hints && props.keys}>{(keys) => <Kbd keys={keys()} class=\"k2b-kbd-hint k2b-toolbar__hint\" />}</Show>\n </IconButton>\n );\n};\n\nconst ToolbarLabel = (props: ToolbarLabelProps): JSX.Element => {\n const danger = useContext(ToolbarDangerContext);\n let label!: HTMLSpanElement;\n // The shared assertive live region exists before the text arrives, so the message is read reliably, also when the\n // pill appears with it or its text changes later.\n onMount(() => {\n if (!danger) return;\n let spoken = \"\";\n const speak = () => {\n const text = label.textContent?.replace(/\\s+/g, \" \").trim() ?? \"\";\n if (text === spoken) return;\n spoken = text;\n announce(text, { politeness: \"assertive\" });\n };\n speak();\n const observer = new MutationObserver(speak);\n observer.observe(label, { childList: true, subtree: true, characterData: true });\n onCleanup(() => observer.disconnect());\n });\n return (\n <span ref={label} class={`k2b-toolbar__label ${props.class ?? \"\"}`} data-detail={props.detail ? \"\" : undefined}>\n <Show when={props.detail} fallback={props.children}>\n <span class=\"k2b-toolbar__label-main\">{props.children}</span>\n <span class=\"k2b-toolbar__label-detail\">{props.detail}</span>\n </Show>\n </span>\n );\n};\n\nconst ToolbarGroup = (props: ToolbarGroupProps): JSX.Element => (\n <div class={`k2b-toolbar__group ${props.class ?? \"\"}`} role=\"group\" aria-label={props.label}>\n {props.children}\n </div>\n);\n\nconst ToolbarSeparator = (props: ToolbarSeparatorProps): JSX.Element => {\n const toolbarOrientation = useContext(ToolbarOrientationContext);\n const separatorOrientation = () => (toolbarOrientation() === \"horizontal\" ? \"vertical\" : \"horizontal\");\n\n return (\n <span\n class={`k2b-toolbar__separator ${props.class ?? \"\"}`}\n role=\"separator\"\n aria-orientation={separatorOrientation()}\n data-orientation={separatorOrientation()}\n />\n );\n};\n\nconst ToolbarSpacer = (): JSX.Element => <span class=\"k2b-toolbar__spacer\" aria-hidden=\"true\" />;\n\nconst rovingFocus = (root: HTMLDivElement, orientation: () => ToolbarOrientation) => {\n let last: HTMLElement | undefined;\n const setLast = (item: HTMLElement | undefined) => {\n if (item === last) return;\n if (last) resizeObserver.unobserve(last);\n last = item;\n if (last) resizeObserver.observe(last);\n };\n const controls = () =>\n Array.from(root.querySelectorAll<HTMLElement>(\"button, a[href], input, select, textarea, [tabindex]\")).filter((item) => {\n if (\n item.matches(\"textarea, select\") ||\n item.isContentEditable ||\n (item.matches(\"input\") && !/^(button|checkbox|reset|submit|image|color|file)$/i.test(item.getAttribute(\"type\") ?? \"text\"))\n )\n return false;\n const nested = item.closest('[role=\"menu\"], [role=\"listbox\"], [role=\"dialog\"], [popover]');\n return !nested || !root.contains(nested);\n });\n const items = () =>\n controls().filter(\n (item) => !item.matches(\":disabled\") && !item.closest('[data-overflow=\"hidden\"]') && item.getClientRects().length > 0,\n );\n const sync = () => {\n // A toolbar that is still hidden, such as a SelectionToolbar about to show, keeps one stop: otherwise Tab right\n // after it shows would pass it before the next measure.\n const shown = items();\n const available = shown.length\n ? shown\n : controls().filter((item) => !item.matches(\":disabled\") && !item.closest('[data-overflow=\"hidden\"]'));\n if (!last || !available.includes(last)) setLast(available[0]);\n for (const item of controls()) item.tabIndex = item === last ? 0 : -1;\n };\n const focusin = (event: FocusEvent) => {\n if (event.target instanceof HTMLElement && items().includes(event.target)) {\n setLast(event.target);\n sync();\n }\n };\n const keydown = (event: KeyboardEvent) => {\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n const available = items();\n const target = event.target;\n if (!(target instanceof HTMLElement) || !available.includes(target)) return;\n const forward = orientation() === \"vertical\" ? \"ArrowDown\" : getComputedStyle(root).direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n const backward = orientation() === \"vertical\" ? \"ArrowUp\" : forward === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n const index = available.indexOf(target);\n const next =\n event.key === \"Home\"\n ? 0\n : event.key === \"End\"\n ? available.length - 1\n : event.key === forward\n ? (index + 1) % available.length\n : event.key === backward\n ? (index + available.length - 1) % available.length\n : -1;\n if (next < 0) return;\n event.preventDefault();\n setLast(available[next]);\n sync();\n last?.focus();\n };\n const observer = new MutationObserver(sync);\n observer.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"disabled\", \"hidden\", \"class\", \"style\", overflowAttribute],\n });\n const resizeObserver = new ResizeObserver(sync);\n resizeObserver.observe(root);\n root.addEventListener(\"focusin\", focusin);\n sync();\n return {\n keydown,\n sync,\n cleanup: () => {\n observer.disconnect();\n resizeObserver.disconnect();\n root.removeEventListener(\"focusin\", focusin);\n },\n };\n};\n\n/**\n * All measurement writes are DOM attributes: reactive writes do not flush during onMount. More is never toggled while\n * measuring: hiding it, even for a moment, can make the browser drop focus from it or from its open menu. An idle More\n * stays out of the flow but keeps its box, so its width is always known.\n */\nconst measureOverflow = (\n root: HTMLDivElement,\n more: HTMLDivElement,\n actions: RegisteredAction[],\n available: number,\n pinned = false,\n): RegisteredAction[] => {\n for (const element of root.querySelectorAll(`[${overflowAttribute}]`)) if (element !== more) reveal(element);\n root.removeAttribute(compactAttribute);\n const children = Array.from(root.children).filter(\n (element): element is HTMLElement => element instanceof HTMLElement && element !== more,\n );\n const visible = (element: Element) => !element.matches(\"[popover]\") && element.getClientRects().length > 0;\n const separator = (element: Element) => element.classList.contains(\"k2b-toolbar__separator\");\n const item = (element: Element) => !separator(element) && !element.classList.contains(\"k2b-toolbar__spacer\");\n // Separators are tidied in DOM order with More, the last control, counted as shown when `withMore` is set.\n const all = Array.from(root.children).filter((element): element is HTMLElement => element instanceof HTMLElement);\n const tidy = (withMore: boolean) => {\n for (const group of root.querySelectorAll(\".k2b-toolbar__group\")) {\n reveal(group);\n if (!Array.from(group.children).some(visible)) hide(group);\n }\n for (const child of children) if (separator(child)) reveal(child);\n const shown = (element: HTMLElement) => (element === more ? withMore : visible(element));\n let preceding = false;\n for (let index = 0; index < all.length; index++) {\n const child = all[index]!;\n if (!shown(child)) continue;\n if (separator(child)) {\n const following = all.slice(index + 1).some((next) => item(next) && shown(next));\n if (!preceding || !following) hide(child);\n else preceding = false;\n } else if (item(child)) preceding = true;\n }\n };\n const style = getComputedStyle(root);\n const edges = [style.paddingLeft, style.paddingRight, style.borderLeftWidth, style.borderRightWidth].reduce(\n (sum, value) => sum + (Number.parseFloat(value) || 0),\n 0,\n );\n const gap = Number.parseFloat(style.columnGap) || 0;\n // A label may shrink in an overfull pill; measure its untruncated width (up to its cap) so actions move before the\n // count or title truncates.\n const width = (child: HTMLElement) => {\n // Separators carry inline margins, which bounding boxes leave out.\n const childStyle = getComputedStyle(child);\n // A spacer takes whatever room is left, so it needs only its minimum.\n if (child.classList.contains(\"k2b-toolbar__spacer\")) return Number.parseFloat(childStyle.minWidth) || 0;\n const box =\n child.getBoundingClientRect().width +\n (Number.parseFloat(childStyle.marginLeft) || 0) +\n (Number.parseFloat(childStyle.marginRight) || 0);\n if (!child.classList.contains(\"k2b-toolbar__label\")) return box;\n // A detail only takes leftover room: the label needs its main text and padding.\n const main = child.querySelector<HTMLElement>(\":scope > .k2b-toolbar__label-main\");\n if (main)\n return (\n main.scrollWidth +\n (Number.parseFloat(childStyle.paddingLeft) || 0) +\n (Number.parseFloat(childStyle.paddingRight) || 0) +\n (Number.parseFloat(childStyle.marginLeft) || 0) +\n (Number.parseFloat(childStyle.marginRight) || 0)\n );\n const cap = Number.parseFloat(childStyle.maxWidth);\n return Math.max(box, Math.min(child.scrollWidth, Number.isNaN(cap) ? Number.POSITIVE_INFINITY : cap));\n };\n const moreWidth = width(more) + gap;\n const used = (withMore: boolean) => {\n const shown = children.filter(visible);\n return shown.reduce((sum, child) => sum + width(child), edges) + gap * Math.max(0, shown.length - 1) + (withMore ? moreWidth : 0);\n };\n // Stable sort retains DOM order for the menu, but removes later actions first on a priority tie.\n const candidates = actions\n // An action its application hides, even with `visibility: hidden`, must not reappear as a More row.\n .filter(\n (action) =>\n action.props.priority !== undefined && visible(action.element) && getComputedStyle(action.element).visibility !== \"hidden\",\n )\n .reverse()\n .sort((a, b) => b.props.priority! - a.props.priority!);\n // With rarer commands of its own, More always shows and always takes its room.\n let movedAny = pinned;\n tidy(pinned);\n // Labels go before actions: a toolbar that does not fit with its labels drops them first.\n if (used(pinned) > available && root.querySelector(\".k2b-toolbar__action[data-text]\")) root.setAttribute(compactAttribute, \"\");\n for (const action of candidates) {\n if (used(movedAny) <= available) break;\n hide(action.element);\n movedAny = true;\n tidy(true);\n }\n // More changes only here, and only when its state changes.\n if (movedAny) reveal(more);\n else if (!more.hasAttribute(overflowAttribute)) hide(more);\n return actions.filter((action) => action.element.hasAttribute(overflowAttribute));\n};\n\nexport const Toolbar = Object.assign(\n (props: ToolbarProps): JSX.Element => {\n // The variant decides the DOM shape, so it is read once.\n const floating = props.variant === \"floating\";\n const danger = () => (floating && props.tone === \"danger\" ? \"danger\" : undefined);\n const orientation = () => (floating ? \"horizontal\" : (props.orientation ?? \"horizontal\"));\n const messages = useToolbarMessages();\n const actions = new Set<RegisteredAction>();\n const [revision, setRevision] = createSignal(0);\n const [moved, setMoved] = createSignal<RegisteredAction[]>([]);\n let root!: HTMLDivElement;\n let strip: HTMLDivElement | undefined;\n let more: HTMLDivElement | undefined;\n let trigger: HTMLButtonElement | undefined;\n let mounted = false;\n let navigation: ReturnType<typeof rovingFocus> | undefined;\n // Only the floating variant moves actions into More; inline toolbars keep every action in place.\n const measure = () => {\n if (!mounted || !strip || !more) return;\n const style = getComputedStyle(strip);\n const available = strip.clientWidth - Number.parseFloat(style.paddingLeft) - Number.parseFloat(style.paddingRight);\n if (available <= 0) return;\n const ordered = [...actions].sort((a, b) =>\n a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n );\n const focused = document.activeElement;\n // Cleared before measuring so the pending `visibility: hidden` does not hide every action from the check\n // below; the whole measurement still runs before the next paint.\n root.removeAttribute(\"data-overflow-pending\");\n const next = measureOverflow(root, more, ordered, available, (props.moreItems?.length ?? 0) > 0);\n setMoved((previous) =>\n previous.length === next.length && previous.every((action, index) => action === next[index]) ? previous : next,\n );\n navigation?.sync();\n // Focus on an action that moved, on a menu row whose action came back, or on a More that disappeared goes to\n // More, or to the toolbar's tab stop when nothing is left in More. Inside an effect the menu rows update after\n // this function returns, so the check waits for that flush; a microtask still runs before the next paint.\n queueMicrotask(() => {\n // A toolbar unmounted meanwhile, as its view closes, owns no focus any more.\n if (!mounted) return;\n const lost =\n next.some((action) => action.element === focused) ||\n (focused instanceof HTMLElement && !focused.isConnected) ||\n (focused === trigger && !next.length);\n if (lost) (next.length ? trigger : root.querySelector<HTMLElement>('[tabindex=\"0\"]'))?.focus();\n });\n };\n const register = (action: RegisteredAction) => {\n actions.add(action);\n setRevision((value) => value + 1);\n return () => {\n actions.delete(action);\n setRevision((value) => value + 1);\n };\n };\n if (floating)\n createEffect(() => {\n revision();\n for (const action of actions) {\n // Content and priority changes can affect intrinsic widths as well as menu rows.\n void action.props.priority;\n void action.props.label;\n void action.props.icon;\n void action.props.keys;\n void action.props.text;\n }\n measure();\n });\n onMount(() => {\n mounted = true;\n navigation = rovingFocus(root, orientation);\n onCleanup(() => {\n mounted = false;\n navigation?.cleanup();\n });\n if (!strip) return;\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(strip);\n observer.observe(root);\n const mutations = new MutationObserver(measure);\n // Visibility an application sets also counts. Measurement writes only data attributes, which stay unobserved.\n mutations.observe(root, {\n childList: true,\n subtree: true,\n characterData: true,\n attributes: true,\n attributeFilter: [\"hidden\", \"class\", \"style\"],\n });\n onCleanup(() => {\n observer.disconnect();\n mutations.disconnect();\n });\n });\n // Actions that moved come first, in their order and in a group of their own; the host's rarer commands follow.\n const menuItems = (): DropdownItem[] => {\n const movedItems = moved().map((action) => action.item);\n const pinnedItems = props.moreItems ?? [];\n if (!pinnedItems.length) return movedItems;\n return movedItems.length ? [{ items: movedItems }, ...pinnedItems] : [...pinnedItems];\n };\n const content = (\n <ToolbarOrientationContext.Provider value={orientation}>\n <ToolbarDangerContext.Provider value={!!danger()}>\n <ToolbarActionsContext.Provider value={floating ? register : undefined}>\n <div\n ref={root}\n onKeyDown={(event) => navigation?.keydown(event)}\n class={`k2b-toolbar ${props.class ?? \"\"}`}\n role=\"toolbar\"\n aria-label={props.label}\n aria-orientation={orientation()}\n data-orientation={orientation()}\n data-variant={floating ? \"floating\" : undefined}\n data-tone={danger()}\n data-wrap={!floating && props.wrap ? \"true\" : undefined}\n data-overflow-pending={floating ? \"\" : undefined}\n >\n {props.children}\n <Show when={floating}>\n <div ref={more} class=\"k2b-toolbar__more\" data-overflow=\"hidden\">\n <Dropdown.Root\n items={menuItems()}\n position=\"top-left\"\n label={messages().moreActions}\n // An open menu closes when its last row returns to the toolbar.\n disabled={moved().length === 0 && !props.moreItems?.length}\n >\n <Dropdown.Trigger ref={trigger} iconOnly label={messages().moreActions}>\n <i class=\"ti ti-dots\" aria-hidden=\"true\" />\n </Dropdown.Trigger>\n </Dropdown.Root>\n </div>\n </Show>\n </div>\n </ToolbarActionsContext.Provider>\n </ToolbarDangerContext.Provider>\n </ToolbarOrientationContext.Provider>\n );\n return floating ? (\n <div ref={strip} class=\"k2b-toolbar-float\" data-edge={props.edge === \"top\" ? \"top\" : undefined} data-tone={danger()}>\n {content}\n </div>\n ) : (\n content\n );\n },\n { Action: ToolbarAction, Label: ToolbarLabel, Group: ToolbarGroup, Separator: ToolbarSeparator, Spacer: ToolbarSpacer },\n) as ToolbarComponent;\n\nexport type ToolbarDockProps = { children: JSX.Element; class?: string };\n\n/**\n * One floating row at the bottom of a column for several floating toolbars: the first sits at the start edge, the last\n * at the end edge, and each moves its own actions into More when the row gets narrow. Content scrolls beneath the row\n * and still ends above it.\n */\nexport const ToolbarDock = (props: ToolbarDockProps): JSX.Element => (\n <div class={props.class ? `k2b-toolbar-dock ${props.class}` : \"k2b-toolbar-dock\"}>{props.children}</div>\n);\n\nexport default Toolbar;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa,EAAE,YAAY,EAAE,YAAY,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,QAAQ,UAAU;AAClI,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,GAAG,QAAQ,gBAAgB;AACpC,SAAS,QAAQ,QAAQ,sBAAsB;AAC/C,SAAS,SAAS,QAAQ,gBAAgB;AAC1C,SAAS,cAAc,EAAyB,gBAAgB,QAAQ,kBAAkB;AAC1F,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,QAAQ,QAAgD,YAAY;AAC7E,SAAS,kBAAkB,QAAQ,oBAAoB;AAsEvD,MAAM,yBAAmD,GAAG,MAAM,YAAY;AAC9E,MAAM,yBAAyB,GAAG,aAAa,CAAC,yBAAyB,CAAC;AAC1E;AACA,MAAM,oBAAoB,GAAG,aAAa,CAAC,KAAK,CAAC;AACjD;AACA,OAAO,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAAC;;AAEtD;;AAEA,MAAM,qBAAqB,GAAG,aAAa,CAA2C,CAAC;AACvF,MAAM,iBAAiB,GAAG,eAAe;AACzC;AACA,MAAM,gBAAgB,GAAG,cAAc;AACvC,MAAM,IAAI,GAAI,OAAgB,IAAK,OAAO,CAAC,YAAY,CAAC,iBAAiB,EAAE,QAAQ,CAAC;AACpF,MAAM,MAAM,GAAI,OAAgB,IAAK,OAAO,C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;0BAAA;wBAAA;sBAAA;oBAAA;kBAAA;kBAAA;gBAAA;cAAA;cAAA;gBAAA,WApBrE,eAAe,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE;kBAAA,OAE7B,KAAK,CAAC,KAAK;kBAAA,OACL,WAAW,CAAC,CAAC;kBAAA,OACb,WAAW,CAAC,CAAC;kBAAA,QAEpB,MAAM,CAAC,CAAC;kBAAA,QACR,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS;gBAAA;gBAAA;gBAAA;gBAAA;gBAAA;gBAAA;gBAAA;cAAA;gBAAA;gBAAA;gBAAA;gBAAA;gBAAA;gBAAA;cAAA;cAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA,EAuBhE;EACD,OAAO,QAAQ;IAAA;IAAA,aACH,KAAK;IAAA,uDAAL,KAAK;IAAA,iBACZ,OAAO;IAAA;MAAA,YAD4C,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG,KAAK,GAAG,SAAS;QAAA,QAAa,MAAM,CAAC,CAAC;MAAA;MAAA;MAAA;IAAA;MAAA;MAAA;IAAA;IAAA;EAAA,OAInH,OACD;AACH,CAAC,EACD;EAAE,MAAM,EAAE,aAAa;EAAE,KAAK,EAAE,YAAY;EAAE,KAAK,EAAE,YAAY;EAAE,SAAS,EAAE,gBAAgB;EAAE,MAAM,EAAE;AAAc,CACxH,CAAqB;AAIrB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,WAAW,GAAI,KAAuB;EAAA;EAAA,uBACkC,KAAK,CAAC,QAAQ;EAAA,mCAArF,KAAK,CAAC,KAAK,GAAG,oBAAoB,KAAK,CAAC,KAAK,EAAE,GAAG,kBAAkB;EAAA;AAAA,IACjF;AAED,eAAe,OAAO;AAAC","ignoreList":[]}
@@ -182,6 +182,8 @@ const swallowTap = down => {
182
182
  const attachmentIcon = attachment => attachment.icon ?? (attachment.kind === "image" ? "ti ti-photo" : attachment.kind === "resource" ? "ti ti-link" : "ti ti-file");
183
183
  const hasContent = items => items.some(item => item != null && typeof item !== "boolean" && item !== "");
184
184
  export function ChatComposer(props) {
185
+ // A parent that recomputes the same key keeps the same draft: only a new value resets what belongs to the old one.
186
+ const draftKey = createMemo(() => props.draftKey);
185
187
  const accessory = children(() => props.accessory);
186
188
  const hasAccessory = () => hasContent(accessory.toArray());
187
189
  const hint = children(() => props.hint);
@@ -378,13 +380,13 @@ export function ChatComposer(props) {
378
380
  });
379
381
  const openingStart = createMemo(() => commandQuery()?.start);
380
382
  createEffect(() => {
381
- props.draftKey;
383
+ draftKey();
382
384
  const start = openingStart();
383
385
  if (start !== undefined) setCommandOpening(opening => opening + 1);
384
386
  });
385
387
  // A failed `open` row says so for the rest of its list opening.
386
388
  createEffect(() => {
387
- props.draftKey;
389
+ draftKey();
388
390
  commandOpening();
389
391
  setOpenFailures({});
390
392
  });
@@ -406,7 +408,7 @@ export function ChatComposer(props) {
406
408
  // Rows of a `fixedWhileOpen` section are the ones it had when this `/` opened the list; later ones wait for the next
407
409
  // `/`. A retry row starts another opening in the same open list, so it does not count.
408
410
  const fixedCommandKeys = createMemo(() => {
409
- props.draftKey;
411
+ draftKey();
410
412
  if (openingStart() === undefined) return undefined;
411
413
  return untrack(() => {
412
414
  const fixed = new Set((props.commandSections ?? []).filter(section => section.fixedWhileOpen).map(section => section.id));
@@ -441,7 +443,7 @@ export function ChatComposer(props) {
441
443
  const currentCommandQuery = createMemo(() => caretCommandToken()?.query);
442
444
  // Arrow marking belongs to one token in one draft; another draft or `/` starts at the top row again.
443
445
  createEffect(() => {
444
- props.draftKey;
446
+ draftKey();
445
447
  caretCommandStart();
446
448
  currentCommandQuery();
447
449
  setCommandMoved(false);
@@ -490,15 +492,15 @@ export function ChatComposer(props) {
490
492
  // cancels too, unless the opener announced that next move with `follow()`: its busy line moves to the status line,
491
493
  // and Escape still cancels there. Any later unannounced draft change cancels.
492
494
  createEffect(() => {
493
- const draftKey = props.draftKey;
495
+ const key = draftKey();
494
496
  const open = commandsOpen();
495
497
  const row = openingRow();
496
498
  const run = openingRun;
497
499
  if (!run || row === undefined) return;
498
- if (draftKey !== run.key) {
500
+ if (key !== run.key) {
499
501
  if (run.follow) {
500
502
  run.follow = false;
501
- run.key = draftKey;
503
+ run.key = key;
502
504
  run.moved = true;
503
505
  showCommandStatus({
504
506
  tone: "busy",
@@ -608,7 +610,7 @@ export function ChatComposer(props) {
608
610
  onCleanup(() => window.removeEventListener("pointerdown", onPointerDown, true));
609
611
  });
610
612
  createEffect(() => {
611
- props.draftKey;
613
+ draftKey();
612
614
  const token = commandQuery();
613
615
  setSearchError(false);
614
616
  if (!token || !props.searchCommands) {
@@ -699,7 +701,7 @@ export function ChatComposer(props) {
699
701
  const history = [];
700
702
  let historyIndex = -1;
701
703
  createEffect(() => {
702
- props.draftKey;
704
+ draftKey();
703
705
  untrack(() => {
704
706
  history.length = 0;
705
707
  historyIndex = -1;
@@ -946,8 +948,7 @@ export function ChatComposer(props) {
946
948
  // drops the source ends it; the words so far stay.
947
949
  // Memos compare values, so typing and arriving words never end it.
948
950
  const dictationField = createMemo(() => `${Boolean(props.dictation)}:${editBlocked()}`);
949
- const dictationDraft = createMemo(() => props.draftKey);
950
- createEffect(on([dictationField, dictationDraft], () => liveDictation.end(), {
951
+ createEffect(on([dictationField, draftKey], () => liveDictation.end(), {
951
952
  defer: true
952
953
  }));
953
954
  const hasDraft = () => Boolean(props.value.trim() || !running() && attachments().length > 0);
@@ -1112,7 +1113,7 @@ export function ChatComposer(props) {
1112
1113
  */
1113
1114
  const attachFilesFromCommand = (token, selection) => {
1114
1115
  if (!canSelectFiles()) return;
1115
- const key = props.draftKey;
1116
+ const key = draftKey();
1116
1117
  const previous = snapshot();
1117
1118
  const previousHistory = {
1118
1119
  entries: [...history],
@@ -1122,7 +1123,7 @@ export function ChatComposer(props) {
1122
1123
  edit(nextValue, reconcileChatMentions(props.value, nextValue, mentions()));
1123
1124
  setDismissed(true);
1124
1125
  chooseFiles(() => {
1125
- if (props.draftKey !== key || props.value !== nextValue) return;
1126
+ if (draftKey() !== key || props.value !== nextValue) return;
1126
1127
  setDismissed(true);
1127
1128
  props.onValueChange(previous.value);
1128
1129
  props.onMentionsChange?.(previous.mentions);
@@ -1135,7 +1136,7 @@ export function ChatComposer(props) {
1135
1136
  });
1136
1137
  });
1137
1138
  queueMicrotask(() => {
1138
- if (props.draftKey !== key || props.value !== nextValue) return;
1139
+ if (draftKey() !== key || props.value !== nextValue) return;
1139
1140
  textareaRef?.setSelectionRange(token.start, token.start);
1140
1141
  syncCaret();
1141
1142
  });
@@ -1157,7 +1158,7 @@ export function ChatComposer(props) {
1157
1158
  };
1158
1159
  const submit = async () => {
1159
1160
  if (!canSubmit()) return;
1160
- const key = props.draftKey;
1161
+ const key = draftKey();
1161
1162
  setSubmitting(true);
1162
1163
  try {
1163
1164
  if (isTouchOnly()) {
@@ -1165,7 +1166,7 @@ export function ChatComposer(props) {
1165
1166
  // The sheet's Back entry leaves first, so a submit handler that navigates finds the history settled.
1166
1167
  await dialogHistorySettled();
1167
1168
  // A draft that another one replaced, or that may no longer go out, is not sent and keeps its text.
1168
- if (disposed || props.draftKey !== key || !submittable()) return;
1169
+ if (disposed || draftKey() !== key || !submittable()) return;
1169
1170
  }
1170
1171
  const intent = running() ? runningSubmitIntent() : "send";
1171
1172
  const previousValue = props.value;
@@ -1256,7 +1257,7 @@ export function ChatComposer(props) {
1256
1257
  // From "+" a reference joins the text at the caret, apart from a word right before it.
1257
1258
  const lead = value => fromAdd && token.start > 0 && !/\s/.test(value[token.start - 1] ?? "") ? " " : "";
1258
1259
  const previous = snapshot();
1259
- const key = props.draftKey;
1260
+ const key = draftKey();
1260
1261
  const replacement = command.mention ? lead(props.value) + command.mention.name + " " : "";
1261
1262
  const nextValue = props.value.slice(0, token.start) + replacement + props.value.slice(token.end);
1262
1263
  const nextMentions = reconcileChatMentions(props.value, nextValue, mentions());
@@ -1280,7 +1281,7 @@ export function ChatComposer(props) {
1280
1281
  let restored = false;
1281
1282
  let mentioned;
1282
1283
  const restore = () => {
1283
- if (props.draftKey !== key || props.value !== nextValue) return;
1284
+ if (draftKey() !== key || props.value !== nextValue) return;
1284
1285
  setDismissed(true);
1285
1286
  props.onValueChange(previous.value);
1286
1287
  props.onMentionsChange?.(previous.mentions);
@@ -1297,7 +1298,7 @@ export function ChatComposer(props) {
1297
1298
  if (heldHistory && command.action) {
1298
1299
  await dialogHistorySettled();
1299
1300
  // Another draft or no composer any more: the command does not run against it.
1300
- if (disposed || props.draftKey !== key) return;
1301
+ if (disposed || draftKey() !== key) return;
1301
1302
  }
1302
1303
  const result = await command.action?.({
1303
1304
  setValue: value => edit(value),
@@ -1313,7 +1314,7 @@ export function ChatComposer(props) {
1313
1314
  showCommandStatus();
1314
1315
  } else if (result && "mention" in result) {
1315
1316
  // One undo step from the token to the reference, as if the row had been a reference itself.
1316
- if (props.draftKey === key && props.value === nextValue) {
1317
+ if (draftKey() === key && props.value === nextValue) {
1317
1318
  restore();
1318
1319
  restored = false;
1319
1320
  const name = result.mention.name;
@@ -1356,9 +1357,9 @@ export function ChatComposer(props) {
1356
1357
  if (commandStatus()?.tone === "busy") showCommandStatus();
1357
1358
  setExecuting(false);
1358
1359
  }
1359
- if (submitRequested && props.draftKey === key) await submit();
1360
+ if (submitRequested && draftKey() === key) await submit();
1360
1361
  queueMicrotask(() => {
1361
- if (props.draftKey !== key) return;
1362
+ if (draftKey() !== key) return;
1362
1363
  if (restored || props.value === nextValue || mentioned && props.value === mentioned.value) {
1363
1364
  const position = restored ? token.end : mentioned?.caret ?? token.start + replacement.length;
1364
1365
  textareaRef?.setSelectionRange(restored && addSelection ? addSelection.start : position, restored && addSelection ? addSelection.end : position);
@@ -1374,13 +1375,13 @@ export function ChatComposer(props) {
1374
1375
  * stays in the row while the list is still there, otherwise the status line says it, so it never ends in silence.
1375
1376
  */
1376
1377
  const openFromCommand = async (command, open, token) => {
1377
- const key = props.draftKey;
1378
+ const key = draftKey();
1378
1379
  const row = chatCommandKey(command);
1379
1380
  const value = props.value;
1380
1381
  const nextValue = value.slice(0, token.start) + value.slice(token.end);
1381
1382
  const nextMentions = reconcileChatMentions(value, nextValue, mentions());
1382
1383
  // Still the same draft and `/…`, so the row is where the person chose it.
1383
- const inPlace = () => !disposed && props.draftKey === key && props.value === value && commandQuery()?.start === token.start;
1384
+ const inPlace = () => !disposed && draftKey() === key && props.value === value && commandQuery()?.start === token.start;
1384
1385
  const heldHistory = commandSheetHeld();
1385
1386
  // Closing the list or leaving the composer cancels the opening; the row ends at once, without waiting for it.
1386
1387
  const controller = new AbortController();
@@ -1442,15 +1443,15 @@ export function ChatComposer(props) {
1442
1443
  // Success: the token leaves and the list closes in the same step that ends the opening, so a phone sheet never
1443
1444
  // takes its Back entry again while the page navigates.
1444
1445
  batch(() => {
1445
- if (!disposed && props.draftKey === key && props.value === value) {
1446
+ if (!disposed && draftKey() === key && props.value === value) {
1446
1447
  edit(nextValue, nextMentions);
1447
1448
  setDismissed(true);
1448
1449
  }
1449
- endAddSearch(!disposed && props.draftKey === key);
1450
+ endAddSearch(!disposed && draftKey() === key);
1450
1451
  finish(true);
1451
1452
  });
1452
1453
  queueMicrotask(() => {
1453
- if (disposed || props.draftKey !== key || props.value !== nextValue) return;
1454
+ if (disposed || draftKey() !== key || props.value !== nextValue) return;
1454
1455
  textareaRef?.setSelectionRange(token.start, token.start);
1455
1456
  syncCaret();
1456
1457
  autoResize();