@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.d.mts
CHANGED
|
@@ -1392,7 +1392,7 @@ declare const navStyles: {
|
|
|
1392
1392
|
paddingHorizontal: number;
|
|
1393
1393
|
};
|
|
1394
1394
|
topbarContainer: {
|
|
1395
|
-
|
|
1395
|
+
minHeight: number;
|
|
1396
1396
|
paddingHorizontal: number;
|
|
1397
1397
|
borderBottomWidth: number;
|
|
1398
1398
|
flexDirection: "row";
|
|
@@ -1446,6 +1446,7 @@ declare const navStyles: {
|
|
|
1446
1446
|
};
|
|
1447
1447
|
userEmail: {
|
|
1448
1448
|
fontSize: number;
|
|
1449
|
+
maxWidth: "100%";
|
|
1449
1450
|
};
|
|
1450
1451
|
accountBtn: {
|
|
1451
1452
|
marginLeft: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1392,7 +1392,7 @@ declare const navStyles: {
|
|
|
1392
1392
|
paddingHorizontal: number;
|
|
1393
1393
|
};
|
|
1394
1394
|
topbarContainer: {
|
|
1395
|
-
|
|
1395
|
+
minHeight: number;
|
|
1396
1396
|
paddingHorizontal: number;
|
|
1397
1397
|
borderBottomWidth: number;
|
|
1398
1398
|
flexDirection: "row";
|
|
@@ -1446,6 +1446,7 @@ declare const navStyles: {
|
|
|
1446
1446
|
};
|
|
1447
1447
|
userEmail: {
|
|
1448
1448
|
fontSize: number;
|
|
1449
|
+
maxWidth: "100%";
|
|
1449
1450
|
};
|
|
1450
1451
|
accountBtn: {
|
|
1451
1452
|
marginLeft: number;
|
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ var navStyles = reactNative.StyleSheet.create({
|
|
|
66
66
|
},
|
|
67
67
|
// --- Topbar ---
|
|
68
68
|
topbarContainer: {
|
|
69
|
-
|
|
69
|
+
minHeight: 64,
|
|
70
70
|
paddingHorizontal: 12,
|
|
71
71
|
borderBottomWidth: 1,
|
|
72
72
|
flexDirection: "row",
|
|
@@ -87,7 +87,7 @@ var navStyles = reactNative.StyleSheet.create({
|
|
|
87
87
|
userBlock: { marginHorizontal: 12, alignItems: "flex-end", flexShrink: 1, minWidth: 0 },
|
|
88
88
|
userName: { fontWeight: "600", maxWidth: "100%" },
|
|
89
89
|
accountNameBtn: { flexShrink: 1, maxWidth: "100%", minHeight: MIN_TOUCH_TARGET, minWidth: MIN_TOUCH_TARGET, justifyContent: "center", alignItems: "flex-end" },
|
|
90
|
-
userEmail: { fontSize: 12 },
|
|
90
|
+
userEmail: { fontSize: 12, maxWidth: "100%" },
|
|
91
91
|
accountBtn: {
|
|
92
92
|
marginLeft: 8,
|
|
93
93
|
paddingHorizontal: 10,
|
|
@@ -938,7 +938,24 @@ var FocusableTouchable = ({
|
|
|
938
938
|
}
|
|
939
939
|
);
|
|
940
940
|
};
|
|
941
|
+
var RAIL_FULL_BREAKPOINT = uiLayout.LAYOUT_COLLAPSE_BREAKPOINT;
|
|
942
|
+
var DEFAULT_COLLAPSED_RAIL_MAX = 1024;
|
|
943
|
+
function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
|
|
944
|
+
if (!hasSidebar) return "none";
|
|
945
|
+
if (hasCollapsed) {
|
|
946
|
+
if (viewport >= range.max) return "full";
|
|
947
|
+
if (viewport >= range.min) return "collapsed";
|
|
948
|
+
return "drawer";
|
|
949
|
+
}
|
|
950
|
+
return viewport >= RAIL_FULL_BREAKPOINT ? "full" : "drawer";
|
|
951
|
+
}
|
|
941
952
|
var TEXT_ON_PRIMARY = "#ffffff";
|
|
953
|
+
var ON_BRAND_SCALE = "onBrand";
|
|
954
|
+
var USER_BLOCK_COMPACT = { marginHorizontal: 4 };
|
|
955
|
+
var CONTAINER_STACKED = { flexWrap: "wrap" };
|
|
956
|
+
var USER_ROW_STACKED = { flexBasis: "100%", alignItems: "flex-end", paddingBottom: 8 };
|
|
957
|
+
var MAIN_STEP = "500";
|
|
958
|
+
var WRAP_ANYWHERE = reactNative.Platform.OS === "web" ? { overflowWrap: "anywhere" } : null;
|
|
942
959
|
function isAccountState(account) {
|
|
943
960
|
return "displayName" in account;
|
|
944
961
|
}
|
|
@@ -948,6 +965,14 @@ function planToneColor(theme, tone) {
|
|
|
948
965
|
if (tone === "enterprise") return palette.accent?.["500"] ?? palette.primary["500"];
|
|
949
966
|
return theme.colors.textSecondary;
|
|
950
967
|
}
|
|
968
|
+
function onBrandInk(palette) {
|
|
969
|
+
const scales = palette;
|
|
970
|
+
return scales[ON_BRAND_SCALE]?.[MAIN_STEP] ?? TEXT_ON_PRIMARY;
|
|
971
|
+
}
|
|
972
|
+
function planBadgeInk(theme, tone) {
|
|
973
|
+
const fillIsPrimary = planToneColor(theme, tone) === theme.palette.primary["500"];
|
|
974
|
+
return fillIsPrimary ? onBrandInk(theme.palette) : TEXT_ON_PRIMARY;
|
|
975
|
+
}
|
|
951
976
|
var Topbar = ({
|
|
952
977
|
left,
|
|
953
978
|
center,
|
|
@@ -961,15 +986,60 @@ var Topbar = ({
|
|
|
961
986
|
const { theme } = uiFeedback.useUi();
|
|
962
987
|
const colors = theme.colors;
|
|
963
988
|
const primaryColor = theme.palette.primary["500"];
|
|
989
|
+
const onPrimaryInk = onBrandInk(theme.palette);
|
|
990
|
+
const { width: viewportWidth } = reactNative.useWindowDimensions();
|
|
991
|
+
const stacked = viewportWidth < uiLayout.HEADER_STACK_BREAKPOINT;
|
|
992
|
+
const userBlockStyle = [
|
|
993
|
+
navStyles.userBlock,
|
|
994
|
+
viewportWidth < RAIL_FULL_BREAKPOINT ? USER_BLOCK_COMPACT : null,
|
|
995
|
+
stacked ? USER_ROW_STACKED : null
|
|
996
|
+
];
|
|
964
997
|
const richAccount = account !== void 0 && isAccountState(account) ? account : void 0;
|
|
965
998
|
const legacyAccount = account !== void 0 && !isAccountState(account) ? account : void 0;
|
|
966
999
|
const upgrade = richAccount?.upgrade;
|
|
1000
|
+
const identityBlocks = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1001
|
+
user ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { accessible: true, accessibilityLabel: `${user.name}, ${user.email}`, style: userBlockStyle, children: [
|
|
1002
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.userName, WRAP_ANYWHERE, { color: colors.text }], children: user.name }),
|
|
1003
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.userEmail, WRAP_ANYWHERE, { color: colors.textSecondary }], children: user.email })
|
|
1004
|
+
] }) : null,
|
|
1005
|
+
richAccount ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: userBlockStyle, children: [
|
|
1006
|
+
richAccount.onAccount ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1007
|
+
FocusableTouchable,
|
|
1008
|
+
{
|
|
1009
|
+
accessibilityHint: richAccount.accountHint ?? richAccount.displayName,
|
|
1010
|
+
accessibilityLabel: richAccount.displayName,
|
|
1011
|
+
ringColor: primaryColor,
|
|
1012
|
+
style: navStyles.accountNameBtn,
|
|
1013
|
+
testID: richAccount.accountTestID ?? NAV_TEST_IDS.accountName,
|
|
1014
|
+
onPress: richAccount.onAccount,
|
|
1015
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], children: richAccount.displayName })
|
|
1016
|
+
}
|
|
1017
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], testID: NAV_TEST_IDS.accountName, children: richAccount.displayName }),
|
|
1018
|
+
richAccount.tenantName !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1019
|
+
reactNative.Text,
|
|
1020
|
+
{
|
|
1021
|
+
style: [navStyles.accountTenant, { color: colors.textSecondary }],
|
|
1022
|
+
testID: NAV_TEST_IDS.accountTenant,
|
|
1023
|
+
children: richAccount.tenantName
|
|
1024
|
+
}
|
|
1025
|
+
) : null,
|
|
1026
|
+
richAccount.plan ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1027
|
+
reactNative.View,
|
|
1028
|
+
{
|
|
1029
|
+
style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
|
|
1030
|
+
testID: NAV_TEST_IDS.accountPlan,
|
|
1031
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.planBadgeText, { color: planBadgeInk(theme, richAccount.plan.tone) }], children: richAccount.plan.label })
|
|
1032
|
+
}
|
|
1033
|
+
) : null
|
|
1034
|
+
] }) : null
|
|
1035
|
+
] });
|
|
967
1036
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
968
1037
|
reactNative.View,
|
|
969
1038
|
{
|
|
970
1039
|
style: [
|
|
971
1040
|
navStyles.topbarContainer,
|
|
972
1041
|
{ borderBottomColor: colors.border, backgroundColor: colors.background },
|
|
1042
|
+
stacked ? CONTAINER_STACKED : null,
|
|
973
1043
|
containerStyle
|
|
974
1044
|
],
|
|
975
1045
|
children: [
|
|
@@ -989,40 +1059,7 @@ var Topbar = ({
|
|
|
989
1059
|
}
|
|
990
1060
|
) : null,
|
|
991
1061
|
renderTextSlot(notificationSlot, { color: colors.text }),
|
|
992
|
-
|
|
993
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.userName, { color: colors.text }], children: user.name }),
|
|
994
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.userEmail, { color: colors.textSecondary }], children: user.email })
|
|
995
|
-
] }) : null,
|
|
996
|
-
richAccount ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: navStyles.userBlock, children: [
|
|
997
|
-
richAccount.onAccount ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
998
|
-
FocusableTouchable,
|
|
999
|
-
{
|
|
1000
|
-
accessibilityHint: richAccount.accountHint ?? richAccount.displayName,
|
|
1001
|
-
accessibilityLabel: richAccount.displayName,
|
|
1002
|
-
ringColor: primaryColor,
|
|
1003
|
-
style: navStyles.accountNameBtn,
|
|
1004
|
-
testID: richAccount.accountTestID ?? NAV_TEST_IDS.accountName,
|
|
1005
|
-
onPress: richAccount.onAccount,
|
|
1006
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], children: richAccount.displayName })
|
|
1007
|
-
}
|
|
1008
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], testID: NAV_TEST_IDS.accountName, children: richAccount.displayName }),
|
|
1009
|
-
richAccount.tenantName !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1010
|
-
reactNative.Text,
|
|
1011
|
-
{
|
|
1012
|
-
style: [navStyles.accountTenant, { color: colors.textSecondary }],
|
|
1013
|
-
testID: NAV_TEST_IDS.accountTenant,
|
|
1014
|
-
children: richAccount.tenantName
|
|
1015
|
-
}
|
|
1016
|
-
) : null,
|
|
1017
|
-
richAccount.plan ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1018
|
-
reactNative.View,
|
|
1019
|
-
{
|
|
1020
|
-
style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
|
|
1021
|
-
testID: NAV_TEST_IDS.accountPlan,
|
|
1022
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.planBadgeText, { color: TEXT_ON_PRIMARY }], children: richAccount.plan.label })
|
|
1023
|
-
}
|
|
1024
|
-
) : null
|
|
1025
|
-
] }) : null,
|
|
1062
|
+
stacked ? null : identityBlocks,
|
|
1026
1063
|
legacyAccount ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1027
1064
|
FocusableTouchable,
|
|
1028
1065
|
{
|
|
@@ -1032,7 +1069,7 @@ var Topbar = ({
|
|
|
1032
1069
|
style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
|
|
1033
1070
|
testID: legacyAccount.testID,
|
|
1034
1071
|
onPress: legacyAccount.onPress,
|
|
1035
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color:
|
|
1072
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: legacyAccount.label })
|
|
1036
1073
|
}
|
|
1037
1074
|
) : null,
|
|
1038
1075
|
upgrade ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1044,7 +1081,7 @@ var Topbar = ({
|
|
|
1044
1081
|
style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
|
|
1045
1082
|
testID: upgrade.testID ?? NAV_TEST_IDS.accountUpgrade,
|
|
1046
1083
|
onPress: upgrade.onPress,
|
|
1047
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color:
|
|
1084
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: upgrade.label })
|
|
1048
1085
|
}
|
|
1049
1086
|
) : null,
|
|
1050
1087
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1056,10 +1093,11 @@ var Topbar = ({
|
|
|
1056
1093
|
style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
|
|
1057
1094
|
testID: logout.testID,
|
|
1058
1095
|
onPress: richAccount ? richAccount.onLogout : logout.onPress,
|
|
1059
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color:
|
|
1096
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: logout.label })
|
|
1060
1097
|
}
|
|
1061
1098
|
)
|
|
1062
|
-
] })
|
|
1099
|
+
] }),
|
|
1100
|
+
stacked ? identityBlocks : null
|
|
1063
1101
|
]
|
|
1064
1102
|
}
|
|
1065
1103
|
);
|
|
@@ -1621,17 +1659,6 @@ var Nav = (props) => {
|
|
|
1621
1659
|
}
|
|
1622
1660
|
return /* @__PURE__ */ jsxRuntime.jsx(NavBar, { ...props });
|
|
1623
1661
|
};
|
|
1624
|
-
var RAIL_FULL_BREAKPOINT = uiLayout.LAYOUT_COLLAPSE_BREAKPOINT;
|
|
1625
|
-
var DEFAULT_COLLAPSED_RAIL_MAX = 1024;
|
|
1626
|
-
function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
|
|
1627
|
-
if (!hasSidebar) return "none";
|
|
1628
|
-
if (hasCollapsed) {
|
|
1629
|
-
if (viewport >= range.max) return "full";
|
|
1630
|
-
if (viewport >= range.min) return "collapsed";
|
|
1631
|
-
return "drawer";
|
|
1632
|
-
}
|
|
1633
|
-
return viewport >= RAIL_FULL_BREAKPOINT ? "full" : "drawer";
|
|
1634
|
-
}
|
|
1635
1662
|
var styles5 = reactNative.StyleSheet.create({
|
|
1636
1663
|
band: { left: 0, position: "absolute", right: 0, top: 0 }
|
|
1637
1664
|
});
|