@m4l/components 9.3.21-JAEBeta.0 → 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/components/MFLoader/MFLoader.js +7 -3
- package/components/MFLoader/styles.js +1 -1
- package/components/MFLoader/types.d.ts +5 -0
- package/components/WindowBase/subcomponents/MicroFrontend/types.d.ts +2 -0
- package/components/areas/components/AreasViewer/AreasViewer.styles.js +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js +3 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow.d.ts +1 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow.js +4 -1
- package/components/popups/components/PopupsViewer/PopupsViewer.js +3 -2
- package/components/popups/components/PopupsViewer/subcomponents/Popup/Popup.js +2 -1
- package/components/popups/components/PopupsViewer/subcomponents/Popup/types.d.ts +5 -0
- package/components/popups/components/PopupsViewer/types.d.ts +2 -0
- package/hooks/useStateRef/index.d.ts +1 -1
- package/hooks/useStateRef/index.js +4 -4
- package/package.json +1 -2
|
@@ -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
|
}
|
|
@@ -30,7 +30,7 @@ function getDivScritId(prefix, moduleId) {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
function MFLoader(props) {
|
|
33
|
-
const { prefix, moduleId, cache = true, debugPort, dynamicMFStore, windowTools, emergeType } = props;
|
|
33
|
+
const { prefix, moduleId, cache = true, debugPort, dynamicMFStore, windowTools, emergeType, loggedUser } = props;
|
|
34
34
|
const { hostThemeOptions, fnComponentsOverrides } = useHostTheme();
|
|
35
35
|
const { networkOperation } = useNetwork();
|
|
36
36
|
const environment = useEnvironment();
|
|
@@ -64,6 +64,10 @@ function MFLoader(props) {
|
|
|
64
64
|
}
|
|
65
65
|
const renderMicroFrontend = useCallback(
|
|
66
66
|
(newDScript) => {
|
|
67
|
+
const options = {
|
|
68
|
+
loggedUser,
|
|
69
|
+
emergeType
|
|
70
|
+
};
|
|
67
71
|
try {
|
|
68
72
|
window[`render_${prefix}_${newDScript.moduleId}`](
|
|
69
73
|
newDScript.divContainerId,
|
|
@@ -75,13 +79,13 @@ function MFLoader(props) {
|
|
|
75
79
|
formatter,
|
|
76
80
|
dynamicMFStore,
|
|
77
81
|
windowTools,
|
|
78
|
-
|
|
82
|
+
options
|
|
79
83
|
);
|
|
80
84
|
} catch (_e) {
|
|
81
85
|
}
|
|
82
86
|
},
|
|
83
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
-
[hostThemeOptions, currentLocale, formatter]
|
|
88
|
+
[hostThemeOptions, currentLocale, formatter, loggedUser]
|
|
85
89
|
);
|
|
86
90
|
const debouncedSetDivScript = useCallback(
|
|
87
91
|
debounce(
|
|
@@ -2,10 +2,10 @@ import { styled } from "@mui/material";
|
|
|
2
2
|
const MFLoaderRoot = styled("div")(() => ({
|
|
3
3
|
width: "100%",
|
|
4
4
|
height: "100%",
|
|
5
|
+
position: "relative",
|
|
5
6
|
display: "flex",
|
|
6
7
|
flexDirection: "column",
|
|
7
8
|
alignItems: "center",
|
|
8
|
-
overflow: "auto",
|
|
9
9
|
"& .M4LMFLoader-containerLinearProgress": {
|
|
10
10
|
width: "100%",
|
|
11
11
|
height: "100%",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DynamicMFStore } from '../WindowBase/contexts/DynamicMFParmsContext/store';
|
|
2
2
|
import { WindowToolsMF } from '../WindowBase/contexts';
|
|
3
3
|
import { EmergeType } from '../areas/types';
|
|
4
|
+
import { AuthUserType } from '@m4l/core';
|
|
4
5
|
/**
|
|
5
6
|
* Propiedades base de un microfrontend.
|
|
6
7
|
*/
|
|
@@ -38,4 +39,8 @@ export interface MFLoaderProps extends MFBaseProps {
|
|
|
38
39
|
* Tipo de lanzamiento de la ventana, popup, layout, modal
|
|
39
40
|
*/
|
|
40
41
|
emergeType?: EmergeType;
|
|
42
|
+
/**
|
|
43
|
+
* loggedUser: usuario logueado, para los microfrontends que necesitan el usuario logueado
|
|
44
|
+
*/
|
|
45
|
+
loggedUser?: AuthUserType;
|
|
41
46
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuthUserType } from '@m4l/core';
|
|
1
2
|
import { EmergeType } from '../../../areas/types';
|
|
2
3
|
import { MFBaseProps } from '../../../MFLoader/types';
|
|
3
4
|
import { WindowToolsMF } from '../../contexts';
|
|
@@ -7,4 +8,5 @@ export interface MicroFrontendProps extends MFBaseProps {
|
|
|
7
8
|
windowTools: WindowToolsMF;
|
|
8
9
|
dynamicMFStore: DynamicMFStore;
|
|
9
10
|
emergeType: EmergeType;
|
|
11
|
+
loggedUser: AuthUserType;
|
|
10
12
|
}
|
package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js
CHANGED
|
@@ -30,7 +30,8 @@ const Window = (props) => {
|
|
|
30
30
|
dynamicMFStore,
|
|
31
31
|
windowTools,
|
|
32
32
|
onTouch,
|
|
33
|
-
memoizedActions
|
|
33
|
+
memoizedActions,
|
|
34
|
+
loggedUser
|
|
34
35
|
} = useWindow(windowId, areaId);
|
|
35
36
|
const maximizedId = useAreasStore(
|
|
36
37
|
(state) => areaId ? state.hashAreas[areaId]?.maximizedId : void 0,
|
|
@@ -83,6 +84,7 @@ const Window = (props) => {
|
|
|
83
84
|
moduleId,
|
|
84
85
|
dynamicMFStore,
|
|
85
86
|
windowTools,
|
|
87
|
+
loggedUser,
|
|
86
88
|
...mfProps
|
|
87
89
|
}
|
|
88
90
|
) : /* @__PURE__ */ jsx(
|
|
@@ -31,4 +31,5 @@ export declare const useWindow: (windowId: string, areaId?: string) => {
|
|
|
31
31
|
windowTools: WindowToolsMF;
|
|
32
32
|
onTouch: () => void;
|
|
33
33
|
memoizedActions: import('../../../../../../../../WindowBase/types').WindowBaseAction[];
|
|
34
|
+
loggedUser: import('@m4l/core').Maybe<import('@m4l/core').UserAuth>;
|
|
34
35
|
};
|
|
@@ -3,6 +3,7 @@ import { shallow } from "zustand/shallow";
|
|
|
3
3
|
import { u as useAreasStore } from "../../../../../../../hooks/useAreas/index.js";
|
|
4
4
|
import { u as useHeaderActions } from "./useHeaderActions.js";
|
|
5
5
|
import { u as usePopupsStore } from "../../../../../../../../popups/components/PopupsProvider/hooks/usePopupsStore.js";
|
|
6
|
+
import { useAuth } from "@m4l/core";
|
|
6
7
|
import { c as createToaster } from "../../../../../../../../ToastContainer/helpers/toaster.js";
|
|
7
8
|
const useWindow = (windowId, areaId) => {
|
|
8
9
|
const [
|
|
@@ -41,6 +42,7 @@ const useWindow = (windowId, areaId) => {
|
|
|
41
42
|
];
|
|
42
43
|
}, shallow);
|
|
43
44
|
const mfProps = useAreasStore((state) => state.hashWindows[windowId]?.mfProps, shallow);
|
|
45
|
+
const { user: loggedUser } = useAuth();
|
|
44
46
|
const component = useAreasStore(
|
|
45
47
|
(state) => state.hashWindows[windowId]?.component,
|
|
46
48
|
shallow
|
|
@@ -115,7 +117,8 @@ const useWindow = (windowId, areaId) => {
|
|
|
115
117
|
dynamicMFStore,
|
|
116
118
|
windowTools,
|
|
117
119
|
onTouch,
|
|
118
|
-
memoizedActions
|
|
120
|
+
memoizedActions,
|
|
121
|
+
loggedUser
|
|
119
122
|
};
|
|
120
123
|
};
|
|
121
124
|
export {
|
|
@@ -7,7 +7,7 @@ import { u as useSizeContainer } from "../../../../hooks/useSizeContainer/index.
|
|
|
7
7
|
import { R as RootStyled } from "./slots/popupsViewerSlots.js";
|
|
8
8
|
import { useRef, createRef, useEffect, memo } from "react";
|
|
9
9
|
const PopupsViewer = (props) => {
|
|
10
|
-
const { groupId = "global", onResizeStart, onResizeStop, onDragStart, onDragStop, containerElement, className } = props;
|
|
10
|
+
const { groupId = "global", onResizeStart, onResizeStop, onDragStart, onDragStop, containerElement, className, loggedUser } = props;
|
|
11
11
|
const popupsIds = usePopupsStore(
|
|
12
12
|
(state) => state.popupsIds.filter((pId) => groupId === state.hashPopups[pId].groupId && state.hashPopups[pId].status !== "closing"),
|
|
13
13
|
shallow
|
|
@@ -57,7 +57,8 @@ const PopupsViewer = (props) => {
|
|
|
57
57
|
"data-testid": "popup",
|
|
58
58
|
popupId: id,
|
|
59
59
|
containerElement,
|
|
60
|
-
containerSize
|
|
60
|
+
containerSize,
|
|
61
|
+
loggedUser
|
|
61
62
|
},
|
|
62
63
|
id
|
|
63
64
|
)
|
|
@@ -11,7 +11,7 @@ import { M as MemonizedWindowBaseMicroFrontend } from "../../../../../WindowBase
|
|
|
11
11
|
import { W as WindowBaseComponent } from "../../../../../WindowBase/subcomponents/Component/index.js";
|
|
12
12
|
import { W as WindowBase } from "../../../../../WindowBase/WindowBase.js";
|
|
13
13
|
const Popup = forwardRef((props, ref) => {
|
|
14
|
-
const { popupId, containerElement, containerSize, style, onResizeStart, onResizeStop, onDragStart, onDragStop } = props;
|
|
14
|
+
const { popupId, containerElement, containerSize, style, onResizeStart, onResizeStop, onDragStart, onDragStop, loggedUser } = props;
|
|
15
15
|
const popup = usePopupsStore((state) => state.hashPopups[popupId], shallow);
|
|
16
16
|
const { bringPopupOnFront } = usePopupsStore((state) => state.popupsActions, shallow);
|
|
17
17
|
const { close } = usePopupsStore((state) => state.popupActions, shallow);
|
|
@@ -133,6 +133,7 @@ const Popup = forwardRef((props, ref) => {
|
|
|
133
133
|
moduleId,
|
|
134
134
|
dynamicMFStore,
|
|
135
135
|
windowTools,
|
|
136
|
+
loggedUser,
|
|
136
137
|
...mfProps ?? { debugPort: 0, prefix: "" }
|
|
137
138
|
}
|
|
138
139
|
) : /* @__PURE__ */ jsx(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import { ContainerSize } from '../../../../../../utils/types';
|
|
3
|
+
import { AuthUserType } from '@m4l/core';
|
|
3
4
|
export type ResizeReason = 'start' | 'resize' | 'stop';
|
|
4
5
|
export interface PopupProps {
|
|
5
6
|
/**
|
|
@@ -34,4 +35,8 @@ export interface PopupProps {
|
|
|
34
35
|
* "onDragStop" Función que se ejecuta cuando se termina de arrastrar el popup
|
|
35
36
|
*/
|
|
36
37
|
onDragStop?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* "loggedUser" Usuario logueado
|
|
40
|
+
*/
|
|
41
|
+
loggedUser?: AuthUserType;
|
|
37
42
|
}
|
|
@@ -3,6 +3,7 @@ import { PopupViewerSlots } from './slots/slots';
|
|
|
3
3
|
import { POPUPS_VIEWER_KEY_COMPONENT } from './constants';
|
|
4
4
|
import { PopupStoreProps, PopupsProviderStoreState } from '../PopupsProvider/contexts/PopupsContext/types';
|
|
5
5
|
import { M4LOverridesStyleRules } from '../../../../@types/augmentations';
|
|
6
|
+
import { AuthUserType } from '@m4l/core';
|
|
6
7
|
export type PopupViewerSlotsType = keyof typeof PopupViewerSlots;
|
|
7
8
|
export type PopupsViewerProps = {
|
|
8
9
|
className?: string;
|
|
@@ -12,6 +13,7 @@ export type PopupsViewerProps = {
|
|
|
12
13
|
onResizeStop?: () => void;
|
|
13
14
|
onDragStart?: () => void;
|
|
14
15
|
onDragStop?: () => void;
|
|
16
|
+
loggedUser?: AuthUserType;
|
|
15
17
|
};
|
|
16
18
|
export type PopupStatus = 'init' | 'closing' | 'hidden';
|
|
17
19
|
export interface PopupOwnerState extends Pick<PopupStoreProps, 'status' | 'subTitle' | 'editionInfo' | 'zIndex' | 'variant'> {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param initialValue
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare function useStateRef<T>(initialValue: T | null): [T | null, (node: T | null) => void];
|
|
8
|
+
export declare function useStateRef<T extends HTMLElement | null>(initialValue: T | null): [T | null, (node: T | null) => void];
|
|
@@ -2,10 +2,10 @@ import { useState, useRef, useCallback } from "react";
|
|
|
2
2
|
function useStateRef(initialValue) {
|
|
3
3
|
const [refState, setRefState] = useState(initialValue);
|
|
4
4
|
const nodeRef = useRef(null);
|
|
5
|
-
const ref = useCallback((
|
|
6
|
-
if (
|
|
7
|
-
nodeRef.current =
|
|
8
|
-
setRefState(
|
|
5
|
+
const ref = useCallback((current) => {
|
|
6
|
+
if (current && nodeRef.current !== current) {
|
|
7
|
+
nodeRef.current = current;
|
|
8
|
+
setRefState(current);
|
|
9
9
|
}
|
|
10
10
|
}, []);
|
|
11
11
|
return [refState, ref];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/components",
|
|
3
|
-
"version": "9.3.21-JAEBeta.
|
|
3
|
+
"version": "9.3.21-JAEBeta.2",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "M4L Components",
|
|
6
6
|
"lint-staged": {
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"react-helmet-async": "^2.0.5",
|
|
44
44
|
"react-hook-form": "^7.33.1",
|
|
45
45
|
"react-intersection-observer": "^9.4.0",
|
|
46
|
-
"react-leaflet": "^4.2.1",
|
|
47
46
|
"react-resizable": "^3.0.4",
|
|
48
47
|
"react-resizable-panels": "^2.1.8",
|
|
49
48
|
"react-rnd": "^10.5.2",
|