@dloizides/ui-nav 1.31.0 → 1.32.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 CHANGED
@@ -1392,7 +1392,7 @@ declare const navStyles: {
1392
1392
  paddingHorizontal: number;
1393
1393
  };
1394
1394
  topbarContainer: {
1395
- height: number;
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
- height: number;
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
- height: 64,
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,22 @@ 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 MAIN_STEP = "500";
956
+ var WRAP_ANYWHERE = reactNative.Platform.OS === "web" ? { overflowWrap: "anywhere" } : null;
942
957
  function isAccountState(account) {
943
958
  return "displayName" in account;
944
959
  }
@@ -948,6 +963,14 @@ function planToneColor(theme, tone) {
948
963
  if (tone === "enterprise") return palette.accent?.["500"] ?? palette.primary["500"];
949
964
  return theme.colors.textSecondary;
950
965
  }
966
+ function onBrandInk(palette) {
967
+ const scales = palette;
968
+ return scales[ON_BRAND_SCALE]?.[MAIN_STEP] ?? TEXT_ON_PRIMARY;
969
+ }
970
+ function planBadgeInk(theme, tone) {
971
+ const fillIsPrimary = planToneColor(theme, tone) === theme.palette.primary["500"];
972
+ return fillIsPrimary ? onBrandInk(theme.palette) : TEXT_ON_PRIMARY;
973
+ }
951
974
  var Topbar = ({
952
975
  left,
953
976
  center,
@@ -961,6 +984,9 @@ var Topbar = ({
961
984
  const { theme } = uiFeedback.useUi();
962
985
  const colors = theme.colors;
963
986
  const primaryColor = theme.palette.primary["500"];
987
+ const onPrimaryInk = onBrandInk(theme.palette);
988
+ const { width: viewportWidth } = reactNative.useWindowDimensions();
989
+ const userBlockStyle = [navStyles.userBlock, viewportWidth < RAIL_FULL_BREAKPOINT ? USER_BLOCK_COMPACT : null];
964
990
  const richAccount = account !== void 0 && isAccountState(account) ? account : void 0;
965
991
  const legacyAccount = account !== void 0 && !isAccountState(account) ? account : void 0;
966
992
  const upgrade = richAccount?.upgrade;
@@ -989,11 +1015,11 @@ var Topbar = ({
989
1015
  }
990
1016
  ) : null,
991
1017
  renderTextSlot(notificationSlot, { color: colors.text }),
992
- user ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: navStyles.userBlock, children: [
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 })
1018
+ user ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { accessible: true, accessibilityLabel: `${user.name}, ${user.email}`, style: userBlockStyle, children: [
1019
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.userName, WRAP_ANYWHERE, { color: colors.text }], children: user.name }),
1020
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.userEmail, WRAP_ANYWHERE, { color: colors.textSecondary }], children: user.email })
995
1021
  ] }) : null,
996
- richAccount ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: navStyles.userBlock, children: [
1022
+ richAccount ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: userBlockStyle, children: [
997
1023
  richAccount.onAccount ? /* @__PURE__ */ jsxRuntime.jsx(
998
1024
  FocusableTouchable,
999
1025
  {
@@ -1019,7 +1045,7 @@ var Topbar = ({
1019
1045
  {
1020
1046
  style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
1021
1047
  testID: NAV_TEST_IDS.accountPlan,
1022
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.planBadgeText, { color: TEXT_ON_PRIMARY }], children: richAccount.plan.label })
1048
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.planBadgeText, { color: planBadgeInk(theme, richAccount.plan.tone) }], children: richAccount.plan.label })
1023
1049
  }
1024
1050
  ) : null
1025
1051
  ] }) : null,
@@ -1032,7 +1058,7 @@ var Topbar = ({
1032
1058
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1033
1059
  testID: legacyAccount.testID,
1034
1060
  onPress: legacyAccount.onPress,
1035
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: legacyAccount.label })
1061
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: legacyAccount.label })
1036
1062
  }
1037
1063
  ) : null,
1038
1064
  upgrade ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -1044,7 +1070,7 @@ var Topbar = ({
1044
1070
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1045
1071
  testID: upgrade.testID ?? NAV_TEST_IDS.accountUpgrade,
1046
1072
  onPress: upgrade.onPress,
1047
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: upgrade.label })
1073
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: upgrade.label })
1048
1074
  }
1049
1075
  ) : null,
1050
1076
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1056,7 +1082,7 @@ var Topbar = ({
1056
1082
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1057
1083
  testID: logout.testID,
1058
1084
  onPress: richAccount ? richAccount.onLogout : logout.onPress,
1059
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: logout.label })
1085
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: logout.label })
1060
1086
  }
1061
1087
  )
1062
1088
  ] })
@@ -1621,17 +1647,6 @@ var Nav = (props) => {
1621
1647
  }
1622
1648
  return /* @__PURE__ */ jsxRuntime.jsx(NavBar, { ...props });
1623
1649
  };
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
1650
  var styles5 = reactNative.StyleSheet.create({
1636
1651
  band: { left: 0, position: "absolute", right: 0, top: 0 }
1637
1652
  });