@octaviaflow/core 3.0.9 → 3.0.10

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.js CHANGED
@@ -6418,6 +6418,7 @@ function DropdownMenu({
6418
6418
  items,
6419
6419
  align = "start",
6420
6420
  className,
6421
+ triggerClassName,
6421
6422
  "aria-label": ariaLabel,
6422
6423
  "aria-labelledby": ariaLabelledby
6423
6424
  }) {
@@ -6436,7 +6437,15 @@ function DropdownMenu({
6436
6437
  );
6437
6438
  const { onDrag, onDragStart, onDragEnd, onAnimationStart, ...safeTriggerProps } = buttonProps;
6438
6439
  return /* @__PURE__ */ jsxs28(Fragment6, { children: [
6439
- /* @__PURE__ */ jsx29("button", { ...safeTriggerProps, ref: triggerRef, className: "ods-dropdown__trigger", children: trigger }),
6440
+ /* @__PURE__ */ jsx29(
6441
+ "button",
6442
+ {
6443
+ ...safeTriggerProps,
6444
+ ref: triggerRef,
6445
+ className: triggerClassName ?? "ods-dropdown__trigger",
6446
+ children: trigger
6447
+ }
6448
+ ),
6440
6449
  /* @__PURE__ */ jsx29(
6441
6450
  MenuPopup,
6442
6451
  {
@@ -11139,15 +11148,17 @@ function Sidebar({
11139
11148
  className
11140
11149
  }) {
11141
11150
  const allSections = sections ?? (items ? [{ items }] : []);
11142
- const [internalPinned, setInternalPinned] = useState21(() => {
11143
- if (typeof window === "undefined") return defaultPinned;
11151
+ const [internalPinned, setInternalPinned] = useState21(defaultPinned);
11152
+ useEffect16(() => {
11153
+ if (pinnedProp !== void 0) return;
11144
11154
  try {
11145
11155
  const stored = window.localStorage.getItem(pinStorageKey);
11146
- if (stored !== null) return stored === "true";
11156
+ if (stored !== null && stored !== String(internalPinned)) {
11157
+ setInternalPinned(stored === "true");
11158
+ }
11147
11159
  } catch {
11148
11160
  }
11149
- return defaultPinned;
11150
- });
11161
+ }, []);
11151
11162
  const pinned = pinnedProp ?? internalPinned;
11152
11163
  const setPinned = useCallback16(
11153
11164
  (p) => {
@@ -11185,6 +11196,17 @@ function Sidebar({
11185
11196
  const autoMode = variant === "auto";
11186
11197
  const showAsRail = autoMode ? !pinned : variant === "rail";
11187
11198
  const overlayOpen = autoMode && !pinned && hoverOpen;
11199
+ useEffect16(() => {
11200
+ if (!overlayOpen) return;
11201
+ const handler = (e) => {
11202
+ if (e.key === "Escape") {
11203
+ clearTimers();
11204
+ setHoverOpen(false);
11205
+ }
11206
+ };
11207
+ window.addEventListener("keydown", handler);
11208
+ return () => window.removeEventListener("keydown", handler);
11209
+ }, [overlayOpen]);
11188
11210
  return /* @__PURE__ */ jsxs68(
11189
11211
  "nav",
11190
11212
  {
@@ -11290,17 +11312,34 @@ function RailLayout({
11290
11312
  },
11291
11313
  item.id
11292
11314
  )) }),
11293
- user && /* @__PURE__ */ jsx69(
11294
- "button",
11315
+ user && /* @__PURE__ */ jsx69(SidebarUserRail, { user })
11316
+ ] });
11317
+ }
11318
+ function SidebarUserRail({ user }) {
11319
+ const labelText = typeof user.name === "string" ? user.name : "User";
11320
+ const avatar = user.avatar ?? /* @__PURE__ */ jsx69("span", { children: user.initial ?? (typeof user.name === "string" ? user.name.charAt(0).toUpperCase() : "?") });
11321
+ if (user.menu && user.menu.length > 0) {
11322
+ return /* @__PURE__ */ jsx69(
11323
+ DropdownMenu,
11295
11324
  {
11296
- type: "button",
11297
- className: "ods-sidebar__user-rail",
11298
- onClick: user.onClick,
11299
- "aria-label": typeof user.name === "string" ? user.name : "User",
11300
- children: user.avatar ?? /* @__PURE__ */ jsx69("span", { children: user.initial ?? (typeof user.name === "string" ? user.name.charAt(0).toUpperCase() : "?") })
11325
+ trigger: avatar,
11326
+ items: user.menu,
11327
+ align: "end",
11328
+ "aria-label": labelText,
11329
+ triggerClassName: "ods-sidebar__user-rail"
11301
11330
  }
11302
- )
11303
- ] });
11331
+ );
11332
+ }
11333
+ return /* @__PURE__ */ jsx69(
11334
+ "button",
11335
+ {
11336
+ type: "button",
11337
+ className: "ods-sidebar__user-rail",
11338
+ onClick: user.onClick,
11339
+ "aria-label": labelText,
11340
+ children: avatar
11341
+ }
11342
+ );
11304
11343
  }
11305
11344
  function RailItem({
11306
11345
  item,
@@ -11419,18 +11458,7 @@ function ExpandedLayout({
11419
11458
  ] }, section.id ?? sIdx)) }),
11420
11459
  (footerItems || user) && /* @__PURE__ */ jsxs68("div", { className: "ods-sidebar__footer", children: [
11421
11460
  footerItems && footerItems.length > 0 && /* @__PURE__ */ jsx69("div", { className: "ods-sidebar__footer-list", children: footerItems.map((item) => /* @__PURE__ */ jsx69(ExpandedItem, { item, level: 0 }, item.id)) }),
11422
- user && /* @__PURE__ */ jsxs68("button", { type: "button", className: "ods-sidebar__user-card", onClick: user.onClick, children: [
11423
- /* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-avatar", children: user.avatar ?? /* @__PURE__ */ jsx69("span", { children: user.initial ?? (typeof user.name === "string" ? user.name.charAt(0).toUpperCase() : "?") }) }),
11424
- /* @__PURE__ */ jsxs68("span", { className: "ods-sidebar__user-info", children: [
11425
- /* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-name", children: user.name }),
11426
- user.email && /* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-email", children: user.email })
11427
- ] }),
11428
- /* @__PURE__ */ jsxs68("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
11429
- /* @__PURE__ */ jsx69("circle", { cx: "8", cy: "3", r: "1.3", fill: "currentColor" }),
11430
- /* @__PURE__ */ jsx69("circle", { cx: "8", cy: "8", r: "1.3", fill: "currentColor" }),
11431
- /* @__PURE__ */ jsx69("circle", { cx: "8", cy: "13", r: "1.3", fill: "currentColor" })
11432
- ] })
11433
- ] })
11461
+ user && /* @__PURE__ */ jsx69(SidebarUserCard, { user })
11434
11462
  ] })
11435
11463
  ] });
11436
11464
  }
@@ -11520,6 +11548,34 @@ function ExpandedItem({ item, level }) {
11520
11548
  }
11521
11549
  );
11522
11550
  }
11551
+ function SidebarUserCard({ user }) {
11552
+ const labelText = typeof user.name === "string" ? user.name : "User";
11553
+ const body = /* @__PURE__ */ jsxs68(Fragment15, { children: [
11554
+ /* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-avatar", children: user.avatar ?? /* @__PURE__ */ jsx69("span", { children: user.initial ?? (typeof user.name === "string" ? user.name.charAt(0).toUpperCase() : "?") }) }),
11555
+ /* @__PURE__ */ jsxs68("span", { className: "ods-sidebar__user-info", children: [
11556
+ /* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-name", children: user.name }),
11557
+ user.email && /* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-email", children: user.email })
11558
+ ] }),
11559
+ /* @__PURE__ */ jsxs68("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
11560
+ /* @__PURE__ */ jsx69("circle", { cx: "8", cy: "3", r: "1.3", fill: "currentColor" }),
11561
+ /* @__PURE__ */ jsx69("circle", { cx: "8", cy: "8", r: "1.3", fill: "currentColor" }),
11562
+ /* @__PURE__ */ jsx69("circle", { cx: "8", cy: "13", r: "1.3", fill: "currentColor" })
11563
+ ] })
11564
+ ] });
11565
+ if (user.menu && user.menu.length > 0) {
11566
+ return /* @__PURE__ */ jsx69(
11567
+ DropdownMenu,
11568
+ {
11569
+ trigger: body,
11570
+ items: user.menu,
11571
+ align: "end",
11572
+ "aria-label": labelText,
11573
+ triggerClassName: "ods-sidebar__user-card"
11574
+ }
11575
+ );
11576
+ }
11577
+ return /* @__PURE__ */ jsx69("button", { type: "button", className: "ods-sidebar__user-card", onClick: user.onClick, children: body });
11578
+ }
11523
11579
  function hasActiveDescendant(item) {
11524
11580
  if (!item.children) return false;
11525
11581
  for (const c of item.children) {