@m4l/components 9.1.97 → 9.1.99
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/WindowBase/WindowBase.d.ts +1 -1
- package/components/WindowBase/WindowBase.js +2 -0
- package/components/WindowBase/types.d.ts +24 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/AreaGridLayout/index.d.ts +4 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/InnerForHooks/index.d.ts +4 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/InnerForHooks/index.js +4 -10
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useHeaderActions/useHeaderActions.d.ts +32 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useHeaderActions/useHeaderActions.js +163 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow/useWindow.d.ts +35 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow/useWindow.js +88 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/index.d.ts +14 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/index.js +47 -113
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/helper.d.ts +12 -8
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/helper.js +3 -16
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/index.d.ts +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/types.d.ts +7 -1
- package/components/areas/contexts/AreasContext/helpers/generateModuleCount.d.ts +4 -0
- package/components/areas/contexts/AreasContext/helpers/helper.d.ts +36 -0
- package/components/areas/contexts/AreasContext/index.d.ts +2 -2
- package/components/areas/contexts/AreasContext/store.d.ts +1 -1
- package/components/areas/contexts/AreasContext/store.js +37 -33
- package/components/areas/contexts/AreasContext/tests/fnNetworkImplementation.d.ts +21 -0
- package/components/areas/contexts/AreasContext/types.d.ts +53 -2
- package/components/areas/types.d.ts +7 -1
- package/package.json +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/PanelWindows/index.js +0 -99
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/styles.js +0 -69
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/index.js +0 -154
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/subcomponents/MainActions/index.js +0 -44
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/subcomponents/WindowHeaderSkeleton/index.js +0 -57
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/subcomponents/WindowPopUpsList/index.d.ts +0 -9
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/subcomponents/WindowPopUpsList/types.d.ts +0 -2
|
@@ -5,7 +5,7 @@ import { WindowBaseProps } from './types';
|
|
|
5
5
|
* It uses hooks like `useModal` and utility style classes.
|
|
6
6
|
* @author cesar - automatic
|
|
7
7
|
* @createdAt 2024-11-15 18:08:44 - automatic
|
|
8
|
-
* @updatedAt 2025-02-
|
|
8
|
+
* @updatedAt 2025-02-07 11:59:47 - automatic
|
|
9
9
|
* @updatedUser cesar - automatic
|
|
10
10
|
*/
|
|
11
11
|
export declare const WindowBase: (props: WindowBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,6 +22,7 @@ const WindowBase = (props) => {
|
|
|
22
22
|
className,
|
|
23
23
|
isLoading,
|
|
24
24
|
windowId,
|
|
25
|
+
onMouseDown,
|
|
25
26
|
...other
|
|
26
27
|
} = props;
|
|
27
28
|
const { currentSize } = useComponentSize(size);
|
|
@@ -40,6 +41,7 @@ const WindowBase = (props) => {
|
|
|
40
41
|
className: clsx(getComponentSlotRoot(WINDOW_BASE_KEY_COMPONENT), className),
|
|
41
42
|
...getPropDataTestId(WINDOW_BASE_KEY_COMPONENT, WindowBaseSlots.wrapperWindowBase, dataTestId),
|
|
42
43
|
ownerState,
|
|
44
|
+
onMouseDown,
|
|
43
45
|
children: [
|
|
44
46
|
/* @__PURE__ */ jsx(
|
|
45
47
|
HeaderWindowBase,
|
|
@@ -8,7 +8,7 @@ import { ComponentPalletColor, Sizes } from '@m4l/styles';
|
|
|
8
8
|
* Type representing a single action in the `WindowBase` component.
|
|
9
9
|
* @author cesar - automatic
|
|
10
10
|
* @createdAt 2024-12-23 09:48:25 - automatic
|
|
11
|
-
* @updatedAt 2025-02-
|
|
11
|
+
* @updatedAt 2025-02-07 11:59:47 - automatic
|
|
12
12
|
* @updatedUser cesar - automatic
|
|
13
13
|
*/
|
|
14
14
|
export interface WindowBaseAction {
|
|
@@ -62,21 +62,25 @@ export interface WindowBaseProps {
|
|
|
62
62
|
/**
|
|
63
63
|
* The main title of the window.
|
|
64
64
|
* This property is required and displayed prominently at the top of the window.
|
|
65
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
65
66
|
*/
|
|
66
67
|
title: string;
|
|
67
68
|
/**
|
|
68
69
|
* An optional subtitle for the window.
|
|
69
70
|
* Typically displayed below the main title to provide additional context or details.
|
|
71
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
70
72
|
*/
|
|
71
73
|
subTitle?: string;
|
|
72
74
|
/**
|
|
73
75
|
* The content to be rendered inside the window.
|
|
74
76
|
* This can include any valid React node or JSX.
|
|
77
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
75
78
|
*/
|
|
76
79
|
children: ReactNode;
|
|
77
80
|
/**
|
|
78
81
|
* URL of the icon displayed in the header of the window.
|
|
79
82
|
* This is optional and used to provide a visual identifier for the window.
|
|
83
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
80
84
|
*/
|
|
81
85
|
iconUrl?: string;
|
|
82
86
|
/**
|
|
@@ -84,6 +88,7 @@ export interface WindowBaseProps {
|
|
|
84
88
|
* - `'outlined'`: Displays the window with an outlined border.
|
|
85
89
|
* - `'text'`: Displays the window with minimal styling, emphasizing the content.
|
|
86
90
|
* Default is `'outlined'` if not specified.
|
|
91
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
87
92
|
*/
|
|
88
93
|
variant?: 'outlined' | 'text';
|
|
89
94
|
/**
|
|
@@ -91,51 +96,69 @@ export interface WindowBaseProps {
|
|
|
91
96
|
* - `'small'`: A compact window size.
|
|
92
97
|
* - `'medium'`: A standard window size.
|
|
93
98
|
* Default is `'medium'` if not specified.
|
|
99
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
94
100
|
*/
|
|
95
101
|
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
96
102
|
/**
|
|
97
103
|
* The color theme of the window.
|
|
98
104
|
* Restricted to `'default'`, which applies the default theme color.
|
|
105
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
99
106
|
*/
|
|
100
107
|
color?: Extract<ComponentPalletColor, 'default'>;
|
|
101
108
|
/**
|
|
102
109
|
* Indicates if the window is currently selected.
|
|
103
110
|
* When `true`, the window may display a visual indicator to denote selection.
|
|
111
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
104
112
|
*/
|
|
105
113
|
selected?: boolean;
|
|
106
114
|
/**
|
|
107
115
|
* The version label for the window.
|
|
108
116
|
* Useful for displaying version information (e.g., `1.0.0`) in the header or footer.
|
|
117
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
109
118
|
*/
|
|
110
119
|
version?: string;
|
|
111
120
|
/**
|
|
112
121
|
* A unique identifier for automated testing.
|
|
113
122
|
* Provides a `data-testid` attribute for querying this component in tests.
|
|
123
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
114
124
|
*/
|
|
115
125
|
dataTestId?: string;
|
|
116
126
|
/**
|
|
117
127
|
* Callback function executed when the window is closed.
|
|
118
128
|
* Typically triggered by a close button or similar action.
|
|
129
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
119
130
|
*/
|
|
120
131
|
onClose?: VoidFunction;
|
|
121
132
|
/**
|
|
122
133
|
* List of actions to display in the window.
|
|
123
134
|
* Each action defines its placement, icon, label, and other properties.
|
|
135
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
124
136
|
*/
|
|
125
137
|
actions?: WindowBaseAction[];
|
|
126
138
|
/**
|
|
127
139
|
* An optional class name to apply to the root element of the component.
|
|
140
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
128
141
|
*/
|
|
129
142
|
className?: string;
|
|
130
143
|
/**
|
|
131
144
|
* Indicates if the window is in a loading state.
|
|
145
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
132
146
|
*/
|
|
133
147
|
isLoading?: boolean;
|
|
134
148
|
/**
|
|
135
149
|
* A unique identifier for the window.
|
|
136
150
|
* This is used to identify and manage multiple windows.
|
|
151
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
137
152
|
*/
|
|
138
153
|
windowId?: string;
|
|
154
|
+
/**
|
|
155
|
+
* "onMouseDown" event handler for the window.
|
|
156
|
+
* @author cesar - automatic
|
|
157
|
+
* @createdAt 2025-02-07 11:56:13 - automatic
|
|
158
|
+
* @updatedAt 2025-02-07 11:56:13 - automatic
|
|
159
|
+
* @updatedUser cesar - automatic
|
|
160
|
+
*/
|
|
161
|
+
onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
|
|
139
162
|
}
|
|
140
163
|
/**
|
|
141
164
|
* Type representing the possible values of `WindowBaseSlots`.
|
|
@@ -2,5 +2,9 @@ import { GridLayoutProps } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Retorna el componente GridLayout con las ventanas (layouts) y popups tomados del área de trabajo.
|
|
4
4
|
* @returns JSX
|
|
5
|
+
* @author cesar - automatic
|
|
6
|
+
* @createdAt 2025-02-07 08:26:21 - automatic
|
|
7
|
+
* @updatedAt 2025-02-07 08:26:22 - automatic
|
|
8
|
+
* @updatedUser cesar - automatic
|
|
5
9
|
*/
|
|
6
10
|
export declare const AreaGridLayout: (props: GridLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { InnerForHooksProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* TODO: Documentar
|
|
4
|
+
* @author cesar - automatic
|
|
5
|
+
* @createdAt 2025-02-05 09:37:08 - automatic
|
|
6
|
+
* @updatedAt 2025-02-05 09:37:08 - automatic
|
|
7
|
+
* @updatedUser cesar - automatic
|
|
4
8
|
*/
|
|
5
9
|
export declare const InnerForHooks: (props: InnerForHooksProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { A as AreaGridLayout } from "../AreaGridLayout/index.js";
|
|
3
|
-
import { P as PanelWindows } from "../PanelWindows/index.js";
|
|
4
3
|
import clsx from "clsx";
|
|
5
4
|
import { a as areasViewerClasses } from "../../../../classes/index.js";
|
|
6
5
|
import { u as useAreasStore } from "../../../../../../hooks/useAreas/index.js";
|
|
7
6
|
import { L as LoadingError } from "../../../../../../../LoadingError/LoadingError.js";
|
|
8
|
-
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
9
7
|
const InnerForHooks = (props) => {
|
|
10
8
|
const { areaId } = props;
|
|
11
|
-
const isDesktop = useResponsiveDesktop();
|
|
12
9
|
const status = useAreasStore((state) => state.hashAreas[areaId].status);
|
|
13
|
-
return /* @__PURE__ */
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
14
11
|
"div",
|
|
15
12
|
{
|
|
16
13
|
className: clsx(
|
|
17
14
|
areasViewerClasses.areaGridLayoutPanelContainer,
|
|
18
15
|
`${areasViewerClasses.areaGridLayoutPanelContainer}-${areaId}`
|
|
19
16
|
),
|
|
20
|
-
children:
|
|
21
|
-
|
|
22
|
-
} }),
|
|
23
|
-
isDesktop ? /* @__PURE__ */ jsx(PanelWindows, { areaId }) : null
|
|
24
|
-
]
|
|
17
|
+
children: status === "loaded" ? /* @__PURE__ */ jsx(AreaGridLayout, { areaId }) : /* @__PURE__ */ jsx(LoadingError, { status, action: () => {
|
|
18
|
+
} })
|
|
25
19
|
}
|
|
26
20
|
);
|
|
27
21
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WindowBaseAction } from '../../../../../../../../../../../src/components/WindowBase';
|
|
2
|
+
interface UseHeaderActionsParams {
|
|
3
|
+
windowId: string;
|
|
4
|
+
areaId: string;
|
|
5
|
+
menuActions?: WindowBaseAction[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Hook useHeaderActions
|
|
9
|
+
*
|
|
10
|
+
* Se encarga de combinar y configurar las acciones del header de una ventana.
|
|
11
|
+
* Utiliza información del entorno (assets, diccionarios) y del store para agregar
|
|
12
|
+
* acciones predefinidas (como collapse/expand y maximize/normalize).
|
|
13
|
+
* @param {UseHeaderActionsParams} params - Parámetros que incluyen las acciones definidas,
|
|
14
|
+
* el id de la ventana y el id del área.
|
|
15
|
+
* @returns {Object} Un objeto con tres arrays: leftActions, menuActions y rightActions.
|
|
16
|
+
* @example
|
|
17
|
+
* const { leftActions, menuActions, rightActions } = useHeaderActions({
|
|
18
|
+
* moduleActions: misAcciones,
|
|
19
|
+
* windowId: 'win_456',
|
|
20
|
+
* areaId: 'area_123',
|
|
21
|
+
* });
|
|
22
|
+
* @author cesar - automatic
|
|
23
|
+
* @createdAt 2025-02-05 08:48:16 - automatic
|
|
24
|
+
* @updatedAt 2025-02-06 14:50:07 - automatic
|
|
25
|
+
* @updatedUser cesar - automatic
|
|
26
|
+
*/
|
|
27
|
+
export declare const useHeaderActions: ({ windowId, areaId, menuActions, }: UseHeaderActionsParams) => {
|
|
28
|
+
leftActions: WindowBaseAction[];
|
|
29
|
+
menuActions: WindowBaseAction[];
|
|
30
|
+
rightActions: WindowBaseAction[];
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
3
|
+
import { u as useAreasStore } from "../../../../../../../../hooks/useAreas/index.js";
|
|
4
|
+
import { I as ICONS } from "../../../../../../../../icons.js";
|
|
5
|
+
import { g as getAreasDictionary, A as AREAS_DICCTIONARY } from "../../../../../../../../dictionary.js";
|
|
6
|
+
import { g as getMainActions, a as getMenuActions } from "../../subcomponents/Header/helper.js";
|
|
7
|
+
import { shallow } from "zustand/shallow";
|
|
8
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
9
|
+
const useHeaderActions = ({
|
|
10
|
+
windowId,
|
|
11
|
+
areaId,
|
|
12
|
+
menuActions = []
|
|
13
|
+
}) => {
|
|
14
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
15
|
+
const { getLabel } = useModuleDictionary();
|
|
16
|
+
const isDesktop = useResponsiveDesktop();
|
|
17
|
+
const urlPrefix = `${host_static_assets}/${environment_assets}`;
|
|
18
|
+
const moduleActions = useAreasStore(
|
|
19
|
+
(state) => {
|
|
20
|
+
const window = state.hashWindows[windowId];
|
|
21
|
+
return window?.moduleActions || [];
|
|
22
|
+
},
|
|
23
|
+
shallow
|
|
24
|
+
);
|
|
25
|
+
const mainActions = useMemo(() => {
|
|
26
|
+
return getMainActions(isDesktop, moduleActions).map((action) => ({
|
|
27
|
+
...action,
|
|
28
|
+
place: "left",
|
|
29
|
+
iconUrl: action.iconUrl || "",
|
|
30
|
+
label: action.label || ""
|
|
31
|
+
}));
|
|
32
|
+
}, [isDesktop, moduleActions]);
|
|
33
|
+
const windowOptions = useAreasStore(
|
|
34
|
+
(state) => state.hashWindows[windowId]?.windowOptions,
|
|
35
|
+
shallow
|
|
36
|
+
);
|
|
37
|
+
const { saveModuleCookies, resetModuleCookies } = useAreasStore(
|
|
38
|
+
(state) => state.windowActions,
|
|
39
|
+
shallow
|
|
40
|
+
);
|
|
41
|
+
const menuActionsInside = useMemo(() => {
|
|
42
|
+
return getMenuActions({
|
|
43
|
+
windowId,
|
|
44
|
+
isDesktop,
|
|
45
|
+
moduleActions,
|
|
46
|
+
urlPrefix,
|
|
47
|
+
saveModuleCookies,
|
|
48
|
+
resetModuleCookies,
|
|
49
|
+
windowOptions: windowOptions || { allowPersistCookies: false },
|
|
50
|
+
getLabel
|
|
51
|
+
}).map((action) => ({
|
|
52
|
+
...action,
|
|
53
|
+
place: "inside",
|
|
54
|
+
iconUrl: action.iconUrl || "",
|
|
55
|
+
label: action.label || ""
|
|
56
|
+
}));
|
|
57
|
+
}, [windowId, isDesktop, moduleActions, urlPrefix, saveModuleCookies, resetModuleCookies, windowOptions, getLabel]);
|
|
58
|
+
const predefActions = useMemo(() => {
|
|
59
|
+
const groups = {
|
|
60
|
+
left: [],
|
|
61
|
+
inside: [],
|
|
62
|
+
right: []
|
|
63
|
+
};
|
|
64
|
+
menuActions.forEach((action) => {
|
|
65
|
+
if (action.place === "left") {
|
|
66
|
+
groups.left.push(action);
|
|
67
|
+
} else if (action.place === "inside") {
|
|
68
|
+
groups.inside.push(action);
|
|
69
|
+
} else if (action.place === "right") {
|
|
70
|
+
groups.right.push(action);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return groups;
|
|
74
|
+
}, [menuActions]);
|
|
75
|
+
const collapsed = useAreasStore(
|
|
76
|
+
(state) => {
|
|
77
|
+
const currentBreakpoint = state.hashAreas[areaId].currentBreakpoint;
|
|
78
|
+
if (currentBreakpoint) {
|
|
79
|
+
return state.hashAreas[areaId].layouts[currentBreakpoint].find(
|
|
80
|
+
(li) => li.i === windowId
|
|
81
|
+
)?.colapsed;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
},
|
|
85
|
+
shallow
|
|
86
|
+
);
|
|
87
|
+
const maximizedId = useAreasStore(
|
|
88
|
+
(state) => state.hashAreas[areaId].maximizedId,
|
|
89
|
+
shallow
|
|
90
|
+
);
|
|
91
|
+
const { maximizeLayout, normalizeLayouts, colapseLayoutItem, unColapseLayoutItem } = useAreasStore((state) => state.areaActions);
|
|
92
|
+
const headerRightActions = useMemo(() => {
|
|
93
|
+
const actions = [];
|
|
94
|
+
actions.push({
|
|
95
|
+
place: "right",
|
|
96
|
+
key: "maximize",
|
|
97
|
+
iconUrl: maximizedId ? `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.NORMALIZE}` : `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.MAXIMIZE}`,
|
|
98
|
+
label: maximizedId ? getLabel(getAreasDictionary(AREAS_DICCTIONARY.label_minimize_window)) : getLabel(getAreasDictionary(AREAS_DICCTIONARY.label_maximize_window)),
|
|
99
|
+
/**
|
|
100
|
+
* onClick de la acción de maximize/normalize.
|
|
101
|
+
* @author cesar - automatic
|
|
102
|
+
* @createdAt 2025-02-06 14:50:07 - automatic
|
|
103
|
+
* @updatedAt 2025-02-06 14:50:07 - automatic
|
|
104
|
+
* @updatedUser cesar - automatic
|
|
105
|
+
*/
|
|
106
|
+
onClick: () => {
|
|
107
|
+
if (maximizedId) {
|
|
108
|
+
normalizeLayouts(areaId);
|
|
109
|
+
} else {
|
|
110
|
+
maximizeLayout(areaId, windowId);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
disabled: false
|
|
114
|
+
});
|
|
115
|
+
if (!maximizedId) {
|
|
116
|
+
actions.push({
|
|
117
|
+
place: "right",
|
|
118
|
+
key: "collapseToggle",
|
|
119
|
+
iconUrl: !collapsed ? `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.COLAPSE}` : `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.UNCOLPASE}`,
|
|
120
|
+
label: !collapsed ? getLabel(getAreasDictionary(AREAS_DICCTIONARY.label_collapse_window)) : getLabel(getAreasDictionary(AREAS_DICCTIONARY.label_uncollapse_window)),
|
|
121
|
+
/**
|
|
122
|
+
* onClick de la acción de collapse/expand.
|
|
123
|
+
* @author cesar - automatic
|
|
124
|
+
* @createdAt 2025-02-06 14:50:07 - automatic
|
|
125
|
+
* @updatedAt 2025-02-06 14:50:07 - automatic
|
|
126
|
+
* @updatedUser cesar - automatic
|
|
127
|
+
*/
|
|
128
|
+
onClick: () => {
|
|
129
|
+
if (collapsed) {
|
|
130
|
+
unColapseLayoutItem(areaId, windowId);
|
|
131
|
+
} else {
|
|
132
|
+
colapseLayoutItem(areaId, windowId);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
disabled: false
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return actions;
|
|
139
|
+
}, [
|
|
140
|
+
collapsed,
|
|
141
|
+
maximizedId,
|
|
142
|
+
host_static_assets,
|
|
143
|
+
environment_assets,
|
|
144
|
+
getLabel,
|
|
145
|
+
areaId,
|
|
146
|
+
windowId,
|
|
147
|
+
colapseLayoutItem,
|
|
148
|
+
unColapseLayoutItem,
|
|
149
|
+
normalizeLayouts,
|
|
150
|
+
maximizeLayout
|
|
151
|
+
]);
|
|
152
|
+
const combinedInsideActions = useMemo(() => {
|
|
153
|
+
return [...menuActionsInside, ...predefActions.inside];
|
|
154
|
+
}, [menuActionsInside, predefActions.inside]);
|
|
155
|
+
return {
|
|
156
|
+
leftActions: [...mainActions, ...predefActions.left],
|
|
157
|
+
menuActions: combinedInsideActions,
|
|
158
|
+
rightActions: [...predefActions.right, ...headerRightActions]
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export {
|
|
162
|
+
useHeaderActions as u
|
|
163
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WindowToolsMF } from '../../../../../../../../../../../src/components/areas/contexts';
|
|
2
|
+
/**
|
|
3
|
+
* Hook useWindow
|
|
4
|
+
*
|
|
5
|
+
* Este hook encapsula toda la lógica relacionada con el estado y las funciones necesarias
|
|
6
|
+
* para el componente Window. Retorna un objeto con el estado, las acciones y las herramientas
|
|
7
|
+
* de la ventana.
|
|
8
|
+
* @param {string} areaId - Identificador del área.
|
|
9
|
+
* @param {string} windowId - Identificador de la ventana.
|
|
10
|
+
* @returns {Object} Un objeto con el estado, las acciones y las herramientas de la ventana.
|
|
11
|
+
* @author cesar - automatic
|
|
12
|
+
* @createdAt 2025-02-07 15:00:00 - automatic
|
|
13
|
+
* @updatedAt 2025-02-07 16:17:15 - automatic
|
|
14
|
+
* @updatedUser cesar - automatic
|
|
15
|
+
*/
|
|
16
|
+
export declare const useWindow: (areaId: string, windowId: string) => {
|
|
17
|
+
emergeType: "layout" | "popup" | "modal";
|
|
18
|
+
moduleId: string;
|
|
19
|
+
winType: "component" | "microfrontend";
|
|
20
|
+
title: string;
|
|
21
|
+
iconUrl: string;
|
|
22
|
+
version: string | undefined;
|
|
23
|
+
moduleCount: number | undefined;
|
|
24
|
+
selected: boolean;
|
|
25
|
+
mfProps: any;
|
|
26
|
+
component: any;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
status: import('../../../../../../../../../../../src/components/areas/types').WindowStatus;
|
|
29
|
+
dynamicMFStore: Omit<import('zustand').StoreApi<import('../../../../../../../../contexts/DynamicMFParmsContext/store').DynamicMFStateWithActions>, "setState"> & {
|
|
30
|
+
setState(nextStateOrUpdater: import('../../../../../../../../contexts/DynamicMFParmsContext/store').DynamicMFStateWithActions | Partial<import('../../../../../../../../contexts/DynamicMFParmsContext/store').DynamicMFStateWithActions> | ((state: import('immer/dist/internal').WritableDraft<import('../../../../../../../../contexts/DynamicMFParmsContext/store').DynamicMFStateWithActions>) => void), shouldReplace?: boolean | undefined): void;
|
|
31
|
+
};
|
|
32
|
+
windowTools: WindowToolsMF;
|
|
33
|
+
onTouch: () => void;
|
|
34
|
+
memoizedActions: import('../../../../../../../../..').WindowBaseAction[];
|
|
35
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useMemo, useEffect } from "react";
|
|
2
|
+
import { shallow } from "zustand/shallow";
|
|
3
|
+
import { u as useAreasStore } from "../../../../../../../../hooks/useAreas/index.js";
|
|
4
|
+
import { u as useHeaderActions } from "../useHeaderActions/useHeaderActions.js";
|
|
5
|
+
import { c as createToaster } from "../../../../../../../../../ToastContainer/helpers/toaster.js";
|
|
6
|
+
const useWindow = (areaId, windowId) => {
|
|
7
|
+
const [emergeType, moduleId, winType, title, iconUrl, version, moduleCount, selected, loading, status, dynamicMFStore] = useAreasStore((state) => {
|
|
8
|
+
const window = state.hashWindows[windowId];
|
|
9
|
+
const selected2 = state.hashAreas[areaId]?.currentLayoutId === windowId || state.hashAreas[areaId]?.currentPopUpId === windowId;
|
|
10
|
+
return [
|
|
11
|
+
window?.emergeType,
|
|
12
|
+
window?.moduleId,
|
|
13
|
+
window?.winType,
|
|
14
|
+
window?.title,
|
|
15
|
+
window?.iconUrl,
|
|
16
|
+
window?.version,
|
|
17
|
+
window?.moduleCount,
|
|
18
|
+
selected2,
|
|
19
|
+
window?.loading,
|
|
20
|
+
window?.status,
|
|
21
|
+
window?.dynamicMFStore
|
|
22
|
+
];
|
|
23
|
+
}, shallow);
|
|
24
|
+
const mfProps = useAreasStore((state) => state.hashWindows[windowId]?.mfProps, shallow);
|
|
25
|
+
const component = useAreasStore(
|
|
26
|
+
(state) => state.hashWindows[windowId]?.component,
|
|
27
|
+
shallow
|
|
28
|
+
);
|
|
29
|
+
const { setActions, getCookie, getCookies, setCookie, close, startProgress, stopProgress, setFnQueryClose, setWindowTitle, loadCookiesFromApi } = useAreasStore((state) => state.windowActions, shallow);
|
|
30
|
+
const { selectLayout } = useAreasStore((state) => state.areaActions, shallow);
|
|
31
|
+
const onTouch = () => {
|
|
32
|
+
if (!selected) {
|
|
33
|
+
selectLayout(areaId, windowId);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const windowTools = useMemo(
|
|
37
|
+
() => ({
|
|
38
|
+
getWindowId: () => windowId,
|
|
39
|
+
setActions: (newActions) => {
|
|
40
|
+
setActions(windowId, newActions, version);
|
|
41
|
+
},
|
|
42
|
+
getCookie: (id) => getCookie(windowId, id),
|
|
43
|
+
getCookies: (type) => getCookies(windowId, type),
|
|
44
|
+
setCookie: (id, type, cookie) => setCookie(windowId, id, type, cookie),
|
|
45
|
+
close: () => close(windowId),
|
|
46
|
+
startProgress: () => startProgress(windowId),
|
|
47
|
+
stopProgress: () => stopProgress(windowId),
|
|
48
|
+
setFnQueryClose: (fnQueryClose) => setFnQueryClose(windowId, fnQueryClose),
|
|
49
|
+
toast: createToaster(windowId),
|
|
50
|
+
setWindowTitle: (newTitle) => setWindowTitle(windowId, newTitle)
|
|
51
|
+
}),
|
|
52
|
+
[windowId, version, setActions, getCookie, getCookies, setCookie, close, startProgress, stopProgress, setFnQueryClose, setWindowTitle]
|
|
53
|
+
);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (status === "init") {
|
|
56
|
+
loadCookiesFromApi(windowId);
|
|
57
|
+
}
|
|
58
|
+
}, [status, loadCookiesFromApi, windowId]);
|
|
59
|
+
const { leftActions, menuActions, rightActions } = useHeaderActions({
|
|
60
|
+
windowId,
|
|
61
|
+
areaId,
|
|
62
|
+
menuActions: []
|
|
63
|
+
});
|
|
64
|
+
const memoizedActions = useMemo(() => {
|
|
65
|
+
return [...leftActions, ...menuActions, ...rightActions];
|
|
66
|
+
}, [leftActions, menuActions, rightActions]);
|
|
67
|
+
return {
|
|
68
|
+
emergeType,
|
|
69
|
+
moduleId,
|
|
70
|
+
winType,
|
|
71
|
+
title,
|
|
72
|
+
iconUrl,
|
|
73
|
+
version,
|
|
74
|
+
moduleCount,
|
|
75
|
+
selected,
|
|
76
|
+
mfProps,
|
|
77
|
+
component,
|
|
78
|
+
loading,
|
|
79
|
+
status,
|
|
80
|
+
dynamicMFStore,
|
|
81
|
+
windowTools,
|
|
82
|
+
onTouch,
|
|
83
|
+
memoizedActions
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export {
|
|
87
|
+
useWindow as u
|
|
88
|
+
};
|
package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/index.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { WindowProps } from './types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Componente Window
|
|
5
|
+
*
|
|
6
|
+
* Este componente se encarga de renderizar la ventana en el AreasViewer.
|
|
7
|
+
* Lee los datos y configuraciones de la ventana desde el store de Zustand,
|
|
8
|
+
* crea herramientas para el microfrontend o componente y utiliza un hook
|
|
9
|
+
* personalizado para definir las acciones del header.
|
|
10
|
+
* @param {WindowProps} props - Propiedades del componente, que incluyen areaId y windowId.
|
|
11
|
+
* @returns {JSX.Element|null} Renderiza la ventana o null si aún no se carga.
|
|
12
|
+
* @example
|
|
13
|
+
* <Window areaId="area_123" windowId="win_456" />
|
|
14
|
+
* @author cesar - automatic
|
|
15
|
+
* @createdAt 2025-02-03 09:18:28 - automatic
|
|
16
|
+
* @updatedAt 2025-02-07 16:17:15 - automatic
|
|
17
|
+
* @updatedUser cesar - automatic
|
|
5
18
|
*/
|
|
6
19
|
export declare const Window: (props: WindowProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
20
|
export declare const MemonizedWindow: React.MemoExoticComponent<(props: WindowProps) => import("react/jsx-runtime").JSX.Element | null>;
|