@bensdev/react-sidebar 0.1.0 → 0.3.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.ts CHANGED
@@ -46,7 +46,12 @@ interface SidebarActionItem extends SidebarItemBase {
46
46
  interface SidebarGroupItem extends SidebarItemBase {
47
47
  type: 'group';
48
48
  items: SidebarItem[];
49
- /** `false` renders a static section: label as heading, children always visible. */
49
+ /**
50
+ * `false` renders a static section: label as heading, children always visible — including on
51
+ * the collapsed icon rail, where it overrides `collapsedGroupBehavior` entirely (no flyout, no
52
+ * hiding). Give the group an `icon` to also get a row for it on the rail; without one, only its
53
+ * (icon-bearing) children render there.
54
+ */
50
55
  collapsible?: boolean;
51
56
  defaultOpen?: boolean;
52
57
  open?: boolean;
@@ -176,6 +181,12 @@ interface SidebarProps {
176
181
  onOpenGroupsChange?: (ids: string[]) => void;
177
182
  accordion?: boolean;
178
183
  autoOpenActiveGroup?: boolean;
184
+ /**
185
+ * How a *collapsible* group presents once the sidebar collapses to its icon rail: a
186
+ * hover/focus flyout (default), inline-and-indented (`"expand"`), or trigger-only with
187
+ * children unreachable (`"ignore"`). Has no effect on `collapsible: false` groups — those
188
+ * always stay fully expanded, on the rail or off.
189
+ */
179
190
  collapsedGroupBehavior?: 'flyout' | 'expand' | 'ignore';
180
191
  mobileOpen?: boolean;
181
192
  onMobileClose?: () => void;
package/dist/index.js CHANGED
@@ -500,10 +500,17 @@ function SidebarGroupRow({ item, depth }) {
500
500
  children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 14 })
501
501
  }
502
502
  ),
503
- showTooltip && behavior !== "flyout" && /* @__PURE__ */ jsx(Tooltip, { id: tooltipId, className: ctx.classNames.tooltip, children: item.tooltip ?? item.label })
503
+ showTooltip && (!collapsible || behavior !== "flyout") && /* @__PURE__ */ jsx(Tooltip, { id: tooltipId, className: ctx.classNames.tooltip, children: item.tooltip ?? item.label })
504
504
  ]
505
505
  }
506
506
  );
507
+ if (!collapsible) {
508
+ const showTrigger = item.icon != null || !isRail;
509
+ return /* @__PURE__ */ jsxs("li", { className: cx("bsb-list-item", "bsb-group"), children: [
510
+ showTrigger && trigger,
511
+ /* @__PURE__ */ jsx("ul", { id: panelId, className: cx("bsb-group__panel", ctx.classNames.groupPanel), children: /* @__PURE__ */ jsx(SidebarNodeList, { items: item.items, depth: depth + 1 }) })
512
+ ] });
513
+ }
507
514
  if (isRail && behavior === "flyout") {
508
515
  return /* @__PURE__ */ jsxs("li", { className: cx("bsb-list-item", "bsb-group", "bsb-group--flyout"), children: [
509
516
  trigger,
@@ -526,7 +533,7 @@ function SidebarGroupRow({ item, depth }) {
526
533
  }
527
534
  return /* @__PURE__ */ jsxs("li", { className: cx("bsb-list-item", "bsb-group"), children: [
528
535
  trigger,
529
- (isOpen || !collapsible) && /* @__PURE__ */ jsx("ul", { id: panelId, className: cx("bsb-group__panel", ctx.classNames.groupPanel), children: /* @__PURE__ */ jsx(SidebarNodeList, { items: item.items, depth: depth + 1 }) })
536
+ isOpen && /* @__PURE__ */ jsx("ul", { id: panelId, className: cx("bsb-group__panel", ctx.classNames.groupPanel), children: /* @__PURE__ */ jsx(SidebarNodeList, { items: item.items, depth: depth + 1 }) })
530
537
  ] });
531
538
  }
532
539
  function SidebarNode({ item, depth }) {
@@ -830,7 +837,10 @@ function MobileDrawer({
830
837
  closeLabel,
831
838
  classNames,
832
839
  durationMs = 400,
833
- children
840
+ children,
841
+ rootClassName,
842
+ rootStyle,
843
+ rootDataAttrs
834
844
  }) {
835
845
  const { mounted, state, onPanelTransitionEnd } = useMountTransition(open, durationMs);
836
846
  const panelRef = React21.useRef(null);
@@ -842,7 +852,7 @@ function MobileDrawer({
842
852
  useBodyScrollLock(lockScroll && open);
843
853
  if (!mounted) return null;
844
854
  const widthValue = typeof width === "number" ? `${width}px` : width;
845
- return /* @__PURE__ */ jsxs(Portal, { target: portalTarget, disabled: disablePortal, children: [
855
+ return /* @__PURE__ */ jsx(Portal, { target: portalTarget, disabled: disablePortal, children: /* @__PURE__ */ jsxs("div", { className: cx(rootClassName, "bsb-root--drawer-host"), style: rootStyle, ...rootDataAttrs, children: [
846
856
  /* @__PURE__ */ jsx(
847
857
  "div",
848
858
  {
@@ -881,7 +891,7 @@ function MobileDrawer({
881
891
  ]
882
892
  }
883
893
  )
884
- ] });
894
+ ] }) });
885
895
  }
886
896
  function widthToCss(value) {
887
897
  if (value == null) return void 0;
@@ -1125,35 +1135,32 @@ var Sidebar = React21.forwardRef(function Sidebar2(props, ref) {
1125
1135
  )
1126
1136
  }
1127
1137
  ),
1128
- isMobile && /* @__PURE__ */ jsx(
1129
- "div",
1130
- {
1131
- ref: rootRef,
1132
- className: rootClassName,
1133
- style: mergedStyle,
1134
- ...rootDataAttrs,
1135
- children: /* @__PURE__ */ jsx(
1136
- MobileDrawer,
1137
- {
1138
- open: mobileOpen,
1139
- onClose: closeMobile,
1140
- ariaLabel,
1141
- width: drawerWidth,
1142
- position,
1143
- closeOnEscape,
1144
- closeOnBackdropClick,
1145
- trapFocus,
1146
- lockScroll,
1147
- restoreFocus,
1148
- portalTarget,
1149
- disablePortal,
1150
- closeLabel: "Close navigation",
1151
- classNames,
1152
- children: /* @__PURE__ */ jsx(SidebarShell, { ...shellProps, collapsed: false, showToggle: false, onToggle: toggleCollapsed, togglePosition: position, toggleStrategy, toggleLabels: { expand: "Expand sidebar", collapse: "Collapse sidebar" } })
1153
- }
1154
- )
1155
- }
1156
- )
1138
+ isMobile && /* @__PURE__ */ jsxs(Fragment, { children: [
1139
+ /* @__PURE__ */ jsx("span", { ref: rootRef, "aria-hidden": "true", style: { display: "none" } }),
1140
+ /* @__PURE__ */ jsx(
1141
+ MobileDrawer,
1142
+ {
1143
+ open: mobileOpen,
1144
+ onClose: closeMobile,
1145
+ ariaLabel,
1146
+ width: drawerWidth,
1147
+ position,
1148
+ closeOnEscape,
1149
+ closeOnBackdropClick,
1150
+ trapFocus,
1151
+ lockScroll,
1152
+ restoreFocus,
1153
+ portalTarget,
1154
+ disablePortal,
1155
+ closeLabel: "Close navigation",
1156
+ classNames,
1157
+ rootClassName,
1158
+ rootStyle: mergedStyle,
1159
+ rootDataAttrs,
1160
+ children: /* @__PURE__ */ jsx(SidebarShell, { ...shellProps, collapsed: false, showToggle: false, onToggle: toggleCollapsed, togglePosition: position, toggleStrategy, toggleLabels: { expand: "Expand sidebar", collapse: "Collapse sidebar" } })
1161
+ }
1162
+ )
1163
+ ] })
1157
1164
  ] });
1158
1165
  });
1159
1166
  Sidebar.displayName = "Sidebar";
@@ -1168,7 +1175,7 @@ var greenMist = {
1168
1175
  radiusAction: "4px",
1169
1176
  ease: "cubic-bezier(0.16, 1, 0.3, 1)",
1170
1177
  shadowLogo: "0 1px 2px rgba(10,37,16,0.05)",
1171
- shadowToggle: "0 4px 12px rgba(10,37,16,0.08)",
1178
+ shadowToggle: "0 4px 10px rgba(10,37,16,0.28), 0 1px 3px rgba(10,37,16,0.35)",
1172
1179
  shadowTooltip: "0 12px 32px rgba(10,37,16,0.12)",
1173
1180
  shadowDrawer: "0 24px 48px rgba(10,37,16,0.16)",
1174
1181
  badgeFontSize: "9px",
@@ -1190,10 +1197,10 @@ var greenMist = {
1190
1197
  tooltipBg: "#0a2510",
1191
1198
  tooltipFg: "#d9eed9",
1192
1199
  tooltipBorder: "#175423",
1193
- toggleBg: "#2d8a3e",
1194
- toggleHoverBg: "#4faa5a",
1200
+ toggleBg: "#175423",
1201
+ toggleHoverBg: "#1f6e2e",
1195
1202
  toggleFg: "#ffffff",
1196
- toggleBorder: "#175423",
1203
+ toggleBorder: "rgba(255,255,255,0.14)",
1197
1204
  avatarBg: "#2d8a3e",
1198
1205
  avatarFg: "#ffffff",
1199
1206
  avatarRing: "rgba(79,170,90,0.4)",
@@ -1229,7 +1236,7 @@ var greenMist = {
1229
1236
  toggleBg: "#27272a",
1230
1237
  toggleHoverBg: "#333333",
1231
1238
  toggleFg: "#e2e2e2",
1232
- toggleBorder: "#3d3d3d",
1239
+ toggleBorder: "rgba(255,255,255,0.14)",
1233
1240
  avatarBg: "#27272a",
1234
1241
  avatarFg: "#e2e2e2",
1235
1242
  avatarRing: "rgba(255,255,255,0.1)",