@dloizides/ui-nav 1.10.0 → 1.10.2

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
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet, Platform, TouchableOpacity, View, Text, useWindowDimensions, ActivityIndicator, ScrollView, Pressable } from 'react-native';
2
2
  import { useUi, UiProvider } from '@dloizides/ui-feedback';
3
- import React5, { useState, useCallback, useMemo, useEffect, useRef } from 'react';
3
+ import React2, { useState, useCallback, useMemo, useEffect, useRef } from 'react';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
5
5
  import { ModalDropdown } from '@dloizides/ui-layout';
6
6
  import { resolveAccessibleRoutes } from '@dloizides/auth-web';
@@ -378,6 +378,17 @@ var NavExpandableItem = ({
378
378
  )) }) : null
379
379
  ] });
380
380
  };
381
+ function isBareText(node) {
382
+ return typeof node === "string" || typeof node === "number";
383
+ }
384
+ function renderTextSlot(node, style) {
385
+ if (node === void 0 || node === null) return node;
386
+ if (isBareText(node)) return /* @__PURE__ */ jsx(Text, { style, children: node });
387
+ return React2.Children.map(
388
+ node,
389
+ (child) => isBareText(child) ? /* @__PURE__ */ jsx(Text, { style, children: child }) : child
390
+ );
391
+ }
381
392
  var Sidebar = ({
382
393
  items,
383
394
  pathname,
@@ -407,7 +418,7 @@ var Sidebar = ({
407
418
  ],
408
419
  children: [
409
420
  /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [navStyles.sidebarTitle, { color: colors.text }], children: title }),
410
- header,
421
+ renderTextSlot(header, { color: colors.text }),
411
422
  items.map((item) => /* @__PURE__ */ jsx(
412
423
  NavExpandableItem,
413
424
  {
@@ -422,7 +433,7 @@ var Sidebar = ({
422
433
  item.key
423
434
  )),
424
435
  /* @__PURE__ */ jsx(View, { style: navStyles.sidebarSpacer }),
425
- footer
436
+ renderTextSlot(footer, { color: colors.text })
426
437
  ]
427
438
  }
428
439
  );
@@ -525,7 +536,7 @@ var Topbar = ({
525
536
  containerStyle
526
537
  ],
527
538
  children: [
528
- /* @__PURE__ */ jsx(View, { style: navStyles.topbarLeft, children: left }),
539
+ /* @__PURE__ */ jsx(View, { style: navStyles.topbarLeft, children: renderTextSlot(left, { color: colors.text }) }),
529
540
  /* @__PURE__ */ jsxs(View, { style: navStyles.topbarRight, children: [
530
541
  language ? /* @__PURE__ */ jsx(
531
542
  FocusableTouchable,
@@ -539,7 +550,7 @@ var Topbar = ({
539
550
  children: /* @__PURE__ */ jsx(Text, { style: [navStyles.topbarLabel, { color: colors.text }], children: language.label })
540
551
  }
541
552
  ) : null,
542
- notificationSlot,
553
+ renderTextSlot(notificationSlot, { color: colors.text }),
543
554
  user ? /* @__PURE__ */ jsxs(View, { style: navStyles.userBlock, children: [
544
555
  /* @__PURE__ */ jsx(Text, { style: [navStyles.userName, { color: colors.text }], children: user.name }),
545
556
  /* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, { color: colors.textSecondary }], children: user.email })
@@ -848,7 +859,7 @@ var NavBarInner = ({
848
859
  containerStyle
849
860
  ],
850
861
  children: /* @__PURE__ */ jsxs(View, { style: [navBarStyles.inner, collapsed ? null : navBarStyles.innerNoWrap, innerCapStyle], children: [
851
- brand !== void 0 ? /* @__PURE__ */ jsx(View, { style: navBarStyles.brand, children: brand }) : null,
862
+ brand !== void 0 ? /* @__PURE__ */ jsx(View, { style: navBarStyles.brand, children: renderTextSlot(brand, { color: colors.text }) }) : null,
852
863
  collapsed ? /* @__PURE__ */ jsx(
853
864
  Pressable,
854
865
  {
@@ -881,7 +892,7 @@ var NavBarInner = ({
881
892
  }
882
893
  );
883
894
  if (collapsed) {
884
- return /* @__PURE__ */ jsx(View, { nativeID: LINKS_REGION_ID, style: navBarStyles.linksStacked, testID: NAV_TEST_IDS.navBarLinks, children: items.map((item) => /* @__PURE__ */ jsx(React5.Fragment, { children: renderLink(item) }, item.key)) });
895
+ return /* @__PURE__ */ jsx(View, { nativeID: LINKS_REGION_ID, style: navBarStyles.linksStacked, testID: NAV_TEST_IDS.navBarLinks, children: items.map((item) => /* @__PURE__ */ jsx(React2.Fragment, { children: renderLink(item) }, item.key)) });
885
896
  }
886
897
  const visibleItems = items.slice(0, visibleCount);
887
898
  const overflowItems = items.slice(visibleCount);
@@ -925,7 +936,7 @@ var NavBarInner = ({
925
936
  }
926
937
  );
927
938
  })() : null,
928
- showLinks && right !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsed ? navBarStyles.rightStacked : navBarStyles.right, children: right }) : null
939
+ showLinks && right !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsed ? navBarStyles.rightStacked : navBarStyles.right, children: renderTextSlot(right, { color: colors.text }) }) : null
929
940
  ] })
930
941
  }
931
942
  );
@@ -987,6 +998,9 @@ var MENU_MIN_TARGET = 44;
987
998
  var MENU_GLYPH_FONT_SIZE = 20;
988
999
  var MENU_TOGGLE_PADDING = 12;
989
1000
  var DRAWER_Z_INDEX = 50;
1001
+ var DRAWER_WIDTH = 280;
1002
+ var SCRIM_Z_INDEX = 1;
1003
+ var PANEL_Z_INDEX = 2;
990
1004
  var NAV_ACTIVATABLE_SELECTOR = 'a, [role="button"], [role="link"]';
991
1005
  var DEFAULT_DRAWER_LABELS = {
992
1006
  openLabel: "Menu",
@@ -996,8 +1010,22 @@ var DEFAULT_DRAWER_LABELS = {
996
1010
  };
997
1011
  var styles2 = StyleSheet.create({
998
1012
  overlay: { ...StyleSheet.absoluteFillObject, zIndex: DRAWER_Z_INDEX },
999
- scrim: { ...StyleSheet.absoluteFillObject, backgroundColor: SCRIM_COLOR },
1000
- panel: { position: "absolute", top: 0, bottom: 0, left: 0 },
1013
+ // The scrim's tap-to-close hit area is anchored to the RIGHT of the panel
1014
+ // (`left: DRAWER_WIDTH`), so it NEVER overlaps the panel: nav-item taps always
1015
+ // reach the Sidebar's TouchableOpacity, while taps beside the drawer still close.
1016
+ scrim: {
1017
+ position: "absolute",
1018
+ top: 0,
1019
+ bottom: 0,
1020
+ left: DRAWER_WIDTH,
1021
+ right: 0,
1022
+ backgroundColor: SCRIM_COLOR,
1023
+ zIndex: SCRIM_Z_INDEX
1024
+ },
1025
+ // The panel gets an explicit width (a real drawer) AND a zIndex above the scrim,
1026
+ // so on react-native-web it — and the nav leaves inside it — sit above the scrim
1027
+ // and receive presses instead of the scrim swallowing them.
1028
+ panel: { position: "absolute", top: 0, bottom: 0, left: 0, width: DRAWER_WIDTH, zIndex: PANEL_Z_INDEX },
1001
1029
  menuToggle: {
1002
1030
  minWidth: MENU_MIN_TARGET,
1003
1031
  minHeight: MENU_MIN_TARGET,
@@ -1029,6 +1057,7 @@ var MobileDrawer = ({
1029
1057
  drawerTestID,
1030
1058
  scrimTestID
1031
1059
  }) => {
1060
+ const { theme } = useUi();
1032
1061
  const panelRef = useRef(null);
1033
1062
  useEffect(() => {
1034
1063
  const node = panelRef.current;
@@ -1053,7 +1082,17 @@ var MobileDrawer = ({
1053
1082
  onPress: onClose
1054
1083
  }
1055
1084
  ),
1056
- /* @__PURE__ */ jsx(View, { ref: panelRef, "aria-modal": true, role: "dialog", style: styles2.panel, testID: drawerTestID, children: sidebar })
1085
+ /* @__PURE__ */ jsx(
1086
+ View,
1087
+ {
1088
+ ref: panelRef,
1089
+ "aria-modal": true,
1090
+ role: "dialog",
1091
+ style: [styles2.panel, { backgroundColor: theme.colors.surface }],
1092
+ testID: drawerTestID,
1093
+ children: renderTextSlot(sidebar, { color: theme.colors.text })
1094
+ }
1095
+ )
1057
1096
  ] });
1058
1097
  };
1059
1098
 
@@ -1160,13 +1199,13 @@ var AppShell = ({
1160
1199
  onOpen: openDrawer
1161
1200
  }
1162
1201
  ),
1163
- /* @__PURE__ */ jsx(View, { style: styles3.headerFill, children: header })
1164
- ] }) : /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.header}`, children: header });
1165
- const railRegion = railMode === "full" ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.sidebar}`, children: sidebar }) : railMode === "collapsed" ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.collapsedSidebar}`, children: collapsedSidebar }) : null;
1202
+ /* @__PURE__ */ jsx(View, { style: styles3.headerFill, children: renderTextSlot(header, { color: theme.colors.text }) })
1203
+ ] }) : /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.header}`, children: renderTextSlot(header, { color: theme.colors.text }) });
1204
+ const railRegion = railMode === "full" ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.sidebar}`, children: renderTextSlot(sidebar, { color: theme.colors.text }) }) : railMode === "collapsed" ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.collapsedSidebar}`, children: renderTextSlot(collapsedSidebar, { color: theme.colors.text }) }) : null;
1166
1205
  return /* @__PURE__ */ jsxs(View, { style: [styles3.root, { backgroundColor: theme.colors.background }], testID, children: [
1167
1206
  headerRegion,
1168
- nav !== void 0 ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.nav}`, children: navInnerStyle !== void 0 ? /* @__PURE__ */ jsx(View, { style: navInnerStyle, children: nav }) : nav }) : null,
1169
- banner !== void 0 ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.banner}`, children: banner }) : null,
1207
+ nav !== void 0 ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.nav}`, children: navInnerStyle !== void 0 ? /* @__PURE__ */ jsx(View, { style: navInnerStyle, children: renderTextSlot(nav, { color: theme.colors.text }) }) : renderTextSlot(nav, { color: theme.colors.text }) }) : null,
1208
+ banner !== void 0 ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.banner}`, children: renderTextSlot(banner, { color: theme.colors.text }) }) : null,
1170
1209
  railRegion !== null ? /* @__PURE__ */ jsxs(View, { style: styles3.bodyRow, children: [
1171
1210
  railRegion,
1172
1211
  scroller
@@ -1212,7 +1251,7 @@ var CollapsedRail = ({
1212
1251
  containerStyle
1213
1252
  ],
1214
1253
  children: [
1215
- header !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: header }) : null,
1254
+ header !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: renderTextSlot(header, { color: colors.text }) }) : null,
1216
1255
  items.map((item) => {
1217
1256
  const active = isRouteActive(pathname, item.route);
1218
1257
  const iconColor = active ? primaryColor : colors.textSecondary;
@@ -1231,7 +1270,7 @@ var CollapsedRail = ({
1231
1270
  );
1232
1271
  }),
1233
1272
  /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.spacer }),
1234
- footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: footer }) : null
1273
+ footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: renderTextSlot(footer, { color: colors.text }) }) : null
1235
1274
  ]
1236
1275
  }
1237
1276
  );