@k2b/ui 0.46.0 → 0.47.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 (54) hide show
  1. package/dist/browser/chat/ChatDecision.js +10 -6
  2. package/dist/browser/chat/ChatDecision.js.map +1 -1
  3. package/dist/browser/content/VirtualFeed.js +26 -21
  4. package/dist/browser/content/VirtualFeed.js.map +1 -1
  5. package/dist/browser/inputs/Combobox.js +14 -6
  6. package/dist/browser/inputs/Combobox.js.map +1 -1
  7. package/dist/browser/layout/AnchoredPopover.js +2 -1
  8. package/dist/browser/layout/AnchoredPopover.js.map +1 -1
  9. package/dist/browser/layout/AppWorkspace.js +340 -440
  10. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  11. package/dist/browser/layout/AppWorkspaceSidebarItemStatus.js +113 -0
  12. package/dist/browser/layout/AppWorkspaceSidebarItemStatus.js.map +1 -0
  13. package/dist/browser/layout/DetailPanel.js +1 -1
  14. package/dist/browser/layout/DetailPanel.js.map +1 -1
  15. package/dist/browser/layout/DetailSections.js +236 -132
  16. package/dist/browser/layout/DetailSections.js.map +1 -1
  17. package/dist/browser/layout/MobileShell.js +30 -13
  18. package/dist/browser/layout/MobileShell.js.map +1 -1
  19. package/dist/browser/layout/detail-sections-messages.js +4 -0
  20. package/dist/browser/layout/detail-sections-messages.js.map +1 -1
  21. package/dist/browser/layout/index.js +1 -0
  22. package/dist/browser/layout/index.js.map +1 -1
  23. package/dist/ssr/chat/ChatDecision.js +10 -6
  24. package/dist/ssr/chat/ChatDecision.js.map +1 -1
  25. package/dist/ssr/content/VirtualFeed.js +26 -21
  26. package/dist/ssr/content/VirtualFeed.js.map +1 -1
  27. package/dist/ssr/inputs/Combobox.js +6 -3
  28. package/dist/ssr/inputs/Combobox.js.map +1 -1
  29. package/dist/ssr/layout/AnchoredPopover.js +2 -1
  30. package/dist/ssr/layout/AnchoredPopover.js.map +1 -1
  31. package/dist/ssr/layout/AppWorkspace.js +61 -127
  32. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  33. package/dist/ssr/layout/AppWorkspaceSidebarItemStatus.js +76 -0
  34. package/dist/ssr/layout/AppWorkspaceSidebarItemStatus.js.map +1 -0
  35. package/dist/ssr/layout/DetailPanel.js +1 -1
  36. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  37. package/dist/ssr/layout/DetailSections.js +126 -50
  38. package/dist/ssr/layout/DetailSections.js.map +1 -1
  39. package/dist/ssr/layout/MobileShell.js +16 -2
  40. package/dist/ssr/layout/MobileShell.js.map +1 -1
  41. package/dist/ssr/layout/detail-sections-messages.js +4 -0
  42. package/dist/ssr/layout/detail-sections-messages.js.map +1 -1
  43. package/dist/ssr/layout/index.js +1 -0
  44. package/dist/ssr/layout/index.js.map +1 -1
  45. package/dist/styles.css +1 -1
  46. package/dist/types/chat/ChatDecision.d.ts +5 -0
  47. package/dist/types/inputs/Combobox.d.ts +2 -0
  48. package/dist/types/layout/AppWorkspace.d.ts +2 -28
  49. package/dist/types/layout/AppWorkspaceSidebarItemStatus.d.ts +30 -0
  50. package/dist/types/layout/DetailSections.d.ts +32 -2
  51. package/dist/types/layout/MobileShell.d.ts +12 -0
  52. package/dist/types/layout/detail-sections-messages.d.ts +2 -0
  53. package/dist/types/layout/index.d.ts +1 -0
  54. package/package.json +1 -1
@@ -84,7 +84,8 @@ export function ChatDecision(props) {
84
84
  };
85
85
 
86
86
  // Read once: an object literal from the host builds its JSX again on every read.
87
- const reason = createMemo(() => props.unavailable ?? props.reason);
87
+ const reason = createMemo(() => props.waiting ?? props.unavailable ?? props.reason);
88
+ const confirmOff = () => Boolean(props.waiting ?? props.unavailable);
88
89
  const open = () => props.state === "open";
89
90
  const answer = (choice, enabled) => {
90
91
  if (!enabled || !open() || answeredHere()) return;
@@ -142,9 +143,9 @@ export function ChatDecision(props) {
142
143
  return props.confirm.variant ?? "ai";
143
144
  },
144
145
  get disabled() {
145
- return Boolean(props.unavailable);
146
+ return confirmOff();
146
147
  },
147
- onClick: () => answer(props.confirm, !props.unavailable),
148
+ onClick: () => answer(props.confirm, !confirmOff()),
148
149
  get children() {
149
150
  return [_$createComponent(Show, {
150
151
  get when() {
@@ -157,7 +158,10 @@ export function ChatDecision(props) {
157
158
  "class": "k2b-chat-decision__answer",
158
159
  wrap: true,
159
160
  variant: "subtle",
160
- onClick: () => answer(props.decline, true),
161
+ get disabled() {
162
+ return Boolean(props.waiting);
163
+ },
164
+ onClick: () => answer(props.decline, !props.waiting),
161
165
  get children() {
162
166
  return [_$createComponent(Show, {
163
167
  get when() {
@@ -175,9 +179,9 @@ export function ChatDecision(props) {
175
179
  wrap: true,
176
180
  variant: "text",
177
181
  get disabled() {
178
- return Boolean(props.unavailable);
182
+ return confirmOff();
179
183
  },
180
- onClick: () => answer(remember(), !props.unavailable),
184
+ onClick: () => answer(remember(), !confirmOff()),
181
185
  get children() {
182
186
  return remember().label;
183
187
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["chat/ChatDecision.tsx"],"sourcesContent":["import {\n createContext,\n createEffect,\n createMemo,\n createSignal,\n createUniqueId,\n For,\n type JSX,\n on,\n onCleanup,\n onMount,\n Show,\n untrack,\n useContext,\n} from \"solid-js\";\nimport { Button } from \"../actions/Button\";\nimport { Avatar } from \"../surfaces/Avatar\";\nimport { useChatMessages } from \"./chat-messages\";\nimport type {\n ChatDecisionAnswer,\n ChatDecisionReason,\n ChatDecisionState,\n ChatOutcomeLine,\n ChatOutcomeTone,\n ChatPreviewHeaderRow,\n ChatPreviewPerson,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Decision\n// ---------------------------------------------------------------------------\n\nexport type ChatDecisionProps = {\n /** `open` shows the question; every other state shows `outcome` in its place. */\n state: ChatDecisionState;\n /** The question as one sentence, usually with `ReferenceChip`s. */\n sentence: JSX.Element;\n /** Why this question is asked, in the platform's words. */\n reason: ChatDecisionReason;\n /** The thing itself, usually `Chat.Preview`. */\n preview?: JSX.Element;\n /** The main answer, named by verb and target (\"Send to Lea\"). `danger` for deletions, `primary` for requests. */\n confirm: ChatDecisionAnswer & { variant?: \"ai\" | \"primary\" | \"danger\" };\n /** The other answer (\"Don't send\"). */\n decline: ChatDecisionAnswer;\n /** An optional quiet third answer after the buttons, such as \"Yes, and don't ask again in this chat\". */\n remember?: ChatDecisionAnswer;\n /** Turns `confirm` and `remember` off; this reason replaces `reason` in the same place. */\n unavailable?: ChatDecisionReason;\n /** The result line shown in every state but `open`, usually `Chat.Outcome`. */\n outcome?: JSX.Element;\n /** Receives a rejected promise from an answer's `onSelect`. */\n onAnswerError?: (error: unknown) => void;\n anchorId?: string | number;\n class?: string;\n};\n\n/** What an outcome inside a question needs from it: whether it was just answered here, and a link press inside it. */\nconst DecisionScope = createContext<{ answered: () => boolean; pressed: () => void; released: () => void }>();\n\nconst reasonIcon = (reason: ChatDecisionReason) => reason.icon ?? \"ti ti-info-circle\";\n\n/**\n * A question the person answers in the conversation: one sentence, why it is asked, the thing itself, and two answers.\n * An answer collapses it at once to its outcome line, which takes the focus and is announced.\n */\nexport function ChatDecision(props: ChatDecisionProps): JSX.Element {\n const id = createUniqueId();\n const sentenceId = `k2b-chat-decision-${id}-sentence`;\n const reasonId = `k2b-chat-decision-${id}-reason`;\n let root: HTMLDivElement | undefined;\n let sentence: HTMLParagraphElement | undefined;\n // An answer given here moves the focus to the outcome; a click in the outcome that reopens the question moves it\n // back to the sentence. A state change from elsewhere moves no focus.\n const [answeredHere, setAnsweredHere] = createSignal(false);\n const [arrive, setArrive] = createSignal(false);\n let reopenedHere = false;\n // A press on the sentence focuses it too; only a focus moved there from elsewhere, such as a jump, lights it up.\n // The browser also focuses the sentence again when its window comes back; that is no arrival either.\n let sentencePressed = false;\n let sentenceHeldAcrossWindow = false;\n const windowLeft = () => {\n if (sentence && document.activeElement === sentence) sentenceHeldAcrossWindow = true;\n };\n onMount(() => {\n window.addEventListener(\"blur\", windowLeft);\n onCleanup(() => window.removeEventListener(\"blur\", windowLeft));\n });\n // A press counts only while its action runs: a reopen from elsewhere later must not take the focus.\n const scope = {\n answered: answeredHere,\n pressed: () => {\n reopenedHere = true;\n },\n released: () => {\n reopenedHere = false;\n },\n };\n\n // Read once: an object literal from the host builds its JSX again on every read.\n const reason = createMemo(() => props.unavailable ?? props.reason);\n const open = () => props.state === \"open\";\n\n const answer = (choice: ChatDecisionAnswer, enabled: boolean) => {\n if (!enabled || !open() || answeredHere()) return;\n setAnsweredHere(true);\n try {\n const result = choice.onSelect();\n if (result instanceof Promise) result.catch((error: unknown) => props.onAnswerError?.(error));\n } catch (error) {\n props.onAnswerError?.(error);\n }\n // A host that keeps the question open (it could not take the answer) gets working buttons back.\n queueMicrotask(() => {\n if (open()) setAnsweredHere(false);\n });\n };\n\n createEffect(\n on(\n () => props.state,\n (state, previous) => {\n if (state !== \"open\" && previous === \"open\" && answeredHere()) {\n root?.querySelector<HTMLElement>(\".k2b-chat-outcome\")?.focus({ preventScroll: true });\n }\n if (state === \"open\" && previous !== undefined && previous !== \"open\") {\n // A host that could not take an answer given here returns the question from `sending`; the outcome that held\n // the focus is gone, so the focus goes back to the sentence instead of the page.\n const active = document.activeElement;\n const failedHere = answeredHere() && previous === \"sending\" && (!active || active === document.body);\n setAnsweredHere(false);\n if (reopenedHere || failedHere) {\n sentence?.focus({ preventScroll: true });\n setArrive(true);\n }\n // Handled. Until then the marker holds through states in between, such as `sending` while a reopen loads.\n reopenedHere = false;\n }\n },\n ),\n );\n\n return (\n <div\n ref={root}\n class={`k2b-chat-decision ${props.class ?? \"\"}`}\n data-state={props.state}\n data-chat-anchor={props.anchorId !== undefined ? String(props.anchorId) : undefined}\n >\n <Show when={open()} fallback={<DecisionScope.Provider value={scope}>{props.outcome}</DecisionScope.Provider>}>\n <section class=\"k2b-chat-decision__card\" aria-labelledby={sentenceId} aria-describedby={reasonId}>\n <p\n ref={sentence}\n id={sentenceId}\n class=\"k2b-chat-decision__sentence\"\n tabindex=\"-1\"\n data-arrive={arrive() ? \"true\" : undefined}\n onPointerDown={() => {\n sentencePressed = true;\n }}\n onPointerUp={() => {\n sentencePressed = false;\n }}\n onPointerCancel={() => {\n sentencePressed = false;\n }}\n onFocus={() => {\n if (!sentencePressed && !sentenceHeldAcrossWindow) setArrive(true);\n sentencePressed = false;\n sentenceHeldAcrossWindow = false;\n }}\n onAnimationEnd={() => setArrive(false)}\n >\n {props.sentence}\n </p>\n <p id={reasonId} class=\"k2b-chat-line k2b-chat-decision__reason\" data-tone={reason().tone ?? \"neutral\"}>\n <i class={`k2b-chat-line__icon ${reasonIcon(reason())}`} aria-hidden=\"true\" />\n <span class=\"k2b-chat-line__text\">{reason().text}</span>\n </p>\n {props.preview}\n <div class=\"k2b-chat-decision__answers\">\n <Button\n class=\"k2b-chat-decision__answer\"\n wrap\n variant={props.confirm.variant ?? \"ai\"}\n disabled={Boolean(props.unavailable)}\n onClick={() => answer(props.confirm, !props.unavailable)}\n >\n <Show when={props.confirm.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n {props.confirm.label}\n </Button>\n <Button class=\"k2b-chat-decision__answer\" wrap variant=\"subtle\" onClick={() => answer(props.decline, true)}>\n <Show when={props.decline.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n {props.decline.label}\n </Button>\n <Show when={props.remember}>\n {(remember) => (\n <Button\n class=\"k2b-chat-decision__remember\"\n wrap\n variant=\"text\"\n disabled={Boolean(props.unavailable)}\n onClick={() => answer(remember(), !props.unavailable)}\n >\n {remember().label}\n </Button>\n )}\n </Show>\n </div>\n </section>\n </Show>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Outcome\n// ---------------------------------------------------------------------------\n\nexport type ChatOutcomeProps = {\n /**\n * Every line one flow can show, such as running and done. All of them share one cell, so the line is as high as\n * the longest and switching between them moves nothing.\n */\n lines: Readonly<Record<string, ChatOutcomeLine>>;\n /** The key of the visible line. */\n current: string;\n /** Receives an error thrown or rejected by a line's `action`. */\n onActionError?: (error: unknown) => void;\n anchorId?: string | number;\n class?: string;\n};\n\nconst OUTCOME_ICONS: Record<ChatOutcomeTone, string> = {\n running: \"ti ti-loader-2 k2b-spin\",\n done: \"ti ti-check\",\n off: \"ti ti-circle-off\",\n waiting: \"ti ti-clock\",\n warning: \"ti ti-alert-triangle\",\n error: \"ti ti-alert-circle\",\n};\n\n/** The visible words of a line, without what screen readers do not hear. */\nconst spokenText = (element: Element): string => {\n const copy = element.cloneNode(true) as Element;\n // Buttons under the line are controls, not part of what happened.\n for (const hidden of copy.querySelectorAll('[aria-hidden=\"true\"], .k2b-chat-outcome__actions')) hidden.remove();\n // The time and the link stand apart by margin only; spoken, they need a space.\n for (const part of copy.querySelectorAll(\".k2b-chat-outcome__time, .k2b-chat-outcome__link\")) part.before(\" \");\n return (copy.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * One line that says what happened: running, done, off, waiting, warning, or error. Changes are announced through a\n * polite live region; the line itself can take the focus.\n */\nexport function ChatOutcome(props: ChatOutcomeProps): JSX.Element {\n const scope = useContext(DecisionScope);\n // Only a line that replaces a question just answered here fades in; history renders final.\n const entering = untrack(() => scope?.answered() ?? false);\n const [live, setLive] = createSignal(\"\");\n let root: HTMLDivElement | undefined;\n let cell: HTMLDivElement | undefined;\n let pending = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n // Read once: an object literal from the host builds its JSX again on every read.\n const lines = createMemo(() => props.lines);\n const line = () => lines()[props.current];\n const tone = () => line()?.tone ?? \"off\";\n const keys = () => {\n const all = Object.keys(lines());\n return all.includes(props.current) ? all : [props.current, ...all];\n };\n\n // Empty the region first, so the same words spoken again are a change too.\n const announce = () => {\n setLive(\"\");\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => {\n const current = cell?.querySelector('[data-current=\"true\"]');\n setLive(current ? spokenText(current) : \"\");\n }, 40);\n };\n\n onMount(() => {\n if (untrack(() => scope?.answered())) announce();\n });\n createEffect(\n on(\n () => props.current,\n () => {\n // A link pressed in a line that is now hidden would leave the focus on an invisible button, which the browser\n // then drops to the page. The line itself keeps it instead.\n const active = document.activeElement;\n const hidden = active && cell?.contains(active) && !active.closest('[data-current=\"true\"]');\n if (hidden || (pending && active === document.body)) root?.focus({ preventScroll: true });\n announce();\n },\n { defer: true },\n ),\n );\n onCleanup(() => {\n if (timer) clearTimeout(timer);\n });\n\n return (\n <div\n ref={root}\n class={`k2b-chat-outcome ${props.class ?? \"\"}`}\n data-tone={tone()}\n data-chat-anchor={props.anchorId !== undefined ? String(props.anchorId) : undefined}\n data-enter={entering ? \"true\" : undefined}\n tabindex=\"-1\"\n >\n <span class=\"k2b-chat-outcome__icon\" aria-hidden=\"true\">\n <i class={line()?.icon ?? OUTCOME_ICONS[tone()]} />\n </span>\n {/* Busy is set on the words only: a live region inside a busy subtree would be held back. */}\n <div ref={cell} class=\"k2b-chat-outcome__cell\" aria-busy={tone() === \"running\" ? \"true\" : undefined}>\n <For each={keys()}>\n {(key) => {\n const entry = () => lines()[key];\n const current = () => key === props.current;\n return (\n <Show when={entry()}>\n {(item) => (\n <div\n class=\"k2b-chat-outcome__text\"\n data-current={current() ? \"true\" : undefined}\n aria-hidden={current() ? undefined : \"true\"}\n >\n {item().text}\n <Show when={item().detail}>\n {(detail) => (\n <>\n {\" \"}\n <span class=\"k2b-chat-outcome__detail\">{detail()}</span>\n </>\n )}\n </Show>\n <Show when={item().time}>{(time) => <span class=\"k2b-chat-outcome__time\">{time()}</span>}</Show>\n <Show when={item().action}>\n {(action) => (\n <Button\n class=\"k2b-chat-outcome__link\"\n wrap\n variant=\"text\"\n tabIndex={current() ? undefined : -1}\n onClick={() => {\n // A second press while the first is still running would repeat its work.\n if (pending) return;\n scope?.pressed();\n try {\n const result = action().onSelect();\n if (result instanceof Promise) {\n pending = true;\n result\n .catch((error: unknown) => props.onActionError?.(error))\n .finally(() => {\n pending = false;\n scope?.released();\n });\n return;\n }\n } catch (error) {\n props.onActionError?.(error);\n }\n scope?.released();\n }}\n >\n {action().label}\n </Button>\n )}\n </Show>\n {/* Every line keeps its buttons, hidden with its text, so the cell also reserves their row. */}\n <Show when={item().actions}>{(actions) => <div class=\"k2b-chat-outcome__actions\">{actions()}</div>}</Show>\n </div>\n )}\n </Show>\n );\n }}\n </For>\n </div>\n <span class=\"k2b-sr-only\" role=\"status\" aria-live=\"polite\">\n {live()}\n </span>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Preview\n// ---------------------------------------------------------------------------\n\nexport type ChatPreviewProps = { children: JSX.Element; class?: string };\n\n/** The thing a question is about, as calm text on the sentence's edge: no surface, no column. */\nfunction ChatPreviewRoot(props: ChatPreviewProps): JSX.Element {\n return <div class={`k2b-chat-preview ${props.class ?? \"\"}`}>{props.children}</div>;\n}\n\nexport type ChatPreviewHeaderProps = {\n /** One row per field, such as From, To, Cc, and Bcc; the label stands right before its value. */\n rows: readonly ChatPreviewHeaderRow[];\n /** A last line, such as when the message goes out. */\n note?: JSX.Element;\n};\n\nconst PreviewPeople = (props: { people: readonly ChatPreviewPerson[] }) => (\n <For each={props.people}>\n {(person, index) => (\n <>\n {index() > 0 ? \", \" : \"\"}\n <span class=\"k2b-chat-preview__person\">\n <Show when={person.name}>{(name) => <b>{name()}</b>}</Show>\n <Show when={person.address}>\n {(address) => (\n <span class=\"k2b-chat-preview__address\" data-alone={person.name ? undefined : \"true\"}>\n {address()}\n </span>\n )}\n </Show>\n </span>\n </>\n )}\n </For>\n);\n\nfunction ChatPreviewHeader(props: ChatPreviewHeaderProps): JSX.Element {\n return (\n <div class=\"k2b-chat-preview__header\">\n <dl>\n <For each={props.rows}>\n {(row) => (\n <div data-emphasis={row.emphasis ? \"true\" : undefined}>\n <dt>{row.label}</dt>\n <dd>\n <Show when={row.people}>{(people) => <PreviewPeople people={people()} />}</Show>\n {row.value}\n </dd>\n </div>\n )}\n </For>\n </dl>\n <Show when={props.note}>{(note) => <p>{note()}</p>}</Show>\n </div>\n );\n}\n\nexport type ChatPreviewTitleProps = { children: JSX.Element; meta?: JSX.Element };\n\n/** The thing's name in the text's own face, with optional quiet facts after it. */\nfunction ChatPreviewTitle(props: ChatPreviewTitleProps): JSX.Element {\n return (\n <p class=\"k2b-chat-preview__title-line\">\n <span class=\"k2b-chat-preview__title\">{props.children}</span>\n <Show when={props.meta}>\n {(meta) => (\n <>\n {\" \"}\n <span class=\"k2b-chat-preview__meta\">{meta()}</span>\n </>\n )}\n </Show>\n </p>\n );\n}\n\n/** A rule or instruction as one sentence, such as what a routine does; chips and marks may stand inside. */\nfunction ChatPreviewSentence(props: { children: JSX.Element }): JSX.Element {\n return <p class=\"k2b-chat-preview__sentence\">{props.children}</p>;\n}\n\nexport type ChatPreviewExcerptProps = {\n children: JSX.Element;\n /** Shows the whole text in place instead of the first lines, such as after `Chat.Preview.ShowAll`. */\n expanded?: boolean;\n id?: string;\n};\n\n/** The first lines of a longer text. It keeps its line breaks, shows about three lines, and fades out. */\nfunction ChatPreviewExcerpt(props: ChatPreviewExcerptProps): JSX.Element {\n return (\n <p\n class=\"k2b-chat-preview__excerpt\"\n id={props.id}\n data-expanded={props.expanded ? \"true\" : undefined}\n tabindex={props.expanded ? -1 : undefined}\n >\n {props.children}\n </p>\n );\n}\n\nexport type ChatPreviewShowAllProps = {\n /** The id of the `Chat.Preview.Excerpt` this button opens. */\n controls: string;\n onShow: () => void;\n children: JSX.Element;\n};\n\n/**\n * Shows the rest of an excerpt in place, for a text with no page of its own to open. It looks like `ReadMore`; the\n * caller removes it once the text is shown, and the focus moves to the text, so reading goes on where it was.\n */\nfunction ChatPreviewShowAll(props: ChatPreviewShowAllProps): JSX.Element {\n const show = () => {\n props.onShow();\n queueMicrotask(() => document.getElementById(props.controls)?.focus({ preventScroll: true }));\n };\n return (\n <button type=\"button\" class=\"k2b-chat-preview__more\" aria-controls={props.controls} aria-expanded=\"false\" onClick={show}>\n {props.children}\n </button>\n );\n}\n\nexport type ChatPreviewReadMoreProps = {\n href: string;\n children: JSX.Element;\n /** Tooltip, such as \"Opens exactly this version of the draft\". */\n title?: string;\n};\n\n/** Opens the whole thing at exactly the version the question shows. */\nfunction ChatPreviewReadMore(props: ChatPreviewReadMoreProps): JSX.Element {\n return (\n <a class=\"k2b-chat-preview__more\" href={props.href} title={props.title}>\n {props.children}\n </a>\n );\n}\n\nconst InList = createContext(false);\n\n/** A list of lines with a name, such as \"What the routine may do\". */\nfunction ChatPreviewLines(props: { label?: string; children: JSX.Element }): JSX.Element {\n return (\n <ul class=\"k2b-chat-preview__lines\" aria-label={props.label}>\n <InList.Provider value={true}>{props.children}</InList.Provider>\n </ul>\n );\n}\n\nexport type ChatPreviewLineProps = {\n /** Icon class; the text after it starts 1.5rem from the edge. */\n icon: string;\n /** Icon colour, such as the PDF colour of an attachment. */\n accent?: string;\n /** `muted` for limits and notes, `warning` for an application's own warning. */\n tone?: \"default\" | \"muted\" | \"warning\";\n /** Marks the whole line as new or removed. */\n mark?: \"added\" | \"removed\";\n /** Quiet facts after the text, such as a file size. */\n meta?: JSX.Element;\n children: JSX.Element;\n};\n\n/** One line led by an icon: a consequence, a right, an attachment, or a warning. */\nfunction ChatPreviewLine(props: ChatPreviewLineProps): JSX.Element {\n const inList = useContext(InList);\n const messages = useChatMessages();\n const content = () => (\n <>\n <i class={`k2b-chat-line__icon ${props.icon}`} style={props.accent ? { color: props.accent } : undefined} aria-hidden=\"true\" />\n <span class=\"k2b-chat-line__text\">\n {/* One stable wrapper, so marking a line later never moves its mounted children. */}\n <span class=\"k2b-chat-mark\" data-change={props.mark}>\n <Show when={props.mark}>\n {(mark) => <span class=\"k2b-sr-only\">{mark() === \"added\" ? messages().markAdded : messages().markRemoved} </span>}\n </Show>\n {props.children}\n </span>\n <Show when={props.meta}>\n {(meta) => (\n <>\n {\" \"}\n <span class=\"k2b-chat-preview__meta\">{meta()}</span>\n </>\n )}\n </Show>\n </span>\n </>\n );\n const attributes = () => ({\n class: \"k2b-chat-line k2b-chat-preview__line\",\n \"data-tone\": props.tone && props.tone !== \"default\" ? props.tone : undefined,\n });\n return inList ? <li {...attributes()}>{content()}</li> : <p {...attributes()}>{content()}</p>;\n}\n\nexport type ChatPreviewPeopleProps = {\n /** The first few people; their avatars overlap at the start of the line. */\n people: readonly { name: string; src?: string | null }[];\n /** The names as text, such as \"Lea Berg, Tom Weber and 3 others\". */\n children: JSX.Element;\n};\n\nfunction ChatPreviewPeople(props: ChatPreviewPeopleProps): JSX.Element {\n return (\n <p class=\"k2b-chat-preview__people\">\n <span class=\"k2b-chat-preview__faces\" aria-hidden=\"true\">\n <For each={props.people}>{(person) => <Avatar name={person.name} src={person.src} size=\"xs\" />}</For>\n </span>\n <span>{props.children}</span>\n </p>\n );\n}\n\nexport const ChatPreview = Object.assign(ChatPreviewRoot, {\n Header: ChatPreviewHeader,\n Title: ChatPreviewTitle,\n Sentence: ChatPreviewSentence,\n Excerpt: ChatPreviewExcerpt,\n ReadMore: ChatPreviewReadMore,\n ShowAll: ChatPreviewShowAll,\n Lines: ChatPreviewLines,\n Line: ChatPreviewLine,\n People: ChatPreviewPeople,\n});\n\n// ---------------------------------------------------------------------------\n// Mark\n// ---------------------------------------------------------------------------\n\nexport type ChatMarkProps = { change: \"added\" | \"removed\"; children: JSX.Element };\n\n/** Marks new or removed words; screen readers hear \"new:\" or \"removed:\" first. */\nexport function ChatMark(props: ChatMarkProps): JSX.Element {\n const messages = useChatMessages();\n return (\n <Show\n when={props.change === \"removed\"}\n fallback={\n <mark class=\"k2b-chat-mark\" data-change=\"added\">\n <span class=\"k2b-sr-only\">{messages().markAdded} </span>\n {props.children}\n </mark>\n }\n >\n <del class=\"k2b-chat-mark\" data-change=\"removed\">\n <span class=\"k2b-sr-only\">{messages().markRemoved} </span>\n {props.children}\n </del>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SACE,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,cAAc,EACd,GAAG,EAEH,EAAE,EACF,SAAS,EACT,OAAO,EACP,IAAI,EACJ,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QAAQ;IAAA;EAAA;AAIvB","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["chat/ChatDecision.tsx"],"sourcesContent":["import {\n createContext,\n createEffect,\n createMemo,\n createSignal,\n createUniqueId,\n For,\n type JSX,\n on,\n onCleanup,\n onMount,\n Show,\n untrack,\n useContext,\n} from \"solid-js\";\nimport { Button } from \"../actions/Button\";\nimport { Avatar } from \"../surfaces/Avatar\";\nimport { useChatMessages } from \"./chat-messages\";\nimport type {\n ChatDecisionAnswer,\n ChatDecisionReason,\n ChatDecisionState,\n ChatOutcomeLine,\n ChatOutcomeTone,\n ChatPreviewHeaderRow,\n ChatPreviewPerson,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Decision\n// ---------------------------------------------------------------------------\n\nexport type ChatDecisionProps = {\n /** `open` shows the question; every other state shows `outcome` in its place. */\n state: ChatDecisionState;\n /** The question as one sentence, usually with `ReferenceChip`s. */\n sentence: JSX.Element;\n /** Why this question is asked, in the platform's words. */\n reason: ChatDecisionReason;\n /** The thing itself, usually `Chat.Preview`. */\n preview?: JSX.Element;\n /** The main answer, named by verb and target (\"Send to Lea\"). `danger` for deletions, `primary` for requests. */\n confirm: ChatDecisionAnswer & { variant?: \"ai\" | \"primary\" | \"danger\" };\n /** The other answer (\"Don't send\"). */\n decline: ChatDecisionAnswer;\n /** An optional quiet third answer after the buttons, such as \"Yes, and don't ask again in this chat\". */\n remember?: ChatDecisionAnswer;\n /** Turns `confirm` and `remember` off; this reason replaces `reason` in the same place. */\n unavailable?: ChatDecisionReason;\n /**\n * Turns every answer off until the reason clears, such as no connection, so no answer is lost on the way; this\n * reason replaces `reason` and `unavailable` in the same place.\n */\n waiting?: ChatDecisionReason;\n /** The result line shown in every state but `open`, usually `Chat.Outcome`. */\n outcome?: JSX.Element;\n /** Receives a rejected promise from an answer's `onSelect`. */\n onAnswerError?: (error: unknown) => void;\n anchorId?: string | number;\n class?: string;\n};\n\n/** What an outcome inside a question needs from it: whether it was just answered here, and a link press inside it. */\nconst DecisionScope = createContext<{ answered: () => boolean; pressed: () => void; released: () => void }>();\n\nconst reasonIcon = (reason: ChatDecisionReason) => reason.icon ?? \"ti ti-info-circle\";\n\n/**\n * A question the person answers in the conversation: one sentence, why it is asked, the thing itself, and two answers.\n * An answer collapses it at once to its outcome line, which takes the focus and is announced.\n */\nexport function ChatDecision(props: ChatDecisionProps): JSX.Element {\n const id = createUniqueId();\n const sentenceId = `k2b-chat-decision-${id}-sentence`;\n const reasonId = `k2b-chat-decision-${id}-reason`;\n let root: HTMLDivElement | undefined;\n let sentence: HTMLParagraphElement | undefined;\n // An answer given here moves the focus to the outcome; a click in the outcome that reopens the question moves it\n // back to the sentence. A state change from elsewhere moves no focus.\n const [answeredHere, setAnsweredHere] = createSignal(false);\n const [arrive, setArrive] = createSignal(false);\n let reopenedHere = false;\n // A press on the sentence focuses it too; only a focus moved there from elsewhere, such as a jump, lights it up.\n // The browser also focuses the sentence again when its window comes back; that is no arrival either.\n let sentencePressed = false;\n let sentenceHeldAcrossWindow = false;\n const windowLeft = () => {\n if (sentence && document.activeElement === sentence) sentenceHeldAcrossWindow = true;\n };\n onMount(() => {\n window.addEventListener(\"blur\", windowLeft);\n onCleanup(() => window.removeEventListener(\"blur\", windowLeft));\n });\n // A press counts only while its action runs: a reopen from elsewhere later must not take the focus.\n const scope = {\n answered: answeredHere,\n pressed: () => {\n reopenedHere = true;\n },\n released: () => {\n reopenedHere = false;\n },\n };\n\n // Read once: an object literal from the host builds its JSX again on every read.\n const reason = createMemo(() => props.waiting ?? props.unavailable ?? props.reason);\n const confirmOff = () => Boolean(props.waiting ?? props.unavailable);\n const open = () => props.state === \"open\";\n\n const answer = (choice: ChatDecisionAnswer, enabled: boolean) => {\n if (!enabled || !open() || answeredHere()) return;\n setAnsweredHere(true);\n try {\n const result = choice.onSelect();\n if (result instanceof Promise) result.catch((error: unknown) => props.onAnswerError?.(error));\n } catch (error) {\n props.onAnswerError?.(error);\n }\n // A host that keeps the question open (it could not take the answer) gets working buttons back.\n queueMicrotask(() => {\n if (open()) setAnsweredHere(false);\n });\n };\n\n createEffect(\n on(\n () => props.state,\n (state, previous) => {\n if (state !== \"open\" && previous === \"open\" && answeredHere()) {\n root?.querySelector<HTMLElement>(\".k2b-chat-outcome\")?.focus({ preventScroll: true });\n }\n if (state === \"open\" && previous !== undefined && previous !== \"open\") {\n // A host that could not take an answer given here returns the question from `sending`; the outcome that held\n // the focus is gone, so the focus goes back to the sentence instead of the page.\n const active = document.activeElement;\n const failedHere = answeredHere() && previous === \"sending\" && (!active || active === document.body);\n setAnsweredHere(false);\n if (reopenedHere || failedHere) {\n sentence?.focus({ preventScroll: true });\n setArrive(true);\n }\n // Handled. Until then the marker holds through states in between, such as `sending` while a reopen loads.\n reopenedHere = false;\n }\n },\n ),\n );\n\n return (\n <div\n ref={root}\n class={`k2b-chat-decision ${props.class ?? \"\"}`}\n data-state={props.state}\n data-chat-anchor={props.anchorId !== undefined ? String(props.anchorId) : undefined}\n >\n <Show when={open()} fallback={<DecisionScope.Provider value={scope}>{props.outcome}</DecisionScope.Provider>}>\n <section class=\"k2b-chat-decision__card\" aria-labelledby={sentenceId} aria-describedby={reasonId}>\n <p\n ref={sentence}\n id={sentenceId}\n class=\"k2b-chat-decision__sentence\"\n tabindex=\"-1\"\n data-arrive={arrive() ? \"true\" : undefined}\n onPointerDown={() => {\n sentencePressed = true;\n }}\n onPointerUp={() => {\n sentencePressed = false;\n }}\n onPointerCancel={() => {\n sentencePressed = false;\n }}\n onFocus={() => {\n if (!sentencePressed && !sentenceHeldAcrossWindow) setArrive(true);\n sentencePressed = false;\n sentenceHeldAcrossWindow = false;\n }}\n onAnimationEnd={() => setArrive(false)}\n >\n {props.sentence}\n </p>\n <p id={reasonId} class=\"k2b-chat-line k2b-chat-decision__reason\" data-tone={reason().tone ?? \"neutral\"}>\n <i class={`k2b-chat-line__icon ${reasonIcon(reason())}`} aria-hidden=\"true\" />\n <span class=\"k2b-chat-line__text\">{reason().text}</span>\n </p>\n {props.preview}\n <div class=\"k2b-chat-decision__answers\">\n <Button\n class=\"k2b-chat-decision__answer\"\n wrap\n variant={props.confirm.variant ?? \"ai\"}\n disabled={confirmOff()}\n onClick={() => answer(props.confirm, !confirmOff())}\n >\n <Show when={props.confirm.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n {props.confirm.label}\n </Button>\n <Button\n class=\"k2b-chat-decision__answer\"\n wrap\n variant=\"subtle\"\n disabled={Boolean(props.waiting)}\n onClick={() => answer(props.decline, !props.waiting)}\n >\n <Show when={props.decline.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n {props.decline.label}\n </Button>\n <Show when={props.remember}>\n {(remember) => (\n <Button\n class=\"k2b-chat-decision__remember\"\n wrap\n variant=\"text\"\n disabled={confirmOff()}\n onClick={() => answer(remember(), !confirmOff())}\n >\n {remember().label}\n </Button>\n )}\n </Show>\n </div>\n </section>\n </Show>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Outcome\n// ---------------------------------------------------------------------------\n\nexport type ChatOutcomeProps = {\n /**\n * Every line one flow can show, such as running and done. All of them share one cell, so the line is as high as\n * the longest and switching between them moves nothing.\n */\n lines: Readonly<Record<string, ChatOutcomeLine>>;\n /** The key of the visible line. */\n current: string;\n /** Receives an error thrown or rejected by a line's `action`. */\n onActionError?: (error: unknown) => void;\n anchorId?: string | number;\n class?: string;\n};\n\nconst OUTCOME_ICONS: Record<ChatOutcomeTone, string> = {\n running: \"ti ti-loader-2 k2b-spin\",\n done: \"ti ti-check\",\n off: \"ti ti-circle-off\",\n waiting: \"ti ti-clock\",\n warning: \"ti ti-alert-triangle\",\n error: \"ti ti-alert-circle\",\n};\n\n/** The visible words of a line, without what screen readers do not hear. */\nconst spokenText = (element: Element): string => {\n const copy = element.cloneNode(true) as Element;\n // Buttons under the line are controls, not part of what happened.\n for (const hidden of copy.querySelectorAll('[aria-hidden=\"true\"], .k2b-chat-outcome__actions')) hidden.remove();\n // The time and the link stand apart by margin only; spoken, they need a space.\n for (const part of copy.querySelectorAll(\".k2b-chat-outcome__time, .k2b-chat-outcome__link\")) part.before(\" \");\n return (copy.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * One line that says what happened: running, done, off, waiting, warning, or error. Changes are announced through a\n * polite live region; the line itself can take the focus.\n */\nexport function ChatOutcome(props: ChatOutcomeProps): JSX.Element {\n const scope = useContext(DecisionScope);\n // Only a line that replaces a question just answered here fades in; history renders final.\n const entering = untrack(() => scope?.answered() ?? false);\n const [live, setLive] = createSignal(\"\");\n let root: HTMLDivElement | undefined;\n let cell: HTMLDivElement | undefined;\n let pending = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n // Read once: an object literal from the host builds its JSX again on every read.\n const lines = createMemo(() => props.lines);\n const line = () => lines()[props.current];\n const tone = () => line()?.tone ?? \"off\";\n const keys = () => {\n const all = Object.keys(lines());\n return all.includes(props.current) ? all : [props.current, ...all];\n };\n\n // Empty the region first, so the same words spoken again are a change too.\n const announce = () => {\n setLive(\"\");\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => {\n const current = cell?.querySelector('[data-current=\"true\"]');\n setLive(current ? spokenText(current) : \"\");\n }, 40);\n };\n\n onMount(() => {\n if (untrack(() => scope?.answered())) announce();\n });\n createEffect(\n on(\n () => props.current,\n () => {\n // A link pressed in a line that is now hidden would leave the focus on an invisible button, which the browser\n // then drops to the page. The line itself keeps it instead.\n const active = document.activeElement;\n const hidden = active && cell?.contains(active) && !active.closest('[data-current=\"true\"]');\n if (hidden || (pending && active === document.body)) root?.focus({ preventScroll: true });\n announce();\n },\n { defer: true },\n ),\n );\n onCleanup(() => {\n if (timer) clearTimeout(timer);\n });\n\n return (\n <div\n ref={root}\n class={`k2b-chat-outcome ${props.class ?? \"\"}`}\n data-tone={tone()}\n data-chat-anchor={props.anchorId !== undefined ? String(props.anchorId) : undefined}\n data-enter={entering ? \"true\" : undefined}\n tabindex=\"-1\"\n >\n <span class=\"k2b-chat-outcome__icon\" aria-hidden=\"true\">\n <i class={line()?.icon ?? OUTCOME_ICONS[tone()]} />\n </span>\n {/* Busy is set on the words only: a live region inside a busy subtree would be held back. */}\n <div ref={cell} class=\"k2b-chat-outcome__cell\" aria-busy={tone() === \"running\" ? \"true\" : undefined}>\n <For each={keys()}>\n {(key) => {\n const entry = () => lines()[key];\n const current = () => key === props.current;\n return (\n <Show when={entry()}>\n {(item) => (\n <div\n class=\"k2b-chat-outcome__text\"\n data-current={current() ? \"true\" : undefined}\n aria-hidden={current() ? undefined : \"true\"}\n >\n {item().text}\n <Show when={item().detail}>\n {(detail) => (\n <>\n {\" \"}\n <span class=\"k2b-chat-outcome__detail\">{detail()}</span>\n </>\n )}\n </Show>\n <Show when={item().time}>{(time) => <span class=\"k2b-chat-outcome__time\">{time()}</span>}</Show>\n <Show when={item().action}>\n {(action) => (\n <Button\n class=\"k2b-chat-outcome__link\"\n wrap\n variant=\"text\"\n tabIndex={current() ? undefined : -1}\n onClick={() => {\n // A second press while the first is still running would repeat its work.\n if (pending) return;\n scope?.pressed();\n try {\n const result = action().onSelect();\n if (result instanceof Promise) {\n pending = true;\n result\n .catch((error: unknown) => props.onActionError?.(error))\n .finally(() => {\n pending = false;\n scope?.released();\n });\n return;\n }\n } catch (error) {\n props.onActionError?.(error);\n }\n scope?.released();\n }}\n >\n {action().label}\n </Button>\n )}\n </Show>\n {/* Every line keeps its buttons, hidden with its text, so the cell also reserves their row. */}\n <Show when={item().actions}>{(actions) => <div class=\"k2b-chat-outcome__actions\">{actions()}</div>}</Show>\n </div>\n )}\n </Show>\n );\n }}\n </For>\n </div>\n <span class=\"k2b-sr-only\" role=\"status\" aria-live=\"polite\">\n {live()}\n </span>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Preview\n// ---------------------------------------------------------------------------\n\nexport type ChatPreviewProps = { children: JSX.Element; class?: string };\n\n/** The thing a question is about, as calm text on the sentence's edge: no surface, no column. */\nfunction ChatPreviewRoot(props: ChatPreviewProps): JSX.Element {\n return <div class={`k2b-chat-preview ${props.class ?? \"\"}`}>{props.children}</div>;\n}\n\nexport type ChatPreviewHeaderProps = {\n /** One row per field, such as From, To, Cc, and Bcc; the label stands right before its value. */\n rows: readonly ChatPreviewHeaderRow[];\n /** A last line, such as when the message goes out. */\n note?: JSX.Element;\n};\n\nconst PreviewPeople = (props: { people: readonly ChatPreviewPerson[] }) => (\n <For each={props.people}>\n {(person, index) => (\n <>\n {index() > 0 ? \", \" : \"\"}\n <span class=\"k2b-chat-preview__person\">\n <Show when={person.name}>{(name) => <b>{name()}</b>}</Show>\n <Show when={person.address}>\n {(address) => (\n <span class=\"k2b-chat-preview__address\" data-alone={person.name ? undefined : \"true\"}>\n {address()}\n </span>\n )}\n </Show>\n </span>\n </>\n )}\n </For>\n);\n\nfunction ChatPreviewHeader(props: ChatPreviewHeaderProps): JSX.Element {\n return (\n <div class=\"k2b-chat-preview__header\">\n <dl>\n <For each={props.rows}>\n {(row) => (\n <div data-emphasis={row.emphasis ? \"true\" : undefined}>\n <dt>{row.label}</dt>\n <dd>\n <Show when={row.people}>{(people) => <PreviewPeople people={people()} />}</Show>\n {row.value}\n </dd>\n </div>\n )}\n </For>\n </dl>\n <Show when={props.note}>{(note) => <p>{note()}</p>}</Show>\n </div>\n );\n}\n\nexport type ChatPreviewTitleProps = { children: JSX.Element; meta?: JSX.Element };\n\n/** The thing's name in the text's own face, with optional quiet facts after it. */\nfunction ChatPreviewTitle(props: ChatPreviewTitleProps): JSX.Element {\n return (\n <p class=\"k2b-chat-preview__title-line\">\n <span class=\"k2b-chat-preview__title\">{props.children}</span>\n <Show when={props.meta}>\n {(meta) => (\n <>\n {\" \"}\n <span class=\"k2b-chat-preview__meta\">{meta()}</span>\n </>\n )}\n </Show>\n </p>\n );\n}\n\n/** A rule or instruction as one sentence, such as what a routine does; chips and marks may stand inside. */\nfunction ChatPreviewSentence(props: { children: JSX.Element }): JSX.Element {\n return <p class=\"k2b-chat-preview__sentence\">{props.children}</p>;\n}\n\nexport type ChatPreviewExcerptProps = {\n children: JSX.Element;\n /** Shows the whole text in place instead of the first lines, such as after `Chat.Preview.ShowAll`. */\n expanded?: boolean;\n id?: string;\n};\n\n/** The first lines of a longer text. It keeps its line breaks, shows about three lines, and fades out. */\nfunction ChatPreviewExcerpt(props: ChatPreviewExcerptProps): JSX.Element {\n return (\n <p\n class=\"k2b-chat-preview__excerpt\"\n id={props.id}\n data-expanded={props.expanded ? \"true\" : undefined}\n tabindex={props.expanded ? -1 : undefined}\n >\n {props.children}\n </p>\n );\n}\n\nexport type ChatPreviewShowAllProps = {\n /** The id of the `Chat.Preview.Excerpt` this button opens. */\n controls: string;\n onShow: () => void;\n children: JSX.Element;\n};\n\n/**\n * Shows the rest of an excerpt in place, for a text with no page of its own to open. It looks like `ReadMore`; the\n * caller removes it once the text is shown, and the focus moves to the text, so reading goes on where it was.\n */\nfunction ChatPreviewShowAll(props: ChatPreviewShowAllProps): JSX.Element {\n const show = () => {\n props.onShow();\n queueMicrotask(() => document.getElementById(props.controls)?.focus({ preventScroll: true }));\n };\n return (\n <button type=\"button\" class=\"k2b-chat-preview__more\" aria-controls={props.controls} aria-expanded=\"false\" onClick={show}>\n {props.children}\n </button>\n );\n}\n\nexport type ChatPreviewReadMoreProps = {\n href: string;\n children: JSX.Element;\n /** Tooltip, such as \"Opens exactly this version of the draft\". */\n title?: string;\n};\n\n/** Opens the whole thing at exactly the version the question shows. */\nfunction ChatPreviewReadMore(props: ChatPreviewReadMoreProps): JSX.Element {\n return (\n <a class=\"k2b-chat-preview__more\" href={props.href} title={props.title}>\n {props.children}\n </a>\n );\n}\n\nconst InList = createContext(false);\n\n/** A list of lines with a name, such as \"What the routine may do\". */\nfunction ChatPreviewLines(props: { label?: string; children: JSX.Element }): JSX.Element {\n return (\n <ul class=\"k2b-chat-preview__lines\" aria-label={props.label}>\n <InList.Provider value={true}>{props.children}</InList.Provider>\n </ul>\n );\n}\n\nexport type ChatPreviewLineProps = {\n /** Icon class; the text after it starts 1.5rem from the edge. */\n icon: string;\n /** Icon colour, such as the PDF colour of an attachment. */\n accent?: string;\n /** `muted` for limits and notes, `warning` for an application's own warning. */\n tone?: \"default\" | \"muted\" | \"warning\";\n /** Marks the whole line as new or removed. */\n mark?: \"added\" | \"removed\";\n /** Quiet facts after the text, such as a file size. */\n meta?: JSX.Element;\n children: JSX.Element;\n};\n\n/** One line led by an icon: a consequence, a right, an attachment, or a warning. */\nfunction ChatPreviewLine(props: ChatPreviewLineProps): JSX.Element {\n const inList = useContext(InList);\n const messages = useChatMessages();\n const content = () => (\n <>\n <i class={`k2b-chat-line__icon ${props.icon}`} style={props.accent ? { color: props.accent } : undefined} aria-hidden=\"true\" />\n <span class=\"k2b-chat-line__text\">\n {/* One stable wrapper, so marking a line later never moves its mounted children. */}\n <span class=\"k2b-chat-mark\" data-change={props.mark}>\n <Show when={props.mark}>\n {(mark) => <span class=\"k2b-sr-only\">{mark() === \"added\" ? messages().markAdded : messages().markRemoved} </span>}\n </Show>\n {props.children}\n </span>\n <Show when={props.meta}>\n {(meta) => (\n <>\n {\" \"}\n <span class=\"k2b-chat-preview__meta\">{meta()}</span>\n </>\n )}\n </Show>\n </span>\n </>\n );\n const attributes = () => ({\n class: \"k2b-chat-line k2b-chat-preview__line\",\n \"data-tone\": props.tone && props.tone !== \"default\" ? props.tone : undefined,\n });\n return inList ? <li {...attributes()}>{content()}</li> : <p {...attributes()}>{content()}</p>;\n}\n\nexport type ChatPreviewPeopleProps = {\n /** The first few people; their avatars overlap at the start of the line. */\n people: readonly { name: string; src?: string | null }[];\n /** The names as text, such as \"Lea Berg, Tom Weber and 3 others\". */\n children: JSX.Element;\n};\n\nfunction ChatPreviewPeople(props: ChatPreviewPeopleProps): JSX.Element {\n return (\n <p class=\"k2b-chat-preview__people\">\n <span class=\"k2b-chat-preview__faces\" aria-hidden=\"true\">\n <For each={props.people}>{(person) => <Avatar name={person.name} src={person.src} size=\"xs\" />}</For>\n </span>\n <span>{props.children}</span>\n </p>\n );\n}\n\nexport const ChatPreview = Object.assign(ChatPreviewRoot, {\n Header: ChatPreviewHeader,\n Title: ChatPreviewTitle,\n Sentence: ChatPreviewSentence,\n Excerpt: ChatPreviewExcerpt,\n ReadMore: ChatPreviewReadMore,\n ShowAll: ChatPreviewShowAll,\n Lines: ChatPreviewLines,\n Line: ChatPreviewLine,\n People: ChatPreviewPeople,\n});\n\n// ---------------------------------------------------------------------------\n// Mark\n// ---------------------------------------------------------------------------\n\nexport type ChatMarkProps = { change: \"added\" | \"removed\"; children: JSX.Element };\n\n/** Marks new or removed words; screen readers hear \"new:\" or \"removed:\" first. */\nexport function ChatMark(props: ChatMarkProps): JSX.Element {\n const messages = useChatMessages();\n return (\n <Show\n when={props.change === \"removed\"}\n fallback={\n <mark class=\"k2b-chat-mark\" data-change=\"added\">\n <span class=\"k2b-sr-only\">{messages().markAdded} </span>\n {props.children}\n </mark>\n }\n >\n <del class=\"k2b-chat-mark\" data-change=\"removed\">\n <span class=\"k2b-sr-only\">{messages().markRemoved} </span>\n {props.children}\n </del>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SACE,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,cAAc,EACd,GAAG,EAEH,EAAE,EACF,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,EACP,UAAU,QACL,UAAU;AACjB,SAAS,MAAM,QAAQ,mBAAmB;AAC1C,SAAS,MAAM,QAAQ,oBAAoB;AAC3C,SAAS,eAAe,QAAQ,iBAAiB;;AAWjD;AACA;AACA;;AAgCA;AACA,MAAM,aAAa,GAAG,aAAa,CAAyE,CAAC;AAE7G,MAAM,UAAU,GAAI,MAA0B,IAAK,MAAM,CAAC,IAAI,IAAI,mBAAmB;;AAErF;AACA;AACA;AACA;AACA,OAAO,SAAS,YAAY,CAAC,KAAwB,EAAe;EAClE,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC;E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,OAAO,CAAC,CAAC,SAAK;AAC/F;AASA,SAAS,iBAAiB,CAAC,KAA6B,EAAe;EACrE,kDAGO,GAAG;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,MAAM;IAAA;IAAA,UAAI,MAAM,sBAAM,MAAM;MAAA,IAAC,IAAI;QAAA,OAAE,MAAM,CAAC,IAAI;MAAA;MAAA,IAAE,GAAG;QAAA,OAAE,MAAM,CAAC,GAAG;MAAA;MAAE,IAAI;IAAA;EAAQ,cAEzF,KAAK,CAAC,QAAQ;AAG3B;AAEA,OAAO,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;EACxD,MAAM,EAAE,iBAAiB;EACzB,KAAK,EAAE,gBAAgB;EACvB,QAAQ,EAAE,mBAAmB;EAC7B,OAAO,EAAE,kBAAkB;EAC3B,QAAQ,EAAE,mBAAmB;EAC7B,OAAO,EAAE,kBAAkB;EAC3B,KAAK,EAAE,gBAAgB;EACvB,IAAI,EAAE,eAAe;EACrB,MAAM,EAAE;AACV,CAAC,CAAC;;AAEF;AACA;AACA;;AAIA;AACA,OAAO,SAAS,QAAQ,CAAC,KAAoB,EAAe;EAC1D,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC;EAClC,yBACG,IAAI;IAAA,IACH,IAAI;MAAA,OAAE,KAAK,CAAC,MAAM,KAAK,SAAS;IAAA;IAAA,IAChC,QAAQ;MAAA,gCAEuB,QAAQ,CAAC,CAAC,CAAC,SAAS,YAC9C,KAAK,CAAC,QAAQ;IAAA;IAAA;MAAA,gCAKU,QAAQ,CAAC,CAAC,CAAC,WAAW,YAChD,KAAK,CAAC,QAAQ;IAAA;EAAA;AAIvB","ignoreList":[]}
@@ -121,6 +121,7 @@ export function VirtualFeed(props) {
121
121
  let focusIndex = -1;
122
122
  let fresh = [];
123
123
  let restoring = false;
124
+ let restoreVersion = 0;
124
125
  let restoreAgain = false;
125
126
  let pendingAnnouncement = [];
126
127
  let announceTimer;
@@ -199,30 +200,30 @@ export function VirtualFeed(props) {
199
200
  * not: rows moved down would show empty space above the first item, and rows moved up would put the first items
200
201
  * out of the scroll range's reach. The margin is the overscan, so the write lands before the engine draws there.
201
202
  */
202
- const mayDefer = top => deferring() && Math.min(viewport.scrollTop, top) > OVERSCAN;
203
+ const mayDefer = (top, physicalTop) => deferring() && Math.min(physicalTop ?? viewport.scrollTop, top) > OVERSCAN;
203
204
  /** Scrolls to `target`, within what the layout can reach, and returns the position the reader gets. */
204
- const writeTop = (target, immediate) => {
205
- const next = Math.min(Math.max(0, total() - viewport.clientHeight), Math.max(0, target));
206
- if (!immediate && mayDefer(next)) {
205
+ const writeTop = (target, immediate, height) => {
206
+ const next = Math.min(Math.max(0, total() - height), Math.max(0, target));
207
+ const from = viewport.scrollTop;
208
+ if (!immediate && mayDefer(next, from)) {
207
209
  // The rows move instead; the scroll range stays the same, so the engine clamps nothing.
208
- lastTop = viewport.scrollTop;
210
+ lastTop = from;
209
211
  deferred = next - lastTop;
210
212
  feed.style.height = `${total() - deferred}px`;
211
213
  return next;
212
214
  }
213
215
  deferred = 0;
214
216
  feed.style.height = `${total()}px`;
215
- const from = viewport.scrollTop;
216
217
  if (Math.abs(from - next) > 0.5) viewport.scrollTop = next;
217
218
  lastTop = viewport.scrollTop;
218
219
  if (Math.abs(lastTop - from) > 0.5) owedUntil = performance.now() + END_WAIT_MS;
219
220
  return next;
220
221
  };
221
222
  let visibleKeys;
222
- const reportVisible = () => {
223
+ const reportVisible = (top, height) => {
223
224
  if (!props.onVisibleChange) return;
224
- const top = logicalTop();
225
- const bottom = top + viewport.clientHeight;
225
+ top ??= logicalTop();
226
+ const bottom = top + (height ?? viewport.clientHeight);
226
227
  let first = -1;
227
228
  let last = -1;
228
229
  if (bottom > top && hi > lo) for (let index = indexAt(top); index < hi && offsetOf(index) < bottom; index++) {
@@ -245,9 +246,7 @@ export function VirtualFeed(props) {
245
246
  last: list[last]
246
247
  });
247
248
  };
248
- const updateRange = () => {
249
- const top = logicalTop();
250
- const height = viewport.clientHeight;
249
+ const updateRange = (top = logicalTop(), height = viewport.clientHeight) => {
251
250
  const indices = [];
252
251
  if (hi > lo) {
253
252
  const start = indexAt(top - OVERSCAN);
@@ -261,7 +260,7 @@ export function VirtualFeed(props) {
261
260
  renderRows(indices);
262
261
  setTabStop(focusIndex >= lo && focusIndex < hi ? focusIndex : hi > lo ? indexAt(top + height - 1) : -1);
263
262
  // Newly mounted rows still have estimates; report only after their heights are measured.
264
- if (!restoring && !fresh.some(node => node.isConnected)) reportVisible();
263
+ if (!restoring && !fresh.some(node => node.isConnected)) reportVisible(top, height);
265
264
  };
266
265
  const measure = measured => {
267
266
  let changed = false;
@@ -369,6 +368,8 @@ export function VirtualFeed(props) {
369
368
  return;
370
369
  }
371
370
  restoring = true;
371
+ const restored = ++restoreVersion;
372
+ const height = viewport.clientHeight;
372
373
  let target = 0;
373
374
  let top = 0;
374
375
  // Following the end shows the end of all items from now on, so later moves are judged against it.
@@ -378,9 +379,10 @@ export function VirtualFeed(props) {
378
379
  restoreAgain = false;
379
380
  recompute();
380
381
  target = stick ? total() : offsetOf(anchor.index) - anchor.delta;
381
- top = writeTop(target, immediate);
382
- updateRange();
383
- setVersion(value => value + 1);
382
+ top = Math.min(Math.max(0, total() - height), Math.max(0, target));
383
+ // Row heights do not depend on their translation or the feed's scroll position. Mount and measure the
384
+ // logical range first; writing the final geometry once avoids a layout flush on every correction pass.
385
+ updateRange(top, height);
384
386
  if (pass === MEASURE_PASSES) break;
385
387
  // Rows mounted here reach the ResizeObserver only next frame (its loop limit), so measure them now.
386
388
  const mounted = fresh.filter(node => node.isConnected);
@@ -388,6 +390,8 @@ export function VirtualFeed(props) {
388
390
  if (measure(mounted.map(node => [node, node.getBoundingClientRect().height]))) restoreAgain = true;
389
391
  if (!restoreAgain) break;
390
392
  }
393
+ top = writeTop(target, immediate, height);
394
+ setVersion(value => value + 1);
391
395
  // A position the layout cannot reach, above its start or past its end, becomes the one the reader sees, so a
392
396
  // page that loads there later keeps it instead of moving to it.
393
397
  if (!stick && Math.abs(top - target) > 0.5) anchor = {
@@ -397,8 +401,9 @@ export function VirtualFeed(props) {
397
401
  } finally {
398
402
  restoring = false;
399
403
  }
400
- checkEdges();
401
- reportVisible();
404
+ checkEdges(lastTop + deferred, height);
405
+ // A synchronous edge load can restore another window; that restore already reports its final geometry.
406
+ if (restored === restoreVersion) reportVisible(lastTop + deferred, height);
402
407
  };
403
408
 
404
409
  /**
@@ -570,10 +575,10 @@ export function VirtualFeed(props) {
570
575
  };
571
576
 
572
577
  /** Grows the window or asks for more items when the reader nears an edge. */
573
- const checkEdges = () => {
578
+ const checkEdges = (top, height) => {
574
579
  if (hi <= lo || restoring) return;
575
- const top = logicalTop();
576
- const height = viewport.clientHeight;
580
+ top ??= logicalTop();
581
+ height ??= viewport.clientHeight;
577
582
  // Rows measured taller than estimated can grow the window past the cap without any edge moving.
578
583
  if (total() > MAX_WINDOW && trimWindow(top + height / 2 > total() / 2 ? "start" : "end")) {
579
584
  restore(true);