@deepseek-ai/dsh-client-ui-primitives 0.2.2-alpha.2 → 0.2.2-alpha.3

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/lib/index.js CHANGED
@@ -11,8 +11,8 @@ import css$6 from "./Button.module.css";
11
11
  import { createPortal } from "react-dom";
12
12
  import css$7 from "./ShortcutKeys.module.css";
13
13
  import css$8 from "./MenuSurface.module.css";
14
- import css$9 from "./Menu.module.css";
15
- import css$10 from "./Tooltip.module.css";
14
+ import css$9 from "./Tooltip.module.css";
15
+ import css$10 from "./Menu.module.css";
16
16
  import css$11 from "./ZoomControls.module.css";
17
17
  import css$12 from "./Pill.module.css";
18
18
  import css$13 from "./SegmentedTabs.module.css";
@@ -58,7 +58,7 @@ import { mathFromMarkdown } from "mdast-util-math";
58
58
  import { gfm } from "micromark-extension-gfm";
59
59
  import { math } from "micromark-extension-math";
60
60
  import { attention } from "micromark-core-commonmark";
61
- import { markdownLineEnding, markdownSpace, unicodePunctuation } from "micromark-util-character";
61
+ import { markdownLineEnding, unicodePunctuation } from "micromark-util-character";
62
62
  import { classifyCharacter } from "micromark-util-classify-character";
63
63
  import { codes, constants, types } from "micromark-util-symbol";
64
64
  import { factorySpace } from "micromark-factory-space";
@@ -99,6 +99,10 @@ const ICON_REGULAR_STROKE = 1;
99
99
  const ICON_MEDIUM_STROKE = 1.3;
100
100
  /** Default artwork keyed by glyph name; symbol ids derive from these keys. */
101
101
  const ICON_ARTWORK = {
102
+ "save-outline": {
103
+ size: 16,
104
+ svg: (strokeWidth) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="${strokeWidth}" stroke-linejoin="round"><path d="M2.5 1.5h8l3 3v9a1 1 0 0 1-1 1h-10a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1Z"></path><path d="M4.5 1.5v4h6v-4M4 14.5v-6h7v6"></path></svg>`
105
+ },
102
106
  "new-chat-outline": {
103
107
  size: 16,
104
108
  svg: (strokeWidth) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke-width="${strokeWidth}"><path d="M2.37091 11.2501C1.58745 9.89288 1.32067 8.29835 1.61969 6.76006C1.91872 5.22177 2.76342 3.8433 3.99826 2.87846C5.2331 1.91362 6.77494 1.42737 8.33988 1.50925C9.90482 1.59113 11.3875 2.23562 12.5149 3.32406C13.6425 4.41269 14.3387 5.87206 14.4754 7.4334C14.612 8.99474 14.18 10.5529 13.2587 11.8209C12.3375 13.0888 10.9891 13.9813 9.46194 14.3337C8.18691 14.628 6.85895 14.5294 5.64989 14.0605C5.1712 13.8748 4.76962 13.4932 4.26534 13.3967C3.67413 13.2835 2.95257 13.5598 2.03794 14.3337" stroke="currentColor"></path><path d="M8 5V11" stroke="currentColor"></path><path d="M5 8H11" stroke="currentColor"></path></svg>`
@@ -916,6 +920,10 @@ function appsAddIcon(weight) {
916
920
  const IconAppsAddOutlineRegular = appsAddIcon("regular");
917
921
  /** Three entry tiles and an add mark with 1.3px strokes. */
918
922
  const IconAppsAddOutlineMedium = appsAddIcon("medium");
923
+ /** Regular floppy-disk save action. */
924
+ const IconSaveOutlineRegular = productIcon("save-outline", "regular");
925
+ /** Medium floppy-disk save action. */
926
+ const IconSaveOutlineMedium = productIcon("save-outline", "medium");
919
927
  //#endregion
920
928
  //#region lib/types/StateDot.js
921
929
  /**
@@ -1376,6 +1384,119 @@ function overlayTopMargin(min, anchor, gap = 0) {
1376
1384
  const cap = anchor !== void 0 && anchor.top >= 0 ? anchor.bottom + gap : Number.POSITIVE_INFINITY;
1377
1385
  return Math.max(min, Math.min((root.hasAttribute("data-fullscreen") ? 0 : clearance) + 20, cap));
1378
1386
  }
1387
+ //#endregion
1388
+ //#region lib/types/useAnchoredPosition.js
1389
+ /** Synchronous placement for body-portaled panels with a viewport fixed-position containing block. */
1390
+ /**
1391
+ * Keep a fixed panel aligned and constrained to the visible viewport.
1392
+ * Panel CSS consumes `--dsh-anchored-max-width` and `--dsh-anchored-max-height` for size limits.
1393
+ * The hook owns those inline variables and optional min-width while open, restoring them on cleanup.
1394
+ * @param options - Open state, element refs, placement, and optional host rect or content change key.
1395
+ * @returns Fixed left/top coordinates, or null while closed or awaiting an anchor; the first measurement completes before paint.
1396
+ */
1397
+ function useAnchoredPosition(options) {
1398
+ const { open, anchorRef, panelRef, side = "bottom", align = "start", gap, margin, getAnchorRect, layoutKey, minWidthFromAnchor = false, frameClearance = true } = options;
1399
+ const [position, setPosition] = useState(null);
1400
+ useLayoutEffect(() => {
1401
+ if (!open) {
1402
+ setPosition(null);
1403
+ return;
1404
+ }
1405
+ const anchor = anchorRef.current;
1406
+ const panel = panelRef.current;
1407
+ if (anchor === null || panel === null) return;
1408
+ const win = anchor.ownerDocument.defaultView;
1409
+ if (win === null) return;
1410
+ const viewport = win.visualViewport;
1411
+ const visualOrigin = typeof win.CSS !== "undefined" && win.CSS.supports("-webkit-backdrop-filter", "none");
1412
+ const previous = [
1413
+ "--dsh-anchored-max-width",
1414
+ "--dsh-anchored-max-height",
1415
+ ...minWidthFromAnchor ? ["min-width"] : []
1416
+ ].map((name) => [
1417
+ name,
1418
+ panel.style.getPropertyValue(name),
1419
+ panel.style.getPropertyPriority(name)
1420
+ ]);
1421
+ let active = true;
1422
+ let lastRect = null;
1423
+ const readRect = () => getAnchorRect === void 0 ? anchor.getBoundingClientRect() : getAnchorRect();
1424
+ const place = (rect) => {
1425
+ lastRect = rect === null ? null : {
1426
+ x: rect.x,
1427
+ y: rect.y,
1428
+ width: rect.width,
1429
+ height: rect.height
1430
+ };
1431
+ let next = null;
1432
+ if (rect !== null) {
1433
+ const x = viewport?.offsetLeft ?? 0;
1434
+ const y = viewport?.offsetTop ?? 0;
1435
+ const width = viewport?.width ?? (anchor.ownerDocument.documentElement.clientWidth || win.innerWidth);
1436
+ const height = viewport?.height ?? (anchor.ownerDocument.documentElement.clientHeight || win.innerHeight);
1437
+ const topMargin = frameClearance ? overlayTopMargin(margin, rect, gap) : margin;
1438
+ const maxWidth = Math.max(0, width - margin * 2);
1439
+ panel.style.setProperty("--dsh-anchored-max-width", `${maxWidth}px`);
1440
+ panel.style.setProperty("--dsh-anchored-max-height", `${Math.max(0, height - topMargin - margin)}px`);
1441
+ if (minWidthFromAnchor) panel.style.minWidth = `${Math.min(rect.width, maxWidth)}px`;
1442
+ const panelWidth = panel.offsetWidth;
1443
+ const panelHeight = panel.offsetHeight;
1444
+ const offsetX = visualOrigin ? x : 0;
1445
+ const offsetY = visualOrigin ? y : 0;
1446
+ const left = offsetX + (side === "right" ? rect.right + gap : align === "end" ? rect.right - panelWidth : rect.left);
1447
+ const top = offsetY + (side === "right" ? rect.top : side === "top" ? rect.top - gap - panelHeight : rect.bottom + gap);
1448
+ next = {
1449
+ left: Math.max(x + margin, Math.min(left, x + width - margin - panelWidth)),
1450
+ top: Math.max(y + topMargin, Math.min(top, y + height - margin - panelHeight))
1451
+ };
1452
+ }
1453
+ setPosition((current) => current?.left === next?.left && current?.top === next?.top ? current : next);
1454
+ };
1455
+ const update = () => {
1456
+ if (!active) return;
1457
+ place(readRect());
1458
+ };
1459
+ update();
1460
+ win.addEventListener("scroll", update, true);
1461
+ win.addEventListener("resize", update);
1462
+ viewport?.addEventListener("scroll", update);
1463
+ viewport?.addEventListener("resize", update);
1464
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
1465
+ observer?.observe(anchor);
1466
+ observer?.observe(panel);
1467
+ let frame = 0;
1468
+ const track = () => {
1469
+ if (!active) return;
1470
+ const rect = readRect();
1471
+ if (rect?.x !== lastRect?.x || rect?.y !== lastRect?.y || rect?.width !== lastRect?.width || rect?.height !== lastRect?.height) place(rect);
1472
+ frame = win.requestAnimationFrame(track);
1473
+ };
1474
+ frame = win.requestAnimationFrame(track);
1475
+ return () => {
1476
+ active = false;
1477
+ win.cancelAnimationFrame(frame);
1478
+ observer?.disconnect();
1479
+ win.removeEventListener("scroll", update, true);
1480
+ win.removeEventListener("resize", update);
1481
+ viewport?.removeEventListener("scroll", update);
1482
+ viewport?.removeEventListener("resize", update);
1483
+ for (const [name, value, priority] of previous) panel.style.setProperty(name, value, priority);
1484
+ };
1485
+ }, [
1486
+ open,
1487
+ anchorRef,
1488
+ panelRef,
1489
+ side,
1490
+ align,
1491
+ gap,
1492
+ margin,
1493
+ getAnchorRect,
1494
+ layoutKey,
1495
+ minWidthFromAnchor,
1496
+ frameClearance
1497
+ ]);
1498
+ return position;
1499
+ }
1379
1500
  /**
1380
1501
  * Delay a pointer-dismissed popup's close so the pointer can cross the gap
1381
1502
  * between anchor and popup. A pending close is dropped on unmount.
@@ -1538,9 +1659,13 @@ const focusable = "button:not(:disabled), input:not(:disabled), textarea:not(:di
1538
1659
  */
1539
1660
  function useModalLayer(dialog, open, onClose) {
1540
1661
  const close = useRef(onClose);
1662
+ const pendingRestore = useRef(void 0);
1541
1663
  close.current = onClose;
1542
1664
  useLayoutEffect(() => {
1665
+ const target = pendingRestore.current;
1666
+ pendingRestore.current = void 0;
1543
1667
  const element = dialog.current;
1668
+ if (!open && element?.contains(element.ownerDocument.activeElement) && target?.isConnected && !target.closest("[inert], [hidden]") && !isBehindModal(target)) focusWithoutRing(target, { preventScroll: true });
1544
1669
  if (!open || element === null) return;
1545
1670
  const document = element.ownerDocument;
1546
1671
  const composition = observeComposition(document);
@@ -1583,7 +1708,10 @@ function useModalLayer(dialog, open, onClose) {
1583
1708
  if (stack.length === 0) layers.delete(document);
1584
1709
  if (wasTop) {
1585
1710
  const target = previous instanceof HTMLElement && previous.isConnected ? previous : stack.at(-1)?.element;
1586
- if (target !== void 0) focusWithoutRing(target);
1711
+ if (target !== void 0) {
1712
+ pendingRestore.current = target;
1713
+ focusWithoutRing(target);
1714
+ }
1587
1715
  }
1588
1716
  };
1589
1717
  }, [dialog, open]);
@@ -1608,6 +1736,13 @@ function ShortcutKeys({ keys, variant = "plain", className }) {
1608
1736
  //#endregion
1609
1737
  //#region lib/types/MenuSurface.js
1610
1738
  /** Shared menu material and the macOS backing that lets Chromium blur transparent windows. */
1739
+ /** Context-menu transition durations in milliseconds, shared with its lifecycle owner. */
1740
+ const MENU_TRANSITION_MS = Object.freeze({
1741
+ enter: 40,
1742
+ dismiss: 80,
1743
+ replace: 10,
1744
+ prepare: 20
1745
+ });
1611
1746
  /**
1612
1747
  * Paint a menu and, on macOS, an opaque backing behind the page content within its bounds.
1613
1748
  * CSS anchors keep each backing aligned during placement, resizing, and nested-menu movement.
@@ -1615,17 +1750,23 @@ function ShortcutKeys({ keys, variant = "plain", className }) {
1615
1750
  * @param ref - The visible menu div, excluding the non-interactive backing.
1616
1751
  * @returns Menu content plus a backing portal removed with the menu.
1617
1752
  */
1618
- const MenuSurface = forwardRef(function MenuSurface({ compact = false, className, style, children, ...props }, ref) {
1753
+ const MenuSurface = forwardRef(function MenuSurface({ compact = false, phase, className, style, children, ...props }, ref) {
1619
1754
  const id = useId();
1620
1755
  const backingRef = useRef(null);
1621
1756
  useLayoutEffect(() => {
1622
1757
  document.body.appendChild(backingRef.current);
1623
1758
  }, []);
1624
- const anchorStyle = { "--dsh-menu-anchor": `--dsh-menu-${id.replaceAll(":", "")}` };
1759
+ const anchorStyle = {
1760
+ "--dsh-menu-anchor": `--dsh-menu-${id.replaceAll(":", "")}`,
1761
+ "--dsh-menu-enter": `${MENU_TRANSITION_MS.enter}ms`,
1762
+ "--dsh-menu-dismiss": `${MENU_TRANSITION_MS.dismiss}ms`,
1763
+ "--dsh-menu-replace": `${MENU_TRANSITION_MS.replace}ms`
1764
+ };
1625
1765
  return jsxs(Fragment, { children: [jsxs("div", {
1626
1766
  ...props,
1627
1767
  ref,
1628
1768
  "data-menu-material": "translucent",
1769
+ "data-menu-phase": phase,
1629
1770
  className: clsx(css$8.surface, compact && css$8.compact, className),
1630
1771
  style: {
1631
1772
  ...style,
@@ -1639,6 +1780,7 @@ const MenuSurface = forwardRef(function MenuSurface({ compact = false, className
1639
1780
  ref: backingRef,
1640
1781
  "aria-hidden": "true",
1641
1782
  "data-menu-backing": "",
1783
+ "data-menu-phase": phase,
1642
1784
  className: clsx(css$8.backing, compact && css$8.compact),
1643
1785
  style: {
1644
1786
  ...anchorStyle,
@@ -1647,905 +1789,955 @@ const MenuSurface = forwardRef(function MenuSurface({ compact = false, className
1647
1789
  }), document.body)] });
1648
1790
  });
1649
1791
  //#endregion
1650
- //#region lib/types/Menu.js
1792
+ //#region lib/types/tooltip-placement.js
1793
+ const opposite = {
1794
+ right: "left",
1795
+ left: "right",
1796
+ top: "bottom",
1797
+ bottom: "top"
1798
+ };
1651
1799
  /**
1652
- * Render one `role="menuitem"` row for a {@link Menu} whose rows are
1653
- * components rather than `items` data: the same markup and styling as a data
1654
- * row, so it joins the list's keyboard walk and post-selection focus return
1655
- * without any shared state. Closing the menu stays the owner's decision, as
1656
- * it is for data rows.
1657
- * @param props.children - visible row label.
1658
- * @param props.shortcut - effective key labels and accessible combination.
1659
- * @param props.icon - optional leading icon.
1660
- * @param props.current - whether the row identifies the currently displayed page or view.
1661
- * @param props.disabled - whether the row cannot be activated.
1662
- * @param props.danger - whether to use the destructive row colors.
1663
- * @param props.separatorBefore - whether this row starts a new group (hairline above it).
1664
- * @param props.onSelect - row activation callback.
1665
- * @returns one menu-item row.
1800
+ * Prefer the requested side, its opposite, then perpendicular sides without covering the anchor.
1801
+ * @param input - Observed dimensions, anchor edges, viewport and requested placement; horizontal gaps remain 10px.
1802
+ * @returns Border-box coordinates and the selected side; if no side fits, a viewport-bounded fallback.
1666
1803
  */
1667
- function MenuItemButton({ children, shortcut, icon, current, disabled = false, danger = false, separatorBefore = false, onSelect }) {
1668
- return jsxs("div", {
1669
- className: css$9.itemWrap,
1670
- children: [separatorBefore && jsx("div", {
1671
- className: css$9.separator,
1672
- role: "separator"
1673
- }), jsxs("button", {
1674
- type: "button",
1675
- role: "menuitem",
1676
- className: clsx(css$9.item, danger && css$9.danger),
1677
- disabled,
1678
- "aria-keyshortcuts": shortcut?.aria,
1679
- "aria-current": current === true ? "page" : void 0,
1680
- onClick: onSelect,
1681
- children: [
1682
- icon !== void 0 && jsx("span", {
1683
- className: css$9.itemIcon,
1684
- children: icon
1685
- }),
1686
- jsx("span", {
1687
- className: css$9.itemLabel,
1688
- children
1689
- }),
1690
- shortcut !== void 0 && jsx("span", {
1691
- "aria-hidden": "true",
1692
- className: css$9.shortcut,
1693
- children: jsx(ShortcutKeys, {
1694
- keys: shortcut.keys,
1695
- className: css$9.shortcutKeys
1696
- })
1697
- })
1698
- ]
1699
- })]
1700
- });
1701
- }
1702
- function isSeparator(entry) {
1703
- return "type" in entry && entry.type === "separator";
1804
+ function placeTooltip(input) {
1805
+ const { anchor, viewportWidth, viewportHeight, side, align, gap } = input;
1806
+ let { width, height } = input;
1807
+ const margin = 12;
1808
+ const maxWidth = Math.max(0, viewportWidth - margin * 2);
1809
+ const maxHeight = Math.max(0, viewportHeight - margin * 2);
1810
+ width = Math.min(width, maxWidth);
1811
+ height = Math.min(height, maxHeight);
1812
+ const clampX = (x) => Math.max(margin, Math.min(x, viewportWidth - margin - width));
1813
+ const clampY = (y) => Math.max(margin, Math.min(y, viewportHeight - margin - height));
1814
+ const horizontal = side === "right" || side === "left";
1815
+ const candidates = [
1816
+ side,
1817
+ opposite[side],
1818
+ ...horizontal ? ["bottom", "top"] : ["right", "left"]
1819
+ ];
1820
+ const positions = {
1821
+ right: {
1822
+ left: anchor.right + 10,
1823
+ top: clampY((anchor.top + anchor.bottom - height) / 2)
1824
+ },
1825
+ left: {
1826
+ left: anchor.left - 10 - width,
1827
+ top: clampY((anchor.top + anchor.bottom - height) / 2)
1828
+ },
1829
+ bottom: {
1830
+ left: clampX(align === "end" ? anchor.right - width : (anchor.left + anchor.right - width) / 2),
1831
+ top: anchor.bottom + gap
1832
+ },
1833
+ top: {
1834
+ left: clampX(align === "end" ? anchor.right - width : (anchor.left + anchor.right - width) / 2),
1835
+ top: anchor.top - gap - height
1836
+ }
1837
+ };
1838
+ for (const candidate of candidates) {
1839
+ const position = positions[candidate];
1840
+ if (position.left >= margin && position.top >= margin && position.left + width <= viewportWidth - margin && position.top + height <= viewportHeight - margin) return {
1841
+ ...position,
1842
+ side: candidate,
1843
+ width,
1844
+ height,
1845
+ overflow: false
1846
+ };
1847
+ }
1848
+ const position = positions[side];
1849
+ return {
1850
+ left: clampX(position.left),
1851
+ top: clampY(position.top),
1852
+ side,
1853
+ width,
1854
+ height,
1855
+ overflow: true
1856
+ };
1704
1857
  }
1705
- function isLabel(entry) {
1706
- return "type" in entry && entry.type === "label";
1858
+ //#endregion
1859
+ //#region lib/types/useDismissOnOutsidePointer.js
1860
+ /**
1861
+ * Outside-pointer dismissal for trigger-owned popovers (jobs list, Cordis
1862
+ * panel): while the surface is open, a pointerdown outside the root closes it.
1863
+ */
1864
+ /**
1865
+ * Close an open popover when a pointerdown lands outside its root element.
1866
+ * @param root - element containing both the trigger and the open surface.
1867
+ * @param open - whether the surface is showing; false detaches the listener.
1868
+ * @param setOpen - state setter invoked with false on an outside pointerdown.
1869
+ * @param portal - surface portaled outside the root (a `document.body` dialog)
1870
+ * that also counts as inside; omit when the root contains the whole popover.
1871
+ */
1872
+ function useDismissOnOutsidePointer(root, open, setOpen, portal) {
1873
+ useEffect(() => {
1874
+ if (!open) return;
1875
+ const closeOutside = (event) => {
1876
+ if (event.target instanceof Node && root.current?.contains(event.target) !== true && portal?.current?.contains(event.target) !== true) setOpen(false);
1877
+ };
1878
+ document.addEventListener("pointerdown", closeOutside);
1879
+ return () => {
1880
+ document.removeEventListener("pointerdown", closeOutside);
1881
+ };
1882
+ }, [
1883
+ root,
1884
+ open,
1885
+ setOpen,
1886
+ portal
1887
+ ]);
1707
1888
  }
1708
- /** Unplaced portal list: hidden but laid out at a fixed origin so offsetWidth/offsetHeight are real. */
1709
- const MEASURE_STYLE = {
1710
- visibility: "hidden",
1711
- left: 0,
1712
- top: 0
1889
+ //#endregion
1890
+ //#region lib/types/input-modality.js
1891
+ /**
1892
+ * Document-wide input tracking shared by tooltips and focus-ring styles.
1893
+ * Tooltips follow the last input; rings follow navigation or a key followed by
1894
+ * focus on a different control. Modifiers and refocusing alone keep rings silent.
1895
+ * Module-level listeners live for the document lifetime; Node imports are inert.
1896
+ */
1897
+ /** Modality values published on the document element. */
1898
+ const INPUT_MODALITY = {
1899
+ pointer: "pointer",
1900
+ keyboard: "keyboard"
1713
1901
  };
1902
+ /** Attribute carrying whether focus navigation last owned focus. */
1903
+ const INPUT_MODALITY_ATTRIBUTE = "data-input-modality";
1904
+ const FOCUS_NAVIGATION = new Set([
1905
+ "Tab",
1906
+ "Home",
1907
+ "End",
1908
+ "PageUp",
1909
+ "PageDown"
1910
+ ]);
1911
+ let pointer = false;
1912
+ let pointerOwnsFocus = false;
1913
+ let keyFocusOrigin;
1914
+ function publish() {
1915
+ document.documentElement.setAttribute(INPUT_MODALITY_ATTRIBUTE, pointerOwnsFocus ? INPUT_MODALITY.pointer : INPUT_MODALITY.keyboard);
1916
+ }
1714
1917
  /**
1715
- * Render an anchored dropdown menu. While the list is open its keys mirror the
1716
- * composer's: Tab settles the focused row — from the trigger, Tab enters the
1717
- * list instead — and Escape or Shift+Tab close it and return focus to the
1718
- * anchor's first button, and selecting a row does the same — the rows unmount
1719
- * with the list. Only a keyboard on the trigger or inside the list is
1720
- * intercepted; Tab presses elsewhere on the page stay the browser's.
1721
- * @param props.autoFocus - focus the first item on open; the arrow keys walk the list either way.
1722
- * @param props.open - whether the list is showing (owner-controlled).
1723
- * @param props.anchor - the trigger element (rendered in place).
1724
- * @param props.items - selectable data rows and optional separators (default none; with no `children` either, the list is empty).
1725
- * @param props.selectedId - row shown as selected.
1726
- * @param props.selectedIds - rows shown as selected when a menu contains independent option groups.
1727
- * @param props.onSelect - data-row activation callback (not called for disabled rows or submenu parents that only open children).
1728
- * @param props.onClose - invoked on outside click, Escape, or a window blur
1729
- * that moved focus into an iframe (the only signal a pointerdown inside a
1730
- * cross-origin iframe leaves).
1731
- * @param props.align - list alignment against the anchor (default 'start').
1732
- * @param props.side - open below (`bottom`, default) or above (`top`) the anchor.
1733
- * @param props.portal - render the list into document.body, fixed-positioned
1734
- * from the anchor rect (follows movement and resizing while open). Use when an
1735
- * ancestor's overflow clipping would crop the in-place list; default false
1736
- * keeps the pure-CSS in-place behavior.
1737
- * @param props.closeOnPointerLeave - close the list once the pointer has left
1738
- * both trigger and list for the pointer grace (default false keeps it open
1739
- * until outside click/Escape/selection). The grace makes the 4px trigger->list
1740
- * gap and a brief overshoot survivable; coming back cancels the close.
1741
- * @param props.dense - reduce vertical row spacing without changing the standard typography or card width.
1742
- * @param props.compact - use reduced menu typography and spacing.
1743
- * @param props.getAnchorRect - portal mode only: supply the anchor rect
1744
- * directly (e.g. from a host-owned trigger button) instead of measuring the
1745
- * Menu's own wrapper span. Required when the wrapper isn't itself laid out at
1746
- * the trigger (render-prop anchors, effect-positioned proxies — measuring the
1747
- * wrapper there races the host's layout effects). Called on open, each animation
1748
- * frame, and scroll/resize; return null to skip placement for that frame.
1749
- * @param props.minWidthFromAnchor - in portal mode, keep the menu at least as wide as its anchor, bounded by viewport margins.
1750
- * @param props.footer - rows pinned below the scrolling items area, separated
1751
- * by a hairline; they stay visible while the items above scroll.
1752
- * @param props.children - component rows rendered after `items` in the same
1753
- * list, each a `role="menuitem"` button such as {@link MenuItemButton}; they
1754
- * share the keyboard walk, the submenu exclusivity, and the post-selection
1755
- * focus return.
1756
- * @param props.selection - how a selected row is marked: a trailing check
1757
- * (`'check'`, default — figma .Menu_cell) or the hover fill held on the row
1758
- * with no check (`'fill'`, for icon-labelled rows where a trailing glyph
1759
- * crowds the cell).
1760
- * @param props.className - extra class on the anchor wrapper span.
1761
- * @param props.listClassName - extra class on the dropdown card itself; the
1762
- * only style hook that reaches a portaled list, which renders under
1763
- * document.body outside the owner's DOM subtree.
1764
- * @returns anchor wrapper with the conditional list.
1918
+ * Whether the last input came from a pointer, independently of ring visibility.
1919
+ * @returns True after pointer input; false after any key.
1765
1920
  */
1766
- function Menu({ open, anchor, items = [], children, selectedId, selectedIds, onSelect, onClose, align = "start", side = "bottom", portal = false, closeOnPointerLeave = false, dense = false, compact = false, autoFocus = false, selection = "check", getAnchorRect, minWidthFromAnchor = false, footer, className, listClassName }) {
1767
- const rootRef = useRef(null);
1768
- const listRef = useRef(null);
1769
- /** Index the arrow walk last focused, the resume point when focus left the rows. */
1770
- const walkIndex = useRef(null);
1771
- /**
1772
- * The control that had the keyboard when this menu opened — its own trigger,
1773
- * which an anchor that wraps several controls (a split button) would not be
1774
- * able to name by position.
1775
- */
1776
- const triggerRef = useRef(null);
1777
- const selectingWithTab = useRef(false);
1778
- /**
1779
- * Hand the keyboard back to the trigger that opened the menu — or, when the
1780
- * anchor never held it, to the anchor's first button. Focus left on a removed
1781
- * row otherwise falls to the page body, where the next Tab restarts from the
1782
- * top of the page.
1783
- * @param navigation - whether explicit keyboard traversal should retain its focus indicator.
1784
- */
1785
- const refocusAnchor = (navigation = false) => {
1786
- const trigger = triggerRef.current;
1787
- const target = trigger !== null && document.contains(trigger) && !trigger.disabled ? trigger : rootRef.current?.querySelector("button:not(:disabled)");
1788
- if (target == null) return;
1789
- if (navigation) target.focus();
1790
- else focusWithoutRing(target);
1791
- };
1792
- /**
1793
- * Post-selection focus, for the paths where the rows unmount with the list.
1794
- * A selection whose owner keeps the menu open is left alone, and so is an
1795
- * owner that moved focus itself (a presented file card hands it to its
1796
- * preview button): only a keyboard left on the closing list (or on the body
1797
- * its removal produced) comes back to the trigger.
1798
- */
1799
- const refocusAfterSelection = () => {
1800
- const navigation = selectingWithTab.current;
1801
- queueMicrotask(() => {
1802
- if (openRef.current) return;
1803
- const active = document.activeElement;
1804
- if (active === null || active === document.body || listRef.current?.contains(active) === true) refocusAnchor(navigation);
1805
- });
1806
- };
1807
- const openRef = useRef(open);
1808
- openRef.current = open;
1809
- const [openSubmenuId, setOpenSubmenuId] = useState(null);
1810
- const [fixedPos, setFixedPos] = useState(null);
1811
- const { arm: armClose, cancel: cancelClose } = usePointerGrace(onClose);
1812
- useLayoutEffect(() => {
1813
- if (!open || !portal) {
1814
- setFixedPos(null);
1921
+ function pointerModality() {
1922
+ return pointer;
1923
+ }
1924
+ if (typeof window !== "undefined") {
1925
+ window.addEventListener("pointerdown", () => {
1926
+ pointer = true;
1927
+ pointerOwnsFocus = true;
1928
+ keyFocusOrigin = void 0;
1929
+ publish();
1930
+ }, true);
1931
+ window.addEventListener("keydown", (event) => {
1932
+ pointer = false;
1933
+ if (event.isComposing) {
1934
+ keyFocusOrigin = void 0;
1815
1935
  return;
1816
1936
  }
1817
- const place = () => {
1818
- let r;
1819
- if (getAnchorRect !== void 0) r = getAnchorRect();
1820
- else
1821
- /* v8 ignore next 2 -- the ref is attached before the layout effect runs and the listeners die with it. */
1822
- r = rootRef.current?.getBoundingClientRect() ?? null;
1823
- if (r === null) return;
1824
- const MARGIN = 12;
1825
- const GAP = 4;
1826
- const vw = window.innerWidth;
1827
- const vh = window.innerHeight;
1828
- const listEl = listRef.current;
1829
- if (listEl !== null) {
1830
- const minimum = minWidthFromAnchor ? `${Math.min(r.width, Math.max(0, vw - MARGIN * 2))}px` : "";
1831
- if (listEl.style.minWidth !== minimum) listEl.style.minWidth = minimum;
1832
- }
1833
- const lw = listEl?.offsetWidth ?? 0;
1834
- const lh = listEl?.offsetHeight ?? 0;
1835
- let x;
1836
- let y;
1837
- if (side === "right") {
1838
- x = r.right + GAP;
1839
- y = r.top;
1840
- } else if (align === "start") {
1841
- x = r.left;
1842
- y = side === "bottom" ? r.bottom + GAP : r.top - lh - GAP;
1843
- } else {
1844
- x = r.right - lw;
1845
- y = side === "bottom" ? r.bottom + GAP : r.top - lh - GAP;
1846
- }
1847
- if (lw > 0) x = Math.min(Math.max(x, MARGIN), vw - lw - MARGIN);
1848
- if (lh > 0) y = Math.min(Math.max(y, overlayTopMargin(MARGIN, r, GAP)), vh - lh - MARGIN);
1849
- setFixedPos((current) => current?.left === x && current.top === y ? current : {
1850
- left: x,
1851
- top: y
1937
+ keyFocusOrigin = event.composedPath()[0];
1938
+ if (!FOCUS_NAVIGATION.has(event.key) && !event.key.startsWith("Arrow")) return;
1939
+ pointerOwnsFocus = false;
1940
+ publish();
1941
+ }, true);
1942
+ window.addEventListener("focusin", (event) => {
1943
+ if (keyFocusOrigin === void 0 || event.composedPath()[0] === keyFocusOrigin) return;
1944
+ keyFocusOrigin = void 0;
1945
+ if (!pointerOwnsFocus) return;
1946
+ pointerOwnsFocus = false;
1947
+ publish();
1948
+ }, true);
1949
+ window.addEventListener("blur", () => {
1950
+ keyFocusOrigin = void 0;
1951
+ });
1952
+ }
1953
+ //#endregion
1954
+ //#region lib/types/Tooltip.js
1955
+ /** Anchor-preserving tooltips; an optional body portal escapes clipping containers and stacking contexts that cap the bubble's z-index. */
1956
+ /**
1957
+ * Suppression channel for nested tooltips: a visible descendant tooltip
1958
+ * withdraws the enclosing tooltip while its bubble is shown.
1959
+ */
1960
+ const TooltipSuppression = createContext(null);
1961
+ function clipped(anchor) {
1962
+ return [anchor, ...anchor.querySelectorAll("*")].some((el) => el instanceof HTMLElement && el.scrollWidth > el.clientWidth);
1963
+ }
1964
+ /**
1965
+ * Attach a hover/focus tooltip to an anchor element.
1966
+ * @param props.label - bubble text, or a resolver evaluated only while visible; an empty string shows only shortcut keys.
1967
+ * @param props.shortcutKeys - effective key labels rendered as platform-formatted keycaps after optional text.
1968
+ * @param props.side - preferred placement (default 'right'); fitting tries the opposite then perpendicular sides.
1969
+ * @param props.align - horizontal anchor-edge alignment for 'bottom'/'top' bubbles: 'end' pins
1970
+ * the bubble's right edge to the anchor's (for anchors beside other hover surfaces the centered
1971
+ * bubble would overlap); default 'center'. Horizontal placements ignore it.
1972
+ * @param props.portal - render the bubble under document.body, so an ancestor's clipping or its
1973
+ * stacking context (which confines the bubble's z-index to that context) cannot hide it.
1974
+ * @param props.delayMs - hover delay in milliseconds (default 0).
1975
+ * @param props.focusDelayMs - keyboard focus delay in milliseconds (default 0); blur, click,
1976
+ * mouse leave, disabling, and unmount cancel a pending show.
1977
+ * @param props.gap - anchor-to-bubble distance in pixels for 'bottom'/'top' bubbles (default 8);
1978
+ * horizontal placements use 10px, including after a flip.
1979
+ * @param props.disabled - suppress the bubble while true; the anchor renders identically so
1980
+ * toggling never remounts it (which would cut its CSS transitions).
1981
+ * @param props.maxWidth - bubble width cap in pixels, for labels long enough that the default
1982
+ * half-viewport cap would render a slab wider than the surface the anchor sits on; always bounded by viewport margins.
1983
+ * @param props.openOnClick - clicking or tapping also pins the bubble for reading; another click, Escape,
1984
+ * Tab, or an outside pointerdown dismisses it. Defaults to false for ordinary action tooltips.
1985
+ * @param props.onlyWhenClipped - show the bubble only when the anchor or an HTML element inside it
1986
+ * overflows horizontally, measured when the bubble is about to show; for labels that repeat
1987
+ * text an ellipsis may cut off. Defaults to false.
1988
+ * @param props.children - a single anchor element; its own ref (callback or object) is forwarded alongside the tooltip's.
1989
+ * @returns the cloned anchor plus a fixed-position bubble, optionally portaled to the body.
1990
+ * The bubble stays hidden until ResizeObserver supplies its size for viewport fitting; clicking the
1991
+ * anchor dismisses the bubble unless openOnClick is enabled, and focus arriving after a pointer
1992
+ * interaction (a closing menu refocusing its trigger) never raises it. Touch cannot trigger hover
1993
+ * tooltips; tapping still invokes the child's action and can open an openOnClick explanation.
1994
+ * When no side fits, the viewport-bounded fallback may overlap the anchor; oversized content is scrollable when pinned.
1995
+ */
1996
+ function Tooltip({ label, shortcutKeys, side = "right", align = "center", delayMs = 0, focusDelayMs = 0, gap = 8, disabled = false, portal = false, maxWidth, openOnClick = false, onlyWhenClipped = false, children }) {
1997
+ const id = useId();
1998
+ const [pinned, setPinned] = useState(false);
1999
+ const anchor = useRef(null);
2000
+ const childRef = children.ref;
2001
+ const mergedRef = useCallback((el) => {
2002
+ anchor.current = el;
2003
+ if (typeof childRef === "function") childRef(el);
2004
+ else if (childRef != null) childRef.current = el;
2005
+ }, [childRef]);
2006
+ const [pos, setPos] = useState(null);
2007
+ const bubble = useRef(null);
2008
+ const resolvedLabel = pos === null ? null : typeof label === "function" ? label() : label;
2009
+ const showTimer = useRef(null);
2010
+ const triggers = useRef({
2011
+ hover: false,
2012
+ focus: false
2013
+ });
2014
+ const suppressAncestors = useContext(TooltipSuppression);
2015
+ const [suppressed, setSuppressed] = useState(false);
2016
+ const announce = useCallback((active) => {
2017
+ suppressAncestors?.(active);
2018
+ }, [suppressAncestors]);
2019
+ const visible = pos !== null && !disabled;
2020
+ useEffect(() => {
2021
+ const el = bubble.current;
2022
+ if (pos === null || !visible || suppressed || el === null) return;
2023
+ let size;
2024
+ let anchorRect = pos;
2025
+ const fit = () => {
2026
+ if (size === void 0) return;
2027
+ const placement = placeTooltip({
2028
+ anchor: anchorRect,
2029
+ width: size.inlineSize,
2030
+ height: size.blockSize,
2031
+ viewportWidth: window.innerWidth,
2032
+ viewportHeight: window.innerHeight,
2033
+ side,
2034
+ align,
2035
+ gap
1852
2036
  });
2037
+ const horizontal = placement.side === "right" || placement.side === "left";
2038
+ const offsetX = horizontal ? 0 : align === "end" ? placement.width : placement.width / 2;
2039
+ const offsetY = horizontal ? placement.height / 2 : placement.side === "top" ? placement.height : 0;
2040
+ el.style.left = `${placement.left + offsetX}px`;
2041
+ el.style.top = `${placement.top + offsetY}px`;
2042
+ el.dataset.side = placement.side;
2043
+ el.style.visibility = "visible";
1853
2044
  };
1854
- place();
1855
- const track = () => {
1856
- place();
1857
- frame = requestAnimationFrame(track);
2045
+ const onResize = () => {
2046
+ if (anchor.current !== null) anchorRect = anchor.current.getBoundingClientRect();
2047
+ fit();
1858
2048
  };
1859
- let frame = requestAnimationFrame(track);
1860
- window.addEventListener("scroll", place, true);
1861
- window.addEventListener("resize", place);
2049
+ const observer = new ResizeObserver((entries) => {
2050
+ size = entries[0]?.borderBoxSize[0];
2051
+ fit();
2052
+ });
2053
+ observer.observe(el, { box: "border-box" });
2054
+ window.addEventListener("resize", onResize);
1862
2055
  return () => {
1863
- cancelAnimationFrame(frame);
1864
- window.removeEventListener("scroll", place, true);
1865
- window.removeEventListener("resize", place);
2056
+ observer.disconnect();
2057
+ window.removeEventListener("resize", onResize);
1866
2058
  };
1867
2059
  }, [
1868
- open,
1869
- portal,
1870
2060
  align,
2061
+ gap,
2062
+ pos,
1871
2063
  side,
1872
- getAnchorRect,
1873
- minWidthFromAnchor
2064
+ suppressed,
2065
+ visible
1874
2066
  ]);
1875
2067
  useEffect(() => {
1876
- if (!open) {
1877
- triggerRef.current = null;
1878
- return;
1879
- }
1880
- const active = document.activeElement;
1881
- triggerRef.current = active instanceof HTMLElement && rootRef.current?.contains(active) === true ? active : null;
1882
- }, [open]);
1883
- useEffect(() => {
1884
- if (!open || !autoFocus) return;
1885
- const first = listRef.current?.querySelector("button:not(:disabled)");
1886
- walkIndex.current = first === void 0 || first === null ? null : 0;
1887
- if (first != null) focusWithoutRing(first);
1888
- }, [open, autoFocus]);
2068
+ announce(visible);
2069
+ return () => {
2070
+ announce(false);
2071
+ };
2072
+ }, [announce, visible]);
2073
+ const cancelShow = useCallback(() => {
2074
+ if (showTimer.current === null) return;
2075
+ clearTimeout(showTimer.current);
2076
+ showTimer.current = null;
2077
+ }, []);
1889
2078
  useEffect(() => {
1890
- if (!open) {
1891
- setOpenSubmenuId(null);
1892
- walkIndex.current = null;
2079
+ if (pinned && (disabled || !openOnClick)) setPinned(false);
2080
+ if (disabled) {
2081
+ cancelShow();
2082
+ triggers.current = {
2083
+ hover: false,
2084
+ focus: false
2085
+ };
2086
+ setPos(null);
2087
+ }
2088
+ return cancelShow;
2089
+ }, [
2090
+ cancelShow,
2091
+ disabled,
2092
+ openOnClick,
2093
+ pinned
2094
+ ]);
2095
+ const show = () => {
2096
+ if (disabled) return;
2097
+ const el = anchor.current;
2098
+ /* v8 ignore next -- the ref is attached by event time: events fire on the cloned anchor. */
2099
+ if (el === null) return;
2100
+ if (onlyWhenClipped && !clipped(el)) return;
2101
+ setPos(el.getBoundingClientRect());
2102
+ announce(true);
2103
+ };
2104
+ const showAfterDelay = (delay) => {
2105
+ cancelShow();
2106
+ if (delay <= 0) {
2107
+ show();
1893
2108
  return;
1894
2109
  }
1895
- const composition = observeComposition(document);
1896
- const onPointerDown = (e) => {
1897
- if (!(e.target instanceof Node)) return;
1898
- if (rootRef.current?.contains(e.target) === true) return;
1899
- if (listRef.current?.contains(e.target) === true) return;
1900
- onClose();
2110
+ showTimer.current = setTimeout(() => {
2111
+ showTimer.current = null;
2112
+ show();
2113
+ }, delay);
2114
+ };
2115
+ const withdraw = useCallback(() => {
2116
+ setPinned(false);
2117
+ setPos(null);
2118
+ announce(false);
2119
+ }, [announce]);
2120
+ const hide = () => {
2121
+ cancelShow();
2122
+ if (!triggers.current.hover && !triggers.current.focus && !pinned) withdraw();
2123
+ };
2124
+ const dismiss = useCallback(() => {
2125
+ cancelShow();
2126
+ triggers.current = {
2127
+ hover: false,
2128
+ focus: false
1901
2129
  };
1902
- const onKeyDown = (e) => {
1903
- if (composition.guards(e) || isBehindModal(rootRef.current) || e.defaultPrevented || e.ctrlKey || e.altKey || e.metaKey) return;
1904
- const focused = document.activeElement;
1905
- const insideList = listRef.current?.contains(focused) === true;
1906
- const anchored = rootRef.current?.contains(focused) === true || insideList;
1907
- if (e.key === "Escape" && !e.shiftKey) {
1908
- e.preventDefault();
1909
- if (e.repeat) return;
1910
- onClose();
1911
- if (anchored || autoFocus) refocusAnchor();
1912
- }
1913
- if (e.key === "Tab") {
1914
- const list = listRef.current;
1915
- if (list === null || !anchored) return;
1916
- if (e.shiftKey) {
1917
- e.preventDefault();
1918
- onClose();
1919
- refocusAnchor(true);
1920
- return;
1921
- }
1922
- if (insideList) {
1923
- if (focused instanceof Element && focused.getAttribute("role") === "menuitem") {
1924
- e.preventDefault();
1925
- selectingWithTab.current = true;
1926
- try {
1927
- focused.click();
1928
- } finally {
1929
- selectingWithTab.current = false;
1930
- }
1931
- }
1932
- return;
1933
- }
1934
- const row = list.querySelector("button:not(:disabled)");
1935
- if (row === null) return;
1936
- e.preventDefault();
1937
- row.focus();
1938
- walkIndex.current = 0;
1939
- return;
2130
+ withdraw();
2131
+ }, [cancelShow, withdraw]);
2132
+ useDismissOnOutsidePointer(anchor, openOnClick && visible, dismiss, bubble);
2133
+ useEffect(() => {
2134
+ if (!openOnClick || !visible) return;
2135
+ const onKeyDown = (event) => {
2136
+ if (event.key !== "Escape" && event.key !== "Tab") return;
2137
+ if (event.key === "Escape") {
2138
+ event.preventDefault();
2139
+ event.stopPropagation();
1940
2140
  }
1941
- if (![
1942
- "ArrowDown",
1943
- "ArrowUp",
1944
- "Home",
1945
- "End"
1946
- ].includes(e.key)) return;
1947
- const list = listRef.current;
1948
- if (list === null || !anchored) return;
1949
- const buttons = Array.from(list.querySelectorAll("button:not(:disabled)"));
1950
- if (buttons.length === 0) return;
1951
- const index = buttons.indexOf(focused);
1952
- const from = index >= 0 ? index : walkIndex.current;
1953
- const next = e.key === "Home" ? 0 : e.key === "End" ? buttons.length - 1 : from === null ? e.key === "ArrowDown" ? 0 : buttons.length - 1 : (from + (e.key === "ArrowDown" ? 1 : -1) + buttons.length) % buttons.length;
1954
- e.preventDefault();
1955
- walkIndex.current = next;
1956
- buttons[next]?.focus();
1957
- };
1958
- const onWindowBlur = () => {
1959
- if (document.activeElement instanceof HTMLIFrameElement) onClose();
1960
- };
1961
- document.addEventListener("pointerdown", onPointerDown);
1962
- const onEscape = (event) => {
1963
- if (event.key === "Escape") onKeyDown(event);
1964
- };
1965
- const onOtherKey = (event) => {
1966
- if (event.key !== "Escape") onKeyDown(event);
2141
+ dismiss();
1967
2142
  };
1968
- document.addEventListener("keydown", onOtherKey);
1969
- document.addEventListener("keydown", onEscape, true);
1970
- window.addEventListener("blur", onWindowBlur);
2143
+ document.addEventListener("keydown", onKeyDown, true);
1971
2144
  return () => {
1972
- composition.dispose();
1973
- document.removeEventListener("pointerdown", onPointerDown);
1974
- document.removeEventListener("keydown", onOtherKey);
1975
- document.removeEventListener("keydown", onEscape, true);
1976
- window.removeEventListener("blur", onWindowBlur);
2145
+ document.removeEventListener("keydown", onKeyDown, true);
1977
2146
  };
1978
2147
  }, [
1979
- open,
1980
- onClose,
1981
- autoFocus
2148
+ dismiss,
2149
+ openOnClick,
2150
+ visible
1982
2151
  ]);
1983
- useEffect(() => {
1984
- if (!open) cancelClose();
1985
- }, [open, cancelClose]);
1986
- const scrollable = !items.some((entry) => !isSeparator(entry) && !isLabel(entry) && entry.submenu !== void 0 && entry.submenu.length > 0);
1987
- const renderEntry = (entry) => {
1988
- if (isSeparator(entry)) return jsx("div", {
1989
- className: css$9.separator,
1990
- role: "separator"
1991
- }, entry.id);
1992
- if (isLabel(entry)) return jsx("div", {
2152
+ const content = visible && !suppressed && jsxs("span", {
2153
+ ref: bubble,
2154
+ id: openOnClick ? id : void 0,
2155
+ className: css$9.bubble,
2156
+ "data-side": side,
2157
+ "data-portal": portal || void 0,
2158
+ "data-pinned": pinned || void 0,
2159
+ "data-align": align,
2160
+ "data-has-shortcut": shortcutKeys?.length ? true : void 0,
2161
+ style: {
2162
+ left: pos.left,
2163
+ top: pos.top,
2164
+ visibility: "hidden",
2165
+ ...maxWidth === void 0 ? {} : { maxWidth: `min(${maxWidth}px, calc(100vw - 24px))` }
2166
+ },
2167
+ role: "tooltip",
2168
+ "aria-label": shortcutKeys?.length ? [resolvedLabel, shortcutKeys.join(" ")].filter(Boolean).join(" ") : void 0,
2169
+ children: [resolvedLabel && jsx("span", {
1993
2170
  className: css$9.label,
1994
- role: "presentation",
1995
- children: entry.text
1996
- }, entry.id);
1997
- const hasSub = entry.submenu !== void 0 && entry.submenu.length > 0;
1998
- const subOpen = hasSub && openSubmenuId === entry.id;
1999
- const selected = entry.id === selectedId || selectedIds?.includes(entry.id) === true;
2000
- return jsxs("div", {
2001
- className: css$9.itemWrap,
2002
- onMouseEnter: hasSub ? () => {
2003
- setOpenSubmenuId(entry.id);
2004
- } : void 0,
2005
- onMouseLeave: () => {
2006
- setOpenSubmenuId(null);
2171
+ children: resolvedLabel
2172
+ }), shortcutKeys !== void 0 && shortcutKeys.length > 0 && jsx(ShortcutKeys, {
2173
+ keys: shortcutKeys,
2174
+ variant: "tooltip"
2175
+ })]
2176
+ });
2177
+ return jsxs(TooltipSuppression.Provider, {
2178
+ value: setSuppressed,
2179
+ children: [cloneElement(children, {
2180
+ ref: mergedRef,
2181
+ "aria-describedby": openOnClick && visible ? [children.props["aria-describedby"], id].filter(Boolean).join(" ") : children.props["aria-describedby"],
2182
+ onPointerEnter: (e) => {
2183
+ children.props.onPointerEnter?.(e);
2184
+ if (e.pointerType === "touch") return;
2185
+ if (e.pointerType === "mouse" && !window.matchMedia("(any-hover: hover)").matches) return;
2186
+ triggers.current.hover = true;
2187
+ showAfterDelay(delayMs);
2007
2188
  },
2008
- children: [jsxs("button", {
2009
- type: "button",
2010
- role: "menuitem",
2011
- className: clsx(css$9.item, selected && (selection === "fill" ? css$9.selectedFill : css$9.selected), entry.danger === true && css$9.danger),
2012
- disabled: entry.disabled,
2013
- "aria-keyshortcuts": entry.shortcut?.aria,
2014
- "aria-haspopup": hasSub ? "menu" : void 0,
2015
- "aria-expanded": hasSub ? subOpen : void 0,
2016
- onFocus: hasSub ? () => {
2017
- setOpenSubmenuId(entry.id);
2018
- } : void 0,
2019
- onClick: () => {
2020
- if (hasSub) {
2021
- setOpenSubmenuId(entry.id);
2022
- return;
2023
- }
2024
- onSelect?.(entry.id);
2025
- },
2026
- children: [
2027
- entry.icon !== void 0 && jsx("span", {
2028
- className: css$9.itemIcon,
2029
- children: entry.icon
2030
- }),
2031
- jsx("span", {
2032
- className: css$9.itemLabel,
2033
- children: entry.label
2034
- }),
2035
- entry.shortcut !== void 0 && jsx("span", {
2036
- "aria-hidden": "true",
2037
- className: css$9.shortcut,
2038
- children: jsx(ShortcutKeys, {
2039
- keys: entry.shortcut.keys,
2040
- className: css$9.shortcutKeys
2041
- })
2042
- }),
2043
- selected && selection === "check" && jsx(IconCheckOutlineRegular, { className: css$9.check })
2044
- ]
2045
- }), subOpen && entry.submenu !== void 0 && jsx(MenuSurface, {
2046
- compact,
2047
- className: clsx(css$9.submenu, compact && css$9.compactList),
2048
- role: "menu",
2049
- children: entry.submenu.map((sub) => jsxs("button", {
2189
+ onPointerLeave: (e) => {
2190
+ children.props.onPointerLeave?.(e);
2191
+ triggers.current.hover = false;
2192
+ cancelShow();
2193
+ if (!pinned) withdraw();
2194
+ },
2195
+ onPointerDown: (e) => {
2196
+ children.props.onPointerDown?.(e);
2197
+ if (e.pointerType === "touch" && !pinned) dismiss();
2198
+ },
2199
+ onClick: (e) => {
2200
+ children.props.onClick?.(e);
2201
+ triggers.current.focus = false;
2202
+ cancelShow();
2203
+ if (openOnClick && !disabled && !pinned) {
2204
+ setPinned(true);
2205
+ show();
2206
+ } else withdraw();
2207
+ },
2208
+ onFocus: (e) => {
2209
+ children.props.onFocus?.(e);
2210
+ if (pointerModality()) return;
2211
+ triggers.current.focus = true;
2212
+ showAfterDelay(focusDelayMs);
2213
+ },
2214
+ onBlur: (e) => {
2215
+ children.props.onBlur?.(e);
2216
+ triggers.current.focus = false;
2217
+ hide();
2218
+ }
2219
+ }), portal ? content !== false && createPortal(content, document.body) : content]
2220
+ });
2221
+ }
2222
+ //#endregion
2223
+ //#region lib/types/Menu.js
2224
+ /**
2225
+ * Render one `role="menuitem"` row for a {@link Menu} whose rows are
2226
+ * components rather than `items` data: the same markup and styling as a data
2227
+ * row, so it joins the list's keyboard walk and post-selection focus return
2228
+ * without any shared state. Closing the menu stays the owner's decision, as
2229
+ * it is for data rows.
2230
+ * @param props.children - visible row label.
2231
+ * @param props.shortcut - effective key labels and accessible combination.
2232
+ * @param props.icon - optional leading icon.
2233
+ * @param props.current - whether the row identifies the currently displayed page or view.
2234
+ * @param props.disabled - whether the row cannot be activated.
2235
+ * @param props.disabledReason - why a disabled row cannot be activated, shown in a tooltip and read as its description.
2236
+ * @param props.danger - whether to use the destructive row colors.
2237
+ * @param props.separatorBefore - whether this row starts a new group (hairline above it).
2238
+ * @param props.onSelect - row activation callback.
2239
+ * @returns one menu-item row.
2240
+ */
2241
+ function MenuItemButton({ children, shortcut, icon, current, disabled = false, disabledReason, danger = false, separatorBefore = false, onSelect }) {
2242
+ const reasonId = useId();
2243
+ const explained = disabled && disabledReason !== void 0;
2244
+ return jsxs("div", {
2245
+ className: css$10.itemWrap,
2246
+ children: [
2247
+ separatorBefore && jsx("div", {
2248
+ className: css$10.separator,
2249
+ role: "separator"
2250
+ }),
2251
+ jsx(Tooltip, {
2252
+ label: disabledReason ?? "",
2253
+ disabled: !explained,
2254
+ side: "bottom",
2255
+ delayMs: 500,
2256
+ maxWidth: 300,
2257
+ portal: true,
2258
+ children: jsxs("button", {
2050
2259
  type: "button",
2051
2260
  role: "menuitem",
2052
- className: css$9.item,
2053
- disabled: sub.disabled,
2054
- "aria-keyshortcuts": sub.shortcut?.aria,
2055
- onClick: () => {
2056
- onSelect?.(sub.id);
2057
- refocusAfterSelection();
2058
- },
2261
+ className: clsx(css$10.item, danger && css$10.danger),
2262
+ disabled: disabled && !explained,
2263
+ "aria-disabled": explained || void 0,
2264
+ "aria-describedby": explained ? reasonId : void 0,
2265
+ "aria-keyshortcuts": shortcut?.aria,
2266
+ "aria-current": current === true ? "page" : void 0,
2267
+ onClick: explained ? void 0 : onSelect,
2059
2268
  children: [
2060
- sub.icon !== void 0 && jsx("span", {
2061
- className: css$9.itemIcon,
2062
- children: sub.icon
2269
+ icon !== void 0 && jsx("span", {
2270
+ className: css$10.itemIcon,
2271
+ children: icon
2063
2272
  }),
2064
2273
  jsx("span", {
2065
- className: css$9.itemLabel,
2066
- children: sub.label
2274
+ className: css$10.itemLabel,
2275
+ children
2067
2276
  }),
2068
- sub.shortcut !== void 0 && jsx("span", {
2277
+ shortcut !== void 0 && jsx("span", {
2069
2278
  "aria-hidden": "true",
2070
- className: css$9.shortcut,
2279
+ className: css$10.shortcut,
2071
2280
  children: jsx(ShortcutKeys, {
2072
- keys: sub.shortcut.keys,
2073
- className: css$9.shortcutKeys
2281
+ keys: shortcut.keys,
2282
+ className: css$10.shortcutKeys
2074
2283
  })
2075
2284
  })
2076
2285
  ]
2077
- }, sub.id))
2078
- })]
2079
- }, entry.id);
2286
+ })
2287
+ }),
2288
+ explained && jsx("span", {
2289
+ id: reasonId,
2290
+ hidden: true,
2291
+ children: disabledReason
2292
+ })
2293
+ ]
2294
+ });
2295
+ }
2296
+ function isSeparator(entry) {
2297
+ return "type" in entry && entry.type === "separator";
2298
+ }
2299
+ function isLabel(entry) {
2300
+ return "type" in entry && entry.type === "label";
2301
+ }
2302
+ /** Mark icon columns within each separator-delimited data group. */
2303
+ function iconColumns(entries, contextual) {
2304
+ const aligned = /* @__PURE__ */ new Set();
2305
+ if (!contextual) return aligned;
2306
+ let group = [];
2307
+ const finish = () => {
2308
+ if (group.some((entry) => !isLabel(entry) && !isSeparator(entry) && entry.icon !== void 0)) for (const entry of group) aligned.add(entry);
2309
+ group = [];
2080
2310
  };
2081
- const collapseSubmenuFrom = (e) => {
2082
- const row = e.target instanceof Element ? e.target.closest("button[role=\"menuitem\"]") : null;
2083
- if (row === null || row.getAttribute("aria-haspopup") === "menu") return;
2084
- if (row.closest("[role=\"menu\"]") !== e.currentTarget) return;
2085
- setOpenSubmenuId(null);
2086
- };
2087
- const list = open && jsxs(MenuSurface, {
2088
- compact,
2089
- ref: listRef,
2090
- className: clsx(css$9.list, listClassName, dense && css$9.denseList, compact && css$9.compactList, scrollable && css$9.scrollable, portal && css$9.portal, side === "top" && !portal && css$9.sideTop, align === "end" && !portal && css$9.alignEnd),
2091
- style: portal ? fixedPos ?? MEASURE_STYLE : void 0,
2092
- role: "menu",
2093
- onClick: (e) => {
2094
- e.stopPropagation();
2095
- const row = e.target instanceof Element ? e.target.closest("button[role=\"menuitem\"]") : null;
2096
- if (row !== null && row.getAttribute("aria-haspopup") !== "menu") refocusAfterSelection();
2097
- },
2098
- onMouseOver: collapseSubmenuFrom,
2099
- onFocus: collapseSubmenuFrom,
2100
- children: [jsxs("div", {
2101
- className: css$9.viewport,
2102
- role: "presentation",
2103
- children: [items.map(renderEntry), children]
2104
- }), footer !== void 0 && footer.length > 0 && jsx("div", {
2105
- className: css$9.footer,
2106
- role: "presentation",
2107
- children: footer.map(renderEntry)
2108
- })]
2109
- });
2110
- return jsxs("span", {
2111
- ref: rootRef,
2112
- className: clsx(css$9.root, className),
2113
- onPointerEnter: closeOnPointerLeave ? cancelClose : void 0,
2114
- onPointerLeave: closeOnPointerLeave ? () => {
2115
- if (open) armClose();
2116
- } : void 0,
2117
- children: [anchor, portal ? list !== false && createPortal(list, document.body) : list]
2118
- });
2311
+ for (const entry of entries) if (isSeparator(entry)) finish();
2312
+ else group.push(entry);
2313
+ finish();
2314
+ return aligned;
2119
2315
  }
2120
- //#endregion
2121
- //#region lib/types/tooltip-placement.js
2122
- const opposite = {
2123
- right: "left",
2124
- left: "right",
2125
- top: "bottom",
2126
- bottom: "top"
2316
+ /** Unplaced portal list: hidden but laid out at a fixed origin so offsetWidth/offsetHeight are real. */
2317
+ const MEASURE_STYLE = {
2318
+ visibility: "hidden",
2319
+ left: 0,
2320
+ top: 0
2127
2321
  };
2128
2322
  /**
2129
- * Prefer the requested side, its opposite, then perpendicular sides without covering the anchor.
2130
- * @param input - Observed dimensions, anchor edges, viewport and requested placement; horizontal gaps remain 10px.
2131
- * @returns Border-box coordinates and the selected side; if no side fits, a viewport-bounded fallback.
2323
+ * Render an anchored dropdown menu. While the list is open its keys mirror the
2324
+ * composer's: Tab settles the focused row — from the trigger, Tab enters the
2325
+ * list instead — and Escape or Shift+Tab close it and return focus to the
2326
+ * anchor's first button, and selecting a row does the same — the rows unmount
2327
+ * with the list. Only a keyboard on the trigger or inside the list is
2328
+ * intercepted; Tab presses elsewhere on the page stay the browser's.
2329
+ * @param props.contextual - cursor positioning, context dismissal, and per-divider icon alignment.
2330
+ * @param props.exiting - retain an inert popup during dismissal or replacement fade.
2331
+ * @param props.returnFocus - original control captured before asynchronous menu preparation.
2332
+ * @param props.autoFocus - focus the first item on open; the arrow keys walk the list either way.
2333
+ * @param props.open - whether the list is showing (owner-controlled).
2334
+ * @param props.anchor - the trigger element (rendered in place).
2335
+ * @param props.items - selectable data rows and optional separators (default none; with no `children` either, the list is empty).
2336
+ * @param props.selectedId - row shown as selected.
2337
+ * @param props.selectedIds - rows shown as selected when a menu contains independent option groups.
2338
+ * @param props.onSelect - data-row activation callback (not called for disabled rows or submenu parents that only open children).
2339
+ * @param props.onClose - invoked on outside click, Escape, or a window blur
2340
+ * that moved focus into an iframe (the only signal a pointerdown inside a
2341
+ * cross-origin iframe leaves).
2342
+ * @param props.align - list alignment against the anchor (default 'start').
2343
+ * @param props.side - open below (`bottom`, default) or above (`top`) the anchor.
2344
+ * @param props.portal - render the list into document.body, fixed-positioned
2345
+ * synchronously (follows movement, resizing, and browser zoom while open)
2346
+ * and clamped inside the visual viewport. Use when an ancestor's overflow clipping would crop the
2347
+ * in-place list; default false keeps the pure-CSS in-place behavior.
2348
+ * @param props.closeOnPointerLeave - close the list once the pointer has left
2349
+ * both trigger and list for the pointer grace (default false keeps it open
2350
+ * until outside click/Escape/selection). The grace makes the 4px trigger->list
2351
+ * gap and a brief overshoot survivable; coming back cancels the close.
2352
+ * @param props.dense - reduce vertical row spacing without changing the standard typography or card width.
2353
+ * @param props.compact - use reduced menu typography and spacing.
2354
+ * @param props.getAnchorRect - portal mode only: supply the anchor rect
2355
+ * directly (e.g. from a host-owned trigger button) instead of measuring the
2356
+ * Menu's own wrapper span. Required when the wrapper isn't itself laid out at
2357
+ * the trigger (render-prop anchors, effect-positioned proxies — measuring the
2358
+ * wrapper there races the host's layout effects). Called while tracking the
2359
+ * anchor and on scroll/resize; return null to defer placement.
2360
+ * @param props.minWidthFromAnchor - in portal mode, keep the menu at least as wide as its anchor, bounded by viewport margins.
2361
+ * @param props.footer - rows pinned below the scrolling items area, separated
2362
+ * by a hairline; contextual menus reuse an explicit leading separator. These rows stay visible while the items above scroll.
2363
+ * @param props.children - component rows rendered after `items` in the same
2364
+ * list, each a `role="menuitem"` button such as {@link MenuItemButton}; they
2365
+ * share the keyboard walk, the submenu exclusivity, and the post-selection
2366
+ * focus return.
2367
+ * @param props.selection - how a selected row is marked: a trailing check
2368
+ * (`'check'`, default — figma .Menu_cell) or the hover fill held on the row
2369
+ * with no check (`'fill'`, for icon-labelled rows where a trailing glyph
2370
+ * crowds the cell).
2371
+ * @param props.className - extra class on the anchor wrapper span.
2372
+ * @param props.listClassName - extra class on the dropdown card itself; the
2373
+ * only style hook that reaches a portaled list, which renders under
2374
+ * document.body outside the owner's DOM subtree.
2375
+ * @returns anchor wrapper with the conditional list.
2132
2376
  */
2133
- function placeTooltip(input) {
2134
- const { anchor, viewportWidth, viewportHeight, side, align, gap } = input;
2135
- let { width, height } = input;
2136
- const margin = 12;
2137
- const maxWidth = Math.max(0, viewportWidth - margin * 2);
2138
- const maxHeight = Math.max(0, viewportHeight - margin * 2);
2139
- width = Math.min(width, maxWidth);
2140
- height = Math.min(height, maxHeight);
2141
- const clampX = (x) => Math.max(margin, Math.min(x, viewportWidth - margin - width));
2142
- const clampY = (y) => Math.max(margin, Math.min(y, viewportHeight - margin - height));
2143
- const horizontal = side === "right" || side === "left";
2144
- const candidates = [
2145
- side,
2146
- opposite[side],
2147
- ...horizontal ? ["bottom", "top"] : ["right", "left"]
2148
- ];
2149
- const positions = {
2150
- right: {
2151
- left: anchor.right + 10,
2152
- top: clampY((anchor.top + anchor.bottom - height) / 2)
2153
- },
2154
- left: {
2155
- left: anchor.left - 10 - width,
2156
- top: clampY((anchor.top + anchor.bottom - height) / 2)
2157
- },
2158
- bottom: {
2159
- left: clampX(align === "end" ? anchor.right - width : (anchor.left + anchor.right - width) / 2),
2160
- top: anchor.bottom + gap
2161
- },
2162
- top: {
2163
- left: clampX(align === "end" ? anchor.right - width : (anchor.left + anchor.right - width) / 2),
2164
- top: anchor.top - gap - height
2165
- }
2166
- };
2167
- for (const candidate of candidates) {
2168
- const position = positions[candidate];
2169
- if (position.left >= margin && position.top >= margin && position.left + width <= viewportWidth - margin && position.top + height <= viewportHeight - margin) return {
2170
- ...position,
2171
- side: candidate,
2172
- width,
2173
- height,
2174
- overflow: false
2377
+ function Menu({ open, anchor, items = [], children, selectedId, selectedIds, onSelect, onClose, align = "start", side = "bottom", portal = false, closeOnPointerLeave = false, dense = false, compact = false, autoFocus = false, selection = "check", getAnchorRect, minWidthFromAnchor = false, footer, className, listClassName, contextual = false, exiting, returnFocus }) {
2378
+ const rootRef = useRef(null);
2379
+ const listRef = useRef(null);
2380
+ const menuId = useId();
2381
+ useLayoutEffect(() => {
2382
+ const trigger = returnFocus?.();
2383
+ if (!open || !contextual || trigger == null) return;
2384
+ const previous = trigger.getAttribute("aria-controls");
2385
+ trigger.setAttribute("aria-controls", [previous, menuId].filter(Boolean).join(" "));
2386
+ return () => {
2387
+ if (previous === null) trigger.removeAttribute("aria-controls");
2388
+ else trigger.setAttribute("aria-controls", previous);
2175
2389
  };
2176
- }
2177
- const position = positions[side];
2178
- return {
2179
- left: clampX(position.left),
2180
- top: clampY(position.top),
2181
- side,
2182
- width,
2183
- height,
2184
- overflow: true
2390
+ }, [
2391
+ open,
2392
+ contextual,
2393
+ returnFocus,
2394
+ menuId
2395
+ ]);
2396
+ /** Index the arrow walk last focused, the resume point when focus left the rows. */
2397
+ const walkIndex = useRef(null);
2398
+ /**
2399
+ * The control that had the keyboard when this menu opened — its own trigger,
2400
+ * which an anchor that wraps several controls (a split button) would not be
2401
+ * able to name by position.
2402
+ */
2403
+ const triggerRef = useRef(null);
2404
+ const selectingWithTab = useRef(false);
2405
+ /**
2406
+ * Hand the keyboard back to the trigger that opened the menu — or, when the
2407
+ * anchor never held it, to the anchor's first button. Focus left on a removed
2408
+ * row otherwise falls to the page body, where the next Tab restarts from the
2409
+ * top of the page.
2410
+ * @param navigation - whether explicit keyboard traversal should retain its focus indicator.
2411
+ */
2412
+ const refocusAnchor = (navigation = false) => {
2413
+ const trigger = returnFocus?.() ?? triggerRef.current;
2414
+ const target = trigger !== null && document.contains(trigger) && !trigger.disabled ? trigger : rootRef.current?.querySelector("button:not(:disabled)");
2415
+ if (target == null) return;
2416
+ if (navigation) target.focus();
2417
+ else focusWithoutRing(target);
2185
2418
  };
2186
- }
2187
- //#endregion
2188
- //#region lib/types/useDismissOnOutsidePointer.js
2189
- /**
2190
- * Outside-pointer dismissal for trigger-owned popovers (jobs list, Cordis
2191
- * panel): while the surface is open, a pointerdown outside the root closes it.
2192
- */
2193
- /**
2194
- * Close an open popover when a pointerdown lands outside its root element.
2195
- * @param root - element containing both the trigger and the open surface.
2196
- * @param open - whether the surface is showing; false detaches the listener.
2197
- * @param setOpen - state setter invoked with false on an outside pointerdown.
2198
- * @param portal - surface portaled outside the root (a `document.body` dialog)
2199
- * that also counts as inside; omit when the root contains the whole popover.
2200
- */
2201
- function useDismissOnOutsidePointer(root, open, setOpen, portal) {
2419
+ /**
2420
+ * Post-selection focus, for the paths where the rows unmount with the list.
2421
+ * A selection whose owner keeps the menu open is left alone, and so is an
2422
+ * owner that moved focus itself (a presented file card hands it to its
2423
+ * preview button): only a keyboard left on the closing list (or on the body
2424
+ * its removal produced) comes back to the trigger.
2425
+ */
2426
+ const refocusAfterSelection = () => {
2427
+ const navigation = selectingWithTab.current;
2428
+ queueMicrotask(() => {
2429
+ if (openRef.current && exitingRef.current === void 0) return;
2430
+ const active = document.activeElement;
2431
+ if (active === null || active === document.body || listRef.current?.contains(active) === true) refocusAnchor(navigation);
2432
+ });
2433
+ };
2434
+ const exitingRef = useRef(exiting);
2435
+ exitingRef.current = exiting;
2436
+ const openRef = useRef(open);
2437
+ openRef.current = open;
2438
+ const [openSubmenuId, setOpenSubmenuId] = useState(null);
2439
+ const close = useRef(onClose);
2440
+ close.current = onClose;
2441
+ const lastAnchorRect = useRef(null);
2442
+ const readAnchor = useCallback(() => {
2443
+ if ((returnFocus?.() ?? rootRef.current)?.closest("[inert], [hidden]") != null) {
2444
+ if (exitingRef.current === void 0) close.current();
2445
+ return lastAnchorRect.current;
2446
+ }
2447
+ lastAnchorRect.current = getAnchorRect === void 0 ? rootRef.current?.getBoundingClientRect() ?? null : getAnchorRect();
2448
+ return lastAnchorRect.current;
2449
+ }, [getAnchorRect, returnFocus]);
2450
+ const fixedPos = useAnchoredPosition({
2451
+ open: open && portal,
2452
+ anchorRef: rootRef,
2453
+ panelRef: listRef,
2454
+ side,
2455
+ align,
2456
+ gap: 4,
2457
+ margin: 12,
2458
+ frameClearance: !contextual,
2459
+ minWidthFromAnchor,
2460
+ getAnchorRect: readAnchor
2461
+ });
2462
+ const positioned = !portal || fixedPos !== null;
2463
+ const { arm: armClose, cancel: cancelClose } = usePointerGrace(onClose);
2202
2464
  useEffect(() => {
2203
2465
  if (!open) return;
2204
- const closeOutside = (event) => {
2205
- if (event.target instanceof Node && root.current?.contains(event.target) !== true && portal?.current?.contains(event.target) !== true) setOpen(false);
2206
- };
2207
- document.addEventListener("pointerdown", closeOutside);
2208
- return () => {
2209
- document.removeEventListener("pointerdown", closeOutside);
2210
- };
2466
+ const active = document.activeElement;
2467
+ triggerRef.current = active instanceof HTMLElement && (getAnchorRect !== void 0 || rootRef.current?.contains(active) === true) ? active : null;
2468
+ }, [open]);
2469
+ useEffect(() => {
2470
+ if (!open || exiting !== void 0 || !autoFocus || !positioned || listRef.current?.contains(document.activeElement)) return;
2471
+ const first = listRef.current?.querySelector("button:not(:disabled)");
2472
+ walkIndex.current = first === void 0 || first === null ? null : 0;
2473
+ if (first != null) focusWithoutRing(first);
2211
2474
  }, [
2212
- root,
2213
2475
  open,
2214
- setOpen,
2215
- portal
2476
+ autoFocus,
2477
+ items.length,
2478
+ footer?.length,
2479
+ positioned,
2480
+ exiting
2216
2481
  ]);
2217
- }
2218
- //#endregion
2219
- //#region lib/types/input-modality.js
2220
- /**
2221
- * Document-wide input tracking shared by tooltips and focus-ring styles.
2222
- * Tooltips follow the last input; rings follow navigation or a key followed by
2223
- * focus on a different control. Modifiers and refocusing alone keep rings silent.
2224
- * Module-level listeners live for the document lifetime; Node imports are inert.
2225
- */
2226
- /** Modality values published on the document element. */
2227
- const INPUT_MODALITY = {
2228
- pointer: "pointer",
2229
- keyboard: "keyboard"
2230
- };
2231
- /** Attribute carrying whether focus navigation last owned focus. */
2232
- const INPUT_MODALITY_ATTRIBUTE = "data-input-modality";
2233
- const FOCUS_NAVIGATION = new Set([
2234
- "Tab",
2235
- "Home",
2236
- "End",
2237
- "PageUp",
2238
- "PageDown"
2239
- ]);
2240
- let pointer = false;
2241
- let pointerOwnsFocus = false;
2242
- let keyFocusOrigin;
2243
- function publish() {
2244
- document.documentElement.setAttribute(INPUT_MODALITY_ATTRIBUTE, pointerOwnsFocus ? INPUT_MODALITY.pointer : INPUT_MODALITY.keyboard);
2245
- }
2246
- /**
2247
- * Whether the last input came from a pointer, independently of ring visibility.
2248
- * @returns True after pointer input; false after any key.
2249
- */
2250
- function pointerModality() {
2251
- return pointer;
2252
- }
2253
- if (typeof window !== "undefined") {
2254
- window.addEventListener("pointerdown", () => {
2255
- pointer = true;
2256
- pointerOwnsFocus = true;
2257
- keyFocusOrigin = void 0;
2258
- publish();
2259
- }, true);
2260
- window.addEventListener("keydown", (event) => {
2261
- pointer = false;
2262
- if (event.isComposing) {
2263
- keyFocusOrigin = void 0;
2482
+ useEffect(() => {
2483
+ if (!open || exiting !== void 0) {
2484
+ setOpenSubmenuId(null);
2485
+ walkIndex.current = null;
2264
2486
  return;
2265
2487
  }
2266
- keyFocusOrigin = event.composedPath()[0];
2267
- if (!FOCUS_NAVIGATION.has(event.key) && !event.key.startsWith("Arrow")) return;
2268
- pointerOwnsFocus = false;
2269
- publish();
2270
- }, true);
2271
- window.addEventListener("focusin", (event) => {
2272
- if (keyFocusOrigin === void 0 || event.composedPath()[0] === keyFocusOrigin) return;
2273
- keyFocusOrigin = void 0;
2274
- if (!pointerOwnsFocus) return;
2275
- pointerOwnsFocus = false;
2276
- publish();
2277
- }, true);
2278
- window.addEventListener("blur", () => {
2279
- keyFocusOrigin = void 0;
2280
- });
2281
- }
2282
- //#endregion
2283
- //#region lib/types/Tooltip.js
2284
- /** Anchor-preserving tooltips; an optional body portal escapes clipping containers and stacking contexts that cap the bubble's z-index. */
2285
- /**
2286
- * Suppression channel for nested tooltips: a visible descendant tooltip
2287
- * withdraws the enclosing tooltip while its bubble is shown.
2288
- */
2289
- const TooltipSuppression = createContext(null);
2290
- function clipped(anchor) {
2291
- return [anchor, ...anchor.querySelectorAll("*")].some((el) => el instanceof HTMLElement && el.scrollWidth > el.clientWidth);
2292
- }
2293
- /**
2294
- * Attach a hover/focus tooltip to an anchor element.
2295
- * @param props.label - bubble text, or a resolver evaluated only while visible; an empty string shows only shortcut keys.
2296
- * @param props.shortcutKeys - effective key labels rendered as platform-formatted keycaps after optional text.
2297
- * @param props.side - preferred placement (default 'right'); fitting tries the opposite then perpendicular sides.
2298
- * @param props.align - horizontal anchor-edge alignment for 'bottom'/'top' bubbles: 'end' pins
2299
- * the bubble's right edge to the anchor's (for anchors beside other hover surfaces the centered
2300
- * bubble would overlap); default 'center'. Horizontal placements ignore it.
2301
- * @param props.portal - render the bubble under document.body, so an ancestor's clipping or its
2302
- * stacking context (which confines the bubble's z-index to that context) cannot hide it.
2303
- * @param props.delayMs - hover delay in milliseconds (default 0).
2304
- * @param props.focusDelayMs - keyboard focus delay in milliseconds (default 0); blur, click,
2305
- * mouse leave, disabling, and unmount cancel a pending show.
2306
- * @param props.gap - anchor-to-bubble distance in pixels for 'bottom'/'top' bubbles (default 8);
2307
- * horizontal placements use 10px, including after a flip.
2308
- * @param props.disabled - suppress the bubble while true; the anchor renders identically so
2309
- * toggling never remounts it (which would cut its CSS transitions).
2310
- * @param props.maxWidth - bubble width cap in pixels, for labels long enough that the default
2311
- * half-viewport cap would render a slab wider than the surface the anchor sits on; always bounded by viewport margins.
2312
- * @param props.openOnClick - clicking or tapping also pins the bubble for reading; another click, Escape,
2313
- * Tab, or an outside pointerdown dismisses it. Defaults to false for ordinary action tooltips.
2314
- * @param props.onlyWhenClipped - show the bubble only when the anchor or an HTML element inside it
2315
- * overflows horizontally, measured when the bubble is about to show; for labels that repeat
2316
- * text an ellipsis may cut off. Defaults to false.
2317
- * @param props.children - a single anchor element; its own ref (callback or object) is forwarded alongside the tooltip's.
2318
- * @returns the cloned anchor plus a fixed-position bubble, optionally portaled to the body.
2319
- * The bubble stays hidden until ResizeObserver supplies its size for viewport fitting; clicking the
2320
- * anchor dismisses the bubble unless openOnClick is enabled, and focus arriving after a pointer
2321
- * interaction (a closing menu refocusing its trigger) never raises it. Touch cannot trigger hover
2322
- * tooltips; tapping still invokes the child's action and can open an openOnClick explanation.
2323
- * When no side fits, the viewport-bounded fallback may overlap the anchor; oversized content is scrollable when pinned.
2324
- */
2325
- function Tooltip({ label, shortcutKeys, side = "right", align = "center", delayMs = 0, focusDelayMs = 0, gap = 8, disabled = false, portal = false, maxWidth, openOnClick = false, onlyWhenClipped = false, children }) {
2326
- const id = useId();
2327
- const [pinned, setPinned] = useState(false);
2328
- const anchor = useRef(null);
2329
- const childRef = children.ref;
2330
- const mergedRef = useCallback((el) => {
2331
- anchor.current = el;
2332
- if (typeof childRef === "function") childRef(el);
2333
- else if (childRef != null) childRef.current = el;
2334
- }, [childRef]);
2335
- const [pos, setPos] = useState(null);
2336
- const bubble = useRef(null);
2337
- const resolvedLabel = pos === null ? null : typeof label === "function" ? label() : label;
2338
- const showTimer = useRef(null);
2339
- const triggers = useRef({
2340
- hover: false,
2341
- focus: false
2342
- });
2343
- const suppressAncestors = useContext(TooltipSuppression);
2344
- const [suppressed, setSuppressed] = useState(false);
2345
- const announce = useCallback((active) => {
2346
- suppressAncestors?.(active);
2347
- }, [suppressAncestors]);
2348
- const visible = pos !== null && !disabled;
2349
- useEffect(() => {
2350
- const el = bubble.current;
2351
- if (pos === null || !visible || suppressed || el === null) return;
2352
- let size;
2353
- let anchorRect = pos;
2354
- const fit = () => {
2355
- if (size === void 0) return;
2356
- const placement = placeTooltip({
2357
- anchor: anchorRect,
2358
- width: size.inlineSize,
2359
- height: size.blockSize,
2360
- viewportWidth: window.innerWidth,
2361
- viewportHeight: window.innerHeight,
2362
- side,
2363
- align,
2364
- gap
2365
- });
2366
- const horizontal = placement.side === "right" || placement.side === "left";
2367
- const offsetX = horizontal ? 0 : align === "end" ? placement.width : placement.width / 2;
2368
- const offsetY = horizontal ? placement.height / 2 : placement.side === "top" ? placement.height : 0;
2369
- el.style.left = `${placement.left + offsetX}px`;
2370
- el.style.top = `${placement.top + offsetY}px`;
2371
- el.dataset.side = placement.side;
2372
- el.style.visibility = "visible";
2488
+ const composition = observeComposition(document);
2489
+ const onPointerDown = (e) => {
2490
+ if (!(e.target instanceof Node) || contextual && e.button === 2) return;
2491
+ if (rootRef.current?.contains(e.target) === true) return;
2492
+ if (listRef.current?.contains(e.target) === true) return;
2493
+ onClose();
2373
2494
  };
2374
- const onResize = () => {
2375
- if (anchor.current !== null) anchorRect = anchor.current.getBoundingClientRect();
2376
- fit();
2495
+ const onKeyDown = (e) => {
2496
+ if (composition.guards(e) || isBehindModal(triggerRef.current ?? rootRef.current) || e.defaultPrevented || e.ctrlKey || e.altKey || e.metaKey) return;
2497
+ const focused = document.activeElement;
2498
+ const insideList = listRef.current?.contains(focused) === true;
2499
+ const anchored = focused === returnFocus?.() || rootRef.current?.contains(focused) === true || insideList;
2500
+ if (e.key === "Escape" && !e.shiftKey) {
2501
+ e.preventDefault();
2502
+ if (e.repeat) return;
2503
+ onClose();
2504
+ if (anchored || autoFocus) refocusAnchor();
2505
+ }
2506
+ if (e.key === "Tab") {
2507
+ const list = listRef.current;
2508
+ if (list === null || !anchored) return;
2509
+ if (e.shiftKey) {
2510
+ e.preventDefault();
2511
+ onClose();
2512
+ refocusAnchor(true);
2513
+ return;
2514
+ }
2515
+ if (insideList) {
2516
+ if (focused instanceof Element && focused.getAttribute("role") === "menuitem") {
2517
+ e.preventDefault();
2518
+ if (focused.getAttribute("aria-disabled") === "true") {
2519
+ onClose();
2520
+ refocusAnchor(true);
2521
+ return;
2522
+ }
2523
+ selectingWithTab.current = true;
2524
+ try {
2525
+ focused.click();
2526
+ } finally {
2527
+ selectingWithTab.current = false;
2528
+ }
2529
+ }
2530
+ return;
2531
+ }
2532
+ const row = list.querySelector("button:not(:disabled)");
2533
+ if (row === null) return;
2534
+ e.preventDefault();
2535
+ row.focus();
2536
+ walkIndex.current = 0;
2537
+ return;
2538
+ }
2539
+ if (![
2540
+ "ArrowDown",
2541
+ "ArrowUp",
2542
+ "Home",
2543
+ "End"
2544
+ ].includes(e.key)) return;
2545
+ const list = listRef.current;
2546
+ if (list === null || !anchored) return;
2547
+ const buttons = Array.from(list.querySelectorAll("button:not(:disabled)"));
2548
+ if (buttons.length === 0) return;
2549
+ const index = buttons.indexOf(focused);
2550
+ const from = index >= 0 ? index : walkIndex.current;
2551
+ const next = e.key === "Home" ? 0 : e.key === "End" ? buttons.length - 1 : from === null ? e.key === "ArrowDown" ? 0 : buttons.length - 1 : (from + (e.key === "ArrowDown" ? 1 : -1) + buttons.length) % buttons.length;
2552
+ e.preventDefault();
2553
+ walkIndex.current = next;
2554
+ buttons[next]?.focus();
2377
2555
  };
2378
- const observer = new ResizeObserver((entries) => {
2379
- size = entries[0]?.borderBoxSize[0];
2380
- fit();
2381
- });
2382
- observer.observe(el, { box: "border-box" });
2383
- window.addEventListener("resize", onResize);
2384
- return () => {
2385
- observer.disconnect();
2386
- window.removeEventListener("resize", onResize);
2556
+ const onWindowBlur = () => {
2557
+ if (document.activeElement instanceof HTMLIFrameElement) onClose();
2387
2558
  };
2388
- }, [
2389
- align,
2390
- gap,
2391
- pos,
2392
- side,
2393
- suppressed,
2394
- visible
2395
- ]);
2396
- useEffect(() => {
2397
- announce(visible);
2559
+ document.addEventListener("pointerdown", onPointerDown);
2560
+ const onEscape = (event) => {
2561
+ if (event.key === "Escape") onKeyDown(event);
2562
+ };
2563
+ const onOtherKey = (event) => {
2564
+ if (event.key !== "Escape") onKeyDown(event);
2565
+ };
2566
+ document.addEventListener("keydown", onOtherKey);
2567
+ document.addEventListener("keydown", onEscape, true);
2568
+ window.addEventListener("blur", onWindowBlur);
2398
2569
  return () => {
2399
- announce(false);
2570
+ composition.dispose();
2571
+ document.removeEventListener("pointerdown", onPointerDown);
2572
+ document.removeEventListener("keydown", onOtherKey);
2573
+ document.removeEventListener("keydown", onEscape, true);
2574
+ window.removeEventListener("blur", onWindowBlur);
2400
2575
  };
2401
- }, [announce, visible]);
2402
- const cancelShow = useCallback(() => {
2403
- if (showTimer.current === null) return;
2404
- clearTimeout(showTimer.current);
2405
- showTimer.current = null;
2406
- }, []);
2407
- useEffect(() => {
2408
- if (pinned && (disabled || !openOnClick)) setPinned(false);
2409
- if (disabled) {
2410
- cancelShow();
2411
- triggers.current = {
2412
- hover: false,
2413
- focus: false
2414
- };
2415
- setPos(null);
2416
- }
2417
- return cancelShow;
2418
2576
  }, [
2419
- cancelShow,
2420
- disabled,
2421
- openOnClick,
2422
- pinned
2577
+ open,
2578
+ onClose,
2579
+ autoFocus,
2580
+ contextual,
2581
+ exiting
2423
2582
  ]);
2424
- const show = () => {
2425
- if (disabled) return;
2426
- const el = anchor.current;
2427
- /* v8 ignore next -- the ref is attached by event time: events fire on the cloned anchor. */
2428
- if (el === null) return;
2429
- if (onlyWhenClipped && !clipped(el)) return;
2430
- setPos(el.getBoundingClientRect());
2431
- announce(true);
2432
- };
2433
- const showAfterDelay = (delay) => {
2434
- cancelShow();
2435
- if (delay <= 0) {
2436
- show();
2437
- return;
2438
- }
2439
- showTimer.current = setTimeout(() => {
2440
- showTimer.current = null;
2441
- show();
2442
- }, delay);
2583
+ useLayoutEffect(() => {
2584
+ if (exiting === "dismiss" && listRef.current?.contains(document.activeElement)) refocusAnchor();
2585
+ }, [exiting]);
2586
+ useEffect(() => {
2587
+ if (!open) cancelClose();
2588
+ }, [open, cancelClose]);
2589
+ const scrollable = !items.some((entry) => !isSeparator(entry) && !isLabel(entry) && entry.submenu !== void 0 && entry.submenu.length > 0);
2590
+ const itemColumns = iconColumns(items, contextual);
2591
+ const footerColumns = iconColumns(footer ?? [], contextual);
2592
+ const renderEntry = (entry, columns) => {
2593
+ if (isSeparator(entry)) return jsx("div", {
2594
+ className: css$10.separator,
2595
+ role: "separator"
2596
+ }, entry.id);
2597
+ if (isLabel(entry)) return jsx("div", {
2598
+ className: css$10.label,
2599
+ role: "presentation",
2600
+ children: entry.text
2601
+ }, entry.id);
2602
+ const hasSub = entry.submenu !== void 0 && entry.submenu.length > 0;
2603
+ const subOpen = hasSub && openSubmenuId === entry.id;
2604
+ const subColumns = iconColumns(entry.submenu ?? [], contextual);
2605
+ const selected = entry.id === selectedId || selectedIds?.includes(entry.id) === true;
2606
+ return jsxs("div", {
2607
+ className: css$10.itemWrap,
2608
+ onMouseEnter: hasSub ? () => {
2609
+ setOpenSubmenuId(entry.id);
2610
+ } : void 0,
2611
+ onMouseLeave: () => {
2612
+ setOpenSubmenuId(null);
2613
+ },
2614
+ children: [jsxs("button", {
2615
+ type: "button",
2616
+ role: "menuitem",
2617
+ className: clsx(css$10.item, selected && (selection === "fill" ? css$10.selectedFill : css$10.selected), entry.danger === true && css$10.danger),
2618
+ disabled: entry.disabled,
2619
+ "aria-keyshortcuts": entry.shortcut?.aria,
2620
+ "aria-haspopup": hasSub ? "menu" : void 0,
2621
+ "aria-expanded": hasSub ? subOpen : void 0,
2622
+ onFocus: hasSub ? () => {
2623
+ setOpenSubmenuId(entry.id);
2624
+ } : void 0,
2625
+ onClick: () => {
2626
+ if (hasSub) {
2627
+ setOpenSubmenuId(entry.id);
2628
+ return;
2629
+ }
2630
+ onSelect?.(entry.id);
2631
+ },
2632
+ children: [
2633
+ (entry.icon !== void 0 || columns.has(entry)) && jsx("span", {
2634
+ "aria-hidden": "true",
2635
+ className: css$10.itemIcon,
2636
+ children: entry.icon
2637
+ }),
2638
+ jsx("span", {
2639
+ className: css$10.itemLabel,
2640
+ children: entry.label
2641
+ }),
2642
+ entry.shortcut !== void 0 && jsx("span", {
2643
+ "aria-hidden": "true",
2644
+ className: css$10.shortcut,
2645
+ children: jsx(ShortcutKeys, {
2646
+ keys: entry.shortcut.keys,
2647
+ className: css$10.shortcutKeys
2648
+ })
2649
+ }),
2650
+ selected && selection === "check" && jsx(IconCheckOutlineRegular, { className: css$10.check })
2651
+ ]
2652
+ }), subOpen && entry.submenu !== void 0 && jsx(MenuSurface, {
2653
+ compact,
2654
+ className: clsx(css$10.submenu, compact && css$10.compactList),
2655
+ role: "menu",
2656
+ children: entry.submenu.map((sub) => isSeparator(sub) ? jsx("div", {
2657
+ className: css$10.separator,
2658
+ role: "separator"
2659
+ }, sub.id) : isLabel(sub) ? jsx("div", {
2660
+ className: css$10.label,
2661
+ children: sub.text
2662
+ }, sub.id) : jsxs("button", {
2663
+ type: "button",
2664
+ role: "menuitem",
2665
+ className: css$10.item,
2666
+ disabled: sub.disabled,
2667
+ "aria-keyshortcuts": sub.shortcut?.aria,
2668
+ onClick: () => {
2669
+ onSelect?.(sub.id);
2670
+ refocusAfterSelection();
2671
+ },
2672
+ children: [
2673
+ (sub.icon !== void 0 || subColumns.has(sub)) && jsx("span", {
2674
+ "aria-hidden": "true",
2675
+ className: css$10.itemIcon,
2676
+ children: sub.icon
2677
+ }),
2678
+ jsx("span", {
2679
+ className: css$10.itemLabel,
2680
+ children: sub.label
2681
+ }),
2682
+ sub.shortcut !== void 0 && jsx("span", {
2683
+ "aria-hidden": "true",
2684
+ className: css$10.shortcut,
2685
+ children: jsx(ShortcutKeys, {
2686
+ keys: sub.shortcut.keys,
2687
+ className: css$10.shortcutKeys
2688
+ })
2689
+ })
2690
+ ]
2691
+ }, sub.id))
2692
+ })]
2693
+ }, entry.id);
2443
2694
  };
2444
- const withdraw = useCallback(() => {
2445
- setPinned(false);
2446
- setPos(null);
2447
- announce(false);
2448
- }, [announce]);
2449
- const hide = () => {
2450
- cancelShow();
2451
- if (!triggers.current.hover && !triggers.current.focus && !pinned) withdraw();
2695
+ const collapseSubmenuFrom = (e) => {
2696
+ const row = e.target instanceof Element ? e.target.closest("button[role=\"menuitem\"]") : null;
2697
+ if (row === null || row.getAttribute("aria-haspopup") === "menu") return;
2698
+ if (row.closest("[role=\"menu\"]") !== e.currentTarget) return;
2699
+ setOpenSubmenuId(null);
2452
2700
  };
2453
- const dismiss = useCallback(() => {
2454
- cancelShow();
2455
- triggers.current = {
2456
- hover: false,
2457
- focus: false
2458
- };
2459
- withdraw();
2460
- }, [cancelShow, withdraw]);
2461
- useDismissOnOutsidePointer(anchor, openOnClick && visible, dismiss, bubble);
2462
- useEffect(() => {
2463
- if (!openOnClick || !visible) return;
2464
- const onKeyDown = (event) => {
2465
- if (event.key !== "Escape" && event.key !== "Tab") return;
2466
- if (event.key === "Escape") {
2467
- event.preventDefault();
2468
- event.stopPropagation();
2469
- }
2470
- dismiss();
2471
- };
2472
- document.addEventListener("keydown", onKeyDown, true);
2473
- return () => {
2474
- document.removeEventListener("keydown", onKeyDown, true);
2475
- };
2476
- }, [
2477
- dismiss,
2478
- openOnClick,
2479
- visible
2480
- ]);
2481
- const content = visible && !suppressed && jsxs("span", {
2482
- ref: bubble,
2483
- id: openOnClick ? id : void 0,
2484
- className: css$10.bubble,
2485
- "data-side": side,
2486
- "data-portal": portal || void 0,
2487
- "data-pinned": pinned || void 0,
2488
- "data-align": align,
2489
- "data-has-shortcut": shortcutKeys?.length ? true : void 0,
2490
- style: {
2491
- left: pos.left,
2492
- top: pos.top,
2493
- visibility: "hidden",
2494
- ...maxWidth === void 0 ? {} : { maxWidth: `min(${maxWidth}px, calc(100vw - 24px))` }
2701
+ const list = open && jsxs(MenuSurface, {
2702
+ compact,
2703
+ id: contextual ? menuId : void 0,
2704
+ ref: listRef,
2705
+ className: clsx(css$10.list, listClassName, dense && css$10.denseList, compact && css$10.compactList, scrollable && css$10.scrollable, portal && css$10.portal, side === "top" && !portal && css$10.sideTop, align === "end" && !portal && css$10.alignEnd),
2706
+ style: portal ? fixedPos ?? MEASURE_STYLE : void 0,
2707
+ role: exiting === void 0 ? "menu" : void 0,
2708
+ "aria-hidden": exiting === void 0 ? void 0 : true,
2709
+ "data-context-menu": contextual ? "" : void 0,
2710
+ phase: contextual ? exiting ?? "enter" : void 0,
2711
+ onClick: (e) => {
2712
+ e.stopPropagation();
2713
+ const row = e.target instanceof Element ? e.target.closest("button[role=\"menuitem\"]") : null;
2714
+ if (row !== null && row.getAttribute("aria-haspopup") !== "menu") refocusAfterSelection();
2495
2715
  },
2496
- role: "tooltip",
2497
- "aria-label": shortcutKeys?.length ? [resolvedLabel, shortcutKeys.join(" ")].filter(Boolean).join(" ") : void 0,
2498
- children: [resolvedLabel && jsx("span", {
2499
- className: css$10.label,
2500
- children: resolvedLabel
2501
- }), shortcutKeys !== void 0 && shortcutKeys.length > 0 && jsx(ShortcutKeys, {
2502
- keys: shortcutKeys,
2503
- variant: "tooltip"
2716
+ onContextMenu: contextual ? (event) => {
2717
+ event.preventDefault();
2718
+ event.stopPropagation();
2719
+ onClose();
2720
+ } : void 0,
2721
+ onMouseOver: collapseSubmenuFrom,
2722
+ onFocus: collapseSubmenuFrom,
2723
+ children: [jsxs("div", {
2724
+ className: css$10.viewport,
2725
+ role: "presentation",
2726
+ children: [items.map((entry) => renderEntry(entry, itemColumns)), children]
2727
+ }), footer !== void 0 && footer.length > 0 && jsx("div", {
2728
+ className: css$10.footer,
2729
+ role: "presentation",
2730
+ children: footer.map((entry) => renderEntry(entry, footerColumns))
2504
2731
  })]
2505
2732
  });
2506
- return jsxs(TooltipSuppression.Provider, {
2507
- value: setSuppressed,
2508
- children: [cloneElement(children, {
2509
- ref: mergedRef,
2510
- "aria-describedby": openOnClick && visible ? [children.props["aria-describedby"], id].filter(Boolean).join(" ") : children.props["aria-describedby"],
2511
- onPointerEnter: (e) => {
2512
- children.props.onPointerEnter?.(e);
2513
- if (e.pointerType === "touch") return;
2514
- if (e.pointerType === "mouse" && !window.matchMedia("(any-hover: hover)").matches) return;
2515
- triggers.current.hover = true;
2516
- showAfterDelay(delayMs);
2517
- },
2518
- onPointerLeave: (e) => {
2519
- children.props.onPointerLeave?.(e);
2520
- triggers.current.hover = false;
2521
- cancelShow();
2522
- if (!pinned) withdraw();
2523
- },
2524
- onPointerDown: (e) => {
2525
- children.props.onPointerDown?.(e);
2526
- if (e.pointerType === "touch" && !pinned) dismiss();
2527
- },
2528
- onClick: (e) => {
2529
- children.props.onClick?.(e);
2530
- triggers.current.focus = false;
2531
- cancelShow();
2532
- if (openOnClick && !disabled && !pinned) {
2533
- setPinned(true);
2534
- show();
2535
- } else withdraw();
2536
- },
2537
- onFocus: (e) => {
2538
- children.props.onFocus?.(e);
2539
- if (pointerModality()) return;
2540
- triggers.current.focus = true;
2541
- showAfterDelay(focusDelayMs);
2542
- },
2543
- onBlur: (e) => {
2544
- children.props.onBlur?.(e);
2545
- triggers.current.focus = false;
2546
- hide();
2547
- }
2548
- }), portal ? content !== false && createPortal(content, document.body) : content]
2733
+ return jsxs("span", {
2734
+ ref: rootRef,
2735
+ className: clsx(css$10.root, className),
2736
+ onPointerEnter: closeOnPointerLeave ? cancelClose : void 0,
2737
+ onPointerLeave: closeOnPointerLeave ? () => {
2738
+ if (open) armClose();
2739
+ } : void 0,
2740
+ children: [anchor, portal ? list !== false && createPortal(list, document.body) : list]
2549
2741
  });
2550
2742
  }
2551
2743
  //#endregion
@@ -3250,76 +3442,6 @@ function useAnchoredMaxHeight(ref, cap, signal, margin = MARGIN) {
3250
3442
  return maxHeight;
3251
3443
  }
3252
3444
  //#endregion
3253
- //#region lib/types/useAnchoredPosition.js
3254
- /**
3255
- * Keep a fixed-position floating element anchored to a trigger.
3256
- *
3257
- * A portaled panel is positioned from its anchor's viewport rect, which stops
3258
- * being true the moment anything scrolls or the window resizes. This owns that
3259
- * one concern: measure the anchor, offset the panel below or above it, clamp
3260
- * the result inside the viewport, and re-run on scroll (capture phase, so
3261
- * scrollers nested inside the page are caught too), on resize, and on the
3262
- * panel's own size changes while the element is open.
3263
- * @module @deepseek-ai/dsh-client-ui-primitives/useAnchoredPosition
3264
- */
3265
- /**
3266
- * Track an anchor and return the panel's fixed coordinates.
3267
- * @param options - the open state, the two refs, the placement side and alignment, and the gap/margin distances.
3268
- * @returns `left`/`top` for the panel, or `null` before the first measurement.
3269
- */
3270
- function useAnchoredPosition(options) {
3271
- const { open, anchorRef, panelRef, side = "bottom", align = "start", gap, margin } = options;
3272
- const [position, setPosition] = useState(null);
3273
- useLayoutEffect(() => {
3274
- if (!open) {
3275
- setPosition(null);
3276
- return;
3277
- }
3278
- const place = () => {
3279
- /* v8 ignore start -- geometry read from real layout: jsdom reports zero
3280
- offset sizes, so the positive-size clamp arms are exercised by browser
3281
- scenarios rather than unit tests. */
3282
- const rect = anchorRef.current?.getBoundingClientRect();
3283
- if (rect === void 0) return;
3284
- const panel = panelRef.current;
3285
- const width = panel?.offsetWidth ?? 0;
3286
- const height = panel?.offsetHeight ?? 0;
3287
- let left = align === "end" ? rect.right - width : rect.left;
3288
- let top = side === "top" ? rect.top - gap - height : rect.bottom + gap;
3289
- if (width > 0) left = Math.min(Math.max(left, margin), window.innerWidth - width - margin);
3290
- if (height > 0) top = Math.min(Math.max(top, overlayTopMargin(margin, rect, gap)), window.innerHeight - height - margin);
3291
- /* v8 ignore stop */
3292
- setPosition({
3293
- left,
3294
- top
3295
- });
3296
- };
3297
- place();
3298
- window.addEventListener("scroll", place, true);
3299
- window.addEventListener("resize", place);
3300
- const panel = panelRef.current;
3301
- let observer = null;
3302
- if (typeof ResizeObserver !== "undefined" && panel !== null) {
3303
- observer = new ResizeObserver(place);
3304
- observer.observe(panel);
3305
- }
3306
- return () => {
3307
- observer?.disconnect();
3308
- window.removeEventListener("scroll", place, true);
3309
- window.removeEventListener("resize", place);
3310
- };
3311
- }, [
3312
- open,
3313
- anchorRef,
3314
- panelRef,
3315
- side,
3316
- align,
3317
- gap,
3318
- margin
3319
- ]);
3320
- return position;
3321
- }
3322
- //#endregion
3323
3445
  //#region lib/types/clipboard.js
3324
3446
  /**
3325
3447
  * Write text to the host clipboard, preferring the async Clipboard API and
@@ -3575,6 +3697,10 @@ function HoverCard({ anchor, content, openDelayMs = 500, disabled = false, group
3575
3697
  const wrapper = rootRef.current;
3576
3698
  /* v8 ignore next -- the ref is attached before the layout effect runs and the listeners die with it. */
3577
3699
  if (wrapper === null) return;
3700
+ if (wrapper.closest("[inert], [hidden]") !== null) {
3701
+ dismissImmediately();
3702
+ return;
3703
+ }
3578
3704
  const r = wrapper.getBoundingClientRect();
3579
3705
  const h = cardRef.current?.offsetHeight ?? 0;
3580
3706
  if (variant === "preview") {
@@ -3630,6 +3756,11 @@ function HoverCard({ anchor, content, openDelayMs = 500, disabled = false, group
3630
3756
  });
3631
3757
  };
3632
3758
  place();
3759
+ const visibility = new MutationObserver(place);
3760
+ for (let ancestor = rootRef.current?.parentElement; ancestor != null; ancestor = ancestor.parentElement) visibility.observe(ancestor, {
3761
+ attributes: true,
3762
+ attributeFilter: ["inert", "hidden"]
3763
+ });
3633
3764
  const observer = (variant === "preview" || inline) && typeof ResizeObserver !== "undefined" ? new ResizeObserver(place) : null;
3634
3765
  for (const element of [
3635
3766
  cardRef.current,
@@ -3640,6 +3771,7 @@ function HoverCard({ anchor, content, openDelayMs = 500, disabled = false, group
3640
3771
  window.addEventListener("resize", place);
3641
3772
  return () => {
3642
3773
  observer?.disconnect();
3774
+ visibility.disconnect();
3643
3775
  window.removeEventListener("scroll", place, true);
3644
3776
  window.removeEventListener("resize", place);
3645
3777
  };
@@ -3649,7 +3781,8 @@ function HoverCard({ anchor, content, openDelayMs = 500, disabled = false, group
3649
3781
  widthAnchorRef,
3650
3782
  positioned,
3651
3783
  inline,
3652
- fitContent
3784
+ fitContent,
3785
+ dismissImmediately
3653
3786
  ]);
3654
3787
  useLayoutEffect(() => {
3655
3788
  if (!open || pos === null || variant === "preview" || inline) return;
@@ -5479,7 +5612,7 @@ function UserTextRun({ text }) {
5479
5612
  * @param props - resolved visual fields and optional action from the owning renderer.
5480
5613
  * @returns an inline label, or a keyboard-accessible button when activation is supplied.
5481
5614
  */
5482
- function ReferenceChip({ appearance, label, title, onActivate }) {
5615
+ function ReferenceChip({ appearance, label, title, onActivate, contextMenuProps }) {
5483
5616
  const slash = appearance === "skill" || appearance === "command";
5484
5617
  const contents = jsxs(Fragment, { children: [!slash && jsx(ReferenceIconRegular, {
5485
5618
  kind: appearance,
@@ -5488,12 +5621,14 @@ function ReferenceChip({ appearance, label, title, onActivate }) {
5488
5621
  }), label] });
5489
5622
  const className = clsx(css$27.refChip, slash && css$27.slashChip);
5490
5623
  return onActivate === void 0 ? jsx("span", {
5624
+ ...contextMenuProps,
5491
5625
  className,
5492
5626
  "data-ref-chip": appearance,
5493
5627
  title,
5494
5628
  children: contents
5495
5629
  }) : jsx("button", {
5496
5630
  type: "button",
5631
+ ...contextMenuProps,
5497
5632
  className: clsx(className, markdownCss.fileMention),
5498
5633
  "data-ref-chip": appearance,
5499
5634
  title,
@@ -9385,16 +9520,7 @@ function cjkFriendlyStrong() {
9385
9520
  }
9386
9521
  //#endregion
9387
9522
  //#region lib/types/markdown/mathCompatibility.js
9388
- /**
9389
- * Extend upstream dollar-only math syntax with TeX delimiters while reusing its
9390
- * token vocabulary. The dollar construct is dispatched before upstream's
9391
- * `mathFlow`, so the shapes it accepts keep the opening line's text as math
9392
- * instead of fence meta, which the renderer does not read. A `$$` candidate it
9393
- * declines — a `$$` sequence the line does not end after, or a block left open
9394
- * — is left to that upstream flow.
9395
- */
9396
- /** Prefixes whose following character is a `\verb` delimiter, not a fence. */
9397
- const VERB_DELIMITER_PREFIXES = ["\\verb", "\\verb*"];
9523
+ /** Extend upstream dollar-only math syntax with TeX delimiters while reusing its token vocabulary. */
9398
9524
  const previousBackslash = function(code) {
9399
9525
  if (code !== codes.backslash) return true;
9400
9526
  const tail = this.events.at(-1);
@@ -9495,16 +9621,10 @@ const tokenizeBackslashMathText = function(effects, ok, nok) {
9495
9621
  }
9496
9622
  }
9497
9623
  };
9498
- function createMathFlow(marker, openMarker, closeMarker) {
9624
+ function createMathFlow(marker, openMarker, closeMarker, multiline) {
9499
9625
  const tokenize = function(effects, ok, nok) {
9500
9626
  const self = this;
9501
9627
  let oddBackslashRun = false;
9502
- let inComment = false;
9503
- let commentHasContent = false;
9504
- let crossedLineEnding = false;
9505
- let sawClosingFenceSequence = false;
9506
- let consumedTail = "";
9507
- let failedClose = false;
9508
9628
  const tail = self.events.at(-1);
9509
9629
  const initialSize = tail?.[1].type === types.linePrefix ? tail[2].sliceSerialize(tail[1], true).length : 0;
9510
9630
  return start;
@@ -9529,64 +9649,18 @@ function createMathFlow(marker, openMarker, closeMarker) {
9529
9649
  }
9530
9650
  function content(code) {
9531
9651
  if (code === codes.eof) return nok(code);
9532
- if (code === marker && marker === codes.dollarSign && !inComment && verbDelimiterAhead()) return verbatimDelimiter(code);
9533
- if (code === marker && closingFenceAllowed()) return effects.attempt({
9652
+ if (code === marker && (marker !== codes.dollarSign || !oddBackslashRun)) return effects.attempt({
9534
9653
  partial: true,
9535
9654
  tokenize: tokenizeClosingFence
9536
9655
  }, closed, afterClosingFenceAttempt)(code);
9537
- if (markdownLineEnding(code)) {
9538
- if (marker === codes.dollarSign && failedClose) return nok(code);
9539
- oddBackslashRun = false;
9540
- inComment = false;
9541
- commentHasContent = false;
9542
- consumedTail = "";
9543
- if (marker === codes.dollarSign) crossedLineEnding = true;
9544
- if (self.interrupt && marker === codes.dollarSign) return nok(code);
9545
- return effects.attempt(nonLazyContinuation, afterContinuation, nok)(code);
9546
- }
9656
+ if (markdownLineEnding(code)) return multiline ? effects.attempt(nonLazyContinuation, afterContinuation, nok)(code) : nok(code);
9547
9657
  return valueStart(code);
9548
9658
  }
9549
- /**
9550
- * Whether the marker under the scanner may close the block. The dollar flow
9551
- * keeps an escaped `$` and a `%` comment that holds text from closing.
9552
- */
9553
- function closingFenceAllowed() {
9554
- if (marker !== codes.dollarSign) return true;
9555
- return !oddBackslashRun && !(inComment && commentHasContent && crossedLineEnding);
9556
- }
9557
- /** Whether the marker under the scanner is a `\verb` region's delimiter. */
9558
- function verbDelimiterAhead() {
9559
- return VERB_DELIMITER_PREFIXES.some((prefix) => consumedTail.endsWith(prefix));
9560
- }
9561
- function verbatimDelimiter(code) {
9562
- effects.enter("mathFlowValue");
9563
- oddBackslashRun = false;
9564
- rememberConsumed(code);
9565
- effects.consume(code);
9566
- return verbatimDelimiterClose;
9567
- }
9568
- function verbatimDelimiterClose(code) {
9569
- if (code !== marker) return value(code);
9570
- rememberConsumed(code);
9571
- effects.consume(code);
9572
- return value;
9573
- }
9574
- /** Record one consumed code unit so a fence can be told from a delimiter. */
9575
- function rememberConsumed(code) {
9576
- /* v8 ignore next 2 -- every call site passes a code unit, never EOF. */
9577
- if (code === null) return;
9578
- consumedTail = `${consumedTail}${String.fromCharCode(code)}`.slice(-6);
9579
- }
9580
9659
  function afterClosingFenceAttempt(code) {
9581
- if (marker === codes.backslash) return effects.check({
9660
+ return marker === codes.backslash ? effects.check({
9582
9661
  partial: true,
9583
9662
  tokenize: tokenizeOpeningFence
9584
- }, nok, markerValueStart)(code);
9585
- if (sawClosingFenceSequence) {
9586
- if (crossedLineEnding) return nok(code);
9587
- failedClose = true;
9588
- }
9589
- return markerValueStart(code);
9663
+ }, nok, markerValueStart)(code) : markerValueStart(code);
9590
9664
  }
9591
9665
  function afterContinuation(code) {
9592
9666
  return effects.attempt({
@@ -9597,25 +9671,17 @@ function createMathFlow(marker, openMarker, closeMarker) {
9597
9671
  function valueStart(code) {
9598
9672
  effects.enter("mathFlowValue");
9599
9673
  oddBackslashRun = code === codes.backslash;
9600
- if (code === codes.percentSign && marker === codes.dollarSign && !inComment) {
9601
- inComment = true;
9602
- commentHasContent = false;
9603
- } else if (inComment && !markdownSpace(code)) commentHasContent = true;
9604
- rememberConsumed(code);
9605
9674
  effects.consume(code);
9606
9675
  return value;
9607
9676
  }
9608
9677
  function markerValueStart(code) {
9609
9678
  effects.enter("mathFlowValue");
9610
9679
  oddBackslashRun = false;
9611
- if (inComment) commentHasContent = true;
9612
- rememberConsumed(code);
9613
9680
  effects.consume(code);
9614
9681
  return valueAfterMarker;
9615
9682
  }
9616
9683
  function valueAfterMarker(code) {
9617
9684
  if (code === marker) {
9618
- rememberConsumed(code);
9619
9685
  effects.consume(code);
9620
9686
  return value;
9621
9687
  }
@@ -9626,15 +9692,7 @@ function createMathFlow(marker, openMarker, closeMarker) {
9626
9692
  effects.exit("mathFlowValue");
9627
9693
  return content(code);
9628
9694
  }
9629
- const escaped = oddBackslashRun;
9630
- const doubleBackslash = code === codes.backslash && escaped;
9631
- oddBackslashRun = code === codes.backslash ? !escaped : false;
9632
- if (!escaped && code === codes.percentSign && marker === codes.dollarSign && !inComment) {
9633
- inComment = true;
9634
- commentHasContent = false;
9635
- } else if (inComment && !markdownSpace(code)) commentHasContent = true;
9636
- if (doubleBackslash) consumedTail = "";
9637
- else rememberConsumed(code);
9695
+ oddBackslashRun = code === codes.backslash ? !oddBackslashRun : false;
9638
9696
  effects.consume(code);
9639
9697
  return value;
9640
9698
  }
@@ -9643,7 +9701,6 @@ function createMathFlow(marker, openMarker, closeMarker) {
9643
9701
  return ok(code);
9644
9702
  }
9645
9703
  function tokenizeClosingFence(closeEffects, closeOk, closeNok) {
9646
- sawClosingFenceSequence = false;
9647
9704
  return factorySpace(closeEffects, sequenceStart, types.linePrefix, constants.tabSize);
9648
9705
  function sequenceStart(code) {
9649
9706
  if (code !== marker) return closeNok(code);
@@ -9656,7 +9713,6 @@ function createMathFlow(marker, openMarker, closeMarker) {
9656
9713
  if (code !== closeMarker) return closeNok(code);
9657
9714
  closeEffects.consume(code);
9658
9715
  closeEffects.exit("mathFlowFenceSequence");
9659
- sawClosingFenceSequence = true;
9660
9716
  return factorySpace(closeEffects, after, types.whitespace);
9661
9717
  }
9662
9718
  function after(code) {
@@ -9684,7 +9740,7 @@ function createMathFlow(marker, openMarker, closeMarker) {
9684
9740
  };
9685
9741
  return {
9686
9742
  concrete: true,
9687
- name: marker === codes.dollarSign ? "dollarMathFlow" : "backslashMathFlow",
9743
+ name: marker === codes.dollarSign ? "sameLineDollarMathFlow" : "backslashMathFlow",
9688
9744
  tokenize
9689
9745
  };
9690
9746
  }
@@ -9714,22 +9770,20 @@ const backslashMathText = {
9714
9770
  previous: previousBackslash,
9715
9771
  tokenize: tokenizeBackslashMathText
9716
9772
  };
9717
- const backslashMathFlow = createMathFlow(codes.backslash, codes.leftSquareBracket, codes.rightSquareBracket);
9718
- const dollarMathFlow = createMathFlow(codes.dollarSign, codes.dollarSign, codes.dollarSign);
9773
+ const backslashMathFlow = createMathFlow(codes.backslash, codes.leftSquareBracket, codes.rightSquareBracket, true);
9774
+ const sameLineDollarMathFlow = createMathFlow(codes.dollarSign, codes.dollarSign, codes.dollarSign, false);
9719
9775
  const backslashMath = {
9720
9776
  flow: {
9721
9777
  [codes.backslash]: backslashMathFlow,
9722
- [codes.dollarSign]: dollarMathFlow
9778
+ [codes.dollarSign]: sameLineDollarMathFlow
9723
9779
  },
9724
9780
  text: { [codes.backslash]: backslashMathText }
9725
9781
  };
9726
9782
  /**
9727
- * TeX backslash delimiters and display-dollar blocks as a micromark syntax
9728
- * extension reusing `micromark-extension-math`'s token vocabulary; the caller
9729
- * must also register `math()` on the same parse so the emitted tokens compile
9730
- * to standard math nodes. Both `$$<math>$$` on one line and a `$$<math>` block
9731
- * closed by a trailing `$$` parse as one math node, and a closing `$$` may sit
9732
- * at the end of a content line.
9783
+ * TeX backslash delimiters and same-line display-dollar blocks as a micromark
9784
+ * syntax extension reusing `micromark-extension-math`'s token vocabulary; the
9785
+ * caller must also register `math()` on the same parse so the emitted tokens
9786
+ * compile to standard math nodes.
9733
9787
  * @returns The micromark syntax extension.
9734
9788
  */
9735
9789
  function mathCompatibility() {
@@ -9801,8 +9855,8 @@ function parseGfmWithMath(text) {
9801
9855
  extensions: [
9802
9856
  gfm(gfmOptions),
9803
9857
  cjkFriendlyStrong(),
9804
- math(),
9805
- mathCompatibility()
9858
+ mathCompatibility(),
9859
+ math()
9806
9860
  ],
9807
9861
  mdastExtensions: [
9808
9862
  gfmFromMarkdown(),
@@ -9990,11 +10044,23 @@ function CodeBlock({ code, lang, streaming, className, contentRef, lineNumbers =
9990
10044
  //#region lib/types/markdown/file-link.js
9991
10045
  /** Local Markdown destinations accepted by the file-preview callback. */
9992
10046
  /**
9993
- * Decode a file destination and its optional GitHub-style line fragment.
9994
- * Literal `?` and `#` in filenames must be percent-encoded.
10047
+ * Recognize a relative, rooted, or absolute Windows path before URL parsing.
10048
+ * @param value - A decoded or URI-normalized destination.
10049
+ * @returns Whether a filesystem prefix makes the destination unambiguous.
10050
+ */
10051
+ function isExplicitFilePath(value) {
10052
+ return /^(?:[\\/]|\.{1,2}[\\/]|[a-z]:[\\/])/i.test(value);
10053
+ }
10054
+ /**
10055
+ * Decode a file destination with a fragment, line range, or line/column suffix.
10056
+ * Explicit relative, slash/backslash-rooted, and Windows drive paths take
10057
+ * precedence over URLs. Other parseable absolute URLs are not file links.
10058
+ * Fragments take precedence over colon suffixes; invalid locations open the
10059
+ * file without selecting a line. Columns are consumed but not selected.
10060
+ * Percent-encode literal `?`, `#`, and numeric colon suffixes in filenames.
9995
10061
  * @param value - Parsed Markdown link destination.
9996
10062
  * @returns A local path and optional first line, or undefined for URLs,
9997
- * fragment-only links, queries, malformed escapes, or invalid line ranges.
10063
+ * fragment-only links, queries, malformed escapes, or control characters.
9998
10064
  */
9999
10065
  function parseFileLink(value) {
10000
10066
  const hash = value.indexOf("#");
@@ -10006,14 +10072,16 @@ function parseFileLink(value) {
10006
10072
  } catch (_error) {
10007
10073
  return;
10008
10074
  }
10009
- if (path.length === 0 || /[\u0000-\u001f\u007f]/.test(path) || /^[\\/]{2}/.test(path) || /^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) return void 0;
10010
- if (hash < 0) return { path };
10011
- const fragment = value.slice(hash + 1);
10012
- const match = /^L([1-9]\d*)(?:-L([1-9]\d*))?$/.exec(fragment);
10013
- if (match === null) return void 0;
10075
+ if (path.length === 0 || /[\u0000-\u001f\u007f]/.test(path)) return void 0;
10076
+ if (!isExplicitFilePath(path) && URL.canParse(path)) return void 0;
10077
+ const suffix = hash < 0 ? /:(\d+)(?::\d+|-(\d+))?$/.exec(destination) : null;
10078
+ if (suffix !== null) path = path.slice(0, -suffix[0].length);
10079
+ if (path.length === 0) return void 0;
10080
+ const match = suffix ?? (hash < 0 ? null : /^L(\d+)(?:-L(\d+))?$/.exec(value.slice(hash + 1)));
10081
+ if (match === null) return { path };
10014
10082
  const line = Number(match[1]);
10015
10083
  const end = match[2] === void 0 ? line : Number(match[2]);
10016
- if (!Number.isSafeInteger(line) || !Number.isSafeInteger(end) || end < line) return void 0;
10084
+ if (!Number.isSafeInteger(line) || !Number.isSafeInteger(end) || line < 1 || end < line) return { path };
10017
10085
  return {
10018
10086
  path,
10019
10087
  line
@@ -10110,15 +10178,17 @@ const MarkdownDelegateContext = createContext({});
10110
10178
  * @param props - Child tree and its file and HTTP(S) link handlers.
10111
10179
  * @returns the scoped child tree.
10112
10180
  */
10113
- function MarkdownDelegateProvider({ children, openExternalLink, openFile, fileImages }) {
10181
+ function MarkdownDelegateProvider({ children, openExternalLink, openFile, fileImages, getTriggerProps }) {
10114
10182
  const delegate = useMemo(() => ({
10115
10183
  openExternalLink,
10116
10184
  openFile,
10117
- fileImages
10185
+ fileImages,
10186
+ getTriggerProps
10118
10187
  }), [
10119
10188
  openExternalLink,
10120
10189
  openFile,
10121
- fileImages
10190
+ fileImages,
10191
+ getTriggerProps
10122
10192
  ]);
10123
10193
  return jsx(MarkdownDelegateContext.Provider, {
10124
10194
  value: delegate,
@@ -10144,16 +10214,18 @@ function useMarkdownDelegate() {
10144
10214
  * @param props.src - the original image URL.
10145
10215
  * @param props.alt - the image's alt text.
10146
10216
  * @param props.labels - dialog and close-control strings.
10217
+ * @param props.contextMenuProps - optional original-image gesture bindings.
10147
10218
  * @param props.onClose - dismiss callback owned by the opener.
10148
10219
  * @returns the modal preview dialog.
10149
10220
  */
10150
- function ImageLightbox({ src, alt, labels, onClose }) {
10221
+ function ImageLightbox({ src, alt, labels, onClose, contextMenuProps }) {
10151
10222
  const closeRef = useRef(null);
10152
10223
  const restoreRef = useRef(null);
10153
10224
  useEffect(() => {
10154
10225
  restoreRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
10155
10226
  closeRef.current?.focus();
10156
10227
  const onKeyDown = (event) => {
10228
+ if (event.defaultPrevented || document.activeElement?.closest("[role=\"menu\"]")) return;
10157
10229
  if (event.key === "Escape") {
10158
10230
  event.stopPropagation();
10159
10231
  onClose();
@@ -10185,7 +10257,8 @@ function ImageLightbox({ src, alt, labels, onClose }) {
10185
10257
  jsx("img", {
10186
10258
  className: css$38.image,
10187
10259
  src,
10188
- alt
10260
+ alt,
10261
+ ...contextMenuProps
10189
10262
  }),
10190
10263
  jsx("button", {
10191
10264
  ref: closeRef,
@@ -10242,30 +10315,15 @@ function Preview({ src, alt, loadingLabel, failedLabel }) {
10242
10315
  }
10243
10316
  //#endregion
10244
10317
  //#region lib/types/markdown/render.js
10245
- /**
10246
- * Direct mdast→React markdown renderer. Replaces the react-markdown /
10247
- * remark-rehype pipeline with one switch over parsed nodes so streaming can
10248
- * cache frozen blocks as React elements; the rendered DOM is pinned
10249
- * byte-for-byte by `tests/fixtures/markdown-dom` and must not drift.
10250
- *
10251
- * External link and image destinations pass a protocol allowlist; settled
10252
- * local file links use an explicit owner callback. Images additionally require
10253
- * absolute HTTP(S), raw HTML renders as literal text (no HTML enters the
10254
- * DOM), and KaTeX runs without trusted commands. Fragment-anchor URLs fail
10255
- * the allowlist, so footnote references and back-references render as plain
10256
- * text rather than in-page links.
10257
- *
10258
- * Merge-extensible node unions fall through the documented default (render
10259
- * nothing) rather than ending in assertNever: grammars registered elsewhere
10260
- * may add node types this renderer has no mapping for.
10261
- */
10262
10318
  function sanitizeUrl(url) {
10319
+ if (isExplicitFilePath(url)) return "";
10263
10320
  try {
10264
10321
  switch (new URL(url).protocol) {
10265
- case "http:":
10266
- case "https:":
10267
- case "mailto:": return url;
10268
- default: return "";
10322
+ case "javascript:":
10323
+ case "vbscript:":
10324
+ case "data:":
10325
+ case "blob:": return "";
10326
+ default: return url;
10269
10327
  }
10270
10328
  } catch {
10271
10329
  return "";
@@ -10427,6 +10485,7 @@ function renderNode(node, key, context) {
10427
10485
  title: mention.title,
10428
10486
  "aria-label": mention.label,
10429
10487
  onClick: mention.open,
10488
+ ...mention.contextMenuProps,
10430
10489
  children: [jsx(LinkIconMedium, {
10431
10490
  kind: classifyLinkPath(value),
10432
10491
  className: markdownCss.linkIcon
@@ -10548,7 +10607,7 @@ function renderTableRow(row, cellTag, align, key, context) {
10548
10607
  function anchorWrapsOnlyImages(children) {
10549
10608
  return children.length > 0 && children.every((child) => child.type === "image" || child.type === "imageReference");
10550
10609
  }
10551
- /** Anchor over an already-authored href: allowlisted or unwrapped, with optional owner navigation for HTTP(S). */
10610
+ /** Anchor over a safe absolute href, with optional owner navigation for HTTP(S). */
10552
10611
  function renderSafeLink(href, children, key, glyph = true) {
10553
10612
  const safeHref = sanitizeUrl(href);
10554
10613
  if (safeHref === "") return jsx(Fragment$1, { children }, key);
@@ -10559,11 +10618,15 @@ function renderSafeLink(href, children, key, glyph = true) {
10559
10618
  }, key);
10560
10619
  }
10561
10620
  function MarkdownAnchor({ href, glyph, children }) {
10562
- const { openExternalLink } = useMarkdownDelegate();
10621
+ const { openExternalLink, getTriggerProps } = useMarkdownDelegate();
10563
10622
  const external = ["http:", "https:"].includes(new URL(href).protocol);
10564
10623
  const open = external ? openExternalLink : void 0;
10565
10624
  return jsxs("a", {
10566
10625
  href,
10626
+ ...external ? getTriggerProps?.({
10627
+ kind: "url",
10628
+ url: href
10629
+ }) : {},
10567
10630
  ...external ? {
10568
10631
  target: "_blank",
10569
10632
  rel: "noopener noreferrer"
@@ -10582,16 +10645,19 @@ function MarkdownAnchor({ href, glyph, children }) {
10582
10645
  }
10583
10646
  /** Local destinations use the scoped file delegate after settlement. */
10584
10647
  function renderAnchor(url, children, key, glyph = true, streaming = false) {
10585
- const file = streaming ? void 0 : parseFileLink(url);
10586
- if (file !== void 0) return jsx(MarkdownFileLink, {
10587
- file,
10588
- glyph,
10589
- children
10590
- }, key);
10648
+ const file = parseFileLink(url);
10649
+ if (file !== void 0) {
10650
+ if (streaming) return jsx(Fragment$1, { children }, key);
10651
+ return jsx(MarkdownFileLink, {
10652
+ file,
10653
+ glyph,
10654
+ children
10655
+ }, key);
10656
+ }
10591
10657
  return renderSafeLink(normalizeUri(url), children, key, glyph);
10592
10658
  }
10593
10659
  function MarkdownFileLink({ file, glyph, children }) {
10594
- const { openFile, fileImages } = useMarkdownDelegate();
10660
+ const { openFile, fileImages, getTriggerProps } = useMarkdownDelegate();
10595
10661
  const [load] = useState(nextImageLoad);
10596
10662
  if (openFile === void 0) return jsx(Fragment, { children });
10597
10663
  const preview = glyph && classifyLinkPath(file.path) === "image" ? fileImages : void 0;
@@ -10601,6 +10667,10 @@ function MarkdownFileLink({ file, glyph, children }) {
10601
10667
  type: "button",
10602
10668
  className: clsx(markdownCss.fileMention, markdownCss.fileLink),
10603
10669
  title: src === void 0 ? file.path : void 0,
10670
+ ...getTriggerProps?.({
10671
+ kind: "file",
10672
+ ...file
10673
+ }),
10604
10674
  onClick: () => {
10605
10675
  openFile(file.path, file.line === void 0 ? void 0 : { line: file.line });
10606
10676
  },
@@ -10664,6 +10734,7 @@ function MarkdownImage({ destination, alt, pathImages, streaming, inLink }) {
10664
10734
  }, src);
10665
10735
  }
10666
10736
  function LoadedMarkdownImage({ src, alt, destination, preview }) {
10737
+ const { getTriggerProps } = useMarkdownDelegate();
10667
10738
  const [failed, setFailed] = useState(false);
10668
10739
  const [open, setOpen] = useState(false);
10669
10740
  const close = useCallback(() => {
@@ -10673,6 +10744,12 @@ function LoadedMarkdownImage({ src, alt, destination, preview }) {
10673
10744
  className: markdownCss.imageAlt,
10674
10745
  children: [preview === void 0 ? "" : `${preview.labels.failed} · `, alt || destination]
10675
10746
  });
10747
+ const file = parseFileLink(destination);
10748
+ const contextMenuProps = getTriggerProps?.({
10749
+ kind: "image",
10750
+ url: src,
10751
+ ...file === void 0 ? {} : { path: file.path }
10752
+ });
10676
10753
  const imageProps = {
10677
10754
  className: markdownCss.image,
10678
10755
  src,
@@ -10684,8 +10761,10 @@ function LoadedMarkdownImage({ src, alt, destination, preview }) {
10684
10761
  decoding: "async",
10685
10762
  referrerPolicy: "no-referrer"
10686
10763
  };
10687
- if (preview === void 0) return jsx("img", { ...imageProps });
10688
- const file = parseFileLink(destination);
10764
+ if (preview === void 0) return jsx("img", {
10765
+ ...imageProps,
10766
+ ...contextMenuProps
10767
+ });
10689
10768
  const localFileName = file?.path.split(/[\\/]/u).at(-1);
10690
10769
  const urlFileName = destination.split("/").at(-1)?.split(/[?#]/u)[0];
10691
10770
  const exportName = localFileName || urlFileName || "image";
@@ -10699,6 +10778,7 @@ function LoadedMarkdownImage({ src, alt, destination, preview }) {
10699
10778
  type: "button",
10700
10779
  className: markdownCss.imageButton,
10701
10780
  title: preview.labels.open,
10781
+ ...contextMenuProps,
10702
10782
  "aria-label": alt ? `${preview.labels.open}: ${alt}` : preview.labels.open,
10703
10783
  onClick: () => {
10704
10784
  setOpen(true);
@@ -10708,7 +10788,8 @@ function LoadedMarkdownImage({ src, alt, destination, preview }) {
10708
10788
  src,
10709
10789
  alt,
10710
10790
  labels: preview.labels,
10711
- onClose: close
10791
+ onClose: close,
10792
+ contextMenuProps
10712
10793
  })] });
10713
10794
  }
10714
10795
  /** The bracketed source text a reference reverts to when its definition is missing. */
@@ -10936,7 +11017,9 @@ var StreamingRenderer = class {
10936
11017
  * renderers, such as package READMEs. `textInteractionSource` marks the
10937
11018
  * existing root as a source for text selection interactions.
10938
11019
  * The provider's `openFile` enables local Markdown links in settled messages,
10939
- * including `#L24` and `#L24-L30` destinations (ranges open at their first line).
11020
+ * including `#L24` / `#L24-L30` fragments and `:24` / `:24-30` / `:24:5` suffixes
11021
+ * (ranges open at their first line, columns are ignored, and invalid locations
11022
+ * open only the file; see the README for URL/path classification).
10940
11023
  * @returns A GFM document with TeX math rendered through KaTeX; raw HTML never
10941
11024
  * renders as markup, and unsafe protocols are disabled. Local links without an opener remain text;
10942
11025
  * absolute HTTP(S) images render directly.
@@ -11738,6 +11821,6 @@ function formatQuoteText(text) {
11738
11821
  return text.replace(/\r\n?/gu, "\n").split("\n").map((line) => `> ${line}`).join("\n");
11739
11822
  }
11740
11823
  //#endregion
11741
- export { AnimatedRows, BrandWordmark, Button, CODE_HIGHLIGHT_EXTENSIONS, Checkbox, CodeBlock, CommandText, ConnectionIndicator, DEFAULT_DIFF_MAX_LINES, DEFAULT_READ_MAX_LINES, DEFAULT_SEARCH_MAX_LINES, DEFAULT_TERMINAL_MAX_LINES, DOCUMENT_ZOOM, DetailDocument, DiffBlock, DisclosureRow, DraggableImage, FISH_LOGO_PATH, FISH_LOGO_VIEWBOX, FileTypeIcon, FishLogo, GuideArtworkBrowser, GuideArtworkFiles, HoverCard, HoverCardGroup, ICON_MEDIUM_STROKE, ICON_REGULAR_STROKE, ICON_SYMBOLS, IconAgentPresetOutlineMedium, IconAgentPresetOutlineRegular, IconAlarmClockOutlineMedium, IconAlarmClockOutlineRegular, IconApiOutlineMedium, IconApiOutlineRegular, IconAppsAddOutlineMedium, IconAppsAddOutlineRegular, IconArchiveCheckOutlineMedium, IconArchiveCheckOutlineRegular, IconArchiveOffOutlineMedium, IconArchiveOffOutlineRegular, IconArchiveOutlineMedium, IconArchiveOutlineRegular, IconBranchOutlineMedium, IconBranchOutlineRegular, IconBrowseOutlineMedium, IconBrowseOutlineRegular, IconCheckCircleFillMedium, IconCheckCircleFillRegular, IconCheckCircleOutlineMedium, IconCheckCircleOutlineRegular, IconCheckOutlineMedium, IconCheckOutlineRegular, IconChecklistOutlineMedium, IconChecklistOutlineRegular, IconChevronDownOutlineMedium, IconChevronDownOutlineRegular, IconChevronLeftOutlineMedium, IconChevronLeftOutlineRegular, IconChevronRightOutlineMedium, IconChevronRightOutlineRegular, IconChevronUpOutlineMedium, IconChevronUpOutlineRegular, IconChevronsUpDownOutlineMedium, IconChevronsUpDownOutlineRegular, IconClockOutlineMedium, IconClockOutlineRegular, IconCloseCircleFillMedium, IconCloseCircleFillRegular, IconCloseFillMedium, IconCloseFillRegular, IconCloseOutlineMedium, IconCloseOutlineRegular, IconCodeOutlineMedium, IconCodeOutlineRegular, IconCompactOutlineMedium, IconCompactOutlineRegular, IconCompareSplitOutlineMedium, IconCompareSplitOutlineRegular, IconContextInjectionOutlineMedium, IconContextInjectionOutlineRegular, IconCopyOutlineMedium, IconCopyOutlineRegular, IconCordisPluginOutlineMedium, IconCordisPluginOutlineRegular, IconDarkOutlineMedium, IconDarkOutlineRegular, IconDataOutlineMedium, IconDataOutlineRegular, IconDatabaseOutlineMedium, IconDatabaseOutlineRegular, IconDeliverDocMedium, IconDeliverDocRegular, IconDislikeFillMedium, IconDislikeFillRegular, IconDislikeOutlineMedium, IconDislikeOutlineRegular, IconDownloadOutlineMedium, IconDownloadOutlineRegular, IconDragHandleOutlineMedium, IconDragHandleOutlineRegular, IconEditOutlineMedium, IconEditOutlineRegular, IconEllipsisOutlineMedium, IconEllipsisOutlineRegular, IconEnhanceOutlineMedium, IconEnhanceOutlineRegular, IconFlatListOutlineMedium, IconFlatListOutlineRegular, IconFolderCloseMedium, IconFolderCloseRegular, IconFolderOpenMedium, IconFolderOpenOutlineMedium, IconFolderOpenOutlineRegular, IconFolderOpenRegular, IconFollowsystemOutlineMedium, IconFollowsystemOutlineRegular, IconFullscreenOutlineMedium, IconFullscreenOutlineRegular, IconGaugeOutlineMedium, IconGaugeOutlineRegular, IconGlobeOutlineMedium, IconGlobeOutlineRegular, IconGoalOutlineMedium, IconGoalOutlineRegular, IconInfoOutlineMedium, IconInfoOutlineRegular, IconInspectOutlineMedium, IconInspectOutlineRegular, IconLightOutlineMedium, IconLightOutlineRegular, IconLikeFillMedium, IconLikeFillRegular, IconLikeOutlineMedium, IconLikeOutlineRegular, IconLinkOutlineMedium, IconLinkOutlineRegular, IconListPenOutlineMedium, IconListPenOutlineRegular, IconLoadingOutlineMedium, IconLoadingOutlineRegular, IconMicrophoneOutlineMedium, IconMicrophoneOutlineRegular, IconNewChatOutlineMedium, IconNewChatOutlineRegular, IconNowrapFillMedium, IconNowrapFillRegular, IconPanelLeftOutlineMedium, IconPanelLeftOutlineRegular, IconPaperPlaneOutlineMedium, IconPaperPlaneOutlineRegular, IconPaperclipOutlineMedium, IconPaperclipOutlineRegular, IconPauseOutlineMedium, IconPauseOutlineRegular, IconPersonalizationOutlineMedium, IconPersonalizationOutlineRegular, IconPinFillMedium, IconPinFillRegular, IconPinOutlineMedium, IconPinOutlineRegular, IconPlanOutlineMedium, IconPlanOutlineRegular, IconPlayOutlineMedium, IconPlayOutlineRegular, IconPluginPinwheelOutlineMedium, IconPluginPinwheelOutlineRegular, IconPlusOutlineMedium, IconPlusOutlineRegular, IconProjectAddOutlineMedium, IconProjectAddOutlineRegular, IconQuestionOutlineMedium, IconQuestionOutlineRegular, IconQueueOutlineMedium, IconQueueOutlineRegular, IconRefreshOutlineMedium, IconRefreshOutlineRegular, IconRightUpOutlineMedium, IconRightUpOutlineRegular, IconSearchOutlineMedium, IconSearchOutlineRegular, IconSendOutlineMedium, IconSendOutlineRegular, IconSettingsOutlineMedium, IconSettingsOutlineRegular, IconShareOutlineMedium, IconShareOutlineRegular, IconShieldOutlineMedium, IconShieldOutlineRegular, IconSkillOutlineMedium, IconSkillOutlineRegular, IconSlidersTwoOutlineMedium, IconSlidersTwoOutlineRegular, IconSparkleMedium, IconSparkleRegular, IconStopFillMedium, IconStopFillRegular, IconThinkOutlineMedium, IconThinkOutlineRegular, IconTrashOutlineMedium, IconTrashOutlineRegular, IconTreeCornerMedium, IconTreeCornerRegular, IconTriangleRightFillMedium, IconTriangleRightFillRegular, IconUnarchiveOutlineMedium, IconUnarchiveOutlineRegular, IconUserOutlineMedium, IconUserOutlineRegular, IconUsersOutlineMedium, IconUsersOutlineRegular, IconWarningOutlineMedium, IconWarningOutlineRegular, IconWarningTriangleOutlineMedium, IconWarningTriangleOutlineRegular, IconWorkspaceTreeOutlineMedium, IconWorkspaceTreeOutlineRegular, IconWrapFillMedium, IconWrapFillRegular, IconWrapLinesOutlineMedium, IconWrapLinesOutlineRegular, ImageLightbox, InlineEditor, Input, JsonBlock, JsonTree, LinkIconMedium, LinkIconRegular, MarkdownDelegateProvider, MarkdownText, Menu, MenuGroup, MenuItemButton, MenuSurface, Modal, PathLabel, PermissionIconAutoReviewMedium, PermissionIconAutoReviewRegular, PermissionIconFullAccessMedium, PermissionIconFullAccessRegular, PermissionIconReadOnlyMedium, PermissionIconReadOnlyRegular, PermissionIconWorkspaceWriteMedium, PermissionIconWorkspaceWriteRegular, Pill, PluginArtworkDefault, PluginArtworkLoop, PluginArtworkSearch, PluginArtworkSubagent, PluginArtworkTerminal, QuotePreview, ReadBlock, ReferenceChip, ReferenceIconMedium, ReferenceIconRegular, RiskConfirmation, SHIELD_OUTLINE_PATH, SearchBlock, SegmentedControl, SegmentedTabs, SettingsForm, SettingsFormModel, SettingsSecretField, SettingsValueField, ShortcutKeys, StateDot, Switch, Tag, TerminalBlock, TextShimmer, Toast, Tooltip, UserMessageBubble, UserTextRun, WebBlock, ZoomControls, classifyFileType, classifyLinkPath, closeTopModal, detailDocumentState, diffTotals, extractMarkdownPlainText, fileExtension, fileSizeText, focusWithoutRing, formatQuoteText, isBehindModal, isDarwinDesktop, isMobileDevice, languageForPath, modalSelector, observeComposition, observeStickyMenuGroups, pointerModality, rankByName, relativeTime, settingsNumberField, settingsTextField, useAnchoredMaxHeight, useAnchoredPosition, useClipboardCopy, useCodeHighlighter, useDetailDocumentLabels, useDismissOnOutsidePointer, useModalLayer, useRowDragPreview, writeClipboard };
11824
+ export { AnimatedRows, BrandWordmark, Button, CODE_HIGHLIGHT_EXTENSIONS, Checkbox, CodeBlock, CommandText, ConnectionIndicator, DEFAULT_DIFF_MAX_LINES, DEFAULT_READ_MAX_LINES, DEFAULT_SEARCH_MAX_LINES, DEFAULT_TERMINAL_MAX_LINES, DOCUMENT_ZOOM, DetailDocument, DiffBlock, DisclosureRow, DraggableImage, FISH_LOGO_PATH, FISH_LOGO_VIEWBOX, FileTypeIcon, FishLogo, GuideArtworkBrowser, GuideArtworkFiles, HoverCard, HoverCardGroup, ICON_MEDIUM_STROKE, ICON_REGULAR_STROKE, ICON_SYMBOLS, IconAgentPresetOutlineMedium, IconAgentPresetOutlineRegular, IconAlarmClockOutlineMedium, IconAlarmClockOutlineRegular, IconApiOutlineMedium, IconApiOutlineRegular, IconAppsAddOutlineMedium, IconAppsAddOutlineRegular, IconArchiveCheckOutlineMedium, IconArchiveCheckOutlineRegular, IconArchiveOffOutlineMedium, IconArchiveOffOutlineRegular, IconArchiveOutlineMedium, IconArchiveOutlineRegular, IconBranchOutlineMedium, IconBranchOutlineRegular, IconBrowseOutlineMedium, IconBrowseOutlineRegular, IconCheckCircleFillMedium, IconCheckCircleFillRegular, IconCheckCircleOutlineMedium, IconCheckCircleOutlineRegular, IconCheckOutlineMedium, IconCheckOutlineRegular, IconChecklistOutlineMedium, IconChecklistOutlineRegular, IconChevronDownOutlineMedium, IconChevronDownOutlineRegular, IconChevronLeftOutlineMedium, IconChevronLeftOutlineRegular, IconChevronRightOutlineMedium, IconChevronRightOutlineRegular, IconChevronUpOutlineMedium, IconChevronUpOutlineRegular, IconChevronsUpDownOutlineMedium, IconChevronsUpDownOutlineRegular, IconClockOutlineMedium, IconClockOutlineRegular, IconCloseCircleFillMedium, IconCloseCircleFillRegular, IconCloseFillMedium, IconCloseFillRegular, IconCloseOutlineMedium, IconCloseOutlineRegular, IconCodeOutlineMedium, IconCodeOutlineRegular, IconCompactOutlineMedium, IconCompactOutlineRegular, IconCompareSplitOutlineMedium, IconCompareSplitOutlineRegular, IconContextInjectionOutlineMedium, IconContextInjectionOutlineRegular, IconCopyOutlineMedium, IconCopyOutlineRegular, IconCordisPluginOutlineMedium, IconCordisPluginOutlineRegular, IconDarkOutlineMedium, IconDarkOutlineRegular, IconDataOutlineMedium, IconDataOutlineRegular, IconDatabaseOutlineMedium, IconDatabaseOutlineRegular, IconDeliverDocMedium, IconDeliverDocRegular, IconDislikeFillMedium, IconDislikeFillRegular, IconDislikeOutlineMedium, IconDislikeOutlineRegular, IconDownloadOutlineMedium, IconDownloadOutlineRegular, IconDragHandleOutlineMedium, IconDragHandleOutlineRegular, IconEditOutlineMedium, IconEditOutlineRegular, IconEllipsisOutlineMedium, IconEllipsisOutlineRegular, IconEnhanceOutlineMedium, IconEnhanceOutlineRegular, IconFlatListOutlineMedium, IconFlatListOutlineRegular, IconFolderCloseMedium, IconFolderCloseRegular, IconFolderOpenMedium, IconFolderOpenOutlineMedium, IconFolderOpenOutlineRegular, IconFolderOpenRegular, IconFollowsystemOutlineMedium, IconFollowsystemOutlineRegular, IconFullscreenOutlineMedium, IconFullscreenOutlineRegular, IconGaugeOutlineMedium, IconGaugeOutlineRegular, IconGlobeOutlineMedium, IconGlobeOutlineRegular, IconGoalOutlineMedium, IconGoalOutlineRegular, IconInfoOutlineMedium, IconInfoOutlineRegular, IconInspectOutlineMedium, IconInspectOutlineRegular, IconLightOutlineMedium, IconLightOutlineRegular, IconLikeFillMedium, IconLikeFillRegular, IconLikeOutlineMedium, IconLikeOutlineRegular, IconLinkOutlineMedium, IconLinkOutlineRegular, IconListPenOutlineMedium, IconListPenOutlineRegular, IconLoadingOutlineMedium, IconLoadingOutlineRegular, IconMicrophoneOutlineMedium, IconMicrophoneOutlineRegular, IconNewChatOutlineMedium, IconNewChatOutlineRegular, IconNowrapFillMedium, IconNowrapFillRegular, IconPanelLeftOutlineMedium, IconPanelLeftOutlineRegular, IconPaperPlaneOutlineMedium, IconPaperPlaneOutlineRegular, IconPaperclipOutlineMedium, IconPaperclipOutlineRegular, IconPauseOutlineMedium, IconPauseOutlineRegular, IconPersonalizationOutlineMedium, IconPersonalizationOutlineRegular, IconPinFillMedium, IconPinFillRegular, IconPinOutlineMedium, IconPinOutlineRegular, IconPlanOutlineMedium, IconPlanOutlineRegular, IconPlayOutlineMedium, IconPlayOutlineRegular, IconPluginPinwheelOutlineMedium, IconPluginPinwheelOutlineRegular, IconPlusOutlineMedium, IconPlusOutlineRegular, IconProjectAddOutlineMedium, IconProjectAddOutlineRegular, IconQuestionOutlineMedium, IconQuestionOutlineRegular, IconQueueOutlineMedium, IconQueueOutlineRegular, IconRefreshOutlineMedium, IconRefreshOutlineRegular, IconRightUpOutlineMedium, IconRightUpOutlineRegular, IconSaveOutlineMedium, IconSaveOutlineRegular, IconSearchOutlineMedium, IconSearchOutlineRegular, IconSendOutlineMedium, IconSendOutlineRegular, IconSettingsOutlineMedium, IconSettingsOutlineRegular, IconShareOutlineMedium, IconShareOutlineRegular, IconShieldOutlineMedium, IconShieldOutlineRegular, IconSkillOutlineMedium, IconSkillOutlineRegular, IconSlidersTwoOutlineMedium, IconSlidersTwoOutlineRegular, IconSparkleMedium, IconSparkleRegular, IconStopFillMedium, IconStopFillRegular, IconThinkOutlineMedium, IconThinkOutlineRegular, IconTrashOutlineMedium, IconTrashOutlineRegular, IconTreeCornerMedium, IconTreeCornerRegular, IconTriangleRightFillMedium, IconTriangleRightFillRegular, IconUnarchiveOutlineMedium, IconUnarchiveOutlineRegular, IconUserOutlineMedium, IconUserOutlineRegular, IconUsersOutlineMedium, IconUsersOutlineRegular, IconWarningOutlineMedium, IconWarningOutlineRegular, IconWarningTriangleOutlineMedium, IconWarningTriangleOutlineRegular, IconWorkspaceTreeOutlineMedium, IconWorkspaceTreeOutlineRegular, IconWrapFillMedium, IconWrapFillRegular, IconWrapLinesOutlineMedium, IconWrapLinesOutlineRegular, ImageLightbox, InlineEditor, Input, JsonBlock, JsonTree, LinkIconMedium, LinkIconRegular, MENU_TRANSITION_MS, MarkdownDelegateProvider, MarkdownText, Menu, MenuGroup, MenuItemButton, MenuSurface, Modal, PathLabel, PermissionIconAutoReviewMedium, PermissionIconAutoReviewRegular, PermissionIconFullAccessMedium, PermissionIconFullAccessRegular, PermissionIconReadOnlyMedium, PermissionIconReadOnlyRegular, PermissionIconWorkspaceWriteMedium, PermissionIconWorkspaceWriteRegular, Pill, PluginArtworkDefault, PluginArtworkLoop, PluginArtworkSearch, PluginArtworkSubagent, PluginArtworkTerminal, QuotePreview, ReadBlock, ReferenceChip, ReferenceIconMedium, ReferenceIconRegular, RiskConfirmation, SHIELD_OUTLINE_PATH, SearchBlock, SegmentedControl, SegmentedTabs, SettingsForm, SettingsFormModel, SettingsSecretField, SettingsValueField, ShortcutKeys, StateDot, Switch, Tag, TerminalBlock, TextShimmer, Toast, Tooltip, UserMessageBubble, UserTextRun, WebBlock, ZoomControls, classifyFileType, classifyLinkPath, closeTopModal, detailDocumentState, diffTotals, extractMarkdownPlainText, fileExtension, fileSizeText, focusWithoutRing, formatQuoteText, isBehindModal, isDarwinDesktop, isMobileDevice, languageForPath, modalSelector, observeComposition, observeStickyMenuGroups, pointerModality, rankByName, relativeTime, settingsNumberField, settingsTextField, useAnchoredMaxHeight, useAnchoredPosition, useClipboardCopy, useCodeHighlighter, useDetailDocumentLabels, useDismissOnOutsidePointer, useMarkdownDelegate, useModalLayer, useRowDragPreview, writeClipboard };
11742
11825
 
11743
11826
  //# sourceMappingURL=index.js.map