@m4l/components 3.1.7 → 3.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +183 -340
- package/node_modules-CQtkw0uG.js +7350 -0
- package/package.json +1 -1
- package/vendor-AfIOyqRr.js +24636 -0
- package/components/AccountPopover/index-Dm2-k-Mv.js +0 -334
- package/components/AppBar/index-i0rhG3J1.js +0 -93
- package/components/BaseModule/index-CiNNlxzS.js +0 -30
- package/components/CommonActions/components/ActionCancel/index-CIdpDXkr.js +0 -12
- package/components/CommonActions/components/ActionFormCancel/index-CpyASN3q.js +0 -56
- package/components/CommonActions/components/ActionFormIntro/index-7KKtcUra.js +0 -33
- package/components/CommonActions/components/ActionIntro/index-CqqDZZcG.js +0 -25
- package/components/CommonActions/components/Actions/index-CuG1pnXW.js +0 -70
- package/components/DataGrid/constants-8L7QgBKi.js +0 -10
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index-CveSCbq_.js +0 -26
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index-CHqvieM2.js +0 -22
- package/components/DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js +0 -19
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index-DE6bwaKP.js +0 -23
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index-BslXGK-A.js +0 -14
- package/components/DataGrid/formatters/ColumnPointsFormatter/index-BXGW2CsK.js +0 -10
- package/components/DataGrid/formatters/ColumnPriceFormatter/index-O11tBykn.js +0 -10
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js +0 -36
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index-Cq7a-jnE.js +0 -10
- package/components/DataGrid/formatters/index-CrZXPa0e.js +0 -13
- package/components/DataGrid/index-BZ-lbmuU.js +0 -908
- package/components/DataGrid/subcomponents/Actions/index-CHvPZ4Ru.js +0 -549
- package/components/DataGrid/subcomponents/editors/TextEditor/index-BIFm8akr.js +0 -80
- package/components/DragResizeWindow/index-D2jLYExo.js +0 -505
- package/components/DynamicFilter/constants-ByqmFATV.js +0 -31
- package/components/DynamicFilter/dictionary-PrbXU3VZ.js +0 -51
- package/components/DynamicFilter/index-DZiJc9h7.js +0 -116
- package/components/DynamicFilter/slots/SlotsEnum-cawFeNzx.js +0 -34
- package/components/DynamicFilter/slots/dynamicFilterSlots-DHxelhXP.js +0 -151
- package/components/DynamicFilter/slots/index-l0sNRNKZ.js +0 -1
- package/components/DynamicFilter/store/index-BT-eWVnJ.js +0 -254
- package/components/DynamicFilter/subcomponents/AppliedFilterChip/index-B32bAzi-.js +0 -60
- package/components/DynamicFilter/subcomponents/AppliedFilters/index-Bha19drV.js +0 -26
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/index-BmvzoHit.js +0 -40
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index-BcO3SlP5.js +0 -129
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index-BCJhpNS8.js +0 -171
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index-DCNhz68u.js +0 -153
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index-BdypjM1Y.js +0 -146
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index-D-NFIVnK.js +0 -114
- package/components/DynamicFilter/subcomponents/FieldTypes/index-BwQHJqk9.js +0 -38
- package/components/DynamicFilter/subcomponents/FilterActions/index-B9UWmk07.js +0 -88
- package/components/DynamicFilter/subcomponents/InputFilter/index-CfGb1TfV.js +0 -188
- package/components/DynamicFilter/subcomponents/PopoverFilter/index-DkfRGrlO.js +0 -158
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/index-DSegwAm2.js +0 -63
- package/components/FieldLabel/index-CI57EizR.js +0 -54
- package/components/GridLayout/index-C4HyxNYX.js +0 -1044
- package/components/GridLayout/subcomponents/Griditem/index-C7jT4s8t.js +0 -395
- package/components/GridLayout/subcomponents/Responsive/index-BKcU2OnF.js +0 -348
- package/components/GridLayout/subcomponents/SizeProvider/index-1aJ-e_54.js +0 -71
- package/components/HelperText/index-Crn_XIPF.js +0 -50
- package/components/Icon/index-C89MAkeH.js +0 -176
- package/components/Image/index-COp8vP0X.js +0 -175
- package/components/LanguagePopover/index-BA2Igs9L.js +0 -179
- package/components/LinearProgressIndeterminate/index-BwI756Mb.js +0 -55
- package/components/Loadable/index-BMbi9ISF.js +0 -9
- package/components/LoadingError/index-Cf0oGUrL.js +0 -89
- package/components/MFIsolationApp/index-V4R55hNU.js +0 -169
- package/components/MFLoader/index-BI8vQZSH.js +0 -299
- package/components/ModalDialog/index-CEVQBQ7W.js +0 -77
- package/components/NavLink/index-D1S_vtFO.js +0 -55
- package/components/NoItemSelected/index-B9oM26AX.js +0 -54
- package/components/ObjectLogs/index-CiXOJpS4.js +0 -233
- package/components/PDFViewer/index-GVN2rfd6.js +0 -51
- package/components/Page/index-DZMkYmr4.js +0 -117
- package/components/PaperForm/index-DwgAfjci.js +0 -59
- package/components/Period/index-2pJG3VmY.js +0 -238
- package/components/PrintingSystem/index-B2qcnfw0.js +0 -187
- package/components/PrintingSystem/subcomponents/BodyNode/index-Cv2aoy8S.js +0 -49
- package/components/PrintingSystem/subcomponents/ChartNode/index-BmJm8v_C.js +0 -105
- package/components/PrintingSystem/subcomponents/DividerNode/index-MpFhE-H0.js +0 -20
- package/components/PrintingSystem/subcomponents/FooterNode/index-ZEcWdMSM.js +0 -49
- package/components/PrintingSystem/subcomponents/GridNode/index-SsKax2xu.js +0 -74
- package/components/PrintingSystem/subcomponents/HeaderNode/index-Cs8TOOBL.js +0 -49
- package/components/PrintingSystem/subcomponents/PaperNode/index-DBb25Ecg.js +0 -30
- package/components/PrintingSystem/subcomponents/PropertyValueNode/index-CTVn7J9Q.js +0 -47
- package/components/PrintingSystem/subcomponents/SectionNode/index-iYPM3EaS.js +0 -49
- package/components/PrintingSystem/subcomponents/TextBoxNode/index-DGjXCFKJ.js +0 -24
- package/components/PropertyValue/index-Bh-Jnrte.js +0 -264
- package/components/Resizeable/index-DdP1xfE9.js +0 -20
- package/components/ScrollBar/index-f2URPPE2.js +0 -35
- package/components/ScrollToTop/index-TxORk5dB.js +0 -12
- package/components/SideBar/index-PUBBe0yH.js +0 -758
- package/components/SplitLayout/index-Bu1hcO6G.js +0 -89
- package/components/ToastContainer/index-DK1d8NNd.js +0 -191
- package/components/WrapperComponent/index-BHV-CsDU.js +0 -14
- package/components/animate/LoadingScreen/index-CkVLOrMz.js +0 -70
- package/components/animate/MotionContainer/index-eartnWyO.js +0 -34
- package/components/animate/MotionLazyContainer/index-Be8osTiG.js +0 -9
- package/components/animate/PropagateLoader/index-Bkq8V2SN.js +0 -23
- package/components/animate/features-BbnE33u3.js +0 -5
- package/components/animate/index-BsWiJfzp.js +0 -89
- package/components/animate/variants/bounce-DanQqHAX.js +0 -101
- package/components/animate/variants/container-Dmpr6tg5.js +0 -22
- package/components/animate/variants/fade-CAOJNn06.js +0 -65
- package/components/animate/variants/index-l0sNRNKZ.js +0 -1
- package/components/animate/variants/transition-B9W5SWTa.js +0 -20
- package/components/areas/components/AreasAdmin/index-OxQU3P8Y.js +0 -699
- package/components/areas/components/AreasViewer/index-DQ0aPioP.js +0 -805
- package/components/areas/components/index-l0sNRNKZ.js +0 -1
- package/components/areas/constants-rqODZNZe.js +0 -6
- package/components/areas/contexts/AreasContext/index-BqRlA7JA.js +0 -1110
- package/components/areas/contexts/DynamicMFParmsContext/index-22c6E7vK.js +0 -36
- package/components/areas/contexts/WindowToolsMFContext/index-DkE30fhm.js +0 -12
- package/components/areas/contexts/index-l0sNRNKZ.js +0 -1
- package/components/areas/dictionary-YUsP9beq.js +0 -36
- package/components/areas/hooks/index-l0sNRNKZ.js +0 -1
- package/components/areas/hooks/useAreas/index-BSbwbJLS.js +0 -11
- package/components/areas/hooks/useDynamicMFParameters/index-DhbcZPs9.js +0 -12
- package/components/areas/hooks/useSetWindowsTitle/useSetWindowsTitle-BzPD-miW.js +0 -31
- package/components/areas/hooks/useWindowToolsMF/index-BECQfhbC.js +0 -10
- package/components/areas/icons-CwFr-alN.js +0 -24
- package/components/areas/index-B_Odny9h.js +0 -22
- package/components/commercial/AppBarCommercial/index-CHq3P3GY.js +0 -28
- package/components/commercial/SectionCommercial/index-BeABGtdr.js +0 -56
- package/components/commercial/TopBar/index-F1repmti.js +0 -232
- package/components/commercial/index-CxDzs6Ax.js +0 -81
- package/components/formatters/BooleanFormatter/index-DktIidqW.js +0 -44
- package/components/formatters/DateFormatter/index-CGcRZ8BA.js +0 -43
- package/components/formatters/PointsFormatter/index-C7sR8iqk.js +0 -25
- package/components/formatters/PriceFormatter/index-CsvRawmc.js +0 -35
- package/components/formatters/UncertaintyFormatter/index-B9ESVEVp.js +0 -29
- package/components/formatters/index-pnJhDYKe.js +0 -109
- package/components/hook-form/HelperError/index-BVnmUazV.js +0 -19
- package/components/hook-form/RHFAutocomplete/index-BtPL16HR.js +0 -657
- package/components/hook-form/RHFAutocompleteAsync/index-BfzjLHG8.js +0 -226
- package/components/hook-form/RHFCheckbox/index-Vyttu8Vx.js +0 -132
- package/components/hook-form/RHFColorPicker/index-Cxxb5Wa_.js +0 -191
- package/components/hook-form/RHFDateTime/index-CW1Slb-f.js +0 -190
- package/components/hook-form/RHFMultiCheckbox/index-BARudV1A.js +0 -34
- package/components/hook-form/RHFPeriod/index-r-HeIOoZ.js +0 -98
- package/components/hook-form/RHFRadioGroup/index-CTD-0zKo.js +0 -52
- package/components/hook-form/RHFSelect/index-LdwRuFz-.js +0 -29
- package/components/hook-form/RHFTextField/index-B6ufruSB.js +0 -337
- package/components/hook-form/RHFUpload/index-CDPbm8NR.js +0 -253
- package/components/maps/components/GpsTools/index-5MXlhIEt.js +0 -1948
- package/components/maps/components/Map/index-2Lx5ARXa.js +0 -2546
- package/components/maps/index-Ci-7-FHg.js +0 -7
- package/components/modal/WindowBase-Gd27v5FU.js +0 -44
- package/components/modal/WindowConfirm-u6vAMFo7.js +0 -73
- package/components/modal/index-CydPIpKZ.js +0 -65
- package/components/mui_extended/Accordion/index-DMLYJL7o.js +0 -124
- package/components/mui_extended/Avatar/index-ClBa-6eF.js +0 -64
- package/components/mui_extended/Badge/index-zI-F_Qkq.js +0 -29
- package/components/mui_extended/BoxIcon/index-BUTJ2tKw.js +0 -22
- package/components/mui_extended/Breadcrumbs/index-DTS7rOZH.js +0 -86
- package/components/mui_extended/Button/index-CGfZbaea.js +0 -222
- package/components/mui_extended/CheckBox-BXUrbonB.js +0 -76
- package/components/mui_extended/CircularProgress/index-Bnnti_G6.js +0 -8
- package/components/mui_extended/IconButton/classes/constants-ChY2jKkp.js +0 -4
- package/components/mui_extended/IconButton/classes/index-BxjJGAqZ.js +0 -45
- package/components/mui_extended/IconButton/index-CusYFjie.js +0 -97
- package/components/mui_extended/IconButton/styledIconButton-fAsbGoFS.js +0 -7
- package/components/mui_extended/LinearProgress/index-CGgW8jq2.js +0 -9
- package/components/mui_extended/LinkWithRoute/index-BC2miUjR.js +0 -15
- package/components/mui_extended/MenuActions/MenuActions-C6CjSU6C.js +0 -149
- package/components/mui_extended/MenuActions/constants-BwsU9chA.js +0 -10
- package/components/mui_extended/MenuActions/dictionary-Dj_07puT.js +0 -11
- package/components/mui_extended/MenuActions/slots/MenuActionsEnum-Bu-L6eWU.js +0 -13
- package/components/mui_extended/MenuActions/slots/MenuActionsSlots-D65KZAKF.js +0 -46
- package/components/mui_extended/Pager/index-DCbxiTZA.js +0 -257
- package/components/mui_extended/Popover/index-DfrJAQkV.js +0 -153
- package/components/mui_extended/Stack/index-DzEeCYfp.js +0 -31
- package/components/mui_extended/Tab/index-Bu3dPidV.js +0 -129
- package/components/mui_extended/ToggleButton/index-C9cBkT1V.js +0 -18
- package/components/mui_extended/ToggleIconButton/index--0b3Td6C.js +0 -26
- package/components/mui_extended/Tooltip/index-B8QUytCK.js +0 -42
- package/components/mui_extended/Typography/index-Cf_4Zw8f.js +0 -54
- package/components/mui_extended/index-l0sNRNKZ.js +0 -1
- package/components/popups/PopupsProvider/index-DhSxmtfJ.js +0 -172
- package/components/popups/PopupsViewer/constants-DuyD7aCn.js +0 -4
- package/components/popups/PopupsViewer/icons-BUujqqbu.js +0 -7
- package/components/popups/PopupsViewer/index-BecevSns.js +0 -172
- package/components/popups/PopupsViewer/slots/index-B98CiRLa.js +0 -14
- package/components/popups/PopupsViewer/slots/popupsViewerSlots-BXH77nCF.js +0 -46
- package/components/popups/index-l0sNRNKZ.js +0 -1
- package/contexts/ModalContext/index-CPfNnfTL.js +0 -39
- package/contexts/RHFormContext/index-D_nK759o.js +0 -78
- package/hocs/withToggle/index-C1_DMZD3.js +0 -14
- package/hooks/useFormAddEdit/index-D9oSjUn1.js +0 -90
- package/hooks/useFormReadyForUpdate/index-B3HygFCM.js +0 -20
- package/hooks/useModal/index-BJSQOX3U.js +0 -10
- package/hooks/useSizeContainer/index-D4hDjM1P.js +0 -37
- package/hooks/useStateRef/index-C3P6ZK3m.js +0 -15
- package/hooks/useTab/index-B_GEQFOP.js +0 -12
- package/react-data-grid-BfYuZ6AK.js +0 -2606
- package/react-draggable-DsCPdgQP.js +0 -811
- package/react-json-view-bhqIAaNg.js +0 -2576
- package/react-resizable-eBbFl2dX.js +0 -618
- package/react-spinners-TpKN9lZg.js +0 -123
- package/react-splitter-layout-C-JTsNGs.js +0 -158
- package/styles/DynamicFilter-CJFsIegc.js +0 -319
- package/styles/MenuActions-lTi-ynPM.js +0 -42
- package/styles/index-DKj6m8SL.js +0 -1691
- package/test/constants_no_mock-CF-669v-.js +0 -4
- package/test/getNameDataTestId-BaBTWhBr.js +0 -10
- package/utils/index-DiMrtgIu.js +0 -502
- /package/components/GridLayout/subcomponents/{Griditem → GridItem}/index.d.ts +0 -0
- /package/components/GridLayout/subcomponents/{Griditem → GridItem}/types.d.ts +0 -0
|
@@ -1,1110 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useRef, useCallback, useEffect } from "react";
|
|
3
|
-
import { createStore, useStore } from "zustand";
|
|
4
|
-
import { shallow } from "zustand/shallow";
|
|
5
|
-
import { useResponsiveDesktop, useFirstRender } from "@m4l/graphics";
|
|
6
|
-
import { useHostTools, useModuleDictionary, useNetwork, useModuleSkeleton, EmitEvents } from "@m4l/core";
|
|
7
|
-
import { devtools } from "zustand/middleware";
|
|
8
|
-
import { immer } from "zustand/middleware/immer";
|
|
9
|
-
import { u as useAreasViewerUtilityClasses } from "../../components/AreasViewer/index-DQ0aPioP.js";
|
|
10
|
-
import { u as useAreasAdminUtilityClasses } from "../../components/AreasAdmin/index-OxQU3P8Y.js";
|
|
11
|
-
import { c as createDynamicMFStore } from "../DynamicMFParmsContext/index-22c6E7vK.js";
|
|
12
|
-
import { g as getAreasDictionary, D as DICCTIONARY } from "../../dictionary-YUsP9beq.js";
|
|
13
|
-
import { a as addLayoutItemToBreakPointIfNoExists, b as addLayoutItemToBreakPoints, c as cloneLayouts } from "../../../GridLayout/subcomponents/Responsive/index-BKcU2OnF.js";
|
|
14
|
-
import { debounce, cloneDeep } from "lodash";
|
|
15
|
-
import { z as isEqualLayouts } from "../../../GridLayout/index-C4HyxNYX.js";
|
|
16
|
-
const PADDING_GRIDLAYOUT = 11;
|
|
17
|
-
const MARGIN_GRIDLAYOUT = 11;
|
|
18
|
-
const DEBOUCED_SAVE_TIME = 500;
|
|
19
|
-
const COOKIE_BREAKPOINT_LAYOUTS = "layoutPros";
|
|
20
|
-
const COOKIE_WINDOWS = "windows";
|
|
21
|
-
const BREAKPOINT_SIZES = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 1 };
|
|
22
|
-
const NORMALIZED_COLS = { lg: 64, md: 48, sm: 32, xs: 24, xxs: 1 };
|
|
23
|
-
const DEFAULT_LAYOUTS = { lg: [], md: [], sm: [], xs: [], xxs: [] };
|
|
24
|
-
const RESPONSIVE_COLAPSED_HEIGHTS = { xxs: 48, xs: 48, sm: 40, md: 40, lg: 40 };
|
|
25
|
-
const RESPONSIVE_ROW_HEIGHTS = { xxs: 48, xs: 48, sm: 48, md: 40, lg: 40 };
|
|
26
|
-
const DEFAULT_WINDOW = {
|
|
27
|
-
status: "init",
|
|
28
|
-
moduleActions: [],
|
|
29
|
-
cookies: { moduleCookies: {}, windowCookies: {} },
|
|
30
|
-
loading: false
|
|
31
|
-
};
|
|
32
|
-
const DEFAULT_AREA = {
|
|
33
|
-
status: "init",
|
|
34
|
-
zPopUpIndex: 0,
|
|
35
|
-
layouts: DEFAULT_LAYOUTS,
|
|
36
|
-
// colapsedItems: {},
|
|
37
|
-
// windowsLayoutIds: [],
|
|
38
|
-
layoutItemsIds: [],
|
|
39
|
-
currentLayoutId: "",
|
|
40
|
-
currentPopUpId: "",
|
|
41
|
-
breakpoints: BREAKPOINT_SIZES,
|
|
42
|
-
cols: NORMALIZED_COLS,
|
|
43
|
-
loadWindows: false
|
|
44
|
-
};
|
|
45
|
-
const addArea = (state) => {
|
|
46
|
-
const areaId = `area_${(/* @__PURE__ */ new Date()).getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
|
|
47
|
-
const labelNewArea = state.getLabel(getAreasDictionary(DICCTIONARY.label_new_area));
|
|
48
|
-
let isFree;
|
|
49
|
-
let name = `${labelNewArea} 1`;
|
|
50
|
-
for (let indexNames = 1; indexNames <= state.areasIds.length + 1; indexNames++) {
|
|
51
|
-
name = `${labelNewArea} ${indexNames + state.areasIds.length}`;
|
|
52
|
-
isFree = true;
|
|
53
|
-
for (let index = 0; index < state.areasIds.length; index++) {
|
|
54
|
-
if (state.hashAreas[state.areasIds[index]].name === name) {
|
|
55
|
-
isFree = false;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (isFree) {
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const newArea = {
|
|
64
|
-
id: areaId,
|
|
65
|
-
name,
|
|
66
|
-
...DEFAULT_AREA
|
|
67
|
-
};
|
|
68
|
-
state.areasIds.push(areaId);
|
|
69
|
-
state.hashAreas[areaId] = newArea;
|
|
70
|
-
state.currentModuleId = "";
|
|
71
|
-
if (state.loadAreasFromNetwork) {
|
|
72
|
-
state.networkOperation({
|
|
73
|
-
method: "POST",
|
|
74
|
-
endPoint: `areas`,
|
|
75
|
-
data: { id: areaId, name },
|
|
76
|
-
toastSuccess: false,
|
|
77
|
-
toastError: false
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
return areaId;
|
|
81
|
-
};
|
|
82
|
-
const updateOwnerStateClasses = (state) => {
|
|
83
|
-
state.viwerClasses = useAreasViewerUtilityClasses(state.ownerState);
|
|
84
|
-
state.adminClasses = useAreasAdminUtilityClasses(state.ownerState);
|
|
85
|
-
};
|
|
86
|
-
const getParmsFromValue = (key, data) => {
|
|
87
|
-
try {
|
|
88
|
-
if (Array.isArray(data)) {
|
|
89
|
-
let ob = data.find((f) => f.id === key);
|
|
90
|
-
if (ob) {
|
|
91
|
-
ob = JSON.parse(ob.value);
|
|
92
|
-
}
|
|
93
|
-
return ob;
|
|
94
|
-
}
|
|
95
|
-
} catch (error) {
|
|
96
|
-
}
|
|
97
|
-
return void 0;
|
|
98
|
-
};
|
|
99
|
-
function setColapsedLayoutBreakPoints(state, layoutId, colapsed) {
|
|
100
|
-
const layoutsBreakPoints = state.layouts;
|
|
101
|
-
for (const key in layoutsBreakPoints) {
|
|
102
|
-
const layoutBreakpoint = layoutsBreakPoints[key];
|
|
103
|
-
const index = layoutBreakpoint.findIndex((lb) => lb.i === layoutId);
|
|
104
|
-
if (index > -1) {
|
|
105
|
-
if (key !== "xxs") {
|
|
106
|
-
layoutBreakpoint[index].colapsed = colapsed;
|
|
107
|
-
} else {
|
|
108
|
-
if (!layoutBreakpoint[index].freeMove) {
|
|
109
|
-
layoutBreakpoint[index].colapsed = colapsed;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function deleteLayoutFromBreakPoints(state, layoutId) {
|
|
116
|
-
const layoutsBreakPoints = state.layouts;
|
|
117
|
-
for (const key in layoutsBreakPoints) {
|
|
118
|
-
const layoutBreakpoint = layoutsBreakPoints[key];
|
|
119
|
-
for (let index = 0; index < layoutBreakpoint.length; index++) {
|
|
120
|
-
const l = layoutBreakpoint[index];
|
|
121
|
-
if (l.i === layoutId) {
|
|
122
|
-
layoutBreakpoint.splice(index, 1);
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function getDataFromResponse(data, state, areaId) {
|
|
129
|
-
let newBreakPointsLayouts = getParmsFromValue(COOKIE_BREAKPOINT_LAYOUTS, data);
|
|
130
|
-
const windows = getParmsFromValue(COOKIE_WINDOWS, data);
|
|
131
|
-
const newWindowsLayoutsIds = [];
|
|
132
|
-
const newHashLayoutItems = [];
|
|
133
|
-
if (!newBreakPointsLayouts) {
|
|
134
|
-
newBreakPointsLayouts = {};
|
|
135
|
-
}
|
|
136
|
-
for (const breakPoint in BREAKPOINT_SIZES) {
|
|
137
|
-
if (!newBreakPointsLayouts[breakPoint]) {
|
|
138
|
-
newBreakPointsLayouts[breakPoint] = [];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (windows) {
|
|
142
|
-
for (const key in windows) {
|
|
143
|
-
const element = windows[key];
|
|
144
|
-
if (element && // element['layoutProps'] && //Garantizar que venga con los LayoutProps de la venta
|
|
145
|
-
element["mfProps"] && //Garantizar que venga con los mfProps de la venta
|
|
146
|
-
element["emergeType"] === "layout" && element["winType"] === "microfrontend") {
|
|
147
|
-
newWindowsLayoutsIds.push(key);
|
|
148
|
-
const onClose = state.areaActions.closeLayout;
|
|
149
|
-
state.hashWindows[key] = {
|
|
150
|
-
...DEFAULT_WINDOW,
|
|
151
|
-
...element,
|
|
152
|
-
windowId: key,
|
|
153
|
-
emergeType: "layout",
|
|
154
|
-
areaId,
|
|
155
|
-
dynamicMFStore: createDynamicMFStore({
|
|
156
|
-
dynamicMFParameters: element.dynamicParams,
|
|
157
|
-
windowId: key
|
|
158
|
-
}),
|
|
159
|
-
onClose: () => onClose(areaId, key)
|
|
160
|
-
};
|
|
161
|
-
newHashLayoutItems.push(key);
|
|
162
|
-
for (const breakPoint in BREAKPOINT_SIZES) {
|
|
163
|
-
addLayoutItemToBreakPointIfNoExists(
|
|
164
|
-
newBreakPointsLayouts,
|
|
165
|
-
breakPoint,
|
|
166
|
-
{ i: element.windowId, x: 0, y: 0, w: 5, h: 5 },
|
|
167
|
-
NORMALIZED_COLS,
|
|
168
|
-
[MARGIN_GRIDLAYOUT, MARGIN_GRIDLAYOUT],
|
|
169
|
-
[PADDING_GRIDLAYOUT, PADDING_GRIDLAYOUT],
|
|
170
|
-
RESPONSIVE_ROW_HEIGHTS
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
for (const breakPoint in BREAKPOINT_SIZES) {
|
|
176
|
-
newBreakPointsLayouts[breakPoint] = newBreakPointsLayouts[breakPoint].filter((li) => {
|
|
177
|
-
return newWindowsLayoutsIds.indexOf(li.i) > -1;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
for (const breakPoint in BREAKPOINT_SIZES) {
|
|
182
|
-
newBreakPointsLayouts[breakPoint] = [];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
newBreakPointsLayouts,
|
|
187
|
-
newHashLayoutItems
|
|
188
|
-
// baseResponsiveLayoutItems,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function getCookiesContainer(data, containerId) {
|
|
192
|
-
const cookies = {};
|
|
193
|
-
try {
|
|
194
|
-
if (Array.isArray(data)) {
|
|
195
|
-
for (let i = 0; i < data.length; i++) {
|
|
196
|
-
if (data[i]?.container_id === containerId && data[i]?.id) {
|
|
197
|
-
cookies[data[i]?.id] = JSON.parse(data[i].value);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
} catch (error) {
|
|
202
|
-
}
|
|
203
|
-
return cookies;
|
|
204
|
-
}
|
|
205
|
-
const createAreasStore = (initProps) => {
|
|
206
|
-
const startProps = {
|
|
207
|
-
viwerClasses: useAreasViewerUtilityClasses(initProps.ownerState),
|
|
208
|
-
adminClasses: useAreasAdminUtilityClasses(initProps.ownerState),
|
|
209
|
-
currentAreaId: "",
|
|
210
|
-
currentModuleId: "",
|
|
211
|
-
areasIds: [],
|
|
212
|
-
hashAreas: {},
|
|
213
|
-
hashWindows: {},
|
|
214
|
-
hashWindowsModals: {},
|
|
215
|
-
windowsModals: [],
|
|
216
|
-
...initProps
|
|
217
|
-
};
|
|
218
|
-
return createStore(
|
|
219
|
-
devtools(
|
|
220
|
-
immer((set, get) => ({
|
|
221
|
-
...startProps,
|
|
222
|
-
areasActions: {
|
|
223
|
-
init: () => {
|
|
224
|
-
if (get().ownerState.status !== "init") {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
if (!get().loadAreasFromNetwork) {
|
|
228
|
-
get().areasActions.addArea();
|
|
229
|
-
set((state) => {
|
|
230
|
-
state.ownerState.status = "loaded";
|
|
231
|
-
updateOwnerStateClasses(state);
|
|
232
|
-
});
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
set((state) => {
|
|
236
|
-
state.ownerState.status = "loading";
|
|
237
|
-
updateOwnerStateClasses(state);
|
|
238
|
-
});
|
|
239
|
-
get().networkOperation({
|
|
240
|
-
method: "GET",
|
|
241
|
-
endPoint: `areas`,
|
|
242
|
-
parms: {},
|
|
243
|
-
toastSuccess: false
|
|
244
|
-
}).then((response) => {
|
|
245
|
-
set((state) => {
|
|
246
|
-
if (response?.data && Array.isArray(response.data) && response.data.length > 0) {
|
|
247
|
-
for (let i = 0; i < response.data.length; i++) {
|
|
248
|
-
const newArea = {
|
|
249
|
-
...DEFAULT_AREA,
|
|
250
|
-
...response.data[i],
|
|
251
|
-
loadWindows: true
|
|
252
|
-
//Se indica que si se carguen las ventas debido a que viene de la API
|
|
253
|
-
};
|
|
254
|
-
state.hashAreas[newArea.id] = newArea;
|
|
255
|
-
state.areasIds.push(newArea.id);
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
addArea(state);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}).finally(() => {
|
|
262
|
-
set((state) => {
|
|
263
|
-
state.ownerState.status = "loaded";
|
|
264
|
-
updateOwnerStateClasses(state);
|
|
265
|
-
});
|
|
266
|
-
if (get().areasIds.length > 0 && get().currentAreaId === "") {
|
|
267
|
-
get().areasActions.selectArea(get().areasIds[0]);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
},
|
|
271
|
-
addArea: () => {
|
|
272
|
-
let newId = "";
|
|
273
|
-
set((state) => {
|
|
274
|
-
newId = addArea(state);
|
|
275
|
-
});
|
|
276
|
-
get().areasActions.selectArea(newId);
|
|
277
|
-
return newId;
|
|
278
|
-
},
|
|
279
|
-
editArea: (areaId, newName) => {
|
|
280
|
-
set((state) => {
|
|
281
|
-
if (state.hashAreas[areaId]) {
|
|
282
|
-
state.hashAreas[areaId].name = newName;
|
|
283
|
-
if (state.loadAreasFromNetwork) {
|
|
284
|
-
state.networkOperation({
|
|
285
|
-
method: "PATCH",
|
|
286
|
-
endPoint: `areas/${areaId}`,
|
|
287
|
-
data: { name: newName },
|
|
288
|
-
toastSuccess: false,
|
|
289
|
-
toastError: false
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
},
|
|
295
|
-
deleteArea: (areaId) => {
|
|
296
|
-
let selectNewAreaId = "";
|
|
297
|
-
set((state) => {
|
|
298
|
-
const ha = state.hashAreas[areaId];
|
|
299
|
-
if (!ha || state.areasIds.length < 2) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
const removeIndex = state.areasIds.indexOf(areaId);
|
|
303
|
-
if (removeIndex > -1) {
|
|
304
|
-
for (const key in state.hashWindows) {
|
|
305
|
-
if (state.hashWindows[key].areaId === areaId) {
|
|
306
|
-
delete state.hashWindows[key];
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
state.areasIds.splice(removeIndex, 1);
|
|
310
|
-
delete state.hashAreas[areaId];
|
|
311
|
-
}
|
|
312
|
-
if (state.currentAreaId === areaId) {
|
|
313
|
-
selectNewAreaId = state.areasIds[0];
|
|
314
|
-
}
|
|
315
|
-
if (state.loadAreasFromNetwork) {
|
|
316
|
-
state.networkOperation({
|
|
317
|
-
method: "DELETE",
|
|
318
|
-
endPoint: `areas/${areaId}`,
|
|
319
|
-
parms: {},
|
|
320
|
-
toastSuccess: false,
|
|
321
|
-
toastError: false
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
if (selectNewAreaId) {
|
|
326
|
-
get().areasActions.selectArea(selectNewAreaId);
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
selectArea: (areaId) => {
|
|
330
|
-
set((state) => {
|
|
331
|
-
state.currentAreaId = areaId;
|
|
332
|
-
if (state.hashAreas[areaId].currentLayoutId) {
|
|
333
|
-
state.currentModuleId = state.hashWindows[state.hashAreas[areaId].currentLayoutId].moduleId;
|
|
334
|
-
} else {
|
|
335
|
-
state.currentModuleId = "";
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
if (get().hashAreas[areaId].status === "init") {
|
|
339
|
-
if (get().hashAreas[areaId].loadWindows) {
|
|
340
|
-
get().areaActions.loadWindowsFromApi(areaId);
|
|
341
|
-
} else {
|
|
342
|
-
set((state) => {
|
|
343
|
-
state.hashAreas[areaId].status = "loaded";
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
if (get().hashAreas[areaId].maximizedId !== void 0) ;
|
|
348
|
-
},
|
|
349
|
-
setHandlerGetLabel: (newHandler) => {
|
|
350
|
-
set((state) => {
|
|
351
|
-
state.getLabel = newHandler;
|
|
352
|
-
});
|
|
353
|
-
},
|
|
354
|
-
setExternalState: (newExternalState) => {
|
|
355
|
-
set((state) => {
|
|
356
|
-
state.ownerState = { ...state.ownerState, ...newExternalState };
|
|
357
|
-
updateOwnerStateClasses(state);
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
areaActions: {
|
|
362
|
-
addWindow: (newWindowProps) => {
|
|
363
|
-
const windowId = `${get().currentAreaId}_window_${(/* @__PURE__ */ new Date()).getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
|
|
364
|
-
if (newWindowProps.emergeType === "layout" || newWindowProps.emergeType === "popup") {
|
|
365
|
-
get().areaActions.addLayout(get().currentAreaId, windowId, newWindowProps);
|
|
366
|
-
} else if (newWindowProps.emergeType === "modal") {
|
|
367
|
-
get().areaActions.addWindowModal(get().currentAreaId, windowId, newWindowProps);
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
addLayout: (areaId, windowId, newWindowProps) => {
|
|
371
|
-
let previousId = windowId;
|
|
372
|
-
const freeMove = newWindowProps.emergeType === "popup";
|
|
373
|
-
const newLayoutItem = {
|
|
374
|
-
...newWindowProps.layoutProps,
|
|
375
|
-
i: windowId,
|
|
376
|
-
isDraggable: true,
|
|
377
|
-
isResizable: true,
|
|
378
|
-
freeMove
|
|
379
|
-
};
|
|
380
|
-
set((state) => {
|
|
381
|
-
const area = state.hashAreas[areaId];
|
|
382
|
-
if (!area) {
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
if (newWindowProps.replaceMeId) {
|
|
386
|
-
for (let index = 0; index < area.layoutItemsIds.length; index++) {
|
|
387
|
-
const key = area.layoutItemsIds[index];
|
|
388
|
-
const WindoPopUp = state.hashWindows[key];
|
|
389
|
-
if (WindoPopUp.replaceMeId === newWindowProps.replaceMeId) {
|
|
390
|
-
previousId = key;
|
|
391
|
-
WindoPopUp.dynamicMFStore.getState().actions.changeData(newWindowProps.dynamicParams);
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
if (previousId === windowId) {
|
|
397
|
-
const dynamicMFStore = createDynamicMFStore({
|
|
398
|
-
dynamicMFParameters: newWindowProps.dynamicParams,
|
|
399
|
-
windowId
|
|
400
|
-
});
|
|
401
|
-
state.hashWindows[windowId] = {
|
|
402
|
-
...newWindowProps,
|
|
403
|
-
areaId,
|
|
404
|
-
windowId,
|
|
405
|
-
onClose: (removeLayoutId) => {
|
|
406
|
-
get().areaActions.closeLayout(areaId, removeLayoutId);
|
|
407
|
-
},
|
|
408
|
-
...DEFAULT_WINDOW,
|
|
409
|
-
dynamicMFStore
|
|
410
|
-
};
|
|
411
|
-
area.layoutItemsIds.push(windowId);
|
|
412
|
-
if (newWindowProps.emergeType === "layout") {
|
|
413
|
-
area.currentLayoutId = windowId;
|
|
414
|
-
} else {
|
|
415
|
-
area.currentPopUpId = windowId;
|
|
416
|
-
}
|
|
417
|
-
if (area.maximizedId) {
|
|
418
|
-
area.maximizedId = windowId;
|
|
419
|
-
}
|
|
420
|
-
area.layouts = addLayoutItemToBreakPoints(
|
|
421
|
-
area.layouts,
|
|
422
|
-
newLayoutItem,
|
|
423
|
-
NORMALIZED_COLS,
|
|
424
|
-
[MARGIN_GRIDLAYOUT, MARGIN_GRIDLAYOUT],
|
|
425
|
-
[PADDING_GRIDLAYOUT, PADDING_GRIDLAYOUT],
|
|
426
|
-
RESPONSIVE_ROW_HEIGHTS,
|
|
427
|
-
area.containerHeight,
|
|
428
|
-
area.currentBreakpoint
|
|
429
|
-
);
|
|
430
|
-
if (area.currentBreakpoint === "xxs") {
|
|
431
|
-
area.maximizedId = windowId;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
get().areaActions.saveLayouts(areaId);
|
|
436
|
-
get().areaActions.bouncedSaveBreakpointsLayouts(areaId);
|
|
437
|
-
},
|
|
438
|
-
closeLayout: (areaId, removeLayoutId) => {
|
|
439
|
-
set((state) => {
|
|
440
|
-
const area = state.hashAreas[areaId];
|
|
441
|
-
if (!area) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
const removeIndex = area.layoutItemsIds.indexOf(removeLayoutId);
|
|
445
|
-
if (removeIndex > -1) {
|
|
446
|
-
area.layoutItemsIds.splice(removeIndex, 1);
|
|
447
|
-
}
|
|
448
|
-
deleteLayoutFromBreakPoints(area, removeLayoutId);
|
|
449
|
-
delete state.hashWindows[removeLayoutId];
|
|
450
|
-
});
|
|
451
|
-
get().areaActions.saveLayouts(areaId);
|
|
452
|
-
if (get().hashAreas[areaId].maximizedId === removeLayoutId) {
|
|
453
|
-
get().areaActions.maximizeLayout(areaId);
|
|
454
|
-
}
|
|
455
|
-
for (let index = 0; index < get().hashAreas[areaId].layoutItemsIds.length; index++) {
|
|
456
|
-
const layoutItemId = get().hashAreas[areaId].layoutItemsIds[index];
|
|
457
|
-
const layoutItem = get().hashWindows[layoutItemId];
|
|
458
|
-
if (layoutItem.parentLayoutId === removeLayoutId) {
|
|
459
|
-
get().areaActions.closeLayout(areaId, layoutItem.windowId);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
saveLayouts: (areaId) => {
|
|
464
|
-
let nrKeys = 0;
|
|
465
|
-
const area = get().hashAreas[areaId];
|
|
466
|
-
if (!area) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
const saveObjetc = {};
|
|
470
|
-
for (let index = 0; index < area.layoutItemsIds.length; index++) {
|
|
471
|
-
const key = area.layoutItemsIds[index];
|
|
472
|
-
if (get().hashWindows[key] && get().hashWindows[key].winType === "microfrontend") {
|
|
473
|
-
const element = get().hashWindows[key];
|
|
474
|
-
const hasPropsToSave = {
|
|
475
|
-
winType: true,
|
|
476
|
-
emergeType: true,
|
|
477
|
-
title: true,
|
|
478
|
-
url_icon: true,
|
|
479
|
-
windowOptions: true,
|
|
480
|
-
// layoutProps: false,
|
|
481
|
-
moduleId: true,
|
|
482
|
-
windowId: true,
|
|
483
|
-
mfProps: true
|
|
484
|
-
};
|
|
485
|
-
const newElement = {};
|
|
486
|
-
for (const keyToSave in hasPropsToSave) {
|
|
487
|
-
newElement[keyToSave] = element[keyToSave];
|
|
488
|
-
}
|
|
489
|
-
saveObjetc[key] = newElement;
|
|
490
|
-
nrKeys++;
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
if (nrKeys > 0) {
|
|
494
|
-
get().networkOperation({
|
|
495
|
-
method: "PUT",
|
|
496
|
-
endPoint: `cookies/${area.id}/${COOKIE_WINDOWS}`,
|
|
497
|
-
data: {
|
|
498
|
-
value: JSON.stringify(saveObjetc)
|
|
499
|
-
},
|
|
500
|
-
toastSuccess: false,
|
|
501
|
-
toastError: false
|
|
502
|
-
});
|
|
503
|
-
} else {
|
|
504
|
-
get().networkOperation({
|
|
505
|
-
method: "DELETE",
|
|
506
|
-
endPoint: `cookies`,
|
|
507
|
-
data: { f: [{ n: "container_id", o: "c", o1: area.id }] },
|
|
508
|
-
toastSuccess: false,
|
|
509
|
-
toastError: false
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
},
|
|
513
|
-
closeWindowModal: (removeModalId) => {
|
|
514
|
-
set((state) => {
|
|
515
|
-
const removeIndex = state.windowsModals.findIndex((w) => w === removeModalId);
|
|
516
|
-
if (removeIndex > -1) {
|
|
517
|
-
state.windowsModals.splice(removeIndex, 1);
|
|
518
|
-
}
|
|
519
|
-
delete state.hashWindows[removeModalId];
|
|
520
|
-
delete state.hashWindowsModals[removeModalId];
|
|
521
|
-
});
|
|
522
|
-
},
|
|
523
|
-
addWindowModal: (areaId, windowId, newWindowModalProps) => {
|
|
524
|
-
set((state) => {
|
|
525
|
-
const dynamicMFStore = createDynamicMFStore({
|
|
526
|
-
dynamicMFParameters: newWindowModalProps.dynamicParams,
|
|
527
|
-
windowId
|
|
528
|
-
});
|
|
529
|
-
state.windowsModals.push(windowId);
|
|
530
|
-
state.hashWindowsModals[windowId] = {
|
|
531
|
-
...newWindowModalProps,
|
|
532
|
-
areaId,
|
|
533
|
-
windowId,
|
|
534
|
-
...DEFAULT_WINDOW,
|
|
535
|
-
onClose: get().areaActions.closeWindowModal,
|
|
536
|
-
dynamicMFStore
|
|
537
|
-
};
|
|
538
|
-
state.hashWindows[windowId] = state.hashWindowsModals[windowId];
|
|
539
|
-
});
|
|
540
|
-
},
|
|
541
|
-
bouncedSaveBreakpointsLayouts: debounce(
|
|
542
|
-
(areaId) => {
|
|
543
|
-
const purgedLayouts = {
|
|
544
|
-
...get().hashAreas[areaId].layouts
|
|
545
|
-
};
|
|
546
|
-
const finalLayouts = {};
|
|
547
|
-
for (const key in purgedLayouts) {
|
|
548
|
-
const element = purgedLayouts[key];
|
|
549
|
-
purgedLayouts[key] = element.filter((l) => {
|
|
550
|
-
if (l.i === "none") {
|
|
551
|
-
return false;
|
|
552
|
-
}
|
|
553
|
-
if (get().hashAreas[areaId].layoutItemsIds.indexOf(l.i) > -1) {
|
|
554
|
-
return true;
|
|
555
|
-
}
|
|
556
|
-
return false;
|
|
557
|
-
});
|
|
558
|
-
if (purgedLayouts[key].length > 0) {
|
|
559
|
-
finalLayouts[key] = purgedLayouts[key];
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
if (Object.keys(finalLayouts).length > 0) {
|
|
563
|
-
get().networkOperation({
|
|
564
|
-
method: "PUT",
|
|
565
|
-
endPoint: `cookies/${get().hashAreas[areaId].id}/${COOKIE_BREAKPOINT_LAYOUTS}`,
|
|
566
|
-
data: {
|
|
567
|
-
value: JSON.stringify(finalLayouts)
|
|
568
|
-
},
|
|
569
|
-
toastSuccess: false,
|
|
570
|
-
toastError: false
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
DEBOUCED_SAVE_TIME,
|
|
575
|
-
{
|
|
576
|
-
leading: true,
|
|
577
|
-
trailing: true
|
|
578
|
-
}
|
|
579
|
-
),
|
|
580
|
-
onBreakpointsLayoutsChange: (areaId, _currentLayout, newAllLayouts) => {
|
|
581
|
-
if (!isEqualLayouts(get().hashAreas[areaId].layouts, newAllLayouts)) {
|
|
582
|
-
set((state) => {
|
|
583
|
-
state.hashAreas[areaId].layouts = cloneLayouts(newAllLayouts);
|
|
584
|
-
});
|
|
585
|
-
if (!get().hashAreas[areaId].maximizedId) {
|
|
586
|
-
get().areaActions.bouncedSaveBreakpointsLayouts(areaId);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
},
|
|
590
|
-
onContainerChange: (areaId, e) => {
|
|
591
|
-
set((state) => {
|
|
592
|
-
state.hashAreas[areaId].containerHeight = e.containerHeight;
|
|
593
|
-
state.hashAreas[areaId].currentBreakpoint = e.breakpoint;
|
|
594
|
-
});
|
|
595
|
-
},
|
|
596
|
-
selectLayout: (areaId, layoutId) => {
|
|
597
|
-
set((state) => {
|
|
598
|
-
const area = state.hashAreas[areaId];
|
|
599
|
-
if (state.hashWindows[layoutId].emergeType === "layout") {
|
|
600
|
-
area.currentLayoutId = layoutId;
|
|
601
|
-
state.currentModuleId = state.hashWindows[layoutId].moduleId;
|
|
602
|
-
if (area.currentPopUpId !== "" && state.hashWindows[area.currentPopUpId]) {
|
|
603
|
-
if (state.hashWindows[area.currentPopUpId].parentLayoutId !== layoutId) {
|
|
604
|
-
area.currentPopUpId = "";
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
} else {
|
|
608
|
-
state.hashAreas[areaId].currentPopUpId = layoutId;
|
|
609
|
-
const parentLayoutId = state.hashWindows[layoutId]?.parentLayoutId;
|
|
610
|
-
if (parentLayoutId && state.hashWindows[parentLayoutId]) {
|
|
611
|
-
area.currentLayoutId = parentLayoutId;
|
|
612
|
-
state.currentModuleId = state.hashWindows[parentLayoutId].moduleId;
|
|
613
|
-
} else {
|
|
614
|
-
area.currentLayoutId = "";
|
|
615
|
-
state.currentModuleId = "";
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
});
|
|
619
|
-
},
|
|
620
|
-
unColapseLayoutItem: (areaId, layoutId) => {
|
|
621
|
-
set((state) => {
|
|
622
|
-
setColapsedLayoutBreakPoints(state.hashAreas[areaId], layoutId, false);
|
|
623
|
-
});
|
|
624
|
-
},
|
|
625
|
-
colapseLayoutItem: (areaId, layoutId) => {
|
|
626
|
-
if (!get().hashAreas[areaId].maximizedId && get().hashWindows[layoutId]) {
|
|
627
|
-
set((state) => {
|
|
628
|
-
setColapsedLayoutBreakPoints(state.hashAreas[areaId], layoutId, true);
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
},
|
|
632
|
-
maximizeLayout: (areaId, layoutId) => {
|
|
633
|
-
set((state) => {
|
|
634
|
-
const area = state.hashAreas[areaId];
|
|
635
|
-
if (!area) return;
|
|
636
|
-
area.maximizedId = layoutId;
|
|
637
|
-
const index = area.layouts["xxs"]?.findIndex((li) => li.i === area.maximizedId);
|
|
638
|
-
if (index !== void 0 && index > -1 && layoutId && state.hashWindows[layoutId].emergeType === "popup") {
|
|
639
|
-
area.layouts["xxs"][index].visible = true;
|
|
640
|
-
area.layouts["xxs"][index].colapsed = false;
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
if (layoutId) {
|
|
644
|
-
get().areaActions.selectLayout(areaId, layoutId);
|
|
645
|
-
}
|
|
646
|
-
},
|
|
647
|
-
normalizeLayouts: (areaId) => {
|
|
648
|
-
set((state) => {
|
|
649
|
-
const area = state.hashAreas[areaId];
|
|
650
|
-
if (!area) return;
|
|
651
|
-
if (area.maximizedId) {
|
|
652
|
-
const index = area.layouts["xxs"]?.findIndex((li) => li.i === area.maximizedId);
|
|
653
|
-
if (index !== void 0 && index > -1 && state.hashWindows[area.maximizedId].emergeType === "popup") {
|
|
654
|
-
area.layouts["xxs"][index].visible = false;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
area.maximizedId = void 0;
|
|
658
|
-
});
|
|
659
|
-
},
|
|
660
|
-
loadWindowsFromApi: (areaId) => {
|
|
661
|
-
const area = get().hashAreas[areaId];
|
|
662
|
-
if (!area) {
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
if (area.status !== "init") {
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
if (!get().loadAreasFromNetwork || !area.loadWindows) {
|
|
669
|
-
set((state) => {
|
|
670
|
-
state.hashAreas[areaId].status = "loaded";
|
|
671
|
-
});
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
set((state) => {
|
|
675
|
-
state.hashAreas[areaId].status = "loading";
|
|
676
|
-
});
|
|
677
|
-
get().networkOperation({
|
|
678
|
-
method: "GET",
|
|
679
|
-
endPoint: `cookies`,
|
|
680
|
-
parms: { f: [{ n: "container_id", o: "e", o1: areaId }] },
|
|
681
|
-
toastSuccess: false,
|
|
682
|
-
toastError: false
|
|
683
|
-
// isRemote: false
|
|
684
|
-
}).then((response) => {
|
|
685
|
-
const area2 = get().hashAreas[areaId];
|
|
686
|
-
if (!area2) {
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
set((state) => {
|
|
690
|
-
const area3 = state.hashAreas[areaId];
|
|
691
|
-
const { newBreakPointsLayouts, newHashLayoutItems } = getDataFromResponse(
|
|
692
|
-
response.data,
|
|
693
|
-
state,
|
|
694
|
-
areaId
|
|
695
|
-
);
|
|
696
|
-
area3.layouts = newBreakPointsLayouts;
|
|
697
|
-
area3.layoutItemsIds = newHashLayoutItems;
|
|
698
|
-
area3.status = "loaded";
|
|
699
|
-
});
|
|
700
|
-
}).catch((_response) => {
|
|
701
|
-
set((state) => {
|
|
702
|
-
state.hashAreas[areaId].status = "loaded";
|
|
703
|
-
});
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
// addWindowLayoutPendiente: (
|
|
707
|
-
// areaId: string,
|
|
708
|
-
// windowId: string,
|
|
709
|
-
// newWindow: NewLayoutMagnetizableProps,
|
|
710
|
-
// ) => {
|
|
711
|
-
// const newLayoutItem: WinLayoutItem = {
|
|
712
|
-
// ...newWindow.layoutProps,
|
|
713
|
-
// i: windowId,
|
|
714
|
-
// isDraggable: true,
|
|
715
|
-
// isResizable: true,
|
|
716
|
-
// winType: newWindow.winType,
|
|
717
|
-
// freeMove: false,
|
|
718
|
-
// };
|
|
719
|
-
// set(state => {
|
|
720
|
-
// const area = state.hashAreas[areaId];
|
|
721
|
-
// if (!area) {
|
|
722
|
-
// return;
|
|
723
|
-
// }
|
|
724
|
-
// const dynamicMFStore = createDynamicMFStore({
|
|
725
|
-
// dynamicMFParameters: newWindow.dynamicParams,
|
|
726
|
-
// windowId,
|
|
727
|
-
// });
|
|
728
|
-
// area.windowsLayouts.push(newLayoutItem);
|
|
729
|
-
// area.hashWindowsLayouts[windowId] = {
|
|
730
|
-
// ...newWindow,
|
|
731
|
-
// areaId,
|
|
732
|
-
// windowId,
|
|
733
|
-
// emergeType: 'layout',
|
|
734
|
-
// onClose: (removeLayoutId: string) => {
|
|
735
|
-
// get().areaActions.closeWindowLayout(areaId, removeLayoutId);
|
|
736
|
-
// },
|
|
737
|
-
// ...DEFAULT_WINDOW,
|
|
738
|
-
// dynamicMFStore,
|
|
739
|
-
// };
|
|
740
|
-
// area.baseResponsivelayoutItems.push({ i: windowId });
|
|
741
|
-
// //Agregar la ventana al hash general de todas las ventanas
|
|
742
|
-
// state.hashWindows[windowId] = area.hashWindowsLayouts[windowId];
|
|
743
|
-
// setAddBreakPoints(area, newLayoutItem);
|
|
744
|
-
// });
|
|
745
|
-
// get().areaActions.selectLayout(areaId, windowId);
|
|
746
|
-
// if (
|
|
747
|
-
// get().hashAreas[areaId].viewMode === 'single' ||
|
|
748
|
-
// newWindow?.openType === 'maximized'
|
|
749
|
-
// ) {
|
|
750
|
-
// get().areaActions.maximizeLayout(areaId, windowId);
|
|
751
|
-
// }
|
|
752
|
-
// get().areaActions.saveLayouts(areaId);
|
|
753
|
-
// get().areaActions.bouncedSaveBreakpointsLayouts(areaId);
|
|
754
|
-
// },
|
|
755
|
-
// closeLayout: (areaId: string, removePopUpId: string) => {
|
|
756
|
-
// set(state => {
|
|
757
|
-
// const area = state.hashAreas[areaId];
|
|
758
|
-
// if (!area) {
|
|
759
|
-
// return;
|
|
760
|
-
// }
|
|
761
|
-
// const removeIndex = area.windowsPopUps.findIndex(
|
|
762
|
-
// wpId => wpId === removePopUpId,
|
|
763
|
-
// );
|
|
764
|
-
// if (removeIndex > -1) {
|
|
765
|
-
// area.windowsPopUps.splice(removeIndex, 1);
|
|
766
|
-
// }
|
|
767
|
-
// delete area.hashWindowsPopups[removePopUpId];
|
|
768
|
-
// delete state.hashWindows[removePopUpId];
|
|
769
|
-
// });
|
|
770
|
-
// },
|
|
771
|
-
// selectWindowPopUp: (areaId: string, popUpId: string) => {
|
|
772
|
-
// set(state => {
|
|
773
|
-
// state.hashAreas[areaId].zPopUpIndex++;
|
|
774
|
-
// state.hashAreas[areaId].currentPopUpId = popUpId;
|
|
775
|
-
// state.hashAreas[areaId].zPopUpIndex++;
|
|
776
|
-
// state.hashAreas[areaId].currentPopUpId = popUpId;
|
|
777
|
-
// state.hashAreas[areaId].hashWindowsPopups[popUpId].zIndex =
|
|
778
|
-
// state.hashAreas[areaId].zPopUpIndex;
|
|
779
|
-
// //Seleccionar el layout padre si lo tiene
|
|
780
|
-
// if (
|
|
781
|
-
// state.hashAreas[areaId].hashWindowsPopups[popUpId].parentLayoutId &&
|
|
782
|
-
// state.hashAreas[areaId].hashWindowsPopups[popUpId]
|
|
783
|
-
// .parentLayoutId !== ''
|
|
784
|
-
// ) {
|
|
785
|
-
// state.hashAreas[areaId].currentLayoutId =
|
|
786
|
-
// state.hashAreas[areaId].hashWindowsPopups[
|
|
787
|
-
// popUpId
|
|
788
|
-
// ].parentLayoutId;
|
|
789
|
-
// } else {
|
|
790
|
-
// state.hashAreas[areaId].currentLayoutId = '';
|
|
791
|
-
// }
|
|
792
|
-
// });
|
|
793
|
-
// //Enfocar el componente despues de la renderización.
|
|
794
|
-
// setTimeout(() => {
|
|
795
|
-
// //Asegurar visibilidad si es un reemplazo
|
|
796
|
-
// const container = document.getElementsByClassName(
|
|
797
|
-
// `${areasViewerClasses.areaGridLayoutPanelContainer}-${areaId}`,
|
|
798
|
-
// )[0];
|
|
799
|
-
// const element = document.getElementsByClassName(
|
|
800
|
-
// `${areasViewerClasses.windowPopupRoot}-${popUpId}`,
|
|
801
|
-
// )[0]; //`M4L_WindowPopUp_${popUpId}`,
|
|
802
|
-
// //TODO: Proteeccion de los vectores
|
|
803
|
-
// if (element && container) {
|
|
804
|
-
// const { top, left } = element.getBoundingClientRect();
|
|
805
|
-
// const { top: containerTop, left: containerLeft } =
|
|
806
|
-
// container.getBoundingClientRect();
|
|
807
|
-
// container.scrollTop = container.scrollTop + top - containerTop;
|
|
808
|
-
// container.scrollLeft = container.scrollLeft + left - containerLeft;
|
|
809
|
-
// }
|
|
810
|
-
// }, 100);
|
|
811
|
-
// // windowsPopUps.findIndex(wp => wp.container_id === lookForThisId) > -1) {
|
|
812
|
-
// // setSelectedWindow(newSeletectedId);
|
|
813
|
-
// },
|
|
814
|
-
// resizeMaximixedLayout: (areaId: string) => {
|
|
815
|
-
// set(state => {
|
|
816
|
-
// const area = state.hashAreas[areaId];
|
|
817
|
-
// if (!area) return;
|
|
818
|
-
// if (areaId !== state.currentAreaId) {
|
|
819
|
-
// return;
|
|
820
|
-
// }
|
|
821
|
-
// if (area.viewMode === 'single' && area.currentLayoutId !== '') {
|
|
822
|
-
// console.log('Rezigning', areaId);
|
|
823
|
-
// const layoutsBreakPoints = area.layouts;
|
|
824
|
-
// const container = document.getElementsByClassName(
|
|
825
|
-
// `${areasViewerClasses.areaGridLayout}-${area.id}`,
|
|
826
|
-
// )[0];
|
|
827
|
-
// window.dispatchEvent(new Event('resize'));
|
|
828
|
-
// for (const key in layoutsBreakPoints) {
|
|
829
|
-
// const layoutBreakpoint = layoutsBreakPoints[key];
|
|
830
|
-
// if (layoutBreakpoint) {
|
|
831
|
-
// const clientHeight = container.clientHeight;
|
|
832
|
-
// //Formula que sale de despejar de acuerdo al grid layout en el codigo fuente: heigthpx = colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx
|
|
833
|
-
// const heigthUnits =
|
|
834
|
-
// (clientHeight +
|
|
835
|
-
// MARGIN_GRIDLAYOUT -
|
|
836
|
-
// 2 * PADDING_GRIDLAYOUT) /
|
|
837
|
-
// (ROW_HEIGTH_GRIDLAYOUT + MARGIN_GRIDLAYOUT);
|
|
838
|
-
// for (
|
|
839
|
-
// let index = 0;
|
|
840
|
-
// index < layoutBreakpoint.length;
|
|
841
|
-
// index++
|
|
842
|
-
// ) {
|
|
843
|
-
// const l = layoutBreakpoint[index];
|
|
844
|
-
// if (l.i === area.currentLayoutId) {
|
|
845
|
-
// l.h = heigthUnits;
|
|
846
|
-
// l.maxH = heigthUnits;
|
|
847
|
-
// }
|
|
848
|
-
// }
|
|
849
|
-
// }
|
|
850
|
-
// }
|
|
851
|
-
// }
|
|
852
|
-
// //TODO: Corregir cuando arranca en celular,
|
|
853
|
-
// // no se han cargado las ventanas y no se puede encontrar
|
|
854
|
-
// // Adicionalmente no se ha posicionado el panelWindows, y calcula
|
|
855
|
-
// // state.cols = MAXIMIZED_COLS;
|
|
856
|
-
// });
|
|
857
|
-
// },
|
|
858
|
-
},
|
|
859
|
-
windowActions: {
|
|
860
|
-
setActions: (windowId, newActions, version) => {
|
|
861
|
-
set((state) => {
|
|
862
|
-
if (state.hashWindows[windowId]) {
|
|
863
|
-
state.hashWindows[windowId].moduleActions = cloneDeep(newActions);
|
|
864
|
-
state.hashWindows[windowId].version = version;
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
},
|
|
868
|
-
getCookie: (windowId, id) => {
|
|
869
|
-
if (get().hashWindows[windowId]) {
|
|
870
|
-
return get().hashWindows[windowId].cookies.windowCookies[id] || get().hashWindows[windowId].cookies.moduleCookies[id];
|
|
871
|
-
}
|
|
872
|
-
return {};
|
|
873
|
-
},
|
|
874
|
-
getCookies: (windowId, type) => {
|
|
875
|
-
if (get().hashWindows[windowId]) {
|
|
876
|
-
if (type === "window") {
|
|
877
|
-
return get().hashWindows[windowId].cookies.windowCookies;
|
|
878
|
-
} else {
|
|
879
|
-
return get().hashWindows[windowId].cookies.moduleCookies;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
return {};
|
|
883
|
-
},
|
|
884
|
-
setCookie: (windowId, id, type, cookie) => {
|
|
885
|
-
set((state) => {
|
|
886
|
-
const hW = state.hashWindows[windowId];
|
|
887
|
-
if (hW) {
|
|
888
|
-
get().networkOperation({
|
|
889
|
-
method: "PUT",
|
|
890
|
-
endPoint: `cookies/${type === "module" ? hW.moduleId : windowId}/${id}`,
|
|
891
|
-
data: {
|
|
892
|
-
value: JSON.stringify(cookie)
|
|
893
|
-
},
|
|
894
|
-
toastSuccess: false,
|
|
895
|
-
toastError: false
|
|
896
|
-
});
|
|
897
|
-
if (type === "window") {
|
|
898
|
-
hW.cookies.windowCookies[id] = cookie;
|
|
899
|
-
} else {
|
|
900
|
-
hW.cookies.moduleCookies[id] = cookie;
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
},
|
|
905
|
-
close: (windowId) => {
|
|
906
|
-
const hW = get().hashWindows[windowId];
|
|
907
|
-
if (hW) {
|
|
908
|
-
const onClose = hW.onClose;
|
|
909
|
-
if (onClose) {
|
|
910
|
-
onClose(hW.windowId);
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
},
|
|
914
|
-
startProgress: (windowId) => {
|
|
915
|
-
set((state) => {
|
|
916
|
-
if (state.hashWindows[windowId]) {
|
|
917
|
-
state.hashWindows[windowId].loading = true;
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
},
|
|
921
|
-
stopProgress: (windowId) => {
|
|
922
|
-
set((state) => {
|
|
923
|
-
if (state.hashWindows[windowId]) {
|
|
924
|
-
state.hashWindows[windowId].loading = false;
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
},
|
|
928
|
-
loadCookiesFromApi: (windowId) => {
|
|
929
|
-
const hW = get().hashWindows[windowId];
|
|
930
|
-
if (hW) {
|
|
931
|
-
if (hW.status === "init") {
|
|
932
|
-
set((state) => {
|
|
933
|
-
state.hashWindows[windowId].status = "loading";
|
|
934
|
-
});
|
|
935
|
-
get().networkOperation({
|
|
936
|
-
method: "GET",
|
|
937
|
-
endPoint: `cookies`,
|
|
938
|
-
parms: {
|
|
939
|
-
f: [
|
|
940
|
-
{ n: "container_id", o: "e", o1: hW.windowId },
|
|
941
|
-
{ n: "container_id", o: "e", o1: hW.moduleId }
|
|
942
|
-
]
|
|
943
|
-
},
|
|
944
|
-
toastSuccess: false,
|
|
945
|
-
toastError: false
|
|
946
|
-
// isRemote: false
|
|
947
|
-
}).then((response) => {
|
|
948
|
-
set((state) => {
|
|
949
|
-
const hWs = state.hashWindows[windowId];
|
|
950
|
-
if (hWs) {
|
|
951
|
-
hWs.cookies.moduleCookies = getCookiesContainer(
|
|
952
|
-
response.data,
|
|
953
|
-
hWs.moduleId
|
|
954
|
-
);
|
|
955
|
-
hWs.cookies.windowCookies = getCookiesContainer(response.data, windowId);
|
|
956
|
-
hWs.status = "loaded";
|
|
957
|
-
}
|
|
958
|
-
});
|
|
959
|
-
}).catch((_response) => {
|
|
960
|
-
set((state) => {
|
|
961
|
-
if (state.hashWindows[windowId]) {
|
|
962
|
-
state.hashWindows[windowId].status = "loaded";
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
},
|
|
969
|
-
saveModuleCookies: (windowId) => {
|
|
970
|
-
const hW = get().hashWindows[windowId];
|
|
971
|
-
if (hW) {
|
|
972
|
-
for (const key in hW.cookies.windowCookies) {
|
|
973
|
-
const cookie = hW.cookies.windowCookies[key];
|
|
974
|
-
get().networkOperation({
|
|
975
|
-
method: "PUT",
|
|
976
|
-
endPoint: `cookies/${hW.moduleId}/${key}`,
|
|
977
|
-
data: {
|
|
978
|
-
value: JSON.stringify(cookie)
|
|
979
|
-
},
|
|
980
|
-
toastSuccess: false,
|
|
981
|
-
toastError: false
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
},
|
|
986
|
-
resetModuleCookies: (windowId) => {
|
|
987
|
-
const hW = get().hashWindows[windowId];
|
|
988
|
-
if (hW) {
|
|
989
|
-
get().networkOperation({
|
|
990
|
-
method: "DELETE",
|
|
991
|
-
endPoint: `cookies`,
|
|
992
|
-
data: {
|
|
993
|
-
f: [
|
|
994
|
-
{
|
|
995
|
-
n: "id",
|
|
996
|
-
o: "c",
|
|
997
|
-
o1: hW.moduleId
|
|
998
|
-
}
|
|
999
|
-
]
|
|
1000
|
-
},
|
|
1001
|
-
toastSuccess: false,
|
|
1002
|
-
toastError: false
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
},
|
|
1006
|
-
setFnQueryClose: (windowId, fnQueryClose) => {
|
|
1007
|
-
set((state) => {
|
|
1008
|
-
state.hashWindows[windowId].fnQueryClose = fnQueryClose;
|
|
1009
|
-
});
|
|
1010
|
-
},
|
|
1011
|
-
setWindowTitle: (windowId, title) => {
|
|
1012
|
-
set((state) => {
|
|
1013
|
-
state.hashWindows[windowId].title = title;
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
},
|
|
1017
|
-
areaAdminActions: {
|
|
1018
|
-
setFocus: (newValue) => {
|
|
1019
|
-
set((state) => {
|
|
1020
|
-
state.ownerState = { ...state.ownerState, focus: newValue };
|
|
1021
|
-
updateOwnerStateClasses(state);
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
})),
|
|
1026
|
-
{ name: `Areas store` }
|
|
1027
|
-
)
|
|
1028
|
-
);
|
|
1029
|
-
};
|
|
1030
|
-
const AreasContext = createContext(null);
|
|
1031
|
-
function AreasProvider(props) {
|
|
1032
|
-
const { children, loadAreasFromNetwork, loadCookiesFromNetwork, onLoad, onSelectLayout } = props;
|
|
1033
|
-
const { events_add_listener, events_remove_listener } = useHostTools();
|
|
1034
|
-
const { getLabel } = useModuleDictionary();
|
|
1035
|
-
const { networkOperation } = useNetwork();
|
|
1036
|
-
const isDesktop = useResponsiveDesktop();
|
|
1037
|
-
const isSkeleton = useModuleSkeleton();
|
|
1038
|
-
const isFirstRender = useFirstRender([getLabel]);
|
|
1039
|
-
const areasStoreRef = useRef();
|
|
1040
|
-
if (!areasStoreRef.current) {
|
|
1041
|
-
areasStoreRef.current = createAreasStore({
|
|
1042
|
-
getLabel,
|
|
1043
|
-
loadAreasFromNetwork,
|
|
1044
|
-
loadCookiesFromNetwork,
|
|
1045
|
-
networkOperation,
|
|
1046
|
-
ownerState: {
|
|
1047
|
-
status: "init",
|
|
1048
|
-
isMobile: !isDesktop,
|
|
1049
|
-
isSkeleton,
|
|
1050
|
-
focus: false
|
|
1051
|
-
}
|
|
1052
|
-
// onLoad,
|
|
1053
|
-
});
|
|
1054
|
-
areasStoreRef.current?.getState().areasActions.init();
|
|
1055
|
-
}
|
|
1056
|
-
const status = useStore(areasStoreRef.current, (state) => state.ownerState.status, shallow);
|
|
1057
|
-
const currentModuleId = useStore(areasStoreRef.current, (state) => state.currentModuleId);
|
|
1058
|
-
const refCurrentModuleId = useRef("");
|
|
1059
|
-
const { setHandlerGetLabel, setExternalState } = useStore(
|
|
1060
|
-
areasStoreRef.current,
|
|
1061
|
-
(state) => state.areasActions,
|
|
1062
|
-
shallow
|
|
1063
|
-
);
|
|
1064
|
-
const addWindow = useCallback((newWindow) => {
|
|
1065
|
-
const currentAreaId = areasStoreRef.current?.getState().currentAreaId;
|
|
1066
|
-
const areas = areasStoreRef.current?.getState().areasIds;
|
|
1067
|
-
if (currentAreaId && areas) {
|
|
1068
|
-
areasStoreRef.current?.getState().areaActions.addWindow(newWindow);
|
|
1069
|
-
}
|
|
1070
|
-
}, []);
|
|
1071
|
-
useEffect(() => {
|
|
1072
|
-
if (status === "loaded") {
|
|
1073
|
-
onLoad && onLoad();
|
|
1074
|
-
}
|
|
1075
|
-
}, [status]);
|
|
1076
|
-
useEffect(() => {
|
|
1077
|
-
if (status === "loaded") {
|
|
1078
|
-
if (currentModuleId !== refCurrentModuleId.current) {
|
|
1079
|
-
onSelectLayout && onSelectLayout(currentModuleId);
|
|
1080
|
-
refCurrentModuleId.current = currentModuleId;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}, [currentModuleId, status]);
|
|
1084
|
-
useEffect(() => {
|
|
1085
|
-
if (!isFirstRender) {
|
|
1086
|
-
setHandlerGetLabel(getLabel);
|
|
1087
|
-
}
|
|
1088
|
-
}, [getLabel]);
|
|
1089
|
-
useEffect(() => {
|
|
1090
|
-
events_add_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
|
|
1091
|
-
return () => {
|
|
1092
|
-
events_remove_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
|
|
1093
|
-
};
|
|
1094
|
-
}, []);
|
|
1095
|
-
useEffect(() => {
|
|
1096
|
-
if (isFirstRender) {
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
setExternalState({ isMobile: !isDesktop, isSkeleton });
|
|
1100
|
-
}, [isDesktop, isSkeleton]);
|
|
1101
|
-
return /* @__PURE__ */ jsx(AreasContext.Provider, { value: areasStoreRef.current, children });
|
|
1102
|
-
}
|
|
1103
|
-
export {
|
|
1104
|
-
AreasProvider as A,
|
|
1105
|
-
MARGIN_GRIDLAYOUT as M,
|
|
1106
|
-
PADDING_GRIDLAYOUT as P,
|
|
1107
|
-
RESPONSIVE_COLAPSED_HEIGHTS as R,
|
|
1108
|
-
RESPONSIVE_ROW_HEIGHTS as a,
|
|
1109
|
-
AreasContext as b
|
|
1110
|
-
};
|