@m4l/components 9.3.21-JAEBeta.1 → 9.3.21-JAEBeta.2
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/components/AccountPopover/AccountPopover.js +12 -13
- package/components/AccountPopover/subcomponents/MenuPopover/MenuPopover.d.ts +1 -1
- package/components/AccountPopover/subcomponents/MenuPopover/MenuPopover.js +7 -4
- package/components/AccountPopover/subcomponents/MenuPopover/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useNetwork } from "@m4l/core";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
3
|
+
import { useState, useEffect, useCallback } from "react";
|
|
4
4
|
import { M as MenuPopover } from "./subcomponents/MenuPopover/MenuPopover.js";
|
|
5
5
|
import { A as ACCOUNT_KEY_POPOVER } from "./constants.js";
|
|
6
6
|
import { I as IconButtonRootStyled, A as AvatarStyled } from "./slots/AccountPopoverSlots.js";
|
|
7
7
|
import { M as MyAvatar } from "./subcomponents/MyAvatar/MyAvatar.js";
|
|
8
|
-
import { u as useStateRef } from "../../hooks/useStateRef/index.js";
|
|
9
8
|
import { g as getComponentClasses } from "../../utils/getComponentSlotRoot.js";
|
|
10
9
|
import { A as AccountPopoverSlots } from "./slots/AccountPopoverEnum.js";
|
|
11
10
|
import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
|
|
@@ -20,7 +19,7 @@ const AccountPopover = (props) => {
|
|
|
20
19
|
} = props;
|
|
21
20
|
const { avatarUrl, firstName = "firstname", lastName = "lastname" } = userData || {};
|
|
22
21
|
const [asyncState, setAsyncState] = useState("unLoad");
|
|
23
|
-
const [
|
|
22
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
24
23
|
const [menuData, setMenuData] = useState([]);
|
|
25
24
|
const { networkOperation } = useNetwork();
|
|
26
25
|
const { currentSize } = useComponentSize(size);
|
|
@@ -50,13 +49,13 @@ const AccountPopover = (props) => {
|
|
|
50
49
|
return function cleanUp() {
|
|
51
50
|
mounted = false;
|
|
52
51
|
};
|
|
53
|
-
}, [
|
|
54
|
-
const handleClose = () => {
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
const handleOpen = (event) => {
|
|
58
|
-
|
|
59
|
-
};
|
|
52
|
+
}, [anchorEl]);
|
|
53
|
+
const handleClose = useCallback(() => {
|
|
54
|
+
setAnchorEl(null);
|
|
55
|
+
}, [setAnchorEl]);
|
|
56
|
+
const handleOpen = useCallback((event) => {
|
|
57
|
+
setAnchorEl(event.currentTarget);
|
|
58
|
+
}, [setAnchorEl]);
|
|
60
59
|
const classes = getComponentClasses(ACCOUNT_KEY_POPOVER, AccountPopoverSlots);
|
|
61
60
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
62
61
|
/* @__PURE__ */ jsx(
|
|
@@ -66,11 +65,11 @@ const AccountPopover = (props) => {
|
|
|
66
65
|
icon: /* @__PURE__ */ jsx(MyAvatar, { size: currentSize, avatarUrl, firstName, lastName, slotAvatar: AvatarStyled }),
|
|
67
66
|
src: "",
|
|
68
67
|
onClick: handleOpen,
|
|
69
|
-
selected:
|
|
68
|
+
selected: anchorEl ? true : false,
|
|
70
69
|
className: classes.iconButtonRoot
|
|
71
70
|
}
|
|
72
71
|
),
|
|
73
|
-
/* @__PURE__ */ jsx(
|
|
72
|
+
!!anchorEl && /* @__PURE__ */ jsx(
|
|
74
73
|
MenuPopover,
|
|
75
74
|
{
|
|
76
75
|
size: currentSize,
|
|
@@ -81,7 +80,7 @@ const AccountPopover = (props) => {
|
|
|
81
80
|
handleLogOut,
|
|
82
81
|
userData,
|
|
83
82
|
settingsHandleOpen,
|
|
84
|
-
|
|
83
|
+
anchorEl,
|
|
85
84
|
handleClose
|
|
86
85
|
}
|
|
87
86
|
)
|
|
@@ -4,4 +4,4 @@ import { MenuPopoverProps } from './types';
|
|
|
4
4
|
* Se debe refactorizar el componente PopOver para recibir la propr de size.
|
|
5
5
|
* @param props
|
|
6
6
|
*/
|
|
7
|
-
export declare const MenuPopover: (props: MenuPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const MenuPopover: (props: MenuPopoverProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -10,7 +10,7 @@ const MenuPopover = (props) => {
|
|
|
10
10
|
const {
|
|
11
11
|
version,
|
|
12
12
|
handleClose,
|
|
13
|
-
|
|
13
|
+
anchorEl,
|
|
14
14
|
userData,
|
|
15
15
|
settingsHandleOpen,
|
|
16
16
|
handleLogOut,
|
|
@@ -29,19 +29,22 @@ const MenuPopover = (props) => {
|
|
|
29
29
|
handleClose();
|
|
30
30
|
};
|
|
31
31
|
const handleClickSetting = () => {
|
|
32
|
-
settingsHandleOpen();
|
|
33
32
|
handleClose();
|
|
33
|
+
settingsHandleOpen();
|
|
34
34
|
};
|
|
35
35
|
const handleLogout = () => {
|
|
36
36
|
handleLogOut();
|
|
37
37
|
handleClose();
|
|
38
38
|
};
|
|
39
|
+
if (!anchorEl) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
39
42
|
return /* @__PURE__ */ jsxs(
|
|
40
43
|
PopoverStyled,
|
|
41
44
|
{
|
|
42
45
|
size,
|
|
43
|
-
open: Boolean(
|
|
44
|
-
anchorEl
|
|
46
|
+
open: Boolean(anchorEl),
|
|
47
|
+
anchorEl,
|
|
45
48
|
onClose: handleClose,
|
|
46
49
|
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
47
50
|
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
@@ -5,6 +5,6 @@ import { AccountPopoverProps, AsyncTypes, RightMenuData } from '../../types';
|
|
|
5
5
|
export interface MenuPopoverProps extends AccountPopoverProps {
|
|
6
6
|
data: Array<RightMenuData> | [];
|
|
7
7
|
asyncState: AsyncTypes;
|
|
8
|
-
|
|
8
|
+
anchorEl: HTMLElement | null;
|
|
9
9
|
handleClose: () => void;
|
|
10
10
|
}
|