@dloizides/ui-nav 1.10.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/CHANGELOG.md +23 -0
- package/dist/index.js +65 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
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(
|
|
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
|
);
|
|
@@ -1029,6 +1040,7 @@ var MobileDrawer = ({
|
|
|
1029
1040
|
drawerTestID,
|
|
1030
1041
|
scrimTestID
|
|
1031
1042
|
}) => {
|
|
1043
|
+
const { theme } = useUi();
|
|
1032
1044
|
const panelRef = useRef(null);
|
|
1033
1045
|
useEffect(() => {
|
|
1034
1046
|
const node = panelRef.current;
|
|
@@ -1053,7 +1065,7 @@ var MobileDrawer = ({
|
|
|
1053
1065
|
onPress: onClose
|
|
1054
1066
|
}
|
|
1055
1067
|
),
|
|
1056
|
-
/* @__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 }) })
|
|
1057
1069
|
] });
|
|
1058
1070
|
};
|
|
1059
1071
|
|
|
@@ -1160,13 +1172,13 @@ var AppShell = ({
|
|
|
1160
1172
|
onOpen: openDrawer
|
|
1161
1173
|
}
|
|
1162
1174
|
),
|
|
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;
|
|
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;
|
|
1166
1178
|
return /* @__PURE__ */ jsxs(View, { style: [styles3.root, { backgroundColor: theme.colors.background }], testID, children: [
|
|
1167
1179
|
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,
|
|
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,
|
|
1170
1182
|
railRegion !== null ? /* @__PURE__ */ jsxs(View, { style: styles3.bodyRow, children: [
|
|
1171
1183
|
railRegion,
|
|
1172
1184
|
scroller
|
|
@@ -1212,7 +1224,7 @@ var CollapsedRail = ({
|
|
|
1212
1224
|
containerStyle
|
|
1213
1225
|
],
|
|
1214
1226
|
children: [
|
|
1215
|
-
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,
|
|
1216
1228
|
items.map((item) => {
|
|
1217
1229
|
const active = isRouteActive(pathname, item.route);
|
|
1218
1230
|
const iconColor = active ? primaryColor : colors.textSecondary;
|
|
@@ -1231,7 +1243,7 @@ var CollapsedRail = ({
|
|
|
1231
1243
|
);
|
|
1232
1244
|
}),
|
|
1233
1245
|
/* @__PURE__ */ jsx(View, { style: collapsedRailStyles.spacer }),
|
|
1234
|
-
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
|
|
1235
1247
|
]
|
|
1236
1248
|
}
|
|
1237
1249
|
);
|