@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.
- package/dist/browser/chat/ChatDecision.js +10 -6
- package/dist/browser/chat/ChatDecision.js.map +1 -1
- package/dist/browser/content/VirtualFeed.js +26 -21
- package/dist/browser/content/VirtualFeed.js.map +1 -1
- package/dist/browser/inputs/Combobox.js +14 -6
- package/dist/browser/inputs/Combobox.js.map +1 -1
- package/dist/browser/layout/AnchoredPopover.js +2 -1
- package/dist/browser/layout/AnchoredPopover.js.map +1 -1
- package/dist/browser/layout/AppWorkspace.js +340 -440
- package/dist/browser/layout/AppWorkspace.js.map +1 -1
- package/dist/browser/layout/AppWorkspaceSidebarItemStatus.js +113 -0
- package/dist/browser/layout/AppWorkspaceSidebarItemStatus.js.map +1 -0
- package/dist/browser/layout/DetailPanel.js +1 -1
- package/dist/browser/layout/DetailPanel.js.map +1 -1
- package/dist/browser/layout/DetailSections.js +236 -132
- package/dist/browser/layout/DetailSections.js.map +1 -1
- package/dist/browser/layout/MobileShell.js +30 -13
- package/dist/browser/layout/MobileShell.js.map +1 -1
- package/dist/browser/layout/detail-sections-messages.js +4 -0
- package/dist/browser/layout/detail-sections-messages.js.map +1 -1
- package/dist/browser/layout/index.js +1 -0
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/ssr/chat/ChatDecision.js +10 -6
- package/dist/ssr/chat/ChatDecision.js.map +1 -1
- package/dist/ssr/content/VirtualFeed.js +26 -21
- package/dist/ssr/content/VirtualFeed.js.map +1 -1
- package/dist/ssr/inputs/Combobox.js +6 -3
- package/dist/ssr/inputs/Combobox.js.map +1 -1
- package/dist/ssr/layout/AnchoredPopover.js +2 -1
- package/dist/ssr/layout/AnchoredPopover.js.map +1 -1
- package/dist/ssr/layout/AppWorkspace.js +61 -127
- package/dist/ssr/layout/AppWorkspace.js.map +1 -1
- package/dist/ssr/layout/AppWorkspaceSidebarItemStatus.js +76 -0
- package/dist/ssr/layout/AppWorkspaceSidebarItemStatus.js.map +1 -0
- package/dist/ssr/layout/DetailPanel.js +1 -1
- package/dist/ssr/layout/DetailPanel.js.map +1 -1
- package/dist/ssr/layout/DetailSections.js +126 -50
- package/dist/ssr/layout/DetailSections.js.map +1 -1
- package/dist/ssr/layout/MobileShell.js +16 -2
- package/dist/ssr/layout/MobileShell.js.map +1 -1
- package/dist/ssr/layout/detail-sections-messages.js +4 -0
- package/dist/ssr/layout/detail-sections-messages.js.map +1 -1
- package/dist/ssr/layout/index.js +1 -0
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/chat/ChatDecision.d.ts +5 -0
- package/dist/types/inputs/Combobox.d.ts +2 -0
- package/dist/types/layout/AppWorkspace.d.ts +2 -28
- package/dist/types/layout/AppWorkspaceSidebarItemStatus.d.ts +30 -0
- package/dist/types/layout/DetailSections.d.ts +32 -2
- package/dist/types/layout/MobileShell.d.ts +12 -0
- package/dist/types/layout/detail-sections-messages.d.ts +2 -0
- package/dist/types/layout/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -91,7 +91,8 @@ export function ChatDecision(props) {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// Read once: an object literal from the host builds its JSX again on every read.
|
|
94
|
-
const reason = createMemo(() => props.unavailable ?? props.reason);
|
|
94
|
+
const reason = createMemo(() => props.waiting ?? props.unavailable ?? props.reason);
|
|
95
|
+
const confirmOff = () => Boolean(props.waiting ?? props.unavailable);
|
|
95
96
|
const open = () => props.state === "open";
|
|
96
97
|
const answer = (choice, enabled) => {
|
|
97
98
|
if (!enabled || !open() || answeredHere()) return;
|
|
@@ -191,9 +192,9 @@ export function ChatDecision(props) {
|
|
|
191
192
|
return props.confirm.variant ?? "ai";
|
|
192
193
|
},
|
|
193
194
|
get disabled() {
|
|
194
|
-
return
|
|
195
|
+
return confirmOff();
|
|
195
196
|
},
|
|
196
|
-
onClick: () => answer(props.confirm, !
|
|
197
|
+
onClick: () => answer(props.confirm, !confirmOff()),
|
|
197
198
|
get children() {
|
|
198
199
|
return [_$createComponent(Show, {
|
|
199
200
|
get when() {
|
|
@@ -211,7 +212,10 @@ export function ChatDecision(props) {
|
|
|
211
212
|
"class": "k2b-chat-decision__answer",
|
|
212
213
|
wrap: true,
|
|
213
214
|
variant: "subtle",
|
|
214
|
-
|
|
215
|
+
get disabled() {
|
|
216
|
+
return Boolean(props.waiting);
|
|
217
|
+
},
|
|
218
|
+
onClick: () => answer(props.decline, !props.waiting),
|
|
215
219
|
get children() {
|
|
216
220
|
return [_$createComponent(Show, {
|
|
217
221
|
get when() {
|
|
@@ -234,9 +238,9 @@ export function ChatDecision(props) {
|
|
|
234
238
|
wrap: true,
|
|
235
239
|
variant: "text",
|
|
236
240
|
get disabled() {
|
|
237
|
-
return
|
|
241
|
+
return confirmOff();
|
|
238
242
|
},
|
|
239
|
-
onClick: () => answer(remember(), !
|
|
243
|
+
onClick: () => answer(remember(), !confirmOff()),
|
|
240
244
|
get children() {
|
|
241
245
|
return remember().label;
|
|
242
246
|
}
|
|
@@ -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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AC,QAAQ;MAAA;IAAA;EAAA;AAIvB;AAAC","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,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AI;QAAA;QAAA,IAAE,GAAG;UAAA,OAAE,MAAM,CAAC,GAAG;QAAA;QAAE,IAAI;MAAA;IAAQ;IAAA,uBAEzF,KAAK,CAAC,QAAQ;IAAA;EAAA;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;QAAA;UAAA;UAAA;UAAA;UAAA;UAAA;UAAA;QAAA,uBAEuB,QAAQ,CAAC,CAAC,CAAC,SAAS;QAAA,uBAC9C,KAAK,CAAC,QAAQ;QAAA;MAAA;IAAA;IAAA;MAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;MAAA,uBAKU,QAAQ,CAAC,CAAC,CAAC,WAAW;MAAA,uBAChD,KAAK,CAAC,QAAQ;MAAA;IAAA;EAAA;AAIvB;AAAC","ignoreList":[]}
|
|
@@ -128,6 +128,7 @@ export function VirtualFeed(props) {
|
|
|
128
128
|
let focusIndex = -1;
|
|
129
129
|
let fresh = [];
|
|
130
130
|
let restoring = false;
|
|
131
|
+
let restoreVersion = 0;
|
|
131
132
|
let restoreAgain = false;
|
|
132
133
|
let pendingAnnouncement = [];
|
|
133
134
|
let announceTimer;
|
|
@@ -206,30 +207,30 @@ export function VirtualFeed(props) {
|
|
|
206
207
|
* not: rows moved down would show empty space above the first item, and rows moved up would put the first items
|
|
207
208
|
* out of the scroll range's reach. The margin is the overscan, so the write lands before the engine draws there.
|
|
208
209
|
*/
|
|
209
|
-
const mayDefer = top => deferring() && Math.min(viewport.scrollTop, top) > OVERSCAN;
|
|
210
|
+
const mayDefer = (top, physicalTop) => deferring() && Math.min(physicalTop ?? viewport.scrollTop, top) > OVERSCAN;
|
|
210
211
|
/** Scrolls to `target`, within what the layout can reach, and returns the position the reader gets. */
|
|
211
|
-
const writeTop = (target, immediate) => {
|
|
212
|
-
const next = Math.min(Math.max(0, total() -
|
|
213
|
-
|
|
212
|
+
const writeTop = (target, immediate, height) => {
|
|
213
|
+
const next = Math.min(Math.max(0, total() - height), Math.max(0, target));
|
|
214
|
+
const from = viewport.scrollTop;
|
|
215
|
+
if (!immediate && mayDefer(next, from)) {
|
|
214
216
|
// The rows move instead; the scroll range stays the same, so the engine clamps nothing.
|
|
215
|
-
lastTop =
|
|
217
|
+
lastTop = from;
|
|
216
218
|
deferred = next - lastTop;
|
|
217
219
|
feed.style.height = `${total() - deferred}px`;
|
|
218
220
|
return next;
|
|
219
221
|
}
|
|
220
222
|
deferred = 0;
|
|
221
223
|
feed.style.height = `${total()}px`;
|
|
222
|
-
const from = viewport.scrollTop;
|
|
223
224
|
if (Math.abs(from - next) > 0.5) viewport.scrollTop = next;
|
|
224
225
|
lastTop = viewport.scrollTop;
|
|
225
226
|
if (Math.abs(lastTop - from) > 0.5) owedUntil = performance.now() + END_WAIT_MS;
|
|
226
227
|
return next;
|
|
227
228
|
};
|
|
228
229
|
let visibleKeys;
|
|
229
|
-
const reportVisible = () => {
|
|
230
|
+
const reportVisible = (top, height) => {
|
|
230
231
|
if (!props.onVisibleChange) return;
|
|
231
|
-
|
|
232
|
-
const bottom = top + viewport.clientHeight;
|
|
232
|
+
top ??= logicalTop();
|
|
233
|
+
const bottom = top + (height ?? viewport.clientHeight);
|
|
233
234
|
let first = -1;
|
|
234
235
|
let last = -1;
|
|
235
236
|
if (bottom > top && hi > lo) for (let index = indexAt(top); index < hi && offsetOf(index) < bottom; index++) {
|
|
@@ -252,9 +253,7 @@ export function VirtualFeed(props) {
|
|
|
252
253
|
last: list[last]
|
|
253
254
|
});
|
|
254
255
|
};
|
|
255
|
-
const updateRange = () => {
|
|
256
|
-
const top = logicalTop();
|
|
257
|
-
const height = viewport.clientHeight;
|
|
256
|
+
const updateRange = (top = logicalTop(), height = viewport.clientHeight) => {
|
|
258
257
|
const indices = [];
|
|
259
258
|
if (hi > lo) {
|
|
260
259
|
const start = indexAt(top - OVERSCAN);
|
|
@@ -268,7 +267,7 @@ export function VirtualFeed(props) {
|
|
|
268
267
|
renderRows(indices);
|
|
269
268
|
setTabStop(focusIndex >= lo && focusIndex < hi ? focusIndex : hi > lo ? indexAt(top + height - 1) : -1);
|
|
270
269
|
// Newly mounted rows still have estimates; report only after their heights are measured.
|
|
271
|
-
if (!restoring && !fresh.some(node => node.isConnected)) reportVisible();
|
|
270
|
+
if (!restoring && !fresh.some(node => node.isConnected)) reportVisible(top, height);
|
|
272
271
|
};
|
|
273
272
|
const measure = measured => {
|
|
274
273
|
let changed = false;
|
|
@@ -422,6 +421,8 @@ export function VirtualFeed(props) {
|
|
|
422
421
|
return;
|
|
423
422
|
}
|
|
424
423
|
restoring = true;
|
|
424
|
+
const restored = ++restoreVersion;
|
|
425
|
+
const height = viewport.clientHeight;
|
|
425
426
|
let target = 0;
|
|
426
427
|
let top = 0;
|
|
427
428
|
// Following the end shows the end of all items from now on, so later moves are judged against it.
|
|
@@ -431,9 +432,10 @@ export function VirtualFeed(props) {
|
|
|
431
432
|
restoreAgain = false;
|
|
432
433
|
recompute();
|
|
433
434
|
target = stick ? total() : offsetOf(anchor.index) - anchor.delta;
|
|
434
|
-
top =
|
|
435
|
-
|
|
436
|
-
|
|
435
|
+
top = Math.min(Math.max(0, total() - height), Math.max(0, target));
|
|
436
|
+
// Row heights do not depend on their translation or the feed's scroll position. Mount and measure the
|
|
437
|
+
// logical range first; writing the final geometry once avoids a layout flush on every correction pass.
|
|
438
|
+
updateRange(top, height);
|
|
437
439
|
if (pass === MEASURE_PASSES) break;
|
|
438
440
|
// Rows mounted here reach the ResizeObserver only next frame (its loop limit), so measure them now.
|
|
439
441
|
const mounted = fresh.filter(node => node.isConnected);
|
|
@@ -441,6 +443,8 @@ export function VirtualFeed(props) {
|
|
|
441
443
|
if (measure(mounted.map(node => [node, node.getBoundingClientRect().height]))) restoreAgain = true;
|
|
442
444
|
if (!restoreAgain) break;
|
|
443
445
|
}
|
|
446
|
+
top = writeTop(target, immediate, height);
|
|
447
|
+
setVersion(value => value + 1);
|
|
444
448
|
// A position the layout cannot reach, above its start or past its end, becomes the one the reader sees, so a
|
|
445
449
|
// page that loads there later keeps it instead of moving to it.
|
|
446
450
|
if (!stick && Math.abs(top - target) > 0.5) anchor = {
|
|
@@ -450,8 +454,9 @@ export function VirtualFeed(props) {
|
|
|
450
454
|
} finally {
|
|
451
455
|
restoring = false;
|
|
452
456
|
}
|
|
453
|
-
checkEdges();
|
|
454
|
-
|
|
457
|
+
checkEdges(lastTop + deferred, height);
|
|
458
|
+
// A synchronous edge load can restore another window; that restore already reports its final geometry.
|
|
459
|
+
if (restored === restoreVersion) reportVisible(lastTop + deferred, height);
|
|
455
460
|
};
|
|
456
461
|
|
|
457
462
|
/**
|
|
@@ -623,10 +628,10 @@ export function VirtualFeed(props) {
|
|
|
623
628
|
};
|
|
624
629
|
|
|
625
630
|
/** Grows the window or asks for more items when the reader nears an edge. */
|
|
626
|
-
const checkEdges = () => {
|
|
631
|
+
const checkEdges = (top, height) => {
|
|
627
632
|
if (hi <= lo || restoring) return;
|
|
628
|
-
|
|
629
|
-
|
|
633
|
+
top ??= logicalTop();
|
|
634
|
+
height ??= viewport.clientHeight;
|
|
630
635
|
// Rows measured taller than estimated can grow the window past the cap without any edge moving.
|
|
631
636
|
if (total() > MAX_WINDOW && trimWindow(top + height / 2 > total() / 2 ? "start" : "end")) {
|
|
632
637
|
restore(true);
|