@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
|
@@ -1,509 +0,0 @@
|
|
|
1
|
-
import React__default, { createContext, useRef, useEffect } from "react";
|
|
2
|
-
import { shallow } from "zustand/shallow";
|
|
3
|
-
import { useNetwork } from "@m4l/core";
|
|
4
|
-
import { createStore, useStore } from "zustand";
|
|
5
|
-
import { immer } from "zustand/middleware/immer";
|
|
6
|
-
import { devtools } from "zustand/middleware";
|
|
7
|
-
import debounce from "lodash/debounce";
|
|
8
|
-
import cloneDeep from "lodash.clonedeep";
|
|
9
|
-
import { u as useAreasStore } from "../../hooks/useArea/index.d6263051.js";
|
|
10
|
-
import { useResponsiveDesktop, useFirstRender } from "@m4l/graphics";
|
|
11
|
-
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
const ROW_HEIGTH_GRIDLAYOUT = 100;
|
|
13
|
-
const CONTAINER_PADDING_GRIDLAYOUT = 3;
|
|
14
|
-
const DEBOUCED_SAVE_TIME = 500;
|
|
15
|
-
const COOKIE_BREAKPOINT_LAYOUTS = "layoutPros";
|
|
16
|
-
const COOKIE_WINDOWS = "windows";
|
|
17
|
-
const NORMALIZED_BREAKPOINTS = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 };
|
|
18
|
-
const NORMALIZED_COLS = { lg: 24, md: 20, sm: 12, xs: 8, xxs: 2 };
|
|
19
|
-
const getParmsFromValue = (key, data) => {
|
|
20
|
-
try {
|
|
21
|
-
if (Array.isArray(data)) {
|
|
22
|
-
let ob = data.find((f) => f.id === key);
|
|
23
|
-
if (ob) {
|
|
24
|
-
ob = JSON.parse(ob.value);
|
|
25
|
-
}
|
|
26
|
-
return ob;
|
|
27
|
-
}
|
|
28
|
-
} catch (error) {
|
|
29
|
-
}
|
|
30
|
-
return void 0;
|
|
31
|
-
};
|
|
32
|
-
function setAddBreakPoints(state, newLayout) {
|
|
33
|
-
const layoutsBreakPoints = state.breakpointsLayouts;
|
|
34
|
-
const beforeMaximizebreakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
|
|
35
|
-
for (const key in layoutsBreakPoints) {
|
|
36
|
-
const layoutBreakpoint = layoutsBreakPoints[key];
|
|
37
|
-
layoutBreakpoint.push(newLayout);
|
|
38
|
-
}
|
|
39
|
-
if (state.viewMode === "single") {
|
|
40
|
-
for (const key in beforeMaximizebreakpointsLayouts) {
|
|
41
|
-
const beforeLayoutBreakpoint = beforeMaximizebreakpointsLayouts[key];
|
|
42
|
-
beforeLayoutBreakpoint.push(newLayout);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return layoutsBreakPoints;
|
|
46
|
-
}
|
|
47
|
-
function setBreakPointsMaximized(state, layoutId) {
|
|
48
|
-
const layoutsBreakPoints = state.breakpointsLayouts;
|
|
49
|
-
const container = document.getElementsByClassName(`M4L_Area_wrapper_${state.id}`)[0];
|
|
50
|
-
if (container) {
|
|
51
|
-
const clientHeight = container.clientHeight - 40;
|
|
52
|
-
for (const key in layoutsBreakPoints) {
|
|
53
|
-
const layoutBreakpoint = layoutsBreakPoints[key];
|
|
54
|
-
const cols = key in NORMALIZED_COLS ? NORMALIZED_COLS[key] : 1;
|
|
55
|
-
const heigth_by_rowheigth = clientHeight / (ROW_HEIGTH_GRIDLAYOUT + 2 * CONTAINER_PADDING_GRIDLAYOUT);
|
|
56
|
-
for (let index = 0; index < layoutBreakpoint.length; index++) {
|
|
57
|
-
const l = layoutBreakpoint[index];
|
|
58
|
-
if (l.i === layoutId) {
|
|
59
|
-
l.x = 0;
|
|
60
|
-
l.y = 0;
|
|
61
|
-
l.h = heigth_by_rowheigth;
|
|
62
|
-
l.w = key in NORMALIZED_COLS ? NORMALIZED_COLS[key] : 1;
|
|
63
|
-
l.minW = 0;
|
|
64
|
-
l.maxW = cols;
|
|
65
|
-
l.minH = 0;
|
|
66
|
-
l.maxH = heigth_by_rowheigth;
|
|
67
|
-
l.isResizable = false;
|
|
68
|
-
l.isDraggable = false;
|
|
69
|
-
} else {
|
|
70
|
-
l.x = 0;
|
|
71
|
-
l.y = 1;
|
|
72
|
-
l.h = 0;
|
|
73
|
-
l.w = 0;
|
|
74
|
-
l.minW = 0;
|
|
75
|
-
l.maxW = 0;
|
|
76
|
-
l.minH = 0;
|
|
77
|
-
l.maxH = 0;
|
|
78
|
-
}
|
|
79
|
-
l.isResizable = false;
|
|
80
|
-
l.isDraggable = false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return layoutsBreakPoints;
|
|
85
|
-
}
|
|
86
|
-
function getDataFromResponse(data, state) {
|
|
87
|
-
const newBreakPointsLayouts = getParmsFromValue(COOKIE_BREAKPOINT_LAYOUTS, data);
|
|
88
|
-
const windows = getParmsFromValue(COOKIE_WINDOWS, data);
|
|
89
|
-
const newGridLayouts = [];
|
|
90
|
-
const newHashWindowLayouts = {};
|
|
91
|
-
if (windows) {
|
|
92
|
-
for (const key in windows) {
|
|
93
|
-
const element = windows[key];
|
|
94
|
-
if (element && element["layoutProps"] && element["mfProps"] && element["emergeType"] === "layout" && element["winType"] === "microfrontend") {
|
|
95
|
-
element["layoutProps"].i = key;
|
|
96
|
-
newGridLayouts.push(element["layoutProps"]);
|
|
97
|
-
newHashWindowLayouts[key] = {
|
|
98
|
-
...element,
|
|
99
|
-
windowId: key,
|
|
100
|
-
emergeType: "layout",
|
|
101
|
-
onClose: state.actions.closeWindowLayout
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
newBreakPointsLayouts,
|
|
108
|
-
newGridLayouts,
|
|
109
|
-
newHashWindowLayouts
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const createAreaStore = (initProps) => {
|
|
113
|
-
const startProps = {
|
|
114
|
-
zPopUpIndex: 999,
|
|
115
|
-
status: "init",
|
|
116
|
-
breakpointsLayouts: {},
|
|
117
|
-
beforeMaximizebreakpointsLayouts: {},
|
|
118
|
-
gridLayouts: [],
|
|
119
|
-
windowModal: null,
|
|
120
|
-
windowsPopUps: [],
|
|
121
|
-
hashWindowsPopups: {},
|
|
122
|
-
hashWindowsLayouts: {},
|
|
123
|
-
currentLayoutId: "",
|
|
124
|
-
currentPopUpId: "",
|
|
125
|
-
viewMode: initProps.isDesktop ? "multiple" : "single",
|
|
126
|
-
breakpoints: NORMALIZED_BREAKPOINTS,
|
|
127
|
-
cols: NORMALIZED_COLS,
|
|
128
|
-
...initProps
|
|
129
|
-
};
|
|
130
|
-
return createStore(
|
|
131
|
-
devtools(
|
|
132
|
-
immer((set, get) => ({
|
|
133
|
-
...startProps,
|
|
134
|
-
actions: {
|
|
135
|
-
addWindow: (newWindow) => {
|
|
136
|
-
const windowId = `${get().id}_window_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
|
|
137
|
-
console.log("addWindow", newWindow.emergeType);
|
|
138
|
-
if (newWindow.emergeType === "layout") {
|
|
139
|
-
get().actions.addWindowLayout(windowId, newWindow);
|
|
140
|
-
} else if (newWindow.emergeType === "popup") {
|
|
141
|
-
get().actions.addWindowPopUp(windowId, newWindow);
|
|
142
|
-
} else if (newWindow.emergeType === "modal") {
|
|
143
|
-
get().actions.addWindowModal(windowId, newWindow);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
closeWindowModal: () => {
|
|
147
|
-
set((state) => {
|
|
148
|
-
state.windowModal = void 0;
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
addWindowModal: (container_id, newWindowModalProps) => {
|
|
152
|
-
set((state) => {
|
|
153
|
-
state.windowModal = { ...newWindowModalProps, windowId: container_id };
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
closeWindowPopUp: (removePopUpId) => {
|
|
157
|
-
set((state) => {
|
|
158
|
-
const removeIndex = state.windowsPopUps.findIndex(
|
|
159
|
-
(wpId) => wpId === removePopUpId
|
|
160
|
-
);
|
|
161
|
-
if (removeIndex > -1) {
|
|
162
|
-
state.windowsPopUps.splice(removeIndex, 1);
|
|
163
|
-
}
|
|
164
|
-
delete state.hashWindowsPopups[removePopUpId];
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
addWindowPopUp: (windowId, newWindowPopupProps) => {
|
|
168
|
-
let popUpId = windowId;
|
|
169
|
-
set((state) => {
|
|
170
|
-
if (newWindowPopupProps.replaceMeId) {
|
|
171
|
-
for (const key in state.hashWindowsPopups) {
|
|
172
|
-
const WindoPopUp = state.hashWindowsPopups[key];
|
|
173
|
-
if (WindoPopUp.replaceMeId === newWindowPopupProps.replaceMeId) {
|
|
174
|
-
popUpId = key;
|
|
175
|
-
state.hashWindowsPopups[key].dynamicParams = newWindowPopupProps.dynamicParams;
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (popUpId === windowId) {
|
|
181
|
-
state.windowsPopUps.push(windowId);
|
|
182
|
-
state.hashWindowsPopups[windowId] = {
|
|
183
|
-
...newWindowPopupProps,
|
|
184
|
-
emergeType: "popup",
|
|
185
|
-
windowId,
|
|
186
|
-
onClose: get().actions.closeWindowPopUp,
|
|
187
|
-
zIndex: state.zPopUpIndex
|
|
188
|
-
};
|
|
189
|
-
state.currentPopUpId = windowId;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
get().actions.selectWindowPopUp(popUpId);
|
|
193
|
-
},
|
|
194
|
-
closeWindowLayout: (removeLayoutId) => {
|
|
195
|
-
set((state) => {
|
|
196
|
-
const removeIndex = state.gridLayouts.findIndex(
|
|
197
|
-
(gl) => gl.i === removeLayoutId
|
|
198
|
-
);
|
|
199
|
-
if (removeIndex > -1) {
|
|
200
|
-
state.gridLayouts.splice(removeIndex, 1);
|
|
201
|
-
}
|
|
202
|
-
delete state.hashWindowsLayouts[removeLayoutId];
|
|
203
|
-
});
|
|
204
|
-
get().actions.saveLayouts();
|
|
205
|
-
if (get().singleId === removeLayoutId) {
|
|
206
|
-
get().actions.maximizeLayout();
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
addWindowLayout: (windowId, newWindow) => {
|
|
210
|
-
const newLayout = {
|
|
211
|
-
...newWindow.layoutProps,
|
|
212
|
-
i: windowId,
|
|
213
|
-
isDraggable: true,
|
|
214
|
-
isResizable: true,
|
|
215
|
-
winType: newWindow.winType
|
|
216
|
-
};
|
|
217
|
-
set((state) => {
|
|
218
|
-
state.gridLayouts.push(newLayout);
|
|
219
|
-
state.hashWindowsLayouts[windowId] = {
|
|
220
|
-
...newWindow,
|
|
221
|
-
windowId,
|
|
222
|
-
emergeType: "layout",
|
|
223
|
-
onClose: get().actions.closeWindowLayout
|
|
224
|
-
};
|
|
225
|
-
setAddBreakPoints(state, newLayout);
|
|
226
|
-
});
|
|
227
|
-
get().actions.selectWindowLayout(windowId);
|
|
228
|
-
if (get().viewMode === "single") {
|
|
229
|
-
get().actions.maximizeLayout(windowId);
|
|
230
|
-
}
|
|
231
|
-
get().actions.saveLayouts();
|
|
232
|
-
get().actions.bouncedSaveBreakpointsLayouts();
|
|
233
|
-
},
|
|
234
|
-
saveLayouts: () => {
|
|
235
|
-
let nrKeys = 0;
|
|
236
|
-
const saveObjetc = {};
|
|
237
|
-
for (const key in get().hashWindowsLayouts) {
|
|
238
|
-
const element = get().hashWindowsLayouts[key];
|
|
239
|
-
if (element.winType === "microfrontend") {
|
|
240
|
-
const newElement = { ...element };
|
|
241
|
-
delete newElement.onClose;
|
|
242
|
-
delete newElement.devCookies;
|
|
243
|
-
saveObjetc[key] = newElement;
|
|
244
|
-
nrKeys++;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (nrKeys > 0) {
|
|
248
|
-
get().networkOperation({
|
|
249
|
-
method: "PUT",
|
|
250
|
-
endPoint: `cookies/${get().id}/${COOKIE_WINDOWS}`,
|
|
251
|
-
data: {
|
|
252
|
-
value: JSON.stringify(saveObjetc)
|
|
253
|
-
},
|
|
254
|
-
toastSuccess: false,
|
|
255
|
-
toastError: false
|
|
256
|
-
});
|
|
257
|
-
} else {
|
|
258
|
-
get().networkOperation({
|
|
259
|
-
method: "DELETE",
|
|
260
|
-
endPoint: `cookies`,
|
|
261
|
-
data: { f: [{ n: "container_id", o: "c", o1: get().id }] },
|
|
262
|
-
toastSuccess: false,
|
|
263
|
-
toastError: false
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
bouncedSaveBreakpointsLayouts: debounce(
|
|
268
|
-
() => {
|
|
269
|
-
const purgedLayouts = {
|
|
270
|
-
...get().viewMode === "multiple" ? get().breakpointsLayouts : get().beforeMaximizebreakpointsLayouts
|
|
271
|
-
};
|
|
272
|
-
const finalLayouts = {};
|
|
273
|
-
for (const key in purgedLayouts) {
|
|
274
|
-
const element = purgedLayouts[key];
|
|
275
|
-
purgedLayouts[key] = element.filter((l) => {
|
|
276
|
-
if (l.i === "none") {
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
if (get().hashWindowsLayouts[l.i]) {
|
|
280
|
-
return true;
|
|
281
|
-
}
|
|
282
|
-
return false;
|
|
283
|
-
});
|
|
284
|
-
if (purgedLayouts[key].length > 0) {
|
|
285
|
-
finalLayouts[key] = purgedLayouts[key];
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (Object.keys(finalLayouts).length > 0) {
|
|
289
|
-
get().networkOperation({
|
|
290
|
-
method: "PUT",
|
|
291
|
-
endPoint: `cookies/${get().id}/${COOKIE_BREAKPOINT_LAYOUTS}`,
|
|
292
|
-
data: {
|
|
293
|
-
value: JSON.stringify(finalLayouts)
|
|
294
|
-
},
|
|
295
|
-
toastSuccess: false,
|
|
296
|
-
toastError: false
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
DEBOUCED_SAVE_TIME
|
|
301
|
-
),
|
|
302
|
-
onBreakpointsLayoutsChange: (_currentLayouts, newAllLayouts) => {
|
|
303
|
-
set((state) => {
|
|
304
|
-
state.breakpointsLayouts = newAllLayouts;
|
|
305
|
-
});
|
|
306
|
-
if (!get().singleId) {
|
|
307
|
-
get().actions.bouncedSaveBreakpointsLayouts();
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
selectWindowLayout: (layoutId) => {
|
|
311
|
-
set((state) => {
|
|
312
|
-
state.currentLayoutId = layoutId;
|
|
313
|
-
if (state.currentPopUpId !== "" && state.hashWindowsPopups[state.currentPopUpId]) {
|
|
314
|
-
const windowPopup = state.hashWindowsPopups[state.currentPopUpId];
|
|
315
|
-
if (windowPopup.parentLayoutId !== layoutId) {
|
|
316
|
-
state.currentPopUpId = "";
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
},
|
|
321
|
-
selectWindowPopUp: (popUpId) => {
|
|
322
|
-
set((state) => {
|
|
323
|
-
state.zPopUpIndex++;
|
|
324
|
-
state.currentPopUpId = popUpId;
|
|
325
|
-
state.zPopUpIndex++;
|
|
326
|
-
state.currentPopUpId = popUpId;
|
|
327
|
-
state.hashWindowsPopups[popUpId].zIndex = state.zPopUpIndex;
|
|
328
|
-
if (state.hashWindowsPopups[popUpId].parentLayoutId && state.hashWindowsPopups[popUpId].parentLayoutId !== "") {
|
|
329
|
-
state.currentLayoutId = state.hashWindowsPopups[popUpId].parentLayoutId;
|
|
330
|
-
} else {
|
|
331
|
-
state.currentLayoutId = "";
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
setTimeout(() => {
|
|
335
|
-
const container = document.getElementsByClassName(
|
|
336
|
-
`M4L_WrapperGridLayout_${get().id}`
|
|
337
|
-
)[0];
|
|
338
|
-
const element = document.getElementsByClassName(
|
|
339
|
-
`M4L_WindowPopUp_${popUpId}`
|
|
340
|
-
)[0];
|
|
341
|
-
if (element && container) {
|
|
342
|
-
const { top, left } = element.getBoundingClientRect();
|
|
343
|
-
const { top: containerTop, left: containerLeft } = container.getBoundingClientRect();
|
|
344
|
-
container.scrollTop = container.scrollTop + top - containerTop;
|
|
345
|
-
container.scrollLeft = container.scrollLeft + left - containerLeft;
|
|
346
|
-
}
|
|
347
|
-
}, 100);
|
|
348
|
-
},
|
|
349
|
-
maximizeLayout: (layoutId) => {
|
|
350
|
-
let finalLayoutId = layoutId;
|
|
351
|
-
set((state) => {
|
|
352
|
-
if (state.viewMode === "multiple") {
|
|
353
|
-
state.beforeMaximizebreakpointsLayouts = cloneDeep(
|
|
354
|
-
state.breakpointsLayouts
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
if (!finalLayoutId) {
|
|
358
|
-
if (state.gridLayouts.length > 0) {
|
|
359
|
-
finalLayoutId = state.gridLayouts[0].i;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
state.viewMode = "single";
|
|
363
|
-
state.singleId = finalLayoutId;
|
|
364
|
-
setBreakPointsMaximized(state, finalLayoutId);
|
|
365
|
-
});
|
|
366
|
-
if (finalLayoutId) {
|
|
367
|
-
get().actions.selectWindowLayout(finalLayoutId);
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
normalizeLayouts: () => {
|
|
371
|
-
set((state) => {
|
|
372
|
-
if (!state.isDesktop)
|
|
373
|
-
return;
|
|
374
|
-
if (state.isDesktop && state.viewMode === "single") {
|
|
375
|
-
state.viewMode = "multiple";
|
|
376
|
-
state.singleId = void 0;
|
|
377
|
-
state.breakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
},
|
|
382
|
-
internalActions: {
|
|
383
|
-
loadFromApi: () => {
|
|
384
|
-
if (get().status !== "init") {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
if (!get().loadAreasFromNetwork || !get().loadWindows) {
|
|
388
|
-
set((state) => {
|
|
389
|
-
state.status = "loaded";
|
|
390
|
-
});
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
get().networkOperation({
|
|
394
|
-
method: "GET",
|
|
395
|
-
endPoint: `cookies`,
|
|
396
|
-
parms: { f: [{ n: "container_id", o: "e", o1: get().id }] },
|
|
397
|
-
toastSuccess: false,
|
|
398
|
-
toastError: false
|
|
399
|
-
}).then((response) => {
|
|
400
|
-
set((state) => {
|
|
401
|
-
const {
|
|
402
|
-
newBreakPointsLayouts,
|
|
403
|
-
newGridLayouts,
|
|
404
|
-
newHashWindowLayouts
|
|
405
|
-
} = getDataFromResponse(response.data, state);
|
|
406
|
-
if (state.viewMode === "multiple") {
|
|
407
|
-
state.breakpointsLayouts = newBreakPointsLayouts;
|
|
408
|
-
} else {
|
|
409
|
-
state.breakpointsLayouts = newBreakPointsLayouts;
|
|
410
|
-
state.beforeMaximizebreakpointsLayouts = newBreakPointsLayouts;
|
|
411
|
-
}
|
|
412
|
-
state.gridLayouts = newGridLayouts;
|
|
413
|
-
state.hashWindowsLayouts = newHashWindowLayouts;
|
|
414
|
-
state.status = "loaded";
|
|
415
|
-
});
|
|
416
|
-
if (get().viewMode === "single") {
|
|
417
|
-
get().actions.maximizeLayout();
|
|
418
|
-
}
|
|
419
|
-
}).catch((_response) => {
|
|
420
|
-
set((state) => {
|
|
421
|
-
state.status = "loaded";
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
|
-
},
|
|
425
|
-
changeDesktopBreakpoint: (isDesktop) => {
|
|
426
|
-
const previousState = get().isDesktop;
|
|
427
|
-
set((state) => {
|
|
428
|
-
state.isDesktop = isDesktop;
|
|
429
|
-
});
|
|
430
|
-
if (previousState != isDesktop) {
|
|
431
|
-
if (isDesktop) {
|
|
432
|
-
get().actions.normalizeLayouts();
|
|
433
|
-
} else {
|
|
434
|
-
if (get().viewMode === "multiple") {
|
|
435
|
-
if (get().gridLayouts.length > 0) {
|
|
436
|
-
get().actions.maximizeLayout(get().gridLayouts[0].i);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
})),
|
|
444
|
-
{ name: `Area state ${initProps.id}` }
|
|
445
|
-
)
|
|
446
|
-
);
|
|
447
|
-
};
|
|
448
|
-
const AreaContext = createContext(null);
|
|
449
|
-
const AreaProvider = (props) => {
|
|
450
|
-
const {
|
|
451
|
-
children,
|
|
452
|
-
id,
|
|
453
|
-
active,
|
|
454
|
-
loadWindows = true
|
|
455
|
-
} = props;
|
|
456
|
-
const loadAreasFromNetwork = useAreasStore((state) => state.loadAreasFromNetwork);
|
|
457
|
-
const {
|
|
458
|
-
setAreaLink
|
|
459
|
-
} = useAreasStore((state) => state.internalActions);
|
|
460
|
-
const isDesktop = useResponsiveDesktop();
|
|
461
|
-
const isFirstRender = useFirstRender([isDesktop]);
|
|
462
|
-
const {
|
|
463
|
-
networkOperation
|
|
464
|
-
} = useNetwork();
|
|
465
|
-
const areaStoreRef = useRef();
|
|
466
|
-
if (!areaStoreRef.current) {
|
|
467
|
-
areaStoreRef.current = createAreaStore({
|
|
468
|
-
id,
|
|
469
|
-
networkOperation,
|
|
470
|
-
loadAreasFromNetwork,
|
|
471
|
-
loadWindows,
|
|
472
|
-
isDesktop: !!isDesktop
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
const {
|
|
476
|
-
loadFromApi,
|
|
477
|
-
changeDesktopBreakpoint
|
|
478
|
-
} = useStore(areaStoreRef.current, (state) => state.internalActions, shallow);
|
|
479
|
-
const status = useStore(areaStoreRef.current, (state) => state.status, shallow);
|
|
480
|
-
useEffect(() => {
|
|
481
|
-
if (!isFirstRender) {
|
|
482
|
-
changeDesktopBreakpoint(!!isDesktop);
|
|
483
|
-
}
|
|
484
|
-
}, [isDesktop]);
|
|
485
|
-
useEffect(() => {
|
|
486
|
-
if (areaStoreRef.current) {
|
|
487
|
-
setAreaLink(id, areaStoreRef.current);
|
|
488
|
-
}
|
|
489
|
-
return () => {
|
|
490
|
-
};
|
|
491
|
-
}, []);
|
|
492
|
-
useEffect(() => {
|
|
493
|
-
if (active && status === "init") {
|
|
494
|
-
loadFromApi();
|
|
495
|
-
}
|
|
496
|
-
}, [active]);
|
|
497
|
-
return /* @__PURE__ */ jsx(AreaContext.Provider, {
|
|
498
|
-
value: areaStoreRef.current,
|
|
499
|
-
children
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
AreaProvider.displayName = "AreaProvider";
|
|
503
|
-
React__default.memo(AreaProvider);
|
|
504
|
-
export {
|
|
505
|
-
AreaProvider as A,
|
|
506
|
-
CONTAINER_PADDING_GRIDLAYOUT as C,
|
|
507
|
-
ROW_HEIGTH_GRIDLAYOUT as R,
|
|
508
|
-
AreaContext as a
|
|
509
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import type { Layout } from 'react-grid-layout';
|
|
3
|
-
import { NewWindowProps, WinType } from '../../components/Area/types';
|
|
4
|
-
import { AreaProps } from '../../components/Area/types';
|
|
5
|
-
import { AreaStore } from './store';
|
|
6
|
-
export declare type AreaStatus = 'init' | 'load' | 'loaded' | 'error';
|
|
7
|
-
export interface AreaProviderProps extends AreaProps {
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export declare type WinLayout = Layout & {
|
|
11
|
-
winType: WinType;
|
|
12
|
-
};
|
|
13
|
-
export declare type AreaProviderRef = {
|
|
14
|
-
store: AreaStore;
|
|
15
|
-
addWindow: (newWindow: NewWindowProps) => string;
|
|
16
|
-
};
|
|
17
|
-
export interface AreaContextProps {
|
|
18
|
-
store: AreaStore;
|
|
19
|
-
addWindow: (newWindow: NewWindowProps) => string;
|
|
20
|
-
}
|