@dloizides/ui-nav 1.12.0 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1048,6 +1048,10 @@ var SCRIM_Z_INDEX = 1;
1048
1048
  var PANEL_Z_INDEX = 2;
1049
1049
  var NAV_ACTIVATABLE_SELECTOR = 'a, [role="button"], [role="link"]';
1050
1050
  var NAV_TOGGLE_SELECTOR = "[aria-expanded]";
1051
+ function deferClose(close) {
1052
+ if (typeof setTimeout === "function") setTimeout(close, 0);
1053
+ else close();
1054
+ }
1051
1055
  var DEFAULT_DRAWER_LABELS = {
1052
1056
  openLabel: "Menu",
1053
1057
  openHint: "Open the navigation menu",
@@ -1113,7 +1117,7 @@ var MobileDrawer = ({
1113
1117
  if (target === null) return;
1114
1118
  const activatable = target.closest(NAV_ACTIVATABLE_SELECTOR);
1115
1119
  const isToggle = activatable !== null && activatable.closest(NAV_TOGGLE_SELECTOR) !== null;
1116
- if (activatable !== null && !isToggle) onClose();
1120
+ if (activatable !== null && !isToggle) deferClose(onClose);
1117
1121
  };
1118
1122
  node.addEventListener("click", handleClick);
1119
1123
  return () => node.removeEventListener("click", handleClick);
@@ -1665,6 +1669,55 @@ var CommandPalette = ({ open, items, onClose, labels, testID }) => {
1665
1669
  )
1666
1670
  ] });
1667
1671
  };
1672
+ var MIN_TARGET = 36;
1673
+ var styles5 = StyleSheet.create({
1674
+ trigger: {
1675
+ flexDirection: "row",
1676
+ alignItems: "center",
1677
+ justifyContent: "space-between",
1678
+ columnGap: 8,
1679
+ paddingHorizontal: 12,
1680
+ minHeight: MIN_TARGET,
1681
+ borderWidth: 1,
1682
+ borderRadius: 8
1683
+ },
1684
+ label: { fontSize: 14 },
1685
+ badge: { paddingHorizontal: 6, paddingVertical: 2, borderRadius: 4, borderWidth: 1 },
1686
+ badgeText: { fontSize: 11, fontWeight: "700" }
1687
+ });
1688
+ var CommandPaletteTrigger = ({
1689
+ label,
1690
+ hint,
1691
+ shortcut,
1692
+ onPress,
1693
+ testID
1694
+ }) => {
1695
+ const { theme } = useUi();
1696
+ const colors = theme.colors;
1697
+ const primary = theme.palette.primary["500"];
1698
+ const [focused, setFocused] = React2.useState(false);
1699
+ return /* @__PURE__ */ jsxs(
1700
+ Pressable,
1701
+ {
1702
+ accessibilityHint: hint,
1703
+ accessibilityLabel: label,
1704
+ accessibilityRole: "button",
1705
+ style: [
1706
+ styles5.trigger,
1707
+ { backgroundColor: colors.surface, borderColor: colors.border },
1708
+ focusRingStyle(focused, primary)
1709
+ ],
1710
+ testID,
1711
+ onBlur: () => setFocused(false),
1712
+ onFocus: () => setFocused(true),
1713
+ onPress,
1714
+ children: [
1715
+ /* @__PURE__ */ jsx(Text, { style: [styles5.label, { color: colors.textSecondary }], children: label }),
1716
+ /* @__PURE__ */ jsx(View, { style: [styles5.badge, { borderColor: colors.border }], children: /* @__PURE__ */ jsx(Text, { style: [styles5.badgeText, { color: colors.textSecondary }], children: shortcut }) })
1717
+ ]
1718
+ }
1719
+ );
1720
+ };
1668
1721
  var LAUNCH_KEY = "k";
1669
1722
  function useCommandPaletteHotkey(onOpen, enabled = true) {
1670
1723
  useEffect(() => {
@@ -1690,6 +1743,6 @@ function accessibleNavItems(user, table, translate) {
1690
1743
  return roleRoutesToNavItems(resolveAccessibleRoutes(user, table), translate);
1691
1744
  }
1692
1745
 
1693
- export { ACTIVE_BORDER_RADIUS, APP_SHELL_SUFFIX, AppShell, BASE_INDENT, CHEVRON_ICON_SIZE, CollapsedRail, CommandPalette, DEFAULT_COLLAPSED_RAIL_MAX, DarkModeControl, NAV_ICON_SIZE, NAV_LINK_GAP, NAV_TEST_IDS, Nav, NavBar, NavExpandableItem, NavOverflowMenu, NavShell, PillNav, RAIL_FULL_BREAKPOINT, Sidebar, Topbar, accessibleNavItems, collapsedRailStyles, darkModeStyles, expandableStyles, filterCommands, isRouteActive, navStyles, pillNavStyles, resolveContentMaxWidth, resolveRailMode, roleRoutesToNavItems, useCommandPaletteHotkey, useContentMaxWidth };
1746
+ export { ACTIVE_BORDER_RADIUS, APP_SHELL_SUFFIX, AppShell, BASE_INDENT, CHEVRON_ICON_SIZE, CollapsedRail, CommandPalette, CommandPaletteTrigger, DEFAULT_COLLAPSED_RAIL_MAX, DarkModeControl, NAV_ICON_SIZE, NAV_LINK_GAP, NAV_TEST_IDS, Nav, NavBar, NavExpandableItem, NavOverflowMenu, NavShell, PillNav, RAIL_FULL_BREAKPOINT, Sidebar, Topbar, accessibleNavItems, collapsedRailStyles, darkModeStyles, expandableStyles, filterCommands, isRouteActive, navStyles, pillNavStyles, resolveContentMaxWidth, resolveRailMode, roleRoutesToNavItems, useCommandPaletteHotkey, useContentMaxWidth };
1694
1747
  //# sourceMappingURL=index.mjs.map
1695
1748
  //# sourceMappingURL=index.mjs.map