@dloizides/ui-nav 1.30.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.mjs CHANGED
@@ -28,6 +28,9 @@ var navStyles = StyleSheet.create({
28
28
  borderRightWidth: 1,
29
29
  height: "100%"
30
30
  },
31
+ sidebarBrand: {
32
+ marginBottom: 12
33
+ },
31
34
  sidebarTitle: {
32
35
  fontWeight: "700",
33
36
  marginBottom: 12
@@ -57,7 +60,7 @@ var navStyles = StyleSheet.create({
57
60
  },
58
61
  // --- Topbar ---
59
62
  topbarContainer: {
60
- height: 64,
63
+ minHeight: 64,
61
64
  paddingHorizontal: 12,
62
65
  borderBottomWidth: 1,
63
66
  flexDirection: "row",
@@ -78,7 +81,7 @@ var navStyles = StyleSheet.create({
78
81
  userBlock: { marginHorizontal: 12, alignItems: "flex-end", flexShrink: 1, minWidth: 0 },
79
82
  userName: { fontWeight: "600", maxWidth: "100%" },
80
83
  accountNameBtn: { flexShrink: 1, maxWidth: "100%", minHeight: MIN_TOUCH_TARGET, minWidth: MIN_TOUCH_TARGET, justifyContent: "center", alignItems: "flex-end" },
81
- userEmail: { fontSize: 12 },
84
+ userEmail: { fontSize: 12, maxWidth: "100%" },
82
85
  accountBtn: {
83
86
  marginLeft: 8,
84
87
  paddingHorizontal: 10,
@@ -815,7 +818,7 @@ var Sidebar = ({
815
818
  containerStyle
816
819
  ],
817
820
  children: [
818
- /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [navStyles.sidebarTitle, { color: colors.text }], children: title }),
821
+ typeof title === "string" ? /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [navStyles.sidebarTitle, { color: colors.text }], children: title }) : /* @__PURE__ */ jsx(View, { style: navStyles.sidebarBrand, children: title }),
819
822
  showInlineSearch && search !== void 0 ? /* @__PURE__ */ jsx(
820
823
  SidebarSearch,
821
824
  {
@@ -929,7 +932,22 @@ var FocusableTouchable = ({
929
932
  }
930
933
  );
931
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
+ }
932
946
  var TEXT_ON_PRIMARY = "#ffffff";
947
+ var ON_BRAND_SCALE = "onBrand";
948
+ var USER_BLOCK_COMPACT = { marginHorizontal: 4 };
949
+ var MAIN_STEP = "500";
950
+ var WRAP_ANYWHERE = Platform.OS === "web" ? { overflowWrap: "anywhere" } : null;
933
951
  function isAccountState(account) {
934
952
  return "displayName" in account;
935
953
  }
@@ -939,6 +957,14 @@ function planToneColor(theme, tone) {
939
957
  if (tone === "enterprise") return palette.accent?.["500"] ?? palette.primary["500"];
940
958
  return theme.colors.textSecondary;
941
959
  }
960
+ function onBrandInk(palette) {
961
+ const scales = palette;
962
+ return scales[ON_BRAND_SCALE]?.[MAIN_STEP] ?? TEXT_ON_PRIMARY;
963
+ }
964
+ function planBadgeInk(theme, tone) {
965
+ const fillIsPrimary = planToneColor(theme, tone) === theme.palette.primary["500"];
966
+ return fillIsPrimary ? onBrandInk(theme.palette) : TEXT_ON_PRIMARY;
967
+ }
942
968
  var Topbar = ({
943
969
  left,
944
970
  center,
@@ -952,6 +978,9 @@ var Topbar = ({
952
978
  const { theme } = useUi();
953
979
  const colors = theme.colors;
954
980
  const primaryColor = theme.palette.primary["500"];
981
+ const onPrimaryInk = onBrandInk(theme.palette);
982
+ const { width: viewportWidth } = useWindowDimensions();
983
+ const userBlockStyle = [navStyles.userBlock, viewportWidth < RAIL_FULL_BREAKPOINT ? USER_BLOCK_COMPACT : null];
955
984
  const richAccount = account !== void 0 && isAccountState(account) ? account : void 0;
956
985
  const legacyAccount = account !== void 0 && !isAccountState(account) ? account : void 0;
957
986
  const upgrade = richAccount?.upgrade;
@@ -980,11 +1009,11 @@ var Topbar = ({
980
1009
  }
981
1010
  ) : null,
982
1011
  renderTextSlot(notificationSlot, { color: colors.text }),
983
- user ? /* @__PURE__ */ jsxs(View, { style: navStyles.userBlock, children: [
984
- /* @__PURE__ */ jsx(Text, { style: [navStyles.userName, { color: colors.text }], children: user.name }),
985
- /* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, { color: colors.textSecondary }], children: user.email })
1012
+ user ? /* @__PURE__ */ jsxs(View, { accessible: true, accessibilityLabel: `${user.name}, ${user.email}`, style: userBlockStyle, children: [
1013
+ /* @__PURE__ */ jsx(Text, { style: [navStyles.userName, WRAP_ANYWHERE, { color: colors.text }], children: user.name }),
1014
+ /* @__PURE__ */ jsx(Text, { style: [navStyles.userEmail, WRAP_ANYWHERE, { color: colors.textSecondary }], children: user.email })
986
1015
  ] }) : null,
987
- richAccount ? /* @__PURE__ */ jsxs(View, { style: navStyles.userBlock, children: [
1016
+ richAccount ? /* @__PURE__ */ jsxs(View, { style: userBlockStyle, children: [
988
1017
  richAccount.onAccount ? /* @__PURE__ */ jsx(
989
1018
  FocusableTouchable,
990
1019
  {
@@ -1010,7 +1039,7 @@ var Topbar = ({
1010
1039
  {
1011
1040
  style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
1012
1041
  testID: NAV_TEST_IDS.accountPlan,
1013
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.planBadgeText, { color: TEXT_ON_PRIMARY }], children: richAccount.plan.label })
1042
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.planBadgeText, { color: planBadgeInk(theme, richAccount.plan.tone) }], children: richAccount.plan.label })
1014
1043
  }
1015
1044
  ) : null
1016
1045
  ] }) : null,
@@ -1023,7 +1052,7 @@ var Topbar = ({
1023
1052
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1024
1053
  testID: legacyAccount.testID,
1025
1054
  onPress: legacyAccount.onPress,
1026
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: legacyAccount.label })
1055
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: legacyAccount.label })
1027
1056
  }
1028
1057
  ) : null,
1029
1058
  upgrade ? /* @__PURE__ */ jsx(
@@ -1035,7 +1064,7 @@ var Topbar = ({
1035
1064
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1036
1065
  testID: upgrade.testID ?? NAV_TEST_IDS.accountUpgrade,
1037
1066
  onPress: upgrade.onPress,
1038
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: upgrade.label })
1067
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: upgrade.label })
1039
1068
  }
1040
1069
  ) : null,
1041
1070
  /* @__PURE__ */ jsx(
@@ -1047,7 +1076,7 @@ var Topbar = ({
1047
1076
  style: [navStyles.accountBtn, { backgroundColor: primaryColor }],
1048
1077
  testID: logout.testID,
1049
1078
  onPress: richAccount ? richAccount.onLogout : logout.onPress,
1050
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: TEXT_ON_PRIMARY }], children: logout.label })
1079
+ children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: logout.label })
1051
1080
  }
1052
1081
  )
1053
1082
  ] })
@@ -1612,17 +1641,6 @@ var Nav = (props) => {
1612
1641
  }
1613
1642
  return /* @__PURE__ */ jsx(NavBar, { ...props });
1614
1643
  };
1615
- var RAIL_FULL_BREAKPOINT = LAYOUT_COLLAPSE_BREAKPOINT;
1616
- var DEFAULT_COLLAPSED_RAIL_MAX = 1024;
1617
- function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
1618
- if (!hasSidebar) return "none";
1619
- if (hasCollapsed) {
1620
- if (viewport >= range.max) return "full";
1621
- if (viewport >= range.min) return "collapsed";
1622
- return "drawer";
1623
- }
1624
- return viewport >= RAIL_FULL_BREAKPOINT ? "full" : "drawer";
1625
- }
1626
1644
  var styles5 = StyleSheet.create({
1627
1645
  band: { left: 0, position: "absolute", right: 0, top: 0 }
1628
1646
  });
@@ -2067,7 +2085,7 @@ var NavShell = ({
2067
2085
  renderChevron: sideRail.renderChevron,
2068
2086
  search: sideRail.search,
2069
2087
  searchQuery: sideRail.searchQuery,
2070
- title: sideRail.title,
2088
+ title: sideRail.brand ?? sideRail.title,
2071
2089
  onNavigate,
2072
2090
  onSearchChange: sideRail.onSearchChange
2073
2091
  }