@m4l/components 0.1.36 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/{commonjs.bcc6b707.js → commonjs.565e6834.js} +0 -1
  2. package/dist/components/CommonActions/components/ActionCancel/{index.4b36950f.js → index.9230c57b.js} +1 -1
  3. package/dist/components/CommonActions/components/ActionFormCancel/{index.945e9887.js → index.ab514bd9.js} +9 -7
  4. package/dist/components/CommonActions/components/ActionIntro/{index.35a0d240.js → index.a0a341c7.js} +1 -1
  5. package/dist/components/CommonActions/components/Actions/index.d3e1f36e.js +54 -0
  6. package/dist/components/DataGrid/{index.156cc30c.js → index.67260455.js} +663 -15
  7. package/dist/components/DynamicFilter/{index.32f84995.js → index.071aa795.js} +92 -18
  8. package/dist/components/Icon/{index.1dbd3e58.js → index.8d754623.js} +62 -5
  9. package/dist/components/LanguagePopover/index.cbc4b282.js +144 -0
  10. package/dist/components/Loadable/{index.8c6006be.js → index.117eaced.js} +1 -1
  11. package/dist/components/ModalDialog/{index.91777582.js → index.a684827f.js} +5 -5
  12. package/dist/components/ObjectLogs/{index.9d3fc2ae.js → index.4a859658.js} +12 -10
  13. package/dist/components/PaperForm/{index.218a6c4b.js → index.c5948756.js} +1 -1
  14. package/dist/components/Period/{index.74f35862.js → index.abe445bd.js} +9 -7
  15. package/dist/components/Resizeable/{index.44a0dd46.js → index.c96c0f09.js} +1 -1
  16. package/dist/components/SplitLayout/{index.81fc4750.js → index.5a8355d8.js} +1 -1
  17. package/dist/components/animate/PropagateLoader/index.be5b02c3.js +30 -0
  18. package/dist/components/areas/components/AreasAdmin/index.6794b22f.js +112 -0
  19. package/dist/components/areas/components/AreasContainer/index.a2f8899b.js +43 -0
  20. package/dist/components/areas/components/GridLayout/index.b9c1e846.js +92 -0
  21. package/dist/components/areas/components/Window/index.252fbf4e.js +646 -0
  22. package/dist/components/areas/components/WindowPopUp/index.214cf099.js +120 -0
  23. package/dist/components/areas/components/index.7d6cd649.js +67 -0
  24. package/dist/components/areas/contexts/AreaContext/index.4894cf23.js +286 -0
  25. package/dist/components/areas/contexts/AreasContext/index.cd8e4bee.js +158 -0
  26. package/dist/components/areas/contexts/DynamicMFParmsContext/index.668bc2e2.js +17 -0
  27. package/dist/components/areas/contexts/index.f9196fb2.js +1 -0
  28. package/dist/components/areas/hooks/useArea/index.9b85ce24.js +19 -0
  29. package/dist/components/areas/hooks/useDynamicMFParameters/index.e6a44ae3.js +11 -0
  30. package/dist/components/areas/index.d1bf612c.js +16 -0
  31. package/dist/components/formatters/BooleanFormatter/{index.efc8ffc2.js → index.3a9b16c8.js} +1 -1
  32. package/dist/components/formatters/{index.c3f4b687.js → index.0b5f95d0.js} +1 -1
  33. package/dist/components/hook-form/RHFPeriod/{index.2b8e63a2.js → index.3772295b.js} +1 -1
  34. package/dist/components/hook-form/RHFTextField/{index.7feaec71.js → index.b17d68f4.js} +1 -1
  35. package/dist/components/modal/WindowBase.04439b8e.js +120 -0
  36. package/dist/components/modal/WindowConfirm.0b8a6818.js +115 -0
  37. package/dist/components/modal/index.8387e90e.js +18 -0
  38. package/dist/components/mui_extended/Accordion/{index.8e123c57.js → index.a541c71c.js} +2 -2
  39. package/dist/components/mui_extended/Button/index.86a155a2.js +101 -0
  40. package/dist/components/mui_extended/IconButton/{index.e3adaa33.js → index.82f16572.js} +5 -62
  41. package/dist/components/mui_extended/MenuActions/index.ee17bddd.js +112 -0
  42. package/dist/components/mui_extended/Pager/{index.d245f821.js → index.74d3f5fc.js} +66 -1
  43. package/dist/components/mui_extended/Popover/index.53c77d23.js +137 -0
  44. package/dist/components/mui_extended/index.85dfadf1.js +16 -0
  45. package/dist/contexts/ModalContext/{index.0797eb17.js → index.b90eec94.js} +1 -1
  46. package/dist/hooks/useModal/{index.32da4dcb.js → index.d14edee3.js} +1 -1
  47. package/dist/index.js +128 -1691
  48. package/dist/{components/animate/PropagateLoader/index.eb401503.js → node_modules.416f1da3.js} +59 -28
  49. package/dist/package.json +2 -1
  50. package/dist/{react-draggable.3b5b6680.js → react-draggable.84d6b038.js} +1 -1
  51. package/dist/{react-json-view.03ae95f5.js → react-json-view.57125fcf.js} +1 -1
  52. package/dist/{react-resizable.6eae0397.js → react-resizable.1d00271d.js} +3 -4
  53. package/dist/{react-splitter-layout.873aece3.js → react-splitter-layout.8b1655c8.js} +1 -1
  54. package/dist/style.css +0 -114
  55. package/dist/utils/{index.9dce2e2f.js → index.899eb67b.js} +28 -460
  56. package/package.json +3 -1
  57. package/vite.config.ts +201 -129
  58. package/dist/components/CommonActions/components/Actions/index.ba86f72f.js +0 -868
  59. package/dist/components/mui_extended/Button/index.55fc70dc.js +0 -178
  60. package/dist/components/mui_extended/Popover/index.97cf3a3e.js +0 -275
  61. package/dist/node_modules.e0b84fac.js +0 -2154
@@ -0,0 +1,646 @@
1
+ import React__default, { createContext, useState, useContext, useMemo, useRef, useCallback, useEffect } from "react";
2
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import { styled } from "@mui/material/styles";
4
+ import { D as DynamicMFParmsProvider } from "../../contexts/DynamicMFParmsContext/index.668bc2e2.js";
5
+ import "../../../../contexts/ModalContext/index.b90eec94.js";
6
+ import "react-hook-form";
7
+ import "@hookform/resolvers/yup";
8
+ import "../../../../contexts/RHFormContext/index.d88e6e27.js";
9
+ import { useEnvironment, useModuleSkeleton, useModuleDictionary, useNetwork, useHostTools, axiosOperation } from "@m4l/core";
10
+ import { Skeleton, Typography, styled as styled$1 } from "@mui/material";
11
+ import { useResponsiveDesktop, useHostTheme, useFormatter, useLocales, useFirstRender } from "@m4l/graphics";
12
+ import { I as IconButton } from "../../../mui_extended/IconButton/index.82f16572.js";
13
+ import { I as Icon } from "../../../Icon/index.8d754623.js";
14
+ import "../../../mui_extended/Accordion/index.a541c71c.js";
15
+ import "../../../mui_extended/Avatar/index.fe06afd7.js";
16
+ import "react-router-dom";
17
+ import "@mui/material/Button";
18
+ import "@mui/lab";
19
+ import { B as Button } from "../../../mui_extended/Button/index.86a155a2.js";
20
+ import { M as MenuActions } from "../../../mui_extended/MenuActions/index.ee17bddd.js";
21
+ import "../../../mui_extended/Popover/index.53c77d23.js";
22
+ import "../../../mui_extended/Pager/index.74d3f5fc.js";
23
+ import "../../../mui_extended/Tab/index.e0653a0a.js";
24
+ import debounce from "lodash/debounce";
25
+ import { L as LinearProgress } from "../../../mui_extended/LinearProgress/index.c92b9ba9.js";
26
+ import { m } from "framer-motion";
27
+ import { I as Image } from "../../../Image/index.93d5f37f.js";
28
+ import { v as varBounce } from "../../../animate/variants/bounce.784aaaaa.js";
29
+ import "../../../animate/LoadingScreen/index.1d0c4307.js";
30
+ import "../../../animate/PropagateLoader/index.be5b02c3.js";
31
+ const WindowContext = createContext(null);
32
+ function WindowProvider(props) {
33
+ const {
34
+ children,
35
+ initialExternalActions = [],
36
+ ...other
37
+ } = props;
38
+ const [moduleActions, setModuleActions] = useState([]);
39
+ const [externalActions, setExternalActions] = useState(initialExternalActions);
40
+ return /* @__PURE__ */ jsx(WindowContext.Provider, {
41
+ value: {
42
+ moduleActions,
43
+ externalActions,
44
+ setModuleActions,
45
+ setExternalActions,
46
+ ...other
47
+ },
48
+ children
49
+ });
50
+ }
51
+ const WrapperWindow = styled("div")(({ theme }) => ({
52
+ display: "flex",
53
+ flexDirection: "column",
54
+ height: "100%",
55
+ width: "100%",
56
+ overflow: "hidden",
57
+ backgroundColor: theme.palette.background.paper,
58
+ padding: theme.spacing(3),
59
+ border: "1px solid gray",
60
+ "&.m4l_selected": {
61
+ borderTop: "1px solid green"
62
+ }
63
+ }));
64
+ const WrapperContent = styled("div")(() => ({
65
+ flexGrow: 1,
66
+ position: "relative"
67
+ }));
68
+ const useWindow = () => {
69
+ const context = useContext(WindowContext);
70
+ if (!context)
71
+ throw new Error("useWindow context must be use inside WindowContext");
72
+ return context;
73
+ };
74
+ const Component = (props) => {
75
+ const {
76
+ setModuleActions
77
+ } = useWindow();
78
+ return /* @__PURE__ */ jsx(DynamicMFParmsProvider, {
79
+ setModuleActions,
80
+ children: props.children
81
+ });
82
+ };
83
+ React__default.memo(Component);
84
+ const StyledHeader = styled("div")(({
85
+ theme
86
+ }) => ({
87
+ display: "flex",
88
+ alignItems: "center",
89
+ position: "relative",
90
+ justifyContent: "space-between",
91
+ minHeight: theme.spacing(5),
92
+ borderBottom: `1px solid ${theme.palette.divider}`,
93
+ overflow: "hidden",
94
+ cursor: "move",
95
+ height: "60px",
96
+ " > span": {
97
+ marginRight: "12px"
98
+ },
99
+ "& > h5": {
100
+ paddingRight: theme.spacing(3),
101
+ borderRight: `1px solid ${theme.palette.divider}`
102
+ },
103
+ " > nav": {
104
+ marginRight: "12px",
105
+ flexGrow: 1
106
+ },
107
+ "& .splitactions.Mui-disabled": {
108
+ color: theme.palette.primary.main
109
+ },
110
+ "& svg ": {
111
+ width: "20px",
112
+ height: "20px"
113
+ }
114
+ }));
115
+ styled("div")(({
116
+ theme
117
+ }) => ({
118
+ display: "flex",
119
+ alignItems: "center",
120
+ position: "relative",
121
+ borderBottom: `1px solid ${theme.palette.divider}`,
122
+ height: "60px",
123
+ minHeight: "60px",
124
+ " > span": {
125
+ marginRight: "12px"
126
+ },
127
+ "& > h5": {
128
+ paddingRight: theme.spacing(3),
129
+ borderRight: `1px solid ${theme.palette.divider}`
130
+ },
131
+ " > nav": {
132
+ marginRight: "12px",
133
+ flexGrow: 1
134
+ },
135
+ "& .splitactions.Mui-disabled": {
136
+ color: theme.palette.primary.main
137
+ },
138
+ "& svg ": {
139
+ width: "20px",
140
+ height: "20px"
141
+ }
142
+ }));
143
+ const Wrapper = styled("div")(({
144
+ theme
145
+ }) => ({
146
+ display: "flex",
147
+ justifyContent: "space-between",
148
+ padding: `0 0`,
149
+ borderBottom: `1px solid ${theme.palette.divider}`,
150
+ minHeight: "60px"
151
+ }));
152
+ const ModuleTitleContent = styled("div")(({
153
+ theme
154
+ }) => ({
155
+ display: "grid",
156
+ gridTemplateColumns: "auto",
157
+ gridGap: theme.spacing(1.75),
158
+ alignItems: "center",
159
+ width: "auto",
160
+ height: "auto",
161
+ [theme.breakpoints.up("sm")]: {
162
+ gridTemplateColumns: "repeat(3, auto)"
163
+ }
164
+ }));
165
+ const ModuleTitle = styled("div")(({
166
+ theme
167
+ }) => ({
168
+ display: "grid",
169
+ gridTemplateColumns: `${theme.spacing(3)} auto`,
170
+ gridGap: theme.spacing(2),
171
+ alignItems: "center",
172
+ width: "auto",
173
+ height: "auto"
174
+ }));
175
+ const Separator = styled("div")(({
176
+ theme
177
+ }) => ({
178
+ display: "none",
179
+ alignItems: "center",
180
+ width: "1px",
181
+ background: theme.palette.divider,
182
+ height: "100%",
183
+ margin: `0 ${theme.spacing(2)}`,
184
+ [theme.breakpoints.up("sm")]: {
185
+ display: "flex"
186
+ }
187
+ }));
188
+ const Breadcrumbs = styled("div")(({
189
+ theme
190
+ }) => ({
191
+ display: "grid",
192
+ alignItems: "center",
193
+ gridTemplateColumns: `repeat(3, auto)`,
194
+ gridGap: theme.spacing(2)
195
+ }));
196
+ const ModuleActions = styled("div")(({
197
+ theme
198
+ }) => ({
199
+ display: "grid",
200
+ gridTemplateColumns: "auto",
201
+ alignItems: "center",
202
+ width: "auto",
203
+ height: "auto",
204
+ [theme.breakpoints.up("sm")]: {
205
+ gridTemplateColumns: `repeat(3, ${theme.spacing(3)})`,
206
+ gridGap: theme.spacing(2)
207
+ }
208
+ }));
209
+ function SKTModuleHeader() {
210
+ const isDesktop = useResponsiveDesktop();
211
+ return /* @__PURE__ */ jsxs(Wrapper, {
212
+ id: "HeaderSkeleton",
213
+ children: [/* @__PURE__ */ jsxs(ModuleTitleContent, {
214
+ children: [/* @__PURE__ */ jsxs(ModuleTitle, {
215
+ children: [/* @__PURE__ */ jsx(Skeleton, {
216
+ variant: "circular",
217
+ width: 24,
218
+ height: 24
219
+ }), /* @__PURE__ */ jsx(Skeleton, {
220
+ variant: "text",
221
+ width: 120,
222
+ height: 14
223
+ })]
224
+ }), /* @__PURE__ */ jsx(Separator, {}), /* @__PURE__ */ jsxs(Breadcrumbs, {
225
+ children: [/* @__PURE__ */ jsx(Skeleton, {
226
+ variant: "text",
227
+ width: 68,
228
+ height: 14
229
+ }), /* @__PURE__ */ jsx(Skeleton, {
230
+ variant: "circular",
231
+ width: 4,
232
+ height: 4
233
+ }), /* @__PURE__ */ jsx(Skeleton, {
234
+ variant: "text",
235
+ width: 68,
236
+ height: 14
237
+ })]
238
+ })]
239
+ }), /* @__PURE__ */ jsx(ModuleActions, {
240
+ children: isDesktop ? /* @__PURE__ */ jsxs(Fragment, {
241
+ children: [/* @__PURE__ */ jsx(Skeleton, {
242
+ variant: "circular",
243
+ width: 24,
244
+ height: 24
245
+ }), /* @__PURE__ */ jsx(Skeleton, {
246
+ variant: "circular",
247
+ width: 24,
248
+ height: 24
249
+ }), /* @__PURE__ */ jsx(Skeleton, {
250
+ variant: "circular",
251
+ width: 24,
252
+ height: 24
253
+ })]
254
+ }) : /* @__PURE__ */ jsx(Skeleton, {
255
+ variant: "circular",
256
+ width: 24,
257
+ height: 24
258
+ })
259
+ })]
260
+ });
261
+ }
262
+ function getMenuActions(isDesktop, moduleActions) {
263
+ let menuActions = [...moduleActions.filter((action) => action.visibility !== "allways")];
264
+ if (isDesktop !== void 0 && isDesktop) {
265
+ menuActions = menuActions.filter((action) => action.visibility === "normal");
266
+ }
267
+ return menuActions;
268
+ }
269
+ function getMainActions(isDesktop, moduleActions) {
270
+ let mainActions = [];
271
+ if (isDesktop !== void 0 && isDesktop) {
272
+ mainActions = mainActions.concat(moduleActions.filter((action) => action.visibility === "main"));
273
+ }
274
+ mainActions = mainActions.concat(moduleActions.filter((action) => action.visibility === "allways"));
275
+ return mainActions;
276
+ }
277
+ function Header() {
278
+ const {
279
+ url_icon,
280
+ title,
281
+ moduleActions,
282
+ onClose,
283
+ container_id
284
+ } = useWindow();
285
+ const {
286
+ host_static_assets,
287
+ environment_assets
288
+ } = useEnvironment();
289
+ const isDesktop = useResponsiveDesktop();
290
+ const isSkeleton = useModuleSkeleton();
291
+ const menuActions = useMemo(() => getMenuActions(isDesktop, moduleActions), [moduleActions, isDesktop]);
292
+ const mainActions = useMemo(() => {
293
+ return getMainActions(isDesktop, moduleActions);
294
+ }, [moduleActions, isDesktop]);
295
+ const onCloseLocal = () => {
296
+ onClose && onClose(container_id);
297
+ };
298
+ if (isSkeleton) {
299
+ return /* @__PURE__ */ jsx(SKTModuleHeader, {});
300
+ }
301
+ return /* @__PURE__ */ jsxs(StyledHeader, {
302
+ id: "Header",
303
+ className: "m4l_draggable_handle",
304
+ children: [/* @__PURE__ */ jsx(Icon, {
305
+ src: url_icon,
306
+ bgColor: "primary.main",
307
+ size: "24px"
308
+ }), /* @__PURE__ */ jsx(Typography, {
309
+ variant: "h5",
310
+ sx: {
311
+ maxWidth: 260,
312
+ overflow: "hidden",
313
+ whiteSpace: "nowrap",
314
+ color: "text.primary",
315
+ marginLeft: "12px",
316
+ marginRight: "24px",
317
+ textOverflow: "ellipsis"
318
+ },
319
+ children: title
320
+ }), mainActions.map((mainAction, index) => {
321
+ if (!mainAction.component) {
322
+ return /* @__PURE__ */ jsx(IconButton, {
323
+ src: mainAction.urlIcon,
324
+ className: mainAction.className,
325
+ onClick: mainAction.onClick,
326
+ "aria-label": mainAction.label,
327
+ disabled: mainAction.disabled
328
+ }, `main_action_${index}`);
329
+ }
330
+ return /* @__PURE__ */ jsx(mainAction.component, {
331
+ description: mainAction.label,
332
+ onClick: mainAction.onClick
333
+ }, `main_action_${index}`);
334
+ }), menuActions.length > 0 && /* @__PURE__ */ jsx(MenuActions, {
335
+ arrowType: "right-top",
336
+ marginTop: "11px",
337
+ anchorOrigin: {
338
+ vertical: "top",
339
+ horizontal: "left"
340
+ },
341
+ transformOrigin: {
342
+ vertical: "top",
343
+ horizontal: "right"
344
+ },
345
+ menuActions
346
+ }), onClose && /* @__PURE__ */ jsx(IconButton, {
347
+ onClick: onCloseLocal,
348
+ "aria-label": "click",
349
+ src: `${host_static_assets}/${environment_assets}/frontend/components/window/assets/icons/close.svg`
350
+ })]
351
+ });
352
+ }
353
+ const WrapperLinearProgress = styled$1("div")(() => ({
354
+ width: "70%",
355
+ margin: "auto auto"
356
+ }));
357
+ const WrapperFallBackNotFound = styled$1("div")(({
358
+ theme
359
+ }) => ({
360
+ width: "100%",
361
+ height: "100%",
362
+ display: "flex",
363
+ flexDirection: "column",
364
+ justifyContent: "center",
365
+ alignItems: "center",
366
+ gap: theme.spacing(3)
367
+ }));
368
+ function FallBackNotFound(props) {
369
+ const {
370
+ setNetworkRefresh
371
+ } = props;
372
+ const {
373
+ getLabel
374
+ } = useModuleDictionary();
375
+ const {
376
+ host_static_assets,
377
+ environment_assets
378
+ } = useEnvironment();
379
+ const handlerClick = () => {
380
+ setNetworkRefresh((prop) => !prop);
381
+ };
382
+ return /* @__PURE__ */ jsxs(WrapperFallBackNotFound, {
383
+ children: [/* @__PURE__ */ jsx(m.div, {
384
+ variants: varBounce().in,
385
+ children: /* @__PURE__ */ jsx(Typography, {
386
+ variant: "h3",
387
+ paragraph: true,
388
+ children: getLabel("loading_mf_title")
389
+ })
390
+ }), /* @__PURE__ */ jsx(Typography, {
391
+ sx: {
392
+ color: "text.secondary"
393
+ },
394
+ children: getLabel("loading_mf_description")
395
+ }), /* @__PURE__ */ jsx(m.div, {
396
+ variants: varBounce().in,
397
+ children: /* @__PURE__ */ jsx(Image, {
398
+ src: `${host_static_assets}/${environment_assets}/frontend/domain/host/commons/assets/img/illustration_noauth.png`,
399
+ width: "292px",
400
+ height: "219px"
401
+ })
402
+ }), /* @__PURE__ */ jsx(Button, {
403
+ size: "large",
404
+ variant: "contained",
405
+ onClick: handlerClick,
406
+ children: getLabel("loading_mf_intro")
407
+ })]
408
+ });
409
+ }
410
+ const LoadingMF = (props) => {
411
+ const {
412
+ loadingProgress,
413
+ setNetworkRefresh
414
+ } = props;
415
+ if (loadingProgress !== -1) {
416
+ return /* @__PURE__ */ jsx(WrapperLinearProgress, {
417
+ id: "WrapperLinearProgress",
418
+ children: /* @__PURE__ */ jsx(LinearProgress, {
419
+ variant: "determinate",
420
+ value: loadingProgress
421
+ })
422
+ });
423
+ }
424
+ return /* @__PURE__ */ jsx(FallBackNotFound, {
425
+ setNetworkRefresh
426
+ });
427
+ };
428
+ function getDivScritId(prefix, moduleId) {
429
+ const rotational_id = `${Math.round(new Date().getTime() / 1e3)}_rnd_${Math.round(Math.random() * 1e3)}`;
430
+ return {
431
+ divContainerId: `container_${prefix}_${moduleId}_${rotational_id}`,
432
+ scriptId: `script_${moduleId}_${rotational_id}`,
433
+ moduleId
434
+ };
435
+ }
436
+ function MFLoader(props) {
437
+ const {
438
+ prefix,
439
+ module_id,
440
+ cache = true,
441
+ debug_port,
442
+ dynamicParams
443
+ } = props;
444
+ const {
445
+ hostThemeOptions,
446
+ fnComponentsOverrides
447
+ } = useHostTheme();
448
+ const {
449
+ networkOperation
450
+ } = useNetwork();
451
+ const environment = useEnvironment();
452
+ const hostTools = useHostTools();
453
+ const formatter = useFormatter();
454
+ const [isLoading, setIsLoading] = useState(true);
455
+ const [networkProgress, setNetworkProgress] = useState(-1);
456
+ const [_networkRefresh, setNetworkRefresh] = useState(false);
457
+ const {
458
+ currentLocale
459
+ } = useLocales();
460
+ const [divScript, setDivScript] = useState(getDivScritId(prefix, module_id));
461
+ const refTime = useRef(0);
462
+ const isFirstRender = useFirstRender([module_id]);
463
+ const final_host = environment.isLocalhost ? `https://localhost:${debug_port}` : `https://${window.location.host}/mf/${module_id}`;
464
+ function cleanUp(dScript) {
465
+ try {
466
+ if (window[`unmount_${prefix}_${dScript.moduleId}`]) {
467
+ window[`unmount_${prefix}_${dScript.moduleId}`](dScript.divContainerId);
468
+ }
469
+ } catch (error) {
470
+ }
471
+ if (!cache) {
472
+ const script = document.getElementById(dScript.scriptId);
473
+ if (script) {
474
+ try {
475
+ document.head.removeChild(script);
476
+ delete window[`render_${prefix}_${dScript.moduleId}`];
477
+ delete window[`unmount_${prefix}_${dScript.moduleId}`];
478
+ } catch (error) {
479
+ }
480
+ }
481
+ }
482
+ }
483
+ const renderMicroFrontend = useCallback((newDScript) => {
484
+ try {
485
+ setIsLoading(false);
486
+ window[`render_${prefix}_${newDScript.moduleId}`](newDScript.divContainerId, environment, hostTools, currentLocale, {
487
+ hostThemeOptions,
488
+ fnComponentsOverrides
489
+ }, axiosOperation, formatter, {
490
+ version: 1,
491
+ ...dynamicParams ? dynamicParams : {}
492
+ });
493
+ } catch (error) {
494
+ }
495
+ }, [hostThemeOptions, currentLocale, formatter, dynamicParams]);
496
+ const debouncedSetDivScript = useCallback(debounce((newName) => {
497
+ const newDivScript = getDivScritId(prefix, newName);
498
+ if (newName !== divScript.moduleId) {
499
+ setDivScript({
500
+ ...newDivScript
501
+ });
502
+ }
503
+ }, 200), [divScript]);
504
+ useEffect(() => {
505
+ if (!isFirstRender) {
506
+ debouncedSetDivScript(module_id + "");
507
+ if (module_id !== divScript.moduleId)
508
+ ;
509
+ }
510
+ return () => {
511
+ };
512
+ }, [module_id]);
513
+ useEffect(() => {
514
+ setIsLoading(true);
515
+ let mounted = true;
516
+ const controller = new AbortController();
517
+ const dsScript = {
518
+ ...divScript
519
+ };
520
+ const loadIfNotLoaded = async () => {
521
+ if (!window[`render_${prefix}_${module_id}`]) {
522
+ let urlFile = "";
523
+ setNetworkProgress(0);
524
+ const manifest = await fetch(`${final_host}/manifest.json?rnd=${Math.random()}`).then((res) => res.json()).catch(() => {
525
+ console.debug("Error fetching manifest", `${final_host}/manifest.json`);
526
+ return void 0;
527
+ });
528
+ if (!manifest) {
529
+ return;
530
+ }
531
+ setNetworkProgress(10);
532
+ if (mounted) {
533
+ urlFile = `${final_host}/${manifest["src/index.tsx"]["file"]}?rnd=${Math.random()}`;
534
+ refTime.current = 0;
535
+ await networkOperation({
536
+ method: "GET",
537
+ endPoint: urlFile,
538
+ isRemote: !environment.isLocalhost,
539
+ headers: {
540
+ "Content-Type": "application/json"
541
+ },
542
+ onDownloadProgress: (progressEvent) => {
543
+ let percentCompleted = 0;
544
+ try {
545
+ if (progressEvent.lengthComputable) {
546
+ percentCompleted = 10 + Math.round(progressEvent.loaded * 90 / progressEvent.total);
547
+ } else {
548
+ if (refTime.current === 0) {
549
+ refTime.current = new Date().getTime();
550
+ }
551
+ percentCompleted = 10 + progressEvent.loaded / 15e5 * 90;
552
+ if (percentCompleted > 95)
553
+ percentCompleted = 95;
554
+ }
555
+ } catch (error) {
556
+ }
557
+ if (mounted) {
558
+ setNetworkProgress(percentCompleted);
559
+ }
560
+ },
561
+ isExternalUrl: true,
562
+ responseType: "text",
563
+ signal: controller.signal
564
+ }).then(() => {
565
+ if (mounted) {
566
+ setNetworkProgress(100);
567
+ }
568
+ }).catch(() => {
569
+ });
570
+ if (mounted) {
571
+ const script = document.createElement("script");
572
+ script.id = divScript.scriptId;
573
+ script.crossOrigin = "";
574
+ script.type = "module";
575
+ script.src = urlFile || "";
576
+ script.onload = () => {
577
+ if (mounted) {
578
+ console.debug("Script loaded", new Date().getTime());
579
+ setNetworkProgress(100);
580
+ renderMicroFrontend(dsScript);
581
+ }
582
+ };
583
+ document.head.appendChild(script);
584
+ console.debug("Script appened", new Date().getTime());
585
+ }
586
+ }
587
+ } else {
588
+ if (mounted) {
589
+ renderMicroFrontend(dsScript);
590
+ }
591
+ }
592
+ };
593
+ loadIfNotLoaded();
594
+ return () => {
595
+ mounted = false;
596
+ controller.abort();
597
+ cleanUp(dsScript);
598
+ };
599
+ }, [divScript]);
600
+ console.log("Render micro frontend", divScript.divContainerId, final_host);
601
+ return /* @__PURE__ */ jsxs(Fragment, {
602
+ children: [/* @__PURE__ */ jsx("div", {
603
+ id: divScript.divContainerId
604
+ }), isLoading ? /* @__PURE__ */ jsx(LoadingMF, {
605
+ loadingProgress: networkProgress,
606
+ setNetworkRefresh
607
+ }) : null]
608
+ });
609
+ }
610
+ MFLoader.defaultProps = {
611
+ document,
612
+ window
613
+ };
614
+ const MicroFrontend = (props) => {
615
+ const {
616
+ setModuleActions
617
+ } = useWindow();
618
+ return /* @__PURE__ */ jsx(MFLoader, {
619
+ ...props,
620
+ dynamicParams: {
621
+ ...props.dynamicParams,
622
+ setModuleActions
623
+ }
624
+ });
625
+ };
626
+ React__default.memo(MicroFrontend);
627
+ const Window = (props) => {
628
+ return /* @__PURE__ */ jsx(WrapperWindow, {
629
+ children: /* @__PURE__ */ jsxs(WindowProvider, {
630
+ initialExternalActions: [],
631
+ ...props,
632
+ children: [/* @__PURE__ */ jsx(Header, {}), /* @__PURE__ */ jsx(WrapperContent, {
633
+ children: props.winType === "microfrontend" ? /* @__PURE__ */ jsx(MicroFrontend, {
634
+ ...props.mfProps
635
+ }) : /* @__PURE__ */ jsx(Component, {
636
+ children: props.component
637
+ })
638
+ })]
639
+ })
640
+ });
641
+ };
642
+ const MemonizedWindow = React__default.memo(Window);
643
+ export {
644
+ MemonizedWindow as M,
645
+ Window as W
646
+ };