@dxos/react-ui 0.6.8-main.3be982f → 0.6.8-staging.63bcb81

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.
@@ -1260,7 +1260,9 @@ var TreegridRoot = /* @__PURE__ */ forwardRef16(({ asChild, classNames, children
1260
1260
  const { tx } = useThemeContext();
1261
1261
  const Root3 = asChild ? Slot9 : Primitive8.div;
1262
1262
  const arrowNavigationAttrs = useArrowNavigationGroup({
1263
- axis: "vertical"
1263
+ axis: "vertical",
1264
+ tabbable: false,
1265
+ circular: true
1264
1266
  });
1265
1267
  return /* @__PURE__ */ React19.createElement(Root3, {
1266
1268
  role: "treegrid",
@@ -1284,11 +1286,14 @@ var TreegridRow = /* @__PURE__ */ forwardRef16(({ __treegridRowScope, asChild, c
1284
1286
  onChange: propsOnOpenChange,
1285
1287
  defaultProp: defaultOpen
1286
1288
  });
1287
- const focusableGroupAttrs = useFocusableGroup();
1289
+ const focusableGroupAttrs = useFocusableGroup({
1290
+ tabBehavior: "limited"
1291
+ });
1288
1292
  const arrowGroupAttrs = useArrowNavigationGroup({
1289
1293
  axis: "horizontal",
1290
- tabbable: true,
1291
- circular: false
1294
+ tabbable: false,
1295
+ circular: false,
1296
+ memorizeCurrent: false
1292
1297
  });
1293
1298
  return /* @__PURE__ */ React19.createElement(TreegridRowProvider, {
1294
1299
  open,
@@ -1337,6 +1342,8 @@ var Treegrid = {
1337
1342
  };
1338
1343
 
1339
1344
  // packages/ui/react-ui/src/components/Main/Main.tsx
1345
+ import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
1346
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
1340
1347
  import { createContext as createContext8 } from "@radix-ui/react-context";
1341
1348
  import { Root as DialogRoot2, DialogContent as DialogContent2 } from "@radix-ui/react-dialog";
1342
1349
  import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
@@ -1450,13 +1457,42 @@ var NAVIGATION_SIDEBAR_NAME = "NavigationSidebar";
1450
1457
  var COMPLEMENTARY_SIDEBAR_NAME = "ComplementarySidebar";
1451
1458
  var MAIN_NAME = "Main";
1452
1459
  var GENERIC_CONSUMER_NAME = "GenericConsumer";
1460
+ var landmarkAttr = "data-main-landmark";
1461
+ var useLandmarkMover = (propsOnKeyDown, landmark) => {
1462
+ const handleKeyDown = useCallback3((event) => {
1463
+ const target = event.target;
1464
+ if (event.target === event.currentTarget && event.key === "Tab" && target.hasAttribute(landmarkAttr)) {
1465
+ event.preventDefault();
1466
+ const landmarks = Array.from(document.querySelectorAll(`[${landmarkAttr}]:not([inert])`)).map((el) => el.hasAttribute(landmarkAttr) ? parseInt(el.getAttribute(landmarkAttr)) : NaN).sort();
1467
+ const l = landmarks.length;
1468
+ const cursor = landmarks.indexOf(parseInt(target.getAttribute(landmarkAttr)));
1469
+ const nextLandmark = landmarks[(cursor + l + (event.getModifierState("Shift") ? -1 : 1)) % l];
1470
+ document.querySelector(`[${landmarkAttr}="${nextLandmark}"]`)?.focus();
1471
+ }
1472
+ propsOnKeyDown?.(event);
1473
+ }, [
1474
+ propsOnKeyDown
1475
+ ]);
1476
+ const focusableAttrs = useFocusableGroup2({
1477
+ tabBehavior: "limited",
1478
+ ignoreDefaultKeydown: {
1479
+ Tab: true
1480
+ }
1481
+ });
1482
+ return {
1483
+ onKeyDown: handleKeyDown,
1484
+ [landmarkAttr]: landmark,
1485
+ tabIndex: 0,
1486
+ ...focusableAttrs
1487
+ };
1488
+ };
1453
1489
  var [MainProvider, useMainContext] = createContext8(MAIN_NAME, {
1454
1490
  resizing: false,
1455
1491
  navigationSidebarOpen: false,
1456
1492
  setNavigationSidebarOpen: (nextOpen) => {
1457
1493
  log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
1458
1494
  F: __dxlog_file,
1459
- L: 49,
1495
+ L: 81,
1460
1496
  S: void 0,
1461
1497
  C: (f, a) => f(...a)
1462
1498
  });
@@ -1465,7 +1501,7 @@ var [MainProvider, useMainContext] = createContext8(MAIN_NAME, {
1465
1501
  setComplementarySidebarOpen: (nextOpen) => {
1466
1502
  log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
1467
1503
  F: __dxlog_file,
1468
- L: 54,
1504
+ L: 86,
1469
1505
  S: void 0,
1470
1506
  C: (f, a) => f(...a)
1471
1507
  });
@@ -1556,6 +1592,14 @@ var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToD
1556
1592
  useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
1557
1593
  onDismiss: () => setOpen(false)
1558
1594
  });
1595
+ const handleKeyDown = useCallback3((event) => {
1596
+ if (event.key === "Escape") {
1597
+ event.target.closest("[data-tabster]")?.focus();
1598
+ }
1599
+ props.onKeyDown?.(event);
1600
+ }, [
1601
+ props.onKeyDown
1602
+ ]);
1559
1603
  const Root3 = isLg ? Primitive9.div : DialogContent2;
1560
1604
  return /* @__PURE__ */ React20.createElement(DialogRoot2, {
1561
1605
  open,
@@ -1571,6 +1615,7 @@ var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToD
1571
1615
  "data-state": open ? "open" : "closed",
1572
1616
  "data-resizing": resizing ? "true" : "false",
1573
1617
  className: tx("main.sidebar", "main__sidebar", {}, classNames),
1618
+ onKeyDown: handleKeyDown,
1574
1619
  ...!open && {
1575
1620
  inert: "true"
1576
1621
  },
@@ -1581,7 +1626,9 @@ var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToD
1581
1626
  });
1582
1627
  var MainNavigationSidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
1583
1628
  const { navigationSidebarOpen, setNavigationSidebarOpen, resizing } = useMainContext(NAVIGATION_SIDEBAR_NAME);
1629
+ const mover = useLandmarkMover(props.onKeyDown, "0");
1584
1630
  return /* @__PURE__ */ React20.createElement(MainSidebar, {
1631
+ ...mover,
1585
1632
  ...props,
1586
1633
  open: navigationSidebarOpen,
1587
1634
  setOpen: setNavigationSidebarOpen,
@@ -1593,7 +1640,9 @@ var MainNavigationSidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) =
1593
1640
  MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
1594
1641
  var MainComplementarySidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
1595
1642
  const { complementarySidebarOpen, setComplementarySidebarOpen, resizing } = useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
1643
+ const mover = useLandmarkMover(props.onKeyDown, "2");
1596
1644
  return /* @__PURE__ */ React20.createElement(MainSidebar, {
1645
+ ...mover,
1597
1646
  ...props,
1598
1647
  open: complementarySidebarOpen,
1599
1648
  setOpen: setComplementarySidebarOpen,
@@ -1603,16 +1652,22 @@ var MainComplementarySidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef
1603
1652
  });
1604
1653
  });
1605
1654
  MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
1606
- var MainContent = /* @__PURE__ */ forwardRef17(({ asChild, classNames, bounce, children, ...props }, forwardedRef) => {
1655
+ var MainContent = /* @__PURE__ */ forwardRef17(({ asChild, classNames, bounce, handlesFocus, children, role, ...props }, forwardedRef) => {
1607
1656
  const { navigationSidebarOpen, complementarySidebarOpen } = useMainContext(MAIN_NAME);
1608
1657
  const { tx } = useThemeContext();
1609
- const Root3 = asChild ? Slot10 : "main";
1658
+ const Root3 = asChild ? Slot10 : role ? "div" : "main";
1659
+ const mover = useLandmarkMover(props.onKeyDown, "1");
1610
1660
  return /* @__PURE__ */ React20.createElement(Root3, {
1661
+ role,
1662
+ ...handlesFocus && {
1663
+ ...mover
1664
+ },
1611
1665
  ...props,
1612
1666
  "data-sidebar-inline-start-state": navigationSidebarOpen ? "open" : "closed",
1613
1667
  "data-sidebar-inline-end-state": complementarySidebarOpen ? "open" : "closed",
1614
1668
  className: tx("main.content", "main", {
1615
- bounce
1669
+ bounce,
1670
+ handlesFocus
1616
1671
  }, classNames),
1617
1672
  ref: forwardedRef
1618
1673
  }, children);
@@ -1643,11 +1698,25 @@ var MainOverlay = /* @__PURE__ */ forwardRef17(({ classNames, ...props }, forwar
1643
1698
  var MainNotch = /* @__PURE__ */ forwardRef17(({ classNames, ...props }, forwardedRef) => {
1644
1699
  const { tx } = useThemeContext();
1645
1700
  const { navigationSidebarOpen } = useMainContext(MAIN_NAME);
1646
- return /* @__PURE__ */ React20.createElement("nav", {
1701
+ const notchElement = useRef(null);
1702
+ const ref = useComposedRefs(forwardedRef, notchElement);
1703
+ const handleKeyDown = useCallback3((event) => {
1704
+ switch (event.key) {
1705
+ case "Escape":
1706
+ props?.onKeyDown?.(event);
1707
+ notchElement.current?.focus();
1708
+ }
1709
+ }, [
1710
+ props?.onKeyDown
1711
+ ]);
1712
+ const mover = useLandmarkMover(handleKeyDown, "3");
1713
+ return /* @__PURE__ */ React20.createElement("div", {
1714
+ role: "toolbar",
1715
+ ...mover,
1647
1716
  ...props,
1648
1717
  "data-nav-sidebar-state": navigationSidebarOpen ? "open" : "closed",
1649
1718
  className: tx("main.notch", "main__notch", {}, classNames),
1650
- ref: forwardedRef
1719
+ ref
1651
1720
  });
1652
1721
  });
1653
1722
  var Main = {