gridsmith-ui 0.30.1 → 0.30.2
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/CHANGELOG.md +21 -1
- package/dist/chat.js +14 -8
- package/dist/chat.js.map +1 -1
- package/dist/{chunk-R5QXMNW7.js → chunk-4HJDOZ2M.js} +107 -17
- package/dist/chunk-4HJDOZ2M.js.map +1 -0
- package/dist/{chunk-SJZWEBHL.js → chunk-ACLKDE5W.js} +6 -5
- package/dist/chunk-ACLKDE5W.js.map +1 -0
- package/dist/{chunk-OVHBQT3Z.js → chunk-BZRZENBS.js} +4 -4
- package/dist/{chunk-OVHBQT3Z.js.map → chunk-BZRZENBS.js.map} +1 -1
- package/dist/{chunk-ISONVOA7.js → chunk-HVGHGBKV.js} +4 -5
- package/dist/chunk-HVGHGBKV.js.map +1 -0
- package/dist/{chunk-KMKBOTFR.js → chunk-K6IDOCGE.js} +7 -9
- package/dist/chunk-K6IDOCGE.js.map +1 -0
- package/dist/{chunk-ULCACQSA.js → chunk-MIUSSYVE.js} +3 -3
- package/dist/{chunk-ULCACQSA.js.map → chunk-MIUSSYVE.js.map} +1 -1
- package/dist/{chunk-T52LAFKG.js → chunk-SIWERRP2.js} +7 -8
- package/dist/chunk-SIWERRP2.js.map +1 -0
- package/dist/{chunk-OX3NNMWG.js → chunk-SQHKC4HA.js} +8 -5
- package/dist/chunk-SQHKC4HA.js.map +1 -0
- package/dist/{chunk-SLRTSBCJ.js → chunk-USHW523V.js} +31 -10
- package/dist/chunk-USHW523V.js.map +1 -0
- package/dist/{chunk-UDJOIVKQ.js → chunk-WWN6CQKI.js} +34 -4
- package/dist/chunk-WWN6CQKI.js.map +1 -0
- package/dist/{chunk-NEUWZUK6.js → chunk-ZASGFL5D.js} +3 -3
- package/dist/{chunk-NEUWZUK6.js.map → chunk-ZASGFL5D.js.map} +1 -1
- package/dist/{chunk-IELIF4PJ.js → chunk-ZCDA74RQ.js} +3 -3
- package/dist/{chunk-IELIF4PJ.js.map → chunk-ZCDA74RQ.js.map} +1 -1
- package/dist/data-grid.js +6 -8
- package/dist/data-grid.js.map +1 -1
- package/dist/editor-mentions.js +2 -3
- package/dist/editor-mentions.js.map +1 -1
- package/dist/editor.js +2 -4
- package/dist/editor.js.map +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +44 -38
- package/dist/index.js.map +1 -1
- package/dist/kanban.js +7 -9
- package/dist/kanban.js.map +1 -1
- package/dist/resizable.js +6 -8
- package/dist/resizable.js.map +1 -1
- package/dist/virtualized.js +6 -8
- package/dist/virtualized.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-HTXP5BMM.js +0 -38
- package/dist/chunk-HTXP5BMM.js.map +0 -1
- package/dist/chunk-ISONVOA7.js.map +0 -1
- package/dist/chunk-KMKBOTFR.js.map +0 -1
- package/dist/chunk-OX3NNMWG.js.map +0 -1
- package/dist/chunk-R5QXMNW7.js.map +0 -1
- package/dist/chunk-SJZWEBHL.js.map +0 -1
- package/dist/chunk-SLRTSBCJ.js.map +0 -1
- package/dist/chunk-T52LAFKG.js.map +0 -1
- package/dist/chunk-UDJOIVKQ.js.map +0 -1
- package/dist/chunk-WIUGPZOH.js +0 -88
- package/dist/chunk-WIUGPZOH.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
# gridsmith-ui changelog
|
|
2
2
|
|
|
3
|
-
## Unreleased (0.30.
|
|
3
|
+
## Unreleased (0.30.2)
|
|
4
|
+
|
|
5
|
+
**Added.**
|
|
6
|
+
- **ScrollArea's name.** `aria-label` names the area for the Tab stop it becomes while it scrolls with nothing in it to Tab to ("Release notes"; default "Scrollable content").
|
|
7
|
+
- **Tabs' name.** `aria-label` names the tab list, and on a phone the Dropdown the tabs collapse to ("Settings sections"). The Dropdown is called "Contents" without one, GOV.UK's title for the same list of sections. SettingsLayout passes its own name.
|
|
8
|
+
|
|
9
|
+
**Fixed.**
|
|
10
|
+
- **Load more's last load hands focus on.** The last load took the button with it, so focus fell to the page, by Load more or in an infinite list. Focus now goes to the first row that load brought: its first control, else the row itself, so the person reads on where they asked to. A load before the last still keeps focus on the button.
|
|
11
|
+
- **ScrollArea, Timeline's row, CodeBlock and a markdown table are in the keyboard's reach.** Each scrolled with nothing in it to Tab to, so a keyboard couldn't scroll it in Safari, and axe flagged it. Each is now a named Tab stop while it scrolls and holds nothing to Tab to, drawn with the inset ring 0.30.1 gave the other scroll areas: ScrollArea by its name, Timeline's horizontal row "Timeline", a CodeBlock's code "Code" while it doesn't wrap, and a markdown table's frame "Table". MarkdownContent's and the chat's code blocks are CodeBlocks too.
|
|
12
|
+
- **Tabs collapsed to a Dropdown on a phone has a name.** It had none, and nor did its list.
|
|
13
|
+
- **An overlay opened from one that was open from the start gives focus back.** A page loaded with its preview open, whose "Edit details" swaps the preview for an edit drawer, left focus on the page when the drawer closed. The last resort now counts an overlay's own address closing back to its page as the same page, and ends at the page's `<main>`: its first control, else its heading, else `<main>` itself, where the skip link's jump goes. An overlay in a portal leaves no place of its own once it has gone.
|
|
14
|
+
- **A focus rule's timer never throws after its page has gone.** A test's page torn down within the last resort's 200 ms wait raised "document is not defined" in the test run.
|
|
15
|
+
|
|
16
|
+
### Upgrade note for agents (0.30.1 → 0.30.2)
|
|
17
|
+
|
|
18
|
+
`^0.30.0` covers 0.30.2, so `npm update gridsmith-ui` brings it in. Nothing in an app's code changes, and the theme's tokens need no regenerating. What to check:
|
|
19
|
+
- **The Tab order.** A ScrollArea, a horizontal Timeline, a CodeBlock that doesn't wrap and a markdown table wider than its column are each a Tab stop while they scroll with nothing in them to Tab to. A test that counts Tab presses through such a page counts one more for each.
|
|
20
|
+
- **Names.** Give a ScrollArea `aria-label` for what it holds, and a Tabs that collapses to a Dropdown on a phone `aria-label` for what its tabs choose between. A test that found Tabs' phone Dropdown by its chosen value finds it by role and name now (`getByRole('button', { name: 'Contents' })`, or the name you gave).
|
|
21
|
+
- **Where focus goes.** After Load more's last load, focus is on the first new row, or its first control. After an overlay with no opener of its own closes back to its page's address, focus is in `<main>`. A test that expected focus on the page in either case finds it there.
|
|
22
|
+
|
|
23
|
+
## 0.30.1 — 16 October 2026
|
|
4
24
|
|
|
5
25
|
**Added.**
|
|
6
26
|
- **VirtualizedList's name.** `aria-label` names the list for the Tab stop it becomes while it scrolls with nothing in it to Tab to ("Activity log"; default "List").
|
package/dist/chat.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Divider, CodeBlock, Link } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-
|
|
2
|
+
import { Divider, CodeBlock, Link } from './chunk-SQHKC4HA.js';
|
|
3
|
+
import './chunk-BZRZENBS.js';
|
|
4
|
+
import { useKeyboardScroll } from './chunk-ACLKDE5W.js';
|
|
5
|
+
import './chunk-ZCDA74RQ.js';
|
|
6
|
+
import './chunk-WWN6CQKI.js';
|
|
6
7
|
import './chunk-L6HWACK7.js';
|
|
7
8
|
import './chunk-7Q46JXSK.js';
|
|
8
|
-
import './chunk-
|
|
9
|
-
import { cn } from './chunk-YL5KD5RC.js';
|
|
10
|
-
import { memo, Children, isValidElement } from 'react';
|
|
9
|
+
import './chunk-4HJDOZ2M.js';
|
|
10
|
+
import { cn, FOCUS_INSET } from './chunk-YL5KD5RC.js';
|
|
11
|
+
import { memo, useState, Children, isValidElement } from 'react';
|
|
11
12
|
import Markdown from 'react-markdown';
|
|
12
13
|
import remarkGfm from 'remark-gfm';
|
|
13
14
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -21,6 +22,11 @@ function codeFromPre(children) {
|
|
|
21
22
|
const code = Children.toArray(raw).map((c) => typeof c === "string" || typeof c === "number" ? String(c) : "").join("").replace(/\n$/, "");
|
|
22
23
|
return { code, language };
|
|
23
24
|
}
|
|
25
|
+
function TableFrame(props) {
|
|
26
|
+
const [frame, setFrame] = useState(null);
|
|
27
|
+
useKeyboardScroll(frame, "Table", true, false, "x");
|
|
28
|
+
return /* @__PURE__ */ jsx("div", { ref: setFrame, className: cn("overflow-x-auto rounded-[var(--ds-radius-md)] border-[length:var(--ds-border-width)] border-[var(--ds-border-default)]", FOCUS_INSET), children: /* @__PURE__ */ jsx("table", { className: "w-full border-collapse text-sm", ...props }) });
|
|
29
|
+
}
|
|
24
30
|
var components = {
|
|
25
31
|
p: ({ node: _n, ...props }) => /* @__PURE__ */ jsx("p", { ...props }),
|
|
26
32
|
a: ({ node: _n, href = "#", children, ...props }) => /* @__PURE__ */ jsx(
|
|
@@ -67,7 +73,7 @@ var components = {
|
|
|
67
73
|
hr: () => /* @__PURE__ */ jsx(Divider, {}),
|
|
68
74
|
strong: ({ node: _n, ...props }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold", ...props }),
|
|
69
75
|
// Wide content scrolls inside its own container; the page never scrolls sideways.
|
|
70
|
-
table: ({ node: _n, ...props }) => /* @__PURE__ */ jsx(
|
|
76
|
+
table: ({ node: _n, ...props }) => /* @__PURE__ */ jsx(TableFrame, { ...props }),
|
|
71
77
|
thead: ({ node: _n, ...props }) => /* @__PURE__ */ jsx("thead", { className: "bg-[var(--ds-bg-muted)]", ...props }),
|
|
72
78
|
th: ({ node: _n, ...props }) => /* @__PURE__ */ jsx("th", { className: "px-ds-3 py-ds-2 text-left text-xs font-semibold uppercase tracking-wide text-[var(--ds-text-secondary)]", ...props }),
|
|
73
79
|
td: ({ node: _n, ...props }) => /* @__PURE__ */ jsx("td", { className: "border-t-[length:var(--ds-border-width)] border-[var(--ds-border-subtle)] px-ds-3 py-ds-2 align-top", ...props }),
|
package/dist/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../showcase/src/components/MarkdownContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,UAAA,GAAa,CAAC,IAAA,KAAiB,kBAAA,CAAmB,KAAK,IAAI,CAAA;AAGjE,SAAS,YA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,QAAA,EAAQ,IAAA,EACnE,QAAA,EACH;AAAA;AAAA,GACF;AAEJ,CAAC,CAAA;AAIM,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC9B","file":"chat.js","sourcesContent":["import { memo, Children, isValidElement, type ComponentProps, type ReactElement, type ReactNode } from \"react\";\nimport Markdown, { type Components } from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport { cn } from \"../lib/utils\";\nimport { CodeBlock } from \"./CodeBlock\";\nimport { Link } from \"./Link\";\nimport { Divider } from \"./Divider\";\n\nexport interface MarkdownContentProps {\n /** The markdown source — a model's reply, an API's description. Raw HTML in it is never rendered. */\n children: string;\n /** Show a caret at the end of the last block while the source is still arriving. Pass a message's status === \"streaming\" from ChatMessageList's renderContent. */\n streaming?: boolean;\n className?: string;\n}\n\nconst isExternal = (href: string) => /^(https?:)?\\/\\//i.test(href);\n\n/** Pull the code string and language out of the single <code> child react-markdown gives a <pre>. */\nfunction codeFromPre(children: ReactNode): { code: string; language?: string } {\n const only = Children.toArray(children).find(isValidElement) as ReactElement<{ className?: string; children?: ReactNode }> | undefined;\n const cls = only?.props.className ?? \"\";\n const language = /language-([\\w+-]+)/.exec(cls)?.[1];\n const raw = only ? only.props.children : children;\n const code = Children.toArray(raw)\n .map((c) => (typeof c === \"string\" || typeof c === \"number\" ? String(c) : \"\"))\n .join(\"\")\n .replace(/\\n$/, \"\");\n return { code, language };\n}\n\ntype P<T extends keyof React.JSX.IntrinsicElements> = ComponentProps<T> & { node?: unknown };\n\nconst components: Components = {\n p: ({ node: _n, ...props }: P<\"p\">) => <p {...props} />,\n a: ({ node: _n, href = \"#\", children, ...props }: P<\"a\">) => (\n <Link\n href={href}\n underline=\"always\"\n {...(isExternal(href) ? { target: \"_blank\", rel: \"noopener noreferrer\" } : {})}\n {...(props as Record<string, unknown>)}\n >\n {children}\n </Link>\n ),\n pre: ({ node: _n, children }: P<\"pre\">) => {\n const { code, language } = codeFromPre(children);\n return <CodeBlock code={code} language={language} />;\n },\n code: ({ node: _n, className, children, ...props }: P<\"code\">) => (\n <code\n className={cn(\n \"rounded-[var(--ds-radius-sm)] bg-[var(--ds-bg-muted)] px-ds-1 py-[1px] font-[family-name:var(--ds-font-mono)] text-[0.9em]\",\n className,\n )}\n {...props}\n >\n {children}\n </code>\n ),\n ul: ({ node: _n, ...props }: P<\"ul\">) => <ul className=\"list-disc space-y-ds-1 pl-ds-5\" {...props} />,\n ol: ({ node: _n, ...props }: P<\"ol\">) => <ol className=\"list-decimal space-y-ds-1 pl-ds-5\" {...props} />,\n li: ({ node: _n, ...props }: P<\"li\">) => <li {...props} />,\n h1: ({ node: _n, ...props }: P<\"h1\">) => <h3 className=\"text-base font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h2: ({ node: _n, ...props }: P<\"h2\">) => <h3 className=\"text-base font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h3: ({ node: _n, ...props }: P<\"h3\">) => <h4 className=\"text-sm font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h4: ({ node: _n, ...props }: P<\"h4\">) => <h4 className=\"text-sm font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h5: ({ node: _n, ...props }: P<\"h5\">) => <h5 className=\"text-sm font-medium text-[var(--ds-text-primary)]\" {...props} />,\n h6: ({ node: _n, ...props }: P<\"h6\">) => <h6 className=\"text-sm font-medium text-[var(--ds-text-secondary)]\" {...props} />,\n blockquote: ({ node: _n, ...props }: P<\"blockquote\">) => (\n <blockquote\n className=\"border-l-[length:calc(var(--ds-border-width)*2)] border-[var(--ds-border-default)] pl-ds-3 text-[var(--ds-text-secondary)]\"\n {...props}\n />\n ),\n hr: () => <Divider />,\n strong: ({ node: _n, ...props }: P<\"strong\">) => <strong className=\"font-semibold\" {...props} />,\n // Wide content scrolls inside its own container; the page never scrolls sideways.\n table: ({ node: _n, ...props }: P<\"table\">) => (\n <div className=\"overflow-x-auto rounded-[var(--ds-radius-md)] border-[length:var(--ds-border-width)] border-[var(--ds-border-default)]\">\n <table className=\"w-full border-collapse text-sm\" {...props} />\n </div>\n ),\n thead: ({ node: _n, ...props }: P<\"thead\">) => <thead className=\"bg-[var(--ds-bg-muted)]\" {...props} />,\n th: ({ node: _n, ...props }: P<\"th\">) => (\n <th className=\"px-ds-3 py-ds-2 text-left text-xs font-semibold uppercase tracking-wide text-[var(--ds-text-secondary)]\" {...props} />\n ),\n td: ({ node: _n, ...props }: P<\"td\">) => (\n <td className=\"border-t-[length:var(--ds-border-width)] border-[var(--ds-border-subtle)] px-ds-3 py-ds-2 align-top\" {...props} />\n ),\n img: ({ node: _n, alt = \"\", ...props }: P<\"img\">) => <img alt={alt} className=\"max-w-full rounded-[var(--ds-radius-md)]\" {...props} />,\n};\n\n/**\n * Renders markdown (GitHub flavour: tables, task lists, strikethrough) with\n * Gridsmith primitives: fenced code becomes CodeBlock, links become Link,\n * a rule becomes Divider, everything else is token-styled markup. Raw HTML is\n * not rendered — the source is untrusted by default. Memoised: an unchanged\n * message never re-parses; a streaming message re-parses only its own string.\n *\n * Lives on the `gridsmith-ui/chat` entry point (react-markdown and remark-gfm\n * are optional peers), so apps without a chat never load a markdown parser.\n */\n// The caret is a pseudo-element on the last block, so it sits at the end of the\n// last line of text instead of on a line of its own below a block element.\nconst STREAMING_CARET = cn(\n \"[&>:last-child]:after:content-['▍'] [&>:last-child]:after:ml-ds-0.5\",\n \"[&>:last-child]:after:text-[var(--ds-accent-ink)] [&>:last-child]:after:animate-pulse\",\n);\n\nconst Memoised = memo(function MarkdownContentInner({ children, streaming, className }: MarkdownContentProps) {\n return (\n <div\n className={cn(\"space-y-ds-4 text-sm leading-relaxed text-[var(--ds-text-primary)]\", streaming && STREAMING_CARET, className)}\n data-markdown=\"\"\n data-streaming={streaming || undefined}\n >\n <Markdown remarkPlugins={[remarkGfm]} components={components} skipHtml>\n {children}\n </Markdown>\n </div>\n );\n});\n\n// A plain function export so the registry extractor (which reads `export function`)\n// documents it; the memo above still skips re-parsing unchanged sources.\nexport function MarkdownContent(props: MarkdownContentProps) {\n return <Memoised {...props} />;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../showcase/src/components/MarkdownContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAiBA,IAAM,UAAA,GAAa,CAAC,IAAA,KAAiB,kBAAA,CAAmB,KAAK,IAAI,CAAA;AAGjE,SAAS,YAAY,QAAA,EAA0D;AAC7E,EAAA,MAAM,OAAO,QAAA,CAAS,OAAA,CAAQ,QAAQ,CAAA,CAAE,KAAK,cAAc,CAAA;AAC3D,EAAA,MAAM,GAAA,GAAM,IAAA,EAAM,KAAA,CAAM,SAAA,IAAa,EAAA;AACrC,EAAA,MAAM,QAAA,GAAW,oBAAA,CAAqB,IAAA,CAAK,GAAG,IAAI,CAAC,CAAA;AACnD,EAAA,MAAM,GAAA,GAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,QAAA,GAAW,QAAA;AACzC,EAAA,MAAM,IAAA,GAAO,QAAA,CAAS,OAAA,CAAQ,GAAG,CAAA,CAC9B,IAAI,CAAC,CAAA,KAAO,OAAO,CAAA,KAAM,QAAA,IAAY,OAAO,MAAM,QAAA,GAAW,MAAA,CAAO,CAAC,CAAA,GAAI,EAAG,CAAA,CAC5E,KAAK,EAAE,CAAA,CACP,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AACpB,EAAA,OAAO,EAAE,MAAM,QAAA,EAAS;AAC1B;AAMA,SAAS,WAAW,KAAA,EAAgC;AAClD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAgC,IAAI,CAAA;AAC9D,EAAA,iBAAA,CAAkB,KAAA,EAAO,OAAA,EAAS,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAClD,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,QAAA,EAAU,WAAW,EAAA,CAA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CAAC,EAAE,IAAA,EAAM,EAAA,EAAI,MAAM,EAAA,EAAI,GAAG,KAAA,EAAM,yBAAiB,KAAA,EAAA,EAAI,GAAA,EAAU,SAAA,EAAU,0CAAA,EAA4C,GAAG,KAAA,EAAO;AACtI,CAAA;AAcA,IAAM,eAAA,GAAkB,EAAA;AAAA,EACtB,0EAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,QAAA,GAAW,KAAK,SAAS,oBAAA,CAAqB,EAAE,QAAA,EAAU,SAAA,EAAW,WAAU,EAAyB;AAC5G,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,EAAA,CAAG,oEAAA,EAAsE,SAAA,IAAa,iBAAiB,SAAS,CAAA;AAAA,MAC3H,eAAA,EAAc,EAAA;AAAA,MACd,kBAAgB,SAAA,IAAa,MAAA;AAAA,MAE7B,QAAA,kBAAA,GAAA,CAAC,YAAS,aAAA,EAAe,CAAC,SAAS,CAAA,EAAG,UAAA,EAAwB,QAAA,EAAQ,IAAA,EACnE,QAAA,EACH;AAAA;AAAA,GACF;AAEJ,CAAC,CAAA;AAIM,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC9B","file":"chat.js","sourcesContent":["import { memo, Children, isValidElement, useState, type ComponentProps, type ReactElement, type ReactNode } from \"react\";\nimport Markdown, { type Components } from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport { cn, FOCUS_INSET } from \"../lib/utils\";\nimport { useKeyboardScroll } from \"../lib/use-keyboard-scroll\";\nimport { CodeBlock } from \"./CodeBlock\";\nimport { Link } from \"./Link\";\nimport { Divider } from \"./Divider\";\n\nexport interface MarkdownContentProps {\n /** The markdown source — a model's reply, an API's description. Raw HTML in it is never rendered. */\n children: string;\n /** Show a caret at the end of the last block while the source is still arriving. Pass a message's status === \"streaming\" from ChatMessageList's renderContent. */\n streaming?: boolean;\n className?: string;\n}\n\nconst isExternal = (href: string) => /^(https?:)?\\/\\//i.test(href);\n\n/** Pull the code string and language out of the single <code> child react-markdown gives a <pre>. */\nfunction codeFromPre(children: ReactNode): { code: string; language?: string } {\n const only = Children.toArray(children).find(isValidElement) as ReactElement<{ className?: string; children?: ReactNode }> | undefined;\n const cls = only?.props.className ?? \"\";\n const language = /language-([\\w+-]+)/.exec(cls)?.[1];\n const raw = only ? only.props.children : children;\n const code = Children.toArray(raw)\n .map((c) => (typeof c === \"string\" || typeof c === \"number\" ? String(c) : \"\"))\n .join(\"\")\n .replace(/\\n$/, \"\");\n return { code, language };\n}\n\n/**\n * A table in its own frame, which scrolls sideways when the table is wider; with nothing in it to Tab to, the frame is\n * a Tab stop while it scrolls, so a keyboard can scroll it too (Sprint 25.30 item 2).\n */\nfunction TableFrame(props: ComponentProps<\"table\">) {\n const [frame, setFrame] = useState<HTMLDivElement | null>(null);\n useKeyboardScroll(frame, \"Table\", true, false, \"x\");\n return (\n <div ref={setFrame} className={cn(\"overflow-x-auto rounded-[var(--ds-radius-md)] border-[length:var(--ds-border-width)] border-[var(--ds-border-default)]\", FOCUS_INSET)}>\n <table className=\"w-full border-collapse text-sm\" {...props} />\n </div>\n );\n}\n\ntype P<T extends keyof React.JSX.IntrinsicElements> = ComponentProps<T> & { node?: unknown };\n\nconst components: Components = {\n p: ({ node: _n, ...props }: P<\"p\">) => <p {...props} />,\n a: ({ node: _n, href = \"#\", children, ...props }: P<\"a\">) => (\n <Link\n href={href}\n underline=\"always\"\n {...(isExternal(href) ? { target: \"_blank\", rel: \"noopener noreferrer\" } : {})}\n {...(props as Record<string, unknown>)}\n >\n {children}\n </Link>\n ),\n pre: ({ node: _n, children }: P<\"pre\">) => {\n const { code, language } = codeFromPre(children);\n return <CodeBlock code={code} language={language} />;\n },\n code: ({ node: _n, className, children, ...props }: P<\"code\">) => (\n <code\n className={cn(\n \"rounded-[var(--ds-radius-sm)] bg-[var(--ds-bg-muted)] px-ds-1 py-[1px] font-[family-name:var(--ds-font-mono)] text-[0.9em]\",\n className,\n )}\n {...props}\n >\n {children}\n </code>\n ),\n ul: ({ node: _n, ...props }: P<\"ul\">) => <ul className=\"list-disc space-y-ds-1 pl-ds-5\" {...props} />,\n ol: ({ node: _n, ...props }: P<\"ol\">) => <ol className=\"list-decimal space-y-ds-1 pl-ds-5\" {...props} />,\n li: ({ node: _n, ...props }: P<\"li\">) => <li {...props} />,\n h1: ({ node: _n, ...props }: P<\"h1\">) => <h3 className=\"text-base font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h2: ({ node: _n, ...props }: P<\"h2\">) => <h3 className=\"text-base font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h3: ({ node: _n, ...props }: P<\"h3\">) => <h4 className=\"text-sm font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h4: ({ node: _n, ...props }: P<\"h4\">) => <h4 className=\"text-sm font-semibold text-[var(--ds-text-primary)]\" {...props} />,\n h5: ({ node: _n, ...props }: P<\"h5\">) => <h5 className=\"text-sm font-medium text-[var(--ds-text-primary)]\" {...props} />,\n h6: ({ node: _n, ...props }: P<\"h6\">) => <h6 className=\"text-sm font-medium text-[var(--ds-text-secondary)]\" {...props} />,\n blockquote: ({ node: _n, ...props }: P<\"blockquote\">) => (\n <blockquote\n className=\"border-l-[length:calc(var(--ds-border-width)*2)] border-[var(--ds-border-default)] pl-ds-3 text-[var(--ds-text-secondary)]\"\n {...props}\n />\n ),\n hr: () => <Divider />,\n strong: ({ node: _n, ...props }: P<\"strong\">) => <strong className=\"font-semibold\" {...props} />,\n // Wide content scrolls inside its own container; the page never scrolls sideways.\n table: ({ node: _n, ...props }: P<\"table\">) => <TableFrame {...props} />,\n thead: ({ node: _n, ...props }: P<\"thead\">) => <thead className=\"bg-[var(--ds-bg-muted)]\" {...props} />,\n th: ({ node: _n, ...props }: P<\"th\">) => (\n <th className=\"px-ds-3 py-ds-2 text-left text-xs font-semibold uppercase tracking-wide text-[var(--ds-text-secondary)]\" {...props} />\n ),\n td: ({ node: _n, ...props }: P<\"td\">) => (\n <td className=\"border-t-[length:var(--ds-border-width)] border-[var(--ds-border-subtle)] px-ds-3 py-ds-2 align-top\" {...props} />\n ),\n img: ({ node: _n, alt = \"\", ...props }: P<\"img\">) => <img alt={alt} className=\"max-w-full rounded-[var(--ds-radius-md)]\" {...props} />,\n};\n\n/**\n * Renders markdown (GitHub flavour: tables, task lists, strikethrough) with\n * Gridsmith primitives: fenced code becomes CodeBlock, links become Link,\n * a rule becomes Divider, everything else is token-styled markup. Raw HTML is\n * not rendered — the source is untrusted by default. Memoised: an unchanged\n * message never re-parses; a streaming message re-parses only its own string.\n *\n * Lives on the `gridsmith-ui/chat` entry point (react-markdown and remark-gfm\n * are optional peers), so apps without a chat never load a markdown parser.\n */\n// The caret is a pseudo-element on the last block, so it sits at the end of the\n// last line of text instead of on a line of its own below a block element.\nconst STREAMING_CARET = cn(\n \"[&>:last-child]:after:content-['▍'] [&>:last-child]:after:ml-ds-0.5\",\n \"[&>:last-child]:after:text-[var(--ds-accent-ink)] [&>:last-child]:after:animate-pulse\",\n);\n\nconst Memoised = memo(function MarkdownContentInner({ children, streaming, className }: MarkdownContentProps) {\n return (\n <div\n className={cn(\"space-y-ds-4 text-sm leading-relaxed text-[var(--ds-text-primary)]\", streaming && STREAMING_CARET, className)}\n data-markdown=\"\"\n data-streaming={streaming || undefined}\n >\n <Markdown remarkPlugins={[remarkGfm]} components={components} skipHtml>\n {children}\n </Markdown>\n </div>\n );\n});\n\n// A plain function export so the registry extractor (which reads `export function`)\n// documents it; the memo above still skips re-parsing unchanged sources.\nexport function MarkdownContent(props: MarkdownContentProps) {\n return <Memoised {...props} />;\n}\n"]}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useRef, useInsertionEffect, useEffect, useCallback, useState, useMemo, useLayoutEffect } from 'react';
|
|
2
|
+
import { useRef, useLayoutEffect, useInsertionEffect, useEffect, useCallback, useState, useMemo } from 'react';
|
|
4
3
|
import { flushSync } from 'react-dom';
|
|
5
4
|
|
|
5
|
+
// ../../showcase/src/lib/focus.ts
|
|
6
|
+
function useLatest(value) {
|
|
7
|
+
const ref = useRef(value);
|
|
8
|
+
useLayoutEffect(() => {
|
|
9
|
+
ref.current = value;
|
|
10
|
+
});
|
|
11
|
+
return ref;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ../../showcase/src/lib/focus.ts
|
|
6
15
|
var FOCUSABLE = 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"]), [contenteditable]:not([contenteditable="false"])';
|
|
7
16
|
var FIELD = "input, select, textarea, [contenteditable='true']";
|
|
8
17
|
var CONTROL_ANCESTOR = 'a[href], button, summary, label, [role="button"], [role="link"], [role="option"], [role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="tab"], [role="treeitem"], [role="row"], [role="gridcell"], [role="checkbox"], [role="radio"], [role="switch"]';
|
|
@@ -132,14 +141,19 @@ function placesOf(el) {
|
|
|
132
141
|
return places;
|
|
133
142
|
}
|
|
134
143
|
function landLastResort(places, closing) {
|
|
135
|
-
const at = places.findIndex((p) => p.box.isConnected);
|
|
136
|
-
if (at < 0) return false;
|
|
137
|
-
const { box, prev, next } = places[at];
|
|
138
|
-
const kids = Array.from(box.children);
|
|
139
|
-
const from = prev?.parentElement === box ? kids.indexOf(prev) + 1 : 0;
|
|
140
|
-
const to = next?.parentElement === box ? kids.indexOf(next) : kids.length;
|
|
141
|
-
const areas = [kids.slice(from, Math.max(from, to)), ...places.slice(at).map((p) => [p.box])];
|
|
142
144
|
const counts = (el) => !closing?.contains(el);
|
|
145
|
+
const areas = [];
|
|
146
|
+
const at = places.findIndex((p) => p.box.isConnected);
|
|
147
|
+
if (at >= 0) {
|
|
148
|
+
const { box, prev, next } = places[at];
|
|
149
|
+
const kids = Array.from(box.children);
|
|
150
|
+
const from = prev?.parentElement === box ? kids.indexOf(prev) + 1 : 0;
|
|
151
|
+
const to = next?.parentElement === box ? kids.indexOf(next) : kids.length;
|
|
152
|
+
areas.push(kids.slice(from, Math.max(from, to)), ...places.slice(at).map((p) => [p.box]));
|
|
153
|
+
}
|
|
154
|
+
const main = document.querySelector('main, [role="main"]');
|
|
155
|
+
const mainCounts = !!main && counts(main) && isRendered(main);
|
|
156
|
+
if (mainCounts) areas.push([main]);
|
|
143
157
|
for (const area of areas) {
|
|
144
158
|
const stop = area.flatMap((a) => [...isTabStop(a) ? [a] : [], ...tabStops(a)]).find(counts);
|
|
145
159
|
if (stop) {
|
|
@@ -149,7 +163,7 @@ function landLastResort(places, closing) {
|
|
|
149
163
|
const heading = area.flatMap((a) => [...a.matches(HEADING) ? [a] : [], ...a.querySelectorAll(HEADING)]).find((h) => h instanceof HTMLElement && isRendered(h) && counts(h));
|
|
150
164
|
if (heading && focusForTheMoment(heading)) return true;
|
|
151
165
|
}
|
|
152
|
-
return
|
|
166
|
+
return mainCounts && focusForTheMoment(main);
|
|
153
167
|
}
|
|
154
168
|
function rememberFocus(el, { ignoreRoute = false } = {}) {
|
|
155
169
|
const { href, pathname } = location;
|
|
@@ -198,6 +212,7 @@ function rememberFocus(el, { ignoreRoute = false } = {}) {
|
|
|
198
212
|
const neighbour = () => inRow(byKey(keyOf(before)) ?? before) || inRow(byKey(keyOf(after)) ?? after) || !!list?.isConnected && land(tabStops(list)[0]);
|
|
199
213
|
const lastResort = () => {
|
|
200
214
|
setTimeout(() => {
|
|
215
|
+
if (typeof document === "undefined") return;
|
|
201
216
|
const active = document.activeElement;
|
|
202
217
|
if (active && active !== document.body && active.isConnected || pageChanged()) return;
|
|
203
218
|
landLastResort(places);
|
|
@@ -224,7 +239,7 @@ function rememberFocus(el, { ignoreRoute = false } = {}) {
|
|
|
224
239
|
function stop() {
|
|
225
240
|
observer.disconnect();
|
|
226
241
|
clearTimeout(timer);
|
|
227
|
-
document.removeEventListener("focusin", onFocusIn, true);
|
|
242
|
+
if (typeof document !== "undefined") document.removeEventListener("focusin", onFocusIn, true);
|
|
228
243
|
unwatch = null;
|
|
229
244
|
}
|
|
230
245
|
observer.observe(list, { childList: true });
|
|
@@ -312,8 +327,9 @@ function rememberOpener(active, root) {
|
|
|
312
327
|
el: null,
|
|
313
328
|
restore() {
|
|
314
329
|
setTimeout(() => {
|
|
330
|
+
if (typeof document === "undefined") return;
|
|
315
331
|
const now = document.activeElement;
|
|
316
|
-
if (now && now !== document.body && now.isConnected && !root.contains(now) || location.pathname !== pathname) return;
|
|
332
|
+
if (now && now !== document.body && now.isConnected && !root.contains(now) || location.pathname !== pathname && !pathAbove(location.pathname, pathname)) return;
|
|
317
333
|
landLastResort(places, root);
|
|
318
334
|
}, LAST_RESORT_MS);
|
|
319
335
|
return false;
|
|
@@ -398,7 +414,8 @@ function focusAfterSelfRemoval(control, { item, group, to } = {}) {
|
|
|
398
414
|
within.focus();
|
|
399
415
|
return document.activeElement === within;
|
|
400
416
|
};
|
|
401
|
-
const
|
|
417
|
+
const landTo = (el) => land(el) || !!el && el.isConnected && !isTabStop(el) && isRendered(el) && focusForTheMoment(el);
|
|
418
|
+
const place = () => landTo(typeof to === "function" ? to() : to) || land(sameBefore) || before.some(land) || land(sameAfter) || after.some(land) || landOnGroup();
|
|
402
419
|
if (typeof MutationObserver === "undefined") return () => {
|
|
403
420
|
};
|
|
404
421
|
const observer = new MutationObserver(() => {
|
|
@@ -413,7 +430,7 @@ function focusAfterSelfRemoval(control, { item, group, to } = {}) {
|
|
|
413
430
|
function stop() {
|
|
414
431
|
observer.disconnect();
|
|
415
432
|
clearTimeout(timer);
|
|
416
|
-
document.removeEventListener("focusin", onFocusIn, true);
|
|
433
|
+
if (typeof document !== "undefined") document.removeEventListener("focusin", onFocusIn, true);
|
|
417
434
|
}
|
|
418
435
|
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["disabled"] });
|
|
419
436
|
document.addEventListener("focusin", onFocusIn, true);
|
|
@@ -759,7 +776,80 @@ function useNonModalDialog(root, active, onClose, isTop = ALWAYS_TOP) {
|
|
|
759
776
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
760
777
|
}, [active, root, isTop, onCloseRef]);
|
|
761
778
|
}
|
|
779
|
+
var VIEWPORT_PADDING = 8;
|
|
780
|
+
function usePosition(triggerRef, floatingRef, open, options = {}) {
|
|
781
|
+
const { side = "bottom", align = "center", offset = 8, flip = true } = options;
|
|
782
|
+
const [pos, setPos] = useState({ top: 0, left: 0, placement: side });
|
|
783
|
+
const rafId = useRef(0);
|
|
784
|
+
const compute = useCallback(() => {
|
|
785
|
+
const trigger = triggerRef.current;
|
|
786
|
+
const floating = floatingRef.current;
|
|
787
|
+
if (!trigger || !floating) return;
|
|
788
|
+
const tRect = trigger.getBoundingClientRect();
|
|
789
|
+
const fRect = floating.getBoundingClientRect();
|
|
790
|
+
const vw = window.innerWidth;
|
|
791
|
+
const vh = window.innerHeight;
|
|
792
|
+
let placement = side;
|
|
793
|
+
if (flip) {
|
|
794
|
+
if (placement === "bottom" && tRect.bottom + offset + fRect.height > vh - VIEWPORT_PADDING && tRect.top - offset - fRect.height > VIEWPORT_PADDING) {
|
|
795
|
+
placement = "top";
|
|
796
|
+
} else if (placement === "top" && tRect.top - offset - fRect.height < VIEWPORT_PADDING && tRect.bottom + offset + fRect.height < vh - VIEWPORT_PADDING) {
|
|
797
|
+
placement = "bottom";
|
|
798
|
+
} else if (placement === "right" && tRect.right + offset + fRect.width > vw - VIEWPORT_PADDING && tRect.left - offset - fRect.width > VIEWPORT_PADDING) {
|
|
799
|
+
placement = "left";
|
|
800
|
+
} else if (placement === "left" && tRect.left - offset - fRect.width < VIEWPORT_PADDING && tRect.right + offset + fRect.width < vw - VIEWPORT_PADDING) {
|
|
801
|
+
placement = "right";
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
let top;
|
|
805
|
+
let left;
|
|
806
|
+
if (placement === "bottom" || placement === "top") {
|
|
807
|
+
top = placement === "bottom" ? tRect.bottom + offset : tRect.top - fRect.height - offset;
|
|
808
|
+
switch (align) {
|
|
809
|
+
case "start":
|
|
810
|
+
left = tRect.left;
|
|
811
|
+
break;
|
|
812
|
+
case "end":
|
|
813
|
+
left = tRect.right - fRect.width;
|
|
814
|
+
break;
|
|
815
|
+
default:
|
|
816
|
+
left = tRect.left + (tRect.width - fRect.width) / 2;
|
|
817
|
+
}
|
|
818
|
+
} else {
|
|
819
|
+
left = placement === "right" ? tRect.right + offset : tRect.left - fRect.width - offset;
|
|
820
|
+
switch (align) {
|
|
821
|
+
case "start":
|
|
822
|
+
top = tRect.top;
|
|
823
|
+
break;
|
|
824
|
+
case "end":
|
|
825
|
+
top = tRect.bottom - fRect.height;
|
|
826
|
+
break;
|
|
827
|
+
default:
|
|
828
|
+
top = tRect.top + (tRect.height - fRect.height) / 2;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
left = Math.max(VIEWPORT_PADDING, Math.min(left, vw - fRect.width - VIEWPORT_PADDING));
|
|
832
|
+
top = Math.max(VIEWPORT_PADDING, Math.min(top, vh - fRect.height - VIEWPORT_PADDING));
|
|
833
|
+
setPos((cur) => cur.top === top && cur.left === left && cur.placement === placement ? cur : { top, left, placement });
|
|
834
|
+
}, [triggerRef, floatingRef, side, align, offset, flip]);
|
|
835
|
+
useLayoutEffect(() => {
|
|
836
|
+
if (!open) return;
|
|
837
|
+
compute();
|
|
838
|
+
const onUpdate = () => {
|
|
839
|
+
cancelAnimationFrame(rafId.current);
|
|
840
|
+
rafId.current = requestAnimationFrame(compute);
|
|
841
|
+
};
|
|
842
|
+
window.addEventListener("scroll", onUpdate, true);
|
|
843
|
+
window.addEventListener("resize", onUpdate);
|
|
844
|
+
return () => {
|
|
845
|
+
cancelAnimationFrame(rafId.current);
|
|
846
|
+
window.removeEventListener("scroll", onUpdate, true);
|
|
847
|
+
window.removeEventListener("resize", onUpdate);
|
|
848
|
+
};
|
|
849
|
+
}, [open, compute]);
|
|
850
|
+
return pos;
|
|
851
|
+
}
|
|
762
852
|
|
|
763
|
-
export { CONTROL_ANCESTOR, FIELD, FOCUSABLE, OVERLAY_CLOSE_ATTR, ZOOM_KEYS, focusAfterRemoval, focusAfterSelfRemoval, focusInitial, inertOutside, isTabStop, rememberFocus, rememberOpener, rovingTabStop, tabStops, useCloseOnFocusOut, useFocusBeforeOpen, useFocusKeptInList, useFocusLeave, useFocusTrap, useGridKeyboard, useNonModalDialog, useOverlayLayer, usePopupFocus, usePressMarks, useReturnFocus };
|
|
764
|
-
//# sourceMappingURL=chunk-
|
|
765
|
-
//# sourceMappingURL=chunk-
|
|
853
|
+
export { CONTROL_ANCESTOR, FIELD, FOCUSABLE, OVERLAY_CLOSE_ATTR, ZOOM_KEYS, focusAfterRemoval, focusAfterSelfRemoval, focusInitial, inertOutside, isTabStop, rememberFocus, rememberOpener, rovingTabStop, tabStops, useCloseOnFocusOut, useFocusBeforeOpen, useFocusKeptInList, useFocusLeave, useFocusTrap, useGridKeyboard, useLatest, useNonModalDialog, useOverlayLayer, usePopupFocus, usePosition, usePressMarks, useReturnFocus };
|
|
854
|
+
//# sourceMappingURL=chunk-4HJDOZ2M.js.map
|
|
855
|
+
//# sourceMappingURL=chunk-4HJDOZ2M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../showcase/src/lib/use-latest.ts","../../../showcase/src/lib/focus.ts","../../../showcase/src/lib/use-position.ts"],"names":["useRef","useLayoutEffect","active","useState","useCallback"],"mappings":";;;;;AAcO,SAAS,UAAa,KAAA,EAAwB;AACnD,EAAA,MAAM,GAAA,GAAM,OAAO,KAAK,CAAA;AACxB,EAAA,eAAA,CAAgB,MAAM;AACpB,IAAA,GAAA,CAAI,OAAA,GAAU,KAAA;AAAA,EAChB,CAAC,CAAA;AACD,EAAA,OAAO,GAAA;AACT;;;ACXO,IAAM,SAAA,GACX;AAGK,IAAM,KAAA,GAAQ;AAQd,IAAM,gBAAA,GAA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EAAK,IAAA,EAAM,WAAY,CAAA;AAAA,EACxH,CAAA,EAAG,CAAC,UAAA,EAAY,WAAA,EAAa,MAAM,KAAA,EAAO,MAAA,EAAQ,IAAI,CAAC,CAAA;AAEvD,EAAAH,gBAAgB,MAAM;AACpB,IAAA,IAAI,CAAC,IAAA,EAAM;AAEX,IAAA,OAAA,EAAQ;AAER,IAAA,MAAM,WAAW,MAAM;AACrB,MAAA,oBAAA,CAAqB,MAAM,OAAO,CAAA;AAClC,MAAA,KAAA,CAAM,OAAA,GAAU,sBAAsB,OAAO,CAAA;AAAA,IAC/C,CAAA;AAEA,IAAA,MAAA,CAAO,gBAAA,CAAiB,QAAA,EAAU,QAAA,EAAU,IAAI,CAAA;AAChD,IAAA,MAAA,CAAO,gBAAA,CAAiB,UAAU,QAAQ,CAAA;AAE1C,IAAA,OAAO,MAAM;AACX,MAAA,oBAAA,CAAqB,MAAM,OAAO,CAAA;AAClC,MAAA,MAAA,CAAO,mBAAA,CAAoB,QAAA,EAAU,QAAA,EAAU,IAAI,CAAA;AACnD,MAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,QAAQ,CAAA;AAAA,IAC/C,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,IAAA,EAAM,OAAO,CAAC,CAAA;AAElB,EAAA,OAAO,GAAA;AACT","file":"chunk-4HJDOZ2M.js","sourcesContent":["import { useLayoutEffect, useRef, type RefObject } from \"react\";\n\n/**\n * A ref that always holds the latest value of `value`, updated in a layout\n * effect (before paint, before any event can fire) rather than during render.\n *\n * Use it for callbacks read from long-lived listeners — `onClose` inside a\n * document keydown handler, `onDismiss` inside a timer — so the listener need\n * not be re-attached every render and never calls a stale closure.\n *\n * The write happens in a commit-phase effect, which is the React-sanctioned\n * place to touch refs (the React Compiler's `refs` rule rejects writes during\n * render).\n */\nexport function useLatest<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n useLayoutEffect(() => {\n ref.current = value;\n });\n return ref;\n}\n","import { useCallback, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type RefObject } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useLatest } from \"./use-latest\";\n\n/**\n * Everything a keyboard user might land on: the candidates. Whether one is a\n * Tab stop right now is `isTabStop`'s call (a roving item with tabindex=\"-1\", a\n * hidden input or a disabled field matches this selector but is not a stop).\n */\nexport const FOCUSABLE =\n 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"]), [contenteditable]:not([contenteditable=\"false\"])';\n\n/** A field that takes typing: keys pressed in one are its own (a grid's arrows, a time view's zoom keys leave them). */\nexport const FIELD = \"input, select, textarea, [contenteditable='true']\";\n\n/**\n * A control a library element with a Tab stop of its own can sit in (a RelativeTime, cut text): a Card or a board's card\n * that is a button, a link, a button, a row or an option the app built. Inside one the element takes no Tab stop: a stop\n * nested in a button, and a Card holding one stops being a button (the 25.17 second review: a time took an action\n * card's keyboard access away).\n */\nexport const CONTROL_ANCESTOR = 'a[href], button, summary, label, [role=\"button\"], [role=\"link\"], [role=\"option\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [role=\"tab\"], [role=\"treeitem\"], [role=\"row\"], [role=\"gridcell\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"switch\"]';\nconst SAFE_BUTTON = 'button:not([data-variant=\"destructive\"])';\n\n/** Mark an overlay's own close/dismiss button so initial focus skips it. */\nexport const OVERLAY_CLOSE_ATTR = \"data-overlay-close\";\n\n// ─── Tab stops ───────────────────────────────────────────────────────────────\n\n/** Rendered and not hidden. Real browsers answer with checkVisibility; with no layout (jsdom) the tree is walked. */\nfunction isRendered(el: HTMLElement): boolean {\n if (typeof el.checkVisibility === \"function\") return el.checkVisibility({ checkVisibilityCSS: true });\n for (let n: Element | null = el; n; n = n.parentElement) {\n if (n instanceof HTMLElement && n.hidden) return false;\n const style = getComputedStyle(n);\n if (style.display === \"none\") return false;\n if (n === el && style.visibility === \"hidden\") return false;\n }\n return true;\n}\n\n/** A native radio is a Tab stop when it is its group's checked radio, or the first when none is checked. */\nfunction isRadioStop(el: HTMLInputElement): boolean {\n if (!el.name) return true;\n const scope: ParentNode = el.form ?? el.ownerDocument;\n const group = Array.from(scope.querySelectorAll<HTMLInputElement>('input[type=\"radio\"]'))\n .filter((r) => r.name === el.name && !r.disabled && r.form === el.form);\n const checked = group.find((r) => r.checked);\n return (checked ?? group[0]) === el;\n}\n\n/**\n * Could the browser's own Tab land here? A focusable element with a\n * non-negative tabIndex, not disabled, not a hidden input, not inside an inert\n * subtree, rendered, and for a native radio the group's one stop (Sprint 25.7).\n */\nexport function isTabStop(el: Element): el is HTMLElement {\n if (!(el instanceof HTMLElement) || el.tabIndex < 0) return false;\n if ((el instanceof HTMLButtonElement || el instanceof HTMLInputElement || el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement) && el.disabled) return false;\n if (el instanceof HTMLInputElement && (el.type === \"hidden\" || (el.type === \"radio\" && !isRadioStop(el)))) return false;\n if (el.closest(\"[inert]\")) return false;\n return isRendered(el);\n}\n\n/** The Tab stops inside `root`, in document order. */\nexport function tabStops(root: ParentNode): HTMLElement[] {\n // sorted: a selector list can come back grouped by selector (jsdom's does), which put a trap's first or last stop, or a\n // card's first action, on the wrong element in a test (the review of 2 October)\n return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE))\n .filter(isTabStop)\n .sort((a, b) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1));\n}\n\n/**\n * Move initial focus into an overlay the way users expect: the first visible\n * form field if there is one, otherwise the first focusable element that is\n * not the overlay's own close button.\n *\n * For destructive confirmations (`destructive: true`) the corpus rule applies\n * instead: focus the non-destructive action so Enter can't confirm by\n * accident. That is the first button not rendered with the destructive\n * variant, regardless of footer order; a lone destructive button falls back to\n * the general rule.\n *\n * React's `autoFocus` prop is not reflected as a DOM attribute, so a\n * field-first rule is the reliable general behaviour.\n */\nexport function focusInitial(root: HTMLElement | null | undefined, opts: { destructive?: boolean } = {}): boolean {\n if (!root) return false;\n const all = tabStops(root);\n if (!all.length) return false;\n const candidates = all.filter((el) => !el.hasAttribute(OVERLAY_CLOSE_ATTR));\n\n // Round 18 (the owner, 55.5; round 17 F-9): a destructive dialog that holds a field is a type-to-confirm dialog — its\n // confirm stays disabled until the text matches, so the field is the safe target. Cancel is the target only when the\n // dialog is buttons-only.\n const field = candidates.find((el) => el.matches(FIELD));\n if (opts.destructive && !field) {\n const safe = candidates.find((el) => el.matches(SAFE_BUTTON));\n if (safe) {\n safe.focus();\n return true;\n }\n }\n\n const target = candidates.find((el) => el.matches(FIELD)) ?? candidates[0] ?? all[0];\n target.focus();\n return true;\n}\n\n// ─── Remembering where focus was ─────────────────────────────────────────────\n\n/**\n * The element that had focus when `open` turned true, read before this commit's children can move it. An `autoFocus`\n * field inside a dialog takes focus while React commits (the layout phase), so an effect that reads\n * document.activeElement afterwards sees that field, not the opener (run 57's type-to-confirm dialog, Sprint 25.7).\n * Insertion effects run earlier in the commit, before any of that.\n */\nexport function useFocusBeforeOpen(open: boolean): RefObject<Element | null> {\n const before = useRef<Element | null>(null);\n useInsertionEffect(() => {\n trackFocus();\n if (!open) return;\n // focus fell to the page in this same commit, its element removed before this overlay looked: that element (Sprint\n // 25.29 item 4: a preview dialog's \"Edit details\", gone with the preview as the edit drawer opens)\n const active = document.activeElement;\n before.current = !active || active === document.body ? (justLost() ?? active) : active;\n }, [open]);\n return before;\n}\n\n/** The element that last took focus, kept once it has left the page, and when; and when the person last acted. */\nlet lastFocused: Element | null = null;\nlet lastFocusedAt = 0;\nlet lastActedAt = 0;\nlet tracking = false;\nfunction trackFocus() {\n if (tracking || typeof document === \"undefined\") return;\n tracking = true;\n document.addEventListener(\"focusin\", (e) => {\n lastFocused = e.target instanceof Element ? e.target : null;\n lastFocusedAt = performance.now();\n }, true);\n const acted = () => { lastActedAt = performance.now(); };\n for (const type of [\"keydown\", \"pointerdown\", \"click\"]) document.addEventListener(type, acted, true);\n}\n\n/**\n * The element focus fell from in what the person just did: it left the page with focus on it, and they had acted since\n * it took focus, within the second. Never one gone long ago, or with a page that has moved on since (a panel open from\n * the start on the next page).\n */\nfunction justLost(): Element | null {\n const recent = lastActedAt >= lastFocusedAt && performance.now() - lastActedAt < 1000;\n return lastFocused && !lastFocused.isConnected && recent ? lastFocused : null;\n}\n// from the start, so a press made before any overlay mounted counts (an edit drawer drawn only once its address is open)\ntrackFocus();\n\n/** `to` is a path above `from`: /calendar above /calendar/events/7; the site's root above /events/7 (a home page's own\n * overlay, the second review). */\nfunction pathAbove(to: string, from: string): boolean {\n const up = to.replace(/\\/+$/, \"\");\n return from.startsWith(`${up}/`) && from.replace(/\\/+$/, \"\") !== up;\n}\n\n/** What counts as \"the row\" an opener sits in, for a row that is deleted while its menu or dialog is open. */\nconst ROW = 'tr, li, [role=\"row\"], [data-card], [data-row]';\n\n/**\n * The index of the one row a deletion took out, when the rows now read as the old rows with that one removed: every\n * row after it moved up by one. A list keyed by position (the library Table, `key={i}`) keeps a deleted row's\n * elements for the next item, and a paged list keeps its length by bringing a new item into its last row. Else -1:\n * an edit (even one that makes a row read like another) or a re-sort.\n */\nfunction deletedRow(before: readonly string[], now: readonly string[]): number {\n const refilled = now.length === before.length;\n if (!refilled && now.length !== before.length - 1) return -1;\n let k = 0;\n while (k < now.length && now[k] === before[k]) k++;\n const last = now.length - 1;\n // a refilled last row shows an item the list did not show\n if (refilled && (k >= last || before.includes(now[last]))) return -1;\n for (let j = k; j < (refilled ? last : now.length); j++) if (now[j] !== before[j + 1]) return -1;\n return k;\n}\n\n/**\n * Focus by script on an element that takes none, a heading or a container (Sprint 25.29 item 3): it takes `tabindex=\"-1\"`\n * while it holds focus, never a Tab stop, and the library's ring when the keyboard brought it there. True when it took\n * focus.\n */\nexport function focusForTheMoment(el: HTMLElement): boolean {\n const own = el.getAttribute(\"tabindex\");\n if (own === null) el.setAttribute(\"tabindex\", \"-1\");\n el.focus();\n if (document.activeElement !== el) {\n if (own === null) el.removeAttribute(\"tabindex\");\n return false;\n }\n let ring = false;\n try { ring = el.matches(\":focus-visible\"); } catch { /* a browser without :focus-visible draws its own */ }\n const { outline, outlineOffset } = el.style;\n if (ring) {\n // FOCUS_RING's outline, which a class added now might not find in a stylesheet built without it\n el.style.outline = \"2px solid var(--ds-focus)\";\n el.style.outlineOffset = \"2px\";\n }\n el.addEventListener(\"blur\", () => {\n if (own === null) el.removeAttribute(\"tabindex\");\n if (ring) Object.assign(el.style, { outline, outlineOffset });\n }, { once: true });\n return true;\n}\n\nconst HEADING = 'h1, h2, h3, h4, h5, h6, [role=\"heading\"]';\n\n/**\n * How long `rememberFocus`'s last resort waits (Sprint 25.29 item 3): past every library component's own place for focus\n * after a removal, so the most particular place goes first. The Calendar's is the slowest: its card's frame, then a\n * check 120 ms on (the event's day).\n */\nexport const LAST_RESORT_MS = 200;\n\n/** Each container round an element, nearest first, with what stood just before and after it there. The app's root and\n * the body are the page itself, never a place for focus. */\ninterface Place { box: HTMLElement; prev: Element | null; next: Element | null }\nfunction placesOf(el: Element): Place[] {\n const places: Place[] = [];\n for (let c: Element = el, box = el.parentElement; box && box !== document.body && box.parentElement && box.parentElement !== document.body; c = box, box = box.parentElement) {\n places.push({ box, prev: c.previousElementSibling, next: c.nextElementSibling });\n }\n return places;\n}\n\n/**\n * The last resort's place (item 3): in the nearest container still on the page, what now stands where the element was,\n * then the container, then each one round it, each its first Tab stop, else its first heading, focused for the moment.\n * Nothing inside `closing` counts (an overlay still on its way out). Last, the page's `<main>` (Sprint 25.30 item 4): an\n * overlay in a portal leaves no place of its own once it has gone, so focus goes where the skip link's jump goes, its\n * first Tab stop, else its first heading, else `<main>` itself. True when focus landed.\n */\nfunction landLastResort(places: Place[], closing?: Element | null): boolean {\n const counts = (el: Element) => !closing?.contains(el);\n const areas: Element[][] = [];\n const at = places.findIndex((p) => p.box.isConnected);\n if (at >= 0) {\n const { box, prev, next } = places[at];\n const kids = Array.from(box.children);\n const from = prev?.parentElement === box ? kids.indexOf(prev) + 1 : 0;\n const to = next?.parentElement === box ? kids.indexOf(next) : kids.length;\n areas.push(kids.slice(from, Math.max(from, to)), ...places.slice(at).map((p) => [p.box]));\n }\n const main = document.querySelector<HTMLElement>('main, [role=\"main\"]');\n const mainCounts = !!main && counts(main) && isRendered(main);\n if (mainCounts) areas.push([main]);\n for (const area of areas) {\n const stop = area.flatMap((a) => [...(isTabStop(a) ? [a] : []), ...tabStops(a)]).find(counts);\n if (stop) {\n stop.focus();\n if (document.activeElement === stop) return true;\n }\n const heading = area.flatMap((a) => [...(a.matches(HEADING) ? [a] : []), ...a.querySelectorAll(HEADING)])\n .find((h): h is HTMLElement => h instanceof HTMLElement && isRendered(h) && counts(h));\n if (heading && focusForTheMoment(heading)) return true;\n }\n return mainCounts && focusForTheMoment(main!);\n}\n\nexport interface RememberFocusOptions {\n /** The element's page outlives a change of path (a list beside a pane whose selection is in the URL): give focus back even then. */\n ignoreRoute?: boolean;\n}\n\nexport interface RememberedFocus {\n readonly el: HTMLElement;\n /**\n * Put focus back (Sprint 25.7). Nothing happens once the page has changed — a new path, or a new URL that took the\n * element with it — since the new page owns focus (D14(d)); a new query or hash alone (a filter, a page number) is\n * no page change, nor is a path above (an overlay's own address closing back to its page, Sprint 25.18). Otherwise the element itself; if its row was deleted, the same control in the row before, else\n * the row after, else the first Tab stop of the list (D14(c), MOJ \"Add another\" order); else `fallback`. True when\n * focus landed. With all of that gone (Sprint 25.29 item 3: a row's \"Restore\" that empties its list, swapped for its\n * empty state), the last resort, `LAST_RESORT_MS` later and only with focus still on nothing: the nearest container\n * still on the page, what now stands where the element was, then the container, each its first Tab stop, else its\n * first heading, focused for the moment (`focusForTheMoment`). Never the page itself.\n *\n * Rows carrying `data-row-key` are told apart by it. Without one, a list keyed by position (the library Table,\n * `key={i}`) keeps a deleted row's elements for the next item, so the rows' text decides: focus follows this item\n * to the one row that now shows it, and when the rows read as the old ones with one taken out, this row's item was\n * deleted or moved up. An edit keeps focus, even one that makes the row read like another.\n *\n * When focus lands back on the element in a row, the list is watched for 10 s: a row deleted a moment later (a\n * server round trip) that takes focus with it sends focus to its neighbour the same way.\n */\n restore(fallback?: HTMLElement | null): boolean;\n}\n\nexport function rememberFocus(el: HTMLElement, { ignoreRoute = false }: RememberFocusOptions = {}): RememberedFocus {\n const { href, pathname } = location;\n const row = el.closest<HTMLElement>(ROW);\n const before = row?.previousElementSibling ?? null;\n const after = row?.nextElementSibling ?? null;\n const list = row?.parentElement ?? null;\n const index = row ? tabStops(row).indexOf(el) : -1;\n const rows = list ? Array.from(list.children) : [];\n const at = row ? rows.indexOf(row) : -1;\n const texts = rows.map((r) => r.textContent ?? \"\");\n const keyOf = (r: Element | null) => r?.getAttribute(\"data-row-key\") ?? null;\n const key = keyOf(row);\n // where it sat, for the last resort\n const places = placesOf(el);\n const pageChanged = () => {\n if (ignoreRoute) return false;\n // back up to a path above: an overlay or a pane with an address of its own closing (/calendar/events/7 back to\n // /calendar, navigation#29), the same page (Sprint 25.18). A page that replaced it keeps nothing focus could land on.\n if (location.pathname !== pathname) return !pathAbove(location.pathname, pathname);\n return location.href !== href && !el.isConnected;\n };\n const land = (target: HTMLElement | null | undefined) => {\n if (!target || !target.isConnected) return false;\n target.focus();\n return document.activeElement === target;\n };\n const inRow = (r: Element | null | undefined) => {\n if (!r || !r.isConnected) return false;\n const stops = tabStops(r);\n return land(stops[Math.max(0, Math.min(index, stops.length - 1))]);\n };\n const byKey = (k: string | null) => (k !== null && list?.isConnected ? list.querySelector(`:scope > [data-row-key=\"${CSS.escape(k)}\"]`) : null);\n /** The row this item is in now, when the list moved under it; undefined when it did not. */\n const moved = (): Element | undefined => {\n if (!list?.isConnected || at < 0) return undefined;\n if (key !== null) {\n const same = byKey(key);\n return same === row ? undefined : same ?? byKey(keyOf(before)) ?? byKey(keyOf(after)) ?? undefined;\n }\n const now = Array.from(list.children, (r) => r.textContent ?? \"\");\n const text = texts[at];\n if (texts.indexOf(text) === texts.lastIndexOf(text)) {\n const found = now.flatMap((t, i) => (t === text ? [i] : []));\n if (found.length === 1) return list.children[found[0]] === row ? undefined : list.children[found[0]];\n }\n const k = deletedRow(texts, now);\n return k >= 0 && k <= at ? list.children[Math.max(0, at - 1)] ?? undefined : undefined;\n };\n const neighbour = () => inRow(byKey(keyOf(before)) ?? before) || inRow(byKey(keyOf(after)) ?? after) || (!!list?.isConnected && land(tabStops(list)[0]));\n // a moment later, and only with focus still on nothing: a component with a place of its own for focus goes first\n const lastResort = () => {\n setTimeout(() => {\n // a page torn down in the meantime (a test's) has nowhere to land\n if (typeof document === \"undefined\") return;\n const active = document.activeElement;\n if ((active && active !== document.body && active.isConnected) || pageChanged()) return;\n landLastResort(places);\n }, LAST_RESORT_MS);\n return false;\n };\n let unwatch: (() => void) | null = null;\n const watch = () => {\n unwatch?.();\n if (!list || typeof MutationObserver === \"undefined\") return;\n const observer = new MutationObserver((changes) => {\n if (el.isConnected) return;\n const active = document.activeElement;\n const dropped = !active || active === document.body || !active.isConnected;\n stop();\n if (!dropped || pageChanged()) return;\n // its row taken from the list: the neighbour (D14(c)); gone any other way, the list with it, the last resort\n const fromList = changes.some((c) => c.target === list || c.target === list.parentNode);\n if (!(fromList && neighbour())) lastResort();\n });\n const onFocusIn = (e: FocusEvent) => { if (e.target !== el) stop(); };\n const timer = setTimeout(() => stop(), 10_000);\n function stop() {\n observer.disconnect();\n clearTimeout(timer);\n // its timer can outlive the page (a test's)\n if (typeof document !== \"undefined\") document.removeEventListener(\"focusin\", onFocusIn, true);\n unwatch = null;\n }\n observer.observe(list, { childList: true });\n if (list.parentNode) observer.observe(list.parentNode, { childList: true });\n // and every container round it: a page that swaps the whole list for its empty state removes it from higher up\n // (Sprint 25.29 item 3)\n for (const { box } of places) observer.observe(box, { childList: true });\n document.addEventListener(\"focusin\", onFocusIn, true);\n unwatch = stop;\n };\n return {\n el,\n restore(fallback) {\n if (pageChanged()) return false;\n if (inRow(moved())) return true;\n if (land(el)) {\n if (row) watch();\n return true;\n }\n if (row && !row.isConnected && neighbour()) return true;\n return land(fallback) || lastResort();\n },\n };\n}\n\n/**\n * A list whose item holding focus the page takes away (Sprint 25.29 item 5: run 81's \"Acknowledge\" filtered its alert out\n * of a StackedList, and focus fell to the page): focus goes on by `rememberFocus`'s rule, the same control in the item\n * before, else in the item after, else the list's first, else the last resort. Watched while focus is in the list;\n * focus moved anywhere else, or let go on the page by a click, forgets it, so a removal the user didn't make (a data\n * refresh) never pulls focus back. A removed element fires no focusout, or one with the element gone, so a removal keeps it.\n */\nexport function useFocusKeptInList(listRef: RefObject<HTMLElement | null>) {\n useEffect(() => {\n if (typeof MutationObserver === \"undefined\") return;\n let held: RememberedFocus | null = null;\n let observer: MutationObserver | null = null;\n const forget = () => {\n held = null;\n observer?.disconnect();\n observer = null;\n };\n const onFocusIn = (e: FocusEvent) => {\n const list = listRef.current;\n const t = e.target;\n if (!list || !(t instanceof HTMLElement) || !list.contains(t)) {\n if (held) forget();\n return;\n }\n held = rememberFocus(t);\n if (observer) return;\n observer = new MutationObserver(() => {\n const h = held;\n if (!h || h.el.isConnected) return;\n const active = document.activeElement;\n forget();\n if (!active || active === document.body || !active.isConnected) h.restore();\n });\n observer.observe(list, { childList: true, subtree: true });\n };\n const onFocusOut = (e: FocusEvent) => {\n if (!held || e.target !== held.el) return;\n queueMicrotask(() => { if (held?.el.isConnected && !listRef.current?.contains(document.activeElement)) forget(); });\n };\n document.addEventListener(\"focusin\", onFocusIn, true);\n document.addEventListener(\"focusout\", onFocusOut, true);\n return () => {\n document.removeEventListener(\"focusin\", onFocusIn, true);\n document.removeEventListener(\"focusout\", onFocusOut, true);\n const h = held;\n forget();\n // the list itself taken away with focus in it (its last item gone, an empty state drawn instead), before the\n // watch heard of it: the last resort (item 3)\n const active = document.activeElement;\n if (h && !h.el.isConnected && (!active || active === document.body || !active.isConnected)) h.restore();\n };\n }, [listRef]);\n}\n\n// ─── An overlay's way back ───────────────────────────────────────────────────\n\n/**\n * Each overlay's opener, by the overlay's element (Sprint 25.29 item 4). An overlay opened from inside another that\n * closed as it opened (run 79: a preview dialog's \"Edit details\" moves the address to the edit drawer's, closing the\n * preview) has an opener that went with it, so it falls back to that overlay's own opener, still on the page (the asset\n * card). Kept by element, not with the layers: the outer overlay has left the layers by the time the inner one opens.\n */\nconst openers = new WeakMap<Element, RememberedFocus>();\n\n/** What an overlay gives focus back to, read as it opened. */\nexport interface OverlayOpener {\n /** What had focus as it opened, while that was on the page; null when it had gone. */\n readonly el: HTMLElement | null;\n /** As RememberedFocus's; else, with the overlay the opener sat in closed, that overlay's own opener. */\n restore(fallback?: HTMLElement | null): boolean;\n}\n\n/**\n * Remember an overlay's opener as it opens: `active`, what had focus then, and `root`, the overlay's element, which\n * keeps it for an overlay opened from inside this one. Null when nothing is left to give focus back to.\n */\nexport function rememberOpener(active: Element | null, root?: Element | null): OverlayOpener | null {\n let own = active instanceof HTMLElement && active !== document.body && active.isConnected ? rememberFocus(active) : null;\n // nothing on the page had focus (an overlay open from the start), or what had it has gone: the control that controls\n // it, which names it in aria-controls (Sprint 25.29 item 6: a CornerPanel open on load, closed by Escape, gives focus\n // to its Launcher)\n const controller = !own && root?.id ? document.querySelector<HTMLElement>(`[aria-controls~=\"${CSS.escape(root.id)}\"]`) : null;\n if (controller) own = rememberFocus(controller);\n // the overlay the opener sat in, on the page or not: a closed overlay's element keeps its children\n let around: { root: Element; opener: RememberedFocus } | null = null;\n for (let n = active; n && !around; n = n.parentElement) {\n const opener = openers.get(n);\n if (opener) around = { root: n, opener };\n }\n const back = own ?? around?.opener;\n if (!back) {\n if (!root) return null;\n // nothing to go back to at all: the last resort round where the overlay sits, once it has gone (item 3). A path\n // above is the same page, as for rememberFocus (an overlay's own address closing back to its page, Sprint 25.30\n // item 4: run 79's edit drawer, opened from a preview that was open as the page loaded)\n const places = placesOf(root);\n const { pathname } = location;\n return {\n el: null,\n restore() {\n setTimeout(() => {\n if (typeof document === \"undefined\") return;\n const now = document.activeElement;\n if ((now && now !== document.body && now.isConnected && !root.contains(now)) || (location.pathname !== pathname && !pathAbove(location.pathname, pathname))) return;\n landLastResort(places, root);\n }, LAST_RESORT_MS);\n return false;\n },\n };\n }\n if (root) openers.set(root, back);\n return {\n el: own?.el ?? null,\n restore(fallback) {\n if (own?.restore(fallback)) return true;\n return !!around && !around.root.isConnected && around.opener.restore();\n },\n };\n}\n\n/**\n * Remember what had focus when a modal overlay opened and give it back on\n * close (corpus: \"After an overlay closes, return focus to the element that\n * triggered it\"). With `root`, focus is given back only when it was lost or is\n * still inside the closing overlay, so a focus move the consumer made on close\n * wins. Returns `returnFocus()` for a command that must hand focus back before\n * it runs (CommandPalette: a command that opens a Dialog).\n */\nexport function useReturnFocus(open: boolean, root?: RefObject<HTMLElement | null>) {\n const remembered = useRef<OverlayOpener | null>(null);\n const before = useFocusBeforeOpen(open);\n useEffect(() => {\n if (open) {\n remembered.current = rememberOpener(before.current, root?.current);\n return;\n }\n const r = remembered.current;\n remembered.current = null;\n if (!r) return;\n const active = document.activeElement;\n const lost = !active || active === document.body || !active.isConnected;\n if (!root || lost || (active instanceof Node && !!root.current?.contains(active))) r.restore();\n }, [open, root, before]);\n // Unmounted while open, as Dialog gives focus back (Sprint 25.18: run 72 keys its form by the event's address, so\n // closing it unmounted an open Drawer, which gave none back; a page that renders an overlay only while open does the\n // same). Its panel is gone, so focus is lost, unless the page moved it.\n useEffect(() => () => {\n const r = remembered.current;\n remembered.current = null;\n const now = document.activeElement;\n if (r && (!now || now === document.body || !now.isConnected)) r.restore();\n }, []);\n return useCallback(() => { remembered.current?.restore(); }, []);\n}\n\n/**\n * Index of the single Tab stop in a radio-style group (APG radio pattern):\n * the checked item, else the first enabled item so a group with no selection\n * is still reachable. −1 when every item is disabled.\n */\nexport function rovingTabStop<T>(items: T[], isChecked: (item: T) => boolean, isDisabled: (item: T) => boolean = () => false): number {\n const checked = items.findIndex((item) => isChecked(item) && !isDisabled(item));\n return checked >= 0 ? checked : items.findIndex((item) => !isDisabled(item));\n}\n\n/**\n * Rule 4 (D14(c), MOJ \"Add another\" order): after the item at `index` was\n * removed, focus the item before it, else the one now in its place, else\n * `fallback`. `items` is the list as it is after the removal.\n */\nexport function focusAfterRemoval(items: ArrayLike<HTMLElement>, index: number, fallback?: HTMLElement | null) {\n (items[index - 1] ?? items[index] ?? fallback)?.focus();\n}\n\n/** The Tab stops in `root`, and the controls disabled now that a press may enable, in document order. */\nfunction mayStop(root: ParentNode): HTMLElement[] {\n const disabled = (el: Element) => (el instanceof HTMLButtonElement || el instanceof HTMLInputElement || el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement) && el.disabled;\n return Array.from(root.querySelectorAll<HTMLElement>(`${FOCUSABLE}, button:disabled, input:disabled, select:disabled, textarea:disabled`))\n .filter((el) => (disabled(el) ? !(el instanceof HTMLInputElement && el.type === \"hidden\") : isTabStop(el)))\n .sort((a, b) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1));\n}\n\nexport interface SelfRemovalOptions {\n /** What goes: the alert, the tag. Nothing inside it is a place for focus. Default: the control itself. */\n item?: HTMLElement | null;\n /** What the item sits in, whose controls are its neighbours. Default: the item's parent. */\n group?: HTMLElement | null;\n /**\n * Where focus belongs next, when it's on the page then (Sprint 25.29 item 2: a chat's suggestion, gone once its message\n * is sent, hands focus to the message field); else the rule above. Read when focus moves, so a control drawn by then\n * counts. One that isn't a Tab stop (a row with nothing in it to Tab to: the first a last Load more brought, Sprint\n * 25.30 item 1) takes focus for the moment.\n */\n to?: HTMLElement | null | (() => HTMLElement | null | undefined);\n}\n\n/**\n * The library's rule for a control that removes itself, or the item it belongs to (Sprint 25.8.7 item 33, D72): Sprint\n * 26 found focus falling to the page after an Alert's Dismiss and a Tag's remove. Focus goes to the item's neighbour in\n * its group, in rule 4's order (D14(c), as `focusAfterRemoval` orders a list): the same control in the item before (else\n * the nearest control before it that takes focus then), else in the item after (else the nearest after), else the group\n * itself. A control disabled as the press began counts, once the press has enabled it (Sprint 25.29 item 2: TransferList's\n * \"Move all left\", once everything has moved right). Call it as the control acts, before the removal: it reads the\n * group's controls now, while the item is in the page, and moves focus once the control has gone (left the page, or been disabled) with focus\n * lost, within 10 s, so a page that removes the item after a server round trip is served too, and focus the page moved\n * itself stays where the page put it. Returns a function that stops the watch.\n */\nexport function focusAfterSelfRemoval(control: HTMLElement, { item, group, to }: SelfRemovalOptions = {}): () => void {\n const goes = item ?? control;\n const within = group === undefined ? goes.parentElement : group;\n const stops = within ? mayStop(within).filter((el) => !goes.contains(el)) : [];\n const before = stops.filter((el) => goes.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING).reverse();\n const after = stops.filter((el) => goes.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING);\n // the same control in the neighbouring item, as rememberFocus finds it in a row: the next tag's remove button after a\n // remove, so the keyboard can go on removing\n const stopsOf = (el: Element) => [...(isTabStop(el) ? [el] : []), ...tabStops(el)];\n const index = stopsOf(goes).indexOf(control);\n const neighbour = (step: \"previousElementSibling\" | \"nextElementSibling\") => {\n for (let el = goes[step]; el; el = el[step]) {\n const own = stopsOf(el);\n if (own.length) return own[Math.max(0, Math.min(index, own.length - 1))];\n }\n return null;\n };\n const sameBefore = neighbour(\"previousElementSibling\");\n const sameAfter = neighbour(\"nextElementSibling\");\n const gone = () => !control.isConnected || (control instanceof HTMLButtonElement && control.disabled);\n const lost = () => {\n const active = document.activeElement;\n return !active || active === document.body || !active.isConnected || active === control;\n };\n const land = (el: HTMLElement | null | undefined) => {\n if (!el || !el.isConnected || !isTabStop(el)) return false;\n el.focus();\n return document.activeElement === el;\n };\n const landOnGroup = () => {\n if (!within?.isConnected) return false;\n // a group that takes no focus is given it for the moment, as an error summary is (focus by script, never by Tab)\n if (!within.hasAttribute(\"tabindex\") && within.tabIndex < 0) within.setAttribute(\"tabindex\", \"-1\");\n within.focus();\n return document.activeElement === within;\n };\n const landTo = (el: HTMLElement | null | undefined) => land(el) || (!!el && el.isConnected && !isTabStop(el) && isRendered(el) && focusForTheMoment(el));\n const place = () => landTo(typeof to === \"function\" ? to() : to) || land(sameBefore) || before.some(land) || land(sameAfter) || after.some(land) || landOnGroup();\n if (typeof MutationObserver === \"undefined\") return () => {};\n const observer = new MutationObserver(() => {\n if (!gone()) return;\n stop();\n if (lost()) place();\n });\n const onFocusIn = (e: FocusEvent) => { if (e.target !== control) stop(); };\n const timer = setTimeout(() => stop(), 10_000);\n function stop() {\n observer.disconnect();\n clearTimeout(timer);\n // its timer can outlive the page (a test's)\n if (typeof document !== \"undefined\") document.removeEventListener(\"focusin\", onFocusIn, true);\n }\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: [\"disabled\"] });\n document.addEventListener(\"focusin\", onFocusIn, true);\n return stop;\n}\n\n// ─── Overlay layers ──────────────────────────────────────────────────────────\n// Every overlay that closes on Escape listens on `document`, so a Dropdown open\n// inside a Drawer used to close both with one key press. Open overlays register\n// here in the order they opened; only the topmost one acts on a global key.\n// (Two overlays opening in the same commit register child-first; in practice\n// overlays open one user action at a time.)\n\nconst layers: symbol[] = [];\n\n/**\n * Register this overlay as a layer while `open`. Returns a stable predicate\n * that is true when this overlay is the topmost open one — check it before\n * acting on Escape or trapping Tab.\n */\nexport function useOverlayLayer(open: boolean): () => boolean {\n const [id] = useState(() => Symbol(\"overlay-layer\"));\n useEffect(() => {\n if (!open) return;\n layers.push(id);\n return () => {\n const i = layers.indexOf(id);\n if (i >= 0) layers.splice(i, 1);\n };\n }, [open, id]);\n return useCallback(() => layers[layers.length - 1] === id, [id]);\n}\n\n/** Number of registered overlay layers (test seam). */\nexport function getOverlayLayerCount(): number {\n return layers.length;\n}\n\n// ─── Close on focus-out ──────────────────────────────────────────────────────\n\n/**\n * Close a non-modal popover (menu, picker, panel) when keyboard focus leaves\n * both its trigger and its panel — Tab and Shift+Tab out, or focus leaving the\n * document. Nested overlays (a Dropdown inside a Popover) register a layer on\n * top, so focus moving into them does not count as leaving. A pointer-down on\n * a non-focusable spot inside the panel briefly sends focus to body; that is\n * ignored so clicking panel chrome never closes it.\n */\nexport function useCloseOnFocusOut(\n open: boolean,\n triggerRef: RefObject<HTMLElement | null>,\n panelRef: RefObject<HTMLElement | null>,\n onClose: () => void,\n isTop: () => boolean = ALWAYS_TOP,\n) {\n // Latest-value ref written in a layout effect, not during render (React Compiler `refs` rule).\n const onCloseRef = useLatest(onClose);\n useEffect(() => {\n if (!open) return;\n let pointerInside = false;\n const inside = (n: EventTarget | Node | null) =>\n n instanceof Node && (!!triggerRef.current?.contains(n) || !!panelRef.current?.contains(n));\n const onPointerDown = (e: PointerEvent) => { pointerInside = inside(e.target); };\n const onFocusOut = (e: FocusEvent) => {\n if (!inside(e.target)) return;\n if (e.relatedTarget) {\n if (!inside(e.relatedTarget) && isTop()) onCloseRef.current();\n return;\n }\n setTimeout(() => {\n if (pointerInside) { pointerInside = false; return; }\n if (!inside(document.activeElement) && isTop()) onCloseRef.current();\n }, 0);\n };\n document.addEventListener(\"pointerdown\", onPointerDown, true);\n document.addEventListener(\"focusout\", onFocusOut, true);\n return () => {\n document.removeEventListener(\"pointerdown\", onPointerDown, true);\n document.removeEventListener(\"focusout\", onFocusOut, true);\n };\n }, [open, triggerRef, panelRef, isTop, onCloseRef]);\n}\n\n// ─── Close on a press outside ───────────────────────────────────────────────\n\n/**\n * Marks the presses that pass through a component's React tree, so a document\n * listener can tell a press inside it from one outside (Sprint 25.7; Radix's\n * dismissable layer). A popup that content inside it renders elsewhere in the\n * page — a Dropdown's list, a DatePicker's calendar, a Dialog — is outside its\n * element tree, but React carries the press through its own tree first. Spread\n * `props` on the tree's outer element; `marked(e)` is true for a pointer or\n * mouse press that went through it.\n */\nexport function usePressMarks() {\n const [marks] = useState(() => new WeakSet<Event>());\n return useMemo(() => {\n const mark = (e: { nativeEvent: Event }) => { marks.add(e.nativeEvent); };\n return { props: { onPointerDownCapture: mark, onMouseDownCapture: mark }, marked: (e: Event) => marks.has(e) };\n }, [marks]);\n}\n\n/**\n * Call `onOutside` for a pointer press outside `ref`'s element and its React\n * tree (Sprint 25.7): spread the returned handler on the element. For a\n * container that is not an overlay layer (the builder's floating toolbar).\n */\nexport function usePressOutside(enabled: boolean, ref: RefObject<HTMLElement | null>, onOutside: (e: PointerEvent) => void) {\n const onOutsideRef = useLatest(onOutside);\n const { props, marked } = usePressMarks();\n useEffect(() => {\n if (!enabled) return;\n const onPointerDown = (e: PointerEvent) => {\n if (marked(e) || (e.target instanceof Node && ref.current?.contains(e.target))) return;\n onOutsideRef.current(e);\n };\n document.addEventListener(\"pointerdown\", onPointerDown);\n return () => document.removeEventListener(\"pointerdown\", onPointerDown);\n }, [enabled, ref, onOutsideRef, marked]);\n return { onPointerDownCapture: props.onPointerDownCapture };\n}\n\n// ─── Leaving a component ─────────────────────────────────────────────────────\n\n/**\n * Focus leaving a component: a blur that no focus inside its React tree follows straight away (round 26's Field check,\n * shared with DataGrid's cell editor in Sprint 25.8.7 item 19). React carries focus events through portals, so focus\n * moving into the component's own popup (a Dropdown's list, a DatePicker's calendar) comes back in and is not leaving.\n * Spread the handlers on the component's outer element; `onLeave` runs a task after the blur, once focus has gone.\n */\nexport function useFocusLeave(onLeave: () => void): { onFocusCapture: () => void; onBlurCapture: () => void } {\n const onLeaveRef = useLatest(onLeave);\n const leaving = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => () => { if (leaving.current) clearTimeout(leaving.current); }, []);\n return useMemo(() => ({\n onFocusCapture: () => {\n if (leaving.current) { clearTimeout(leaving.current); leaving.current = null; }\n },\n onBlurCapture: () => {\n if (leaving.current) clearTimeout(leaving.current);\n leaving.current = setTimeout(() => {\n leaving.current = null;\n onLeaveRef.current();\n }, 0);\n },\n }), [onLeaveRef]);\n}\n\n// ─── Popup focus (Sprint 25.7) ───────────────────────────────────────────────\n// Every non-modal popup — a list, a menu, a picker, a panel — renders in a portal\n// at the end of <body>. Without help, a choice removes the focused option and\n// focus falls to the page, and Tab out of the panel moves on from the end of the\n// document. usePopupFocus hands focus back and makes Tab carry on from the\n// control that opened the popup, in the browser's own order.\n\nexport type PopupTabExits = \"any\" | \"edges\" | \"none\";\n\ninterface OpenPopup {\n panel: RefObject<HTMLElement | null>;\n tabExits: PopupTabExits;\n leave: (e: KeyboardEvent) => void;\n}\n\n/** Open popups, so a popup inside another popup's panel can hand a Tab exit on to it. */\nconst openPopups = new Map<symbol, OpenPopup>();\n\nexport interface PopupFocusOptions {\n trigger: RefObject<HTMLElement | null>;\n panel: RefObject<HTMLElement | null>;\n /** Closes the popup (sets its open state false). */\n close: () => void;\n /**\n * How Tab leaves the panel. \"any\": every Tab leaves (single-stop lists and\n * menus). \"edges\": Tab leaves from the panel's last Tab stop and Shift+Tab\n * from its first (panels with several stops). \"none\": focus never enters the\n * panel (a combobox keeps it in its input), so the browser's Tab is left alone.\n */\n tabExits: PopupTabExits;\n /** Runs first when Tab leaves, before the popup closes — a list commits the option the user moved to (D14(a)). */\n onTabOut?: (e: KeyboardEvent) => void;\n /**\n * True for a press that went through the popup's React tree (`usePressMarks`), so a press in a list its content\n * opened elsewhere in the page is not a press outside it.\n */\n marked?: (e: Event) => boolean;\n}\n\n/**\n * Focus for a non-modal popup (Sprint 25.7, P10):\n * - records the opener when the popup opens (the trigger when focus was on the page);\n * - closes on focus-out, and registers the overlay layer (`isTop`);\n * - Tab out of the panel closes it and carries on from the opener: Shift+Tab lands\n * on the opener; Tab puts focus on the opener and lets the browser's own Tab run,\n * except that inside a modal the opener's being its last stop wraps to its first,\n * and inside another popup's panel that popup's own exit rule then applies;\n * - on close, when focus was lost (the focused option went with the panel), puts it\n * back — unless the close followed a press outside the popup and its React tree\n * (`marked`), or the page changed; inside a modal, a press outside that left focus\n * on nothing gives it back too, so focus never drops out of the modal;\n * - returns `returnFocus()`, which a select handler calls before the consumer's\n * callback so a dialog that callback opens records the opener, and any focus\n * move the consumer makes wins.\n */\nexport function usePopupFocus(open: boolean, { trigger, panel, close, tabExits, onTabOut, marked }: PopupFocusOptions) {\n const isTop = useOverlayLayer(open);\n const [id] = useState(() => Symbol(\"popup\"));\n const closeRef = useLatest(close);\n const onTabOutRef = useLatest(onTabOut);\n const markedRef = useLatest(marked);\n const remembered = useRef<RememberedFocus | null>(null);\n // The last press while open, and whether it was in the trigger or panel; a key press since clears it.\n const lastPress = useRef<{ e: Event; inside: boolean } | null>(null);\n const wasOpen = useRef(false);\n\n useCloseOnFocusOut(open, trigger, panel, close, isTop);\n\n // The opener, as it was before this commit (content with autoFocus moves focus in during it).\n const before = useFocusBeforeOpen(open);\n useLayoutEffect(() => {\n if (!open) return;\n const active = before.current;\n const inPanel = active instanceof Node && !!panel.current?.contains(active);\n const opener = active instanceof HTMLElement && active !== document.body && !inPanel ? active : trigger.current;\n remembered.current = opener ? rememberFocus(opener) : null;\n // kept by the panel, for an overlay opened from inside it that outlives it (Sprint 25.29 item 4)\n if (panel.current && remembered.current) openers.set(panel.current, remembered.current);\n lastPress.current = null;\n }, [open, trigger, panel, before]);\n\n useEffect(() => {\n if (!open) return;\n const onPointerDown = (e: PointerEvent) => {\n const t = e.target;\n lastPress.current = { e, inside: t instanceof Node && (!!trigger.current?.contains(t) || !!panel.current?.contains(t)) };\n };\n const onKeyPress = () => { lastPress.current = null; };\n const leave = (e: KeyboardEvent) => {\n onTabOutRef.current?.(e);\n const r = remembered.current;\n const opener = r && r.el.isConnected ? r.el : trigger.current;\n // Focus the opener, then close now, so the panel is gone before the browser moves focus on.\n opener?.focus();\n flushSync(() => closeRef.current());\n if (!opener || !opener.isConnected) return;\n if (e.shiftKey) {\n e.preventDefault();\n return;\n }\n const modal = opener.closest<HTMLElement>('[aria-modal=\"true\"]');\n if (modal) {\n const stops = tabStops(modal);\n if (stops.length && stops[stops.length - 1] === opener) {\n e.preventDefault();\n stops[0].focus();\n return;\n }\n }\n for (const [otherId, other] of openPopups) {\n const outer = other.panel.current;\n if (otherId === id || !outer?.contains(opener)) continue;\n const stops = tabStops(outer);\n if (other.tabExits === \"any\" || stops[stops.length - 1] === opener) {\n other.leave(e);\n return;\n }\n break;\n }\n // The browser's own Tab carries on from the opener.\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== \"Tab\" || e.defaultPrevented || tabExits === \"none\" || !isTop()) return;\n const p = panel.current;\n const active = document.activeElement;\n if (!p || !(active instanceof Node) || !p.contains(active)) return;\n if (tabExits === \"edges\") {\n const stops = tabStops(p);\n if (stops.length && active !== (e.shiftKey ? stops[0] : stops[stops.length - 1])) return;\n }\n leave(e);\n };\n openPopups.set(id, { panel, tabExits, leave });\n document.addEventListener(\"pointerdown\", onPointerDown, true);\n document.addEventListener(\"keydown\", onKeyPress, true);\n document.addEventListener(\"keydown\", onKeyDown);\n return () => {\n openPopups.delete(id);\n document.removeEventListener(\"pointerdown\", onPointerDown, true);\n document.removeEventListener(\"keydown\", onKeyPress, true);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [open, tabExits, isTop, id, trigger, panel, closeRef, onTabOutRef]);\n\n // The safety net: a close the component could not see (content that closes it,\n // a choice that removed the focused option) puts focus back when it was lost.\n useLayoutEffect(() => {\n if (open) {\n wasOpen.current = true;\n return;\n }\n if (!wasOpen.current) return;\n wasOpen.current = false;\n const r = remembered.current;\n remembered.current = null;\n // A close that followed a press outside the popup (and outside its React tree) leaves focus to that press.\n const press = lastPress.current;\n if (!r) return;\n if (press && !press.inside && !markedRef.current?.(press.e)) {\n // Inside a modal, a press on nothing that takes focus (its text, its padding) would drop focus out of the modal\n // onto the page, so the control that opened the popup takes it back, once the press has done its own focusing\n // (Sprint 25.8.7 item 35: a date picker in a phone's sheet, closed by a tap beside it). On the page itself, focus\n // on nothing after a press on nothing is the browser's own, and stays.\n const modal = r.el.closest('[aria-modal=\"true\"]');\n const target = press.e.target;\n if (modal && target instanceof Node && modal.contains(target)) {\n setTimeout(() => {\n const active = document.activeElement;\n if (active && active !== document.body && active.isConnected) return;\n if (modal.isConnected) r.restore(trigger.current);\n }, 0);\n }\n return;\n }\n // Focus that is somewhere real stays there: the user or the consumer put it there. Focus on the opener is\n // checked again, because the choice may have deleted the opener's row in this commit (see rememberFocus).\n const active = document.activeElement;\n if (active !== r.el && active && active !== document.body && active.isConnected) return;\n r.restore(trigger.current);\n }, [open, trigger, markedRef]);\n\n // Removed while open with focus in it (a row menu whose Delete removed its own row): give focus back once the DOM\n // has settled. The panel is still in the page while this runs. A popup focus never went into (a flyout opened by\n // hover) leaves focus where it is.\n useLayoutEffect(() => () => {\n if (!wasOpen.current) return;\n const active = document.activeElement;\n if (!(active instanceof Node) || !(panel.current?.contains(active) || trigger.current?.contains(active))) return;\n const r = remembered.current;\n queueMicrotask(() => {\n const now = document.activeElement;\n if (now && now !== document.body && now.isConnected) return;\n r?.restore();\n });\n }, [panel, trigger]);\n\n const returnFocus = useCallback(() => {\n remembered.current?.restore(trigger.current);\n }, [trigger]);\n\n return { isTop, returnFocus };\n}\n\n// ─── Grid keyboard (Sprint 25.7, P11) ────────────────────────────────────────\n\nexport interface GridKeyboardOptions<K> {\n /** Holds the items, which carry `data-grid-key={keyOf(item)}`. */\n container: RefObject<HTMLElement | null>;\n /** The item that is the Tab stop. Keep it in step with focus (setActive from the item's onFocus). */\n active: K;\n setActive: (item: K) => void;\n keyOf: (item: K) => string;\n /** Where a key moves focus from `from` (arrows, Home, End: the caller's geometry), or null for a key it leaves alone. */\n move: (from: K, e: ReactKeyboardEvent) => K | null;\n /** Enter and Space on an item. */\n onActivate?: (item: K, e: ReactKeyboardEvent) => void;\n /**\n * Printable keys go to the next item whose label starts with what was typed in the last 500 ms (the same letter\n * again cycles). Never the zoom keys (+, = and −), never with Ctrl, ⌘ or Alt.\n */\n typeahead?: { items: readonly K[]; labelOf: (item: K) => string };\n /** Runs after focus moves to an item, in place of the browser's own scrolling (a time view keeps the item clear of its pinned column). */\n scrollIntoView?: (key: string, el: HTMLElement) => void;\n /**\n * Keys held with Ctrl, ⌘ or Alt go to `move` too: an APG grid's Ctrl+Home and Ctrl+End. Typeahead and activation\n * still ignore them. Off by default, so the browser keeps its own (Alt+Left is Back).\n */\n modifierKeys?: boolean;\n}\n\nexport interface GridKeyboard<K> {\n /** On the container. */\n onKeyDown: (e: ReactKeyboardEvent) => void;\n tabIndexOf: (item: K) => 0 | -1;\n /** Focus the active item (after the next render when it is not in the DOM yet). */\n focusActive: () => void;\n /** Focus an item, as a key would (after the next render when it is not in the DOM yet); keep `active` in step. */\n focus: (item: K) => void;\n}\n\nconst TYPEAHEAD_MS = 500;\n/** The keys a time view zooms with (TimeViewport), in and out; typeahead leaves them to it. U+2212 is the minus sign. */\nexport const ZOOM_KEYS: { readonly in: readonly string[]; readonly out: readonly string[] } = { in: [\"+\", \"=\"], out: [\"-\", \"\\u2212\"] };\nconst isZoomKey = (key: string) => ZOOM_KEYS.in.includes(key) || ZOOM_KEYS.out.includes(key);\n\nfunction focusGridKey(root: HTMLElement | null, key: string, scrollIntoView?: (key: string, el: HTMLElement) => void): boolean {\n const el = root?.querySelector<HTMLElement>(`[data-grid-key=\"${CSS.escape(key)}\"]`);\n if (!el) return false;\n el.focus(scrollIntoView ? { preventScroll: true } : undefined);\n scrollIntoView?.(key, el);\n return true;\n}\n\n/** The next item whose label starts with `text`: a new search (one letter, or one letter repeated) starts after `from`. */\nfunction typeaheadMatch<K>(items: readonly K[], labelOf: (item: K) => string, keyOf: (item: K) => string, fromKey: string, text: string): K | null {\n const chars = [...text];\n const query = chars.every((c) => c === chars[0]) ? chars[0] : text;\n const at = items.findIndex((item) => keyOf(item) === fromKey);\n const first = at < 0 ? 0 : at + (query.length === 1 ? 1 : 0);\n for (let k = 0; k < items.length; k++) {\n const item = items[(first + k) % items.length];\n if (labelOf(item).trim().toLocaleLowerCase().startsWith(query)) return item;\n }\n return null;\n}\n\n/**\n * One Tab stop over a grid or rows of items (APG grid and tree patterns): the caller says where each key moves\n * (`move`), and the hook keeps the roving tabindex and puts focus on the new item — after the next render when the\n * item is not in the DOM yet (a date grid moving into the next month). Enter and Space activate, typeahead jumps by\n * label, and `scrollIntoView` places the item. It works by key, not DOM position, so a virtualised list can use it.\n * Keys typed in a field inside the container are left alone. Built for the date pickers, extended in Part D for\n * time-axis rows (it is Sprint 2X.3's `useGridNavigation`).\n */\nexport function useGridKeyboard<K>({ container, active, setActive, keyOf, move, onActivate, typeahead, scrollIntoView, modifierKeys = false }: GridKeyboardOptions<K>): GridKeyboard<K> {\n const pending = useRef<string | null>(null);\n const typed = useRef({ text: \"\", at: 0 });\n // One try, on the render the move caused: a key that never renders is dropped, so a later render cannot steal focus.\n useLayoutEffect(() => {\n const key = pending.current;\n if (key === null) return;\n pending.current = null;\n focusGridKey(container.current, key, scrollIntoView);\n });\n const activeKey = keyOf(active);\n const go = (next: K) => {\n const key = keyOf(next);\n setActive(next);\n if (!focusGridKey(container.current, key, scrollIntoView)) pending.current = key;\n };\n const onKeyDown = (e: ReactKeyboardEvent) => {\n const modified = e.altKey || e.ctrlKey || e.metaKey;\n if (e.defaultPrevented || (modified && !modifierKeys)) return;\n // React passes on keys from a portal opened inside an item (a dialog, a menu): they are that popup's own\n if (!(e.currentTarget as Node).contains(e.target as Node)) return;\n const target = e.target instanceof HTMLElement ? e.target : null;\n if (target?.closest(FIELD)) return;\n const next = move(active, e);\n if (next !== null) {\n e.preventDefault();\n go(next);\n return;\n }\n // Activation and typeahead act on the item itself, not a control inside it, and never with a modifier held.\n if (modified || target?.getAttribute(\"data-grid-key\") !== activeKey) return;\n const buffered = typed.current.text !== \"\" && Date.now() - typed.current.at <= TYPEAHEAD_MS;\n if (onActivate && (e.key === \"Enter\" || (e.key === \" \" && !buffered))) {\n e.preventDefault();\n onActivate(active, e);\n return;\n }\n if (!typeahead || [...e.key].length !== 1 || isZoomKey(e.key) || (e.key === \" \" && !buffered)) return;\n const text = (buffered ? typed.current.text : \"\") + e.key.toLocaleLowerCase();\n typed.current = { text, at: Date.now() };\n const match = typeaheadMatch(typeahead.items, typeahead.labelOf, keyOf, activeKey, text);\n if (match === null) return;\n e.preventDefault();\n if (keyOf(match) !== activeKey) go(match);\n };\n const focus = (item: K) => {\n const key = keyOf(item);\n if (!focusGridKey(container.current, key, scrollIntoView)) pending.current = key;\n };\n const focusActive = () => focus(active);\n const tabIndexOf = (item: K): 0 | -1 => (keyOf(item) === activeKey ? 0 : -1);\n return { onKeyDown, tabIndexOf, focusActive, focus };\n}\n\n// ─── Focus trap ──────────────────────────────────────────────────────────────\n\nconst ALWAYS_TOP = () => true;\n\n/**\n * Keep Tab and Shift+Tab inside `root` while `active` (corpus: a modal\n * overlay owns keyboard focus until it closes). Focus that has escaped the\n * root — a portalled menu that just closed, or the body — is pulled back in on\n * the next Tab. Pass the predicate from `useOverlayLayer` so a nested overlay\n * on top of this one keeps its own keyboard handling.\n */\nexport function useFocusTrap(root: RefObject<HTMLElement | null>, active: boolean, isTop: () => boolean = ALWAYS_TOP, also?: RefObject<HTMLElement | null> | null) {\n useEffect(() => {\n if (!active) return;\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== \"Tab\" || e.defaultPrevented || !root.current || !isTop()) return;\n // the trap's scope: the overlay, and what stays in it outside the overlay (the shell's navbar above its phone menu,\n // Sprint 25.29 item 9), in the page's order\n const scope = [root.current, also?.current].filter((el): el is HTMLElement => !!el);\n const focusable = scope.flatMap((el) => tabStops(el))\n .sort((a, b) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1));\n if (focusable.length === 0) {\n e.preventDefault();\n return;\n }\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n const current = document.activeElement;\n const inside = current instanceof Node && scope.some((el) => el.contains(current));\n if (e.shiftKey) {\n if (!inside || current === first) {\n e.preventDefault();\n last.focus();\n }\n } else if (!inside || current === last) {\n e.preventDefault();\n first.focus();\n }\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [root, active, isTop, also]);\n}\n\n/**\n * Everything in `within` made inert but what `keep` holds (Sprint 25.29 item 9: the shell's phone menu is modal with the\n * navbar in its scope): the highest elements that hold none of it. Returns a function that undoes it; an element already\n * inert stays as the page made it.\n */\nexport function inertOutside(keep: Element[], within: Element): () => void {\n const made: Element[] = [];\n const visit = (el: Element) => {\n for (const child of Array.from(el.children)) {\n if (keep.includes(child)) continue;\n if (keep.some((k) => child.contains(k))) visit(child);\n else if (!child.hasAttribute(\"inert\")) {\n child.setAttribute(\"inert\", \"\");\n made.push(child);\n }\n }\n };\n visit(within);\n return () => { for (const el of made) el.removeAttribute(\"inert\"); };\n}\n\n// ─── Non-modal dialog ────────────────────────────────────────────────────────\n\n/**\n * The lifecycle of a persistent, non-modal dialog — an assistant panel the\n * user works alongside (Drawer with modal={false}, CornerPanel). Unlike a\n * popover it does not close when focus leaves; unlike a modal it never traps.\n *\n * While `active`: remembers the opener and gives focus back on close when focus\n * was lost or inside the panel, never from where the user moved it; moves focus\n * into the panel on open (first field, else first non-close control); closes on\n * Escape only while focus is inside the panel, it is the topmost layer and\n * nothing inside handled the key, so Escape elsewhere is untouched. Outside\n * clicks do nothing. Tab out of the panel is allowed — the panel is portalled to the end\n * of the document, so the last Tab reaches the browser chrome; a Launcher\n * shortcut is the way back in.\n */\nexport function useNonModalDialog(\n root: RefObject<HTMLElement | null>,\n active: boolean,\n onClose: () => void,\n isTop: () => boolean = ALWAYS_TOP,\n) {\n const onCloseRef = useLatest(onClose);\n useReturnFocus(active, root);\n useEffect(() => {\n if (!active) return;\n const raf = requestAnimationFrame(() => focusInitial(root.current));\n return () => cancelAnimationFrame(raf);\n }, [active, root]);\n useEffect(() => {\n if (!active) return;\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== \"Escape\" || e.defaultPrevented || !isTop()) return;\n const el = root.current;\n if (!el || !el.contains(document.activeElement)) return;\n e.preventDefault();\n onCloseRef.current();\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [active, root, isTop, onCloseRef]);\n}\n","import { useState, useCallback, useLayoutEffect, useRef, type RefObject } from \"react\";\n\nexport type Side = \"top\" | \"right\" | \"bottom\" | \"left\";\nexport type Align = \"start\" | \"center\" | \"end\";\n\ninterface PositionOptions {\n side?: Side;\n align?: Align;\n offset?: number;\n flip?: boolean;\n}\n\ninterface PositionResult {\n top: number;\n left: number;\n placement: Side;\n}\n\nconst VIEWPORT_PADDING = 8;\n\nexport function usePosition(\n triggerRef: RefObject<HTMLElement | null>,\n floatingRef: RefObject<HTMLElement | null>,\n open: boolean,\n options: PositionOptions = {}\n): PositionResult {\n const { side = \"bottom\", align = \"center\", offset = 8, flip = true } = options;\n const [pos, setPos] = useState<PositionResult>({ top: 0, left: 0, placement: side });\n const rafId = useRef(0);\n\n const compute = useCallback(() => {\n const trigger = triggerRef.current;\n const floating = floatingRef.current;\n if (!trigger || !floating) return;\n\n const tRect = trigger.getBoundingClientRect();\n const fRect = floating.getBoundingClientRect();\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n let placement = side;\n\n if (flip) {\n if (placement === \"bottom\" && tRect.bottom + offset + fRect.height > vh - VIEWPORT_PADDING && tRect.top - offset - fRect.height > VIEWPORT_PADDING) {\n placement = \"top\";\n } else if (placement === \"top\" && tRect.top - offset - fRect.height < VIEWPORT_PADDING && tRect.bottom + offset + fRect.height < vh - VIEWPORT_PADDING) {\n placement = \"bottom\";\n } else if (placement === \"right\" && tRect.right + offset + fRect.width > vw - VIEWPORT_PADDING && tRect.left - offset - fRect.width > VIEWPORT_PADDING) {\n placement = \"left\";\n } else if (placement === \"left\" && tRect.left - offset - fRect.width < VIEWPORT_PADDING && tRect.right + offset + fRect.width < vw - VIEWPORT_PADDING) {\n placement = \"right\";\n }\n }\n\n let top: number;\n let left: number;\n\n if (placement === \"bottom\" || placement === \"top\") {\n top = placement === \"bottom\" ? tRect.bottom + offset : tRect.top - fRect.height - offset;\n\n switch (align) {\n case \"start\":\n left = tRect.left;\n break;\n case \"end\":\n left = tRect.right - fRect.width;\n break;\n default:\n left = tRect.left + (tRect.width - fRect.width) / 2;\n }\n } else {\n left = placement === \"right\" ? tRect.right + offset : tRect.left - fRect.width - offset;\n\n switch (align) {\n case \"start\":\n top = tRect.top;\n break;\n case \"end\":\n top = tRect.bottom - fRect.height;\n break;\n default:\n top = tRect.top + (tRect.height - fRect.height) / 2;\n }\n }\n\n left = Math.max(VIEWPORT_PADDING, Math.min(left, vw - fRect.width - VIEWPORT_PADDING));\n top = Math.max(VIEWPORT_PADDING, Math.min(top, vh - fRect.height - VIEWPORT_PADDING));\n\n // the same place is no change: a scroll anywhere on the page, the popup's own list included, re-renders nothing (the\n // 25.17 second review: every scroll re-rendered an open list)\n setPos((cur) => (cur.top === top && cur.left === left && cur.placement === placement ? cur : { top, left, placement }));\n }, [triggerRef, floatingRef, side, align, offset, flip]);\n\n useLayoutEffect(() => {\n if (!open) return;\n\n compute();\n\n const onUpdate = () => {\n cancelAnimationFrame(rafId.current);\n rafId.current = requestAnimationFrame(compute);\n };\n\n window.addEventListener(\"scroll\", onUpdate, true);\n window.addEventListener(\"resize\", onUpdate);\n\n return () => {\n cancelAnimationFrame(rafId.current);\n window.removeEventListener(\"scroll\", onUpdate, true);\n window.removeEventListener(\"resize\", onUpdate);\n };\n }, [open, compute]);\n\n return pos;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRevealFocus } from './chunk-
|
|
3
|
-
import { tabStops } from './chunk-
|
|
2
|
+
import { useRevealFocus } from './chunk-WWN6CQKI.js';
|
|
3
|
+
import { tabStops } from './chunk-4HJDOZ2M.js';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
|
|
6
6
|
function useKeyboardScroll(el, label, enabled = true, nameFromHeading = false, axis = "y") {
|
|
@@ -34,7 +34,8 @@ function useKeyboardScroll(el, label, enabled = true, nameFromHeading = false, a
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
const update = () => {
|
|
37
|
-
const
|
|
37
|
+
const wide = el.scrollWidth > el.clientWidth + 1, tall = el.scrollHeight > el.clientHeight + 1;
|
|
38
|
+
const overflows = axis === "x" ? wide : axis === "both" ? wide || tall : tall;
|
|
38
39
|
const scrolls = overflows && tabStops(el).length === 0;
|
|
39
40
|
set(scrolls || el.hasAttribute("data-scroll-stop") && document.activeElement === el);
|
|
40
41
|
};
|
|
@@ -54,5 +55,5 @@ function useKeyboardScroll(el, label, enabled = true, nameFromHeading = false, a
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export { useKeyboardScroll };
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-ACLKDE5W.js.map
|
|
59
|
+
//# sourceMappingURL=chunk-ACLKDE5W.js.map
|