@adea-ai/ui 0.149.5 → 0.149.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/composites/terminal/ansi.d.ts +5 -0
- package/dist/components/composites/terminal/ansi.d.ts.map +1 -1
- package/dist/components/composites/terminal/ansi.js +14 -1
- package/dist/components/composites/terminal/ansi.js.map +1 -1
- package/dist/components/composites/terminal/terminal.d.ts.map +1 -1
- package/dist/components/composites/terminal/terminal.js +2 -2
- package/dist/components/composites/terminal/terminal.js.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.js +1 -0
- package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
- package/dist/components/ui/dialog/dialog.d.ts +6 -0
- package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog.js +7 -2
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/lib/tooltip-focus-gate.d.ts +4 -3
- package/dist/lib/tooltip-focus-gate.d.ts.map +1 -1
- package/dist/lib/tooltip-focus-gate.js +16 -4
- package/dist/lib/tooltip-focus-gate.js.map +1 -1
- package/dist/r/appearance-editor.json +1 -1
- package/dist/r/lib.json +1 -1
- package/dist/r/registry.json +3 -3
- package/dist/r/src/components/composites/terminal/ansi.ts +15 -0
- package/dist/r/src/components/composites/terminal/terminal.tsx +2 -1
- package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +3 -0
- package/dist/r/src/components/ui/dialog/dialog.tsx +12 -3
- package/dist/r/src/lib/tooltip-focus-gate.ts +27 -3
- package/dist/r/theming.json +1 -1
- package/package.json +3 -3
- package/registry.json +3 -3
- package/src/components/composites/terminal/ansi.ts +15 -0
- package/src/components/composites/terminal/terminal.tsx +2 -1
- package/src/components/composites/update-dialog/update-dialog.tsx +3 -0
- package/src/components/ui/dialog/dialog.tsx +12 -3
- package/src/lib/tooltip-focus-gate.ts +27 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-focus-gate.js","names":[],"sources":["../../src/lib/tooltip-focus-gate.ts"],"sourcesContent":["/*\n * Tooltips open on active hover over the control, or on keyboard focus that\n * follows a Tab key press. They must never open from programmatic focus: the\n * autofocus a dialog or sheet gives its first control, and the focus a closing\n * overlay restores to its opener, both land on buttons that carry tooltips —\n * and the tooltip primitive opens immediately on focus and pins the tooltip\n * until blur. That is the \"tooltip auto-displays when a sheet opens\" report,\n * and the pinned tooltip is the \"tooltip gets stuck and never disappears\"\n * report: the pointer is nowhere near the control, so no pointer leave ever\n * closes it.\n *\n * The trigger listens for the native `focus` event on the trigger element, and\n * composites build tooltips internally (ActionButton renders one from its\n * `tooltip` prop), so the single interception point that covers every tooltip\n * is a capture-phase `focus` listener on `document`. When focus lands without a\n * keyboard-intent signal on a button-like element, the event is stopped before\n * any element listener runs: the tooltip never learns about the focus. Hover\n * opens are untouched (they ride pointer events), and the separate `focusin`\n * event still flows, so dialog focus-cycle tracking, `:focus-visible` styling,\n * and focus restoration all keep working. Focus still lands — only the event\n * is stopped — so `document.activeElement` and scripted `.blur()` behave.\n *\n * The keyboard-intent signal is a Tab key press immediately before the focus —\n * the only key that moves focus natively. Enter and Space open overlays too,\n * so any \"recent key\" window wide enough for those would let an overlay's own\n * autofocus back through; Tab-only keeps autofocus suppressed no matter how\n * the overlay was opened, while normal Tab navigation still announces each\n * control's tooltip (hover descriptions stay reachable from the keyboard).\n *\n * Suppression is scoped to button-like targets (`button`, `a[href]`,\n * `[role=\"button\"]`, `[role=\"link\"]`). Composite widgets that move focus\n * programmatically — menu items, listbox options, grid cells — are other\n * element types whose roving-focus highlighting must keep receiving focus\n * events, and text controls keep their own focus behaviour (select on focus,\n * caret placement).\n *\n * Suppressed focus is real as far as the DOM is concerned (`activeElement`\n * moves; only the event was stopped), and the tooltip interaction model treats\n * a trigger that is `activeElement` as keyboard-held: while a tooltip on it is\n * open, pointer movement away only *requests* a close and the request is\n * refused for as long as the pointer keeps moving. Left alone, a later real\n * hover on that control would open the tip and never let it leave — the\n * residual \"stuck\" case. The gate therefore treats a suppressed focus as a\n * phantom and releases it: the first pointer activity after the focus (a\n * pointer session taking over from a script) blurs the element. Keyboard\n * sessions never release it and never need to — keyboard focus moves by Tab,\n * which is never suppressed, so nothing pins; and the release only runs for\n * elements still holding `activeElement`, so a Tab already taken from the\n * phantom is left alone.\n *\n * Focus that arrives while a pointer button is held belongs to a pointer\n * gesture, not to a tooltip: the pixel resize handle focuses its handle when a\n * drag starts and cancels the drag on blur, so a gesture focus must pass\n * through untouched (no suppression, no phantom, no release). A gesture's own\n * click behaviour already keeps tooltips closed, and the autofocus cases this\n * gate exists for all happen with the pointer up.\n *\n * Independently of the gesture window, resize grips render as\n * `<button role=\"separator\">` and carry no tooltip, so they are excluded from\n * the button-like scope entirely (see `isButtonLikeFocusTarget`).\n *\n * The gate is installed by the `Tooltip` root for the lifetime of the first\n * tooltip in a document and removed when the last one unmounts, so every\n * consumer of the primitive — including composites that build their own\n * tooltips — inherits the contract without wiring of its own.\n */\n\n/** How long after a Tab key press a resulting focus event still counts as\n * keyboard navigation. The native focus move follows the key press\n * immediately; the window only has to bridge that dispatch, not a later\n * script-driven focus. */\nexport const TOOLTIP_FOCUS_INTENT_WINDOW_MS = 250\n\n/** Elements a tooltip-bearing control is rendered as. Everything else keeps\n * its native focus behaviour, and so do resize grips (see below). */\nconst BUTTON_LIKE_SELECTOR = 'button, a[href], [role=\"button\"], [role=\"link\"]'\n\n/**\n * Whether a focus event landing on this target could open a tooltip on a\n * button-like control. Accepts any Element (an SVG glyph inside a control,\n * for instance) and duck-types so the decision is testable without a DOM.\n */\nexport function isButtonLikeFocusTarget(target: unknown): boolean {\n const element = target as Element | null | undefined\n if (typeof element?.closest !== 'function') return false\n const control = element.closest(BUTTON_LIKE_SELECTOR)\n if (control === null) return false\n // Resize grips render as `<button role=\"separator\">` and focus themselves\n // when a pointer drag starts. They carry no tooltip, and the blur that\n // releases a suppressed focus would end the drag on its first move.\n return control.getAttribute?.('role') !== 'separator'\n}\n\n/**\n * The suppression decision: a button-like focus target hides a tooltip only\n * when no keyboard navigation is in flight. Anything else — a Tab-driven\n * focus, or focus on a non-button element — passes through untouched.\n */\nexport function shouldSuppressTooltipFocus(input: {\n isButtonLike: boolean\n keyboardIntentActive: boolean\n}): boolean {\n return input.isButtonLike && !input.keyboardIntentActive\n}\n\nconst installedDocuments = new WeakSet<Document>()\n\n/**\n * Install the gate on a document. Idempotent per document; returns a disposer\n * that removes the listeners (used by tests and by the tooltip root, which\n * releases the gate when its document's last tooltip unmounts).\n */\nexport function installTooltipFocusGate(doc: Document = document): () => void {\n if (installedDocuments.has(doc)) return () => {}\n\n let lastTabKeyDownAt = 0\n /** True between a pointerdown and its pointerup/pointercancel: focus events\n * inside that window belong to a pointer gesture (drag bootstrap, press)\n * and must reach their element untouched. */\n let pointerGestureActive = false\n /** The element holding a suppressed programmatic focus, if it still holds\n * `activeElement`. One slot: a newer suppressed focus replaces an older\n * one, and anything that already lost focus needs no release. */\n let phantomFocusTarget: Element | undefined\n /** The phantom-release `pointermove` listener exists only while a phantom\n * does: a gate that parks a permanent pointer listener on every document\n * with a tooltip in it costs every page a standing listener for a state\n * that is live for a few hundred milliseconds at most. */\n let phantomReleaseAttached = false\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Tab') lastTabKeyDownAt = Date.now()\n }\n const onPointerDown = () => {\n pointerGestureActive = true\n releasePhantomFocus()\n }\n const onPointerGestureEnd = () => {\n pointerGestureActive = false\n }\n const dropPhantom = () => {\n phantomFocusTarget = undefined\n if (phantomReleaseAttached) {\n phantomReleaseAttached = false\n doc.removeEventListener('pointermove', onPointerMove, true)\n }\n }\n const onFocus = (event: FocusEvent) => {\n // Focus that moves on retires the phantom: there is nothing left to\n // release, so the parked pointer listener goes with it.\n if (phantomFocusTarget && event.target !== phantomFocusTarget) dropPhantom()\n if (pointerGestureActive) return\n if (!isButtonLikeFocusTarget(event.target)) return\n const keyboardIntentActive = Date.now() - lastTabKeyDownAt <= TOOLTIP_FOCUS_INTENT_WINDOW_MS\n if (!shouldSuppressTooltipFocus({ isButtonLike: true, keyboardIntentActive })) return\n event.stopPropagation()\n phantomFocusTarget = event.target as Element\n if (!phantomReleaseAttached) {\n phantomReleaseAttached = true\n doc.addEventListener('pointermove', onPointerMove, true)\n }\n }\n const releasePhantomFocus = () => {\n if (pointerGestureActive) return\n if (!phantomFocusTarget) return\n const phantom = phantomFocusTarget\n dropPhantom()\n if ((doc as Document).activeElement !== phantom) return\n if (typeof (phantom as HTMLElement).blur === 'function') (phantom as HTMLElement).blur()\n }\n const onPointerMove = () => releasePhantomFocus()\n\n doc.addEventListener('keydown', onKeyDown, true)\n doc.addEventListener('focus', onFocus, true)\n doc.addEventListener('pointerdown', onPointerDown, true)\n doc.addEventListener('pointerup', onPointerGestureEnd, true)\n doc.addEventListener('pointercancel', onPointerGestureEnd, true)\n installedDocuments.add(doc)\n return () => {\n doc.removeEventListener('keydown', onKeyDown, true)\n doc.removeEventListener('focus', onFocus, true)\n doc.removeEventListener('pointerdown', onPointerDown, true)\n doc.removeEventListener('pointerup', onPointerGestureEnd, true)\n doc.removeEventListener('pointercancel', onPointerGestureEnd, true)\n doc.removeEventListener('pointermove', onPointerMove, true)\n installedDocuments.delete(doc)\n }\n}\n\n/**\n * Reference-counted install for the tooltip root: the first tooltip in a\n * document acquires the gate, the last one to unmount releases it. The document\n * parameter exists so tests can drive the counter without a global DOM; the\n * production call site guards on the server render before calling.\n */\nconst gateHolders = new WeakMap<Document, number>()\nconst gateDisposers = new WeakMap<Document, () => void>()\n\nexport function acquireTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n gateHolders.set(doc, holders + 1)\n if (holders === 0) gateDisposers.set(doc, installTooltipFocusGate(doc))\n}\n\nexport function releaseTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n if (holders === 0) return\n if (holders === 1) {\n gateHolders.delete(doc)\n gateDisposers.get(doc)?.()\n gateDisposers.delete(doc)\n return\n }\n gateHolders.set(doc, holders - 1)\n}\n"],"mappings":";;;;;AAuEA,IAAa,iCAAiC;;;AAI9C,IAAM,uBAAuB;;;;;;AAO7B,SAAgB,wBAAwB,QAA0B;CAChE,MAAM,UAAU;CAChB,IAAI,OAAO,SAAS,YAAY,YAAY,OAAO;CACnD,MAAM,UAAU,QAAQ,QAAQ,oBAAoB;CACpD,IAAI,YAAY,MAAM,OAAO;CAI7B,OAAO,QAAQ,eAAe,MAAM,MAAM;AAC5C;;;;;;AAOA,SAAgB,2BAA2B,OAG/B;CACV,OAAO,MAAM,gBAAgB,CAAC,MAAM;AACtC;AAEA,IAAM,qCAAqB,IAAI,QAAkB;;;;;;AAOjD,SAAgB,wBAAwB,MAAgB,UAAsB;CAC5E,IAAI,mBAAmB,IAAI,GAAG,GAAG,aAAa,CAAC;CAE/C,IAAI,mBAAmB;;;;CAIvB,IAAI,uBAAuB;;;;CAI3B,IAAI;;;;;CAKJ,IAAI,yBAAyB;CAC7B,MAAM,aAAa,UAAyB;EAC1C,IAAI,MAAM,QAAQ,OAAO,mBAAmB,KAAK,IAAI;CACvD;CACA,MAAM,sBAAsB;EAC1B,uBAAuB;EACvB,oBAAoB;CACtB;CACA,MAAM,4BAA4B;EAChC,uBAAuB;CACzB;CACA,MAAM,oBAAoB;EACxB,qBAAqB,KAAA;EACrB,IAAI,wBAAwB;GAC1B,yBAAyB;GACzB,IAAI,oBAAoB,eAAe,eAAe,IAAI;EAC5D;CACF;CACA,MAAM,WAAW,UAAsB;EAGrC,IAAI,sBAAsB,MAAM,WAAW,oBAAoB,YAAY;EAC3E,IAAI,sBAAsB;EAC1B,IAAI,CAAC,wBAAwB,MAAM,MAAM,GAAG;EAE5C,IAAI,CAAC,2BA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,KAAK,wBAAwB,GAAG,CAAC;AACxE;AAEA,SAAgB,wBAAwB,WAA4B;CAClE,IAAI,OAAO,aAAa,eAAe,CAAC,WAAW;CACnD,MAAM,MAAM,aAAa;CACzB,MAAM,UAAU,YAAY,IAAI,GAAG,KAAK;CACxC,IAAI,YAAY,GAAG;CACnB,IAAI,YAAY,GAAG;EACjB,YAAY,OAAO,GAAG;EACtB,cAAc,IAAI,GAAG,CAAC,GAAG;EACzB,cAAc,OAAO,GAAG;EACxB;CACF;CACA,YAAY,IAAI,KAAK,UAAU,CAAC;AAClC"}
|
|
1
|
+
{"version":3,"file":"tooltip-focus-gate.js","names":[],"sources":["../../src/lib/tooltip-focus-gate.ts"],"sourcesContent":["/*\n * Tooltips open on active hover over the control, or on keyboard focus that\n * follows a Tab key press. They must never open from programmatic focus: the\n * autofocus a dialog or sheet gives its first control, and the focus a closing\n * overlay restores to its opener, both land on buttons that carry tooltips —\n * and the tooltip primitive opens immediately on focus and pins the tooltip\n * until blur. That is the \"tooltip auto-displays when a sheet opens\" report,\n * and the pinned tooltip is the \"tooltip gets stuck and never disappears\"\n * report: the pointer is nowhere near the control, so no pointer leave ever\n * closes it.\n *\n * The trigger listens for the native `focus` event on the trigger element, and\n * composites build tooltips internally (ActionButton renders one from its\n * `tooltip` prop), so the single interception point that covers every tooltip\n * is a capture-phase `focus` listener on `document`. When focus lands without a\n * keyboard-intent signal on a button-like element, the event is stopped before\n * any element listener runs: the tooltip never learns about the focus. Hover\n * opens are untouched (they ride pointer events), and the separate `focusin`\n * event still flows, so dialog focus-cycle tracking, `:focus-visible` styling,\n * and focus restoration all keep working. Focus still lands — only the event\n * is stopped — so `document.activeElement` and scripted `.blur()` behave.\n *\n * The keyboard-intent signal is a Tab key press immediately before the focus —\n * the only key that moves focus natively. Enter and Space open overlays too,\n * so any \"recent key\" window wide enough for those would let an overlay's own\n * autofocus back through; Tab-only keeps autofocus suppressed no matter how\n * the overlay was opened, while normal Tab navigation still announces each\n * control's tooltip (hover descriptions stay reachable from the keyboard).\n *\n * Suppression is scoped to button-like targets (`button`, `a[href]`,\n * `[role=\"button\"]`, `[role=\"link\"]`). Composite widgets that move focus\n * programmatically — menu items, listbox options, grid cells — are other\n * element types whose roving-focus highlighting must keep receiving focus\n * events, and text controls keep their own focus behaviour (select on focus,\n * caret placement).\n *\n * Suppressed focus is real as far as the DOM is concerned (`activeElement`\n * moves; only the event was stopped), and the tooltip interaction model treats\n * a trigger that is `activeElement` as keyboard-held: while a tooltip on it is\n * open, pointer movement away only *requests* a close and the request is\n * refused for as long as the pointer keeps moving. Left alone, a later real\n * hover on that control would open the tip and never let it leave — the\n * residual \"stuck\" case. The gate therefore treats a suppressed focus as a\n * phantom and releases it: the first pointer activity after the focus (a\n * pointer session taking over from a script) blurs the element. Keyboard\n * sessions never release it and never need to — keyboard focus moves by Tab,\n * which is never suppressed, so nothing pins; and the release only runs for\n * elements still holding `activeElement`, so a Tab already taken from the\n * phantom is left alone.\n *\n * Focus that arrives while a pointer button is held belongs to a pointer\n * gesture, not to a tooltip: the pixel resize handle focuses its handle when a\n * drag starts and cancels the drag on blur, so a gesture focus must pass\n * through untouched (no suppression, no phantom, no release). A gesture's own\n * click behaviour already keeps tooltips closed, and the autofocus cases this\n * gate exists for all happen with the pointer up.\n *\n * A tab in a roving-focus tab list is the one button-like element whose\n * programmatic focus is the widget working as designed: a dialog's focus scope\n * and the tab list both put focus on the selected tab, and the tab list scrolls\n * it into view on every focus-in. Releasing that focus would hand it straight\n * back (the scope restores it), so every pointer move would re-suppress,\n * re-release and re-scroll the rail to the top, and a tab below the fold of a\n * large-font or short-window rail could not be clicked. A focus on `role=\"tab\"`\n * is therefore still hidden from the tooltip, so no tooltip opens from it, but\n * it is not tracked as a phantom and the pointer never blurs it.\n *\n * Independently of the gesture window, resize grips render as\n * `<button role=\"separator\">` and carry no tooltip, so they are excluded from\n * the button-like scope entirely (see `isButtonLikeFocusTarget`).\n *\n * The gate is installed by the `Tooltip` root for the lifetime of the first\n * tooltip in a document and removed when the last one unmounts, so every\n * consumer of the primitive — including composites that build their own\n * tooltips — inherits the contract without wiring of its own.\n */\n\n/** How long after a Tab key press a resulting focus event still counts as\n * keyboard navigation. The native focus move follows the key press\n * immediately; the window only has to bridge that dispatch, not a later\n * script-driven focus. */\nexport const TOOLTIP_FOCUS_INTENT_WINDOW_MS = 250\n\n/** Elements a tooltip-bearing control is rendered as. Everything else keeps\n * its native focus behaviour, and so do resize grips (see below). */\nconst BUTTON_LIKE_SELECTOR = 'button, a[href], [role=\"button\"], [role=\"link\"]'\n\n/**\n * Whether a focus event landing on this target could open a tooltip on a\n * button-like control. Accepts any Element (an SVG glyph inside a control,\n * for instance) and duck-types so the decision is testable without a DOM.\n */\nfunction buttonLikeControl(target: unknown): Element | null {\n const element = target as Element | null | undefined\n if (typeof element?.closest !== 'function') return null\n return element.closest(BUTTON_LIKE_SELECTOR)\n}\n\n/**\n * Whether the focus target is a tab of a roving-focus tab list. Its focus is\n * hidden from tooltips like any other programmatic focus, but it is never\n * released by the pointer (see the header).\n */\nexport function isTabFocusTarget(target: unknown): boolean {\n return buttonLikeControl(target)?.getAttribute?.('role') === 'tab'\n}\n\nexport function isButtonLikeFocusTarget(target: unknown): boolean {\n const control = buttonLikeControl(target)\n if (control === null) return false\n // Resize grips render as `<button role=\"separator\">` and focus themselves\n // when a pointer drag starts. They carry no tooltip, and the blur that\n // releases a suppressed focus would end the drag on its first move.\n return control.getAttribute?.('role') !== 'separator'\n}\n\n/**\n * The suppression decision: a button-like focus target hides a tooltip only\n * when no keyboard navigation is in flight. Anything else — a Tab-driven\n * focus, or focus on a non-button element — passes through untouched.\n */\nexport function shouldSuppressTooltipFocus(input: {\n isButtonLike: boolean\n keyboardIntentActive: boolean\n}): boolean {\n return input.isButtonLike && !input.keyboardIntentActive\n}\n\nconst installedDocuments = new WeakSet<Document>()\n\n/**\n * Install the gate on a document. Idempotent per document; returns a disposer\n * that removes the listeners (used by tests and by the tooltip root, which\n * releases the gate when its document's last tooltip unmounts).\n */\nexport function installTooltipFocusGate(doc: Document = document): () => void {\n if (installedDocuments.has(doc)) return () => {}\n\n let lastTabKeyDownAt = 0\n /** True between a pointerdown and its pointerup/pointercancel: focus events\n * inside that window belong to a pointer gesture (drag bootstrap, press)\n * and must reach their element untouched. */\n let pointerGestureActive = false\n /** The element holding a suppressed programmatic focus, if it still holds\n * `activeElement`. One slot: a newer suppressed focus replaces an older\n * one, and anything that already lost focus needs no release. */\n let phantomFocusTarget: Element | undefined\n /** The phantom-release `pointermove` listener exists only while a phantom\n * does: a gate that parks a permanent pointer listener on every document\n * with a tooltip in it costs every page a standing listener for a state\n * that is live for a few hundred milliseconds at most. */\n let phantomReleaseAttached = false\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Tab') lastTabKeyDownAt = Date.now()\n }\n const onPointerDown = () => {\n pointerGestureActive = true\n releasePhantomFocus()\n }\n const onPointerGestureEnd = () => {\n pointerGestureActive = false\n }\n const dropPhantom = () => {\n phantomFocusTarget = undefined\n if (phantomReleaseAttached) {\n phantomReleaseAttached = false\n doc.removeEventListener('pointermove', onPointerMove, true)\n }\n }\n const onFocus = (event: FocusEvent) => {\n // Focus that moves on retires the phantom: there is nothing left to\n // release, so the parked pointer listener goes with it.\n if (phantomFocusTarget && event.target !== phantomFocusTarget) dropPhantom()\n if (pointerGestureActive) return\n if (!isButtonLikeFocusTarget(event.target)) return\n const keyboardIntentActive = Date.now() - lastTabKeyDownAt <= TOOLTIP_FOCUS_INTENT_WINDOW_MS\n if (!shouldSuppressTooltipFocus({ isButtonLike: true, keyboardIntentActive })) return\n event.stopPropagation()\n if (isTabFocusTarget(event.target)) return\n phantomFocusTarget = event.target as Element\n if (!phantomReleaseAttached) {\n phantomReleaseAttached = true\n doc.addEventListener('pointermove', onPointerMove, true)\n }\n }\n const releasePhantomFocus = () => {\n if (pointerGestureActive) return\n if (!phantomFocusTarget) return\n const phantom = phantomFocusTarget\n dropPhantom()\n if ((doc as Document).activeElement !== phantom) return\n if (typeof (phantom as HTMLElement).blur === 'function') (phantom as HTMLElement).blur()\n }\n const onPointerMove = () => releasePhantomFocus()\n\n doc.addEventListener('keydown', onKeyDown, true)\n doc.addEventListener('focus', onFocus, true)\n doc.addEventListener('pointerdown', onPointerDown, true)\n doc.addEventListener('pointerup', onPointerGestureEnd, true)\n doc.addEventListener('pointercancel', onPointerGestureEnd, true)\n installedDocuments.add(doc)\n return () => {\n doc.removeEventListener('keydown', onKeyDown, true)\n doc.removeEventListener('focus', onFocus, true)\n doc.removeEventListener('pointerdown', onPointerDown, true)\n doc.removeEventListener('pointerup', onPointerGestureEnd, true)\n doc.removeEventListener('pointercancel', onPointerGestureEnd, true)\n doc.removeEventListener('pointermove', onPointerMove, true)\n installedDocuments.delete(doc)\n }\n}\n\n/**\n * Reference-counted install for the tooltip root: the first tooltip in a\n * document acquires the gate, the last one to unmount releases it. The document\n * parameter exists so tests can drive the counter without a global DOM; the\n * production call site guards on the server render before calling.\n */\nconst gateHolders = new WeakMap<Document, number>()\nconst gateDisposers = new WeakMap<Document, () => void>()\n\nexport function acquireTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n gateHolders.set(doc, holders + 1)\n if (holders === 0) gateDisposers.set(doc, installTooltipFocusGate(doc))\n}\n\nexport function releaseTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n if (holders === 0) return\n if (holders === 1) {\n gateHolders.delete(doc)\n gateDisposers.get(doc)?.()\n gateDisposers.delete(doc)\n return\n }\n gateHolders.set(doc, holders - 1)\n}\n"],"mappings":";;;;;AAiFA,IAAa,iCAAiC;;;AAI9C,IAAM,uBAAuB;;;;;;AAO7B,SAAS,kBAAkB,QAAiC;CAC1D,MAAM,UAAU;CAChB,IAAI,OAAO,SAAS,YAAY,YAAY,OAAO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AAY,IAAI,GAAG,KAAK;CACxC,IAAI,YAAY,GAAG;CACnB,IAAI,YAAY,GAAG;EACjB,YAAY,OAAO,GAAG;EACtB,cAAc,IAAI,GAAG,CAAC,GAAG;EACzB,cAAc,OAAO,GAAG;EACxB;CACF;CACA,YAAY,IAAI,KAAK,UAAU,CAAC;AAClC"}
|
package/dist/r/lib.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"title": "Class-name and token helpers",
|
|
5
5
|
"description": "The private helpers the components import: the class-name merge, the variant recipes, the token manifest and the theme bridge. Installed automatically as a peer of any component that needs it.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"@adea-ai/themes@^0.11.
|
|
7
|
+
"@adea-ai/themes@^0.11.5",
|
|
8
8
|
"class-variance-authority@^0.7.1",
|
|
9
9
|
"cn@^0.5.1"
|
|
10
10
|
],
|
package/dist/r/registry.json
CHANGED
|
@@ -2298,7 +2298,7 @@
|
|
|
2298
2298
|
"title": "Appearance Editor",
|
|
2299
2299
|
"description": "",
|
|
2300
2300
|
"dependencies": [
|
|
2301
|
-
"@adea-ai/themes@^0.11.
|
|
2301
|
+
"@adea-ai/themes@^0.11.5",
|
|
2302
2302
|
"@kobalte/core@^0.13.14",
|
|
2303
2303
|
"lucide-solid@^1.65.0"
|
|
2304
2304
|
],
|
|
@@ -3458,7 +3458,7 @@
|
|
|
3458
3458
|
"title": "Theming",
|
|
3459
3459
|
"description": "",
|
|
3460
3460
|
"dependencies": [
|
|
3461
|
-
"@adea-ai/themes@^0.11.
|
|
3461
|
+
"@adea-ai/themes@^0.11.5",
|
|
3462
3462
|
"@kobalte/core@^0.13.14",
|
|
3463
3463
|
"lucide-solid@^1.65.0"
|
|
3464
3464
|
],
|
|
@@ -3643,7 +3643,7 @@
|
|
|
3643
3643
|
"title": "Class-name and token helpers",
|
|
3644
3644
|
"description": "The private helpers the components import: the class-name merge, the variant recipes, the token manifest and the theme bridge. Installed automatically as a peer of any component that needs it.",
|
|
3645
3645
|
"dependencies": [
|
|
3646
|
-
"@adea-ai/themes@^0.11.
|
|
3646
|
+
"@adea-ai/themes@^0.11.5",
|
|
3647
3647
|
"class-variance-authority@^0.7.1",
|
|
3648
3648
|
"cn@^0.5.1"
|
|
3649
3649
|
],
|
|
@@ -668,6 +668,21 @@ export function parseAnsi(text: string, options?: AnsiParserOptions): AnsiLine[]
|
|
|
668
668
|
return open ? [...parser.lines, open] : [...parser.lines]
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
+
/**
|
|
672
|
+
* The whole output as a reader sees it, for the clipboard: every line, none
|
|
673
|
+
* shortened, with escape sequences and overwritten text resolved away.
|
|
674
|
+
*/
|
|
675
|
+
export function ansiPlainText(text: string): string {
|
|
676
|
+
const parser = createAnsiParser({
|
|
677
|
+
maxLineLength: Number.POSITIVE_INFINITY,
|
|
678
|
+
retainLines: Number.POSITIVE_INFINITY,
|
|
679
|
+
})
|
|
680
|
+
parser.write(text)
|
|
681
|
+
const open = parser.openLine()
|
|
682
|
+
// Finished lines carry their newline even when only control sequences follow.
|
|
683
|
+
return [...parser.lines.map(ansiLineText), open ? ansiLineText(open) : ''].join('\n')
|
|
684
|
+
}
|
|
685
|
+
|
|
671
686
|
/** A line's text with styling removed, for tests and for accessible names. */
|
|
672
687
|
export function ansiLineText(line: AnsiLine): string {
|
|
673
688
|
return line.segments.map((segment) => segment.text).join('')
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
resolveColors,
|
|
27
27
|
type AnsiLine,
|
|
28
28
|
type AnsiStyle,
|
|
29
|
+
ansiPlainText,
|
|
29
30
|
} from './ansi'
|
|
30
31
|
import {
|
|
31
32
|
isAtBottom,
|
|
@@ -407,7 +408,7 @@ export function Terminal(props: TerminalProps) {
|
|
|
407
408
|
const copy = async () => {
|
|
408
409
|
let ok = true
|
|
409
410
|
try {
|
|
410
|
-
await writeClipboardText(local.output)
|
|
411
|
+
await writeClipboardText(ansiPlainText(local.output))
|
|
411
412
|
} catch {
|
|
412
413
|
ok = false
|
|
413
414
|
}
|
|
@@ -614,8 +614,11 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
614
614
|
</DialogTrigger>
|
|
615
615
|
</Show>
|
|
616
616
|
|
|
617
|
+
{/* The footer keeps the visible "Close"; the corner icon is named for the
|
|
618
|
+
dialog so the two controls stay distinct to assistive tech. */}
|
|
617
619
|
<DialogContent
|
|
618
620
|
positioner="inset"
|
|
621
|
+
closeLabel="Close version and updates"
|
|
619
622
|
class={cn('flex max-h-full min-h-0 max-w-3xl flex-col overflow-hidden', local.class)}
|
|
620
623
|
onKeyDown={(event: KeyboardEvent) => {
|
|
621
624
|
// An explanatory tooltip must not consume the popup's close shortcut,
|
|
@@ -269,6 +269,12 @@ export type DialogContentProps = ComponentProps<typeof KobalteDialogContent> & {
|
|
|
269
269
|
* user can escape from needs the button.
|
|
270
270
|
*/
|
|
271
271
|
closeButton?: JSX.Element | false
|
|
272
|
+
/**
|
|
273
|
+
* The corner close's accessible name. Defaults to "Close". Name it for the
|
|
274
|
+
* dialog ("Close version and updates") when the footer also has a text
|
|
275
|
+
* "Close", so the two controls do not share one name.
|
|
276
|
+
*/
|
|
277
|
+
closeLabel?: string
|
|
272
278
|
/** Use a 1rem inset as the positioner bounds for tall, viewport-filling surfaces. */
|
|
273
279
|
positioner?: 'default' | 'inset'
|
|
274
280
|
/**
|
|
@@ -295,6 +301,7 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
295
301
|
'class',
|
|
296
302
|
'children',
|
|
297
303
|
'closeButton',
|
|
304
|
+
'closeLabel',
|
|
298
305
|
'positioner',
|
|
299
306
|
'size',
|
|
300
307
|
])
|
|
@@ -316,12 +323,12 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
316
323
|
{local.children}
|
|
317
324
|
<Show when={local.closeButton !== false}>
|
|
318
325
|
{/* The corner close is icon-only, so it carries the shared tooltip
|
|
319
|
-
treatment
|
|
326
|
+
treatment. Its accessible name is "Close" unless the caller names it. */}
|
|
320
327
|
<Tooltip>
|
|
321
328
|
<TooltipTrigger
|
|
322
329
|
as={KobalteDialog.CloseButton}
|
|
323
330
|
data-slot="dialog-corner-close"
|
|
324
|
-
aria-label=
|
|
331
|
+
aria-label={local.closeLabel ?? 'Close'}
|
|
325
332
|
class={cn(
|
|
326
333
|
'absolute top-3.5 end-3.5 rounded-md p-1 text-muted-foreground',
|
|
327
334
|
'transition-colors ease-out hover:bg-surface-hover hover:text-foreground',
|
|
@@ -330,7 +337,9 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
330
337
|
>
|
|
331
338
|
{local.closeButton ?? <X class="size-4" />}
|
|
332
339
|
</TooltipTrigger>
|
|
333
|
-
<TooltipContent>
|
|
340
|
+
<TooltipContent>
|
|
341
|
+
{local.closeLabel ? `${local.closeLabel}.` : 'Close dialog.'}
|
|
342
|
+
</TooltipContent>
|
|
334
343
|
</Tooltip>
|
|
335
344
|
</Show>
|
|
336
345
|
</KobalteDialogContent>
|
|
@@ -55,6 +55,16 @@
|
|
|
55
55
|
* click behaviour already keeps tooltips closed, and the autofocus cases this
|
|
56
56
|
* gate exists for all happen with the pointer up.
|
|
57
57
|
*
|
|
58
|
+
* A tab in a roving-focus tab list is the one button-like element whose
|
|
59
|
+
* programmatic focus is the widget working as designed: a dialog's focus scope
|
|
60
|
+
* and the tab list both put focus on the selected tab, and the tab list scrolls
|
|
61
|
+
* it into view on every focus-in. Releasing that focus would hand it straight
|
|
62
|
+
* back (the scope restores it), so every pointer move would re-suppress,
|
|
63
|
+
* re-release and re-scroll the rail to the top, and a tab below the fold of a
|
|
64
|
+
* large-font or short-window rail could not be clicked. A focus on `role="tab"`
|
|
65
|
+
* is therefore still hidden from the tooltip, so no tooltip opens from it, but
|
|
66
|
+
* it is not tracked as a phantom and the pointer never blurs it.
|
|
67
|
+
*
|
|
58
68
|
* Independently of the gesture window, resize grips render as
|
|
59
69
|
* `<button role="separator">` and carry no tooltip, so they are excluded from
|
|
60
70
|
* the button-like scope entirely (see `isButtonLikeFocusTarget`).
|
|
@@ -80,10 +90,23 @@ const BUTTON_LIKE_SELECTOR = 'button, a[href], [role="button"], [role="link"]'
|
|
|
80
90
|
* button-like control. Accepts any Element (an SVG glyph inside a control,
|
|
81
91
|
* for instance) and duck-types so the decision is testable without a DOM.
|
|
82
92
|
*/
|
|
83
|
-
|
|
93
|
+
function buttonLikeControl(target: unknown): Element | null {
|
|
84
94
|
const element = target as Element | null | undefined
|
|
85
|
-
if (typeof element?.closest !== 'function') return
|
|
86
|
-
|
|
95
|
+
if (typeof element?.closest !== 'function') return null
|
|
96
|
+
return element.closest(BUTTON_LIKE_SELECTOR)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether the focus target is a tab of a roving-focus tab list. Its focus is
|
|
101
|
+
* hidden from tooltips like any other programmatic focus, but it is never
|
|
102
|
+
* released by the pointer (see the header).
|
|
103
|
+
*/
|
|
104
|
+
export function isTabFocusTarget(target: unknown): boolean {
|
|
105
|
+
return buttonLikeControl(target)?.getAttribute?.('role') === 'tab'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function isButtonLikeFocusTarget(target: unknown): boolean {
|
|
109
|
+
const control = buttonLikeControl(target)
|
|
87
110
|
if (control === null) return false
|
|
88
111
|
// Resize grips render as `<button role="separator">` and focus themselves
|
|
89
112
|
// when a pointer drag starts. They carry no tooltip, and the blur that
|
|
@@ -153,6 +176,7 @@ export function installTooltipFocusGate(doc: Document = document): () => void {
|
|
|
153
176
|
const keyboardIntentActive = Date.now() - lastTabKeyDownAt <= TOOLTIP_FOCUS_INTENT_WINDOW_MS
|
|
154
177
|
if (!shouldSuppressTooltipFocus({ isButtonLike: true, keyboardIntentActive })) return
|
|
155
178
|
event.stopPropagation()
|
|
179
|
+
if (isTabFocusTarget(event.target)) return
|
|
156
180
|
phantomFocusTarget = event.target as Element
|
|
157
181
|
if (!phantomReleaseAttached) {
|
|
158
182
|
phantomReleaseAttached = true
|
package/dist/r/theming.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/ui",
|
|
3
|
-
"version": "0.149.
|
|
3
|
+
"version": "0.149.7",
|
|
4
4
|
"description": "The Adea design system: Kobalte-backed Solid components, semantic OKLCH tokens, and the app-shell layout primitives shared by Adea and Cortana.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adea",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"build": "bun run cn:build && vite build && tsc -p tsconfig.json --emitDeclarationOnly",
|
|
121
121
|
"dev": "bun run cn:build && vite build --watch",
|
|
122
122
|
"lint": "oxlint",
|
|
123
|
-
"test": "bun run cn:check && bun test --conditions=browser --preload ./src/testing/solid-transform.ts tests",
|
|
123
|
+
"test": "bun run cn:check && bun test --conditions=browser --preload ./src/testing/solid-transform.ts tests src",
|
|
124
124
|
"typecheck": "bun check -p tsconfig.check.json",
|
|
125
125
|
"cn:build": "bun scripts/build-cn-tables.ts",
|
|
126
126
|
"cn:check": "bun scripts/check-cn-tables.ts",
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"check:packed-paste-model": "node scripts/check-packed-paste-model.mjs"
|
|
151
151
|
},
|
|
152
152
|
"dependencies": {
|
|
153
|
-
"@adea-ai/themes": "^0.11.
|
|
153
|
+
"@adea-ai/themes": "^0.11.5",
|
|
154
154
|
"@corvu/calendar": "^0.1.2",
|
|
155
155
|
"@corvu/drawer": "^0.2.4",
|
|
156
156
|
"@corvu/otp-field": "^0.1.4",
|
package/registry.json
CHANGED
|
@@ -2298,7 +2298,7 @@
|
|
|
2298
2298
|
"title": "Appearance Editor",
|
|
2299
2299
|
"description": "",
|
|
2300
2300
|
"dependencies": [
|
|
2301
|
-
"@adea-ai/themes@^0.11.
|
|
2301
|
+
"@adea-ai/themes@^0.11.5",
|
|
2302
2302
|
"@kobalte/core@^0.13.14",
|
|
2303
2303
|
"lucide-solid@^1.65.0"
|
|
2304
2304
|
],
|
|
@@ -3458,7 +3458,7 @@
|
|
|
3458
3458
|
"title": "Theming",
|
|
3459
3459
|
"description": "",
|
|
3460
3460
|
"dependencies": [
|
|
3461
|
-
"@adea-ai/themes@^0.11.
|
|
3461
|
+
"@adea-ai/themes@^0.11.5",
|
|
3462
3462
|
"@kobalte/core@^0.13.14",
|
|
3463
3463
|
"lucide-solid@^1.65.0"
|
|
3464
3464
|
],
|
|
@@ -3643,7 +3643,7 @@
|
|
|
3643
3643
|
"title": "Class-name and token helpers",
|
|
3644
3644
|
"description": "The private helpers the components import: the class-name merge, the variant recipes, the token manifest and the theme bridge. Installed automatically as a peer of any component that needs it.",
|
|
3645
3645
|
"dependencies": [
|
|
3646
|
-
"@adea-ai/themes@^0.11.
|
|
3646
|
+
"@adea-ai/themes@^0.11.5",
|
|
3647
3647
|
"class-variance-authority@^0.7.1",
|
|
3648
3648
|
"cn@^0.5.1"
|
|
3649
3649
|
],
|
|
@@ -668,6 +668,21 @@ export function parseAnsi(text: string, options?: AnsiParserOptions): AnsiLine[]
|
|
|
668
668
|
return open ? [...parser.lines, open] : [...parser.lines]
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
+
/**
|
|
672
|
+
* The whole output as a reader sees it, for the clipboard: every line, none
|
|
673
|
+
* shortened, with escape sequences and overwritten text resolved away.
|
|
674
|
+
*/
|
|
675
|
+
export function ansiPlainText(text: string): string {
|
|
676
|
+
const parser = createAnsiParser({
|
|
677
|
+
maxLineLength: Number.POSITIVE_INFINITY,
|
|
678
|
+
retainLines: Number.POSITIVE_INFINITY,
|
|
679
|
+
})
|
|
680
|
+
parser.write(text)
|
|
681
|
+
const open = parser.openLine()
|
|
682
|
+
// Finished lines carry their newline even when only control sequences follow.
|
|
683
|
+
return [...parser.lines.map(ansiLineText), open ? ansiLineText(open) : ''].join('\n')
|
|
684
|
+
}
|
|
685
|
+
|
|
671
686
|
/** A line's text with styling removed, for tests and for accessible names. */
|
|
672
687
|
export function ansiLineText(line: AnsiLine): string {
|
|
673
688
|
return line.segments.map((segment) => segment.text).join('')
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
resolveColors,
|
|
27
27
|
type AnsiLine,
|
|
28
28
|
type AnsiStyle,
|
|
29
|
+
ansiPlainText,
|
|
29
30
|
} from './ansi'
|
|
30
31
|
import {
|
|
31
32
|
isAtBottom,
|
|
@@ -407,7 +408,7 @@ export function Terminal(props: TerminalProps) {
|
|
|
407
408
|
const copy = async () => {
|
|
408
409
|
let ok = true
|
|
409
410
|
try {
|
|
410
|
-
await writeClipboardText(local.output)
|
|
411
|
+
await writeClipboardText(ansiPlainText(local.output))
|
|
411
412
|
} catch {
|
|
412
413
|
ok = false
|
|
413
414
|
}
|
|
@@ -614,8 +614,11 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
614
614
|
</DialogTrigger>
|
|
615
615
|
</Show>
|
|
616
616
|
|
|
617
|
+
{/* The footer keeps the visible "Close"; the corner icon is named for the
|
|
618
|
+
dialog so the two controls stay distinct to assistive tech. */}
|
|
617
619
|
<DialogContent
|
|
618
620
|
positioner="inset"
|
|
621
|
+
closeLabel="Close version and updates"
|
|
619
622
|
class={cn('flex max-h-full min-h-0 max-w-3xl flex-col overflow-hidden', local.class)}
|
|
620
623
|
onKeyDown={(event: KeyboardEvent) => {
|
|
621
624
|
// An explanatory tooltip must not consume the popup's close shortcut,
|
|
@@ -269,6 +269,12 @@ export type DialogContentProps = ComponentProps<typeof KobalteDialogContent> & {
|
|
|
269
269
|
* user can escape from needs the button.
|
|
270
270
|
*/
|
|
271
271
|
closeButton?: JSX.Element | false
|
|
272
|
+
/**
|
|
273
|
+
* The corner close's accessible name. Defaults to "Close". Name it for the
|
|
274
|
+
* dialog ("Close version and updates") when the footer also has a text
|
|
275
|
+
* "Close", so the two controls do not share one name.
|
|
276
|
+
*/
|
|
277
|
+
closeLabel?: string
|
|
272
278
|
/** Use a 1rem inset as the positioner bounds for tall, viewport-filling surfaces. */
|
|
273
279
|
positioner?: 'default' | 'inset'
|
|
274
280
|
/**
|
|
@@ -295,6 +301,7 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
295
301
|
'class',
|
|
296
302
|
'children',
|
|
297
303
|
'closeButton',
|
|
304
|
+
'closeLabel',
|
|
298
305
|
'positioner',
|
|
299
306
|
'size',
|
|
300
307
|
])
|
|
@@ -316,12 +323,12 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
316
323
|
{local.children}
|
|
317
324
|
<Show when={local.closeButton !== false}>
|
|
318
325
|
{/* The corner close is icon-only, so it carries the shared tooltip
|
|
319
|
-
treatment
|
|
326
|
+
treatment. Its accessible name is "Close" unless the caller names it. */}
|
|
320
327
|
<Tooltip>
|
|
321
328
|
<TooltipTrigger
|
|
322
329
|
as={KobalteDialog.CloseButton}
|
|
323
330
|
data-slot="dialog-corner-close"
|
|
324
|
-
aria-label=
|
|
331
|
+
aria-label={local.closeLabel ?? 'Close'}
|
|
325
332
|
class={cn(
|
|
326
333
|
'absolute top-3.5 end-3.5 rounded-md p-1 text-muted-foreground',
|
|
327
334
|
'transition-colors ease-out hover:bg-surface-hover hover:text-foreground',
|
|
@@ -330,7 +337,9 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
330
337
|
>
|
|
331
338
|
{local.closeButton ?? <X class="size-4" />}
|
|
332
339
|
</TooltipTrigger>
|
|
333
|
-
<TooltipContent>
|
|
340
|
+
<TooltipContent>
|
|
341
|
+
{local.closeLabel ? `${local.closeLabel}.` : 'Close dialog.'}
|
|
342
|
+
</TooltipContent>
|
|
334
343
|
</Tooltip>
|
|
335
344
|
</Show>
|
|
336
345
|
</KobalteDialogContent>
|
|
@@ -55,6 +55,16 @@
|
|
|
55
55
|
* click behaviour already keeps tooltips closed, and the autofocus cases this
|
|
56
56
|
* gate exists for all happen with the pointer up.
|
|
57
57
|
*
|
|
58
|
+
* A tab in a roving-focus tab list is the one button-like element whose
|
|
59
|
+
* programmatic focus is the widget working as designed: a dialog's focus scope
|
|
60
|
+
* and the tab list both put focus on the selected tab, and the tab list scrolls
|
|
61
|
+
* it into view on every focus-in. Releasing that focus would hand it straight
|
|
62
|
+
* back (the scope restores it), so every pointer move would re-suppress,
|
|
63
|
+
* re-release and re-scroll the rail to the top, and a tab below the fold of a
|
|
64
|
+
* large-font or short-window rail could not be clicked. A focus on `role="tab"`
|
|
65
|
+
* is therefore still hidden from the tooltip, so no tooltip opens from it, but
|
|
66
|
+
* it is not tracked as a phantom and the pointer never blurs it.
|
|
67
|
+
*
|
|
58
68
|
* Independently of the gesture window, resize grips render as
|
|
59
69
|
* `<button role="separator">` and carry no tooltip, so they are excluded from
|
|
60
70
|
* the button-like scope entirely (see `isButtonLikeFocusTarget`).
|
|
@@ -80,10 +90,23 @@ const BUTTON_LIKE_SELECTOR = 'button, a[href], [role="button"], [role="link"]'
|
|
|
80
90
|
* button-like control. Accepts any Element (an SVG glyph inside a control,
|
|
81
91
|
* for instance) and duck-types so the decision is testable without a DOM.
|
|
82
92
|
*/
|
|
83
|
-
|
|
93
|
+
function buttonLikeControl(target: unknown): Element | null {
|
|
84
94
|
const element = target as Element | null | undefined
|
|
85
|
-
if (typeof element?.closest !== 'function') return
|
|
86
|
-
|
|
95
|
+
if (typeof element?.closest !== 'function') return null
|
|
96
|
+
return element.closest(BUTTON_LIKE_SELECTOR)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether the focus target is a tab of a roving-focus tab list. Its focus is
|
|
101
|
+
* hidden from tooltips like any other programmatic focus, but it is never
|
|
102
|
+
* released by the pointer (see the header).
|
|
103
|
+
*/
|
|
104
|
+
export function isTabFocusTarget(target: unknown): boolean {
|
|
105
|
+
return buttonLikeControl(target)?.getAttribute?.('role') === 'tab'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function isButtonLikeFocusTarget(target: unknown): boolean {
|
|
109
|
+
const control = buttonLikeControl(target)
|
|
87
110
|
if (control === null) return false
|
|
88
111
|
// Resize grips render as `<button role="separator">` and focus themselves
|
|
89
112
|
// when a pointer drag starts. They carry no tooltip, and the blur that
|
|
@@ -153,6 +176,7 @@ export function installTooltipFocusGate(doc: Document = document): () => void {
|
|
|
153
176
|
const keyboardIntentActive = Date.now() - lastTabKeyDownAt <= TOOLTIP_FOCUS_INTENT_WINDOW_MS
|
|
154
177
|
if (!shouldSuppressTooltipFocus({ isButtonLike: true, keyboardIntentActive })) return
|
|
155
178
|
event.stopPropagation()
|
|
179
|
+
if (isTabFocusTarget(event.target)) return
|
|
156
180
|
phantomFocusTarget = event.target as Element
|
|
157
181
|
if (!phantomReleaseAttached) {
|
|
158
182
|
phantomReleaseAttached = true
|