@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.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
 
@@ -946,6 +946,8 @@ function resolveRailMode({ viewport, hasSidebar, hasCollapsed, range }) {
946
946
  var TEXT_ON_PRIMARY = "#ffffff";
947
947
  var ON_BRAND_SCALE = "onBrand";
948
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 };
949
951
  var MAIN_STEP = "500";
950
952
  var WRAP_ANYWHERE = Platform.OS === "web" ? { overflowWrap: "anywhere" } : null;
951
953
  function isAccountState(account) {
@@ -980,16 +982,58 @@ var Topbar = ({
980
982
  const primaryColor = theme.palette.primary["500"];
981
983
  const onPrimaryInk = onBrandInk(theme.palette);
982
984
  const { width: viewportWidth } = useWindowDimensions();
983
- const userBlockStyle = [navStyles.userBlock, viewportWidth < RAIL_FULL_BREAKPOINT ? USER_BLOCK_COMPACT : null];
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
+ ];
984
991
  const richAccount = account !== void 0 && isAccountState(account) ? account : void 0;
985
992
  const legacyAccount = account !== void 0 && !isAccountState(account) ? account : void 0;
986
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
+ ] });
987
1030
  return /* @__PURE__ */ jsxs(
988
1031
  View,
989
1032
  {
990
1033
  style: [
991
1034
  navStyles.topbarContainer,
992
1035
  { borderBottomColor: colors.border, backgroundColor: colors.background },
1036
+ stacked ? CONTAINER_STACKED : null,
993
1037
  containerStyle
994
1038
  ],
995
1039
  children: [
@@ -1009,40 +1053,7 @@ var Topbar = ({
1009
1053
  }
1010
1054
  ) : null,
1011
1055
  renderTextSlot(notificationSlot, { color: colors.text }),
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 })
1015
- ] }) : null,
1016
- richAccount ? /* @__PURE__ */ jsxs(View, { style: userBlockStyle, children: [
1017
- richAccount.onAccount ? /* @__PURE__ */ jsx(
1018
- FocusableTouchable,
1019
- {
1020
- accessibilityHint: richAccount.accountHint ?? richAccount.displayName,
1021
- accessibilityLabel: richAccount.displayName,
1022
- ringColor: primaryColor,
1023
- style: navStyles.accountNameBtn,
1024
- testID: richAccount.accountTestID ?? NAV_TEST_IDS.accountName,
1025
- onPress: richAccount.onAccount,
1026
- children: /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], children: richAccount.displayName })
1027
- }
1028
- ) : /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [navStyles.userName, { color: colors.text }], testID: NAV_TEST_IDS.accountName, children: richAccount.displayName }),
1029
- richAccount.tenantName !== void 0 ? /* @__PURE__ */ jsx(
1030
- Text,
1031
- {
1032
- style: [navStyles.accountTenant, { color: colors.textSecondary }],
1033
- testID: NAV_TEST_IDS.accountTenant,
1034
- children: richAccount.tenantName
1035
- }
1036
- ) : null,
1037
- richAccount.plan ? /* @__PURE__ */ jsx(
1038
- View,
1039
- {
1040
- style: [navStyles.planBadge, { backgroundColor: planToneColor(theme, richAccount.plan.tone) }],
1041
- testID: NAV_TEST_IDS.accountPlan,
1042
- children: /* @__PURE__ */ jsx(Text, { style: [navStyles.planBadgeText, { color: planBadgeInk(theme, richAccount.plan.tone) }], children: richAccount.plan.label })
1043
- }
1044
- ) : null
1045
- ] }) : null,
1056
+ stacked ? null : identityBlocks,
1046
1057
  legacyAccount ? /* @__PURE__ */ jsx(
1047
1058
  FocusableTouchable,
1048
1059
  {
@@ -1079,7 +1090,8 @@ var Topbar = ({
1079
1090
  children: /* @__PURE__ */ jsx(Text, { style: [navStyles.accountText, { color: onPrimaryInk }], children: logout.label })
1080
1091
  }
1081
1092
  )
1082
- ] })
1093
+ ] }),
1094
+ stacked ? identityBlocks : null
1083
1095
  ]
1084
1096
  }
1085
1097
  );
@@ -2248,7 +2260,8 @@ var DarkModeControl = ({
2248
2260
  regionLabel,
2249
2261
  variant = "segmented",
2250
2262
  testID,
2251
- containerStyle
2263
+ containerStyle,
2264
+ showLabel = false
2252
2265
  }) => {
2253
2266
  const { theme } = useUi();
2254
2267
  const colors = theme.colors;
@@ -2262,6 +2275,7 @@ var DarkModeControl = ({
2262
2275
  if (next !== void 0) onChange(next.value);
2263
2276
  }, [options, currentIndex, onChange]);
2264
2277
  if (options.length === 0 || current === void 0) return null;
2278
+ const labelVisible = (option) => showLabel || typeof option.renderIcon !== "function";
2265
2279
  if (variant === "cycle") {
2266
2280
  const iconColor = colors.text;
2267
2281
  return /* @__PURE__ */ jsx(View, { "aria-label": regionLabel, style: containerStyle, children: /* @__PURE__ */ jsxs(
@@ -2275,7 +2289,7 @@ var DarkModeControl = ({
2275
2289
  onPress: advance,
2276
2290
  children: [
2277
2291
  typeof current.renderIcon === "function" ? current.renderIcon(iconColor, DARK_MODE_ICON_SIZE) : null,
2278
- /* @__PURE__ */ jsx(Text, { style: [darkModeStyles.cycleText, { color: colors.text }], children: current.label })
2292
+ labelVisible(current) ? /* @__PURE__ */ jsx(Text, { style: [darkModeStyles.cycleText, { color: colors.text }], children: current.label }) : null
2279
2293
  ]
2280
2294
  }
2281
2295
  ) });
@@ -2300,7 +2314,7 @@ var DarkModeControl = ({
2300
2314
  onPress: () => onChange(option.value),
2301
2315
  children: [
2302
2316
  typeof option.renderIcon === "function" ? option.renderIcon(textColor, DARK_MODE_ICON_SIZE) : null,
2303
- /* @__PURE__ */ jsx(Text, { style: [darkModeStyles.segmentText, { color: textColor }], children: option.label })
2317
+ labelVisible(option) ? /* @__PURE__ */ jsx(Text, { style: [darkModeStyles.segmentText, { color: textColor }], children: option.label }) : null
2304
2318
  ]
2305
2319
  },
2306
2320
  option.value