@m4l/components 0.1.36 → 0.1.37

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.
Files changed (61) hide show
  1. package/dist/{commonjs.bcc6b707.js → commonjs.565e6834.js} +0 -1
  2. package/dist/components/CommonActions/components/ActionCancel/{index.4b36950f.js → index.9230c57b.js} +1 -1
  3. package/dist/components/CommonActions/components/ActionFormCancel/{index.945e9887.js → index.ab514bd9.js} +9 -7
  4. package/dist/components/CommonActions/components/ActionIntro/{index.35a0d240.js → index.a0a341c7.js} +1 -1
  5. package/dist/components/CommonActions/components/Actions/index.d3e1f36e.js +54 -0
  6. package/dist/components/DataGrid/{index.156cc30c.js → index.67260455.js} +663 -15
  7. package/dist/components/DynamicFilter/{index.32f84995.js → index.071aa795.js} +92 -18
  8. package/dist/components/Icon/{index.1dbd3e58.js → index.8d754623.js} +62 -5
  9. package/dist/components/LanguagePopover/index.cbc4b282.js +144 -0
  10. package/dist/components/Loadable/{index.8c6006be.js → index.117eaced.js} +1 -1
  11. package/dist/components/ModalDialog/{index.91777582.js → index.a684827f.js} +5 -5
  12. package/dist/components/ObjectLogs/{index.9d3fc2ae.js → index.4a859658.js} +12 -10
  13. package/dist/components/PaperForm/{index.218a6c4b.js → index.c5948756.js} +1 -1
  14. package/dist/components/Period/{index.74f35862.js → index.abe445bd.js} +9 -7
  15. package/dist/components/Resizeable/{index.44a0dd46.js → index.c96c0f09.js} +1 -1
  16. package/dist/components/SplitLayout/{index.81fc4750.js → index.5a8355d8.js} +1 -1
  17. package/dist/components/animate/PropagateLoader/index.be5b02c3.js +30 -0
  18. package/dist/components/areas/components/AreasAdmin/index.6794b22f.js +112 -0
  19. package/dist/components/areas/components/AreasContainer/index.a2f8899b.js +43 -0
  20. package/dist/components/areas/components/GridLayout/index.b9c1e846.js +92 -0
  21. package/dist/components/areas/components/Window/index.252fbf4e.js +646 -0
  22. package/dist/components/areas/components/WindowPopUp/index.214cf099.js +120 -0
  23. package/dist/components/areas/components/index.7d6cd649.js +67 -0
  24. package/dist/components/areas/contexts/AreaContext/index.4894cf23.js +286 -0
  25. package/dist/components/areas/contexts/AreasContext/index.cd8e4bee.js +158 -0
  26. package/dist/components/areas/contexts/DynamicMFParmsContext/index.668bc2e2.js +17 -0
  27. package/dist/components/areas/contexts/index.f9196fb2.js +1 -0
  28. package/dist/components/areas/hooks/useArea/index.9b85ce24.js +19 -0
  29. package/dist/components/areas/hooks/useDynamicMFParameters/index.e6a44ae3.js +11 -0
  30. package/dist/components/areas/index.d1bf612c.js +16 -0
  31. package/dist/components/formatters/BooleanFormatter/{index.efc8ffc2.js → index.3a9b16c8.js} +1 -1
  32. package/dist/components/formatters/{index.c3f4b687.js → index.0b5f95d0.js} +1 -1
  33. package/dist/components/hook-form/RHFPeriod/{index.2b8e63a2.js → index.3772295b.js} +1 -1
  34. package/dist/components/hook-form/RHFTextField/{index.7feaec71.js → index.b17d68f4.js} +1 -1
  35. package/dist/components/modal/WindowBase.04439b8e.js +120 -0
  36. package/dist/components/modal/WindowConfirm.0b8a6818.js +115 -0
  37. package/dist/components/modal/index.8387e90e.js +18 -0
  38. package/dist/components/mui_extended/Accordion/{index.8e123c57.js → index.a541c71c.js} +2 -2
  39. package/dist/components/mui_extended/Button/index.86a155a2.js +101 -0
  40. package/dist/components/mui_extended/IconButton/{index.e3adaa33.js → index.82f16572.js} +5 -62
  41. package/dist/components/mui_extended/MenuActions/index.ee17bddd.js +112 -0
  42. package/dist/components/mui_extended/Pager/{index.d245f821.js → index.74d3f5fc.js} +66 -1
  43. package/dist/components/mui_extended/Popover/index.53c77d23.js +137 -0
  44. package/dist/components/mui_extended/index.85dfadf1.js +16 -0
  45. package/dist/contexts/ModalContext/{index.0797eb17.js → index.b90eec94.js} +1 -1
  46. package/dist/hooks/useModal/{index.32da4dcb.js → index.d14edee3.js} +1 -1
  47. package/dist/index.js +128 -1691
  48. package/dist/{components/animate/PropagateLoader/index.eb401503.js → node_modules.416f1da3.js} +59 -28
  49. package/dist/package.json +2 -1
  50. package/dist/{react-draggable.3b5b6680.js → react-draggable.84d6b038.js} +1 -1
  51. package/dist/{react-json-view.03ae95f5.js → react-json-view.57125fcf.js} +1 -1
  52. package/dist/{react-resizable.6eae0397.js → react-resizable.1d00271d.js} +3 -4
  53. package/dist/{react-splitter-layout.873aece3.js → react-splitter-layout.8b1655c8.js} +1 -1
  54. package/dist/style.css +0 -114
  55. package/dist/utils/{index.9dce2e2f.js → index.899eb67b.js} +28 -460
  56. package/package.json +3 -1
  57. package/vite.config.ts +201 -129
  58. package/dist/components/CommonActions/components/Actions/index.ba86f72f.js +0 -868
  59. package/dist/components/mui_extended/Button/index.55fc70dc.js +0 -178
  60. package/dist/components/mui_extended/Popover/index.97cf3a3e.js +0 -275
  61. package/dist/node_modules.e0b84fac.js +0 -2154
@@ -0,0 +1,120 @@
1
+ import { useState } from "react";
2
+ import "../../../Icon/index.8d754623.js";
3
+ import "framer-motion";
4
+ import "@mui/material";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { styled } from "@mui/material/styles";
7
+ import "react-router-dom";
8
+ import "../../../animate/LoadingScreen/index.1d0c4307.js";
9
+ import "../../../animate/PropagateLoader/index.be5b02c3.js";
10
+ import "../index.7d6cd649.js";
11
+ import "../AreasAdmin/index.6794b22f.js";
12
+ import "@m4l/core";
13
+ import "../../contexts/AreasContext/index.cd8e4bee.js";
14
+ import "../AreasContainer/index.a2f8899b.js";
15
+ import "react-grid-layout/css/styles.css";
16
+ import "../../../../react-resizable.1d00271d.js";
17
+ import "react-hook-form";
18
+ import "../../../hook-form/RHFAutocomplete/index.de93fe01.js";
19
+ import "../../../Image/index.93d5f37f.js";
20
+ import "lodash/debounce";
21
+ import "../../../hook-form/RHFCheckbox/index.6dcec9e2.js";
22
+ import "@mui/x-date-pickers";
23
+ import "../../../hook-form/RHFDateTime/index.7f1cbd85.js";
24
+ import "@m4l/graphics";
25
+ import "../../../hook-form/RHFTextField/index.b17d68f4.js";
26
+ import "../../../hook-form/RHFPeriod/index.3772295b.js";
27
+ import "../../../ErrorLabel/index.c8615f16.js";
28
+ import "../../../Period/index.abe445bd.js";
29
+ import "../../../CommonActions/components/Actions/index.d3e1f36e.js";
30
+ import "@mui/material/Button";
31
+ import "../../../../contexts/ModalContext/index.b90eec94.js";
32
+ import "../../../../react-draggable.84d6b038.js";
33
+ import "../../../ModalDialog/index.a684827f.js";
34
+ import { R as ResizeableWindow } from "../../../Resizeable/index.c96c0f09.js";
35
+ import "../../contexts/DynamicMFParmsContext/index.668bc2e2.js";
36
+ import "../../../modal/WindowConfirm.0b8a6818.js";
37
+ import "../../../modal/WindowBase.04439b8e.js";
38
+ import "@mui/lab";
39
+ import "lodash/isString";
40
+ import "react-dropzone";
41
+ import "../../../hook-form/RHFUpload/index.d5cc7c13.js";
42
+ import "../../../mui_extended/Accordion/index.a541c71c.js";
43
+ import "../../../mui_extended/Avatar/index.fe06afd7.js";
44
+ import "../../../mui_extended/Button/index.86a155a2.js";
45
+ import "../../../mui_extended/Popover/index.53c77d23.js";
46
+ import "../../../mui_extended/MenuActions/index.ee17bddd.js";
47
+ import "../../../mui_extended/Pager/index.74d3f5fc.js";
48
+ import "../../../mui_extended/Tab/index.e0653a0a.js";
49
+ import "../../../DataGrid/index.67260455.js";
50
+ import "react-dnd";
51
+ import "react-dnd-html5-backend";
52
+ import "../../../ScrollBar/index.39eeb2de.js";
53
+ import "../../../DynamicFilter/index.071aa795.js";
54
+ import "simplebar/dist/simplebar.min.css";
55
+ import "@hookform/resolvers/yup";
56
+ import "../../../../contexts/RHFormContext/index.d88e6e27.js";
57
+ import "yup";
58
+ import { DraggableWindow } from "../../../../index.js";
59
+ import "../../../LanguagePopover/index.cbc4b282.js";
60
+ import "../../../NoItemSelected/index.46d2f632.js";
61
+ import "../../../ObjectLogs/index.4a859658.js";
62
+ import "../../../../react-json-view.57125fcf.js";
63
+ import "../../../PaperForm/index.c5948756.js";
64
+ import "../../../Page/index.4237c241.js";
65
+ import "../../../PropertyValue/index.dfcfe1ba.js";
66
+ import "../../../../react-splitter-layout.8b1655c8.js";
67
+ import "../../../SplitLayout/index.5a8355d8.js";
68
+ import { a as useArea } from "../../hooks/useArea/index.9b85ce24.js";
69
+ import { W as Window } from "../Window/index.252fbf4e.js";
70
+ const WrapperPopUpWindow = styled("div")(() => ({
71
+ height: "100%",
72
+ "&.m4l_selected": {
73
+ borderTop: "1px solid green"
74
+ }
75
+ }));
76
+ const WindowPopUp = (props) => {
77
+ const {
78
+ zIndex,
79
+ windowProps: rect
80
+ } = props;
81
+ const {
82
+ isWindowSelected,
83
+ selectWindow,
84
+ getWindowPopUpZindex
85
+ } = useArea();
86
+ const [currentZIndex, setZindex] = useState(zIndex || getWindowPopUpZindex());
87
+ const isSelected = isWindowSelected(props.container_id);
88
+ const onTouch = () => {
89
+ if (!isSelected) {
90
+ selectWindow(props.container_id);
91
+ setZindex(getWindowPopUpZindex());
92
+ }
93
+ };
94
+ return /* @__PURE__ */ jsx(DraggableWindow, {
95
+ handle: ".m4l_draggable_handle",
96
+ cancel: "",
97
+ defaultPosition: rect,
98
+ children: /* @__PURE__ */ jsx(ResizeableWindow, {
99
+ width: rect.width,
100
+ height: rect.height,
101
+ style: {
102
+ zIndex: currentZIndex,
103
+ position: "absolute"
104
+ },
105
+ className: isSelected ? "m4l_selected" : "",
106
+ onResizeStart: () => {
107
+ onTouch();
108
+ },
109
+ children: /* @__PURE__ */ jsx(WrapperPopUpWindow, {
110
+ onMouseDown: onTouch,
111
+ children: /* @__PURE__ */ jsx(Window, {
112
+ ...props
113
+ })
114
+ })
115
+ })
116
+ });
117
+ };
118
+ export {
119
+ WindowPopUp as W
120
+ };
@@ -0,0 +1,67 @@
1
+ import { A as AreaProvider } from "../contexts/AreaContext/index.4894cf23.js";
2
+ import { G as GridLayout } from "./GridLayout/index.b9c1e846.js";
3
+ import { u as useAreas } from "../hooks/useArea/index.9b85ce24.js";
4
+ import { styled } from "@mui/material/styles";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import "./AreasAdmin/index.6794b22f.js";
7
+ import "react";
8
+ import "@m4l/core";
9
+ import "@mui/material";
10
+ import "../../Icon/index.8d754623.js";
11
+ import "../contexts/AreasContext/index.cd8e4bee.js";
12
+ import "./AreasContainer/index.a2f8899b.js";
13
+ import "react-grid-layout/css/styles.css";
14
+ import "../../../react-resizable.1d00271d.js";
15
+ const WrapperArea = styled("div")(() => ({
16
+ flexDirection: "column",
17
+ flexGrow: "1",
18
+ position: "absolute",
19
+ height: "100%",
20
+ width: "100%",
21
+ overflow: "auto",
22
+ justifyContent: "top",
23
+ alignItems: "flex-start",
24
+ border: "1px dashed black",
25
+ visibility: "hidden",
26
+ display: "none",
27
+ "&.active": {
28
+ display: "flex",
29
+ visibility: "visible"
30
+ },
31
+ "& .layout": {
32
+ overflow: "scroll",
33
+ minWidth: "100%",
34
+ minHeight: "100%"
35
+ },
36
+ "& .selected": {
37
+ borderTop: "1px solid green"
38
+ }
39
+ }));
40
+ const Area = (props) => {
41
+ const {
42
+ id,
43
+ active
44
+ } = props;
45
+ const {
46
+ setAreaRef
47
+ } = useAreas();
48
+ const setAreaProviderRef = (element) => {
49
+ console.log("setAreaProviderRef", element, id);
50
+ if (element) {
51
+ setAreaRef(id, element);
52
+ }
53
+ };
54
+ console.log("Render Area");
55
+ return /* @__PURE__ */ jsx(WrapperArea, {
56
+ className: active ? "active" : "",
57
+ children: /* @__PURE__ */ jsx(AreaProvider, {
58
+ ...props,
59
+ ref: setAreaProviderRef,
60
+ children: /* @__PURE__ */ jsx(GridLayout, {})
61
+ })
62
+ });
63
+ };
64
+ Area.displayName = "Area";
65
+ export {
66
+ Area as A
67
+ };
@@ -0,0 +1,286 @@
1
+ import React__default, { createContext, forwardRef, useState, useRef, useImperativeHandle, useCallback, useEffect } from "react";
2
+ import isEqual from "lodash/isEqual";
3
+ import debounce from "lodash/debounce";
4
+ import { W as Window } from "../../components/Window/index.252fbf4e.js";
5
+ import { u as useModal } from "../../../../hooks/useModal/index.d14edee3.js";
6
+ import { useNetwork } from "@m4l/core";
7
+ import { u as useAreas } from "../../hooks/useArea/index.9b85ce24.js";
8
+ import { jsx } from "react/jsx-runtime";
9
+ const AreaContext = createContext(null);
10
+ const getParmsFromValue = (key, data) => {
11
+ try {
12
+ if (Array.isArray(data)) {
13
+ let ob = data.find((f) => f.id === key);
14
+ if (ob) {
15
+ ob = JSON.parse(ob.value);
16
+ }
17
+ return ob;
18
+ }
19
+ } catch (error) {
20
+ }
21
+ return void 0;
22
+ };
23
+ const AreaProvider = forwardRef((props, ref) => {
24
+ const {
25
+ children,
26
+ id,
27
+ active
28
+ } = props;
29
+ const {
30
+ networkOperation
31
+ } = useNetwork();
32
+ const [status, setStatus] = useState("init");
33
+ const [layouts, setLayouts] = useState([]);
34
+ const [allLayouts, setAllLayouts] = useState({});
35
+ const [hashWindowsLayouts, setHashhWindowsLayouts] = useState({});
36
+ const windowsLayoutsBack = useRef({});
37
+ const [windowsPopUps, setWindowsPopUps] = useState([]);
38
+ const [, setSelectedWindow] = useState("");
39
+ const {
40
+ openModal,
41
+ closeModal
42
+ } = useModal();
43
+ const {
44
+ activeAreasNetwork
45
+ } = useAreas();
46
+ useImperativeHandle(ref, () => ({
47
+ addWindow
48
+ }), []);
49
+ const WindowPopUpZindex = useRef(999);
50
+ const getWindowPopUpZindex = useCallback(() => {
51
+ WindowPopUpZindex.current++;
52
+ return WindowPopUpZindex.current;
53
+ }, []);
54
+ useEffect(() => {
55
+ console.log("useEffect AreaProvider");
56
+ return () => {
57
+ console.log("useEffect cluanUp AreaProvider****");
58
+ };
59
+ }, []);
60
+ useEffect(() => {
61
+ if (active && status === "init") {
62
+ setStatus("load");
63
+ }
64
+ }, [active]);
65
+ console.log("Rendeer AreaProvider status", status, activeAreasNetwork);
66
+ useEffect(() => {
67
+ let mounted = true;
68
+ if (status === "load") {
69
+ if (activeAreasNetwork) {
70
+ console.log("useEffect Load Cargarcokies");
71
+ networkOperation({
72
+ method: "GET",
73
+ endPoint: `cookies`,
74
+ parms: {
75
+ f: [{
76
+ n: "container_id",
77
+ o: "c",
78
+ o1: id
79
+ }]
80
+ },
81
+ toastSuccess: false,
82
+ toastError: false
83
+ }).then((_response) => {
84
+ if (mounted) {
85
+ const layoutParms = getParmsFromValue("layout_parms", _response.data);
86
+ const windows = getParmsFromValue("windows", _response.data);
87
+ if (layoutParms) {
88
+ setAllLayouts(layoutParms);
89
+ }
90
+ if (windows) {
91
+ const newLayouts = [];
92
+ const newHashLayouts = {};
93
+ for (const key in windows) {
94
+ const element = windows[key];
95
+ if (element && element["layoutProps"] && element["mfProps"] && element["emergeType"] === "layout" && element["winType"] === "microfrontend") {
96
+ element["layoutProps"].i = key;
97
+ newLayouts.push(element["layoutProps"]);
98
+ newHashLayouts[key] = {
99
+ ...element,
100
+ container_id: key,
101
+ emergeType: "layout",
102
+ onClose: onCloseWindowLayout
103
+ };
104
+ }
105
+ }
106
+ console.log("GET cookies", layoutParms, newHashLayouts);
107
+ setLayouts(newLayouts);
108
+ setHashhWindowsLayouts(newHashLayouts);
109
+ }
110
+ setStatus("loaded");
111
+ }
112
+ }).catch((_response) => {
113
+ setStatus("loaded");
114
+ });
115
+ } else {
116
+ setStatus("loaded");
117
+ }
118
+ }
119
+ return () => {
120
+ mounted = false;
121
+ };
122
+ }, [status]);
123
+ useEffect(() => {
124
+ console.log("useEffect SaveWindow", status, hashWindowsLayouts);
125
+ if (status === "loaded") {
126
+ let nrKeys = 0;
127
+ const saveObjetc = {};
128
+ for (const key in hashWindowsLayouts) {
129
+ const element = hashWindowsLayouts[key];
130
+ const newElement = {
131
+ ...element
132
+ };
133
+ delete newElement.onClose;
134
+ if (element.winType === "microfrontend") {
135
+ saveObjetc[key] = newElement;
136
+ nrKeys++;
137
+ }
138
+ }
139
+ console.log("saveWindows", nrKeys, saveObjetc, JSON.stringify(saveObjetc));
140
+ if (activeAreasNetwork && nrKeys > 0) {
141
+ networkOperation({
142
+ method: "PUT",
143
+ endPoint: `cookies/windows/${id}/nomodule`,
144
+ data: {
145
+ value: JSON.stringify(saveObjetc)
146
+ },
147
+ toastSuccess: false,
148
+ toastError: false
149
+ });
150
+ }
151
+ }
152
+ }, [hashWindowsLayouts]);
153
+ const debouncedLayoutChange = useCallback(debounce((currentLayouts, newAllLayouts) => {
154
+ currentLayouts.forEach((layout) => {
155
+ const {
156
+ i
157
+ } = layout;
158
+ if (i === "none")
159
+ return;
160
+ if (isEqual(layout, windowsLayoutsBack.current[i]))
161
+ return;
162
+ });
163
+ setAllLayouts(newAllLayouts);
164
+ if (activeAreasNetwork) {
165
+ networkOperation({
166
+ method: "PUT",
167
+ endPoint: `cookies/layout_parms/${id}/nomodule`,
168
+ data: {
169
+ value: JSON.stringify(newAllLayouts)
170
+ },
171
+ toastSuccess: false,
172
+ toastError: false
173
+ });
174
+ }
175
+ }, 2e3), [layouts]);
176
+ const onLayoutChange = useCallback((currentLayouts, newAllLayouts) => {
177
+ debouncedLayoutChange(currentLayouts, newAllLayouts);
178
+ }, [debouncedLayoutChange]);
179
+ const onCloseWindowLayout = useCallback((removeLayoutId) => {
180
+ setHashhWindowsLayouts((lastHashhWL) => {
181
+ const newLayouts = {
182
+ ...lastHashhWL
183
+ };
184
+ delete newLayouts[removeLayoutId];
185
+ return newLayouts;
186
+ });
187
+ delete windowsLayoutsBack.current[removeLayoutId];
188
+ }, []);
189
+ const onCloseWindowPopUp = useCallback((removePopUpId) => {
190
+ setWindowsPopUps((lastPopUpsMfs) => {
191
+ const newPopUps = [...lastPopUpsMfs];
192
+ return newPopUps.filter((p) => p.container_id !== removePopUpId);
193
+ });
194
+ }, []);
195
+ const onCloseWindowModal = useCallback((_removePopUpId) => {
196
+ closeModal();
197
+ }, []);
198
+ const addWindowPopUp = useCallback((container_id, newWindowPopupProps) => {
199
+ setWindowsPopUps((lastPopUpsMfs) => {
200
+ return [{
201
+ ...newWindowPopupProps,
202
+ emergeType: "popup",
203
+ container_id,
204
+ onClose: onCloseWindowPopUp
205
+ }, ...lastPopUpsMfs];
206
+ });
207
+ }, []);
208
+ const addWindowModal = useCallback((container_id, newWindowProps) => {
209
+ openModal({
210
+ window: /* @__PURE__ */ jsx(Window, {
211
+ ...newWindowProps,
212
+ container_id,
213
+ onClose: onCloseWindowModal
214
+ })
215
+ });
216
+ }, []);
217
+ const addWindowLayout = useCallback((container_id, newWindow) => {
218
+ const newLayout = {
219
+ ...newWindow.layoutProps,
220
+ i: container_id,
221
+ isDraggable: true,
222
+ isResizable: true,
223
+ winType: newWindow.winType
224
+ };
225
+ setLayouts((lastLayout) => [...lastLayout, newLayout]);
226
+ setHashhWindowsLayouts((lastHashWindowsLayouts) => {
227
+ return {
228
+ ...lastHashWindowsLayouts,
229
+ [container_id]: {
230
+ ...newWindow,
231
+ container_id,
232
+ emergeType: "layout",
233
+ onClose: onCloseWindowLayout
234
+ }
235
+ };
236
+ });
237
+ windowsLayoutsBack.current[container_id] = {
238
+ ...newLayout
239
+ };
240
+ }, []);
241
+ const addWindow = useCallback((newWindow) => {
242
+ const newId = `${id}_window_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
243
+ console.log("addWindow", newWindow.winType, newWindow.emergeType, newId);
244
+ if (newWindow.emergeType === "layout") {
245
+ addWindowLayout(newId, newWindow);
246
+ } else if (newWindow.emergeType === "popup") {
247
+ addWindowPopUp(newId, newWindow);
248
+ } else if (newWindow.emergeType === "modal") {
249
+ addWindowModal(newId, newWindow);
250
+ }
251
+ return newId;
252
+ }, []);
253
+ const isWindowSelected = useCallback((lookForThisId) => {
254
+ if (windowsPopUps.findIndex((wp) => wp.container_id === lookForThisId) > -1) {
255
+ return true;
256
+ }
257
+ return false;
258
+ }, [hashWindowsLayouts, windowsPopUps]);
259
+ const selectWindow = useCallback((newSeletectedId) => {
260
+ setSelectedWindow(newSeletectedId);
261
+ }, []);
262
+ return /* @__PURE__ */ jsx(AreaContext.Provider, {
263
+ value: {
264
+ id,
265
+ status,
266
+ isWindowSelected,
267
+ selectWindow,
268
+ getWindowPopUpZindex,
269
+ allLayouts,
270
+ layouts,
271
+ hashWindowsLayouts,
272
+ addWindow,
273
+ onCloseWindowLayout,
274
+ onLayoutChange,
275
+ windowsPopUps,
276
+ onCloseWindowPopUp
277
+ },
278
+ children
279
+ });
280
+ });
281
+ AreaProvider.displayName = "AreaProvider";
282
+ React__default.memo(AreaProvider);
283
+ export {
284
+ AreaProvider as A,
285
+ AreaContext as a
286
+ };
@@ -0,0 +1,158 @@
1
+ import { createContext, useState, useRef, useCallback, useEffect } from "react";
2
+ import { useHostTools, useModuleDictionary, useNetwork, EmitEvents } from "@m4l/core";
3
+ import { L as LABEL_NEW_AREA } from "../../index.d1bf612c.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ const AreasContext = createContext(null);
6
+ function AreasProvider(props) {
7
+ const {
8
+ children,
9
+ activeAreasNetwork,
10
+ onLoad
11
+ } = props;
12
+ const [areas, setAreas] = useState([]);
13
+ const {
14
+ events_add_listener,
15
+ events_remove_listener
16
+ } = useHostTools();
17
+ const {
18
+ getLabel
19
+ } = useModuleDictionary();
20
+ const [status, setStatus] = useState("init");
21
+ const {
22
+ networkOperation
23
+ } = useNetwork();
24
+ const [currentArea, setCurrentArea] = useState(areas.length > 0 ? areas[0].id : "");
25
+ const currentAreaRef = useRef(areas.length > 0 ? areas[0].id : "");
26
+ const areaRefs = useRef({});
27
+ const addWindow = useCallback((newWindow) => {
28
+ let current;
29
+ console.log("addWindow raw");
30
+ if (areaRefs.current && areaRefs.current[currentAreaRef.current]) {
31
+ current = areaRefs.current[currentAreaRef.current];
32
+ }
33
+ if (current && current.addWindow) {
34
+ current.addWindow(newWindow);
35
+ }
36
+ }, []);
37
+ const addArea = useCallback(() => {
38
+ const newId = `area_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
39
+ const newName = `${getLabel(LABEL_NEW_AREA)} ${areas.length + 1}`;
40
+ setAreas((lastAreas) => [...lastAreas, {
41
+ id: newId,
42
+ url_icon: "",
43
+ name: newName,
44
+ loadWindows: false
45
+ }]);
46
+ selectArea(newId);
47
+ if (activeAreasNetwork) {
48
+ networkOperation({
49
+ method: "POST",
50
+ endPoint: `areas`,
51
+ data: {
52
+ id: newId,
53
+ name: newName
54
+ },
55
+ toastSuccess: false,
56
+ toastError: false
57
+ });
58
+ }
59
+ return newId;
60
+ }, [getLabel]);
61
+ useEffect(() => {
62
+ events_add_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
63
+ console.log("useEffect AreasProvider Emmiter");
64
+ return () => {
65
+ events_remove_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
66
+ };
67
+ }, []);
68
+ useEffect(() => {
69
+ let mounted = true;
70
+ if (status === "init") {
71
+ if (activeAreasNetwork) {
72
+ setStatus("loading");
73
+ networkOperation({
74
+ method: "GET",
75
+ endPoint: `areas`,
76
+ parms: {},
77
+ toastSuccess: false
78
+ }).then((response) => {
79
+ if (mounted) {
80
+ if (response?.data && Array.isArray(response.data) && response.data.length > 0) {
81
+ setAreas(response.data);
82
+ selectArea(response.data[0].id);
83
+ } else {
84
+ addArea();
85
+ }
86
+ }
87
+ }).finally(() => {
88
+ setStatus("loaded");
89
+ });
90
+ } else {
91
+ addArea();
92
+ setStatus("loaded");
93
+ }
94
+ }
95
+ console.log("useEffect AreasProvider");
96
+ return () => {
97
+ console.log("useEffect cluanUp AreasProvider *** no deber\xEDa darse");
98
+ mounted = false;
99
+ };
100
+ }, []);
101
+ useEffect(() => {
102
+ if (status === "loaded") {
103
+ console.log("useEffect Areas loaded");
104
+ onLoad && onLoad();
105
+ }
106
+ }, [status]);
107
+ const selectArea = (newId) => {
108
+ currentAreaRef.current = newId;
109
+ setCurrentArea(newId);
110
+ };
111
+ const deleteArea = (areaId) => {
112
+ let newAreas = [];
113
+ setAreas((lastAreas) => {
114
+ newAreas = [...lastAreas];
115
+ newAreas = lastAreas.filter((area) => area.id !== areaId);
116
+ return newAreas;
117
+ });
118
+ if (currentAreaRef.current === areaId) {
119
+ if (newAreas.length > 0) {
120
+ selectArea(newAreas[0].id);
121
+ } else {
122
+ selectArea("");
123
+ }
124
+ }
125
+ if (activeAreasNetwork) {
126
+ networkOperation({
127
+ method: "DELETE",
128
+ endPoint: `areas/${areaId}`,
129
+ parms: {},
130
+ toastSuccess: false,
131
+ toastError: false
132
+ });
133
+ }
134
+ };
135
+ const setAreaRef = (areaId, ref) => {
136
+ console.log("setAreaRef", areaRefs.current[areaId] === ref, areaRefs.current[areaId]?.addWindow === ref?.addWindow, JSON.stringify(areaRefs.current[areaId]) === JSON.stringify(ref), areaRefs.current[areaId], ref);
137
+ if (areaRefs.current[areaId] !== ref) {
138
+ areaRefs.current[areaId] = ref;
139
+ }
140
+ };
141
+ return /* @__PURE__ */ jsx(AreasContext.Provider, {
142
+ value: {
143
+ status,
144
+ activeAreasNetwork,
145
+ areas,
146
+ currentArea,
147
+ addArea,
148
+ deleteArea,
149
+ selectArea,
150
+ setAreaRef
151
+ },
152
+ children
153
+ });
154
+ }
155
+ export {
156
+ AreasContext as A,
157
+ AreasProvider as a
158
+ };
@@ -0,0 +1,17 @@
1
+ import { createContext } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ const DynamicMFParmsContext = createContext(null);
4
+ function DynamicMFParmsProvider(props) {
5
+ const {
6
+ children,
7
+ ...other
8
+ } = props;
9
+ return /* @__PURE__ */ jsx(DynamicMFParmsContext.Provider, {
10
+ value: other,
11
+ children
12
+ });
13
+ }
14
+ export {
15
+ DynamicMFParmsProvider as D,
16
+ DynamicMFParmsContext as a
17
+ };
@@ -0,0 +1 @@
1
+ import "./AreasContext/index.cd8e4bee.js";
@@ -0,0 +1,19 @@
1
+ import { useContext } from "react";
2
+ import { A as AreasContext } from "../../contexts/AreasContext/index.cd8e4bee.js";
3
+ import { a as AreaContext } from "../../contexts/AreaContext/index.4894cf23.js";
4
+ function useAreas() {
5
+ const context = useContext(AreasContext);
6
+ if (!context)
7
+ throw new Error("useAreas context must be use inside AreasContext");
8
+ return context;
9
+ }
10
+ const useArea = () => {
11
+ const context = useContext(AreaContext);
12
+ if (!context)
13
+ throw new Error("useArea context must be use inside AreaContext");
14
+ return context;
15
+ };
16
+ export {
17
+ useArea as a,
18
+ useAreas as u
19
+ };
@@ -0,0 +1,11 @@
1
+ import { useContext } from "react";
2
+ import { a as DynamicMFParmsContext } from "../../contexts/DynamicMFParmsContext/index.668bc2e2.js";
3
+ const useDynamicMFParameters = () => {
4
+ const context = useContext(DynamicMFParmsContext);
5
+ if (!context)
6
+ throw new Error("useDynamicMFParameters context must be use inside DynamicMFParmsContext");
7
+ return context;
8
+ };
9
+ export {
10
+ useDynamicMFParameters as u
11
+ };