@m4l/components 0.1.50 → 0.1.52

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 (121) hide show
  1. package/components/CommonActions/components/ActionFormCancel/{index.bf4c99f9.js → index.bd0d16d6.js} +10 -11
  2. package/components/CommonActions/components/Actions/{index.274f0ce8.js → index.f0a3167b.js} +9 -9
  3. package/components/DataGrid/{index.01df4f26.js → index.85390177.js} +10 -10
  4. package/components/DynamicFilter/{index.c1022a6f.js → index.cddd7472.js} +13 -13
  5. package/components/ModalDialog/{index.1e2f7995.js → index.5a307e29.js} +2 -2
  6. package/components/ObjectLogs/{index.820d75ac.js → index.1315af37.js} +12 -12
  7. package/components/Period/{index.514252d6.js → index.85fe764a.js} +10 -10
  8. package/components/areas/components/Area/subcomponents/InnerForHooks/index.d.ts +2 -0
  9. package/components/areas/components/Area/types.d.ts +4 -2
  10. package/components/areas/components/AreasAdmin/{index.c6ccc79c.js → index.dbab59f1.js} +1 -3
  11. package/components/areas/components/AreasContainer/{index.a4393459.js → index.f3f921b9.js} +2 -7
  12. package/components/areas/components/GridLayout/index.9953146d.js +103 -0
  13. package/components/areas/components/Window/{index.ac629c20.js → index.e34225ae.js} +223 -36
  14. package/components/areas/components/WindowModal/index.d.ts +4 -0
  15. package/components/areas/components/WindowPopUp/{index.ba674a09.js → index.90eb0348.js} +18 -19
  16. package/components/areas/components/WindowsPanel/index.d.ts +2 -0
  17. package/components/areas/components/index.6d863764.js +77 -0
  18. package/components/areas/contexts/AreaContext/helper.d.ts +27 -0
  19. package/components/areas/contexts/AreaContext/index.d.ts +18 -4
  20. package/components/areas/contexts/AreaContext/{index.282b9a30.js → index.f25f7180.js} +181 -66
  21. package/components/areas/contexts/AreaContext/store.d.ts +23 -3
  22. package/components/areas/contexts/AreasContext/{index.cbfa4a53.js → index.7406c20f.js} +7 -14
  23. package/components/areas/contexts/AreasContext/store.d.ts +2 -2
  24. package/components/areas/contexts/{index.ea2185f5.js → index.e80d8f0f.js} +10 -15
  25. package/components/areas/hooks/{index.98cf18fc.js → index.0fd57f88.js} +1 -1
  26. package/components/areas/hooks/useArea/{index.868089ed.js → index.7bdbbb79.js} +8 -8
  27. package/components/areas/hooks/useArea/index.d.ts +9 -1
  28. package/components/areas/{index.d1ebea1b.js → index.6f09d168.js} +5 -5
  29. package/components/hook-form/RHFPeriod/{index.72f32f9b.js → index.5d2a2071.js} +1 -1
  30. package/components/hook-form/RHFTextField/{index.57f138f7.js → index.bef7eced.js} +0 -1
  31. package/components/index.d.ts +0 -1
  32. package/components/modal/ModalDialog/types.d.ts +2 -1
  33. package/components/modal/{WindowBase.9f5db87e.js → WindowBase.b5e29758.js} +1 -1
  34. package/components/modal/{WindowConfirm.d5026cb4.js → WindowConfirm.cbc7720c.js} +9 -9
  35. package/components/modal/{index.a568e1f0.js → index.f6de895f.js} +10 -10
  36. package/contexts/ModalContext/{index.6a6bf90d.js → index.3d92d9f9.js} +1 -1
  37. package/hooks/useModal/{index.2097260d.js → index.4454145e.js} +1 -1
  38. package/index.js +29 -60
  39. package/package.json +5 -3
  40. package/components/CmpDisenoTest/index.d.ts +0 -4
  41. package/components/CmpDisenoTest/types.d.ts +0 -20
  42. package/components/CommonActions/components/Actions/styles.d.ts +0 -2
  43. package/components/DataGrid/styles.d.ts +0 -3
  44. package/components/DataGrid/subcomponents/Actions/styles.d.ts +0 -2
  45. package/components/DataGrid/subcomponents/Actions/subcomponents/Density/styles.d.ts +0 -3
  46. package/components/DataGrid/subcomponents/Actions/subcomponents/Filter/styles.d.ts +0 -2
  47. package/components/DataGrid/subcomponents/Actions/subcomponents/RowsCount/styles.d.ts +0 -4
  48. package/components/DataGrid/subcomponents/Actions/subcomponents/Settings/styles.d.ts +0 -2
  49. package/components/DataGrid/subcomponents/Actions/subcomponents/Settings/subcomponents/ColumnsConfig/styles.d.ts +0 -8
  50. package/components/DataGrid/subcomponents/Table/styles.d.ts +0 -3
  51. package/components/DataGrid/subcomponents/Table/subcomponents/SkeletonFormatter/styles.d.ts +0 -2
  52. package/components/DataGrid/subcomponents/editors/TextEditor/index.d.ts +0 -6
  53. package/components/DynamicFilter/styles.d.ts +0 -6
  54. package/components/DynamicFilter/subcomponents/ApplyedFilters/components/ApplyedFilter/styles.d.ts +0 -6
  55. package/components/DynamicFilter/subcomponents/ApplyedFilters/styles.d.ts +0 -3
  56. package/components/DynamicFilter/subcomponents/ClearFilters/styles.d.ts +0 -3
  57. package/components/DynamicFilter/subcomponents/FilterButton/styles.d.ts +0 -3
  58. package/components/DynamicFilter/subcomponents/InputFilter/styles.d.ts +0 -3
  59. package/components/DynamicFilter/subcomponents/PopupEditFilter/styles.d.ts +0 -7
  60. package/components/DynamicFilter/subcomponents/fieldstypes/BooleanFilter/styles.d.ts +0 -3
  61. package/components/DynamicFilter/subcomponents/fieldstypes/DateTimeFilter/styles.d.ts +0 -3
  62. package/components/DynamicFilter/subcomponents/fieldstypes/NumberFilter/styles.d.ts +0 -3
  63. package/components/DynamicFilter/subcomponents/fieldstypes/StringFilter/styles.d.ts +0 -3
  64. package/components/ErrorLabel/styles.d.ts +0 -2
  65. package/components/Icon/styles.d.ts +0 -4
  66. package/components/Image/styles.d.ts +0 -3
  67. package/components/Image/subcomponents/LazyLoadComponent/styles.d.ts +0 -2
  68. package/components/Image/subcomponents/Skeleton/styles.d.ts +0 -2
  69. package/components/LanguagePopover/styles.d.ts +0 -5
  70. package/components/NoItemSelected/styles.d.ts +0 -5
  71. package/components/ObjectLogs/components/DetailDialog/styles.d.ts +0 -3
  72. package/components/ObjectLogs/styles.d.ts +0 -4
  73. package/components/PaperForm/styles.d.ts +0 -7
  74. package/components/Period/styles.d.ts +0 -7
  75. package/components/PropertyValue/styles.d.ts +0 -6
  76. package/components/ResizeableWindow/styles.d.ts +0 -5
  77. package/components/SplitLayout/styles.d.ts +0 -4
  78. package/components/animate/LoadingScreen/styles.d.ts +0 -3
  79. package/components/animate/PropagateLoader/syles.d.ts +0 -2
  80. package/components/areas/components/Area/styles.d.ts +0 -2
  81. package/components/areas/components/AreasAdmin/styles.d.ts +0 -2
  82. package/components/areas/components/AreasAdmin/subcomponents/AreaChip/styles.d.ts +0 -3
  83. package/components/areas/components/AreasContainer/styles.d.ts +0 -2
  84. package/components/areas/components/GridLayout/index.7a78196e.js +0 -102
  85. package/components/areas/components/GridLayout/styles.d.ts +0 -2
  86. package/components/areas/components/Window/styles.d.ts +0 -6
  87. package/components/areas/components/Window/subcomponents/InnerForHooks/styles.d.ts +0 -2
  88. package/components/areas/components/Window/subcomponents/InnerForHooks/subcomponents/Header/styles.d.ts +0 -9
  89. package/components/areas/components/Window/subcomponents/InnerForHooks/subcomponents/MicroFrontend/subcomponents/MFLoader/subcomponents/LoadingMF/styles.d.ts +0 -2
  90. package/components/areas/components/Window/subcomponents/InnerForHooks/subcomponents/MicroFrontend/subcomponents/MFLoader/subcomponents/LoadingMF/subcomponents/NotFound/styles.d.ts +0 -2
  91. package/components/areas/components/index.3c88ce04.js +0 -72
  92. package/components/hook-form/RHFAutocomplete/styles.d.ts +0 -2
  93. package/components/hook-form/RHFAutocomplete/subcomponents/RenderOption/styles.d.ts +0 -2
  94. package/components/hook-form/RHFAutocomplete/subcomponents/Skeleton/styles.d.ts +0 -3
  95. package/components/hook-form/RHFCheckbox/styles.d.ts +0 -14
  96. package/components/hook-form/RHFCheckbox/subcomponents/Skeleton/styles.d.ts +0 -2
  97. package/components/hook-form/RHFDateTime/subcomponents/Skeleton/styles.d.ts +0 -2
  98. package/components/hook-form/RHFPeriod/styles.d.ts +0 -2
  99. package/components/hook-form/RHFTextField/styles.d.ts +0 -3
  100. package/components/hook-form/RHFTextField/subcomponents/Skeleton/styles.d.ts +0 -2
  101. package/components/hook-form/RHFTextFieldPassword/styles.d.ts +0 -2
  102. package/components/hook-form/RHFUpload/RHFUploadImage/styles.d.ts +0 -2
  103. package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/styles.d.ts +0 -12
  104. package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/subcomponents/Skeleton/styles.d.ts +0 -2
  105. package/components/modal/ModalDialog/styles.d.ts +0 -9
  106. package/components/modal/WindowBase/styles.d.ts +0 -2
  107. package/components/modal/WindowBase/subcomponents/Header/styles.d.ts +0 -6
  108. package/components/modal/WindowConfirm/subcomponents/MessageIlustration/styles.d.ts +0 -6
  109. package/components/mui_extended/Accordion/styles.d.ts +0 -4
  110. package/components/mui_extended/Button/styles.d.ts +0 -13
  111. package/components/mui_extended/IconButton/styles.d.ts +0 -2
  112. package/components/mui_extended/ImageButton/styles.d.ts +0 -2
  113. package/components/mui_extended/LoadingButton/subcomponents/Skeleton/styles.d.ts +0 -2
  114. package/components/mui_extended/MenuActions/styles.d.ts +0 -30
  115. package/components/mui_extended/Pager/components/PagerActions/styles.d.ts +0 -2
  116. package/components/mui_extended/Pager/styles.d.ts +0 -6
  117. package/components/mui_extended/Popover/styles.d.ts +0 -1
  118. package/components/mui_extended/Popover/subcomponts/ArrowIcon/index.d.ts +0 -3
  119. package/components/mui_extended/Tab/styles.d.ts +0 -2
  120. package/components/mui_extended/Typography/styles.d.ts +0 -2
  121. package/contexts/RHFormContext/styles.d.ts +0 -2
@@ -1,17 +1,21 @@
1
- import React__default, { createContext, forwardRef, useRef, useImperativeHandle, useEffect, useCallback } from "react";
1
+ import React__default, { createContext, useRef, useEffect } from "react";
2
2
  import { shallow } from "zustand/shallow";
3
- import { W as Window } from "../../components/Window/index.ac629c20.js";
4
- import { u as useModal } from "../../../../hooks/useModal/index.2097260d.js";
5
3
  import { useNetwork } from "@m4l/core";
6
4
  import { createStore, useStore } from "zustand";
7
5
  import { immer } from "zustand/middleware/immer";
8
6
  import { devtools } from "zustand/middleware";
9
7
  import debounce from "lodash/debounce";
10
- import { u as useAreasStore } from "../../hooks/useArea/index.868089ed.js";
8
+ import cloneDeep from "lodash.clonedeep";
9
+ import { u as useAreasStore } from "../../hooks/useArea/index.7bdbbb79.js";
10
+ import { useResponsiveDesktop, useFirstRender } from "@m4l/graphics";
11
11
  import { jsx } from "react/jsx-runtime";
12
+ const ROW_HEIGTH_GRIDLAYOUT = 100;
13
+ const CONTAINER_PADDING_GRIDLAYOUT = 3;
12
14
  const DEBOUCED_SAVE_TIME = 500;
13
15
  const COOKIE_BREAKPOINT_LAYOUTS = "layoutPros";
14
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 };
15
19
  const getParmsFromValue = (key, data) => {
16
20
  try {
17
21
  if (Array.isArray(data)) {
@@ -25,6 +29,60 @@ const getParmsFromValue = (key, data) => {
25
29
  }
26
30
  return void 0;
27
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
+ }
28
86
  function getDataFromResponse(data, state) {
29
87
  const newBreakPointsLayouts = getParmsFromValue(COOKIE_BREAKPOINT_LAYOUTS, data);
30
88
  const windows = getParmsFromValue(COOKIE_WINDOWS, data);
@@ -44,7 +102,6 @@ function getDataFromResponse(data, state) {
44
102
  };
45
103
  }
46
104
  }
47
- console.log("GET cookies", newBreakPointsLayouts, newHashWindowLayouts);
48
105
  }
49
106
  return {
50
107
  newBreakPointsLayouts,
@@ -53,17 +110,21 @@ function getDataFromResponse(data, state) {
53
110
  };
54
111
  }
55
112
  const createAreaStore = (initProps) => {
56
- console.debug("Creating Area State");
57
113
  const startProps = {
58
114
  zPopUpIndex: 999,
59
115
  status: "init",
60
116
  breakpointsLayouts: {},
117
+ beforeMaximizebreakpointsLayouts: {},
61
118
  gridLayouts: [],
119
+ windowModal: null,
62
120
  windowsPopUps: [],
63
121
  hashWindowsPopups: {},
64
122
  hashWindowsLayouts: {},
65
123
  currentLayoutId: "",
66
124
  currentPopUpId: "",
125
+ viewMode: initProps.isDesktop ? "multiple" : "single",
126
+ breakpoints: NORMALIZED_BREAKPOINTS,
127
+ cols: NORMALIZED_COLS,
67
128
  ...initProps
68
129
  };
69
130
  return createStore(
@@ -71,6 +132,27 @@ const createAreaStore = (initProps) => {
71
132
  immer((set, get) => ({
72
133
  ...startProps,
73
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
+ },
74
156
  closeWindowPopUp: (removePopUpId) => {
75
157
  set((state) => {
76
158
  const removeIndex = state.windowsPopUps.findIndex(
@@ -106,7 +188,6 @@ const createAreaStore = (initProps) => {
106
188
  };
107
189
  state.currentPopUpId = windowId;
108
190
  }
109
- console.log("addWindowPopUp fin");
110
191
  });
111
192
  get().actions.selectWindowPopUp(popUpId);
112
193
  },
@@ -121,6 +202,9 @@ const createAreaStore = (initProps) => {
121
202
  delete state.hashWindowsLayouts[removeLayoutId];
122
203
  });
123
204
  get().actions.saveLayouts();
205
+ if (get().singleId === removeLayoutId) {
206
+ get().actions.maximizeLayout();
207
+ }
124
208
  },
125
209
  addWindowLayout: (windowId, newWindow) => {
126
210
  const newLayout = {
@@ -138,9 +222,14 @@ const createAreaStore = (initProps) => {
138
222
  emergeType: "layout",
139
223
  onClose: get().actions.closeWindowLayout
140
224
  };
225
+ setAddBreakPoints(state, newLayout);
141
226
  });
142
227
  get().actions.selectWindowLayout(windowId);
228
+ if (get().viewMode === "single") {
229
+ get().actions.maximizeLayout(windowId);
230
+ }
143
231
  get().actions.saveLayouts();
232
+ get().actions.bouncedSaveBreakpointsLayouts();
144
233
  },
145
234
  saveLayouts: () => {
146
235
  let nrKeys = 0;
@@ -155,7 +244,6 @@ const createAreaStore = (initProps) => {
155
244
  nrKeys++;
156
245
  }
157
246
  }
158
- console.log("saveWindows", nrKeys, saveObjetc, JSON.stringify(saveObjetc));
159
247
  if (nrKeys > 0) {
160
248
  get().networkOperation({
161
249
  method: "PUT",
@@ -178,7 +266,9 @@ const createAreaStore = (initProps) => {
178
266
  },
179
267
  bouncedSaveBreakpointsLayouts: debounce(
180
268
  () => {
181
- const purgedLayouts = { ...get().breakpointsLayouts };
269
+ const purgedLayouts = {
270
+ ...get().viewMode === "multiple" ? get().breakpointsLayouts : get().beforeMaximizebreakpointsLayouts
271
+ };
182
272
  const finalLayouts = {};
183
273
  for (const key in purgedLayouts) {
184
274
  const element = purgedLayouts[key];
@@ -196,7 +286,6 @@ const createAreaStore = (initProps) => {
196
286
  }
197
287
  }
198
288
  if (Object.keys(finalLayouts).length > 0) {
199
- console.log(finalLayouts);
200
289
  get().networkOperation({
201
290
  method: "PUT",
202
291
  endPoint: `cookies/${get().id}/${COOKIE_BREAKPOINT_LAYOUTS}`,
@@ -214,7 +303,9 @@ const createAreaStore = (initProps) => {
214
303
  set((state) => {
215
304
  state.breakpointsLayouts = newAllLayouts;
216
305
  });
217
- get().actions.bouncedSaveBreakpointsLayouts();
306
+ if (!get().singleId) {
307
+ get().actions.bouncedSaveBreakpointsLayouts();
308
+ }
218
309
  },
219
310
  selectWindowLayout: (layoutId) => {
220
311
  set((state) => {
@@ -242,7 +333,7 @@ const createAreaStore = (initProps) => {
242
333
  });
243
334
  setTimeout(() => {
244
335
  const container = document.getElementsByClassName(
245
- `M4L_GridLayout_${get().id}`
336
+ `M4L_WrapperGridLayout_${get().id}`
246
337
  )[0];
247
338
  const element = document.getElementsByClassName(
248
339
  `M4L_WindowPopUp_${popUpId}`
@@ -250,16 +341,42 @@ const createAreaStore = (initProps) => {
250
341
  if (element && container) {
251
342
  const { top, left } = element.getBoundingClientRect();
252
343
  const { top: containerTop, left: containerLeft } = container.getBoundingClientRect();
253
- console.log(
254
- "scroll top:",
255
- `M4L_WindowPopUp_${popUpId}`,
256
- top,
257
- containerTop
258
- );
259
344
  container.scrollTop = container.scrollTop + top - containerTop;
260
345
  container.scrollLeft = container.scrollLeft + left - containerLeft;
261
346
  }
262
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
+ });
263
380
  }
264
381
  },
265
382
  internalActions: {
@@ -286,17 +403,41 @@ const createAreaStore = (initProps) => {
286
403
  newGridLayouts,
287
404
  newHashWindowLayouts
288
405
  } = getDataFromResponse(response.data, state);
289
- state.breakpointsLayouts = newBreakPointsLayouts;
406
+ if (state.viewMode === "multiple") {
407
+ state.breakpointsLayouts = newBreakPointsLayouts;
408
+ } else {
409
+ state.breakpointsLayouts = newBreakPointsLayouts;
410
+ state.beforeMaximizebreakpointsLayouts = newBreakPointsLayouts;
411
+ }
290
412
  state.gridLayouts = newGridLayouts;
291
413
  state.hashWindowsLayouts = newHashWindowLayouts;
292
- console.log("Area loaded");
293
414
  state.status = "loaded";
294
415
  });
416
+ if (get().viewMode === "single") {
417
+ get().actions.maximizeLayout();
418
+ }
295
419
  }).catch((_response) => {
296
420
  set((state) => {
297
421
  state.status = "loaded";
298
422
  });
299
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
+ }
300
441
  }
301
442
  }
302
443
  })),
@@ -305,7 +446,7 @@ const createAreaStore = (initProps) => {
305
446
  );
306
447
  };
307
448
  const AreaContext = createContext(null);
308
- const AreaProvider = forwardRef((props, ref) => {
449
+ const AreaProvider = (props) => {
309
450
  const {
310
451
  children,
311
452
  id,
@@ -313,6 +454,11 @@ const AreaProvider = forwardRef((props, ref) => {
313
454
  loadWindows = true
314
455
  } = props;
315
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]);
316
462
  const {
317
463
  networkOperation
318
464
  } = useNetwork();
@@ -322,29 +468,23 @@ const AreaProvider = forwardRef((props, ref) => {
322
468
  id,
323
469
  networkOperation,
324
470
  loadAreasFromNetwork,
325
- loadWindows
471
+ loadWindows,
472
+ isDesktop: !!isDesktop
326
473
  });
327
474
  }
328
475
  const {
329
- addWindowLayout,
330
- addWindowPopUp
331
- } = useStore(areaStoreRef.current, (state) => state.actions, shallow);
332
- const {
333
- loadFromApi
476
+ loadFromApi,
477
+ changeDesktopBreakpoint
334
478
  } = useStore(areaStoreRef.current, (state) => state.internalActions, shallow);
335
479
  const status = useStore(areaStoreRef.current, (state) => state.status, shallow);
336
- const {
337
- openModal,
338
- closeModal
339
- } = useModal();
340
- useImperativeHandle(ref, () => ({
341
- store: areaStoreRef.current,
342
- addWindow
343
- }), []);
344
480
  useEffect(() => {
345
- console.log("useEffect AreaProvider");
481
+ if (!isFirstRender) {
482
+ changeDesktopBreakpoint(!!isDesktop);
483
+ }
484
+ }, [isDesktop]);
485
+ useEffect(() => {
486
+ setAreaLink(id, areaStoreRef.current);
346
487
  return () => {
347
- console.log("useEffect cluanUp AreaProvider****");
348
488
  };
349
489
  }, []);
350
490
  useEffect(() => {
@@ -352,41 +492,16 @@ const AreaProvider = forwardRef((props, ref) => {
352
492
  loadFromApi();
353
493
  }
354
494
  }, [active]);
355
- console.log("Rendeer AreaProvider status", status, loadAreasFromNetwork);
356
- const closeWindowModal = useCallback(() => {
357
- closeModal();
358
- }, []);
359
- const openWindowModal = useCallback((container_id, newWindowProps) => {
360
- openModal({
361
- window: /* @__PURE__ */ jsx(Window, {
362
- ...newWindowProps,
363
- windowId: container_id,
364
- onClose: closeWindowModal
365
- })
366
- });
367
- }, []);
368
- const addWindow = useCallback((newWindow) => {
369
- const newId = `${id}_window_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
370
- if (newWindow.emergeType === "layout") {
371
- addWindowLayout(newId, newWindow);
372
- } else if (newWindow.emergeType === "popup") {
373
- addWindowPopUp(newId, newWindow);
374
- } else {
375
- openWindowModal(newId, newWindow);
376
- }
377
- return newId;
378
- }, []);
379
495
  return /* @__PURE__ */ jsx(AreaContext.Provider, {
380
- value: {
381
- store: areaStoreRef.current,
382
- addWindow
383
- },
496
+ value: areaStoreRef.current,
384
497
  children
385
498
  });
386
- });
499
+ };
387
500
  AreaProvider.displayName = "AreaProvider";
388
501
  React__default.memo(AreaProvider);
389
502
  export {
390
503
  AreaProvider as A,
504
+ CONTAINER_PADDING_GRIDLAYOUT as C,
505
+ ROW_HEIGTH_GRIDLAYOUT as R,
391
506
  AreaContext as a
392
507
  };
@@ -1,8 +1,15 @@
1
- import { NetworkProps } from '@m4l/core';
1
+ import { Maybe, NetworkProps } from '@m4l/core';
2
2
  import { Layout, Layouts } from 'react-grid-layout';
3
3
  import { DebouncedFunc } from 'lodash';
4
- import { HashWindowsByLayouts, HashWindowsByPopups, NewLayoutProps, NewPopUpProps } from '../../components/Area/types';
4
+ import { HashWindowsByLayouts, HashWindowsByPopups, ModalProps, NewLayoutProps, NewModalProps, NewPopUpProps, NewWindowProps } from '../../components/Area/types';
5
5
  export declare type AreaStatus = 'init' | 'load' | 'loaded' | 'error';
6
+ export declare type Breakpoints = {
7
+ [P: string]: number;
8
+ };
9
+ export declare type Cols = {
10
+ [P: string]: number;
11
+ };
12
+ export declare type ViewAreaMode = 'multiple' | 'single';
6
13
  export interface AreaState {
7
14
  zPopUpIndex: number;
8
15
  id: string;
@@ -10,16 +17,26 @@ export interface AreaState {
10
17
  loadWindows: boolean;
11
18
  status: AreaStatus;
12
19
  breakpointsLayouts: Layouts;
20
+ beforeMaximizebreakpointsLayouts: Layouts;
13
21
  gridLayouts: Layout[];
14
22
  windowsPopUps: string[];
23
+ windowModal?: Maybe<ModalProps>;
15
24
  hashWindowsPopups: HashWindowsByPopups;
16
25
  hashWindowsLayouts: HashWindowsByLayouts;
17
26
  networkOperation: (props: NetworkProps) => Promise<any>;
18
27
  currentLayoutId: string;
19
28
  currentPopUpId: string;
29
+ breakpoints: Breakpoints;
30
+ cols: Cols;
31
+ viewMode: ViewAreaMode;
32
+ singleId?: string;
33
+ isDesktop: boolean;
20
34
  }
21
35
  export interface AreaStateWithActions extends AreaState {
22
36
  actions: {
37
+ addWindow: (newWindow: NewWindowProps) => void;
38
+ closeWindowModal: () => void;
39
+ addWindowModal: (container_id: string, newWindowModalProps: NewModalProps) => void;
23
40
  closeWindowPopUp: (removePopUpId: string) => void;
24
41
  addWindowPopUp: (container_id: string, newWindowPopupProps: NewPopUpProps) => void;
25
42
  closeWindowLayout: (removeLayoutId: string) => void;
@@ -29,13 +46,16 @@ export interface AreaStateWithActions extends AreaState {
29
46
  bouncedSaveBreakpointsLayouts: DebouncedFunc<() => void>;
30
47
  selectWindowLayout: (layoutId: string) => void;
31
48
  selectWindowPopUp: (popUpId: string) => void;
49
+ maximizeLayout: (layoutId?: string) => void;
50
+ normalizeLayouts: () => void;
32
51
  };
33
52
  internalActions: {
34
53
  loadFromApi: () => void;
54
+ changeDesktopBreakpoint: (isDesktop: boolean) => void;
35
55
  };
36
56
  }
37
57
  declare type DefaultStoreProps = Omit<AreaState, 'id'>;
38
- declare type InitialStoreProps = Pick<AreaState, 'id' | 'networkOperation' | 'loadAreasFromNetwork' | 'loadWindows'> & Partial<DefaultStoreProps>;
58
+ declare type InitialStoreProps = Pick<AreaState, 'id' | 'networkOperation' | 'loadAreasFromNetwork' | 'loadWindows' | 'isDesktop'> & Partial<DefaultStoreProps>;
39
59
  export declare const createAreaStore: (initProps: InitialStoreProps) => Omit<Omit<import("zustand").StoreApi<AreaStateWithActions>, "setState"> & {
40
60
  setState<A extends string | {
41
61
  type: unknown;
@@ -3,7 +3,7 @@ import { useHostTools, useModuleDictionary, useNetwork, EmitEvents } from "@m4l/
3
3
  import { createStore, useStore } from "zustand";
4
4
  import { devtools } from "zustand/middleware";
5
5
  import { immer } from "zustand/middleware/immer";
6
- import { L as LABEL_NEW_AREA } from "../../index.d1ebea1b.js";
6
+ import { L as LABEL_NEW_AREA } from "../../index.6f09d168.js";
7
7
  import { shallow } from "zustand/shallow";
8
8
  import { useFirstRender } from "@m4l/graphics";
9
9
  import { jsx } from "react/jsx-runtime";
@@ -11,7 +11,6 @@ const addAreaNoBoilerPlate = (state) => {
11
11
  let newName = "";
12
12
  const newId = `area_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
13
13
  newName = `${state.getLabel(LABEL_NEW_AREA)} ${state.areas.length + 1}`;
14
- console.log("addAreaNoBoilerPlate", newName);
15
14
  state.areas.push({ id: newId, name: newName, loadWindows: false });
16
15
  state.currentArea = newId;
17
16
  if (state.loadAreasFromNetwork) {
@@ -69,7 +68,6 @@ const createAreasStore = (initProps) => {
69
68
  });
70
69
  },
71
70
  selectArea: (newAreaId) => {
72
- console.log("Areas selected, ", newAreaId);
73
71
  set((state) => {
74
72
  if (state.areas.findIndex((area) => area.id === newAreaId) > -1) {
75
73
  state.currentArea = newAreaId;
@@ -116,11 +114,12 @@ const createAreasStore = (initProps) => {
116
114
  }
117
115
  }
118
116
  },
119
- setAreaRef: (areaId, ref) => {
117
+ setAreaLink: (areaId, store) => {
120
118
  set((state) => {
121
119
  const areaIndex = state.areas.findIndex((area) => area.id === areaId);
122
- if (areaIndex > -1 && !state.areas[areaIndex].ref) {
123
- state.areas[areaIndex].ref = ref;
120
+ if (areaIndex > -1) {
121
+ state.areas[areaIndex].store = store;
122
+ state.areas[areaIndex].linked = true;
124
123
  }
125
124
  });
126
125
  }
@@ -161,22 +160,17 @@ function AreasProvider(props) {
161
160
  setHandlerGetLabel
162
161
  } = useStore(areasStoreRef.current, (state) => state.internalActions, shallow);
163
162
  const addWindow = useCallback((newWindow) => {
164
- console.log("addWindow raw");
165
163
  const currentArea = areasStoreRef.current?.getState().currentArea;
166
164
  const areas = areasStoreRef.current?.getState().areas;
167
165
  if (currentArea && areas) {
168
166
  const areaIndex = areas.findIndex((area) => area.id == currentArea);
169
- if (areaIndex > -1 && areas[areaIndex].ref) {
170
- const areaRef = areas[areaIndex].ref;
171
- if (areaRef) {
172
- areaRef.addWindow(newWindow);
173
- }
167
+ if (areaIndex > -1 && areas[areaIndex].store) {
168
+ areas[areaIndex].store?.getState().actions.addWindow(newWindow);
174
169
  }
175
170
  }
176
171
  }, []);
177
172
  useEffect(() => {
178
173
  if (status === "loaded") {
179
- console.log("useEffect Areas loaded");
180
174
  onLoad && onLoad();
181
175
  }
182
176
  }, [status]);
@@ -188,7 +182,6 @@ function AreasProvider(props) {
188
182
  useEffect(() => {
189
183
  events_add_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
190
184
  areasStoreRef.current?.getState().internalActions.loadFromApi();
191
- console.log("useEffect AreasProvider Emmiter");
192
185
  return () => {
193
186
  events_remove_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
194
187
  };
@@ -1,7 +1,7 @@
1
- import { AreaProviderRef } from '../AreaContext/types';
2
1
  import { AreaType } from '../../components/Area/types';
3
2
  import { GetLabelType, NetworkProps } from '@m4l/core';
4
3
  import { WritableDraft } from 'immer/dist/internal';
4
+ import { AreaStore } from '../AreaContext/store';
5
5
  export declare type AreasStatus = 'init' | 'loading' | 'loaded' | 'error';
6
6
  export interface AreasState {
7
7
  networkOperation: (props: NetworkProps) => Promise<any>;
@@ -20,7 +20,7 @@ export interface AreasStateWithActions extends AreasState {
20
20
  internalActions: {
21
21
  setHandlerGetLabel: (newHandler: GetLabelType) => void;
22
22
  loadFromApi: () => void;
23
- setAreaRef: (areaId: string, ref: AreaProviderRef) => void;
23
+ setAreaLink: (areaId: string, store: AreaStore) => void;
24
24
  };
25
25
  }
26
26
  declare type DefaultStoreProps = Omit<AreasState, 'currentArea'>;
@@ -6,7 +6,7 @@ import { devtools } from "zustand/middleware";
6
6
  import { immer } from "zustand/middleware/immer";
7
7
  import cloneDeep from "lodash.clonedeep";
8
8
  import { jsx } from "react/jsx-runtime";
9
- import "./AreasContext/index.cbfa4a53.js";
9
+ import "./AreasContext/index.7406c20f.js";
10
10
  function getCookiesContainer(data, containerId) {
11
11
  const cookies = {};
12
12
  try {
@@ -31,7 +31,7 @@ const createWindowStore = (initProps) => {
31
31
  delete startProps.devCookies;
32
32
  return createStore(
33
33
  devtools(
34
- immer((set, get) => ({
34
+ immer((set, get, _api) => ({
35
35
  ...startProps,
36
36
  actions: {
37
37
  setActions: (newActions) => {
@@ -79,7 +79,6 @@ const createWindowStore = (initProps) => {
79
79
  },
80
80
  internalActions: {
81
81
  loadCookiesFromApi: () => {
82
- console.log("loadCookiesFromApi start");
83
82
  if (get().status === "init") {
84
83
  get().networkOperation({
85
84
  method: "GET",
@@ -102,10 +101,6 @@ const createWindowStore = (initProps) => {
102
101
  response.data,
103
102
  state.windowId
104
103
  );
105
- console.log(
106
- "loadCookiesFromApi end",
107
- state.cookies.moduleCookies
108
- );
109
104
  state.status = "loaded";
110
105
  });
111
106
  }).catch((_response) => {
@@ -116,7 +111,6 @@ const createWindowStore = (initProps) => {
116
111
  }
117
112
  },
118
113
  saveModuleCookies: () => {
119
- console.log("saveModuleCookies end", get().cookies.moduleCookies);
120
114
  for (const key in get().cookies.windowCookies) {
121
115
  const cookie = get().cookies.windowCookies[key];
122
116
  get().networkOperation({
@@ -132,7 +126,11 @@ const createWindowStore = (initProps) => {
132
126
  }
133
127
  }
134
128
  })),
135
- { name: `window store ${initProps.windowId}` }
129
+ {
130
+ name: `window store ${initProps.windowId}`,
131
+ store: `window dev store ${initProps.windowId}`,
132
+ trace: true
133
+ }
136
134
  )
137
135
  );
138
136
  };
@@ -162,14 +160,15 @@ function WindowMFProvider(props) {
162
160
  }
163
161
  useEffect(() => {
164
162
  windowStoreRef.current?.getState().internalActions.loadCookiesFromApi();
163
+ return () => {
164
+ console.debug("useEffect cleanUP WindowMFProvider", props.windowId, windowStoreRef.current);
165
+ };
165
166
  }, []);
166
167
  useEffect(() => {
167
168
  if (windowStoreRef.current?.getState().status === "loaded") {
168
- console.log("useEffect Reemplazo de ventan");
169
169
  dynamicMFStoreRef.current?.getState().actions.changeData(props.dynamicParams);
170
170
  }
171
171
  }, [props.dynamicParams]);
172
- console.log("Render WindowProvider");
173
172
  return /* @__PURE__ */ jsx(WindowContext.Provider, {
174
173
  value: windowStoreRef.current,
175
174
  children
@@ -182,10 +181,6 @@ function WindowToolsMFProvider(props) {
182
181
  setActions,
183
182
  ...other
184
183
  } = props;
185
- useEffect(() => {
186
- console.log("useEffect {DynamicMFParmsProvider}", other);
187
- }, []);
188
- console.log("Render WindowToolsMFProvider", other);
189
184
  return /* @__PURE__ */ jsx(WindowToolsMFContext.Provider, {
190
185
  value: {
191
186
  setActions,
@@ -1,6 +1,6 @@
1
1
  import { useContext } from "react";
2
2
  import { useStore } from "zustand";
3
- import { b as WindowContext, c as WindowToolsMFContext } from "../contexts/index.ea2185f5.js";
3
+ import { b as WindowContext, c as WindowToolsMFContext } from "../contexts/index.e80d8f0f.js";
4
4
  import "../contexts/DynamicMFParmsContext/index.c19cb8cc.js";
5
5
  const useWindow = () => {
6
6
  const context = useContext(WindowContext);