habarico 7.3.0-beta.4 → 7.3.0-beta.5
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/lib/index.cjs +54 -23
- package/lib/index.cjs.map +1 -1
- package/lib/index.esm.js +54 -23
- package/lib/index.esm.js.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -55441,6 +55441,7 @@ const MenuItem = ({
|
|
|
55441
55441
|
highlighted,
|
|
55442
55442
|
sub,
|
|
55443
55443
|
dropdown,
|
|
55444
|
+
expanded,
|
|
55444
55445
|
tooltip,
|
|
55445
55446
|
onMouseEnter,
|
|
55446
55447
|
onMouseLeave,
|
|
@@ -55450,12 +55451,13 @@ const MenuItem = ({
|
|
|
55450
55451
|
const isLight = theme.palette.mode === "light";
|
|
55451
55452
|
const activeText = isLight ? theme.palette.primary.dark : theme.palette.primary.light;
|
|
55452
55453
|
const activeIcon = isLight ? theme.palette.primary.main : theme.palette.primary.lighter;
|
|
55454
|
+
const isGroup = !!item.items?.length;
|
|
55455
|
+
const linkProps = isGroup ? { "aria-expanded": !!expanded } : { component: RouterLink, href: item.href };
|
|
55453
55456
|
return /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: tooltip, placement: "right", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
55454
55457
|
material.ListItemButton,
|
|
55455
55458
|
{
|
|
55456
55459
|
disableGutters: true,
|
|
55457
|
-
|
|
55458
|
-
href: item.href,
|
|
55460
|
+
...linkProps,
|
|
55459
55461
|
onMouseEnter,
|
|
55460
55462
|
onMouseLeave,
|
|
55461
55463
|
onClick,
|
|
@@ -55504,6 +55506,7 @@ const MenuItemWithPopper = ({ children, onClick, ...rest }) => {
|
|
|
55504
55506
|
const isOverSubMenuRef = React.useRef(false);
|
|
55505
55507
|
const openTimeoutRef = React.useRef(void 0);
|
|
55506
55508
|
const closeTimeoutRef = React.useRef(void 0);
|
|
55509
|
+
const openedByClickRef = React.useRef(false);
|
|
55507
55510
|
const closeIfNotOver = React.useCallback(() => {
|
|
55508
55511
|
clearTimeout(closeTimeoutRef.current);
|
|
55509
55512
|
closeTimeoutRef.current = setTimeout(() => {
|
|
@@ -55517,9 +55520,22 @@ const MenuItemWithPopper = ({ children, onClick, ...rest }) => {
|
|
|
55517
55520
|
isOverMenuRef.current = true;
|
|
55518
55521
|
const target = e.currentTarget;
|
|
55519
55522
|
openTimeoutRef.current = setTimeout(() => {
|
|
55523
|
+
openedByClickRef.current = false;
|
|
55520
55524
|
setAnchorEl(target);
|
|
55521
55525
|
}, POPOVER_OPEN_DEBOUNCE);
|
|
55522
55526
|
}, []);
|
|
55527
|
+
const togglePopper = React.useCallback(
|
|
55528
|
+
(e) => {
|
|
55529
|
+
clearTimeout(openTimeoutRef.current);
|
|
55530
|
+
clearTimeout(closeTimeoutRef.current);
|
|
55531
|
+
const target = e.currentTarget;
|
|
55532
|
+
const close = Boolean(anchorEl) && openedByClickRef.current;
|
|
55533
|
+
openedByClickRef.current = !close;
|
|
55534
|
+
setAnchorEl(close ? null : target);
|
|
55535
|
+
onClick?.(e);
|
|
55536
|
+
},
|
|
55537
|
+
[anchorEl, onClick]
|
|
55538
|
+
);
|
|
55523
55539
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
55524
55540
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
55525
55541
|
MenuItem,
|
|
@@ -55531,7 +55547,8 @@ const MenuItemWithPopper = ({ children, onClick, ...rest }) => {
|
|
|
55531
55547
|
isOverMenuRef.current = false;
|
|
55532
55548
|
closeIfNotOver();
|
|
55533
55549
|
},
|
|
55534
|
-
onClick
|
|
55550
|
+
onClick: togglePopper,
|
|
55551
|
+
expanded: Boolean(anchorEl)
|
|
55535
55552
|
}
|
|
55536
55553
|
),
|
|
55537
55554
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -55629,8 +55646,39 @@ const MenuListCollapsed = ({ items, level, onItemClick }) => {
|
|
|
55629
55646
|
const SUB_INDENT = 40;
|
|
55630
55647
|
const ELBOW_WIDTH = 16;
|
|
55631
55648
|
const ELBOW_RADIUS = 10;
|
|
55632
|
-
const
|
|
55649
|
+
const MenuListFullItem = ({ item, level, onItemClick }) => {
|
|
55633
55650
|
const { isActive, isExpanded } = useActiveExpanded();
|
|
55651
|
+
const pathname = usePathname();
|
|
55652
|
+
const routeExpanded = isExpanded(item);
|
|
55653
|
+
const [open, setOpen] = React.useState(routeExpanded);
|
|
55654
|
+
const [syncedPathname, setSyncedPathname] = React.useState(pathname);
|
|
55655
|
+
if (syncedPathname !== pathname) {
|
|
55656
|
+
setSyncedPathname(pathname);
|
|
55657
|
+
if (routeExpanded) setOpen(true);
|
|
55658
|
+
}
|
|
55659
|
+
const active = isActive(item);
|
|
55660
|
+
const isGroup = !!item.items?.length;
|
|
55661
|
+
const highlighted = !active && isGroup && open;
|
|
55662
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
55663
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
55664
|
+
MenuItem,
|
|
55665
|
+
{
|
|
55666
|
+
item,
|
|
55667
|
+
active,
|
|
55668
|
+
highlighted,
|
|
55669
|
+
expanded: isGroup ? open : void 0,
|
|
55670
|
+
sub: level >= 1,
|
|
55671
|
+
collapsed: false,
|
|
55672
|
+
onClick: () => {
|
|
55673
|
+
if (isGroup) setOpen((value) => !value);
|
|
55674
|
+
onItemClick?.(item);
|
|
55675
|
+
}
|
|
55676
|
+
}
|
|
55677
|
+
),
|
|
55678
|
+
isGroup && /* @__PURE__ */ jsxRuntime.jsx(material.Collapse, { in: open, children: /* @__PURE__ */ jsxRuntime.jsx(MenuListFull, { items: item.items, onItemClick, level: level + 1 }) })
|
|
55679
|
+
] });
|
|
55680
|
+
};
|
|
55681
|
+
const MenuListFull = ({ items, level, onItemClick }) => {
|
|
55634
55682
|
const theme = material.useTheme();
|
|
55635
55683
|
const isSub = level >= 1;
|
|
55636
55684
|
const lineColor = varAlpha(theme.palette.grey["500Channel"], 0.32);
|
|
@@ -55651,9 +55699,7 @@ const MenuListFull = ({ items, level, onItemClick }) => {
|
|
|
55651
55699
|
position: isSub ? "relative" : void 0
|
|
55652
55700
|
},
|
|
55653
55701
|
children: items.map((item, index) => {
|
|
55654
|
-
|
|
55655
|
-
const highlighted = !active && !!item.items?.length && isExpanded(item);
|
|
55656
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
55702
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
55657
55703
|
material.ListItem,
|
|
55658
55704
|
{
|
|
55659
55705
|
disableGutters: true,
|
|
@@ -55684,22 +55730,7 @@ const MenuListFull = ({ items, level, onItemClick }) => {
|
|
|
55684
55730
|
}
|
|
55685
55731
|
}
|
|
55686
55732
|
},
|
|
55687
|
-
children:
|
|
55688
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
55689
|
-
MenuItem,
|
|
55690
|
-
{
|
|
55691
|
-
item,
|
|
55692
|
-
active,
|
|
55693
|
-
highlighted,
|
|
55694
|
-
sub: isSub,
|
|
55695
|
-
collapsed: false,
|
|
55696
|
-
onClick: () => {
|
|
55697
|
-
onItemClick?.(item);
|
|
55698
|
-
}
|
|
55699
|
-
}
|
|
55700
|
-
),
|
|
55701
|
-
item.items && /* @__PURE__ */ jsxRuntime.jsx(material.Collapse, { in: isExpanded(item), children: /* @__PURE__ */ jsxRuntime.jsx(MenuListFull, { items: item.items, onItemClick, level: level + 1 }) })
|
|
55702
|
-
]
|
|
55733
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MenuListFullItem, { item, level, onItemClick })
|
|
55703
55734
|
},
|
|
55704
55735
|
index
|
|
55705
55736
|
);
|