@dloizides/ui-nav 1.9.0 → 1.10.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
@@ -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,
@@ -534,11 +545,12 @@ var Topbar = ({
534
545
  accessibilityLabel: language.label,
535
546
  ringColor: primaryColor,
536
547
  style: navStyles.topbarRowItem,
548
+ testID: language.testID,
537
549
  onPress: language.onPress,
538
550
  children: /* @__PURE__ */ jsx(Text, { style: [navStyles.topbarLabel, { color: colors.text }], children: language.label })
539
551
  }
540
552
  ) : null,
541
- notificationSlot,
553
+ renderTextSlot(notificationSlot, { color: colors.text }),
542
554
  user ? /* @__PURE__ */ jsxs(View, { style: navStyles.userBlock, children: [
543
555
  /* @__PURE__ */ jsx(Text, { style: [navStyles.userName, { color: colors.text }], children: user.name }),
544
556
  /* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, { color: colors.textSecondary }], children: user.email })
@@ -547,10 +559,10 @@ var Topbar = ({
547
559
  richAccount.onAccount ? /* @__PURE__ */ jsx(
548
560
  FocusableTouchable,
549
561
  {
550
- accessibilityHint: richAccount.displayName,
562
+ accessibilityHint: richAccount.accountHint ?? richAccount.displayName,
551
563
  accessibilityLabel: richAccount.displayName,
552
564
  ringColor: primaryColor,
553
- testID: NAV_TEST_IDS.accountName,
565
+ testID: richAccount.accountTestID ?? NAV_TEST_IDS.accountName,
554
566
  onPress: richAccount.onAccount,
555
567
  children: /* @__PURE__ */ jsx(Text, { style: [navStyles.userName, { color: colors.text }], children: richAccount.displayName })
556
568
  }
@@ -847,7 +859,7 @@ var NavBarInner = ({
847
859
  containerStyle
848
860
  ],
849
861
  children: /* @__PURE__ */ jsxs(View, { style: [navBarStyles.inner, collapsed ? null : navBarStyles.innerNoWrap, innerCapStyle], children: [
850
- 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,
851
863
  collapsed ? /* @__PURE__ */ jsx(
852
864
  Pressable,
853
865
  {
@@ -880,7 +892,7 @@ var NavBarInner = ({
880
892
  }
881
893
  );
882
894
  if (collapsed) {
883
- 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)) });
884
896
  }
885
897
  const visibleItems = items.slice(0, visibleCount);
886
898
  const overflowItems = items.slice(visibleCount);
@@ -924,7 +936,7 @@ var NavBarInner = ({
924
936
  }
925
937
  );
926
938
  })() : null,
927
- 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
928
940
  ] })
929
941
  }
930
942
  );
@@ -1028,6 +1040,7 @@ var MobileDrawer = ({
1028
1040
  drawerTestID,
1029
1041
  scrimTestID
1030
1042
  }) => {
1043
+ const { theme } = useUi();
1031
1044
  const panelRef = useRef(null);
1032
1045
  useEffect(() => {
1033
1046
  const node = panelRef.current;
@@ -1052,7 +1065,7 @@ var MobileDrawer = ({
1052
1065
  onPress: onClose
1053
1066
  }
1054
1067
  ),
1055
- /* @__PURE__ */ jsx(View, { ref: panelRef, "aria-modal": true, role: "dialog", style: styles2.panel, testID: drawerTestID, children: sidebar })
1068
+ /* @__PURE__ */ jsx(View, { ref: panelRef, "aria-modal": true, role: "dialog", style: styles2.panel, testID: drawerTestID, children: renderTextSlot(sidebar, { color: theme.colors.text }) })
1056
1069
  ] });
1057
1070
  };
1058
1071
 
@@ -1159,13 +1172,13 @@ var AppShell = ({
1159
1172
  onOpen: openDrawer
1160
1173
  }
1161
1174
  ),
1162
- /* @__PURE__ */ jsx(View, { style: styles3.headerFill, children: header })
1163
- ] }) : /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.header}`, children: header });
1164
- 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;
1175
+ /* @__PURE__ */ jsx(View, { style: styles3.headerFill, children: renderTextSlot(header, { color: theme.colors.text }) })
1176
+ ] }) : /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.header}`, children: renderTextSlot(header, { color: theme.colors.text }) });
1177
+ 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;
1165
1178
  return /* @__PURE__ */ jsxs(View, { style: [styles3.root, { backgroundColor: theme.colors.background }], testID, children: [
1166
1179
  headerRegion,
1167
- 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,
1168
- banner !== void 0 ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.banner}`, children: banner }) : null,
1180
+ 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,
1181
+ banner !== void 0 ? /* @__PURE__ */ jsx(View, { testID: `${testID}${APP_SHELL_SUFFIX.banner}`, children: renderTextSlot(banner, { color: theme.colors.text }) }) : null,
1169
1182
  railRegion !== null ? /* @__PURE__ */ jsxs(View, { style: styles3.bodyRow, children: [
1170
1183
  railRegion,
1171
1184
  scroller
@@ -1211,7 +1224,7 @@ var CollapsedRail = ({
1211
1224
  containerStyle
1212
1225
  ],
1213
1226
  children: [
1214
- header !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: header }) : null,
1227
+ header !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: renderTextSlot(header, { color: colors.text }) }) : null,
1215
1228
  items.map((item) => {
1216
1229
  const active = isRouteActive(pathname, item.route);
1217
1230
  const iconColor = active ? primaryColor : colors.textSecondary;
@@ -1230,13 +1243,13 @@ var CollapsedRail = ({
1230
1243
  );
1231
1244
  }),
1232
1245
  /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.spacer }),
1233
- footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: footer }) : null
1246
+ footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: collapsedRailStyles.slot, children: renderTextSlot(footer, { color: colors.text }) }) : null
1234
1247
  ]
1235
1248
  }
1236
1249
  );
1237
1250
  };
1238
- function wantsTopBar(layout, hasHeader, hasTopBar) {
1239
- return layout === "top" || layout === "both" || hasHeader || layout === "side" && hasTopBar;
1251
+ function wantsTopBar(layout, hasHeader) {
1252
+ return layout === "top" || layout === "both" || hasHeader;
1240
1253
  }
1241
1254
  function wantsSideRail(layout, hasSideRail) {
1242
1255
  return (layout === "side" || layout === "both") && hasSideRail;
@@ -1255,7 +1268,7 @@ var NavShell = ({
1255
1268
  collapsedRailRange: collapsedRailRangeProp,
1256
1269
  ...shellProps
1257
1270
  }) => {
1258
- const showTopBar = wantsTopBar(layout, header !== void 0, topBar !== void 0);
1271
+ const showTopBar = wantsTopBar(layout, header !== void 0);
1259
1272
  const showSideRail = wantsSideRail(layout, sideRail !== void 0);
1260
1273
  const headerNode = header !== void 0 ? header : showTopBar && topBar !== void 0 ? /* @__PURE__ */ jsx(
1261
1274
  NavBar,