gridsmith-ui 0.30.2 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +71 -1
  2. package/dist/charts.d.ts +114 -1
  3. package/dist/charts.js +1113 -206
  4. package/dist/charts.js.map +1 -1
  5. package/dist/chat.js +20 -12
  6. package/dist/chat.js.map +1 -1
  7. package/dist/{chunk-HVGHGBKV.js → chunk-2TCCSKL3.js} +6 -7
  8. package/dist/chunk-2TCCSKL3.js.map +1 -0
  9. package/dist/{chunk-L6HWACK7.js → chunk-53F7GVBQ.js} +6 -3
  10. package/dist/chunk-53F7GVBQ.js.map +1 -0
  11. package/dist/chunk-BHTAVJIG.js +285 -0
  12. package/dist/chunk-BHTAVJIG.js.map +1 -0
  13. package/dist/{chunk-WWN6CQKI.js → chunk-DR6WEI3A.js} +60 -7
  14. package/dist/chunk-DR6WEI3A.js.map +1 -0
  15. package/dist/{chunk-4HJDOZ2M.js → chunk-EZ3ZGFGA.js} +203 -34
  16. package/dist/chunk-EZ3ZGFGA.js.map +1 -0
  17. package/dist/{chunk-MIUSSYVE.js → chunk-HQFTP7Y5.js} +27 -52
  18. package/dist/chunk-HQFTP7Y5.js.map +1 -0
  19. package/dist/{chunk-SIWERRP2.js → chunk-I6JJ7KKP.js} +14 -15
  20. package/dist/chunk-I6JJ7KKP.js.map +1 -0
  21. package/dist/chunk-IOHGE4EW.js +755 -0
  22. package/dist/chunk-IOHGE4EW.js.map +1 -0
  23. package/dist/{chunk-USHW523V.js → chunk-IZW5XHKA.js} +73 -699
  24. package/dist/chunk-IZW5XHKA.js.map +1 -0
  25. package/dist/{chunk-ZASGFL5D.js → chunk-K3NAFQ4S.js} +3 -4
  26. package/dist/chunk-K3NAFQ4S.js.map +1 -0
  27. package/dist/{chunk-ACLKDE5W.js → chunk-KSJTMSYA.js} +23 -11
  28. package/dist/chunk-KSJTMSYA.js.map +1 -0
  29. package/dist/{chunk-SQHKC4HA.js → chunk-NDL2JGQ7.js} +8 -7
  30. package/dist/chunk-NDL2JGQ7.js.map +1 -0
  31. package/dist/{chunk-TYNDXMBV.js → chunk-QOMP4D6V.js} +3 -3
  32. package/dist/{chunk-TYNDXMBV.js.map → chunk-QOMP4D6V.js.map} +1 -1
  33. package/dist/{chunk-BZRZENBS.js → chunk-SLGGZ3MU.js} +6 -6
  34. package/dist/{chunk-BZRZENBS.js.map → chunk-SLGGZ3MU.js.map} +1 -1
  35. package/dist/{chunk-K6IDOCGE.js → chunk-TH272DIC.js} +10 -10
  36. package/dist/{chunk-K6IDOCGE.js.map → chunk-TH272DIC.js.map} +1 -1
  37. package/dist/chunk-V73LHNRL.js +51 -0
  38. package/dist/chunk-V73LHNRL.js.map +1 -0
  39. package/dist/{chunk-ZCDA74RQ.js → chunk-W3GY5ROH.js} +3 -3
  40. package/dist/{chunk-ZCDA74RQ.js.map → chunk-W3GY5ROH.js.map} +1 -1
  41. package/dist/data-grid.js +11 -12
  42. package/dist/data-grid.js.map +1 -1
  43. package/dist/editor-mentions.js +2 -3
  44. package/dist/editor-mentions.js.map +1 -1
  45. package/dist/editor.js +4 -6
  46. package/dist/editor.js.map +1 -1
  47. package/dist/icons.js +1 -1
  48. package/dist/index.d.ts +100 -16
  49. package/dist/index.js +1177 -660
  50. package/dist/index.js.map +1 -1
  51. package/dist/kanban.js +10 -11
  52. package/dist/kanban.js.map +1 -1
  53. package/dist/resizable.js +10 -11
  54. package/dist/resizable.js.map +1 -1
  55. package/dist/virtualized.js +11 -12
  56. package/dist/virtualized.js.map +1 -1
  57. package/package.json +1 -1
  58. package/dist/chunk-4HJDOZ2M.js.map +0 -1
  59. package/dist/chunk-6C2IUMY7.js +0 -46
  60. package/dist/chunk-6C2IUMY7.js.map +0 -1
  61. package/dist/chunk-7Q46JXSK.js +0 -51
  62. package/dist/chunk-7Q46JXSK.js.map +0 -1
  63. package/dist/chunk-ACLKDE5W.js.map +0 -1
  64. package/dist/chunk-HVGHGBKV.js.map +0 -1
  65. package/dist/chunk-L6HWACK7.js.map +0 -1
  66. package/dist/chunk-MIUSSYVE.js.map +0 -1
  67. package/dist/chunk-NKUCS67T.js +0 -13
  68. package/dist/chunk-NKUCS67T.js.map +0 -1
  69. package/dist/chunk-SIWERRP2.js.map +0 -1
  70. package/dist/chunk-SQHKC4HA.js.map +0 -1
  71. package/dist/chunk-USHW523V.js.map +0 -1
  72. package/dist/chunk-WWN6CQKI.js.map +0 -1
  73. package/dist/chunk-YL5KD5RC.js +0 -49
  74. package/dist/chunk-YL5KD5RC.js.map +0 -1
  75. package/dist/chunk-ZASGFL5D.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../showcase/src/lib/use-latest.ts","../../../showcase/src/lib/focus.ts","../../../showcase/src/lib/utils.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,GAAmB;AAChC,IAAM,WAAA,GAAc,0CAAA;AAGb,IAAM,kBAAA,GAAqB;AAKlC,SAAS,WAAW,EAAA,EAA0B;AAC5C,EAAA,IAAI,OAAO,EAAA,CAAG,eAAA,KAAoB,UAAA,EAAY,OAAO,GAAG,eAAA,CAAgB,EAAE,kBAAA,EAAoB,IAAA,EAAM,CAAA;AACpG,EAAA,KAAA,IAAS,CAAA,GAAoB,EAAA,EAAI,CAAA,EAAG,CAAA,GAAI,EAAE,aAAA,EAAe;AACvD,IAAA,IAAI,CAAA,YAAa,WAAA,IAAe,CAAA,CAAE,MAAA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K,GAAA,CAAI,gBAAA,EAAkB,IAAA,CAAK,GAAA,CAAI,KAAK,EAAA,GAAK,KAAA,CAAM,MAAA,GAAS,gBAAgB,CAAC,CAAA;AAIpF,IAAA,MAAA,CAAO,CAAC,GAAA,KAAS,GAAA,CAAI,GAAA,KAAQ,GAAA,IAAO,IAAI,IAAA,KAAS,IAAA,IAAQ,GAAA,CAAI,SAAA,KAAc,YAAY,GAAA,GAAM,EAAE,GAAA,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-EZ3ZGFGA.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/**\n * Whether `root` holds a Tab stop at all: the first one found ends the search, with no order to sort (Sprint 25.31 item 7:\n * the shell's `<main>` asked it of the whole page on every change).\n */\nexport function hasTabStop(root: ParentNode): boolean {\n for (const el of root.querySelectorAll(FOCUSABLE)) if (isTabStop(el)) return true;\n return false;\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/**\n * The page the address names, for a rule that never acts across a change of page (Sprint 25.32): its path, and a hash\n * router's route (`#/settings`, the review of 18 October), never an in-page link's `#section` or a query.\n */\nexport function pageAddress(): string {\n const { pathname, hash } = location;\n return /^#!?\\//.test(hash) ? pathname + hash.replace(/\\?.*$/, \"\") : pathname;\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/**\n * Whether focus lands anywhere from now on, until `stop` (Sprint 25.32). A last resort acts only on focus that stayed on\n * nothing for its whole wait: a place that took focus meanwhile (a component's own, the page's) stands it down, though the\n * user let focus go again before the wait ended. Round 29's calendar-repeats race: a deleted event's day had focus, the\n * user clicked plain text, and the last resort, looking a moment later, found focus on nothing and pulled it back.\n */\nfunction focusLandings(): { readonly landed: boolean; stop: () => void } {\n let landed = false;\n const onIn = () => { landed = true; };\n document.addEventListener(\"focusin\", onIn, true);\n // its timer can outlive the page (a test's): with no document left, there's nothing to stop\n return { get landed() { return landed; }, stop: () => { if (typeof document !== \"undefined\") document.removeEventListener(\"focusin\", onIn, true); } };\n}\n\n/** Keys that scroll the page when focus is on nothing. */\nconst SCROLL_KEYS = new Set([\"PageDown\", \"PageUp\", \"Home\", \"End\", \"ArrowDown\", \"ArrowUp\", \"ArrowLeft\", \"ArrowRight\", \" \"]);\n\n/** Out of the keyboard's reach for now (disabled, or by a fieldset; inert), though still on the page. */\nconst unreachable = (el: Element) => el.matches(\":disabled\") || !!el.closest(\"[inert]\");\n\n/**\n * The user moving on from a control, which ends a watch on it (Sprint 25.32's reviews: a click on plain text, then the\n * server's answer, pulled focus back): focus taken elsewhere; focus let go on the page with the control still here, in\n * reach and drawn (Chrome fires a removal's focusout as the control goes, and takes focus off a control disabled, made\n * inert or hidden a frame later: none of them the user's); a pointer's press; a scroll by wheel, touch or key (the third\n * and fourth reviews: PageDown away, then focus and the page pulled back). Calls `done`, at most until the function it\n * returns stops listening.\n */\nfunction onMovingOn(control: HTMLElement, done: () => void): () => void {\n let live = true;\n const end = () => { if (live) done(); };\n const onFocusIn = (e: FocusEvent) => { if (e.target !== control) end(); };\n const onFocusOut = (e: FocusEvent) => {\n if (e.target !== control) return;\n queueMicrotask(() => {\n if (typeof document === \"undefined\") return;\n if (control.isConnected && !unreachable(control) && isRendered(control) && document.activeElement !== control) end();\n });\n };\n // a scroll by key: with focus on nothing, or on the control itself, whose Space is its press (the fourth review: PageDown\n // while the server answered, then focus and the page pulled back)\n const onKey = (e: KeyboardEvent) => {\n const active = document.activeElement;\n if (SCROLL_KEYS.has(e.key) && (!active || active === document.body || (active === control && e.key !== \" \"))) end();\n };\n const listeners: [string, (e: never) => void, AddEventListenerOptions][] = [\n [\"focusin\", onFocusIn, { capture: true }],\n [\"focusout\", onFocusOut, { capture: true }],\n [\"pointerdown\", end, { capture: true }],\n [\"wheel\", end, { capture: true, passive: true }],\n [\"touchmove\", end, { capture: true, passive: true }],\n [\"keydown\", onKey, { capture: true }],\n ];\n for (const [type, fn, opts] of listeners) document.addEventListener(type, fn as EventListener, opts);\n return () => {\n live = false;\n // a watch's timer can outlive its page (a test's)\n if (typeof document !== \"undefined\") for (const [type, fn, opts] of listeners) document.removeEventListener(type, fn as EventListener, opts);\n };\n}\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\nconst DIALOG = 'dialog, [role=\"dialog\"], [role=\"alertdialog\"], [aria-modal=\"true\"]';\n\n/**\n * A live range round an element's contents (Sprint 25.32 D1). Once the element has gone the DOM keeps the range where it\n * stood, through any number of removals (a row with its divider, a fragment), as Chrome keeps the place its next Tab goes\n * on from: content drawn there since comes after it, content drawn just before the element while it waited comes before.\n * Taken while the element is in the page, before whatever takes it away runs.\n */\nexport function pointOf(el: Element): Range {\n const point = document.createRange();\n point.selectNodeContents(el);\n return point;\n}\n\n/**\n * Where the browser's own Tab would go on from content that went (Sprint 25.32 D1, with its plan review): the first Tab\n * stop after the point, else the last before it, within the layer the point is in. The layer is the dialog round it,\n * else the part of the page holding it (the app, or a portal of its own): never the toast stack, a popover or another\n * dialog, so a deleted last row never sends focus to a toast's Undo. A stop compares after the point only when wholly\n * after it: a focusable container round the point is before it, as Shift+Tab treats it. A destructive control is no\n * exception, as Tab reaches it: a red button belongs in a confirmation dialog, which opens on its safe action\n * (`gs:destructive-button-outside-confirmation` flags any other), and an inline confirmation in its wrapper alone reuses\n * the pressed button, so no rule here could reach it (Part E's plan review). With nothing in the layer, the last resort, which ends at `<main>`'s first stop for a portal of its own, where the skip\n * link goes; a dialog keeps its own focus handling, so nothing behind it takes focus. True when focus landed.\n */\nfunction landWhereTabGoes(point: Range, places: Place[]): boolean {\n const at = point.startContainer;\n const from = at instanceof Element ? at : at.parentElement;\n if (!from?.isConnected) return landLastResort(places);\n const dialog = from.closest<HTMLElement>(DIALOG);\n let layer: Element | null = dialog;\n if (!layer) for (let el: Element | null = from; el && el !== document.body; el = el.parentElement) layer = el;\n if (!layer) return landLastResort(places);\n const stops = tabStops(layer);\n const next = stops.findIndex((s) => point.comparePoint(s, 0) === 1);\n const to = next >= 0 ? stops[next] : stops.at(-1);\n if (to) {\n to.focus();\n if (document.activeElement === to) return true;\n }\n return !dialog && landLastResort(places);\n}\n\n/** The request a closed section answers by opening, for focus sent into it (Sprint 25.32 D2). */\nexport const OPEN_TO_FOCUS = \"ds-open-to-focus\";\n/** What a request to open carries: the element focus is for, the caller's own scroll-and-focus step, and when. */\nexport interface OpenToFocus { target: HTMLElement; step: () => void; done: boolean; at: number }\n\n/**\n * Focus sent to an element a closed section hides (Sprint 25.32 D2, with its plan review: a form's only invalid field in\n * a closed Collapsible was inert, so the form's focus did nothing, and the error was neither seen nor heard). With nothing\n * hiding it, the caller's own scroll-and-focus `step` runs at once. Else the request goes up from the element: each\n * closed section round it opens, and the step runs in the commit that leaves the element reachable, so the caller's own\n * scroll lands on the open field. A request no section takes, or a page keeps closed, does nothing.\n */\nexport function openToFocus(target: HTMLElement, step: () => void): void {\n if (!target.closest(\"[inert]\")) {\n step();\n return;\n }\n target.dispatchEvent(new CustomEvent<OpenToFocus>(OPEN_TO_FOCUS, { bubbles: true, detail: { target, step, done: false, at: performance.now() } }));\n}\n\n/**\n * Focus moved out of an element about to be hidden, before it is (Sprint 25.32's review: a Collapsible with no trigger to\n * go back to, closed by a control inside it, was made inert with focus in it, and the browser dropped focus to the page):\n * to the Tab stop before it, where Shift+Tab goes, else the last resort round where it sat. True when focus landed.\n */\nexport function focusOutOf(el: HTMLElement): boolean {\n // within the dialog it sits in: a Tab stop before it outside the dialog is behind it (the second review)\n const root = el.closest<HTMLElement>(DIALOG) ?? document.body;\n const before = tabStops(root).filter((s) => !el.contains(s) && el.compareDocumentPosition(s) & Node.DOCUMENT_POSITION_PRECEDING).at(-1);\n if (before) {\n before.focus();\n if (document.activeElement === before) return true;\n }\n return landLastResort(placesOf(el), el);\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 const landings = focusLandings();\n setTimeout(() => {\n landings.stop();\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) || landings.landed || 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 timer = setTimeout(() => stop(), 10_000);\n // the user moving on ends it, as a self-removal's watch (the second review: a blur and a click on plain text, then the\n // row's deletion, pulled focus to the row before)\n const quit = onMovingOn(el, () => stop());\n function stop() {\n observer.disconnect();\n clearTimeout(timer);\n quit();\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 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/**\n * Each overlay's last resort still waiting, by the overlay's element, with what stops it (Sprint 25.31 item 2). The overlay\n * opening again stops it: StrictMode's rehearsal unmounts an overlay open from the start and mounts it again, which armed\n * its way back while it stayed open, and 200 ms on that took focus from inside it to the page behind it. So does a remount\n * or a quick reopen.\n */\nconst waiting = new WeakMap<Element, () => void>();\n\n/** How long a way back watches for the overlay it came from to go (Sprint 25.31 item 2), as the removal watches do. */\nconst WATCH_MS = 10_000;\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 /**\n * As RememberedFocus's; else, with the overlay the opener sat in closed, that overlay's own opener. With nothing to go\n * back to, the last resort round where the overlay sat. `closed`: the overlay's open state turned false, so it's on\n * its way out and focus left inside it is lost at once (Sprint 25.29 item 6). Without it, the overlay unmounted, which\n * StrictMode rehearses with the overlay still open, so focus inside it is lost only once it has left the page or is\n * hidden (Sprint 25.31 item 2).\n */\n restore(fallback?: HTMLElement | null, closed?: boolean): 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 // open again: the last resort its last close left waiting has nothing to do\n if (root) waiting.get(root)?.();\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(_fallback, closed = false) {\n const since = performance.now();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const stop = () => {\n clearTimeout(timer);\n if (waiting.get(root) === stop) waiting.delete(root);\n };\n const look = () => {\n // a page torn down in the meantime (a test's) has nowhere to land\n if (typeof document === \"undefined\") return;\n const now = document.activeElement;\n const real = !!now && now !== document.body && now.isConnected;\n if ((real && !root.contains(now)) || (location.pathname !== pathname && !pathAbove(location.pathname, pathname))) return stop();\n // unmounted, not closed: focus inside the overlay is lost only once the overlay has left the page or is hidden\n // (Sprint 25.31 item 2), since StrictMode's rehearsal leaves it open; until then, look again shortly. Closed, it's\n // on its way out, and nothing inside it is a place for focus (Sprint 25.29 item 6).\n if (real && !closed && root instanceof HTMLElement && isRendered(root)) {\n if (performance.now() - since < WATCH_MS) timer = setTimeout(look, 50);\n else stop();\n return;\n }\n stop();\n landLastResort(places, root);\n };\n timer = setTimeout(look, LAST_RESORT_MS);\n waiting.set(root, stop);\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(undefined, true);\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 /**\n * What the item sits in, whose controls are its neighbours. Default: the item's parent. Null for an item in no group of\n * its own (Load more's pager, which may sit in a layout's empty box, Sprint 25.31 item 4): with nowhere else, the last\n * resort round where it sat.\n */\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 * Act only while the page is the one the press was on (Sprint 25.32, R29-2). A Button watches every press, and a press\n * that navigates takes its button away with its page: the new page owns focus then (D14(d)).\n */\n samePage?: boolean;\n /**\n * Wait this long once the control has gone, and act only if it's still gone and focus is still on nothing then, with\n * focus landing nowhere meanwhile (Sprint 25.32): a Button's watch waits twice `LAST_RESORT_MS`, so the place a\n * component or the page gives focus after a removal goes first (a dialog's Close, gone with its dialog, whose focus goes\n * back to the button that opened it), and focus moves once.\n */\n defer?: number;\n /**\n * Only the control leaving the page counts as gone, not its being disabled (Sprint 25.32's reviews): a Button disabled\n * while its press is pending (`disabled={saving}`) is enabled again, and the handover moves nothing meanwhile. Focus\n * the browser takes off a disabled control (Chrome does, a frame after) stays where the browser puts it, as before.\n * A component that disables its own control for good (TransferList's \"Move all left\") leaves it off.\n */\n removedOnly?: boolean;\n /**\n * With no group, where the browser's own Tab would go on from (Sprint 25.32 D1): a live range round the control's\n * contents (`pointOf`), taken before the press acts. Focus goes to the first Tab stop after it in its layer, else the\n * last before it (`landWhereTabGoes`), never by the containers round where the item sat. The Button's handover; Load\n * more keeps its own last resort.\n */\n point?: Range;\n}\n\n/** The controls a self-removal watch is on now: a Button's own watch steps aside for a component's (Sprint 25.32). */\nconst watched = new WeakSet<HTMLElement>();\n/** Whether a watch is already on this control: a component that knows where focus belongs next set it first. */\nexport const hasSelfRemovalWatch = (control: HTMLElement): boolean => watched.has(control);\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. The watch ends when the user moves on (`onMovingOn`). With no group, focus goes\n * where the browser's own Tab would go on from `point` when it's given, else to the last resort round where the item\n * sat. A control already gone when the watch starts (its press took it away at once) is handled at once. Returns a\n * function that stops the watch.\n */\nexport function focusAfterSelfRemoval(control: HTMLElement, { item, group, to, samePage, defer, removedOnly, point }: 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 // in a group, the same control in the neighbouring item, as rememberFocus finds it in a row: the next tag's remove\n // button after a remove, so the keyboard can go on removing. Read only in a group: read with none, a keyboard press\n // beside a 3,000-row table took 30 ms (the second review)\n const stopsOf = (el: Element) => [...(isTabStop(el) ? [el] : []), ...tabStops(el)];\n const neighbour = (step: \"previousElementSibling\" | \"nextElementSibling\") => {\n const index = stopsOf(goes).indexOf(control);\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 = within ? neighbour(\"previousElementSibling\") : null;\n const sameAfter = within ? neighbour(\"nextElementSibling\") : null;\n const disabled = () => control.matches(\":disabled\");\n const gone = () => !control.isConnected || (!removedOnly && 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 // a group that takes no focus is given it for the moment, as an error summary is (focus by script, never by Tab); its\n // tabindex comes off as focus leaves it (focusForTheMoment, Sprint 25.31 item 4: it stayed, on a box left empty)\n const landOnGroup = () => !!within?.isConnected && focusForTheMoment(within);\n // no group: where the item sat, read now while it's in the page\n const places = within ? [] : placesOf(goes);\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) || (within ? landOnGroup() : point ? landWhereTabGoes(point, places) : landLastResort(places));\n if (typeof MutationObserver === \"undefined\") return () => {};\n const path = samePage && typeof location !== \"undefined\" ? pageAddress() : null;\n const samePlace = () => path === null || pageAddress() === path;\n let on = true;\n const look = () => {\n if (!gone()) return;\n if (!defer) {\n stop();\n if (lost() && samePlace()) place();\n return;\n }\n // the wait, still listening: focus landing anywhere meanwhile, or the user moving on, stands it down\n observer.disconnect();\n clearTimeout(timer);\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 act = on && gone() && lost() && samePlace();\n stop();\n if (act) place();\n }, defer);\n };\n const observer = new MutationObserver(look);\n const timer = setTimeout(() => stop(), 10_000);\n const quit = onMovingOn(control, () => stop());\n function stop() {\n on = false;\n observer.disconnect();\n clearTimeout(timer);\n watched.delete(control);\n quit();\n }\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: [\"disabled\"] });\n watched.add(control);\n // gone already: a handler that took its button away at once (flushSync), before the watch began\n look();\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 { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n\nexport const GLASS_BACKDROP = \"[backdrop-filter:var(--ds-glass-filter)] [-webkit-backdrop-filter:var(--ds-glass-filter)]\";\n\nexport const GLASS_SURFACE = `${GLASS_BACKDROP} shadow-[var(--ds-shadow-card),var(--ds-glass-inset)]`;\n\nexport const GLASS_OVERLAY = `${GLASS_BACKDROP} shadow-[var(--ds-shadow-modal),var(--ds-glass-inset)]`;\n\n/**\n * A modal surface (Dialog, Drawer, Sheet, CommandPalette, GlobalSearch): the theme's surface, never less than 85% opaque.\n * A glass theme's surface is see-through by design, which suits a card on the canvas; over an overlay's scrim the same\n * glass reads as grey mud, and the page shows through (round 27, R27-17, the owner picked 85% from a mock-up). An opaque\n * theme keeps its surface as it is: the alpha only rises, through CSS relative colour, in every mode and scope.\n *\n * The theme's surface comes first, for a browser without relative colour (Chrome before 119, Firefox before 128,\n * Safari before 16.4): a value holding var() is only found invalid once computed, which drops the background to\n * transparent rather than to an earlier declaration, so the raised one applies only where @supports says it can (the\n * round 27 review). A surface with no colour at all (fully transparent) stays so: raising it would paint it black.\n */\nexport const OVERLAY_SURFACE = \"bg-[var(--ds-bg-surface)] supports-[color:oklch(from_red_l_c_h)]:bg-[oklch(from_var(--ds-bg-surface)_l_c_h_/_max(alpha,min(1,alpha*1000)*0.85))]\";\n\nexport const GLASS_DROPDOWN = `${GLASS_BACKDROP} shadow-[var(--ds-shadow-dropdown),var(--ds-glass-inset)]`;\n\n// Keyboard focus (Sprint 30, the owner's D1 and D6): where Tab has landed. A solid outline in the theme's focus colour\n// (--ds-focus, derived to 3:1 on every ground), 2 px, with a 2 px gap between it and the element. The gap shows what the\n// element sits on, so one colour reads beside any fill, and while the outline shows, the element's own shadow steps\n// aside (D7, P12): shadow-none drops its --tw-shadow and keeps any ring. Every part is prefixed: an unprefixed\n// outline-solid draws an outline at rest. And outline-solid is required: in Tailwind 4, outline-none (which many\n// components set at rest) sets --tw-outline-style: none, which outline-2 reads, so without it no outline draws. These\n// draw no border (a button that uses one, the Launcher, gets the outline alone); a field takes FIELD_FOCUS_RING. `cn()`\n// keeps only the last of outline-none and outline-solid in one variant, so a component's own focus-visible:outline-none\n// after a utility would remove the outline: none may follow one.\nexport const FOCUS_RING = \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-[var(--ds-focus)] focus-visible:shadow-none\";\n\n/**\n * On a wrapper that shows focus for a control inside it: HAS_FOCUS_RING, from the keyboard only (`:has(:focus-visible)`).\n * FOCUS_WITHIN_RING shows it on any focus inside, a click's too, since `:focus-within` has no keyboard-only form: kept\n * for code that uses it, and a new wrapper takes HAS_FOCUS_RING (D6: keyboard focus shows only from the keyboard).\n */\nexport const FOCUS_WITHIN_RING = \"focus-within:outline-2 focus-within:outline-solid focus-within:outline-offset-2 focus-within:outline-[var(--ds-focus)] focus-within:shadow-none\";\n\nexport const HAS_FOCUS_RING = \"has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--ds-focus)] has-[:focus-visible]:shadow-none\";\n\n/**\n * The outline on a drawn child, where the element that takes focus is hidden or wraps it: a checkbox's box beside its\n * input (`peer`), a radio's circle inside its button, a separator's grip, a Gantt milestone's diamond (`group`). The\n * same outline, gap and shadow rule.\n */\nexport const PEER_FOCUS_RING = \"peer-focus-visible:outline-2 peer-focus-visible:outline-solid peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--ds-focus)] peer-focus-visible:shadow-none\";\n\nexport const GROUP_FOCUS_RING = \"group-focus-visible:outline-2 group-focus-visible:outline-solid group-focus-visible:outline-offset-2 group-focus-visible:outline-[var(--ds-focus)] group-focus-visible:shadow-none\";\n\n/**\n * The same outline drawn inside the element's edge, for edge-to-edge rows, cells and scroll regions only (the plan's\n * P3): elements that are never filled solid, since inside the edge there is no gap to keep one colour readable on a fill.\n * It sits `--ds-focus-inset` in: 5 px, deeper where the theme's corners are rounder, so it clears a table's rounded\n * corners (D8, the owner's decision A); what such an element holds keeps 1 px more clear of its edge. Anywhere else the\n * outline stays outside, with room made for it. Moved here from use-keyboard-scroll.ts (Sprint 30) so the server-safe\n * `gridsmith-ui/utils` can export it.\n */\nexport const FOCUS_INSET = \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-[var(--ds-focus-inset)] focus-visible:outline-[var(--ds-focus)]\";\n\n/**\n * FOCUS_INSET only while the element is a scroll region's Tab stop (useKeyboardScroll's `data-scroll-stop`), for one that\n * takes focus by script for another reason and shows no ring for it: the shell's <main>, the skip link's target (Sprint\n * 25.29 item 10).\n */\nexport const FOCUS_INSET_WHILE_STOP = \"data-[scroll-stop]:focus-visible:outline-2 data-[scroll-stop]:focus-visible:outline-solid data-[scroll-stop]:focus-visible:-outline-offset-[var(--ds-focus-inset)] data-[scroll-stop]:focus-visible:outline-[var(--ds-focus)]\";\n\n/**\n * The room FOCUS_RING's outline takes outside its element, in px: its 2 px gap and 2 px line (Sprint 30, P3). Where a\n * container clips, what sits beside its edge keeps this much clear of it: a fixed size, never a theme space. Internal,\n * as is the one below (exports/utils.ts exports by name).\n */\nexport const FOCUS_ROOM = 4;\n\n/** A theme's length that sets how far something sits from a clipping edge, never under FOCUS_ROOM (Sprint 25.27). */\nexport const atLeastFocusRoom = (length: string) => `max(${length}, ${FOCUS_ROOM}px)`;\n\n/**\n * A field (D6, P4, P13). Reached with Tab: the keyboard's outline, and its border in the focus colour, as GOV.UK turns a\n * focused input's border: it is where you type. Clicked into: the active look instead, the accent border and its soft\n * halo (`ring-2` in --ds-ring-active, laid over the field's own shadow), and no outline. A browser matches :focus-visible\n * on a text field either way, so lib/input-modality.ts notes on <html> whether a pointer moved focus last; with no note\n * yet, the outline. The field keeps its own (inset) shadow in both: no shadow-none here.\n *\n * The wrapper forms (_WITHIN_ and _HAS_, for a box round the part you type in) show it while that part has focus, and\n * not while a control of the field's own does: a button, a select, a link, a checkbox, a radio or a switch inside it (a\n * tag's remove, a picker's chevron, a composer's Send, an editor's toolbar or a task's checkbox), or anything in a popup\n * inside the box (a dialog of its own; a field that is itself in a dialog still shows it). That control shows its own outline, so there is one focus point, never\n * two (P11). _WITHIN_ reads :focus, as a click on a date's segment isn't :focus-visible; _HAS_ reads :focus-visible.\n * Either outranks the field's hover border, so hovering keeps the look.\n */\nexport const FIELD_FOCUS_RING = \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-[var(--ds-focus)] focus-visible:border-[var(--ds-focus)] [[data-input-modality=pointer]_&]:focus-visible:outline-none [[data-input-modality=pointer]_&]:focus-visible:border-[var(--ds-accent-ink)] [[data-input-modality=pointer]_&]:focus-visible:ring-2 [[data-input-modality=pointer]_&]:focus-visible:ring-[var(--ds-ring-active)]\";\n\nexport const FIELD_FOCUS_WITHIN_RING = \"has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-2 has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-solid has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-offset-2 has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-[var(--ds-focus)] has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:border-[var(--ds-focus)] [[data-input-modality=pointer]_&]:has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-none [[data-input-modality=pointer]_&]:has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:border-[var(--ds-accent-ink)] [[data-input-modality=pointer]_&]:has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:ring-2 [[data-input-modality=pointer]_&]:has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:ring-[var(--ds-ring-active)]\";\n\nexport const FIELD_HAS_FOCUS_RING = \"has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-2 has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-solid has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-offset-2 has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-[var(--ds-focus)] has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:border-[var(--ds-focus)] [[data-input-modality=pointer]_&]:has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-none [[data-input-modality=pointer]_&]:has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:border-[var(--ds-accent-ink)] [[data-input-modality=pointer]_&]:has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:ring-2 [[data-input-modality=pointer]_&]:has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:ring-[var(--ds-ring-active)]\";\n\n// A field with an error: the same, its red border kept, and the red halo when clicked into.\nexport const ERROR_FOCUS_RING = \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-[var(--ds-focus)] focus-visible:border-[var(--ds-status-error)] [[data-input-modality=pointer]_&]:focus-visible:outline-none [[data-input-modality=pointer]_&]:focus-visible:ring-2 [[data-input-modality=pointer]_&]:focus-visible:ring-[var(--ds-ring-error)]\";\n\nexport const ERROR_FOCUS_WITHIN_RING = \"has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-2 has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-solid has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-offset-2 has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-[var(--ds-focus)] has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:border-[var(--ds-status-error)] [[data-input-modality=pointer]_&]:has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:outline-none [[data-input-modality=pointer]_&]:has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:ring-2 [[data-input-modality=pointer]_&]:has-[:focus:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus))]:ring-[var(--ds-ring-error)]\";\n\nexport const ERROR_HAS_FOCUS_RING = \"has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-2 has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-solid has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-offset-2 has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-[var(--ds-focus)] has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:border-[var(--ds-status-error)] [[data-input-modality=pointer]_&]:has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:outline-none [[data-input-modality=pointer]_&]:has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:ring-2 [[data-input-modality=pointer]_&]:has-[:focus-visible:not(button,select,a,[role=button],input[type=checkbox],input[type=radio],[role=checkbox],[role=radio],[role=switch])]:[&:not(:has([role=dialog]_:focus-visible))]:ring-[var(--ds-ring-error)]\";\n\n// Active (D6): a field clicked into, or a dropdown or picker that's open, is its accent border (--ds-accent-ink, P8) with\n// the soft halo beyond it; on a field with an error, red with the red halo. Never an outline: that is keyboard focus's.\n// Choices (a selected card, row or swatch, the Stepper's current step) draw their own selected look, not this (D2).\nexport const ACTIVE_RING = \"border-[var(--ds-accent-ink)] ring-2 ring-[var(--ds-ring-active)]\";\n\nexport const ERROR_ACTIVE_RING = \"border-[var(--ds-status-error)] ring-2 ring-[var(--ds-ring-error)]\";\n\n// Body scroll lock is reference-counted so stacked overlays (a Dialog opened\n// from a Drawer, for example) only restore scrolling when the LAST one\n// closes. The original overflow value is captured on the first lock and put\n// back on the last unlock; an unbalanced unlock is clamped at zero.\nlet scrollLockCount = 0;\nlet scrollLockPreviousOverflow = \"\";\n\nexport function lockBodyScroll() {\n if (scrollLockCount === 0) {\n scrollLockPreviousOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n scrollLockCount++;\n}\n\nexport function unlockBodyScroll() {\n if (scrollLockCount === 0) return;\n scrollLockCount--;\n if (scrollLockCount === 0) {\n document.body.style.overflow = scrollLockPreviousOverflow;\n scrollLockPreviousOverflow = \"\";\n }\n}\n\n/** Test-only: current number of active locks. */\nexport function getBodyScrollLockCount() {\n return scrollLockCount;\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,10 +1,10 @@
1
1
  "use client";
2
- import { elementType } from './chunk-NKUCS67T.js';
3
- import { AutoTooltip, NATIVE_TITLE } from './chunk-WWN6CQKI.js';
4
- import { slotDraws, slotIcon } from './chunk-L6HWACK7.js';
5
- import { cn, FOCUS_RING } from './chunk-YL5KD5RC.js';
2
+ import { inputModality } from './chunk-7RKC5C7G.js';
3
+ import { AutoTooltip, NATIVE_TITLE } from './chunk-DR6WEI3A.js';
4
+ import { slotDraws, slotIcon } from './chunk-53F7GVBQ.js';
5
+ import { cn, FOCUS_RING, pageAddress, pointOf, hasSelfRemovalWatch, focusAfterSelfRemoval, LAST_RESORT_MS } from './chunk-EZ3ZGFGA.js';
6
6
  import { jsxs, jsx } from 'react/jsx-runtime';
7
- import { createContext, forwardRef, useContext, isValidElement, createElement, useLayoutEffect } from 'react';
7
+ import { createContext, forwardRef, useContext, isValidElement } from 'react';
8
8
 
9
9
  var sizes = {
10
10
  sm: "h-4 w-4 border-[1.5px]",
@@ -26,6 +26,16 @@ function Spinner({ size = "md", color = "default", label = "Loading", className
26
26
  }
27
27
  );
28
28
  }
29
+
30
+ // ../../showcase/src/lib/element-type.ts
31
+ var LAZY = /* @__PURE__ */ Symbol.for("react.lazy");
32
+ var isLazy = (type) => type !== null && typeof type === "object" && type.$$typeof === LAZY && typeof type._init === "function";
33
+ function elementType(type) {
34
+ let resolved = type;
35
+ for (let step = 0; step < 8 && isLazy(resolved); step++) resolved = resolved._init(resolved._payload);
36
+ return resolved;
37
+ }
38
+ var BUTTON_HANDOVER_MS = LAST_RESORT_MS * 2;
29
39
  var ControlSizeContext = createContext(null);
30
40
  var ButtonSizeContext = ControlSizeContext;
31
41
  var variantStyles = {
@@ -87,7 +97,15 @@ var Button = forwardRef(function Button2({ variant = "default", size: sizeProp,
87
97
  const isDisabled = !!disabled;
88
98
  const handleClick = isLoading ? (e) => {
89
99
  e.preventDefault();
90
- } : onClick;
100
+ } : (e) => {
101
+ const button = e.currentTarget;
102
+ const watch = document.activeElement === button && inputModality() !== "pointer";
103
+ const page = watch ? pageAddress() : null;
104
+ const point = watch ? pointOf(button) : void 0;
105
+ onClick?.(e);
106
+ if (!watch || pageAddress() !== page || hasSelfRemovalWatch(button)) return;
107
+ focusAfterSelfRemoval(button, { group: null, samePage: true, defer: BUTTON_HANDOVER_MS, removedOnly: true, point });
108
+ };
91
109
  const ariaLabel = props["aria-label"];
92
110
  const drawsTooltip = isIconSize && !!ariaLabel;
93
111
  const title = props.title;
@@ -159,50 +177,7 @@ function triggerType(node) {
159
177
  const type = elementType(node.type);
160
178
  return (type === "button" || type === Button) && node.props.type === void 0 ? { type: "button" } : {};
161
179
  }
162
- var PageActionsCtx = createContext(null);
163
- var CardSurfaceCtx = createContext(false);
164
- var SplitPaneCtx = createContext(false);
165
- var TableCardCtx = createContext(false);
166
- var RowsCtx = createContext(false);
167
- var SplitListFramerCtx = createContext(null);
168
- function useReportToList(kind) {
169
- const report = useContext(SplitListFramerCtx);
170
- useLayoutEffect(() => {
171
- if (!report) return;
172
- report(kind, true);
173
- return () => report(kind, false);
174
- }, [report, kind]);
175
- }
176
- function useFramesItself() {
177
- useReportToList("framed");
178
- }
179
- function useScrollsInside() {
180
- useReportToList("scrolls");
181
- }
182
- function SurfaceBoundary({ children, pane = false, framer = null }) {
183
- return createElement(
184
- CardSurfaceCtx,
185
- { value: false },
186
- createElement(
187
- SplitPaneCtx,
188
- { value: pane },
189
- createElement(
190
- TableCardCtx,
191
- { value: false },
192
- createElement(
193
- RowsCtx,
194
- { value: false },
195
- createElement(
196
- PageActionsCtx,
197
- { value: null },
198
- createElement(SplitListFramerCtx, { value: framer }, children)
199
- )
200
- )
201
- )
202
- )
203
- );
204
- }
205
180
 
206
- export { Button, ButtonSizeContext, CardSurfaceCtx, ControlSizeContext, PageActionsCtx, RowsCtx, Spinner, SplitPaneCtx, SurfaceBoundary, TableCardCtx, triggerType, useFramesItself, useScrollsInside };
207
- //# sourceMappingURL=chunk-MIUSSYVE.js.map
208
- //# sourceMappingURL=chunk-MIUSSYVE.js.map
181
+ export { Button, ButtonSizeContext, ControlSizeContext, Spinner, elementType, triggerType };
182
+ //# sourceMappingURL=chunk-HQFTP7Y5.js.map
183
+ //# sourceMappingURL=chunk-HQFTP7Y5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../showcase/src/components/Spinner.tsx","../../../showcase/src/lib/element-type.ts","../../../showcase/src/components/Button.tsx"],"names":["Button","jsx"],"mappings":";;;;;;;;AAEA,IAAM,KAAA,GAAQ;AAAA,EACZ,EAAA,EAAI,wBAAA;AAAA,EACJ,EAAA,EAAI,kBAAA;AAAA,EACJ,EAAA,EAAI;AACN,CAAA;AASO,SAAS,OAAA,CAAQ,EAAE,IAAA,GAAO,IAAA,EAAM,QAAQ,SAAA,EAAW,KAAA,GAAQ,SAAA,EAAW,SAAA,EAAU,EAAiB;AACtG,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,QAAA;AAAA,MACL,YAAA,EAAY,KAAA;AAAA,MACZ,SAAA,EAAW,EAAA;AAAA,QACT,2DAAA;AAAA,QACA,KAAA,KAAU,YACN,oCAAA,GACA,oEAAA;AAAA,QACJ,MAAM,IAAI,CAAA;AAAA,QACV;AAAA;AACF;AAAA,GACF;AAEJ;;;ACtBA,IAAM,IAAA,mBAAO,MAAA,CAAO,GAAA,CAAI,YAAY,CAAA;AAQpC,IAAM,MAAA,GAAS,CAAC,IAAA,KACd,IAAA,KAAS,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,IAAa,IAAA,CAAuB,QAAA,KAAa,IAAA,IAAQ,OAAQ,KAAuB,KAAA,KAAU,UAAA;AAE9H,SAAS,YAAY,IAAA,EAAwB;AAClD,EAAA,IAAI,QAAA,GAAW,IAAA;AAEf,EAAA,KAAA,IAAS,IAAA,GAAO,CAAA,EAAG,IAAA,GAAO,CAAA,IAAK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W,YAAA,CAAa,IAAI,GAAG,oBAAoB;AAAA,SAAA,EAC/D;AAAA;AAAA;AAAA,GACF;AAGF,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,uBAAOA,GAAAA,CAAC,WAAA,EAAA,EAAY,OAAA,EAAS,KAAA,IAAS,WAAY,QAAA,EAAA,GAAA,EAAI,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,GAAA;AACT,CAAC;AAEA,MAAA,CAA2C,YAAY,CAAA,GAAI,IAAA;AAE5D,SAAS,cAAc,IAAA,EAA+E;AACpG,EAAA,QAAQ,IAAA;AAAM,IACZ,KAAK,IAAA;AAAM,MAAA,OAAO,mBAAA;AAAA,IAClB,KAAK,IAAA;AAAM,MAAA,OAAO,mBAAA;AAAA,IAClB,KAAK,IAAA;AAAM,MAAA,OAAO,mBAAA;AAAA,IAClB,KAAK,IAAA;AAAM,MAAA,OAAO,mBAAA;AAAA;AAEtB;AAOO,SAAS,YAAY,IAAA,EAAoC;AAC9D,EAAA,IAAI,CAAC,cAAA,CAAe,IAAI,CAAA,SAAU,EAAC;AACnC,EAAA,MAAM,IAAA,GAAO,WAAA,CAAY,IAAA,CAAK,IAAI,CAAA;AAClC,EAAA,OAAA,CAAQ,IAAA,KAAS,QAAA,IAAY,IAAA,KAAS,MAAA,KAAY,IAAA,CAAK,KAAA,CAA6B,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,QAAA,EAAS,GAAI,EAAC;AACjI","file":"chunk-HQFTP7Y5.js","sourcesContent":["import { cn } from \"../lib/utils\";\n\nconst sizes = {\n sm: \"h-4 w-4 border-[1.5px]\",\n md: \"h-6 w-6 border-2\",\n lg: \"h-8 w-8 border-[2.5px]\",\n} as const;\n\ninterface SpinnerProps {\n size?: keyof typeof sizes;\n color?: \"default\" | \"inherit\";\n label?: string;\n className?: string;\n}\n\nexport function Spinner({ size = \"md\", color = \"default\", label = \"Loading\", className }: SpinnerProps) {\n return (\n <span\n role=\"status\"\n aria-label={label}\n className={cn(\n \"inline-block rounded-[var(--ds-radius-full)] animate-spin\",\n color === \"inherit\"\n ? \"border-current/30 border-t-current\"\n : \"border-[var(--ds-bg-emphasis)] border-t-[var(--ds-accent-primary)]\",\n sizes[size],\n className\n )}\n />\n );\n}\n","/**\n * An element's own component, through a lazy reference (Sprint 25.22's fresh-eyes review). A Next.js server component\n * hands each client component among its children on as a React.lazy reference, not as the component, so a check of\n * `element.type` against a component (PageContainer's header, Card's title, EmptyState's icon) missed every one, and a\n * server page drew without its layout: no colourful band, no contained breadcrumbs, a card's badge out of place. The\n * reference is resolved as React resolves one when it renders it: its component once loaded; while it loads, its promise\n * is thrown, so the component reading it suspends until it has it. Anything else is returned as it is.\n */\nconst LAZY = Symbol.for(\"react.lazy\");\n\ninterface LazyReference {\n $$typeof: symbol;\n _payload: unknown;\n _init: (payload: unknown) => unknown;\n}\n\nconst isLazy = (type: unknown): type is LazyReference =>\n type !== null && typeof type === \"object\" && (type as LazyReference).$$typeof === LAZY && typeof (type as LazyReference)._init === \"function\";\n\nexport function elementType(type: unknown): unknown {\n let resolved = type;\n // a reference to a reference resolves in turn; a handful of steps covers any real chain\n for (let step = 0; step < 8 && isLazy(resolved); step++) resolved = resolved._init(resolved._payload);\n return resolved;\n}\n","import { cn, FOCUS_RING } from \"../lib/utils\";\n// a server component hands its client children on as lazy references (Sprint 25.22's review)\nimport { elementType } from \"../lib/element-type\";\nimport { createContext, useContext, forwardRef, isValidElement, type ButtonHTMLAttributes, type CSSProperties, type ReactNode } from \"react\";\nimport { AutoTooltip, NATIVE_TITLE } from \"./Tooltip\";\nimport { Spinner } from \"./Spinner\";\nimport { slotIcon, type IconSlot, slotDraws } from \"../lib/icons\";\nimport { focusAfterSelfRemoval, hasSelfRemovalWatch, LAST_RESORT_MS, pageAddress, pointOf } from \"../lib/focus\";\nimport { inputModality } from \"../lib/input-modality\";\n\n/** How long a Button's own handover waits once the button has gone (Sprint 25.32): past every library rule's place. */\nexport const BUTTON_HANDOVER_MS = LAST_RESORT_MS * 2;\n\ntype ButtonVariant = \"default\" | \"secondary\" | \"tertiary\" | \"outline\" | \"ghost\" | \"destructive\" | \"success\" | \"warning\" | \"link\";\ntype ButtonSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"icon-xs\" | \"icon-sm\" | \"icon\" | \"icon-lg\";\n\nexport type ControlSize = \"sm\" | \"md\" | \"lg\";\nexport const ControlSizeContext = createContext<ControlSize | null>(null);\nexport const ButtonSizeContext = ControlSizeContext;\n\ninterface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** An icon name (\"clock\"), drawn as the theme's icon at the button's icon size, or an element. Not text: use children. */\n iconLeft?: IconSlot;\n /** As iconLeft, after the label. */\n iconRight?: IconSlot;\n loading?: boolean;\n children?: ReactNode;\n}\n\nconst variantStyles: Record<ButtonVariant, string> = {\n default: \"bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)] [background-origin:border-box] text-[var(--ds-text-on-primary)] border-transparent hover:bg-[var(--ds-accent-primary-hover)] hover:brightness-110\",\n secondary: \"bg-[var(--ds-bg-surface)] text-[var(--ds-text-primary)] border-[var(--ds-border-default)] hover:bg-[var(--ds-bg-muted)]\",\n tertiary: \"bg-[var(--ds-bg-muted)] text-[var(--ds-text-primary)] border-transparent hover:brightness-95\",\n outline: \"bg-[var(--ds-input-bg)] text-[var(--ds-text-primary)] border-[var(--ds-border-default)] hover:bg-[var(--ds-bg-muted)]\",\n ghost: \"bg-transparent text-[var(--ds-text-primary)] border-transparent hover:bg-[var(--ds-bg-muted)] shadow-none\",\n destructive: \"bg-[var(--ds-status-error)] text-[var(--ds-text-on-error)] border-transparent hover:opacity-90\",\n success: \"bg-[var(--ds-status-success)] text-[var(--ds-text-on-success)] border-transparent hover:opacity-90\",\n warning: \"bg-[var(--ds-status-warning)] text-[var(--ds-text-on-warning)] border-transparent hover:opacity-90\",\n link: \"bg-transparent text-[var(--ds-accent-ink)] hover:text-[var(--ds-accent-primary-hover)] hover:underline\",\n};\n\nconst sizeStyles: Record<ButtonSize, string> = {\n // xs / icon-xs: dense tool chrome (builder toolbars, inline row actions).\n xs: \"h-ds-6 px-ds-3 py-0 text-xs\",\n sm: \"h-[var(--ds-control-height-sm)] px-ds-4 py-ds-1 text-xs\",\n md: \"h-[var(--ds-control-height-md)] px-ds-6 py-ds-2 text-sm\",\n lg: \"h-[var(--ds-control-height-lg)] px-ds-8 py-ds-3 text-base\",\n \"icon-xs\": \"h-ds-6 w-ds-6 p-0\",\n \"icon-sm\": \"h-[var(--ds-control-height-sm)] w-[var(--ds-control-height-sm)] p-0\",\n icon: \"h-[var(--ds-control-height-md)] w-[var(--ds-control-height-md)] p-0\",\n \"icon-lg\": \"h-[var(--ds-control-height-lg)] w-[var(--ds-control-height-lg)] p-0\",\n};\n\n// Link buttons have no box, so only the text size follows `size`.\nconst linkSizeStyles: Record<ButtonSize, string> = {\n xs: \"text-xs\",\n sm: \"text-xs\",\n md: \"text-sm\",\n lg: \"text-base\",\n \"icon-xs\": \"text-xs\",\n \"icon-sm\": \"text-xs\",\n icon: \"text-sm\",\n \"icon-lg\": \"text-base\",\n};\n\nconst iconPaddingReduce: Record<Exclude<ButtonSize, \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\">, number> = {\n xs: 2,\n sm: 2,\n md: 4,\n lg: 6,\n};\n\n/** The icon size each button size draws a named icon at (Sprint 25.17 A26): what the library's own buttons pass by hand. */\nconst SLOT_ICON_PX: Record<ButtonSize, number> = { xs: 12, sm: 14, md: 16, lg: 18, \"icon-xs\": 12, \"icon-sm\": 14, icon: 16, \"icon-lg\": 18 };\n\nconst HOVER_SCALE_CAP = { '--_btn-scale': 'min(var(--ds-hover-scale), 1.02)' } as CSSProperties;\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button({ variant = \"default\", size: sizeProp, iconLeft, iconRight, loading, className, children, disabled, style, onClick, ...props }, ref) {\n const contextSize = useContext(ControlSizeContext);\n const size = sizeProp ?? contextSize ?? \"md\";\n const isLink = variant === \"link\";\n const spinnerSize = size === \"lg\" || size === \"icon-lg\" ? \"md\" : \"sm\";\n let paddingStyle: CSSProperties | undefined;\n const isIconSize = size === \"icon\" || size === \"icon-xs\" || size === \"icon-sm\" || size === \"icon-lg\";\n // a slot that draws nothing (text, which no icon pack names) keeps the button's even padding\n const drawsLeft = slotDraws(iconLeft);\n const drawsRight = slotDraws(iconRight);\n if (!isIconSize && !isLink && (drawsLeft || drawsRight)) {\n const reduce = iconPaddingReduce[size];\n paddingStyle = {};\n if (drawsLeft) paddingStyle.paddingLeft = `calc(${getCssPadding(size)} - ${reduce}px)`;\n if (drawsRight) paddingStyle.paddingRight = `calc(${getCssPadding(size)} - ${reduce}px)`;\n }\n\n const isLoading = loading && !disabled;\n const isDisabled = !!disabled;\n\n // Sprint 25.32 (R29-2: round 29's \"Reconnect\" was drawn only while an app was disconnected, so its own press took it\n // away and focus fell to the page): a keyboard press that takes its button away hands focus on, where the browser's\n // own Tab would go on from where the button stood (D1: the first Tab stop after a live range taken round the button\n // before its press acts, else the last before it, within the page or the dialog it was in). Only a press that isn't a\n // pointer's (the keyboard's, a screen reader's), on the button holding focus (the review of 18 October): focus moved\n // by script after a pointer's press shows no ring, so a Space meant to scroll would press whatever it landed on. Only\n // the button leaving the page counts, not its being disabled while the press is pending. Set after the page's\n // handler, so a component that knows better (Pagination's own rule) has set its watch first, and this one steps\n // aside. It waits twice the last resort's time once the button has gone, so every place the library or the page gives\n // focus goes first (a drawer's Cancel, whose drawer sends focus back where its opener's panel sat, a last resort of\n // its own at LAST_RESORT_MS), and never acts across a change of page, whose new page owns focus. The user moving on\n // ends it.\n const handleClick = isLoading\n ? (e: React.MouseEvent<HTMLButtonElement>) => { e.preventDefault(); }\n : (e: React.MouseEvent<HTMLButtonElement>) => {\n const button = e.currentTarget;\n const watch = document.activeElement === button && inputModality() !== \"pointer\";\n // the page the press was on: a handler that navigated has a new page, which owns focus\n const page = watch ? pageAddress() : null;\n // where the button stands, taken before its press acts: the DOM keeps it once the button has gone\n const point = watch ? pointOf(button) : undefined;\n onClick?.(e);\n if (!watch || pageAddress() !== page || hasSelfRemovalWatch(button)) return;\n focusAfterSelfRemoval(button, { group: null, samePage: true, defer: BUTTON_HANDOVER_MS, removedOnly: true, point });\n };\n\n const ariaLabel = props[\"aria-label\"];\n // An icon-size Button with an aria-label draws its own tooltip from it. Round 15 (52.7): where a Tooltip the page put\n // around it shows, that one owns the label and this steps aside (AutoTooltip asks when it would show).\n const drawsTooltip = isIconSize && !!ariaLabel;\n // A title beside a tooltip is the browser's second one, a moment later (the review of 21.6 session B): a Button that\n // draws its tooltip shows the title's text in it instead (the Tooltip drops the button's own title), and a Tooltip the\n // page puts around a Button drops its title too (NATIVE_TITLE).\n const title = props.title;\n\n const btn = (\n <button\n ref={ref}\n data-variant={variant}\n className={cn(\n \"relative inline-flex items-center justify-center gap-ds-2 whitespace-nowrap font-medium\",\n isLink\n ? cn(\n \"px-0 py-ds-0.5 h-auto\",\n linkSizeStyles[size],\n \"transition-colors duration-[var(--ds-transition-speed)]\",\n FOCUS_RING,\n \"cursor-pointer\",\n \"active:text-[var(--ds-accent-primary-active)]\",\n )\n : cn(\n \"border-[length:var(--ds-border-width)]\",\n \"rounded-[var(--ds-radius-md)]\",\n \"shadow-[var(--ds-shadow-button)]\",\n \"hover:scale-[var(--_btn-scale)] hover:-translate-y-[var(--ds-hover-lift)]\",\n \"active:shadow-[var(--ds-shadow-button-pressed)] active:translate-x-[var(--ds-press-depth)] active:translate-y-[var(--ds-press-depth)]\",\n \"[transition:var(--ds-transition-interactive)]\",\n FOCUS_RING,\n \"cursor-pointer disabled:cursor-not-allowed disabled:opacity-disabled\",\n sizeStyles[size],\n ),\n variantStyles[variant],\n isLoading && !isLink && \"cursor-wait pointer-events-none\",\n className\n )}\n disabled={isDisabled}\n aria-busy={isLoading || undefined}\n aria-disabled={isLoading && !disabled ? true : undefined}\n onClick={handleClick}\n style={isLink ? style : { ...HOVER_SCALE_CAP, ...paddingStyle, ...style }}\n {...props}\n >\n {loading && !isLink && (\n <span className=\"absolute inset-0 flex items-center justify-center\">\n <Spinner size={spinnerSize} color=\"inherit\" />\n </span>\n )}\n <span className={cn(\"inline-flex items-center gap-ds-2 min-w-0\", loading && !isLink && \"invisible\")}>\n {slotIcon(iconLeft, SLOT_ICON_PX[size], \"Button's iconLeft\")}\n {children}\n {slotIcon(iconRight, SLOT_ICON_PX[size], \"Button's iconRight\")}\n </span>\n </button>\n );\n\n if (drawsTooltip) {\n return <AutoTooltip content={title ?? ariaLabel}>{btn}</AutoTooltip>;\n }\n\n return btn;\n});\n// a Button's title is the native attribute: a Tooltip around it drops it, as it does an element's\n(Button as unknown as Record<symbol, true>)[NATIVE_TITLE] = true;\n\nfunction getCssPadding(size: Exclude<ButtonSize, \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\">): string {\n switch (size) {\n case \"xs\": return \"var(--ds-space-3)\";\n case \"sm\": return \"var(--ds-space-4)\";\n case \"md\": return \"var(--ds-space-6)\";\n case \"lg\": return \"var(--ds-space-8)\";\n }\n}\n\n/**\n * A trigger the library wires up (a Collapsible's, a menu's, a popover's) never submits the form it sits in (0.21.0): a\n * button element or Button given no type gets type=\"button\". A page's own Button keeps HTML's default, so its submits\n * still work.\n */\nexport function triggerType(node: unknown): { type?: \"button\" } {\n if (!isValidElement(node)) return {};\n const type = elementType(node.type);\n return (type === \"button\" || type === Button) && (node.props as { type?: unknown }).type === undefined ? { type: \"button\" } : {};\n}\n"]}
@@ -1,16 +1,15 @@
1
1
  "use client";
2
- import { useFieldControl, CHECK_FILL } from './chunk-USHW523V.js';
3
2
  import { useHydrated, LocaleContext, useFormatLocale, useToday } from './chunk-LJYSVZMI.js';
3
+ import { useFieldControl, CHECK_FILL } from './chunk-IZW5XHKA.js';
4
4
  import { formatLocale } from './chunk-7QLXYRPD.js';
5
- import { useInputModality } from './chunk-7RKC5C7G.js';
6
5
  import { useReportedChange } from './chunk-72SDAX54.js';
7
- import { RowsCtx, ControlSizeContext, Button } from './chunk-MIUSSYVE.js';
8
- import { useTextOverflow } from './chunk-ZCDA74RQ.js';
9
- import { RevealTooltip, AutoTooltip, Tooltip } from './chunk-WWN6CQKI.js';
10
- import { Icon } from './chunk-L6HWACK7.js';
11
- import { mergeRefs, Slot } from './chunk-7Q46JXSK.js';
12
- import { CONTROL_ANCESTOR, usePosition, useGridKeyboard, usePopupFocus, useLatest } from './chunk-4HJDOZ2M.js';
13
- import { cn, FOCUS_RING, GLASS_DROPDOWN, PEER_FOCUS_RING, ERROR_ACTIVE_RING, ACTIVE_RING, ERROR_FOCUS_WITHIN_RING, FIELD_FOCUS_WITHIN_RING } from './chunk-YL5KD5RC.js';
6
+ import { RowsCtx } from './chunk-V73LHNRL.js';
7
+ import { ControlSizeContext, Button } from './chunk-HQFTP7Y5.js';
8
+ import { useInputModality } from './chunk-7RKC5C7G.js';
9
+ import { useTextOverflow } from './chunk-W3GY5ROH.js';
10
+ import { mergeRefs, RevealTooltip, Slot, AutoTooltip, Tooltip } from './chunk-DR6WEI3A.js';
11
+ import { Icon } from './chunk-53F7GVBQ.js';
12
+ import { cn, CONTROL_ANCESTOR, FOCUS_RING, usePosition, GLASS_DROPDOWN, PEER_FOCUS_RING, useGridKeyboard, usePopupFocus, useLatest, ERROR_ACTIVE_RING, ACTIVE_RING, ERROR_FOCUS_WITHIN_RING, FIELD_FOCUS_WITHIN_RING } from './chunk-EZ3ZGFGA.js';
14
13
  import { createContext, forwardRef, useState, useCallback, cloneElement, useRef, useEffect, useContext, useId, useMemo, useLayoutEffect, Fragment as Fragment$1 } from 'react';
15
14
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
16
15
  import { createPortal } from 'react-dom';
@@ -24,7 +23,7 @@ function Checkbox({ checked, onChange: onChangeProp, label, size = "md", disable
24
23
  const internalRef = useRef(null);
25
24
  const spaceWithShift = useRef(false);
26
25
  const dims = CHECKBOX_SIZES[size];
27
- const control = useFieldControl(wiring);
26
+ const control = useFieldControl(wiring, { component: "Checkbox", ownLabel: label ? true : void 0 });
28
27
  const mergedRef = useCallback(
29
28
  (node) => {
30
29
  internalRef.current = node;
@@ -57,8 +56,8 @@ function Checkbox({ checked, onChange: onChangeProp, label, size = "md", disable
57
56
  ref: mergedRef,
58
57
  type: "checkbox",
59
58
  id: control.id,
60
- "aria-label": control.label,
61
- "aria-labelledby": wiring["aria-labelledby"],
59
+ "aria-label": control.labelId ? void 0 : control.label,
60
+ "aria-labelledby": control.shown ? void 0 : wiring["aria-labelledby"],
62
61
  "aria-describedby": control.describedBy,
63
62
  "aria-invalid": control.invalid || void 0,
64
63
  required: control.required || void 0,
@@ -800,7 +799,7 @@ function DatePicker({ value, onChange: onChangeProp, placeholder = "Pick a date"
800
799
  const panelRef = useRef(null);
801
800
  const gridRef = useRef(null);
802
801
  const generatedId = useId();
803
- const control = useFieldControl({ ...wiring, id, error: error || void 0 }, { requiredInDescription: true });
802
+ const control = useFieldControl({ ...wiring, id, error: error || void 0 }, { requiredInDescription: true, component: "DatePicker", ownLabel: label ? true : void 0 });
804
803
  useInputModality();
805
804
  const inputId = control.id ?? generatedId;
806
805
  const pos = usePosition(triggerRef, panelRef, open, { side: "bottom", align: "start", offset: 4, flip: true });
@@ -1345,5 +1344,5 @@ function useCardsSwitch(narrowScreen, cardsBelow = CARDS_BELOW, remeasure) {
1345
1344
  }
1346
1345
 
1347
1346
  export { CARDS_BELOW, CardValue, Checkbox, CheckboxGroup, CheckboxGroupItem, CutCell, CutEmail, DatePicker, DateSegmentFields, HoverCard, SortIndicator, TIME_SEPARATORS, TextOverflow, addDays2 as addDays, addMonths, addMonthsClamped, dayKey, dayPieces, endOfWeek, getEventsForDay, getMonthGrid, getWeekDays, groupEventsByDay, inferColumnKinds, isBarEvent, isExcludedDay, isSameDay, isSameMonth, isWeekend, kindOfRenderedText, layoutPieces, layoutWeek, localeCache, localeDayFirst, moveDay, pad2, separatorMovesOn, startOfDay, startOfWeek, stepValue, timeSegments, timeToFraction, typeDigit, useCardsSwitch, useDateWords, useWeekStart };
1348
- //# sourceMappingURL=chunk-SIWERRP2.js.map
1349
- //# sourceMappingURL=chunk-SIWERRP2.js.map
1347
+ //# sourceMappingURL=chunk-I6JJ7KKP.js.map
1348
+ //# sourceMappingURL=chunk-I6JJ7KKP.js.map