@m4l/components 0.1.64 → 0.1.66
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/@types/export.d.ts +8 -0
- package/components/CommonActions/components/ActionCancel/{index.2eb2c1e1.js → index.4d0333c0.js} +1 -1
- package/components/CommonActions/components/ActionFormCancel/{index.2864d574.js → index.298e0109.js} +11 -18
- package/components/CommonActions/components/ActionFormIntro/{index.e7f83ddd.js → index.b45922ff.js} +1 -1
- package/components/CommonActions/components/ActionIntro/{index.0d138cb3.js → index.138101aa.js} +2 -2
- package/components/CommonActions/components/Actions/{index.433cd345.js → index.77574633.js} +11 -18
- package/components/DataGrid/{index.42521a55.js → index.ef23d0a9.js} +28 -35
- package/components/DynamicFilter/{index.442bda79.js → index.04ed3d58.js} +34 -46
- package/components/DynamicFilter/index.d.ts +1 -1
- package/components/HelperText/{index.3c07ca2a.js → index.c35dcb93.js} +10 -10
- package/components/Icon/{index.0f9b360e.js → index.fbeeacc8.js} +2 -2
- package/components/Icon/tests/utils.d.ts +1 -1
- package/components/Image/{index.1a9c0327.js → index.77396f79.js} +1 -1
- package/components/LanguagePopover/{index.68de7176.js → index.c0fc94c7.js} +11 -11
- package/components/ModalDialog/{index.3efe049b.js → index.e600b43a.js} +5 -5
- package/components/NavLink/{index.ae9f1cc9.js → index.3f4e2417.js} +11 -11
- package/components/NoItemSelected/{index.7cfd7613.js → index.609c3c20.js} +1 -1
- package/components/ObjectLogs/{index.b50726fb.js → index.7f93ba51.js} +14 -21
- package/components/PaperForm/{index.44bf4469.js → index.fb4fa784.js} +1 -1
- package/components/Period/{index.99feb99e.js → index.0c5bf66f.js} +12 -19
- package/components/Resizeable/{index.b5d42efb.js → index.4545dd6a.js} +3 -3
- package/components/SideBar/{index.011880b6.js → index.7d970041.js} +7 -7
- package/components/areas/components/AreasAdmin/classes/index.d.ts +5 -0
- package/components/areas/components/AreasAdmin/classes/types.d.ts +11 -0
- package/components/areas/components/AreasAdmin/subcomponents/AreaChip/types.d.ts +1 -1
- package/components/areas/components/AreasViewer/classes/index.d.ts +5 -0
- package/components/areas/components/AreasViewer/classes/types.d.ts +19 -0
- package/components/areas/components/AreasViewer/index.d.ts +7 -0
- package/components/areas/{contexts → components/AreasViewer/subcomponents/Area/contexts}/AreaContext/helper.d.ts +2 -2
- package/components/areas/{contexts → components/AreasViewer/subcomponents/Area/contexts}/AreaContext/index.d.ts +3 -3
- package/components/areas/components/AreasViewer/subcomponents/Area/contexts/AreaContext/store.d.ts +11 -0
- package/components/areas/{contexts/AreaContext/store.d.ts → components/AreasViewer/subcomponents/Area/contexts/AreaContext/types.d.ts} +29 -16
- package/components/areas/components/AreasViewer/subcomponents/Area/index.d.ts +12 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/GridLayout/index.d.ts +5 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/PanelWindows/index.d.ts +6 -0
- package/components/areas/{contexts → components/AreasViewer/subcomponents/Area/subcomponents/Window/contexts}/WindowContext/store.d.ts +8 -3
- package/components/areas/{contexts → components/AreasViewer/subcomponents/Area/subcomponents/Window/contexts}/WindowContext/types.d.ts +1 -1
- package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/index.d.ts +1 -1
- package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/index.d.ts +1 -1
- package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/Component/index.d.ts +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/InnerForHooks/subcomponents/Header/helper.d.ts +3 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/InnerForHooks/subcomponents/Header/subcomponents/MainActions/index.d.ts +1 -0
- package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/MicroFrontend/index.d.ts +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/InnerForHooks/subcomponents/MicroFrontend/types.d.ts +8 -0
- package/components/areas/components/{WindowModal → AreasViewer/subcomponents/Area/subcomponents/WindowModal}/index.d.ts +1 -1
- package/components/areas/components/{WindowPopUp → AreasViewer/subcomponents/Area/subcomponents/WindowPopUp}/index.d.ts +1 -1
- package/components/areas/components/{Area → AreasViewer/subcomponents/Area}/types.d.ts +6 -11
- package/components/areas/components/index.d.ts +3 -4
- package/components/areas/constants.d.ts +3 -0
- package/components/areas/contexts/AreasContext/index.d.ts +10 -4
- package/components/areas/contexts/AreasContext/store.d.ts +8 -29
- package/components/areas/contexts/AreasContext/types.d.ts +119 -0
- package/components/areas/contexts/WindowToolsMFContext/types.d.ts +3 -2
- package/components/areas/dictionary.d.ts +9 -14
- package/components/areas/hooks/useArea/index.d.ts +1 -1
- package/components/areas/hooks/useAreas/index.d.ts +1 -1
- package/components/areas/hooks/useWindow/index.d.ts +1 -1
- package/components/areas/icons.d.ts +8 -0
- package/components/areas/index.d.ts +1 -0
- package/components/areas/index.d7519516.js +2416 -0
- package/components/formatters/BooleanFormatter/{index.cd00c8e1.js → index.0edacc9b.js} +1 -1
- package/components/formatters/{index.deae4701.js → index.879170b2.js} +2 -2
- package/components/hook-form/RHFAutocomplete/{index.083e23c1.js → index.5f27e28c.js} +13 -12
- package/components/hook-form/RHFAutocomplete/test/constants.d.ts +1 -0
- package/components/hook-form/RHFAutocomplete/test/utils.d.ts +1 -1
- package/components/hook-form/RHFAutocompleteAsync/{index.ba751be9.js → index.35e17cd6.js} +2 -2
- package/components/hook-form/RHFCheckbox/{index.c19393b1.js → index.4f134f09.js} +3 -3
- package/components/hook-form/RHFPeriod/{index.c0a80aeb.js → index.dcaa0c87.js} +2 -2
- package/components/hook-form/RHFTextField/{index.97485ff2.js → index.fc90a570.js} +13 -13
- package/components/hook-form/RHFUpload/{index.798eb11d.js → index.654ad316.js} +1 -1
- package/components/index.d.ts +1 -3
- package/components/modal/{WindowBase.59f50553.js → WindowBase.230a498f.js} +3 -3
- package/components/modal/{WindowConfirm.c1339cf8.js → WindowConfirm.575b4d41.js} +14 -21
- package/components/modal/index.237881ea.js +23 -0
- package/components/mui_extended/Accordion/{index.b7487e37.js → index.0b15f939.js} +2 -2
- package/components/mui_extended/Button/{index.d9e0ae2e.js → index.b7b70e5f.js} +3 -3
- package/components/mui_extended/IconButton/{index.be9c2ce5.js → index.a5072cd3.js} +15 -11
- package/components/mui_extended/IconButton/types.d.ts +1 -1
- package/components/mui_extended/MenuActions/icons.d.ts +3 -0
- package/components/mui_extended/MenuActions/{index.ec654122.js → index.3a275abb.js} +21 -20
- package/components/mui_extended/MenuActions/types.d.ts +5 -6
- package/components/mui_extended/Pager/{index.9e123670.js → index.5a69ab10.js} +5 -5
- package/components/mui_extended/Popover/{index.260aae81.js → index.e271e4f0.js} +1 -0
- package/components/mui_extended/Typography/{index.41b60a6b.js → index.eab3d85c.js} +1 -1
- package/components/mui_extended/index.35f74599.js +19 -0
- package/contexts/ModalContext/{index.ae8041f3.js → index.de0a3457.js} +1 -1
- package/hooks/useModal/{index.5c159ed2.js → index.e103db09.js} +1 -1
- package/index.js +118 -132
- package/package.json +2 -3
- package/{react-draggable.1aa81436.js → react-draggable.4d08d714.js} +1 -1
- package/{react-resizable.e86cb01e.js → react-resizable.23b980cb.js} +5 -4
- package/utils/{index.e199226a.js → index.c2e62d8f.js} +32 -32
- package/{vendor.a15d263e.js → vendor.be57c149.js} +43 -52
- package/components/areas/components/Area/index.d.ts +0 -5
- package/components/areas/components/AreasAdmin/index.51e28f63.js +0 -120
- package/components/areas/components/AreasContainer/index.1e5e6e91.js +0 -37
- package/components/areas/components/AreasContainer/index.d.ts +0 -1
- package/components/areas/components/GridLayout/index.5bf8d5e4.js +0 -103
- package/components/areas/components/GridLayout/index.d.ts +0 -1
- package/components/areas/components/Window/icons.d.ts +0 -3
- package/components/areas/components/Window/index.416a874f.js +0 -855
- package/components/areas/components/Window/subcomponents/InnerForHooks/subcomponents/MicroFrontend/types.d.ts +0 -8
- package/components/areas/components/WindowPopUp/index.f053fca7.js +0 -118
- package/components/areas/components/WindowsPanel/index.d.ts +0 -1
- package/components/areas/components/index.eace295a.js +0 -77
- package/components/areas/contexts/AreaContext/index.7890e58d.js +0 -509
- package/components/areas/contexts/AreaContext/types.d.ts +0 -20
- package/components/areas/contexts/AreasContext/index.0792a8d1.js +0 -197
- package/components/areas/contexts/DynamicMFParmsContext/index.c19cb8cc.js +0 -43
- package/components/areas/contexts/index.2a915acf.js +0 -198
- package/components/areas/hooks/index.f4d78492.js +0 -27
- package/components/areas/hooks/useArea/index.d6263051.js +0 -20
- package/components/areas/hooks/useDynamicMFParameters/index.041a666b.js +0 -14
- package/components/areas/index.8fca0f8f.js +0 -20
- package/components/modal/index.7a84f64d.js +0 -30
- package/components/mui_extended/index.459cbd6c.js +0 -19
- /package/components/areas/components/{Area → AreasViewer/subcomponents/Area}/subcomponents/InnerForHooks/index.d.ts +0 -0
- /package/components/areas/{contexts → components/AreasViewer/subcomponents/Area/subcomponents/Window/contexts}/WindowContext/helper.d.ts +0 -0
- /package/components/areas/{contexts → components/AreasViewer/subcomponents/Area/subcomponents/Window/contexts}/WindowContext/index.d.ts +0 -0
- /package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/Header/index.d.ts +0 -0
- /package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/Header/skeleton.d.ts +0 -0
- /package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/MicroFrontend/subcomponents/MFLoader/index.d.ts +0 -0
- /package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/MicroFrontend/subcomponents/MFLoader/subcomponents/LoadingMF/index.d.ts +0 -0
- /package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/MicroFrontend/subcomponents/MFLoader/subcomponents/LoadingMF/subcomponents/NotFound/index.d.ts +0 -0
- /package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/MicroFrontend/subcomponents/MFLoader/subcomponents/LoadingMF/subcomponents/NotFound/types.d.ts +0 -0
- /package/components/areas/components/{Window → AreasViewer/subcomponents/Area/subcomponents/Window}/subcomponents/InnerForHooks/subcomponents/MicroFrontend/subcomponents/MFLoader/subcomponents/LoadingMF/types.d.ts +0 -0
|
@@ -0,0 +1,2416 @@
|
|
|
1
|
+
import { I as IconButton } from "../mui_extended/IconButton/index.a5072cd3.js";
|
|
2
|
+
import { useHostTools, useModuleDictionary, useNetwork, useModuleSkeleton, EmitEvents, useEnvironment, axiosOperation } from "@m4l/core";
|
|
3
|
+
import { shallow } from "zustand/shallow";
|
|
4
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
|
+
import React__default, { createContext, useRef, useCallback, useEffect, useContext, useMemo, useState } from "react";
|
|
6
|
+
import { generateUtilityClasses, Skeleton, styled as styled$1, Typography as Typography$1, Dialog } from "@mui/material";
|
|
7
|
+
import { I as Icon } from "../Icon/index.fbeeacc8.js";
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
import { createStore, useStore } from "zustand";
|
|
10
|
+
import { useResponsiveDesktop, useFirstRender, useHostTheme, useFormatter, useLocales } from "@m4l/graphics";
|
|
11
|
+
import { devtools } from "zustand/middleware";
|
|
12
|
+
import { immer } from "zustand/middleware/immer";
|
|
13
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
14
|
+
import { g as getComponentUtilityClass } from "../../utils/index.c2e62d8f.js";
|
|
15
|
+
import "../mui_extended/Accordion/index.0b15f939.js";
|
|
16
|
+
import "../mui_extended/Avatar/index.fe06afd7.js";
|
|
17
|
+
import "react-router-dom";
|
|
18
|
+
import "@mui/material/Button";
|
|
19
|
+
import { B as Button } from "../mui_extended/Button/index.b7b70e5f.js";
|
|
20
|
+
import { I as Image } from "../Image/index.77396f79.js";
|
|
21
|
+
import "@mui/lab";
|
|
22
|
+
import { T as Typography } from "../mui_extended/Typography/index.eab3d85c.js";
|
|
23
|
+
import "../mui_extended/Popover/index.e271e4f0.js";
|
|
24
|
+
import { M as MenuActions } from "../mui_extended/MenuActions/index.3a275abb.js";
|
|
25
|
+
import "../mui_extended/Pager/index.5a69ab10.js";
|
|
26
|
+
import "../mui_extended/Tab/index.e0653a0a.js";
|
|
27
|
+
import { styled } from "@mui/material/styles";
|
|
28
|
+
import { r as react_resizable_css } from "../../react-resizable.23b980cb.js";
|
|
29
|
+
import debounce from "lodash/debounce";
|
|
30
|
+
import cloneDeep from "lodash.clonedeep";
|
|
31
|
+
import { WidthProvider, Responsive } from "react-grid-layout";
|
|
32
|
+
import { m } from "framer-motion";
|
|
33
|
+
import "../animate/LoadingScreen/index.1d0c4307.js";
|
|
34
|
+
import "../animate/PropagateLoader/index.be5b02c3.js";
|
|
35
|
+
import "react-hook-form";
|
|
36
|
+
import "../hook-form/RHFAutocomplete/index.5f27e28c.js";
|
|
37
|
+
import "../HelperText/index.c35dcb93.js";
|
|
38
|
+
import "../hook-form/RHFAutocompleteAsync/index.35e17cd6.js";
|
|
39
|
+
import "../hook-form/RHFCheckbox/index.4f134f09.js";
|
|
40
|
+
import "@mui/x-date-pickers";
|
|
41
|
+
import "../hook-form/RHFDateTime/index.6c129ce4.js";
|
|
42
|
+
import "../hook-form/RHFTextField/index.fc90a570.js";
|
|
43
|
+
import "../hook-form/RHFPeriod/index.dcaa0c87.js";
|
|
44
|
+
import "../Period/index.0c5bf66f.js";
|
|
45
|
+
import "../CommonActions/components/Actions/index.77574633.js";
|
|
46
|
+
import "../../contexts/ModalContext/index.de0a3457.js";
|
|
47
|
+
import { c as cjs } from "../../react-draggable.4d08d714.js";
|
|
48
|
+
import "../ModalDialog/index.e600b43a.js";
|
|
49
|
+
import { R as ResizeableWindow } from "../Resizeable/index.4545dd6a.js";
|
|
50
|
+
import "../modal/WindowConfirm.575b4d41.js";
|
|
51
|
+
import "../modal/WindowBase.230a498f.js";
|
|
52
|
+
import "lodash/isString";
|
|
53
|
+
import "react-dropzone";
|
|
54
|
+
import "../hook-form/RHFUpload/index.654ad316.js";
|
|
55
|
+
import "../DataGrid/index.ef23d0a9.js";
|
|
56
|
+
import "react-dnd";
|
|
57
|
+
import "react-dnd-html5-backend";
|
|
58
|
+
import "../DynamicFilter/index.04ed3d58.js";
|
|
59
|
+
import "../ScrollBar/index.bbe48f4d.js";
|
|
60
|
+
import "yup";
|
|
61
|
+
import "@hookform/resolvers/yup";
|
|
62
|
+
import "../../contexts/RHFormContext/index.a7511399.js";
|
|
63
|
+
import { D as DraggableWindow } from "../../vendor.be57c149.js";
|
|
64
|
+
import "../LanguagePopover/index.c0fc94c7.js";
|
|
65
|
+
import "../NavLink/index.3f4e2417.js";
|
|
66
|
+
import "../NoItemSelected/index.609c3c20.js";
|
|
67
|
+
import "../ObjectLogs/index.7f93ba51.js";
|
|
68
|
+
import "../../react-json-view.57125fcf.js";
|
|
69
|
+
import "../PaperForm/index.fb4fa784.js";
|
|
70
|
+
import "../Page/index.4237c241.js";
|
|
71
|
+
import "../PropertyValue/index.dfcfe1ba.js";
|
|
72
|
+
import "../../react-splitter-layout.8b1655c8.js";
|
|
73
|
+
import "../SplitLayout/index.5a8355d8.js";
|
|
74
|
+
import "../SideBar/index.7d970041.js";
|
|
75
|
+
import { L as LinearProgress } from "../mui_extended/LinearProgress/index.c92b9ba9.js";
|
|
76
|
+
import { v as varBounce } from "../animate/variants/bounce.784aaaaa.js";
|
|
77
|
+
const AREAS_DICTIONARY_ID = "areas";
|
|
78
|
+
function getAreasComponentsDictionary() {
|
|
79
|
+
return [AREAS_DICTIONARY_ID];
|
|
80
|
+
}
|
|
81
|
+
const LABEL_FILTER_BUTTON = "filter_tooltip";
|
|
82
|
+
const DICCTIONARY = {
|
|
83
|
+
label_new_area: "label_new_area",
|
|
84
|
+
label_persist_module_cookies: "label_persist_module_cookies"
|
|
85
|
+
};
|
|
86
|
+
const getAreasDictionary = (key) => {
|
|
87
|
+
return `${AREAS_DICTIONARY_ID}.${key}`;
|
|
88
|
+
};
|
|
89
|
+
const AREAS_VIEWER_CLASS_NAME = "M4LAreasViewer";
|
|
90
|
+
const AREAS_ADMIN_CLASS_NAME = "M4LAreasAdmin";
|
|
91
|
+
const areasViewerClasses = generateUtilityClasses(AREAS_VIEWER_CLASS_NAME, [
|
|
92
|
+
"root",
|
|
93
|
+
"areaRoot",
|
|
94
|
+
"areaGridLayoutPanelContainer",
|
|
95
|
+
"areaGridLayout",
|
|
96
|
+
"areaGridLayoutPopupsContainer",
|
|
97
|
+
"windowRoot",
|
|
98
|
+
"windowHeader",
|
|
99
|
+
"windowHeaderTitle",
|
|
100
|
+
"windowHeaderMainActions",
|
|
101
|
+
"windowContent",
|
|
102
|
+
"windowPopupRoot",
|
|
103
|
+
"windowModalRoot",
|
|
104
|
+
"panelWindowsRoot",
|
|
105
|
+
"panelWindowsButtonContainer",
|
|
106
|
+
"selected",
|
|
107
|
+
"isMobile"
|
|
108
|
+
], AREAS_VIEWER_CLASS_NAME);
|
|
109
|
+
const useAreasViewerUtilityClasses = (ownerState) => {
|
|
110
|
+
const slots = {
|
|
111
|
+
root: ["root", ownerState.status, ownerState.isMobile && "isMobile", ownerState.isSkeleton && "isSkeleton"],
|
|
112
|
+
areaRoot: ["areaRoot"],
|
|
113
|
+
areaGridLayoutPanelContainer: ["areaGridLayoutPanelContainer"],
|
|
114
|
+
areaGridLayout: ["areaGridLayout"],
|
|
115
|
+
areaGridLayoutPopupsContainer: ["areaGridLayoutPopupsContainer"],
|
|
116
|
+
windowRoot: ["windowRoot"],
|
|
117
|
+
windowHeader: ["windowHeader"],
|
|
118
|
+
windowHeaderTitle: ["windowHeaderTitle"],
|
|
119
|
+
windowHeaderMainActions: ["windowHeaderMainActions"],
|
|
120
|
+
windowContent: ["windowContent"],
|
|
121
|
+
windowPopupRoot: ["windowPopupRoot"],
|
|
122
|
+
windowModalRoot: ["windowModalRoot"],
|
|
123
|
+
panelWindowsRoot: ["panelWindowsRoot"],
|
|
124
|
+
panelWindowsButtonContainer: ["panelWindowsButtonContainer"]
|
|
125
|
+
};
|
|
126
|
+
return unstable_composeClasses(slots, getComponentUtilityClass(AREAS_VIEWER_CLASS_NAME), {});
|
|
127
|
+
};
|
|
128
|
+
const areasAdminClasses = generateUtilityClasses(AREAS_ADMIN_CLASS_NAME, [
|
|
129
|
+
"root",
|
|
130
|
+
"areaChipRoot",
|
|
131
|
+
"areaChipTitle",
|
|
132
|
+
"areaChipDeleteButton",
|
|
133
|
+
"areaChipEditButton",
|
|
134
|
+
"areasAddButton",
|
|
135
|
+
"selected",
|
|
136
|
+
"isMobile"
|
|
137
|
+
], AREAS_ADMIN_CLASS_NAME);
|
|
138
|
+
const useAreasAdminUtilityClasses = (ownerState) => {
|
|
139
|
+
const slots = {
|
|
140
|
+
root: ["root", ownerState.status, ownerState.isMobile && "isMobile", ownerState.isSkeleton && "isSkeleton"],
|
|
141
|
+
areaChipRoot: ["areaChipRoot"],
|
|
142
|
+
areaChipTitle: ["areaChipTitle"],
|
|
143
|
+
areaChipDeleteButton: ["areaChipDeleteButton"],
|
|
144
|
+
areaChipEditButton: ["areaChipEditButton"],
|
|
145
|
+
areasAddButton: ["areasAddButton"]
|
|
146
|
+
};
|
|
147
|
+
return unstable_composeClasses(slots, getComponentUtilityClass(AREAS_ADMIN_CLASS_NAME), {});
|
|
148
|
+
};
|
|
149
|
+
const addArea = (state) => {
|
|
150
|
+
let newName = "";
|
|
151
|
+
const newId = `area_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
|
|
152
|
+
newName = `${state.getLabel(getAreasDictionary("label_new_area"))} ${state.areas.length + 1}`;
|
|
153
|
+
state.areas.push({ id: newId, name: newName, loadWindows: false });
|
|
154
|
+
state.currentArea = newId;
|
|
155
|
+
if (state.loadAreasFromNetwork) {
|
|
156
|
+
state.networkOperation({
|
|
157
|
+
method: "POST",
|
|
158
|
+
endPoint: `areas`,
|
|
159
|
+
data: { id: newId, name: newName },
|
|
160
|
+
toastSuccess: false,
|
|
161
|
+
toastError: false
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return newId;
|
|
165
|
+
};
|
|
166
|
+
const updateOwnerStateClasses = (state) => {
|
|
167
|
+
state.viwerClasses = useAreasViewerUtilityClasses(state.ownerState);
|
|
168
|
+
state.adminClasses = useAreasAdminUtilityClasses(state.ownerState);
|
|
169
|
+
};
|
|
170
|
+
const createAreasStore = (initProps) => {
|
|
171
|
+
const startProps = {
|
|
172
|
+
viwerClasses: useAreasViewerUtilityClasses(initProps.ownerState),
|
|
173
|
+
adminClasses: useAreasAdminUtilityClasses(initProps.ownerState),
|
|
174
|
+
currentArea: "",
|
|
175
|
+
areas: [],
|
|
176
|
+
...initProps
|
|
177
|
+
};
|
|
178
|
+
return createStore(
|
|
179
|
+
devtools(
|
|
180
|
+
immer((set, get) => ({
|
|
181
|
+
...startProps,
|
|
182
|
+
actions: {
|
|
183
|
+
init: () => {
|
|
184
|
+
if (get().ownerState.status === "init") {
|
|
185
|
+
if (!get().loadAreasFromNetwork) {
|
|
186
|
+
get().actions.addArea();
|
|
187
|
+
set((state) => {
|
|
188
|
+
state.ownerState.status = "loaded";
|
|
189
|
+
updateOwnerStateClasses(state);
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
set((state) => {
|
|
193
|
+
state.ownerState.status = "loading";
|
|
194
|
+
updateOwnerStateClasses(state);
|
|
195
|
+
state.networkOperation({
|
|
196
|
+
method: "GET",
|
|
197
|
+
endPoint: `areas`,
|
|
198
|
+
parms: {},
|
|
199
|
+
toastSuccess: false
|
|
200
|
+
}).then((response) => {
|
|
201
|
+
set((otherState) => {
|
|
202
|
+
if (response?.data && Array.isArray(response.data) && response.data.length > 0) {
|
|
203
|
+
otherState.areas = response.data;
|
|
204
|
+
otherState.currentArea = response.data[0].id;
|
|
205
|
+
} else {
|
|
206
|
+
addArea(otherState);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}).finally(() => {
|
|
210
|
+
set((state2) => {
|
|
211
|
+
state2.ownerState.status = "loaded";
|
|
212
|
+
updateOwnerStateClasses(state2);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
addArea: () => {
|
|
220
|
+
let newId = "";
|
|
221
|
+
set((state) => {
|
|
222
|
+
newId = addArea(state);
|
|
223
|
+
});
|
|
224
|
+
return newId;
|
|
225
|
+
},
|
|
226
|
+
deleteArea: (areaId) => {
|
|
227
|
+
set((state) => {
|
|
228
|
+
const removeIndex = state.areas.findIndex((area) => area.id === areaId);
|
|
229
|
+
if (removeIndex > -1) {
|
|
230
|
+
state.areas.splice(removeIndex, 1);
|
|
231
|
+
}
|
|
232
|
+
if (state.currentArea === areaId) {
|
|
233
|
+
if (state.areas.length > 0) {
|
|
234
|
+
state.currentArea = state.areas[0].id;
|
|
235
|
+
} else {
|
|
236
|
+
state.currentArea = "";
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (state.loadAreasFromNetwork) {
|
|
240
|
+
state.networkOperation({
|
|
241
|
+
method: "DELETE",
|
|
242
|
+
endPoint: `areas/${areaId}`,
|
|
243
|
+
parms: {},
|
|
244
|
+
toastSuccess: false,
|
|
245
|
+
toastError: false
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
selectArea: (newAreaId) => {
|
|
251
|
+
set((state) => {
|
|
252
|
+
if (state.areas.findIndex((area) => area.id === newAreaId) > -1) {
|
|
253
|
+
state.currentArea = newAreaId;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
internalActions: {
|
|
259
|
+
setHandlerGetLabel: (newHandler) => {
|
|
260
|
+
set((state) => {
|
|
261
|
+
state.getLabel = newHandler;
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
setAreaLink: (areaId, store) => {
|
|
265
|
+
set((state) => {
|
|
266
|
+
const areaIndex = state.areas.findIndex((area) => area.id === areaId);
|
|
267
|
+
if (areaIndex > -1) {
|
|
268
|
+
state.areas[areaIndex].store = store;
|
|
269
|
+
state.areas[areaIndex].linked = true;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
setExternalState: (newExternalState) => {
|
|
274
|
+
set((state) => {
|
|
275
|
+
state.ownerState = { ...state.ownerState, ...newExternalState };
|
|
276
|
+
updateOwnerStateClasses(state);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
})),
|
|
281
|
+
{ name: `Areas store` }
|
|
282
|
+
)
|
|
283
|
+
);
|
|
284
|
+
};
|
|
285
|
+
const AreasContext = createContext(null);
|
|
286
|
+
function AreasProvider(props) {
|
|
287
|
+
const {
|
|
288
|
+
children,
|
|
289
|
+
loadAreasFromNetwork,
|
|
290
|
+
loadCookiesFromNetwork,
|
|
291
|
+
onLoad
|
|
292
|
+
} = props;
|
|
293
|
+
const {
|
|
294
|
+
events_add_listener,
|
|
295
|
+
events_remove_listener
|
|
296
|
+
} = useHostTools();
|
|
297
|
+
const {
|
|
298
|
+
getLabel
|
|
299
|
+
} = useModuleDictionary();
|
|
300
|
+
const {
|
|
301
|
+
networkOperation
|
|
302
|
+
} = useNetwork();
|
|
303
|
+
const isDesktop = useResponsiveDesktop();
|
|
304
|
+
const isSkeleton = useModuleSkeleton();
|
|
305
|
+
const isFirstRender = useFirstRender([getLabel]);
|
|
306
|
+
const areasStoreRef = useRef();
|
|
307
|
+
if (!areasStoreRef.current) {
|
|
308
|
+
areasStoreRef.current = createAreasStore({
|
|
309
|
+
getLabel,
|
|
310
|
+
loadAreasFromNetwork,
|
|
311
|
+
loadCookiesFromNetwork,
|
|
312
|
+
networkOperation,
|
|
313
|
+
ownerState: {
|
|
314
|
+
status: "init",
|
|
315
|
+
isMobile: !isDesktop,
|
|
316
|
+
isSkeleton
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
areasStoreRef.current?.getState().actions.init();
|
|
320
|
+
}
|
|
321
|
+
const status = useStore(areasStoreRef.current, (state) => state.ownerState.status, shallow);
|
|
322
|
+
const {
|
|
323
|
+
setHandlerGetLabel
|
|
324
|
+
} = useStore(areasStoreRef.current, (state) => state.internalActions, shallow);
|
|
325
|
+
const addWindow = useCallback((newWindow) => {
|
|
326
|
+
const currentArea = areasStoreRef.current?.getState().currentArea;
|
|
327
|
+
const areas = areasStoreRef.current?.getState().areas;
|
|
328
|
+
if (currentArea && areas) {
|
|
329
|
+
const areaIndex = areas.findIndex((area) => area.id == currentArea);
|
|
330
|
+
if (areaIndex > -1 && areas[areaIndex].store) {
|
|
331
|
+
areas[areaIndex].store?.getState().actions.addWindow(newWindow);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}, []);
|
|
335
|
+
useEffect(() => {
|
|
336
|
+
if (status === "loaded") {
|
|
337
|
+
onLoad && onLoad();
|
|
338
|
+
}
|
|
339
|
+
}, [status]);
|
|
340
|
+
useEffect(() => {
|
|
341
|
+
if (!isFirstRender) {
|
|
342
|
+
setHandlerGetLabel(getLabel);
|
|
343
|
+
}
|
|
344
|
+
}, [getLabel]);
|
|
345
|
+
useEffect(() => {
|
|
346
|
+
events_add_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
|
|
347
|
+
return () => {
|
|
348
|
+
events_remove_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
|
|
349
|
+
};
|
|
350
|
+
}, []);
|
|
351
|
+
useEffect(() => {
|
|
352
|
+
if (isFirstRender) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
areasStoreRef.current?.getState().internalActions.setExternalState({
|
|
356
|
+
isMobile: !isDesktop,
|
|
357
|
+
isSkeleton
|
|
358
|
+
});
|
|
359
|
+
}, [isDesktop, isSkeleton]);
|
|
360
|
+
return /* @__PURE__ */ jsx(AreasContext.Provider, {
|
|
361
|
+
value: areasStoreRef.current,
|
|
362
|
+
children
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function useAreas() {
|
|
366
|
+
const context = useContext(AreasContext);
|
|
367
|
+
if (!context)
|
|
368
|
+
throw new Error("useAreas context must be use inside AreasContext");
|
|
369
|
+
return context;
|
|
370
|
+
}
|
|
371
|
+
function useAreasStore(selector, equalityFn) {
|
|
372
|
+
const context = useContext(AreasContext);
|
|
373
|
+
if (!context)
|
|
374
|
+
throw new Error("useAreasStore context must be use inside AreasContext");
|
|
375
|
+
return useStore(context, selector, equalityFn);
|
|
376
|
+
}
|
|
377
|
+
const ICONS = {
|
|
378
|
+
CLOSE: "close.svg",
|
|
379
|
+
MAXIMIZE: "maximize.svg",
|
|
380
|
+
NORMALIZE: "normalize.svg",
|
|
381
|
+
DELETE_AREA: "delete_area.svg",
|
|
382
|
+
ADD_AREA: "add_area.svg",
|
|
383
|
+
EDIT_AREA: "edit_area.svg"
|
|
384
|
+
};
|
|
385
|
+
const AreaChip = (props) => {
|
|
386
|
+
const {
|
|
387
|
+
areaId,
|
|
388
|
+
selected,
|
|
389
|
+
areaName
|
|
390
|
+
} = props;
|
|
391
|
+
const {
|
|
392
|
+
host_static_assets,
|
|
393
|
+
environment_assets
|
|
394
|
+
} = useEnvironment();
|
|
395
|
+
const {
|
|
396
|
+
deleteArea,
|
|
397
|
+
selectArea
|
|
398
|
+
} = useAreasStore((state) => state.actions);
|
|
399
|
+
const onClickDeleteArea = (e) => {
|
|
400
|
+
e.stopPropagation();
|
|
401
|
+
deleteArea(areaId);
|
|
402
|
+
};
|
|
403
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
404
|
+
role: "presentation",
|
|
405
|
+
className: clsx(areasAdminClasses.areaChipRoot, selected ? areasAdminClasses.selected : null),
|
|
406
|
+
onClick: () => {
|
|
407
|
+
selectArea(areaId);
|
|
408
|
+
},
|
|
409
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
410
|
+
className: areasAdminClasses.areaChipTitle,
|
|
411
|
+
children: areaName
|
|
412
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
413
|
+
className: areasAdminClasses.areaChipDeleteButton,
|
|
414
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.DELETE_AREA}`,
|
|
415
|
+
size: "small",
|
|
416
|
+
onClick: onClickDeleteArea
|
|
417
|
+
})]
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
AreaChip.displayName = "AreaButtons";
|
|
421
|
+
const AreasAdminRoot = styled("div")`
|
|
422
|
+
display: flex;
|
|
423
|
+
position: relative;
|
|
424
|
+
|
|
425
|
+
//areaRoot
|
|
426
|
+
& .${areasAdminClasses.areaChipRoot} {
|
|
427
|
+
display: flex;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
& .${areasAdminClasses.areaChipRoot}.${areasAdminClasses.selected}::before {
|
|
431
|
+
content: "";
|
|
432
|
+
background-color: ${(props) => props.theme.palette.primary.main};
|
|
433
|
+
height: 100%;
|
|
434
|
+
width: 8px;
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
${(props) => props.theme.components?.M4LAreasAdmin}
|
|
438
|
+
|
|
439
|
+
`;
|
|
440
|
+
function AreasAdmin() {
|
|
441
|
+
const areas = useAreasStore((state) => state.areas, shallow);
|
|
442
|
+
const currentArea = useAreasStore((state) => state.currentArea, shallow);
|
|
443
|
+
const status = useAreasStore((state) => state.ownerState.status);
|
|
444
|
+
const classesRoot = useAreasStore((state) => state.adminClasses.root);
|
|
445
|
+
const {
|
|
446
|
+
addArea: addArea2
|
|
447
|
+
} = useAreasStore((state) => state.actions, shallow);
|
|
448
|
+
const {
|
|
449
|
+
host_static_assets,
|
|
450
|
+
environment_assets
|
|
451
|
+
} = useEnvironment();
|
|
452
|
+
console.log("Render AreasAdmin", status, areas);
|
|
453
|
+
if (status !== "loaded") {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
return /* @__PURE__ */ jsxs(AreasAdminRoot, {
|
|
457
|
+
className: classesRoot,
|
|
458
|
+
children: [areas.map((area) => /* @__PURE__ */ jsx(AreaChip, {
|
|
459
|
+
areaId: area.id,
|
|
460
|
+
selected: area.id === currentArea,
|
|
461
|
+
areaName: area.name
|
|
462
|
+
}, area.id)), /* @__PURE__ */ jsx(IconButton, {
|
|
463
|
+
className: areasAdminClasses.areasAddButton,
|
|
464
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.ADD_AREA}`,
|
|
465
|
+
size: "small",
|
|
466
|
+
onClick: addArea2
|
|
467
|
+
})]
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
const AreasViewerRoot = styled("div")`
|
|
471
|
+
|
|
472
|
+
/* display: flex; */
|
|
473
|
+
width: 100%;
|
|
474
|
+
height: 100%;
|
|
475
|
+
overflow: hidden;
|
|
476
|
+
/* flex-grow: 1; */
|
|
477
|
+
position: relative;
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
//areaRoot
|
|
482
|
+
& .${areasViewerClasses.areaRoot} {
|
|
483
|
+
display: none;
|
|
484
|
+
position: absolute;
|
|
485
|
+
/* flex-grow: 1; */
|
|
486
|
+
flex-direction: row;
|
|
487
|
+
inset: 0;
|
|
488
|
+
/* width: 100%; */
|
|
489
|
+
overflow: hidden;
|
|
490
|
+
justify-content: top;
|
|
491
|
+
align-items: flex-start;
|
|
492
|
+
|
|
493
|
+
visibility: hidden;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
& .${areasViewerClasses.areaRoot}.${areasViewerClasses.selected} {
|
|
497
|
+
display: block;
|
|
498
|
+
visibility: visible;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
&.${areasViewerClasses.isMobile} .${areasViewerClasses.areaRoot} {
|
|
502
|
+
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// areaGridLayoutPanelContainer
|
|
506
|
+
& .${areasViewerClasses.areaGridLayoutPanelContainer} {
|
|
507
|
+
display: flex;
|
|
508
|
+
flex-direction: row;
|
|
509
|
+
height: 100%;
|
|
510
|
+
width: 100%;
|
|
511
|
+
overflow: hidden;
|
|
512
|
+
}
|
|
513
|
+
&.${areasViewerClasses.isMobile} .${areasViewerClasses.areaGridLayoutPanelContainer} {
|
|
514
|
+
flex-direction: column-reverse;
|
|
515
|
+
}
|
|
516
|
+
// areaGridLayout
|
|
517
|
+
& .${areasViewerClasses.areaGridLayout} {
|
|
518
|
+
height: 100%!important;
|
|
519
|
+
overflow: auto;
|
|
520
|
+
flex-grow: 1;
|
|
521
|
+
}
|
|
522
|
+
&.${areasViewerClasses.isMobile} .${areasViewerClasses.areaGridLayout} {
|
|
523
|
+
flex-direction: column-reverse;
|
|
524
|
+
height: unset;
|
|
525
|
+
width: 100%;
|
|
526
|
+
}
|
|
527
|
+
// areaGridLayoutPopupsContainer
|
|
528
|
+
& .${areasViewerClasses.areaGridLayoutPopupsContainer} {
|
|
529
|
+
z-index: 1; //Garantizar q el contenedor de los popus este por encima de los layouts
|
|
530
|
+
// // ' .react-draggable': {
|
|
531
|
+
// // position: 'absolute',
|
|
532
|
+
// // },
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// PanelWindowsRoot
|
|
536
|
+
& .${areasViewerClasses.panelWindowsRoot} {
|
|
537
|
+
display: flex;
|
|
538
|
+
flex-direction: column;
|
|
539
|
+
position: relative;
|
|
540
|
+
}
|
|
541
|
+
&.${areasViewerClasses.isMobile} .${areasViewerClasses.panelWindowsRoot} {
|
|
542
|
+
flex-direction: row;
|
|
543
|
+
}
|
|
544
|
+
& .${areasViewerClasses.panelWindowsButtonContainer}.${areasViewerClasses.selected} {
|
|
545
|
+
border: 1px solid red;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// windowRoot
|
|
549
|
+
& .${areasViewerClasses.windowRoot} {
|
|
550
|
+
inset:0;
|
|
551
|
+
position: absolute;
|
|
552
|
+
display: flex;
|
|
553
|
+
flex-direction: column;
|
|
554
|
+
/* height: 100%; */
|
|
555
|
+
/* width: 100%; */
|
|
556
|
+
overflow: hidden;
|
|
557
|
+
border: 1px solid gray;
|
|
558
|
+
|
|
559
|
+
background-color: ${(props) => props.theme.palette.background.default};
|
|
560
|
+
padding: ${(props) => props.theme.spacing(0)};
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
& .${areasViewerClasses.windowRoot}.${areasViewerClasses.selected} {
|
|
564
|
+
border-top: 1px solid green;
|
|
565
|
+
}
|
|
566
|
+
// windowHeader
|
|
567
|
+
& .${areasViewerClasses.windowHeader} {
|
|
568
|
+
display: flex;
|
|
569
|
+
gap: 4px;
|
|
570
|
+
|
|
571
|
+
align-items: center;
|
|
572
|
+
position: relative;
|
|
573
|
+
|
|
574
|
+
padding: 8px;
|
|
575
|
+
justify-content: end;
|
|
576
|
+
min-height: ${(props) => props.theme.spacing(5)} ;
|
|
577
|
+
|
|
578
|
+
border-bottom: 1px solid ${(props) => props.theme.palette.divider},
|
|
579
|
+
overflow: hidden;
|
|
580
|
+
cursor: move;
|
|
581
|
+
height: 60px;
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
> span: {
|
|
586
|
+
margin-right: 12px;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
// windowHeaderTitle
|
|
590
|
+
& .${areasViewerClasses.windowHeaderTitle} {
|
|
591
|
+
width: 100%;
|
|
592
|
+
max-width: 100%;
|
|
593
|
+
overflow: hidden;
|
|
594
|
+
white-space: nowrap;
|
|
595
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
596
|
+
margin-left: 12px;
|
|
597
|
+
margin-right: 24px;
|
|
598
|
+
text-overflow: ellipsis;
|
|
599
|
+
}
|
|
600
|
+
// windowHeaderMainActions
|
|
601
|
+
& .${areasViewerClasses.windowHeaderMainActions} {
|
|
602
|
+
display: flex;
|
|
603
|
+
|
|
604
|
+
gap: 4px;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
// windowHeaderMainActions
|
|
609
|
+
& .${areasViewerClasses.windowContent} {
|
|
610
|
+
flex-grow: 1;
|
|
611
|
+
position: relative;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// windowModalRoot
|
|
615
|
+
& .${areasViewerClasses.windowModalRoot} .${areasViewerClasses.windowRoot}{
|
|
616
|
+
padding: 16px;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.react-grid-layout {
|
|
620
|
+
position: relative;
|
|
621
|
+
transition: height 200ms ease;
|
|
622
|
+
}
|
|
623
|
+
.react-grid-item {
|
|
624
|
+
transition: all 200ms ease;
|
|
625
|
+
transition-property: left, top;
|
|
626
|
+
}
|
|
627
|
+
.react-grid-item img {
|
|
628
|
+
pointer-events: none;
|
|
629
|
+
user-select: none;
|
|
630
|
+
}
|
|
631
|
+
.react-grid-item.cssTransforms {
|
|
632
|
+
transition-property: transform;
|
|
633
|
+
}
|
|
634
|
+
.react-grid-item.resizing {
|
|
635
|
+
z-index: 1;
|
|
636
|
+
will-change: width, height;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
.react-grid-item.react-draggable-dragging {
|
|
640
|
+
transition: none;
|
|
641
|
+
z-index: 3;
|
|
642
|
+
will-change: transform;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
.react-grid-item.dropping {
|
|
646
|
+
visibility: hidden;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.react-grid-item.react-grid-placeholder {
|
|
650
|
+
background: green;
|
|
651
|
+
opacity: 0.2;
|
|
652
|
+
transition-duration: 100ms;
|
|
653
|
+
z-index: 2;
|
|
654
|
+
-webkit-user-select: none;
|
|
655
|
+
-moz-user-select: none;
|
|
656
|
+
-ms-user-select: none;
|
|
657
|
+
-o-user-select: none;
|
|
658
|
+
user-select: none;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.react-grid-item > .react-resizable-handle {
|
|
662
|
+
position: absolute;
|
|
663
|
+
width: 20px;
|
|
664
|
+
height: 20px;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
.react-grid-item > .react-resizable-handle::after {
|
|
668
|
+
content: "";
|
|
669
|
+
position: absolute;
|
|
670
|
+
right: 3px;
|
|
671
|
+
bottom: 3px;
|
|
672
|
+
width: 5px;
|
|
673
|
+
height: 5px;
|
|
674
|
+
border-right: 2px solid rgba(0, 0, 0, 0.4);
|
|
675
|
+
border-bottom: 2px solid rgba(0, 0, 0, 0.4);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.react-resizable-hide > .react-resizable-handle {
|
|
679
|
+
display: none;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-sw {
|
|
683
|
+
bottom: 0;
|
|
684
|
+
left: 0;
|
|
685
|
+
cursor: sw-resize;
|
|
686
|
+
transform: rotate(90deg);
|
|
687
|
+
}
|
|
688
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-se {
|
|
689
|
+
bottom: 0;
|
|
690
|
+
right: 0;
|
|
691
|
+
cursor: se-resize;
|
|
692
|
+
}
|
|
693
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-nw {
|
|
694
|
+
top: 0;
|
|
695
|
+
left: 0;
|
|
696
|
+
cursor: nw-resize;
|
|
697
|
+
transform: rotate(180deg);
|
|
698
|
+
}
|
|
699
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-ne {
|
|
700
|
+
top: 0;
|
|
701
|
+
right: 0;
|
|
702
|
+
cursor: ne-resize;
|
|
703
|
+
transform: rotate(270deg);
|
|
704
|
+
}
|
|
705
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-w,
|
|
706
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-e {
|
|
707
|
+
top: 50%;
|
|
708
|
+
margin-top: -10px;
|
|
709
|
+
cursor: ew-resize;
|
|
710
|
+
}
|
|
711
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-w {
|
|
712
|
+
left: 0;
|
|
713
|
+
transform: rotate(135deg);
|
|
714
|
+
}
|
|
715
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-e {
|
|
716
|
+
right: 0;
|
|
717
|
+
transform: rotate(315deg);
|
|
718
|
+
}
|
|
719
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-n,
|
|
720
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-s {
|
|
721
|
+
left: 50%;
|
|
722
|
+
margin-left: -10px;
|
|
723
|
+
cursor: ns-resize;
|
|
724
|
+
}
|
|
725
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-n {
|
|
726
|
+
top: 0;
|
|
727
|
+
transform: rotate(225deg);
|
|
728
|
+
}
|
|
729
|
+
.react-grid-item > .react-resizable-handle.react-resizable-handle-s {
|
|
730
|
+
bottom: 0;
|
|
731
|
+
transform: rotate(45deg);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
${react_resizable_css}
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
${(props) => props.theme.components?.M4LAreasViewer}
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
`;
|
|
742
|
+
const ROW_HEIGTH_GRIDLAYOUT = 100;
|
|
743
|
+
const CONTAINER_PADDING_GRIDLAYOUT = 3;
|
|
744
|
+
const DEBOUCED_SAVE_TIME = 500;
|
|
745
|
+
const COOKIE_BREAKPOINT_LAYOUTS = "layoutPros";
|
|
746
|
+
const COOKIE_WINDOWS = "windows";
|
|
747
|
+
const NORMALIZED_BREAKPOINTS = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 };
|
|
748
|
+
const NORMALIZED_COLS = { lg: 24, md: 20, sm: 12, xs: 8, xxs: 2 };
|
|
749
|
+
const MAXIMIZED_COLS = { lg: 24, md: 20, sm: 12, xs: 8, xxs: 2 };
|
|
750
|
+
const getParmsFromValue = (key, data) => {
|
|
751
|
+
try {
|
|
752
|
+
if (Array.isArray(data)) {
|
|
753
|
+
let ob = data.find((f) => f.id === key);
|
|
754
|
+
if (ob) {
|
|
755
|
+
ob = JSON.parse(ob.value);
|
|
756
|
+
}
|
|
757
|
+
return ob;
|
|
758
|
+
}
|
|
759
|
+
} catch (error) {
|
|
760
|
+
}
|
|
761
|
+
return void 0;
|
|
762
|
+
};
|
|
763
|
+
function setAddBreakPoints(state, newLayout) {
|
|
764
|
+
const layoutsBreakPoints = state.breakpointsLayouts;
|
|
765
|
+
const beforeMaximizebreakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
|
|
766
|
+
for (const key in layoutsBreakPoints) {
|
|
767
|
+
const layoutBreakpoint = layoutsBreakPoints[key];
|
|
768
|
+
layoutBreakpoint.push(newLayout);
|
|
769
|
+
}
|
|
770
|
+
if (state.viewMode === "single") {
|
|
771
|
+
for (const key in beforeMaximizebreakpointsLayouts) {
|
|
772
|
+
const beforeLayoutBreakpoint = beforeMaximizebreakpointsLayouts[key];
|
|
773
|
+
beforeLayoutBreakpoint.push(newLayout);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return layoutsBreakPoints;
|
|
777
|
+
}
|
|
778
|
+
function setBreakPointsMaximized(state, layoutId) {
|
|
779
|
+
const layoutsBreakPoints = state.breakpointsLayouts;
|
|
780
|
+
const container = document.getElementsByClassName(`${areasViewerClasses.areaRoot}`)[0];
|
|
781
|
+
console.log(`Setting breakpoints`, container);
|
|
782
|
+
if (container) {
|
|
783
|
+
const clientHeight = container.clientHeight;
|
|
784
|
+
for (const key in layoutsBreakPoints) {
|
|
785
|
+
const layoutBreakpoint = layoutsBreakPoints[key];
|
|
786
|
+
const cols = key in MAXIMIZED_COLS ? MAXIMIZED_COLS[key] : 1;
|
|
787
|
+
const heigth_by_rowheigth = clientHeight / (ROW_HEIGTH_GRIDLAYOUT + 2 * CONTAINER_PADDING_GRIDLAYOUT);
|
|
788
|
+
for (let index = 0; index < layoutBreakpoint.length; index++) {
|
|
789
|
+
const l = layoutBreakpoint[index];
|
|
790
|
+
if (l.i === layoutId) {
|
|
791
|
+
l.x = 0;
|
|
792
|
+
l.y = 0;
|
|
793
|
+
l.h = heigth_by_rowheigth;
|
|
794
|
+
l.w = cols;
|
|
795
|
+
l.minW = 0;
|
|
796
|
+
l.maxW = cols;
|
|
797
|
+
l.minH = 0;
|
|
798
|
+
l.maxH = heigth_by_rowheigth;
|
|
799
|
+
l.isResizable = false;
|
|
800
|
+
l.isDraggable = false;
|
|
801
|
+
} else {
|
|
802
|
+
l.x = 0;
|
|
803
|
+
l.y = 1;
|
|
804
|
+
l.h = 0;
|
|
805
|
+
l.w = 0;
|
|
806
|
+
l.minW = 0;
|
|
807
|
+
l.maxW = 0;
|
|
808
|
+
l.minH = 0;
|
|
809
|
+
l.maxH = 0;
|
|
810
|
+
}
|
|
811
|
+
l.isResizable = false;
|
|
812
|
+
l.isDraggable = false;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return layoutsBreakPoints;
|
|
817
|
+
}
|
|
818
|
+
function getDataFromResponse(data, state) {
|
|
819
|
+
const newBreakPointsLayouts = getParmsFromValue(COOKIE_BREAKPOINT_LAYOUTS, data);
|
|
820
|
+
const windows = getParmsFromValue(COOKIE_WINDOWS, data);
|
|
821
|
+
const newGridLayouts = [];
|
|
822
|
+
const newHashWindowLayouts = {};
|
|
823
|
+
if (windows) {
|
|
824
|
+
for (const key in windows) {
|
|
825
|
+
const element = windows[key];
|
|
826
|
+
if (element && element["layoutProps"] && element["mfProps"] && element["emergeType"] === "layout" && element["winType"] === "microfrontend") {
|
|
827
|
+
element["layoutProps"].i = key;
|
|
828
|
+
newGridLayouts.push(element["layoutProps"]);
|
|
829
|
+
newHashWindowLayouts[key] = {
|
|
830
|
+
...element,
|
|
831
|
+
windowId: key,
|
|
832
|
+
emergeType: "layout",
|
|
833
|
+
onClose: state.actions.closeWindowLayout
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return {
|
|
839
|
+
newBreakPointsLayouts,
|
|
840
|
+
newGridLayouts,
|
|
841
|
+
newHashWindowLayouts
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
const createAreaStore = (initProps) => {
|
|
845
|
+
const startProps = {
|
|
846
|
+
zPopUpIndex: 999,
|
|
847
|
+
status: "init",
|
|
848
|
+
breakpointsLayouts: {},
|
|
849
|
+
beforeMaximizebreakpointsLayouts: {},
|
|
850
|
+
gridLayouts: [],
|
|
851
|
+
windowModal: null,
|
|
852
|
+
windowsPopUps: [],
|
|
853
|
+
hashWindowsPopups: {},
|
|
854
|
+
hashWindowsLayouts: {},
|
|
855
|
+
currentLayoutId: "",
|
|
856
|
+
currentPopUpId: "",
|
|
857
|
+
viewMode: initProps.isDesktop ? "multiple" : "single",
|
|
858
|
+
breakpoints: NORMALIZED_BREAKPOINTS,
|
|
859
|
+
cols: NORMALIZED_COLS,
|
|
860
|
+
...initProps
|
|
861
|
+
};
|
|
862
|
+
return createStore(
|
|
863
|
+
devtools(
|
|
864
|
+
immer((set, get) => ({
|
|
865
|
+
...startProps,
|
|
866
|
+
actions: {
|
|
867
|
+
addWindow: (newWindowProps) => {
|
|
868
|
+
const windowId = `${get().id}_window_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
|
|
869
|
+
console.log("addWindow", newWindowProps.emergeType);
|
|
870
|
+
if (newWindowProps.emergeType === "layout") {
|
|
871
|
+
get().actions.addWindowLayout(windowId, newWindowProps);
|
|
872
|
+
} else if (newWindowProps.emergeType === "popup") {
|
|
873
|
+
get().actions.addWindowPopUp(windowId, newWindowProps);
|
|
874
|
+
} else if (newWindowProps.emergeType === "modal") {
|
|
875
|
+
get().actions.addWindowModal(windowId, newWindowProps);
|
|
876
|
+
}
|
|
877
|
+
},
|
|
878
|
+
closeWindowModal: () => {
|
|
879
|
+
set((state) => {
|
|
880
|
+
state.windowModal = void 0;
|
|
881
|
+
});
|
|
882
|
+
},
|
|
883
|
+
addWindowModal: (container_id, newWindowModalProps) => {
|
|
884
|
+
set((state) => {
|
|
885
|
+
state.windowModal = { ...newWindowModalProps, windowId: container_id };
|
|
886
|
+
});
|
|
887
|
+
},
|
|
888
|
+
closeWindowPopUp: (removePopUpId) => {
|
|
889
|
+
set((state) => {
|
|
890
|
+
const removeIndex = state.windowsPopUps.findIndex(
|
|
891
|
+
(wpId) => wpId === removePopUpId
|
|
892
|
+
);
|
|
893
|
+
if (removeIndex > -1) {
|
|
894
|
+
state.windowsPopUps.splice(removeIndex, 1);
|
|
895
|
+
}
|
|
896
|
+
delete state.hashWindowsPopups[removePopUpId];
|
|
897
|
+
});
|
|
898
|
+
},
|
|
899
|
+
addWindowPopUp: (windowId, newWindowPopupProps) => {
|
|
900
|
+
let popUpId = windowId;
|
|
901
|
+
set((state) => {
|
|
902
|
+
if (newWindowPopupProps.replaceMeId) {
|
|
903
|
+
for (const key in state.hashWindowsPopups) {
|
|
904
|
+
const WindoPopUp = state.hashWindowsPopups[key];
|
|
905
|
+
if (WindoPopUp.replaceMeId === newWindowPopupProps.replaceMeId) {
|
|
906
|
+
popUpId = key;
|
|
907
|
+
state.hashWindowsPopups[key].dynamicParams = newWindowPopupProps.dynamicParams;
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
if (popUpId === windowId) {
|
|
913
|
+
state.windowsPopUps.push(windowId);
|
|
914
|
+
state.hashWindowsPopups[windowId] = {
|
|
915
|
+
...newWindowPopupProps,
|
|
916
|
+
emergeType: "popup",
|
|
917
|
+
windowId,
|
|
918
|
+
onClose: get().actions.closeWindowPopUp,
|
|
919
|
+
zIndex: state.zPopUpIndex
|
|
920
|
+
};
|
|
921
|
+
state.currentPopUpId = windowId;
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
get().actions.selectWindowPopUp(popUpId);
|
|
925
|
+
},
|
|
926
|
+
closeWindowLayout: (removeLayoutId) => {
|
|
927
|
+
set((state) => {
|
|
928
|
+
const removeIndex = state.gridLayouts.findIndex(
|
|
929
|
+
(gl) => gl.i === removeLayoutId
|
|
930
|
+
);
|
|
931
|
+
if (removeIndex > -1) {
|
|
932
|
+
state.gridLayouts.splice(removeIndex, 1);
|
|
933
|
+
}
|
|
934
|
+
delete state.hashWindowsLayouts[removeLayoutId];
|
|
935
|
+
});
|
|
936
|
+
get().actions.saveLayouts();
|
|
937
|
+
if (get().singleId === removeLayoutId) {
|
|
938
|
+
get().actions.maximizeLayout();
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
addWindowLayout: (windowId, newWindow) => {
|
|
942
|
+
const newLayout = {
|
|
943
|
+
...newWindow.layoutProps,
|
|
944
|
+
i: windowId,
|
|
945
|
+
isDraggable: true,
|
|
946
|
+
isResizable: true,
|
|
947
|
+
winType: newWindow.winType
|
|
948
|
+
};
|
|
949
|
+
set((state) => {
|
|
950
|
+
state.gridLayouts.push(newLayout);
|
|
951
|
+
state.hashWindowsLayouts[windowId] = {
|
|
952
|
+
...newWindow,
|
|
953
|
+
windowId,
|
|
954
|
+
emergeType: "layout",
|
|
955
|
+
onClose: get().actions.closeWindowLayout
|
|
956
|
+
};
|
|
957
|
+
setAddBreakPoints(state, newLayout);
|
|
958
|
+
});
|
|
959
|
+
get().actions.selectWindowLayout(windowId);
|
|
960
|
+
if (get().viewMode === "single") {
|
|
961
|
+
get().actions.maximizeLayout(windowId);
|
|
962
|
+
}
|
|
963
|
+
get().actions.saveLayouts();
|
|
964
|
+
get().actions.bouncedSaveBreakpointsLayouts();
|
|
965
|
+
},
|
|
966
|
+
saveLayouts: () => {
|
|
967
|
+
let nrKeys = 0;
|
|
968
|
+
const saveObjetc = {};
|
|
969
|
+
for (const key in get().hashWindowsLayouts) {
|
|
970
|
+
const element = get().hashWindowsLayouts[key];
|
|
971
|
+
if (element.winType === "microfrontend") {
|
|
972
|
+
const newElement = { ...element };
|
|
973
|
+
delete newElement.onClose;
|
|
974
|
+
delete newElement.devCookies;
|
|
975
|
+
saveObjetc[key] = newElement;
|
|
976
|
+
nrKeys++;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if (nrKeys > 0) {
|
|
980
|
+
get().networkOperation({
|
|
981
|
+
method: "PUT",
|
|
982
|
+
endPoint: `cookies/${get().id}/${COOKIE_WINDOWS}`,
|
|
983
|
+
data: {
|
|
984
|
+
value: JSON.stringify(saveObjetc)
|
|
985
|
+
},
|
|
986
|
+
toastSuccess: false,
|
|
987
|
+
toastError: false
|
|
988
|
+
});
|
|
989
|
+
} else {
|
|
990
|
+
get().networkOperation({
|
|
991
|
+
method: "DELETE",
|
|
992
|
+
endPoint: `cookies`,
|
|
993
|
+
data: { f: [{ n: "container_id", o: "c", o1: get().id }] },
|
|
994
|
+
toastSuccess: false,
|
|
995
|
+
toastError: false
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
bouncedSaveBreakpointsLayouts: debounce(
|
|
1000
|
+
() => {
|
|
1001
|
+
const purgedLayouts = {
|
|
1002
|
+
...get().viewMode === "multiple" ? get().breakpointsLayouts : get().beforeMaximizebreakpointsLayouts
|
|
1003
|
+
};
|
|
1004
|
+
const finalLayouts = {};
|
|
1005
|
+
for (const key in purgedLayouts) {
|
|
1006
|
+
const element = purgedLayouts[key];
|
|
1007
|
+
purgedLayouts[key] = element.filter((l) => {
|
|
1008
|
+
if (l.i === "none") {
|
|
1009
|
+
return false;
|
|
1010
|
+
}
|
|
1011
|
+
if (get().hashWindowsLayouts[l.i]) {
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
return false;
|
|
1015
|
+
});
|
|
1016
|
+
if (purgedLayouts[key].length > 0) {
|
|
1017
|
+
finalLayouts[key] = purgedLayouts[key];
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
if (Object.keys(finalLayouts).length > 0) {
|
|
1021
|
+
get().networkOperation({
|
|
1022
|
+
method: "PUT",
|
|
1023
|
+
endPoint: `cookies/${get().id}/${COOKIE_BREAKPOINT_LAYOUTS}`,
|
|
1024
|
+
data: {
|
|
1025
|
+
value: JSON.stringify(finalLayouts)
|
|
1026
|
+
},
|
|
1027
|
+
toastSuccess: false,
|
|
1028
|
+
toastError: false
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
},
|
|
1032
|
+
DEBOUCED_SAVE_TIME
|
|
1033
|
+
),
|
|
1034
|
+
onBreakpointsLayoutsChange: (_currentLayouts, newAllLayouts) => {
|
|
1035
|
+
set((state) => {
|
|
1036
|
+
state.breakpointsLayouts = newAllLayouts;
|
|
1037
|
+
});
|
|
1038
|
+
if (!get().singleId) {
|
|
1039
|
+
get().actions.bouncedSaveBreakpointsLayouts();
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
selectWindowLayout: (layoutId) => {
|
|
1043
|
+
set((state) => {
|
|
1044
|
+
state.currentLayoutId = layoutId;
|
|
1045
|
+
if (state.currentPopUpId !== "" && state.hashWindowsPopups[state.currentPopUpId]) {
|
|
1046
|
+
const windowPopup = state.hashWindowsPopups[state.currentPopUpId];
|
|
1047
|
+
if (windowPopup.parentLayoutId !== layoutId) {
|
|
1048
|
+
state.currentPopUpId = "";
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
},
|
|
1053
|
+
selectWindowPopUp: (popUpId) => {
|
|
1054
|
+
set((state) => {
|
|
1055
|
+
state.zPopUpIndex++;
|
|
1056
|
+
state.currentPopUpId = popUpId;
|
|
1057
|
+
state.zPopUpIndex++;
|
|
1058
|
+
state.currentPopUpId = popUpId;
|
|
1059
|
+
state.hashWindowsPopups[popUpId].zIndex = state.zPopUpIndex;
|
|
1060
|
+
if (state.hashWindowsPopups[popUpId].parentLayoutId && state.hashWindowsPopups[popUpId].parentLayoutId !== "") {
|
|
1061
|
+
state.currentLayoutId = state.hashWindowsPopups[popUpId].parentLayoutId;
|
|
1062
|
+
} else {
|
|
1063
|
+
state.currentLayoutId = "";
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
setTimeout(() => {
|
|
1067
|
+
const container = document.getElementsByClassName(
|
|
1068
|
+
`${areasViewerClasses.areaGridLayoutPanelContainer}-${get().id}`
|
|
1069
|
+
)[0];
|
|
1070
|
+
const element = document.getElementsByClassName(
|
|
1071
|
+
`${areasViewerClasses.windowPopupRoot}-${popUpId}`
|
|
1072
|
+
)[0];
|
|
1073
|
+
if (element && container) {
|
|
1074
|
+
const { top, left } = element.getBoundingClientRect();
|
|
1075
|
+
const { top: containerTop, left: containerLeft } = container.getBoundingClientRect();
|
|
1076
|
+
container.scrollTop = container.scrollTop + top - containerTop;
|
|
1077
|
+
container.scrollLeft = container.scrollLeft + left - containerLeft;
|
|
1078
|
+
}
|
|
1079
|
+
}, 100);
|
|
1080
|
+
},
|
|
1081
|
+
maximizeLayout: (layoutId) => {
|
|
1082
|
+
let finalLayoutId = layoutId;
|
|
1083
|
+
set((state) => {
|
|
1084
|
+
if (state.viewMode === "multiple") {
|
|
1085
|
+
state.beforeMaximizebreakpointsLayouts = cloneDeep(
|
|
1086
|
+
state.breakpointsLayouts
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
if (!finalLayoutId) {
|
|
1090
|
+
if (state.gridLayouts.length > 0) {
|
|
1091
|
+
finalLayoutId = state.gridLayouts[0].i;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
state.viewMode = "single";
|
|
1095
|
+
state.singleId = finalLayoutId;
|
|
1096
|
+
setBreakPointsMaximized(state, finalLayoutId);
|
|
1097
|
+
});
|
|
1098
|
+
if (finalLayoutId) {
|
|
1099
|
+
get().actions.selectWindowLayout(finalLayoutId);
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1102
|
+
normalizeLayouts: () => {
|
|
1103
|
+
set((state) => {
|
|
1104
|
+
if (!state.isDesktop)
|
|
1105
|
+
return;
|
|
1106
|
+
if (state.isDesktop && state.viewMode === "single") {
|
|
1107
|
+
state.viewMode = "multiple";
|
|
1108
|
+
state.singleId = void 0;
|
|
1109
|
+
state.breakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
},
|
|
1114
|
+
internalActions: {
|
|
1115
|
+
loadFromApi: () => {
|
|
1116
|
+
if (get().status !== "init") {
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
if (!get().loadAreasFromNetwork || !get().loadWindows) {
|
|
1120
|
+
set((state) => {
|
|
1121
|
+
state.status = "loaded";
|
|
1122
|
+
});
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
get().networkOperation({
|
|
1126
|
+
method: "GET",
|
|
1127
|
+
endPoint: `cookies`,
|
|
1128
|
+
parms: { f: [{ n: "container_id", o: "e", o1: get().id }] },
|
|
1129
|
+
toastSuccess: false,
|
|
1130
|
+
toastError: false
|
|
1131
|
+
}).then((response) => {
|
|
1132
|
+
set((state) => {
|
|
1133
|
+
const {
|
|
1134
|
+
newBreakPointsLayouts,
|
|
1135
|
+
newGridLayouts,
|
|
1136
|
+
newHashWindowLayouts
|
|
1137
|
+
} = getDataFromResponse(response.data, state);
|
|
1138
|
+
if (state.viewMode === "multiple") {
|
|
1139
|
+
state.breakpointsLayouts = newBreakPointsLayouts;
|
|
1140
|
+
} else {
|
|
1141
|
+
state.breakpointsLayouts = newBreakPointsLayouts;
|
|
1142
|
+
state.beforeMaximizebreakpointsLayouts = newBreakPointsLayouts;
|
|
1143
|
+
}
|
|
1144
|
+
state.gridLayouts = newGridLayouts;
|
|
1145
|
+
state.hashWindowsLayouts = newHashWindowLayouts;
|
|
1146
|
+
state.status = "loaded";
|
|
1147
|
+
});
|
|
1148
|
+
console.log("loadFromApi", get().viewMode);
|
|
1149
|
+
if (get().viewMode === "single") {
|
|
1150
|
+
get().actions.maximizeLayout();
|
|
1151
|
+
}
|
|
1152
|
+
}).catch((_response) => {
|
|
1153
|
+
set((state) => {
|
|
1154
|
+
state.status = "loaded";
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1157
|
+
},
|
|
1158
|
+
changeDesktopBreakpoint: (isDesktop) => {
|
|
1159
|
+
const previousState = get().isDesktop;
|
|
1160
|
+
set((state) => {
|
|
1161
|
+
state.isDesktop = isDesktop;
|
|
1162
|
+
});
|
|
1163
|
+
if (previousState != isDesktop) {
|
|
1164
|
+
if (isDesktop) {
|
|
1165
|
+
get().actions.normalizeLayouts();
|
|
1166
|
+
} else {
|
|
1167
|
+
if (get().viewMode === "multiple") {
|
|
1168
|
+
if (get().gridLayouts.length > 0) {
|
|
1169
|
+
get().actions.maximizeLayout(get().gridLayouts[0].i);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
})),
|
|
1177
|
+
{ name: `Area state ${initProps.id}` }
|
|
1178
|
+
)
|
|
1179
|
+
);
|
|
1180
|
+
};
|
|
1181
|
+
const AreaContext = createContext(null);
|
|
1182
|
+
const AreaProvider = (props) => {
|
|
1183
|
+
const {
|
|
1184
|
+
children,
|
|
1185
|
+
id,
|
|
1186
|
+
selected: active,
|
|
1187
|
+
loadWindows = true
|
|
1188
|
+
} = props;
|
|
1189
|
+
const [loadAreasFromNetwork, loadCookiesFromNetwork] = useAreasStore((state) => [state.loadAreasFromNetwork, state.loadCookiesFromNetwork], shallow);
|
|
1190
|
+
const {
|
|
1191
|
+
setAreaLink
|
|
1192
|
+
} = useAreasStore((state) => state.internalActions);
|
|
1193
|
+
const isDesktop = useResponsiveDesktop();
|
|
1194
|
+
const isFirstRender = useFirstRender([isDesktop]);
|
|
1195
|
+
const {
|
|
1196
|
+
networkOperation
|
|
1197
|
+
} = useNetwork();
|
|
1198
|
+
const areaStoreRef = useRef();
|
|
1199
|
+
if (!areaStoreRef.current) {
|
|
1200
|
+
areaStoreRef.current = createAreaStore({
|
|
1201
|
+
id,
|
|
1202
|
+
networkOperation,
|
|
1203
|
+
loadAreasFromNetwork,
|
|
1204
|
+
loadCookiesFromNetwork,
|
|
1205
|
+
loadWindows,
|
|
1206
|
+
isDesktop: !!isDesktop
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
const {
|
|
1210
|
+
loadFromApi,
|
|
1211
|
+
changeDesktopBreakpoint
|
|
1212
|
+
} = useStore(areaStoreRef.current, (state) => state.internalActions, shallow);
|
|
1213
|
+
const status = useStore(areaStoreRef.current, (state) => state.status, shallow);
|
|
1214
|
+
useEffect(() => {
|
|
1215
|
+
if (!isFirstRender) {
|
|
1216
|
+
changeDesktopBreakpoint(!!isDesktop);
|
|
1217
|
+
}
|
|
1218
|
+
}, [isDesktop]);
|
|
1219
|
+
useEffect(() => {
|
|
1220
|
+
if (areaStoreRef.current) {
|
|
1221
|
+
setAreaLink(id, areaStoreRef.current);
|
|
1222
|
+
}
|
|
1223
|
+
return () => {
|
|
1224
|
+
};
|
|
1225
|
+
}, []);
|
|
1226
|
+
useEffect(() => {
|
|
1227
|
+
if (active && status === "init") {
|
|
1228
|
+
loadFromApi();
|
|
1229
|
+
}
|
|
1230
|
+
}, [active]);
|
|
1231
|
+
return /* @__PURE__ */ jsx(AreaContext.Provider, {
|
|
1232
|
+
value: areaStoreRef.current,
|
|
1233
|
+
children
|
|
1234
|
+
});
|
|
1235
|
+
};
|
|
1236
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1237
|
+
AreaProvider.displayName = "AreaProvider";
|
|
1238
|
+
}
|
|
1239
|
+
React__default.memo(AreaProvider);
|
|
1240
|
+
const useArea = () => {
|
|
1241
|
+
const context = useContext(AreaContext);
|
|
1242
|
+
if (!context)
|
|
1243
|
+
throw new Error("useArea context must be use inside AreaContext");
|
|
1244
|
+
return context;
|
|
1245
|
+
};
|
|
1246
|
+
function useAreaStore(selector, equalityFn) {
|
|
1247
|
+
const context = useContext(AreaContext);
|
|
1248
|
+
if (!context)
|
|
1249
|
+
throw new Error("useAreaStore context must be use inside AreaContext");
|
|
1250
|
+
return useStore(context, selector, equalityFn);
|
|
1251
|
+
}
|
|
1252
|
+
const WindowToolsMFContext = createContext(null);
|
|
1253
|
+
function WindowToolsMFProvider(props) {
|
|
1254
|
+
const {
|
|
1255
|
+
children,
|
|
1256
|
+
...other
|
|
1257
|
+
} = props;
|
|
1258
|
+
return /* @__PURE__ */ jsx(WindowToolsMFContext.Provider, {
|
|
1259
|
+
value: {
|
|
1260
|
+
...other
|
|
1261
|
+
},
|
|
1262
|
+
children
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
React__default.memo(WindowToolsMFProvider);
|
|
1266
|
+
const DynamicMFParmsContext = createContext(null);
|
|
1267
|
+
function DynamicMFParmsProvider(props) {
|
|
1268
|
+
const {
|
|
1269
|
+
children,
|
|
1270
|
+
store
|
|
1271
|
+
} = props;
|
|
1272
|
+
return /* @__PURE__ */ jsx(DynamicMFParmsContext.Provider, {
|
|
1273
|
+
value: store,
|
|
1274
|
+
children
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
const MemonizedDynamicMFParmsProvider = React__default.memo(DynamicMFParmsProvider);
|
|
1278
|
+
const createDynamicMFStore = (initProps) => {
|
|
1279
|
+
const startProps = {
|
|
1280
|
+
...initProps
|
|
1281
|
+
};
|
|
1282
|
+
return createStore(
|
|
1283
|
+
devtools(
|
|
1284
|
+
immer((set, _get) => ({
|
|
1285
|
+
...startProps,
|
|
1286
|
+
actions: {
|
|
1287
|
+
changeData: (newDynamicMFState) => {
|
|
1288
|
+
set((state) => {
|
|
1289
|
+
state.dynamicMFParameters = newDynamicMFState;
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
})),
|
|
1294
|
+
{ name: `dyamic store ${initProps.windowId}` }
|
|
1295
|
+
)
|
|
1296
|
+
);
|
|
1297
|
+
};
|
|
1298
|
+
function getCookiesContainer(data, containerId) {
|
|
1299
|
+
const cookies = {};
|
|
1300
|
+
try {
|
|
1301
|
+
if (Array.isArray(data)) {
|
|
1302
|
+
for (let i = 0; i < data.length; i++) {
|
|
1303
|
+
if (data[i]?.container_id === containerId && data[i]?.id) {
|
|
1304
|
+
cookies[data[i]?.id] = JSON.parse(data[i].value);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
} catch (error) {
|
|
1309
|
+
}
|
|
1310
|
+
return cookies;
|
|
1311
|
+
}
|
|
1312
|
+
const createWindowStore = (initProps) => {
|
|
1313
|
+
const startProps = {
|
|
1314
|
+
status: "init",
|
|
1315
|
+
moduleActions: [],
|
|
1316
|
+
cookies: initProps.devCookies || { moduleCookies: {}, windowCookies: {} },
|
|
1317
|
+
...initProps
|
|
1318
|
+
};
|
|
1319
|
+
delete startProps.devCookies;
|
|
1320
|
+
return createStore(
|
|
1321
|
+
devtools(
|
|
1322
|
+
immer((set, get, _api) => ({
|
|
1323
|
+
...startProps,
|
|
1324
|
+
actions: {
|
|
1325
|
+
setActions: (newActions, version) => {
|
|
1326
|
+
set((state) => {
|
|
1327
|
+
state.moduleActions = cloneDeep(newActions);
|
|
1328
|
+
state.version = version;
|
|
1329
|
+
console.log("LLEGO Version", version);
|
|
1330
|
+
});
|
|
1331
|
+
},
|
|
1332
|
+
close: () => {
|
|
1333
|
+
const onClose = get().onClose;
|
|
1334
|
+
if (onClose) {
|
|
1335
|
+
onClose(get().windowId);
|
|
1336
|
+
}
|
|
1337
|
+
},
|
|
1338
|
+
getWindowId: () => {
|
|
1339
|
+
return get().windowId;
|
|
1340
|
+
},
|
|
1341
|
+
getCookie: (id) => {
|
|
1342
|
+
return get().cookies.windowCookies[id] || get().cookies.moduleCookies[id];
|
|
1343
|
+
},
|
|
1344
|
+
getCookies: (type) => {
|
|
1345
|
+
if (type === "window") {
|
|
1346
|
+
return get().cookies.windowCookies;
|
|
1347
|
+
} else {
|
|
1348
|
+
return get().cookies.moduleCookies;
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
setCookie: (id, type, cookie) => {
|
|
1352
|
+
get().networkOperation({
|
|
1353
|
+
method: "PUT",
|
|
1354
|
+
endPoint: `cookies/${type === "module" ? get().moduleId : get().windowId}/${id}`,
|
|
1355
|
+
data: {
|
|
1356
|
+
value: JSON.stringify(cookie)
|
|
1357
|
+
},
|
|
1358
|
+
toastSuccess: false,
|
|
1359
|
+
toastError: false
|
|
1360
|
+
});
|
|
1361
|
+
set((state) => {
|
|
1362
|
+
if (type === "window") {
|
|
1363
|
+
state.cookies.windowCookies[id] = cookie;
|
|
1364
|
+
} else {
|
|
1365
|
+
state.cookies.moduleCookies[id] = cookie;
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
internalActions: {
|
|
1371
|
+
loadCookiesFromApi: () => {
|
|
1372
|
+
if (get().status === "init") {
|
|
1373
|
+
get().networkOperation({
|
|
1374
|
+
method: "GET",
|
|
1375
|
+
endPoint: `cookies`,
|
|
1376
|
+
parms: {
|
|
1377
|
+
f: [
|
|
1378
|
+
{ n: "container_id", o: "e", o1: get().windowId },
|
|
1379
|
+
{ n: "container_id", o: "e", o1: get().moduleId }
|
|
1380
|
+
]
|
|
1381
|
+
},
|
|
1382
|
+
toastSuccess: false,
|
|
1383
|
+
toastError: false
|
|
1384
|
+
}).then((response) => {
|
|
1385
|
+
set((state) => {
|
|
1386
|
+
state.cookies.moduleCookies = getCookiesContainer(
|
|
1387
|
+
response.data,
|
|
1388
|
+
state.moduleId
|
|
1389
|
+
);
|
|
1390
|
+
state.cookies.windowCookies = getCookiesContainer(
|
|
1391
|
+
response.data,
|
|
1392
|
+
state.windowId
|
|
1393
|
+
);
|
|
1394
|
+
state.status = "loaded";
|
|
1395
|
+
});
|
|
1396
|
+
}).catch((_response) => {
|
|
1397
|
+
set((state) => {
|
|
1398
|
+
state.status = "loaded";
|
|
1399
|
+
});
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
saveModuleCookies: () => {
|
|
1404
|
+
for (const key in get().cookies.windowCookies) {
|
|
1405
|
+
const cookie = get().cookies.windowCookies[key];
|
|
1406
|
+
get().networkOperation({
|
|
1407
|
+
method: "PUT",
|
|
1408
|
+
endPoint: `cookies/${get().moduleId}/${key}`,
|
|
1409
|
+
data: {
|
|
1410
|
+
value: JSON.stringify(cookie)
|
|
1411
|
+
},
|
|
1412
|
+
toastSuccess: false,
|
|
1413
|
+
toastError: false
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
})),
|
|
1419
|
+
{
|
|
1420
|
+
name: `window store ${initProps.windowId}`,
|
|
1421
|
+
store: `window dev store ${initProps.windowId}`,
|
|
1422
|
+
trace: true
|
|
1423
|
+
}
|
|
1424
|
+
)
|
|
1425
|
+
);
|
|
1426
|
+
};
|
|
1427
|
+
const WindowContext = createContext(null);
|
|
1428
|
+
function WindowMFProvider(props) {
|
|
1429
|
+
const {
|
|
1430
|
+
children,
|
|
1431
|
+
...other
|
|
1432
|
+
} = props;
|
|
1433
|
+
const {
|
|
1434
|
+
networkOperation
|
|
1435
|
+
} = useNetwork();
|
|
1436
|
+
const windowStoreRef = useRef();
|
|
1437
|
+
const dynamicMFStoreRef = useRef();
|
|
1438
|
+
const areaStore = useArea();
|
|
1439
|
+
const areasStore = useAreas();
|
|
1440
|
+
if (!dynamicMFStoreRef.current) {
|
|
1441
|
+
dynamicMFStoreRef.current = createDynamicMFStore({
|
|
1442
|
+
dynamicMFParameters: props.dynamicParams,
|
|
1443
|
+
windowId: props.windowId
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
if (!windowStoreRef.current) {
|
|
1447
|
+
windowStoreRef.current = createWindowStore({
|
|
1448
|
+
...other,
|
|
1449
|
+
dynamicMFStore: dynamicMFStoreRef.current,
|
|
1450
|
+
networkOperation,
|
|
1451
|
+
areaStore,
|
|
1452
|
+
areasStore
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
useEffect(() => {
|
|
1456
|
+
windowStoreRef.current?.getState().internalActions.loadCookiesFromApi();
|
|
1457
|
+
return () => {
|
|
1458
|
+
console.debug("useEffect cleanUP WindowMFProvider", props.windowId, windowStoreRef.current);
|
|
1459
|
+
};
|
|
1460
|
+
}, []);
|
|
1461
|
+
useEffect(() => {
|
|
1462
|
+
if (windowStoreRef.current?.getState().status === "loaded") {
|
|
1463
|
+
dynamicMFStoreRef.current?.getState().actions.changeData(props.dynamicParams);
|
|
1464
|
+
}
|
|
1465
|
+
}, [props.dynamicParams]);
|
|
1466
|
+
return /* @__PURE__ */ jsx(WindowContext.Provider, {
|
|
1467
|
+
value: windowStoreRef.current,
|
|
1468
|
+
children
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
const useWindow = () => {
|
|
1472
|
+
const context = useContext(WindowContext);
|
|
1473
|
+
if (!context)
|
|
1474
|
+
throw new Error("useWindow context must be use inside WindowContext");
|
|
1475
|
+
return context;
|
|
1476
|
+
};
|
|
1477
|
+
function useWindowStore(selector, equalityFn) {
|
|
1478
|
+
const store = useContext(WindowContext);
|
|
1479
|
+
if (!store)
|
|
1480
|
+
throw new Error("useWindow context must be use inside WindowContext");
|
|
1481
|
+
return useStore(store, selector, equalityFn);
|
|
1482
|
+
}
|
|
1483
|
+
const Component = (props) => {
|
|
1484
|
+
const {
|
|
1485
|
+
component
|
|
1486
|
+
} = props;
|
|
1487
|
+
const store = useWindow();
|
|
1488
|
+
const dynamicMFStore = useWindowStore((state) => state.dynamicMFStore);
|
|
1489
|
+
const actions = useWindowStore((state) => state.actions, shallow);
|
|
1490
|
+
return /* @__PURE__ */ jsx(WindowToolsMFProvider, {
|
|
1491
|
+
...actions,
|
|
1492
|
+
children: /* @__PURE__ */ jsx(DynamicMFParmsProvider, {
|
|
1493
|
+
store: dynamicMFStore,
|
|
1494
|
+
children: typeof component === "function" ? component(store) : component
|
|
1495
|
+
})
|
|
1496
|
+
});
|
|
1497
|
+
};
|
|
1498
|
+
React__default.memo(Component);
|
|
1499
|
+
styled("div")(({
|
|
1500
|
+
theme
|
|
1501
|
+
}) => ({
|
|
1502
|
+
display: "flex",
|
|
1503
|
+
alignItems: "center",
|
|
1504
|
+
position: "relative",
|
|
1505
|
+
justifyContent: "space-between",
|
|
1506
|
+
minHeight: theme.spacing(5),
|
|
1507
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
1508
|
+
overflow: "hidden",
|
|
1509
|
+
cursor: "move",
|
|
1510
|
+
height: "60px",
|
|
1511
|
+
" > span": {
|
|
1512
|
+
marginRight: "12px"
|
|
1513
|
+
},
|
|
1514
|
+
"& > h5": {
|
|
1515
|
+
paddingRight: theme.spacing(3),
|
|
1516
|
+
borderRight: `1px solid ${theme.palette.divider}`
|
|
1517
|
+
},
|
|
1518
|
+
" > nav": {
|
|
1519
|
+
marginRight: "12px",
|
|
1520
|
+
flexGrow: 1
|
|
1521
|
+
},
|
|
1522
|
+
"& .splitactions.Mui-disabled": {
|
|
1523
|
+
color: theme.palette.primary.main
|
|
1524
|
+
},
|
|
1525
|
+
"& svg ": {
|
|
1526
|
+
width: "20px",
|
|
1527
|
+
height: "20px"
|
|
1528
|
+
}
|
|
1529
|
+
}));
|
|
1530
|
+
styled("div")(({
|
|
1531
|
+
theme
|
|
1532
|
+
}) => ({
|
|
1533
|
+
display: "flex",
|
|
1534
|
+
alignItems: "center",
|
|
1535
|
+
position: "relative",
|
|
1536
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
1537
|
+
height: "60px",
|
|
1538
|
+
minHeight: "60px",
|
|
1539
|
+
" > span": {
|
|
1540
|
+
marginRight: "12px"
|
|
1541
|
+
},
|
|
1542
|
+
"& > h5": {
|
|
1543
|
+
paddingRight: theme.spacing(3),
|
|
1544
|
+
borderRight: `1px solid ${theme.palette.divider}`
|
|
1545
|
+
},
|
|
1546
|
+
" > nav": {
|
|
1547
|
+
marginRight: "12px",
|
|
1548
|
+
flexGrow: 1
|
|
1549
|
+
},
|
|
1550
|
+
"& .splitactions.Mui-disabled": {
|
|
1551
|
+
color: theme.palette.primary.main
|
|
1552
|
+
},
|
|
1553
|
+
"& svg ": {
|
|
1554
|
+
width: "20px",
|
|
1555
|
+
height: "20px"
|
|
1556
|
+
}
|
|
1557
|
+
}));
|
|
1558
|
+
const Wrapper = styled("div")(({
|
|
1559
|
+
theme
|
|
1560
|
+
}) => ({
|
|
1561
|
+
display: "flex",
|
|
1562
|
+
justifyContent: "space-between",
|
|
1563
|
+
padding: `0 0`,
|
|
1564
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
1565
|
+
minHeight: "60px"
|
|
1566
|
+
}));
|
|
1567
|
+
const ModuleTitleContent = styled("div")(({
|
|
1568
|
+
theme
|
|
1569
|
+
}) => ({
|
|
1570
|
+
display: "grid",
|
|
1571
|
+
gridTemplateColumns: "auto",
|
|
1572
|
+
gridGap: theme.spacing(1.75),
|
|
1573
|
+
alignItems: "center",
|
|
1574
|
+
width: "auto",
|
|
1575
|
+
height: "auto",
|
|
1576
|
+
[theme.breakpoints.up("sm")]: {
|
|
1577
|
+
gridTemplateColumns: "repeat(3, auto)"
|
|
1578
|
+
}
|
|
1579
|
+
}));
|
|
1580
|
+
const ModuleTitle = styled("div")(({
|
|
1581
|
+
theme
|
|
1582
|
+
}) => ({
|
|
1583
|
+
display: "grid",
|
|
1584
|
+
gridTemplateColumns: `${theme.spacing(3)} auto`,
|
|
1585
|
+
gridGap: theme.spacing(2),
|
|
1586
|
+
alignItems: "center",
|
|
1587
|
+
width: "auto",
|
|
1588
|
+
height: "auto"
|
|
1589
|
+
}));
|
|
1590
|
+
const Separator = styled("div")(({
|
|
1591
|
+
theme
|
|
1592
|
+
}) => ({
|
|
1593
|
+
display: "none",
|
|
1594
|
+
alignItems: "center",
|
|
1595
|
+
width: "1px",
|
|
1596
|
+
background: theme.palette.divider,
|
|
1597
|
+
height: "100%",
|
|
1598
|
+
margin: `0 ${theme.spacing(2)}`,
|
|
1599
|
+
[theme.breakpoints.up("sm")]: {
|
|
1600
|
+
display: "flex"
|
|
1601
|
+
}
|
|
1602
|
+
}));
|
|
1603
|
+
const Breadcrumbs = styled("div")(({
|
|
1604
|
+
theme
|
|
1605
|
+
}) => ({
|
|
1606
|
+
display: "grid",
|
|
1607
|
+
alignItems: "center",
|
|
1608
|
+
gridTemplateColumns: `repeat(3, auto)`,
|
|
1609
|
+
gridGap: theme.spacing(2)
|
|
1610
|
+
}));
|
|
1611
|
+
const ModuleActions = styled("div")(({
|
|
1612
|
+
theme
|
|
1613
|
+
}) => ({
|
|
1614
|
+
display: "grid",
|
|
1615
|
+
gridTemplateColumns: "auto",
|
|
1616
|
+
alignItems: "center",
|
|
1617
|
+
width: "auto",
|
|
1618
|
+
height: "auto",
|
|
1619
|
+
[theme.breakpoints.up("sm")]: {
|
|
1620
|
+
gridTemplateColumns: `repeat(3, ${theme.spacing(3)})`,
|
|
1621
|
+
gridGap: theme.spacing(2)
|
|
1622
|
+
}
|
|
1623
|
+
}));
|
|
1624
|
+
function SKTModuleHeader() {
|
|
1625
|
+
const isDesktop = useResponsiveDesktop();
|
|
1626
|
+
return /* @__PURE__ */ jsxs(Wrapper, {
|
|
1627
|
+
id: "HeaderSkeleton",
|
|
1628
|
+
children: [/* @__PURE__ */ jsxs(ModuleTitleContent, {
|
|
1629
|
+
children: [/* @__PURE__ */ jsxs(ModuleTitle, {
|
|
1630
|
+
children: [/* @__PURE__ */ jsx(Skeleton, {
|
|
1631
|
+
variant: "circular",
|
|
1632
|
+
width: 24,
|
|
1633
|
+
height: 24
|
|
1634
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
1635
|
+
variant: "text",
|
|
1636
|
+
width: 120,
|
|
1637
|
+
height: 14
|
|
1638
|
+
})]
|
|
1639
|
+
}), /* @__PURE__ */ jsx(Separator, {}), /* @__PURE__ */ jsxs(Breadcrumbs, {
|
|
1640
|
+
children: [/* @__PURE__ */ jsx(Skeleton, {
|
|
1641
|
+
variant: "text",
|
|
1642
|
+
width: 68,
|
|
1643
|
+
height: 14
|
|
1644
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
1645
|
+
variant: "circular",
|
|
1646
|
+
width: 4,
|
|
1647
|
+
height: 4
|
|
1648
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
1649
|
+
variant: "text",
|
|
1650
|
+
width: 68,
|
|
1651
|
+
height: 14
|
|
1652
|
+
})]
|
|
1653
|
+
})]
|
|
1654
|
+
}), /* @__PURE__ */ jsx(ModuleActions, {
|
|
1655
|
+
children: isDesktop ? /* @__PURE__ */ jsxs(Fragment, {
|
|
1656
|
+
children: [/* @__PURE__ */ jsx(Skeleton, {
|
|
1657
|
+
variant: "circular",
|
|
1658
|
+
width: 24,
|
|
1659
|
+
height: 24
|
|
1660
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
1661
|
+
variant: "circular",
|
|
1662
|
+
width: 24,
|
|
1663
|
+
height: 24
|
|
1664
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
1665
|
+
variant: "circular",
|
|
1666
|
+
width: 24,
|
|
1667
|
+
height: 24
|
|
1668
|
+
})]
|
|
1669
|
+
}) : /* @__PURE__ */ jsx(Skeleton, {
|
|
1670
|
+
variant: "circular",
|
|
1671
|
+
width: 24,
|
|
1672
|
+
height: 24
|
|
1673
|
+
})
|
|
1674
|
+
})]
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
function getMainActions(isDesktop, moduleActions) {
|
|
1678
|
+
let mainActions = [];
|
|
1679
|
+
if (isDesktop !== void 0 && isDesktop) {
|
|
1680
|
+
mainActions = mainActions.concat(
|
|
1681
|
+
moduleActions.filter((action) => action.visibility === "main")
|
|
1682
|
+
);
|
|
1683
|
+
}
|
|
1684
|
+
mainActions = mainActions.concat(
|
|
1685
|
+
moduleActions.filter((action) => action.visibility === "allways")
|
|
1686
|
+
);
|
|
1687
|
+
return mainActions;
|
|
1688
|
+
}
|
|
1689
|
+
function getMenuActions(isDesktop, moduleActions, urlPrefix, saveModuleCookies, version) {
|
|
1690
|
+
let menuActions = [...moduleActions.filter((action) => action.visibility !== "allways")];
|
|
1691
|
+
if (isDesktop !== void 0 && isDesktop) {
|
|
1692
|
+
menuActions = menuActions.filter((action) => action.visibility === "normal");
|
|
1693
|
+
}
|
|
1694
|
+
console.log("getMenuActions", version);
|
|
1695
|
+
const savePropsAction = {
|
|
1696
|
+
urlIcon: `${urlPrefix}/frontend/components/areas/assets/icons/split_vertical.svg`,
|
|
1697
|
+
onClick: () => saveModuleCookies,
|
|
1698
|
+
disabled: false,
|
|
1699
|
+
visibility: "normal",
|
|
1700
|
+
dictionaryId: getAreasDictionary("label_persist_module_cookies"),
|
|
1701
|
+
key: "save_props"
|
|
1702
|
+
};
|
|
1703
|
+
menuActions.push(savePropsAction);
|
|
1704
|
+
if (version) {
|
|
1705
|
+
const versionAction = {
|
|
1706
|
+
urlIcon: `${urlPrefix}/frontend/components/areas/assets/icons/version.svg`,
|
|
1707
|
+
onClick: () => {
|
|
1708
|
+
},
|
|
1709
|
+
disabled: true,
|
|
1710
|
+
visibility: "normal",
|
|
1711
|
+
label: version,
|
|
1712
|
+
key: "version"
|
|
1713
|
+
};
|
|
1714
|
+
menuActions.push(versionAction);
|
|
1715
|
+
}
|
|
1716
|
+
return menuActions;
|
|
1717
|
+
}
|
|
1718
|
+
function MainActions() {
|
|
1719
|
+
const [moduleActions] = useWindowStore((state) => [state.moduleActions], shallow);
|
|
1720
|
+
const {
|
|
1721
|
+
getLabel
|
|
1722
|
+
} = useModuleDictionary();
|
|
1723
|
+
const isDesktop = useResponsiveDesktop();
|
|
1724
|
+
const mainActions = useMemo(() => {
|
|
1725
|
+
return getMainActions(isDesktop, moduleActions);
|
|
1726
|
+
}, [moduleActions, isDesktop]);
|
|
1727
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1728
|
+
className: areasViewerClasses.windowHeaderMainActions,
|
|
1729
|
+
children: mainActions.map((mainAction) => {
|
|
1730
|
+
const tooltip = mainAction.label !== void 0 ? mainAction.label : getLabel(mainAction.dictionaryId || "");
|
|
1731
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
1732
|
+
src: mainAction.urlIcon,
|
|
1733
|
+
className: mainAction.className,
|
|
1734
|
+
onClick: mainAction.onClick,
|
|
1735
|
+
"aria-label": mainAction.label,
|
|
1736
|
+
disabled: mainAction.disabled,
|
|
1737
|
+
tooltip
|
|
1738
|
+
}, mainAction.key);
|
|
1739
|
+
})
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
function Header() {
|
|
1743
|
+
const [url_icon, title, moduleActions, onClose, container_id, version] = useWindowStore((state) => [state.url_icon, state.title, state.moduleActions, state.onClose, state.windowId, state.version], shallow);
|
|
1744
|
+
const {
|
|
1745
|
+
saveModuleCookies
|
|
1746
|
+
} = useWindowStore((state) => state.internalActions);
|
|
1747
|
+
const emergeType = useWindowStore((state) => state.emergeType);
|
|
1748
|
+
const maximizedId = useAreaStore((state) => state.singleId);
|
|
1749
|
+
const {
|
|
1750
|
+
maximizeLayout,
|
|
1751
|
+
normalizeLayouts
|
|
1752
|
+
} = useAreaStore((state) => state.actions, shallow);
|
|
1753
|
+
const {
|
|
1754
|
+
host_static_assets,
|
|
1755
|
+
environment_assets
|
|
1756
|
+
} = useEnvironment();
|
|
1757
|
+
const isDesktop = useResponsiveDesktop();
|
|
1758
|
+
const isSkeleton = useModuleSkeleton();
|
|
1759
|
+
const urlPrefix = `${host_static_assets}/${environment_assets}`;
|
|
1760
|
+
const menuActions = useMemo(() => {
|
|
1761
|
+
return getMenuActions(isDesktop, moduleActions, urlPrefix, saveModuleCookies, version);
|
|
1762
|
+
}, [moduleActions, isDesktop]);
|
|
1763
|
+
const onCloseLocal = () => {
|
|
1764
|
+
onClose && onClose(container_id);
|
|
1765
|
+
};
|
|
1766
|
+
const maxNormalize = () => {
|
|
1767
|
+
if (maximizedId) {
|
|
1768
|
+
normalizeLayouts();
|
|
1769
|
+
} else {
|
|
1770
|
+
maximizeLayout(container_id);
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
if (isSkeleton) {
|
|
1774
|
+
return /* @__PURE__ */ jsx(SKTModuleHeader, {});
|
|
1775
|
+
}
|
|
1776
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1777
|
+
className: clsx(areasViewerClasses.windowHeader, "m4l_draggable_handle"),
|
|
1778
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1779
|
+
src: url_icon,
|
|
1780
|
+
size: "medium"
|
|
1781
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
1782
|
+
className: areasViewerClasses.windowHeaderTitle,
|
|
1783
|
+
variant: "h5",
|
|
1784
|
+
children: `${title}`
|
|
1785
|
+
}), /* @__PURE__ */ jsx(MainActions, {}), isDesktop && emergeType === "layout" && /* @__PURE__ */ jsx(IconButton, {
|
|
1786
|
+
onClick: maxNormalize,
|
|
1787
|
+
"aria-label": "click",
|
|
1788
|
+
src: 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}`
|
|
1789
|
+
}), menuActions.length > 0 && /* @__PURE__ */ jsx(MenuActions, {
|
|
1790
|
+
arrowType: "no-arrow",
|
|
1791
|
+
marginTop: "12px!important",
|
|
1792
|
+
marginLeft: "14px!important",
|
|
1793
|
+
anchorOrigin: {
|
|
1794
|
+
vertical: "bottom",
|
|
1795
|
+
horizontal: "right"
|
|
1796
|
+
},
|
|
1797
|
+
transformOrigin: {
|
|
1798
|
+
vertical: "top",
|
|
1799
|
+
horizontal: "right"
|
|
1800
|
+
},
|
|
1801
|
+
menuActions
|
|
1802
|
+
}), onClose && /* @__PURE__ */ jsx(IconButton, {
|
|
1803
|
+
onClick: onCloseLocal,
|
|
1804
|
+
"aria-label": "click",
|
|
1805
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.CLOSE}`
|
|
1806
|
+
})]
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
const WrapperLinearProgress = styled$1("div")(() => ({
|
|
1810
|
+
width: "70%",
|
|
1811
|
+
margin: "auto auto"
|
|
1812
|
+
}));
|
|
1813
|
+
const WrapperFallBackNotFound = styled$1("div")(({
|
|
1814
|
+
theme
|
|
1815
|
+
}) => ({
|
|
1816
|
+
width: "100%",
|
|
1817
|
+
height: "100%",
|
|
1818
|
+
display: "flex",
|
|
1819
|
+
flexDirection: "column",
|
|
1820
|
+
justifyContent: "center",
|
|
1821
|
+
alignItems: "center",
|
|
1822
|
+
gap: theme.spacing(3)
|
|
1823
|
+
}));
|
|
1824
|
+
function FallBackNotFound(props) {
|
|
1825
|
+
const {
|
|
1826
|
+
setNetworkRefresh
|
|
1827
|
+
} = props;
|
|
1828
|
+
const {
|
|
1829
|
+
getLabel
|
|
1830
|
+
} = useModuleDictionary();
|
|
1831
|
+
const {
|
|
1832
|
+
host_static_assets,
|
|
1833
|
+
environment_assets
|
|
1834
|
+
} = useEnvironment();
|
|
1835
|
+
const handlerClick = () => {
|
|
1836
|
+
setNetworkRefresh((prop) => !prop);
|
|
1837
|
+
};
|
|
1838
|
+
return /* @__PURE__ */ jsxs(WrapperFallBackNotFound, {
|
|
1839
|
+
children: [/* @__PURE__ */ jsx(m.div, {
|
|
1840
|
+
variants: varBounce().in,
|
|
1841
|
+
children: /* @__PURE__ */ jsx(Typography$1, {
|
|
1842
|
+
variant: "h3",
|
|
1843
|
+
paragraph: true,
|
|
1844
|
+
children: getLabel("loading_mf_title")
|
|
1845
|
+
})
|
|
1846
|
+
}), /* @__PURE__ */ jsx(Typography$1, {
|
|
1847
|
+
sx: {
|
|
1848
|
+
color: "text.secondary"
|
|
1849
|
+
},
|
|
1850
|
+
children: getLabel("loading_mf_description")
|
|
1851
|
+
}), /* @__PURE__ */ jsx(m.div, {
|
|
1852
|
+
variants: varBounce().in,
|
|
1853
|
+
children: /* @__PURE__ */ jsx(Image, {
|
|
1854
|
+
src: `${host_static_assets}/${environment_assets}/frontend/domain/host/commons/assets/img/illustration_noauth.png`,
|
|
1855
|
+
ratio: "1:1"
|
|
1856
|
+
})
|
|
1857
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1858
|
+
size: "medium",
|
|
1859
|
+
variant: "contained",
|
|
1860
|
+
onClick: handlerClick,
|
|
1861
|
+
children: getLabel("loading_mf_intro")
|
|
1862
|
+
})]
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
const LoadingMF = (props) => {
|
|
1866
|
+
const {
|
|
1867
|
+
loadingProgress,
|
|
1868
|
+
setNetworkRefresh
|
|
1869
|
+
} = props;
|
|
1870
|
+
if (loadingProgress !== -1) {
|
|
1871
|
+
return /* @__PURE__ */ jsx(WrapperLinearProgress, {
|
|
1872
|
+
id: "WrapperLinearProgress",
|
|
1873
|
+
children: /* @__PURE__ */ jsx(LinearProgress, {
|
|
1874
|
+
variant: "determinate",
|
|
1875
|
+
value: loadingProgress
|
|
1876
|
+
})
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
return /* @__PURE__ */ jsx(FallBackNotFound, {
|
|
1880
|
+
setNetworkRefresh
|
|
1881
|
+
});
|
|
1882
|
+
};
|
|
1883
|
+
function getDivScritId(prefix, moduleId) {
|
|
1884
|
+
const rotational_id = `${Math.round(new Date().getTime() / 1e3)}_rnd_${Math.round(Math.random() * 1e3)}`;
|
|
1885
|
+
return {
|
|
1886
|
+
divContainerId: `container_${prefix}_${moduleId}_${rotational_id}`,
|
|
1887
|
+
scriptId: `script_${moduleId}_${rotational_id}`,
|
|
1888
|
+
moduleId
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
function MFLoader(props) {
|
|
1892
|
+
const {
|
|
1893
|
+
prefix,
|
|
1894
|
+
moduleId,
|
|
1895
|
+
cache = true,
|
|
1896
|
+
debug_port,
|
|
1897
|
+
dynamicMFStore,
|
|
1898
|
+
windowTools
|
|
1899
|
+
} = props;
|
|
1900
|
+
const {
|
|
1901
|
+
hostThemeOptions,
|
|
1902
|
+
fnComponentsOverrides
|
|
1903
|
+
} = useHostTheme();
|
|
1904
|
+
const {
|
|
1905
|
+
networkOperation
|
|
1906
|
+
} = useNetwork();
|
|
1907
|
+
const environment = useEnvironment();
|
|
1908
|
+
const hostTools = useHostTools();
|
|
1909
|
+
const formatter = useFormatter();
|
|
1910
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
1911
|
+
const [networkProgress, setNetworkProgress] = useState(-1);
|
|
1912
|
+
const [_networkRefresh, setNetworkRefresh] = useState(false);
|
|
1913
|
+
const {
|
|
1914
|
+
currentLocale
|
|
1915
|
+
} = useLocales();
|
|
1916
|
+
const [divScript, setDivScript] = useState(getDivScritId(prefix, moduleId));
|
|
1917
|
+
const refTime = useRef(0);
|
|
1918
|
+
const isFirstRender = useFirstRender([moduleId]);
|
|
1919
|
+
const final_host = environment.isLocalhost ? `https://localhost:${debug_port}` : `https://${window.location.host}/mf/${moduleId}`;
|
|
1920
|
+
function cleanUp(dScript) {
|
|
1921
|
+
try {
|
|
1922
|
+
if (window[`unmount_${prefix}_${dScript.moduleId}`]) {
|
|
1923
|
+
window[`unmount_${prefix}_${dScript.moduleId}`](dScript.divContainerId);
|
|
1924
|
+
}
|
|
1925
|
+
} catch (error) {
|
|
1926
|
+
}
|
|
1927
|
+
if (!cache) {
|
|
1928
|
+
const script = document.getElementById(dScript.scriptId);
|
|
1929
|
+
if (script) {
|
|
1930
|
+
try {
|
|
1931
|
+
document.head.removeChild(script);
|
|
1932
|
+
delete window[`render_${prefix}_${dScript.moduleId}`];
|
|
1933
|
+
delete window[`unmount_${prefix}_${dScript.moduleId}`];
|
|
1934
|
+
} catch (error) {
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
const renderMicroFrontend = useCallback((newDScript) => {
|
|
1940
|
+
try {
|
|
1941
|
+
setIsLoading(false);
|
|
1942
|
+
window[`render_${prefix}_${newDScript.moduleId}`](newDScript.divContainerId, environment, hostTools, currentLocale, {
|
|
1943
|
+
hostThemeOptions,
|
|
1944
|
+
fnComponentsOverrides
|
|
1945
|
+
}, axiosOperation, formatter, dynamicMFStore, windowTools);
|
|
1946
|
+
} catch (error) {
|
|
1947
|
+
}
|
|
1948
|
+
}, [hostThemeOptions, currentLocale, formatter]);
|
|
1949
|
+
const debouncedSetDivScript = useCallback(debounce((newName) => {
|
|
1950
|
+
const newDivScript = getDivScritId(prefix, newName);
|
|
1951
|
+
if (newName !== divScript.moduleId) {
|
|
1952
|
+
setDivScript({
|
|
1953
|
+
...newDivScript
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
}, 200), [divScript]);
|
|
1957
|
+
useEffect(() => {
|
|
1958
|
+
if (!isFirstRender) {
|
|
1959
|
+
debouncedSetDivScript(moduleId + "");
|
|
1960
|
+
if (moduleId !== divScript.moduleId)
|
|
1961
|
+
;
|
|
1962
|
+
}
|
|
1963
|
+
return () => {
|
|
1964
|
+
};
|
|
1965
|
+
}, [moduleId]);
|
|
1966
|
+
useEffect(() => {
|
|
1967
|
+
setIsLoading(true);
|
|
1968
|
+
let mounted = true;
|
|
1969
|
+
const controller = new AbortController();
|
|
1970
|
+
const dsScript = {
|
|
1971
|
+
...divScript
|
|
1972
|
+
};
|
|
1973
|
+
const loadIfNotLoaded = async () => {
|
|
1974
|
+
if (!window[`render_${prefix}_${moduleId}`]) {
|
|
1975
|
+
let urlFile = "";
|
|
1976
|
+
setNetworkProgress(0);
|
|
1977
|
+
const manifest = await fetch(`${final_host}/manifest.json?rnd=${Math.random()}`).then((res) => res.json()).catch(() => {
|
|
1978
|
+
console.debug("Error fetching manifest", `${final_host}/manifest.json`);
|
|
1979
|
+
return void 0;
|
|
1980
|
+
});
|
|
1981
|
+
if (!manifest) {
|
|
1982
|
+
return;
|
|
1983
|
+
}
|
|
1984
|
+
setNetworkProgress(10);
|
|
1985
|
+
if (mounted) {
|
|
1986
|
+
urlFile = `${final_host}/${manifest["src/index.tsx"]["file"]}?rnd=${Math.random()}`;
|
|
1987
|
+
refTime.current = 0;
|
|
1988
|
+
await networkOperation({
|
|
1989
|
+
method: "GET",
|
|
1990
|
+
endPoint: urlFile,
|
|
1991
|
+
isRemote: !environment.isLocalhost,
|
|
1992
|
+
headers: {
|
|
1993
|
+
"Content-Type": "application/json"
|
|
1994
|
+
},
|
|
1995
|
+
onDownloadProgress: (progressEvent) => {
|
|
1996
|
+
let percentCompleted = 0;
|
|
1997
|
+
try {
|
|
1998
|
+
if (progressEvent.lengthComputable) {
|
|
1999
|
+
percentCompleted = 10 + Math.round(progressEvent.loaded * 90 / progressEvent.total);
|
|
2000
|
+
} else {
|
|
2001
|
+
if (refTime.current === 0) {
|
|
2002
|
+
refTime.current = new Date().getTime();
|
|
2003
|
+
}
|
|
2004
|
+
percentCompleted = 10 + progressEvent.loaded / 15e5 * 90;
|
|
2005
|
+
if (percentCompleted > 95)
|
|
2006
|
+
percentCompleted = 95;
|
|
2007
|
+
}
|
|
2008
|
+
} catch (error) {
|
|
2009
|
+
}
|
|
2010
|
+
if (mounted) {
|
|
2011
|
+
setNetworkProgress(percentCompleted);
|
|
2012
|
+
}
|
|
2013
|
+
},
|
|
2014
|
+
isExternalUrl: true,
|
|
2015
|
+
responseType: "text",
|
|
2016
|
+
signal: controller.signal
|
|
2017
|
+
}).then(() => {
|
|
2018
|
+
if (mounted) {
|
|
2019
|
+
setNetworkProgress(100);
|
|
2020
|
+
}
|
|
2021
|
+
}).catch(() => {
|
|
2022
|
+
});
|
|
2023
|
+
if (mounted) {
|
|
2024
|
+
const script = document.createElement("script");
|
|
2025
|
+
script.id = divScript.scriptId;
|
|
2026
|
+
script.crossOrigin = "";
|
|
2027
|
+
script.type = "module";
|
|
2028
|
+
script.src = urlFile || "";
|
|
2029
|
+
script.onload = () => {
|
|
2030
|
+
if (mounted) {
|
|
2031
|
+
console.debug("Script loaded", new Date().getTime());
|
|
2032
|
+
setNetworkProgress(100);
|
|
2033
|
+
renderMicroFrontend(dsScript);
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
document.head.appendChild(script);
|
|
2037
|
+
console.debug("Script appened", new Date().getTime());
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
} else {
|
|
2041
|
+
if (mounted) {
|
|
2042
|
+
renderMicroFrontend(dsScript);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
loadIfNotLoaded();
|
|
2047
|
+
return () => {
|
|
2048
|
+
mounted = false;
|
|
2049
|
+
controller.abort();
|
|
2050
|
+
cleanUp(dsScript);
|
|
2051
|
+
};
|
|
2052
|
+
}, [divScript]);
|
|
2053
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2054
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2055
|
+
id: divScript.divContainerId
|
|
2056
|
+
}), isLoading ? /* @__PURE__ */ jsx(LoadingMF, {
|
|
2057
|
+
loadingProgress: networkProgress,
|
|
2058
|
+
setNetworkRefresh
|
|
2059
|
+
}) : null]
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
MFLoader.defaultProps = {
|
|
2063
|
+
document,
|
|
2064
|
+
window
|
|
2065
|
+
};
|
|
2066
|
+
const MicroFrontend = (props) => {
|
|
2067
|
+
const dynamicMFStore = useWindowStore((state) => state.dynamicMFStore, shallow);
|
|
2068
|
+
const moduleId = useWindowStore((state) => state.moduleId, shallow);
|
|
2069
|
+
const actions = useWindowStore((state) => state.actions, shallow);
|
|
2070
|
+
return /* @__PURE__ */ jsx(MFLoader, {
|
|
2071
|
+
...props,
|
|
2072
|
+
moduleId,
|
|
2073
|
+
dynamicMFStore,
|
|
2074
|
+
windowTools: {
|
|
2075
|
+
...actions
|
|
2076
|
+
}
|
|
2077
|
+
});
|
|
2078
|
+
};
|
|
2079
|
+
React__default.memo(MicroFrontend);
|
|
2080
|
+
const InnerForHooks$1 = (props) => {
|
|
2081
|
+
const {
|
|
2082
|
+
winType
|
|
2083
|
+
} = props;
|
|
2084
|
+
const status = useWindowStore((state) => state.status);
|
|
2085
|
+
if (status !== "loaded") {
|
|
2086
|
+
return null;
|
|
2087
|
+
}
|
|
2088
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2089
|
+
children: [/* @__PURE__ */ jsx(Header, {}), /* @__PURE__ */ jsx("div", {
|
|
2090
|
+
className: areasViewerClasses.windowContent,
|
|
2091
|
+
children: winType === "microfrontend" ? /* @__PURE__ */ jsx(MicroFrontend, {
|
|
2092
|
+
...props.mfProps
|
|
2093
|
+
}) : /* @__PURE__ */ jsx(Component, {
|
|
2094
|
+
component: props.component
|
|
2095
|
+
})
|
|
2096
|
+
})]
|
|
2097
|
+
});
|
|
2098
|
+
};
|
|
2099
|
+
React__default.memo(InnerForHooks$1);
|
|
2100
|
+
const Window = (props) => {
|
|
2101
|
+
const {
|
|
2102
|
+
emergeType
|
|
2103
|
+
} = props;
|
|
2104
|
+
const selected = useAreaStore((state) => emergeType === "layout" ? state.currentLayoutId : state.currentPopUpId) === props.windowId;
|
|
2105
|
+
const {
|
|
2106
|
+
selectWindowPopUp,
|
|
2107
|
+
selectWindowLayout
|
|
2108
|
+
} = useAreaStore((state) => state.actions);
|
|
2109
|
+
const onTouch = () => {
|
|
2110
|
+
if (!selected) {
|
|
2111
|
+
if (emergeType === "popup") {
|
|
2112
|
+
selectWindowPopUp(props.windowId);
|
|
2113
|
+
} else if (emergeType === "layout") {
|
|
2114
|
+
selectWindowLayout(props.windowId);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
2118
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2119
|
+
role: "presentation",
|
|
2120
|
+
className: clsx(areasViewerClasses.windowRoot, selected ? areasViewerClasses.selected : null),
|
|
2121
|
+
onMouseDown: onTouch,
|
|
2122
|
+
children: /* @__PURE__ */ jsx(WindowMFProvider, {
|
|
2123
|
+
...props,
|
|
2124
|
+
children: /* @__PURE__ */ jsx(InnerForHooks$1, {
|
|
2125
|
+
...props
|
|
2126
|
+
})
|
|
2127
|
+
})
|
|
2128
|
+
});
|
|
2129
|
+
};
|
|
2130
|
+
const MemonizedWindow = React__default.memo(Window);
|
|
2131
|
+
const WindowPopUp = (props) => {
|
|
2132
|
+
const {
|
|
2133
|
+
windowProps,
|
|
2134
|
+
windowId
|
|
2135
|
+
} = props;
|
|
2136
|
+
const {
|
|
2137
|
+
selectWindowPopUp
|
|
2138
|
+
} = useAreaStore((store) => store.actions);
|
|
2139
|
+
const selectedPopUpId = useAreaStore((store) => store.currentPopUpId);
|
|
2140
|
+
const zIndex = useAreaStore((store) => store.hashWindowsPopups[props.windowId].zIndex);
|
|
2141
|
+
const isSelected = props.windowId === selectedPopUpId;
|
|
2142
|
+
const onTouch = () => {
|
|
2143
|
+
if (!isSelected) {
|
|
2144
|
+
selectWindowPopUp(props.windowId);
|
|
2145
|
+
}
|
|
2146
|
+
};
|
|
2147
|
+
return /* @__PURE__ */ jsx(DraggableWindow, {
|
|
2148
|
+
handle: ".m4l_draggable_handle",
|
|
2149
|
+
cancel: "",
|
|
2150
|
+
defaultPosition: windowProps,
|
|
2151
|
+
children: /* @__PURE__ */ jsx(ResizeableWindow, {
|
|
2152
|
+
className: clsx(areasViewerClasses.windowPopupRoot, `${areasViewerClasses.windowPopupRoot}-${windowId}`),
|
|
2153
|
+
width: windowProps.width,
|
|
2154
|
+
height: windowProps.height,
|
|
2155
|
+
style: {
|
|
2156
|
+
zIndex,
|
|
2157
|
+
position: "absolute"
|
|
2158
|
+
},
|
|
2159
|
+
onResizeStart: () => {
|
|
2160
|
+
onTouch();
|
|
2161
|
+
},
|
|
2162
|
+
children: /* @__PURE__ */ jsx(Window, {
|
|
2163
|
+
...props
|
|
2164
|
+
})
|
|
2165
|
+
})
|
|
2166
|
+
});
|
|
2167
|
+
};
|
|
2168
|
+
const MemonizedWindowPopUp = React__default.memo(WindowPopUp);
|
|
2169
|
+
styled("div")(({ theme }) => ({
|
|
2170
|
+
display: "flex",
|
|
2171
|
+
flexDirection: "column",
|
|
2172
|
+
height: "100%",
|
|
2173
|
+
overflow: "hidden",
|
|
2174
|
+
padding: theme.spacing(3)
|
|
2175
|
+
}));
|
|
2176
|
+
const WrapperWindowModal = styled(Dialog)(() => ({
|
|
2177
|
+
"& .MuiDialog-container": {},
|
|
2178
|
+
"&.m4l_selected": {
|
|
2179
|
+
borderTop: "1px solid green"
|
|
2180
|
+
}
|
|
2181
|
+
}));
|
|
2182
|
+
const WindowModal = (props) => {
|
|
2183
|
+
const {
|
|
2184
|
+
closeWindowModal
|
|
2185
|
+
} = useAreaStore((state) => state.actions);
|
|
2186
|
+
const isDesktop = useResponsiveDesktop();
|
|
2187
|
+
const onClose = () => {
|
|
2188
|
+
closeWindowModal();
|
|
2189
|
+
};
|
|
2190
|
+
const DragabblePaperComponent = (_props) => {
|
|
2191
|
+
return /* @__PURE__ */ jsx(cjs.exports, {
|
|
2192
|
+
handle: ".m4l_draggable_handle",
|
|
2193
|
+
bounds: "parent",
|
|
2194
|
+
children: /* @__PURE__ */ jsx(ResizeableWindow, {
|
|
2195
|
+
className: areasViewerClasses.windowModalRoot,
|
|
2196
|
+
width: props.width,
|
|
2197
|
+
height: props.height,
|
|
2198
|
+
children: /* @__PURE__ */ jsx(Window, {
|
|
2199
|
+
...props,
|
|
2200
|
+
onClose
|
|
2201
|
+
})
|
|
2202
|
+
})
|
|
2203
|
+
});
|
|
2204
|
+
};
|
|
2205
|
+
function PaperComponent(_props) {
|
|
2206
|
+
return /* @__PURE__ */ jsx(Window, {
|
|
2207
|
+
...props,
|
|
2208
|
+
onClose
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
return /* @__PURE__ */ jsx(WrapperWindowModal, {
|
|
2212
|
+
open: true,
|
|
2213
|
+
disablePortal: true,
|
|
2214
|
+
scroll: "paper",
|
|
2215
|
+
onKeyDown: (event) => {
|
|
2216
|
+
if (event.key === "Escape") {
|
|
2217
|
+
onClose();
|
|
2218
|
+
}
|
|
2219
|
+
},
|
|
2220
|
+
"aria-labelledby": "child-modal-title",
|
|
2221
|
+
"aria-describedby": "child-modal-description",
|
|
2222
|
+
PaperComponent: isDesktop ? DragabblePaperComponent : PaperComponent,
|
|
2223
|
+
maxWidth: false,
|
|
2224
|
+
fullWidth: !isDesktop,
|
|
2225
|
+
fullScreen: false,
|
|
2226
|
+
disableEnforceFocus: true
|
|
2227
|
+
});
|
|
2228
|
+
};
|
|
2229
|
+
const MemonizedWindowModal = React__default.memo(WindowModal);
|
|
2230
|
+
const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
2231
|
+
const GridLayout = () => {
|
|
2232
|
+
const gridLayouts = useAreaStore((state) => state.gridLayouts, shallow);
|
|
2233
|
+
const hashWindowsPopups = useAreaStore((state) => state.hashWindowsPopups, shallow);
|
|
2234
|
+
const hashWindowsLayouts = useAreaStore((state) => state.hashWindowsLayouts, shallow);
|
|
2235
|
+
const breakPointsLayouts = useAreaStore((state) => state.breakpointsLayouts, shallow);
|
|
2236
|
+
const windowsPopUps = useAreaStore((state) => state.windowsPopUps, shallow);
|
|
2237
|
+
const windowModal = useAreaStore((state) => state.windowModal, shallow);
|
|
2238
|
+
const breakpoints = useAreaStore((state) => state.breakpoints, shallow);
|
|
2239
|
+
const viewMode = useAreaStore((state) => state.viewMode, shallow);
|
|
2240
|
+
const cols = useAreaStore((state) => state.cols, shallow);
|
|
2241
|
+
const {
|
|
2242
|
+
onBreakpointsLayoutsChange
|
|
2243
|
+
} = useAreaStore((state) => state.actions);
|
|
2244
|
+
function onBreakpointChange(_newBreakpoint, _newCols) {
|
|
2245
|
+
}
|
|
2246
|
+
useEffect(() => {
|
|
2247
|
+
console.log("ResponsiveGridLayout resize");
|
|
2248
|
+
window.dispatchEvent(new Event("resize"));
|
|
2249
|
+
}, [viewMode, gridLayouts]);
|
|
2250
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2251
|
+
children: [/* @__PURE__ */ jsxs(ResponsiveGridLayout, {
|
|
2252
|
+
autoSize: false,
|
|
2253
|
+
compactType: "vertical",
|
|
2254
|
+
measureBeforeMount: true,
|
|
2255
|
+
resizeHandles: ["nw", "se"],
|
|
2256
|
+
className: areasViewerClasses.areaGridLayout,
|
|
2257
|
+
layouts: breakPointsLayouts,
|
|
2258
|
+
onLayoutChange: onBreakpointsLayoutsChange,
|
|
2259
|
+
onBreakpointChange,
|
|
2260
|
+
breakpoints,
|
|
2261
|
+
cols,
|
|
2262
|
+
rowHeight: ROW_HEIGTH_GRIDLAYOUT,
|
|
2263
|
+
margin: [5, 5],
|
|
2264
|
+
containerPadding: [CONTAINER_PADDING_GRIDLAYOUT, CONTAINER_PADDING_GRIDLAYOUT],
|
|
2265
|
+
draggableHandle: ".m4l_draggable_handle",
|
|
2266
|
+
isBounded: false,
|
|
2267
|
+
preventCollision: false,
|
|
2268
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2269
|
+
className: areasViewerClasses.areaGridLayoutPopupsContainer,
|
|
2270
|
+
"data-grid": {
|
|
2271
|
+
i: "none",
|
|
2272
|
+
x: 0,
|
|
2273
|
+
y: 0,
|
|
2274
|
+
w: 0,
|
|
2275
|
+
h: 0,
|
|
2276
|
+
maxW: 0,
|
|
2277
|
+
maxH: 0,
|
|
2278
|
+
minW: 0,
|
|
2279
|
+
minH: 0,
|
|
2280
|
+
static: true,
|
|
2281
|
+
isDraggable: false,
|
|
2282
|
+
isResizable: false
|
|
2283
|
+
},
|
|
2284
|
+
children: windowsPopUps.map((wp) => {
|
|
2285
|
+
if (hashWindowsPopups[wp]) {
|
|
2286
|
+
return /* @__PURE__ */ jsx(MemonizedWindowPopUp, {
|
|
2287
|
+
...hashWindowsPopups[wp]
|
|
2288
|
+
}, hashWindowsPopups[wp].windowId);
|
|
2289
|
+
}
|
|
2290
|
+
return null;
|
|
2291
|
+
})
|
|
2292
|
+
}, "none"), gridLayouts.map((l) => {
|
|
2293
|
+
if (hashWindowsLayouts[l.i]) {
|
|
2294
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2295
|
+
children: /* @__PURE__ */ jsx(MemonizedWindow, {
|
|
2296
|
+
...hashWindowsLayouts[l.i]
|
|
2297
|
+
})
|
|
2298
|
+
}, l.i);
|
|
2299
|
+
}
|
|
2300
|
+
return null;
|
|
2301
|
+
})]
|
|
2302
|
+
}), windowModal && /* @__PURE__ */ jsx(MemonizedWindowModal, {
|
|
2303
|
+
...windowModal
|
|
2304
|
+
})]
|
|
2305
|
+
});
|
|
2306
|
+
};
|
|
2307
|
+
const InnerForHooks = () => {
|
|
2308
|
+
const status = useAreaStore((state) => state.status);
|
|
2309
|
+
if (status === "loaded") {
|
|
2310
|
+
return /* @__PURE__ */ jsx(GridLayout, {});
|
|
2311
|
+
} else {
|
|
2312
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2313
|
+
children: "Loading.. Intentar si falla."
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
const PanelWindows = () => {
|
|
2318
|
+
const status = useAreaStore((state) => state.status);
|
|
2319
|
+
const mode = useAreaStore((state) => state.viewMode);
|
|
2320
|
+
const singleId = useAreaStore((state) => state.singleId);
|
|
2321
|
+
const gridLayouts = useAreaStore((state) => state.gridLayouts, shallow);
|
|
2322
|
+
const hashWindowsLayouts = useAreaStore((state) => state.hashWindowsLayouts, shallow);
|
|
2323
|
+
const {
|
|
2324
|
+
maximizeLayout
|
|
2325
|
+
} = useAreaStore((state) => state.actions);
|
|
2326
|
+
const onTouched = (layoutId) => {
|
|
2327
|
+
maximizeLayout(layoutId);
|
|
2328
|
+
};
|
|
2329
|
+
if (status === "loaded") {
|
|
2330
|
+
if (mode !== "single" || gridLayouts.length < 2) {
|
|
2331
|
+
return null;
|
|
2332
|
+
}
|
|
2333
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2334
|
+
className: areasViewerClasses.panelWindowsRoot,
|
|
2335
|
+
children: gridLayouts.map((l) => {
|
|
2336
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2337
|
+
className: clsx(areasViewerClasses.panelWindowsButtonContainer, singleId === l.i ? areasViewerClasses.selected : null),
|
|
2338
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
2339
|
+
src: hashWindowsLayouts[l.i].url_icon,
|
|
2340
|
+
size: "small",
|
|
2341
|
+
onClick: () => onTouched(l.i)
|
|
2342
|
+
})
|
|
2343
|
+
}, l.i);
|
|
2344
|
+
})
|
|
2345
|
+
});
|
|
2346
|
+
} else {
|
|
2347
|
+
return null;
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
const Area = (props) => {
|
|
2351
|
+
const {
|
|
2352
|
+
selected
|
|
2353
|
+
} = props;
|
|
2354
|
+
const classesAreaRoot = useAreasStore((state) => state.viwerClasses.areaRoot);
|
|
2355
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2356
|
+
className: clsx(classesAreaRoot, selected ? areasViewerClasses.selected : null),
|
|
2357
|
+
children: /* @__PURE__ */ jsx(AreaProvider, {
|
|
2358
|
+
...props,
|
|
2359
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2360
|
+
className: clsx(areasViewerClasses.areaGridLayoutPanelContainer, `${areasViewerClasses.areaGridLayoutPanelContainer}-${props.id}`),
|
|
2361
|
+
children: [/* @__PURE__ */ jsx(InnerForHooks, {}), /* @__PURE__ */ jsx(PanelWindows, {})]
|
|
2362
|
+
})
|
|
2363
|
+
})
|
|
2364
|
+
});
|
|
2365
|
+
};
|
|
2366
|
+
Area.displayName = "Area";
|
|
2367
|
+
function AreasViewer() {
|
|
2368
|
+
const areas = useAreasStore((state) => state.areas);
|
|
2369
|
+
const currentArea = useAreasStore((state) => state.currentArea);
|
|
2370
|
+
const status = useAreasStore((state) => state.ownerState.status);
|
|
2371
|
+
const classesRoot = useAreasStore((state) => state.viwerClasses.root);
|
|
2372
|
+
return /* @__PURE__ */ jsx(AreasViewerRoot, {
|
|
2373
|
+
className: classesRoot,
|
|
2374
|
+
children: status === "loaded" ? areas.map((area) => {
|
|
2375
|
+
return /* @__PURE__ */ jsx(Area, {
|
|
2376
|
+
id: area.id,
|
|
2377
|
+
selected: currentArea === area.id,
|
|
2378
|
+
loadWindows: area.loadWindows
|
|
2379
|
+
}, area.id);
|
|
2380
|
+
}) : /* @__PURE__ */ jsx(Fragment, {
|
|
2381
|
+
children: "Bruce cargando"
|
|
2382
|
+
})
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2385
|
+
function useDynamicMFParametersStore(selector, equalityFn) {
|
|
2386
|
+
const store = useContext(DynamicMFParmsContext);
|
|
2387
|
+
if (!store)
|
|
2388
|
+
throw new Error(
|
|
2389
|
+
"useDynamicMFParametersStore context must be use inside DynamicMFParmsContext"
|
|
2390
|
+
);
|
|
2391
|
+
return useStore(store, selector, equalityFn);
|
|
2392
|
+
}
|
|
2393
|
+
const useWindowToolsMF = () => {
|
|
2394
|
+
const context = useContext(WindowToolsMFContext);
|
|
2395
|
+
if (!context)
|
|
2396
|
+
throw new Error("useWindowToolsMF context must be use inside WindowToolsMFContext");
|
|
2397
|
+
return context;
|
|
2398
|
+
};
|
|
2399
|
+
export {
|
|
2400
|
+
AreasAdmin as A,
|
|
2401
|
+
DICCTIONARY as D,
|
|
2402
|
+
LABEL_FILTER_BUTTON as L,
|
|
2403
|
+
MemonizedDynamicMFParmsProvider as M,
|
|
2404
|
+
WindowToolsMFProvider as W,
|
|
2405
|
+
AreasViewer as a,
|
|
2406
|
+
WindowToolsMFContext as b,
|
|
2407
|
+
AreasProvider as c,
|
|
2408
|
+
AreasContext as d,
|
|
2409
|
+
useDynamicMFParametersStore as e,
|
|
2410
|
+
AREAS_DICTIONARY_ID as f,
|
|
2411
|
+
getAreasComponentsDictionary as g,
|
|
2412
|
+
getAreasDictionary as h,
|
|
2413
|
+
DynamicMFParmsProvider as i,
|
|
2414
|
+
DynamicMFParmsContext as j,
|
|
2415
|
+
useWindowToolsMF as u
|
|
2416
|
+
};
|