@m4l/components 0.1.65 → 0.1.67

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