@dloizides/ui-nav 1.32.0 → 1.34.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
@@ -1023,8 +1023,10 @@ interface DarkModeControlProps {
1023
1023
  testID?: string;
1024
1024
  /** Extra container style overrides. */
1025
1025
  containerStyle?: ViewStyle | ViewStyle[];
1026
+ /** Show the text label beside the icon; an option without an icon always shows it. */
1027
+ showLabel?: boolean;
1026
1028
  }
1027
- declare const DarkModeControl: ({ value, options, onChange, regionLabel, variant, testID, containerStyle, }: DarkModeControlProps) => React.ReactElement | null;
1029
+ declare const DarkModeControl: ({ value, options, onChange, regionLabel, variant, testID, containerStyle, showLabel, }: DarkModeControlProps) => React.ReactElement | null;
1028
1030
 
1029
1031
  /**
1030
1032
  * NavBarLink — a SINGLE horizontal `NavBar` link, extracted so each link owns its
package/dist/index.d.ts CHANGED
@@ -1023,8 +1023,10 @@ interface DarkModeControlProps {
1023
1023
  testID?: string;
1024
1024
  /** Extra container style overrides. */
1025
1025
  containerStyle?: ViewStyle | ViewStyle[];
1026
+ /** Show the text label beside the icon; an option without an icon always shows it. */
1027
+ showLabel?: boolean;
1026
1028
  }
1027
- declare const DarkModeControl: ({ value, options, onChange, regionLabel, variant, testID, containerStyle, }: DarkModeControlProps) => React.ReactElement | null;
1029
+ declare const DarkModeControl: ({ value, options, onChange, regionLabel, variant, testID, containerStyle, showLabel, }: DarkModeControlProps) => React.ReactElement | null;
1028
1030
 
1029
1031
  /**
1030
1032
  * NavBarLink — a SINGLE horizontal `NavBar` link, extracted so each link owns its
package/dist/index.js CHANGED
@@ -952,6 +952,8 @@ function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
952
952
  var TEXT_ON_PRIMARY = "#ffffff";
953
953
  var ON_BRAND_SCALE = "onBrand";
954
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 };
955
957
  var MAIN_STEP = "500";
956
958
  var WRAP_ANYWHERE = reactNative.Platform.OS === "web" ? { overflowWrap: "anywhere" } : null;
957
959
  function isAccountState(account) {
@@ -986,16 +988,58 @@ var Topbar = ({
986
988
  const primaryColor = theme.palette.primary["500"];
987
989
  const onPrimaryInk = onBrandInk(theme.palette);
988
990
  const { width: viewportWidth } = reactNative.useWindowDimensions();
989
- const userBlockStyle = [navStyles.userBlock, viewportWidth < RAIL_FULL_BREAKPOINT ? USER_BLOCK_COMPACT : null];
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
+ ];
990
997
  const richAccount = account !== void 0 && isAccountState(account) ? account : void 0;
991
998
  const legacyAccount = account !== void 0 && !isAccountState(account) ? account : void 0;
992
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
+ ] });
993
1036
  return /* @__PURE__ */ jsxRuntime.jsxs(
994
1037
  reactNative.View,
995
1038
  {
996
1039
  style: [
997
1040
  navStyles.topbarContainer,
998
1041
  { borderBottomColor: colors.border, backgroundColor: colors.background },
1042
+ stacked ? CONTAINER_STACKED : null,
999
1043
  containerStyle
1000
1044
  ],
1001
1045
  children: [
@@ -1015,40 +1059,7 @@ var Topbar = ({
1015
1059
  }
1016
1060
  ) : null,
1017
1061
  renderTextSlot(notificationSlot, { color: colors.text }),
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 })
1021
- ] }) : null,
1022
- richAccount ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: userBlockStyle, children: [
1023
- richAccount.onAccount ? /* @__PURE__ */ jsxRuntime.jsx(
1024
- FocusableTouchable,
1025
- {
1026
- accessibilityHint: richAccount.accountHint ?? richAccount.displayName,
1027
- accessibilityLabel: richAccount.displayName,
1028
- ringColor: primaryColor,
1029
- style: navStyles.accountNameBtn,
1030
- testID: richAccount.accountTestID ?? NAV_TEST_IDS.accountName,
1031
- onPress: richAccount.onAccount,
1032
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], children: richAccount.displayName })
1033
- }
1034
- ) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], testID: NAV_TEST_IDS.accountName, children: richAccount.displayName }),
1035
- richAccount.tenantName !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1036
- reactNative.Text,
1037
- {
1038
- style: [navStyles.accountTenant, { color: colors.textSecondary }],
1039
- testID: NAV_TEST_IDS.accountTenant,
1040
- children: richAccount.tenantName
1041
- }
1042
- ) : null,
1043
- richAccount.plan ? /* @__PURE__ */ jsxRuntime.jsx(
1044
- reactNative.View,
1045
- {
1046
- style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
1047
- testID: NAV_TEST_IDS.accountPlan,
1048
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.planBadgeText, { color: planBadgeInk(theme, richAccount.plan.tone) }], children: richAccount.plan.label })
1049
- }
1050
- ) : null
1051
- ] }) : null,
1062
+ stacked ? null : identityBlocks,
1052
1063
  legacyAccount ? /* @__PURE__ */ jsxRuntime.jsx(
1053
1064
  FocusableTouchable,
1054
1065
  {
@@ -1085,7 +1096,8 @@ var Topbar = ({
1085
1096
  children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: logout.label })
1086
1097
  }
1087
1098
  )
1088
- ] })
1099
+ ] }),
1100
+ stacked ? identityBlocks : null
1089
1101
  ]
1090
1102
  }
1091
1103
  );
@@ -2254,7 +2266,8 @@ var DarkModeControl = ({
2254
2266
  regionLabel,
2255
2267
  variant = "segmented",
2256
2268
  testID,
2257
- containerStyle
2269
+ containerStyle,
2270
+ showLabel = false
2258
2271
  }) => {
2259
2272
  const { theme } = uiFeedback.useUi();
2260
2273
  const colors = theme.colors;
@@ -2268,6 +2281,7 @@ var DarkModeControl = ({
2268
2281
  if (next !== void 0) onChange(next.value);
2269
2282
  }, [options, currentIndex, onChange]);
2270
2283
  if (options.length === 0 || current === void 0) return null;
2284
+ const labelVisible = (option) => showLabel || typeof option.renderIcon !== "function";
2271
2285
  if (variant === "cycle") {
2272
2286
  const iconColor = colors.text;
2273
2287
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-label": regionLabel, style: containerStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2281,7 +2295,7 @@ var DarkModeControl = ({
2281
2295
  onPress: advance,
2282
2296
  children: [
2283
2297
  typeof current.renderIcon === "function" ? current.renderIcon(iconColor, DARK_MODE_ICON_SIZE) : null,
2284
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [darkModeStyles.cycleText, { color: colors.text }], children: current.label })
2298
+ labelVisible(current) ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [darkModeStyles.cycleText, { color: colors.text }], children: current.label }) : null
2285
2299
  ]
2286
2300
  }
2287
2301
  ) });
@@ -2306,7 +2320,7 @@ var DarkModeControl = ({
2306
2320
  onPress: () => onChange(option.value),
2307
2321
  children: [
2308
2322
  typeof option.renderIcon === "function" ? option.renderIcon(textColor, DARK_MODE_ICON_SIZE) : null,
2309
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [darkModeStyles.segmentText, { color: textColor }], children: option.label })
2323
+ labelVisible(option) ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [darkModeStyles.segmentText, { color: textColor }], children: option.label }) : null
2310
2324
  ]
2311
2325
  },
2312
2326
  option.value