@dloizides/ui-nav 1.37.0 → 1.38.1

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
@@ -839,8 +839,8 @@ var SIDEBAR_WIDTH_PX = {
839
839
  lg: 288
840
840
  };
841
841
  var NAV_BRAND_DEFAULTS = {
842
- brandPlacement: "sidebar",
843
- sidebarWidth: "default",
842
+ placement: "sidebar",
843
+ railWidth: "default",
844
844
  drawerHeader: "none",
845
845
  drawerWidth: "default"
846
846
  };
@@ -861,7 +861,6 @@ var Sidebar = ({
861
861
  pathname,
862
862
  onNavigate,
863
863
  title,
864
- width: railWidth = "default",
865
864
  regionLabel,
866
865
  navigateHint = (label) => label,
867
866
  expandHint = "",
@@ -909,7 +908,7 @@ var Sidebar = ({
909
908
  role: "navigation",
910
909
  style: [
911
910
  navStyles.sidebarContainer,
912
- { width: SIDEBAR_WIDTH_PX[railWidth] },
911
+ { width: SIDEBAR_WIDTH_PX.default },
913
912
  { backgroundColor: colors.surface, borderRightColor: colors.border },
914
913
  containerStyle
915
914
  ],
@@ -1909,7 +1908,7 @@ var styles9 = StyleSheet.create({
1909
1908
  // so on react-native-web it — and the nav leaves inside it — sit above the scrim
1910
1909
  // and receive presses instead of the scrim swallowing them.
1911
1910
  panel: { position: "absolute", top: 0, bottom: 0, left: 0, width: DRAWER_WIDTH, zIndex: PANEL_Z_INDEX },
1912
- panelFull: { width: "100%" },
1911
+ windowFill: { right: void 0, bottom: void 0 },
1913
1912
  panelBody: { flex: 1 },
1914
1913
  menuToggle: {
1915
1914
  minWidth: MIN_TOUCH_TARGET,
@@ -1947,6 +1946,8 @@ var MobileDrawer = ({
1947
1946
  const { theme } = useUi();
1948
1947
  const panelRef = useRef(null);
1949
1948
  const isFull = width === "full";
1949
+ const viewport = useWindowDimensions();
1950
+ const windowSize = isFull ? [styles9.windowFill, { width: viewport.width, height: viewport.height }] : null;
1950
1951
  const showHeaderBar = header !== void 0 || isFull;
1951
1952
  useEffect(() => {
1952
1953
  const node = panelRef.current;
@@ -1961,7 +1962,7 @@ var MobileDrawer = ({
1961
1962
  node.addEventListener("click", handleClick);
1962
1963
  return () => node.removeEventListener("click", handleClick);
1963
1964
  }, [onClose]);
1964
- return /* @__PURE__ */ jsxs(View, { style: styles9.overlay, children: [
1965
+ return /* @__PURE__ */ jsxs(View, { style: [styles9.overlay, windowSize], children: [
1965
1966
  isFull ? null : /* @__PURE__ */ jsx(
1966
1967
  Pressable,
1967
1968
  {
@@ -1979,7 +1980,7 @@ var MobileDrawer = ({
1979
1980
  ref: panelRef,
1980
1981
  "aria-modal": true,
1981
1982
  role: "dialog",
1982
- style: [styles9.panel, isFull ? styles9.panelFull : null, { backgroundColor: theme.colors.surface }],
1983
+ style: [styles9.panel, windowSize, { backgroundColor: theme.colors.surface }],
1983
1984
  testID: drawerTestID,
1984
1985
  children: [
1985
1986
  showHeaderBar ? /* @__PURE__ */ jsx(
@@ -2188,7 +2189,7 @@ function renderShellSidebar({ sideRail, nav, width, showBrand }) {
2188
2189
  Sidebar,
2189
2190
  {
2190
2191
  collapseHint: sideRail.collapseHint,
2191
- containerStyle: sideRail.containerStyle,
2192
+ containerStyle: { width: SIDEBAR_WIDTH_PX[width], ...StyleSheet.flatten(sideRail.containerStyle) },
2192
2193
  enableInlineSearch: sideRail.enableInlineSearch,
2193
2194
  expandHint: sideRail.expandHint,
2194
2195
  footer: sideRail.footer,
@@ -2202,7 +2203,6 @@ function renderShellSidebar({ sideRail, nav, width, showBrand }) {
2202
2203
  search: sideRail.search,
2203
2204
  searchQuery: sideRail.searchQuery,
2204
2205
  title: showBrand ? brandSlot : null,
2205
- width,
2206
2206
  onNavigate: nav.onNavigate,
2207
2207
  onSearchChange: sideRail.onSearchChange
2208
2208
  }
@@ -2210,14 +2210,15 @@ function renderShellSidebar({ sideRail, nav, width, showBrand }) {
2210
2210
  }
2211
2211
  var styles11 = StyleSheet.create({
2212
2212
  row: { flexDirection: "row", alignItems: "center" },
2213
- brand: { justifyContent: "center", paddingHorizontal: 12 },
2213
+ brand: { justifyContent: "center", alignSelf: "stretch", paddingHorizontal: 12, borderBottomWidth: 1 },
2214
2214
  fill: { flex: 1 }
2215
2215
  });
2216
2216
  var TopbarBrandRow = ({ brand, brandWidth, testID, children }) => {
2217
2217
  const { width } = useWindowDimensions();
2218
+ const { colors } = useUi().theme;
2218
2219
  if (width < RAIL_FULL_BREAKPOINT) return /* @__PURE__ */ jsx(Fragment, { children });
2219
2220
  return /* @__PURE__ */ jsxs(View, { style: styles11.row, testID, children: [
2220
- /* @__PURE__ */ jsx(View, { style: [styles11.brand, brandWidth !== void 0 ? { width: brandWidth } : null], testID: `${testID}-brand`, children: brand }),
2221
+ /* @__PURE__ */ jsx(View, { style: [styles11.brand, { backgroundColor: colors.background, borderBottomColor: colors.border }, brandWidth !== void 0 ? { width: brandWidth } : null], testID: `${testID}-brand`, children: brand }),
2221
2222
  /* @__PURE__ */ jsx(View, { style: styles11.fill, children })
2222
2223
  ] });
2223
2224
  };
@@ -2239,10 +2240,7 @@ var NavShell = ({
2239
2240
  children,
2240
2241
  collapsedSidebar: collapsedSidebarProp,
2241
2242
  collapsedRailRange: collapsedRailRangeProp,
2242
- brandPlacement = NAV_BRAND_DEFAULTS.brandPlacement,
2243
- sidebarWidth = NAV_BRAND_DEFAULTS.sidebarWidth,
2244
- drawerHeader = NAV_BRAND_DEFAULTS.drawerHeader,
2245
- drawerWidth = NAV_BRAND_DEFAULTS.drawerWidth,
2243
+ brand,
2246
2244
  mobileMenu,
2247
2245
  ...shellProps
2248
2246
  }) => {
@@ -2271,11 +2269,12 @@ var NavShell = ({
2271
2269
  ) : null;
2272
2270
  const nav = { pathname, onNavigate, regionLabel, navigateHint };
2273
2271
  const rail = showSideRail ? sideRail : void 0;
2274
- const brandInBar = brandPlacement === "topbar" && rail?.brand !== void 0;
2272
+ const { placement, railWidth, drawerHeader, drawerWidth } = { ...NAV_BRAND_DEFAULTS, ...brand };
2273
+ const brandInBar = placement === "topbar" && rail?.brand !== void 0;
2275
2274
  const brandInDrawer = drawerHeader === "brand" ? rail?.brand : void 0;
2276
- const sidebarNode = rail === void 0 ? void 0 : renderShellSidebar({ sideRail: rail, nav, width: sidebarWidth, showBrand: !brandInBar });
2277
- const drawerSidebar = rail !== void 0 && brandInDrawer !== void 0 && !brandInBar ? renderShellSidebar({ sideRail: rail, nav, width: sidebarWidth, showBrand: false }) : void 0;
2278
- const shellHeader = brandInBar ? /* @__PURE__ */ jsx(TopbarBrandRow, { brand: rail?.brand, brandWidth: SIDEBAR_WIDTH_PX[sidebarWidth], testID: `${shellProps.testID}-topbar-brand-row`, children: headerNode }) : headerNode;
2275
+ const sidebarNode = rail === void 0 ? void 0 : renderShellSidebar({ sideRail: rail, nav, width: railWidth, showBrand: !brandInBar });
2276
+ const drawerSidebar = rail !== void 0 && brandInDrawer !== void 0 && !brandInBar ? renderShellSidebar({ sideRail: rail, nav, width: railWidth, showBrand: false }) : void 0;
2277
+ const shellHeader = brandInBar ? /* @__PURE__ */ jsx(TopbarBrandRow, { brand: rail?.brand, brandWidth: SIDEBAR_WIDTH_PX[railWidth], testID: `${shellProps.testID}-topbar-brand-row`, children: headerNode }) : headerNode;
2279
2278
  const collapsedCfg = showSideRail ? sideRail?.collapsed : void 0;
2280
2279
  const collapsedNode = collapsedCfg !== void 0 && sideRail !== void 0 ? /* @__PURE__ */ jsx(
2281
2280
  CollapsedRail,