@dloizides/ui-nav 1.31.0 → 1.33.0
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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +78 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useState, useCallback, useMemo, useEffect, useRef } from 'react';
|
|
2
2
|
import { StyleSheet, Platform, Pressable, Text, View, TextInput, useWindowDimensions, Image, ScrollView, ActivityIndicator, Animated } from 'react-native';
|
|
3
3
|
import { useUi, UiProvider } from '@dloizides/ui-feedback';
|
|
4
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { Collapse, motionDurations, motionEasings } from '@dloizides/ui-motion';
|
|
6
|
-
import { LAYOUT_COLLAPSE_BREAKPOINT, ModalDropdown, DropdownVariant, SelectedMarker } from '@dloizides/ui-layout';
|
|
6
|
+
import { LAYOUT_COLLAPSE_BREAKPOINT, ModalDropdown, HEADER_STACK_BREAKPOINT, DropdownVariant, SelectedMarker } from '@dloizides/ui-layout';
|
|
7
7
|
import { Z_INDEX } from '@dloizides/design-tokens';
|
|
8
8
|
import { resolveAccessibleRoutes } from '@dloizides/auth-web';
|
|
9
9
|
|
|
@@ -60,7 +60,7 @@ var navStyles = StyleSheet.create({
|
|
|
60
60
|
},
|
|
61
61
|
// --- Topbar ---
|
|
62
62
|
topbarContainer: {
|
|
63
|
-
|
|
63
|
+
minHeight: 64,
|
|
64
64
|
paddingHorizontal: 12,
|
|
65
65
|
borderBottomWidth: 1,
|
|
66
66
|
flexDirection: "row",
|
|
@@ -81,7 +81,7 @@ var navStyles = StyleSheet.create({
|
|
|
81
81
|
userBlock: { marginHorizontal: 12, alignItems: "flex-end", flexShrink: 1, minWidth: 0 },
|
|
82
82
|
userName: { fontWeight: "600", maxWidth: "100%" },
|
|
83
83
|
accountNameBtn: { flexShrink: 1, maxWidth: "100%", minHeight: MIN_TOUCH_TARGET, minWidth: MIN_TOUCH_TARGET, justifyContent: "center", alignItems: "flex-end" },
|
|
84
|
-
userEmail: { fontSize: 12 },
|
|
84
|
+
userEmail: { fontSize: 12, maxWidth: "100%" },
|
|
85
85
|
accountBtn: {
|
|
86
86
|
marginLeft: 8,
|
|
87
87
|
paddingHorizontal: 10,
|
|
@@ -932,7 +932,24 @@ var FocusableTouchable = ({
|
|
|
932
932
|
}
|
|
933
933
|
);
|
|
934
934
|
};
|
|
935
|
+
var RAIL_FULL_BREAKPOINT = LAYOUT_COLLAPSE_BREAKPOINT;
|
|
936
|
+
var DEFAULT_COLLAPSED_RAIL_MAX = 1024;
|
|
937
|
+
function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
|
|
938
|
+
if (!hasSidebar) return "none";
|
|
939
|
+
if (hasCollapsed) {
|
|
940
|
+
if (viewport >= range.max) return "full";
|
|
941
|
+
if (viewport >= range.min) return "collapsed";
|
|
942
|
+
return "drawer";
|
|
943
|
+
}
|
|
944
|
+
return viewport >= RAIL_FULL_BREAKPOINT ? "full" : "drawer";
|
|
945
|
+
}
|
|
935
946
|
var TEXT_ON_PRIMARY = "#ffffff";
|
|
947
|
+
var ON_BRAND_SCALE = "onBrand";
|
|
948
|
+
var USER_BLOCK_COMPACT = { marginHorizontal: 4 };
|
|
949
|
+
var CONTAINER_STACKED = { flexWrap: "wrap" };
|
|
950
|
+
var USER_ROW_STACKED = { flexBasis: "100%", alignItems: "flex-end", paddingBottom: 8 };
|
|
951
|
+
var MAIN_STEP = "500";
|
|
952
|
+
var WRAP_ANYWHERE = Platform.OS === "web" ? { overflowWrap: "anywhere" } : null;
|
|
936
953
|
function isAccountState(account) {
|
|
937
954
|
return "displayName" in account;
|
|
938
955
|
}
|
|
@@ -942,6 +959,14 @@ function planToneColor(theme, tone) {
|
|
|
942
959
|
if (tone === "enterprise") return palette.accent?.["500"] ?? palette.primary["500"];
|
|
943
960
|
return theme.colors.textSecondary;
|
|
944
961
|
}
|
|
962
|
+
function onBrandInk(palette) {
|
|
963
|
+
const scales = palette;
|
|
964
|
+
return scales[ON_BRAND_SCALE]?.[MAIN_STEP] ?? TEXT_ON_PRIMARY;
|
|
965
|
+
}
|
|
966
|
+
function planBadgeInk(theme, tone) {
|
|
967
|
+
const fillIsPrimary = planToneColor(theme, tone) === theme.palette.primary["500"];
|
|
968
|
+
return fillIsPrimary ? onBrandInk(theme.palette) : TEXT_ON_PRIMARY;
|
|
969
|
+
}
|
|
945
970
|
var Topbar = ({
|
|
946
971
|
left,
|
|
947
972
|
center,
|
|
@@ -955,15 +980,60 @@ var Topbar = ({
|
|
|
955
980
|
const { theme } = useUi();
|
|
956
981
|
const colors = theme.colors;
|
|
957
982
|
const primaryColor = theme.palette.primary["500"];
|
|
983
|
+
const onPrimaryInk = onBrandInk(theme.palette);
|
|
984
|
+
const { width: viewportWidth } = useWindowDimensions();
|
|
985
|
+
const stacked = viewportWidth < HEADER_STACK_BREAKPOINT;
|
|
986
|
+
const userBlockStyle = [
|
|
987
|
+
navStyles.userBlock,
|
|
988
|
+
viewportWidth < RAIL_FULL_BREAKPOINT ? USER_BLOCK_COMPACT : null,
|
|
989
|
+
stacked ? USER_ROW_STACKED : null
|
|
990
|
+
];
|
|
958
991
|
const richAccount = account !== void 0 && isAccountState(account) ? account : void 0;
|
|
959
992
|
const legacyAccount = account !== void 0 && !isAccountState(account) ? account : void 0;
|
|
960
993
|
const upgrade = richAccount?.upgrade;
|
|
994
|
+
const identityBlocks = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
995
|
+
user ? /* @__PURE__ */ jsxs(View, { accessible: true, accessibilityLabel: `${user.name}, ${user.email}`, style: userBlockStyle, children: [
|
|
996
|
+
/* @__PURE__ */ jsx(Text, { style: [navStyles.userName, WRAP_ANYWHERE, { color: colors.text }], children: user.name }),
|
|
997
|
+
/* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, WRAP_ANYWHERE, { color: colors.textSecondary }], children: user.email })
|
|
998
|
+
] }) : null,
|
|
999
|
+
richAccount ? /* @__PURE__ */ jsxs(View, { style: userBlockStyle, children: [
|
|
1000
|
+
richAccount.onAccount ? /* @__PURE__ */ jsx(
|
|
1001
|
+
FocusableTouchable,
|
|
1002
|
+
{
|
|
1003
|
+
accessibilityHint: richAccount.accountHint ?? richAccount.displayName,
|
|
1004
|
+
accessibilityLabel: richAccount.displayName,
|
|
1005
|
+
ringColor: primaryColor,
|
|
1006
|
+
style: navStyles.accountNameBtn,
|
|
1007
|
+
testID: richAccount.accountTestID ?? NAV_TEST_IDS.accountName,
|
|
1008
|
+
onPress: richAccount.onAccount,
|
|
1009
|
+
children: /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], children: richAccount.displayName })
|
|
1010
|
+
}
|
|
1011
|
+
) : /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], testID: NAV_TEST_IDS.accountName, children: richAccount.displayName }),
|
|
1012
|
+
richAccount.tenantName !== void 0 ? /* @__PURE__ */ jsx(
|
|
1013
|
+
Text,
|
|
1014
|
+
{
|
|
1015
|
+
style: [navStyles.accountTenant, { color: colors.textSecondary }],
|
|
1016
|
+
testID: NAV_TEST_IDS.accountTenant,
|
|
1017
|
+
children: richAccount.tenantName
|
|
1018
|
+
}
|
|
1019
|
+
) : null,
|
|
1020
|
+
richAccount.plan ? /* @__PURE__ */ jsx(
|
|
1021
|
+
View,
|
|
1022
|
+
{
|
|
1023
|
+
style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
|
|
1024
|
+
testID: NAV_TEST_IDS.accountPlan,
|
|
1025
|
+
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.planBadgeText, { color: planBadgeInk(theme, richAccount.plan.tone) }], children: richAccount.plan.label })
|
|
1026
|
+
}
|
|
1027
|
+
) : null
|
|
1028
|
+
] }) : null
|
|
1029
|
+
] });
|
|
961
1030
|
return /* @__PURE__ */ jsxs(
|
|
962
1031
|
View,
|
|
963
1032
|
{
|
|
964
1033
|
style: [
|
|
965
1034
|
navStyles.topbarContainer,
|
|
966
1035
|
{ borderBottomColor: colors.border, backgroundColor: colors.background },
|
|
1036
|
+
stacked ? CONTAINER_STACKED : null,
|
|
967
1037
|
containerStyle
|
|
968
1038
|
],
|
|
969
1039
|
children: [
|
|
@@ -983,40 +1053,7 @@ var Topbar = ({
|
|
|
983
1053
|
}
|
|
984
1054
|
) : null,
|
|
985
1055
|
renderTextSlot(notificationSlot, { color: colors.text }),
|
|
986
|
-
|
|
987
|
-
/* @__PURE__ */ jsx(Text, { style: [navStyles.userName, { color: colors.text }], children: user.name }),
|
|
988
|
-
/* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, { color: colors.textSecondary }], children: user.email })
|
|
989
|
-
] }) : null,
|
|
990
|
-
richAccount ? /* @__PURE__ */ jsxs(View, { style: navStyles.userBlock, children: [
|
|
991
|
-
richAccount.onAccount ? /* @__PURE__ */ jsx(
|
|
992
|
-
FocusableTouchable,
|
|
993
|
-
{
|
|
994
|
-
accessibilityHint: richAccount.accountHint ?? richAccount.displayName,
|
|
995
|
-
accessibilityLabel: richAccount.displayName,
|
|
996
|
-
ringColor: primaryColor,
|
|
997
|
-
style: navStyles.accountNameBtn,
|
|
998
|
-
testID: richAccount.accountTestID ?? NAV_TEST_IDS.accountName,
|
|
999
|
-
onPress: richAccount.onAccount,
|
|
1000
|
-
children: /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], children: richAccount.displayName })
|
|
1001
|
-
}
|
|
1002
|
-
) : /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], testID: NAV_TEST_IDS.accountName, children: richAccount.displayName }),
|
|
1003
|
-
richAccount.tenantName !== void 0 ? /* @__PURE__ */ jsx(
|
|
1004
|
-
Text,
|
|
1005
|
-
{
|
|
1006
|
-
style: [navStyles.accountTenant, { color: colors.textSecondary }],
|
|
1007
|
-
testID: NAV_TEST_IDS.accountTenant,
|
|
1008
|
-
children: richAccount.tenantName
|
|
1009
|
-
}
|
|
1010
|
-
) : null,
|
|
1011
|
-
richAccount.plan ? /* @__PURE__ */ jsx(
|
|
1012
|
-
View,
|
|
1013
|
-
{
|
|
1014
|
-
style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
|
|
1015
|
-
testID: NAV_TEST_IDS.accountPlan,
|
|
1016
|
-
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.planBadgeText, { color: TEXT_ON_PRIMARY }], children: richAccount.plan.label })
|
|
1017
|
-
}
|
|
1018
|
-
) : null
|
|
1019
|
-
] }) : null,
|
|
1056
|
+
stacked ? null : identityBlocks,
|
|
1020
1057
|
legacyAccount ? /* @__PURE__ */ jsx(
|
|
1021
1058
|
FocusableTouchable,
|
|
1022
1059
|
{
|
|
@@ -1026,7 +1063,7 @@ var Topbar = ({
|
|
|
1026
1063
|
style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
|
|
1027
1064
|
testID: legacyAccount.testID,
|
|
1028
1065
|
onPress: legacyAccount.onPress,
|
|
1029
|
-
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color:
|
|
1066
|
+
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: legacyAccount.label })
|
|
1030
1067
|
}
|
|
1031
1068
|
) : null,
|
|
1032
1069
|
upgrade ? /* @__PURE__ */ jsx(
|
|
@@ -1038,7 +1075,7 @@ var Topbar = ({
|
|
|
1038
1075
|
style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
|
|
1039
1076
|
testID: upgrade.testID ?? NAV_TEST_IDS.accountUpgrade,
|
|
1040
1077
|
onPress: upgrade.onPress,
|
|
1041
|
-
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color:
|
|
1078
|
+
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: upgrade.label })
|
|
1042
1079
|
}
|
|
1043
1080
|
) : null,
|
|
1044
1081
|
/* @__PURE__ */ jsx(
|
|
@@ -1050,10 +1087,11 @@ var Topbar = ({
|
|
|
1050
1087
|
style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
|
|
1051
1088
|
testID: logout.testID,
|
|
1052
1089
|
onPress: richAccount ? richAccount.onLogout : logout.onPress,
|
|
1053
|
-
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color:
|
|
1090
|
+
children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: logout.label })
|
|
1054
1091
|
}
|
|
1055
1092
|
)
|
|
1056
|
-
] })
|
|
1093
|
+
] }),
|
|
1094
|
+
stacked ? identityBlocks : null
|
|
1057
1095
|
]
|
|
1058
1096
|
}
|
|
1059
1097
|
);
|
|
@@ -1615,17 +1653,6 @@ var Nav = (props) => {
|
|
|
1615
1653
|
}
|
|
1616
1654
|
return /* @__PURE__ */ jsx(NavBar, { ...props });
|
|
1617
1655
|
};
|
|
1618
|
-
var RAIL_FULL_BREAKPOINT = LAYOUT_COLLAPSE_BREAKPOINT;
|
|
1619
|
-
var DEFAULT_COLLAPSED_RAIL_MAX = 1024;
|
|
1620
|
-
function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
|
|
1621
|
-
if (!hasSidebar) return "none";
|
|
1622
|
-
if (hasCollapsed) {
|
|
1623
|
-
if (viewport >= range.max) return "full";
|
|
1624
|
-
if (viewport >= range.min) return "collapsed";
|
|
1625
|
-
return "drawer";
|
|
1626
|
-
}
|
|
1627
|
-
return viewport >= RAIL_FULL_BREAKPOINT ? "full" : "drawer";
|
|
1628
|
-
}
|
|
1629
1656
|
var styles5 = StyleSheet.create({
|
|
1630
1657
|
band: { left: 0, position: "absolute", right: 0, top: 0 }
|
|
1631
1658
|
});
|