@octaviaflow/core 3.0.8 → 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/components/Button/Button.d.ts +14 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +8 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/index.cjs +88 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -27
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -645,10 +645,14 @@ function Button({
|
|
|
645
645
|
className,
|
|
646
646
|
children,
|
|
647
647
|
type,
|
|
648
|
+
cursor,
|
|
649
|
+
style,
|
|
648
650
|
...props
|
|
649
651
|
}) {
|
|
650
652
|
const ref = useRef3(null);
|
|
651
653
|
const isDisabled = disabled || loading;
|
|
654
|
+
const hasAction = Boolean(props.onClick) || type === "submit" || type === "reset" || Boolean(props.href);
|
|
655
|
+
const resolvedCursor = cursor ?? (disabled ? "not-allowed" : loading ? "progress" : hasAction ? "pointer" : "default");
|
|
652
656
|
const resolvedType = type ?? "button";
|
|
653
657
|
const hasVisibleText = typeof children === "string" ? children.trim().length > 0 : Boolean(children);
|
|
654
658
|
const needsAriaName = !hasVisibleText;
|
|
@@ -693,6 +697,7 @@ function Button({
|
|
|
693
697
|
fullWidth && "ods-btn--full",
|
|
694
698
|
className
|
|
695
699
|
),
|
|
700
|
+
style: { cursor: resolvedCursor, ...style },
|
|
696
701
|
"data-loading": loading || void 0,
|
|
697
702
|
whileTap: isDisabled ? void 0 : { scale: 0.97 },
|
|
698
703
|
transition: { duration: 0.1 },
|
|
@@ -6413,6 +6418,7 @@ function DropdownMenu({
|
|
|
6413
6418
|
items,
|
|
6414
6419
|
align = "start",
|
|
6415
6420
|
className,
|
|
6421
|
+
triggerClassName,
|
|
6416
6422
|
"aria-label": ariaLabel,
|
|
6417
6423
|
"aria-labelledby": ariaLabelledby
|
|
6418
6424
|
}) {
|
|
@@ -6431,7 +6437,15 @@ function DropdownMenu({
|
|
|
6431
6437
|
);
|
|
6432
6438
|
const { onDrag, onDragStart, onDragEnd, onAnimationStart, ...safeTriggerProps } = buttonProps;
|
|
6433
6439
|
return /* @__PURE__ */ jsxs28(Fragment6, { children: [
|
|
6434
|
-
/* @__PURE__ */ jsx29(
|
|
6440
|
+
/* @__PURE__ */ jsx29(
|
|
6441
|
+
"button",
|
|
6442
|
+
{
|
|
6443
|
+
...safeTriggerProps,
|
|
6444
|
+
ref: triggerRef,
|
|
6445
|
+
className: triggerClassName ?? "ods-dropdown__trigger",
|
|
6446
|
+
children: trigger
|
|
6447
|
+
}
|
|
6448
|
+
),
|
|
6435
6449
|
/* @__PURE__ */ jsx29(
|
|
6436
6450
|
MenuPopup,
|
|
6437
6451
|
{
|
|
@@ -11134,15 +11148,17 @@ function Sidebar({
|
|
|
11134
11148
|
className
|
|
11135
11149
|
}) {
|
|
11136
11150
|
const allSections = sections ?? (items ? [{ items }] : []);
|
|
11137
|
-
const [internalPinned, setInternalPinned] = useState21(
|
|
11138
|
-
|
|
11151
|
+
const [internalPinned, setInternalPinned] = useState21(defaultPinned);
|
|
11152
|
+
useEffect16(() => {
|
|
11153
|
+
if (pinnedProp !== void 0) return;
|
|
11139
11154
|
try {
|
|
11140
11155
|
const stored = window.localStorage.getItem(pinStorageKey);
|
|
11141
|
-
if (stored !== null
|
|
11156
|
+
if (stored !== null && stored !== String(internalPinned)) {
|
|
11157
|
+
setInternalPinned(stored === "true");
|
|
11158
|
+
}
|
|
11142
11159
|
} catch {
|
|
11143
11160
|
}
|
|
11144
|
-
|
|
11145
|
-
});
|
|
11161
|
+
}, []);
|
|
11146
11162
|
const pinned = pinnedProp ?? internalPinned;
|
|
11147
11163
|
const setPinned = useCallback16(
|
|
11148
11164
|
(p) => {
|
|
@@ -11180,6 +11196,17 @@ function Sidebar({
|
|
|
11180
11196
|
const autoMode = variant === "auto";
|
|
11181
11197
|
const showAsRail = autoMode ? !pinned : variant === "rail";
|
|
11182
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]);
|
|
11183
11210
|
return /* @__PURE__ */ jsxs68(
|
|
11184
11211
|
"nav",
|
|
11185
11212
|
{
|
|
@@ -11285,17 +11312,34 @@ function RailLayout({
|
|
|
11285
11312
|
},
|
|
11286
11313
|
item.id
|
|
11287
11314
|
)) }),
|
|
11288
|
-
user && /* @__PURE__ */ jsx69(
|
|
11289
|
-
|
|
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,
|
|
11290
11324
|
{
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
"aria-label":
|
|
11295
|
-
|
|
11325
|
+
trigger: avatar,
|
|
11326
|
+
items: user.menu,
|
|
11327
|
+
align: "end",
|
|
11328
|
+
"aria-label": labelText,
|
|
11329
|
+
triggerClassName: "ods-sidebar__user-rail"
|
|
11296
11330
|
}
|
|
11297
|
-
)
|
|
11298
|
-
|
|
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
|
+
);
|
|
11299
11343
|
}
|
|
11300
11344
|
function RailItem({
|
|
11301
11345
|
item,
|
|
@@ -11414,18 +11458,7 @@ function ExpandedLayout({
|
|
|
11414
11458
|
] }, section.id ?? sIdx)) }),
|
|
11415
11459
|
(footerItems || user) && /* @__PURE__ */ jsxs68("div", { className: "ods-sidebar__footer", children: [
|
|
11416
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)) }),
|
|
11417
|
-
user && /* @__PURE__ */
|
|
11418
|
-
/* @__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() : "?") }) }),
|
|
11419
|
-
/* @__PURE__ */ jsxs68("span", { className: "ods-sidebar__user-info", children: [
|
|
11420
|
-
/* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-name", children: user.name }),
|
|
11421
|
-
user.email && /* @__PURE__ */ jsx69("span", { className: "ods-sidebar__user-email", children: user.email })
|
|
11422
|
-
] }),
|
|
11423
|
-
/* @__PURE__ */ jsxs68("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
|
|
11424
|
-
/* @__PURE__ */ jsx69("circle", { cx: "8", cy: "3", r: "1.3", fill: "currentColor" }),
|
|
11425
|
-
/* @__PURE__ */ jsx69("circle", { cx: "8", cy: "8", r: "1.3", fill: "currentColor" }),
|
|
11426
|
-
/* @__PURE__ */ jsx69("circle", { cx: "8", cy: "13", r: "1.3", fill: "currentColor" })
|
|
11427
|
-
] })
|
|
11428
|
-
] })
|
|
11461
|
+
user && /* @__PURE__ */ jsx69(SidebarUserCard, { user })
|
|
11429
11462
|
] })
|
|
11430
11463
|
] });
|
|
11431
11464
|
}
|
|
@@ -11515,6 +11548,34 @@ function ExpandedItem({ item, level }) {
|
|
|
11515
11548
|
}
|
|
11516
11549
|
);
|
|
11517
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
|
+
}
|
|
11518
11579
|
function hasActiveDescendant(item) {
|
|
11519
11580
|
if (!item.children) return false;
|
|
11520
11581
|
for (const c of item.children) {
|