@m4l/components 1.0.0 → 1.0.2
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/components/AccountPopover/{index.efc74d5c.js → index.ec031003.js} +5 -3
- package/components/AppBar/{index.fc126a22.js → index.1499770b.js} +4 -4
- package/components/DragResizeWindow/{index.46b380e1.js → index.5e316291.js} +3 -3
- package/components/DynamicFilter/{index.d9168c12.js → index.05e15fb8.js} +28 -211
- package/components/FieldLabel/{index.f9cdcc27.js → index.400a46e0.js} +4 -4
- package/components/GridLayout/{index.bb3b7769.js → index.7156fbc9.js} +2 -2
- package/components/GridLayout/subcomponents/Griditem/{index.bb23f651.js → index.8946f18e.js} +4 -4
- package/components/GridLayout/subcomponents/Responsive/{index.b8a2a121.js → index.3c68f0cb.js} +2 -2
- package/components/GridLayout/subcomponents/SizeProvider/{index.094bc6b5.js → index.a5b2190d.js} +1 -1
- package/components/HamburgerMenu/{index.5997af31.js → index.d57bca4c.js} +3 -3
- package/components/HelperText/{index.be949cdf.js → index.651a9b4b.js} +1 -1
- package/components/Icon/index.2e8ec5a1.js +209 -0
- package/components/Image/index.0d32558e.js +168 -0
- package/components/LoadingError/{index.9f00c83c.js → index.d137be81.js} +5 -4
- package/components/MFLoader/{index.402c1acc.js → index.2038aa6c.js} +3 -3
- package/components/ModalDialog/{index.ea9189c3.js → index.85d30f10.js} +4 -4
- package/components/NavLink/{index.4e548cee.js → index.badec599.js} +2 -2
- package/components/NoItemSelected/{index.418c8316.js → index.008154ce.js} +2 -2
- package/components/ObjectLogs/{index.bfa7dad3.js → index.65a6b1bc.js} +8 -7
- package/components/PDFViewer/{index.bb2eca5a.js → index.9677b02a.js} +2 -2
- package/components/Page/index.7482cf60.js +98 -0
- package/components/PaperForm/{index.8121e3da.js → index.e04f9f1f.js} +2 -2
- package/components/Period/{index.5233694b.js → index.3d695534.js} +8 -103
- package/components/PrintingSystem/{index.fb176a93.js → index.89493ad6.js} +15 -14
- package/components/PrintingSystem/subcomponents/BodyNode/{index.c1d61038.js → index.fdd8cebb.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.18bd9bad.js → index.12293a60.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.67d9f1b4.js → index.7fdad1df.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.eaee152a.js → index.fcaf9b2f.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.f5f63a2a.js → index.03148990.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.7de4e411.js → index.691b5c38.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.f9ccf22b.js → index.3699b685.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.f2f2e903.js → index.bcc87da8.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.540a4b19.js → index.659f28e5.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.41e7fcb0.js → index.137ebb7a.js} +1 -1
- package/components/PropertyValue/{index.9572c347.js → index.e31d4282.js} +3 -3
- package/components/Resizeable/{index.1f0c1359.js → index.8c72e36a.js} +1 -1
- package/components/ScrollBar/{index.adf0eade.js → index.9bfcc74f.js} +1 -1
- package/components/SideBar/{index.629ba840.js → index.004a2de1.js} +7 -31
- package/components/SplitLayout/{index.74091a81.js → index.aed78a1f.js} +1 -1
- package/components/ToastContainer/{index.f9b507b9.js → index.586b1194.js} +3 -3
- package/components/areas/constants.630a4f42.js +293 -0
- package/components/areas/contexts/AreasContext/{index.bb316000.js → index.81b748ec.js} +4 -4
- package/components/areas/{dictionary.7e74022a.js → dictionary.19b25583.js} +26 -34
- package/components/areas/hooks/useAreas/{index.e24bd74d.js → index.b02d5bdc.js} +1 -1
- package/components/hook-form/HelperError/index.fd10c3ab.js +19 -0
- package/components/hook-form/RHFAutocompleteAsync/index.ea3ba7a7.js +160 -0
- package/components/hook-form/RHFCheckbox/index.9ac452cc.js +143 -0
- package/components/hook-form/RHFColorPicker/index.25e4e643.js +191 -0
- package/components/hook-form/RHFDateTime/index.31a0537d.js +190 -0
- package/components/hook-form/RHFMultiCheckbox/index.437e6ba3.js +34 -0
- package/components/hook-form/RHFPeriod/index.c8868100.js +105 -0
- package/components/hook-form/RHFRadioGroup/index.11c0add8.js +35 -0
- package/components/hook-form/RHFSelect/index.c6c60ecc.js +29 -0
- package/components/hook-form/RHFTextField/index.2ae1f130.js +326 -0
- package/components/{Image/index.36a3d440.js → hook-form/RHFUpload/index.9eeaee0f.js} +32 -232
- package/components/maps/components/GpsTools/index.ef751d28.js +251 -0
- package/components/maps/{index.8ec46ce4.js → index.ba1ccfad.js} +21 -555
- package/components/modal/{WindowBase.a3ac7adc.js → WindowBase.c1e879e4.js} +4 -3
- package/components/modal/{WindowConfirm.e35da619.js → WindowConfirm.1a123368.js} +6 -6
- package/components/modal/{index.a0e30c8b.js → index.7ca17f55.js} +1 -1
- package/components/mui_extended/Accordion/index.391679d1.js +143 -0
- package/components/mui_extended/Avatar/index.3ba36655.js +63 -0
- package/components/mui_extended/Badge/index.3465d7fb.js +31 -0
- package/components/mui_extended/BoxIcon/index.d61e7ac5.js +22 -0
- package/components/mui_extended/Breadcrumbs/index.4a44883c.js +87 -0
- package/components/mui_extended/Button/index.a7dc6ef0.js +289 -0
- package/components/mui_extended/CheckBox/index.c5c8721c.js +76 -0
- package/components/mui_extended/CircularProgress/index.967e70b7.js +8 -0
- package/components/mui_extended/IconButton/index.87f4726c.js +120 -0
- package/components/{LinearProgressIndeterminate/index.de9d447c.js → mui_extended/LinearProgress/index.52edc848.js} +11 -4
- package/components/mui_extended/LinkWithRoute/index.288c51f3.js +15 -0
- package/components/{Page/index.fdf04592.js → mui_extended/Pager/index.46aec921.js} +9 -98
- package/components/mui_extended/Popover/index.8e5ac765.js +1041 -0
- package/components/mui_extended/Stack/index.fe363ca5.js +31 -0
- package/components/{maps/components/GpsTools/index.75880ce0.js → mui_extended/Tab/index.ad88441e.js} +674 -239
- package/components/mui_extended/ToggleButton/index.38ca2330.js +18 -0
- package/components/mui_extended/ToggleIconButton/index.7fbece74.js +24 -0
- package/components/mui_extended/Tooltip/index.49bb5ee1.js +40 -0
- package/components/mui_extended/Typography/index.2a1c68f8.js +55 -0
- package/components/popups/PopupsProvider/{index.18669fb4.js → index.3b43e55f.js} +1 -1
- package/components/popups/PopupsViewer/{index.ba354267.js → index.fb3f0c48.js} +5 -4
- package/contexts/ModalContext/{index.cf02e6bd.js → index.82f61407.js} +1 -1
- package/contexts/RHFormContext/{index.dc955a09.js → index.e942a298.js} +1 -1
- package/hooks/useFormAddEdit/{index.f156a2cd.js → index.fa430551.js} +2 -2
- package/hooks/useModal/{index.ef54bcf2.js → index.9fe41bde.js} +3 -3
- package/index.js +266 -239
- package/package.json +1 -1
- package/{react-draggable.5331add7.js → react-draggable.2df3b71a.js} +1 -1
- package/{react-resizable.37bfb965.js → react-resizable.c60f3843.js} +2 -2
- package/utils/{index.9ee4c99a.js → index.0660ee9c.js} +9 -62
- package/{vendor.a1ce6777.js → vendor.3eadfa16.js} +746 -3011
- package/components/Icon/index.d5fed418.js +0 -420
- package/components/LanguagePopover/index.e6fa2336.js +0 -184
- package/components/areas/constants.5387d83e.js +0 -412
- package/hooks/useTab/index.bce8b99e.js +0 -12
|
@@ -0,0 +1,1041 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { u as useDynamicFilterStore, P as PopoverMenuStyled, a as PopoverMenuItemStyled, b as PopoverMenuItemIconStyled, c as PopoverMenuItemLabelStyled, f as fieldFactory, d as PopoverStyled, e as PopoverHeaderStyled, g as PopoverHeaderIconStyled, h as PopoverHeaderTitleStyled, i as PopoverContainerFieldsStyled, j as DataTypeComponent, k as PopoverHeaderActionsStyled } from "../../DynamicFilter/index.05e15fb8.js";
|
|
3
|
+
import { useModuleDictionary, useEnvironment, useNetwork, useModulePrivileges } from "@m4l/core";
|
|
4
|
+
import React__default, { useRef, useMemo, useCallback, useState, useEffect } from "react";
|
|
5
|
+
import { R as RHFormProvider } from "../../../contexts/RHFormContext/index.e942a298.js";
|
|
6
|
+
import { d as ActionCancel, e as ActionIntro, C as ColumnSetCheckFormatter, a as DataGrid } from "../../../vendor.3eadfa16.js";
|
|
7
|
+
import { Popover as Popover$1, generateUtilityClasses, generateUtilityClass, styled as styled$1, Stack, MenuItem, Tooltip, FormControl, RadioGroup, FormControlLabel, Radio, useTheme } from "@mui/material";
|
|
8
|
+
import { I as Image } from "../../Image/index.0d32558e.js";
|
|
9
|
+
import { useLocales } from "@m4l/graphics";
|
|
10
|
+
import { styled } from "@mui/material/styles";
|
|
11
|
+
import { I as ImageButton } from "../Button/index.a7dc6ef0.js";
|
|
12
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
13
|
+
import { T as TEST_PROP_ID } from "../../areas/constants.630a4f42.js";
|
|
14
|
+
import { C as CircularProgress } from "../CircularProgress/index.967e70b7.js";
|
|
15
|
+
import { M as MAP_DICCTIONARY } from "../../areas/dictionary.19b25583.js";
|
|
16
|
+
import { M as MAP_ICONS } from "../../areas/icons.504ec098.js";
|
|
17
|
+
import { shallow } from "zustand/shallow";
|
|
18
|
+
import { I as Icon } from "../../Icon/index.2e8ec5a1.js";
|
|
19
|
+
import { u as useMapStore, a as useDisableZoomEvents, m as mapClasses } from "../../maps/index.ba1ccfad.js";
|
|
20
|
+
import { u as useStateRef } from "../../../hooks/useStateRef/index.538edb89.js";
|
|
21
|
+
import clsx from "clsx";
|
|
22
|
+
import { C as CheckBox } from "../CheckBox/index.c5c8721c.js";
|
|
23
|
+
import { I as IconButton } from "../IconButton/index.87f4726c.js";
|
|
24
|
+
const PopoverRoot = styled(Popover$1)(({ theme }) => ({
|
|
25
|
+
...theme.components?.M4LPopover?.styleOverrides
|
|
26
|
+
}));
|
|
27
|
+
generateUtilityClasses("M4LPopover", [
|
|
28
|
+
"root",
|
|
29
|
+
"arrowStyle",
|
|
30
|
+
"noArrow",
|
|
31
|
+
"topLeft",
|
|
32
|
+
"topCenter",
|
|
33
|
+
"topRight",
|
|
34
|
+
"bottomLeft",
|
|
35
|
+
"bottomCenter",
|
|
36
|
+
"bottomRight",
|
|
37
|
+
"leftTop",
|
|
38
|
+
"leftCenter",
|
|
39
|
+
"leftBottom",
|
|
40
|
+
"rightTop",
|
|
41
|
+
"rightCenter",
|
|
42
|
+
"rightBottom"
|
|
43
|
+
]);
|
|
44
|
+
function getPopoverClassesUtilityClass(slot) {
|
|
45
|
+
return generateUtilityClass("M4LPopover", slot);
|
|
46
|
+
}
|
|
47
|
+
const useUtilityClasses$1 = (ownerState) => {
|
|
48
|
+
const slots = {
|
|
49
|
+
root: ["root"],
|
|
50
|
+
arrowStyle: [
|
|
51
|
+
"arrowStyle",
|
|
52
|
+
ownerState.arrowType === "top-left" && "topLeft",
|
|
53
|
+
ownerState.arrowType === "top-center" && "topCenter",
|
|
54
|
+
ownerState.arrowType === "top-right" && "topRight",
|
|
55
|
+
ownerState.arrowType === "bottom-left" && "bottomLeft",
|
|
56
|
+
ownerState.arrowType === "bottom-center" && "bottomCenter",
|
|
57
|
+
ownerState.arrowType === "bottom-right" && "bottomRight",
|
|
58
|
+
ownerState.arrowType === "left-top" && "leftTop",
|
|
59
|
+
ownerState.arrowType === "left-center" && "leftCenter",
|
|
60
|
+
ownerState.arrowType === "left-bottom" && "leftBottom",
|
|
61
|
+
ownerState.arrowType === "right-top" && "rightTop",
|
|
62
|
+
ownerState.arrowType === "right-center" && "rightCenter",
|
|
63
|
+
ownerState.arrowType === "right-bottom" && "rightBottom"
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
const composedClasses = unstable_composeClasses(slots, getPopoverClassesUtilityClass, {});
|
|
67
|
+
return {
|
|
68
|
+
...composedClasses
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const ArrowStyle = styled$1("span")(({ arrowType, theme }) => {
|
|
72
|
+
const SIZE = 12;
|
|
73
|
+
const POSITION = -(SIZE / 2);
|
|
74
|
+
const borderStyle = `solid 1px ${theme.vars.palette.state.borderDens}`;
|
|
75
|
+
const topStyle = {
|
|
76
|
+
borderRadius: "0 0 3px 0",
|
|
77
|
+
top: POSITION,
|
|
78
|
+
borderBottom: borderStyle,
|
|
79
|
+
borderRight: borderStyle
|
|
80
|
+
};
|
|
81
|
+
const bottomStyle = {
|
|
82
|
+
borderRadius: "3px 0 0 0",
|
|
83
|
+
bottom: POSITION,
|
|
84
|
+
borderTop: borderStyle,
|
|
85
|
+
borderLeft: borderStyle
|
|
86
|
+
};
|
|
87
|
+
const leftStyle = {
|
|
88
|
+
borderRadius: "0 3px 0 0",
|
|
89
|
+
left: POSITION,
|
|
90
|
+
borderTop: borderStyle,
|
|
91
|
+
borderRight: borderStyle
|
|
92
|
+
};
|
|
93
|
+
const rightStyle = {
|
|
94
|
+
borderRadius: "0 0 0 3px",
|
|
95
|
+
right: POSITION,
|
|
96
|
+
borderBottom: borderStyle,
|
|
97
|
+
borderLeft: borderStyle
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
display: "none",
|
|
101
|
+
[theme.breakpoints.up("sm")]: {
|
|
102
|
+
width: SIZE,
|
|
103
|
+
height: SIZE,
|
|
104
|
+
content: "''",
|
|
105
|
+
position: "absolute",
|
|
106
|
+
display: "block",
|
|
107
|
+
transform: "rotate(-135deg)",
|
|
108
|
+
background: theme.vars.palette.background.default
|
|
109
|
+
},
|
|
110
|
+
...arrowType === "top-left" && { ...topStyle, left: 20 },
|
|
111
|
+
...arrowType === "top-center" && { ...topStyle, left: 0, right: 0, margin: "auto" },
|
|
112
|
+
...arrowType === "top-right" && { ...topStyle, right: 20 },
|
|
113
|
+
...arrowType === "bottom-left" && { ...bottomStyle, left: 20 },
|
|
114
|
+
...arrowType === "bottom-center" && { ...bottomStyle, left: 0, right: 0, margin: "auto" },
|
|
115
|
+
...arrowType === "bottom-right" && { ...bottomStyle, right: 20 },
|
|
116
|
+
...arrowType === "left-top" && { ...leftStyle, top: 20 },
|
|
117
|
+
...arrowType === "left-center" && { ...leftStyle, top: 0, bottom: 0, margin: "auto" },
|
|
118
|
+
...arrowType === "left-bottom" && { ...leftStyle, bottom: 20 },
|
|
119
|
+
...arrowType === "right-top" && { ...rightStyle, top: 20 },
|
|
120
|
+
...arrowType === "right-center" && { ...rightStyle, top: 0, bottom: 0, margin: "auto" },
|
|
121
|
+
...arrowType === "right-bottom" && { ...rightStyle, bottom: 20 }
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
const Popover = (props) => {
|
|
125
|
+
const { children, arrowType = "top-right", className, ...other } = props;
|
|
126
|
+
const ownerState = {
|
|
127
|
+
arrowType
|
|
128
|
+
};
|
|
129
|
+
const classes = useUtilityClasses$1(ownerState);
|
|
130
|
+
return /* @__PURE__ */ jsxs(
|
|
131
|
+
PopoverRoot,
|
|
132
|
+
{
|
|
133
|
+
className: clsx(classes.root, className),
|
|
134
|
+
"data-testid": "PopoverRoot",
|
|
135
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
136
|
+
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
137
|
+
transitionDuration: 0,
|
|
138
|
+
PaperProps: {
|
|
139
|
+
sx: {
|
|
140
|
+
p: 1,
|
|
141
|
+
overflow: "inherit"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
...other,
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx(
|
|
147
|
+
ArrowStyle,
|
|
148
|
+
{
|
|
149
|
+
className: classes.arrowStyle,
|
|
150
|
+
"data-testid": "ArrowStyle",
|
|
151
|
+
arrowType
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
children
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
function usePopoverMenuFields() {
|
|
160
|
+
const { getLabel } = useModuleDictionary();
|
|
161
|
+
const fnAnchorEl = useDynamicFilterStore((state) => state.fnAnchorEl);
|
|
162
|
+
const { showPopoverFilterForAdd, closePopoverMenuFields } = useDynamicFilterStore(
|
|
163
|
+
(state) => state.actions
|
|
164
|
+
);
|
|
165
|
+
function handleOpenPopUpClickItem(_event, field) {
|
|
166
|
+
if (fnAnchorEl) {
|
|
167
|
+
showPopoverFilterForAdd(fnAnchorEl(), field);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function handleClosePopover() {
|
|
171
|
+
closePopoverMenuFields(false);
|
|
172
|
+
}
|
|
173
|
+
function getItemLabel(field) {
|
|
174
|
+
return field.label ?? getLabel(field.dictionaryId);
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
fnAnchorEl,
|
|
178
|
+
getItemLabel,
|
|
179
|
+
handleClosePopover,
|
|
180
|
+
handleOpenPopUpClickItem
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function PopoverMenuFields(props) {
|
|
184
|
+
const { fields, selectFieldIndex } = props;
|
|
185
|
+
const { fnAnchorEl, handleOpenPopUpClickItem, handleClosePopover, getItemLabel } = usePopoverMenuFields();
|
|
186
|
+
return /* @__PURE__ */ jsx(
|
|
187
|
+
PopoverMenuStyled,
|
|
188
|
+
{
|
|
189
|
+
disableAutoFocus: true,
|
|
190
|
+
disableRestoreFocus: true,
|
|
191
|
+
arrowType: "top-left",
|
|
192
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
193
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
194
|
+
open: Boolean(fnAnchorEl),
|
|
195
|
+
onClose: handleClosePopover,
|
|
196
|
+
anchorEl: fnAnchorEl?.(),
|
|
197
|
+
ownerState: {},
|
|
198
|
+
children: Boolean(fnAnchorEl) && fields.map((field, index) => /* @__PURE__ */ jsxs(
|
|
199
|
+
PopoverMenuItemStyled,
|
|
200
|
+
{
|
|
201
|
+
dense: true,
|
|
202
|
+
selected: index === selectFieldIndex,
|
|
203
|
+
onClick: (event) => handleOpenPopUpClickItem(event, field),
|
|
204
|
+
ownerState: {},
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsx(PopoverMenuItemIconStyled, { src: field.urlIcon, ownerState: {} }),
|
|
207
|
+
/* @__PURE__ */ jsx(PopoverMenuItemLabelStyled, { ownerState: {}, children: getItemLabel(field) })
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
`menu_action_${getItemLabel(field)}`
|
|
211
|
+
))
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
function usePopoverFilter() {
|
|
216
|
+
let anchorEl;
|
|
217
|
+
let field;
|
|
218
|
+
let formFilter;
|
|
219
|
+
let filterFormValue;
|
|
220
|
+
let popupValidationSchema;
|
|
221
|
+
const { getLabel } = useModuleDictionary();
|
|
222
|
+
const popoverFilterData = useDynamicFilterStore((state) => state.popoverFilterData);
|
|
223
|
+
const { hidePopoverFilter, addFilter, updateFilter, getNewId } = useDynamicFilterStore(
|
|
224
|
+
(state) => state.actions
|
|
225
|
+
);
|
|
226
|
+
const refPreviousPopoverFilterData = useRef(popoverFilterData);
|
|
227
|
+
const statusLoad = useMemo(() => {
|
|
228
|
+
let returnStatus;
|
|
229
|
+
if (popoverFilterData && refPreviousPopoverFilterData.current === void 0) {
|
|
230
|
+
returnStatus = "ready";
|
|
231
|
+
} else if (!popoverFilterData) {
|
|
232
|
+
returnStatus = "initial";
|
|
233
|
+
} else {
|
|
234
|
+
returnStatus = "reload_values_provider";
|
|
235
|
+
}
|
|
236
|
+
refPreviousPopoverFilterData.current = popoverFilterData;
|
|
237
|
+
return returnStatus;
|
|
238
|
+
}, [popoverFilterData]);
|
|
239
|
+
if (popoverFilterData?.openFor === "add") {
|
|
240
|
+
anchorEl = popoverFilterData?.fnAnchorEl();
|
|
241
|
+
field = popoverFilterData.field;
|
|
242
|
+
const helperField = fieldFactory(field.type);
|
|
243
|
+
popupValidationSchema = helperField.getSchema(getLabel);
|
|
244
|
+
filterFormValue = helperField.getFormValue(field, getLabel);
|
|
245
|
+
formFilter = {
|
|
246
|
+
field,
|
|
247
|
+
id: getNewId(),
|
|
248
|
+
isSet: true,
|
|
249
|
+
fixed: false,
|
|
250
|
+
...filterFormValue
|
|
251
|
+
};
|
|
252
|
+
} else if (popoverFilterData) {
|
|
253
|
+
anchorEl = popoverFilterData?.fnAnchorEl();
|
|
254
|
+
field = popoverFilterData?.filter.field;
|
|
255
|
+
const helperField = fieldFactory(field.type);
|
|
256
|
+
popupValidationSchema = helperField.getSchema(getLabel);
|
|
257
|
+
filterFormValue = helperField.getFormValue(field, getLabel, popoverFilterData.filter);
|
|
258
|
+
formFilter = { ...popoverFilterData?.filter, ...filterFormValue };
|
|
259
|
+
} else {
|
|
260
|
+
filterFormValue = {};
|
|
261
|
+
field = {};
|
|
262
|
+
formFilter = {};
|
|
263
|
+
anchorEl = {};
|
|
264
|
+
}
|
|
265
|
+
const onClose = useCallback(() => {
|
|
266
|
+
hidePopoverFilter(false);
|
|
267
|
+
}, []);
|
|
268
|
+
const handleKeyDownPopper = useCallback((event) => {
|
|
269
|
+
if (event.key === "Escape") {
|
|
270
|
+
onClose();
|
|
271
|
+
}
|
|
272
|
+
}, []);
|
|
273
|
+
function handleClosePopover() {
|
|
274
|
+
hidePopoverFilter(false);
|
|
275
|
+
}
|
|
276
|
+
async function onSubmit(dataFieldValues) {
|
|
277
|
+
const filterField = { ...filterFormValue, ...dataFieldValues };
|
|
278
|
+
const newFilter = {
|
|
279
|
+
...formFilter,
|
|
280
|
+
...fieldFactory(filterField.fieldType).getFilterFromFormValue(filterField),
|
|
281
|
+
isSet: true
|
|
282
|
+
};
|
|
283
|
+
if (popoverFilterData?.openFor === "add") {
|
|
284
|
+
addFilter(newFilter);
|
|
285
|
+
} else {
|
|
286
|
+
updateFilter(newFilter);
|
|
287
|
+
}
|
|
288
|
+
hidePopoverFilter(false);
|
|
289
|
+
}
|
|
290
|
+
const labelField = field?.label ?? getLabel(field?.dictionaryId ?? "");
|
|
291
|
+
return {
|
|
292
|
+
field,
|
|
293
|
+
labelField,
|
|
294
|
+
canRender: Boolean(popoverFilterData),
|
|
295
|
+
anchorEl,
|
|
296
|
+
handleKeyDownPopper,
|
|
297
|
+
handleClosePopover,
|
|
298
|
+
onSubmit,
|
|
299
|
+
onClose,
|
|
300
|
+
filterFormValue,
|
|
301
|
+
formFilter,
|
|
302
|
+
popupValidationSchema,
|
|
303
|
+
statusLoad
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function PopoverFilter() {
|
|
307
|
+
const {
|
|
308
|
+
field,
|
|
309
|
+
labelField,
|
|
310
|
+
anchorEl,
|
|
311
|
+
handleKeyDownPopper,
|
|
312
|
+
handleClosePopover,
|
|
313
|
+
onSubmit,
|
|
314
|
+
onClose,
|
|
315
|
+
filterFormValue,
|
|
316
|
+
formFilter,
|
|
317
|
+
popupValidationSchema,
|
|
318
|
+
statusLoad,
|
|
319
|
+
canRender
|
|
320
|
+
} = usePopoverFilter();
|
|
321
|
+
if (!canRender) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
return /* @__PURE__ */ jsx(
|
|
325
|
+
PopoverStyled,
|
|
326
|
+
{
|
|
327
|
+
open: true,
|
|
328
|
+
disableRestoreFocus: true,
|
|
329
|
+
transitionDuration: 0,
|
|
330
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
331
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
332
|
+
arrowType: "top-left",
|
|
333
|
+
anchorEl,
|
|
334
|
+
onKeyDown: handleKeyDownPopper,
|
|
335
|
+
onClose: handleClosePopover,
|
|
336
|
+
ownerState: {},
|
|
337
|
+
children: /* @__PURE__ */ jsxs(
|
|
338
|
+
RHFormProvider,
|
|
339
|
+
{
|
|
340
|
+
onSubmit,
|
|
341
|
+
values: filterFormValue,
|
|
342
|
+
validationSchema: popupValidationSchema,
|
|
343
|
+
statusLoad,
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ jsxs(PopoverHeaderStyled, { ownerState: {}, children: [
|
|
346
|
+
field.urlIcon && /* @__PURE__ */ jsx(PopoverHeaderIconStyled, { src: field.urlIcon, ownerState: {} }),
|
|
347
|
+
/* @__PURE__ */ jsx(PopoverHeaderTitleStyled, { variant: "paragraphDens", ownerState: {}, children: labelField })
|
|
348
|
+
] }),
|
|
349
|
+
/* @__PURE__ */ jsx(PopoverContainerFieldsStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(DataTypeComponent, { formFilter, statusLoad }) }),
|
|
350
|
+
/* @__PURE__ */ jsxs(PopoverHeaderActionsStyled, { ownerState: {}, children: [
|
|
351
|
+
/* @__PURE__ */ jsx(ActionCancel, { onClick: onClose, skeletonWidth: "68px" }),
|
|
352
|
+
/* @__PURE__ */ jsx(ActionIntro, { skeletonWidth: "64px" })
|
|
353
|
+
] })
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
const LanguagePopoverRoot = styled("div")(({ theme }) => ({
|
|
361
|
+
...theme.components?.M4LanguagePopover?.styleOverrides
|
|
362
|
+
}));
|
|
363
|
+
const LabelItem = styled("div")(({ theme }) => ({
|
|
364
|
+
marginLeft: theme.spacing(1)
|
|
365
|
+
}));
|
|
366
|
+
const ContainerProgress = styled("div")(({ theme }) => ({
|
|
367
|
+
padding: theme.spacing(0.75, 0),
|
|
368
|
+
margin: theme.spacing(0, 1.25)
|
|
369
|
+
}));
|
|
370
|
+
const ContainerMenuItems = styled("div")(() => ({
|
|
371
|
+
display: "flex",
|
|
372
|
+
flexDirection: "column"
|
|
373
|
+
}));
|
|
374
|
+
const ContainerImage = styled("div")(() => ({
|
|
375
|
+
display: "flex",
|
|
376
|
+
gap: "4px",
|
|
377
|
+
width: "16px",
|
|
378
|
+
height: "16px"
|
|
379
|
+
}));
|
|
380
|
+
const componentName = "M4LanguagePopover";
|
|
381
|
+
generateUtilityClasses(
|
|
382
|
+
componentName,
|
|
383
|
+
[
|
|
384
|
+
"root",
|
|
385
|
+
"containerItems",
|
|
386
|
+
"containerProgress",
|
|
387
|
+
"labelItem",
|
|
388
|
+
"imageButton"
|
|
389
|
+
]
|
|
390
|
+
);
|
|
391
|
+
function getM4LanguagePopoverClassesUtilityClass(slot) {
|
|
392
|
+
return generateUtilityClass(componentName, slot);
|
|
393
|
+
}
|
|
394
|
+
const useUtilityClasses = () => {
|
|
395
|
+
const slots = {
|
|
396
|
+
root: ["root"],
|
|
397
|
+
containerItems: ["containerItems"],
|
|
398
|
+
containerProgress: ["containerProgress"],
|
|
399
|
+
labelItem: ["labelItem"]
|
|
400
|
+
};
|
|
401
|
+
const composedClasses = unstable_composeClasses(slots, getM4LanguagePopoverClassesUtilityClass, {});
|
|
402
|
+
return {
|
|
403
|
+
...composedClasses
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
const LANGUAGEPOPOVER_PREFIX = "LanguagePopover";
|
|
407
|
+
const getNameDataTestId = (KEY) => {
|
|
408
|
+
return `${LANGUAGEPOPOVER_PREFIX}-${KEY}`;
|
|
409
|
+
};
|
|
410
|
+
function LanguagePopover(props) {
|
|
411
|
+
const { testingProps } = props;
|
|
412
|
+
const { currentLocale, onChangeLocale } = useLocales();
|
|
413
|
+
const { domain_token } = useEnvironment();
|
|
414
|
+
const { networkOperation } = useNetwork();
|
|
415
|
+
const [open, setOpen] = useState(testingProps?.open || null);
|
|
416
|
+
const [loading, setLoading] = useState(testingProps?.loading || false);
|
|
417
|
+
const [allLocales, setAllLocales] = useState(
|
|
418
|
+
testingProps?.allLocales || []
|
|
419
|
+
);
|
|
420
|
+
const handleOpen = (event) => {
|
|
421
|
+
setOpen(event.currentTarget);
|
|
422
|
+
};
|
|
423
|
+
const handleClose = () => {
|
|
424
|
+
setOpen(null);
|
|
425
|
+
};
|
|
426
|
+
useEffect(() => {
|
|
427
|
+
let mounted = true;
|
|
428
|
+
if (open === null || loading || allLocales.length > 0) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
setLoading(true);
|
|
432
|
+
networkOperation({
|
|
433
|
+
method: "GET",
|
|
434
|
+
endPoint: `na/locales`,
|
|
435
|
+
parms: { domain_token }
|
|
436
|
+
}).then((response) => {
|
|
437
|
+
if (mounted) {
|
|
438
|
+
!testingProps && setAllLocales(response.data);
|
|
439
|
+
}
|
|
440
|
+
}).finally(() => {
|
|
441
|
+
setLoading(false);
|
|
442
|
+
});
|
|
443
|
+
return function cleanUp() {
|
|
444
|
+
mounted = false;
|
|
445
|
+
};
|
|
446
|
+
}, [open]);
|
|
447
|
+
const classes = useUtilityClasses();
|
|
448
|
+
return /* @__PURE__ */ jsxs(
|
|
449
|
+
LanguagePopoverRoot,
|
|
450
|
+
{
|
|
451
|
+
className: classes.root,
|
|
452
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("root") } : {},
|
|
453
|
+
children: [
|
|
454
|
+
/* @__PURE__ */ jsx(
|
|
455
|
+
ImageButton,
|
|
456
|
+
{
|
|
457
|
+
className: classes.imageButton,
|
|
458
|
+
onClick: handleOpen,
|
|
459
|
+
sx: {
|
|
460
|
+
width: 28,
|
|
461
|
+
height: 28,
|
|
462
|
+
...open && { bgcolor: "action.selected" }
|
|
463
|
+
},
|
|
464
|
+
src: currentLocale?.url_icon || "",
|
|
465
|
+
alt: currentLocale?.name,
|
|
466
|
+
width: "24px",
|
|
467
|
+
height: "24px",
|
|
468
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("imageButton") } : {}
|
|
469
|
+
}
|
|
470
|
+
),
|
|
471
|
+
/* @__PURE__ */ jsx(
|
|
472
|
+
Popover,
|
|
473
|
+
{
|
|
474
|
+
arrowType: "top-right",
|
|
475
|
+
open: Boolean(open),
|
|
476
|
+
anchorEl: open,
|
|
477
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
478
|
+
onClose: handleClose,
|
|
479
|
+
sx: {
|
|
480
|
+
mt: 1.5,
|
|
481
|
+
ml: 0.75,
|
|
482
|
+
width: 180,
|
|
483
|
+
rowGap: "100px",
|
|
484
|
+
"& .MuiMenuItem-root": { px: 1, typography: "body2", borderRadius: 0.75 }
|
|
485
|
+
},
|
|
486
|
+
children: /* @__PURE__ */ jsxs(
|
|
487
|
+
ContainerMenuItems,
|
|
488
|
+
{
|
|
489
|
+
className: classes.containerItems,
|
|
490
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("containerItems") } : {},
|
|
491
|
+
children: [
|
|
492
|
+
allLocales.length === 0 && /* @__PURE__ */ jsx(
|
|
493
|
+
ContainerProgress,
|
|
494
|
+
{
|
|
495
|
+
className: classes.containerProgress,
|
|
496
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("containerProgress") } : {},
|
|
497
|
+
children: /* @__PURE__ */ jsx(CircularProgress, { size: "20px" })
|
|
498
|
+
}
|
|
499
|
+
),
|
|
500
|
+
allLocales.length > 0 && /* @__PURE__ */ jsx(Stack, { spacing: 0.75, children: allLocales.map((option) => /* @__PURE__ */ jsxs(
|
|
501
|
+
MenuItem,
|
|
502
|
+
{
|
|
503
|
+
selected: option.lang === currentLocale?.lang && option?.script === currentLocale?.script && option?.region === currentLocale?.region,
|
|
504
|
+
onClick: () => {
|
|
505
|
+
onChangeLocale(option);
|
|
506
|
+
handleClose();
|
|
507
|
+
},
|
|
508
|
+
children: [
|
|
509
|
+
/* @__PURE__ */ jsx(ContainerImage, { children: /* @__PURE__ */ jsx(Image, { alt: option.name, src: option.url_icon, ratio: "1:1" }) }),
|
|
510
|
+
/* @__PURE__ */ jsx(
|
|
511
|
+
LabelItem,
|
|
512
|
+
{
|
|
513
|
+
className: classes.labelItem,
|
|
514
|
+
...process.env.NODE_ENV !== "production" ? {
|
|
515
|
+
[TEST_PROP_ID]: getNameDataTestId("labelItem")
|
|
516
|
+
} : {},
|
|
517
|
+
children: option.name
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
]
|
|
521
|
+
},
|
|
522
|
+
option.lang || option.script || option.region
|
|
523
|
+
)) })
|
|
524
|
+
]
|
|
525
|
+
}
|
|
526
|
+
)
|
|
527
|
+
}
|
|
528
|
+
)
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
const TILE_LAYER_OSM = {
|
|
534
|
+
id: "osm_roadmap",
|
|
535
|
+
sourceType: "OSM",
|
|
536
|
+
iconUrl: MAP_ICONS.MAP_SOURCE_OSM,
|
|
537
|
+
mapTypeTile: "roadmap",
|
|
538
|
+
dictionaryId: MAP_DICCTIONARY.LABEL_TILE_OSM,
|
|
539
|
+
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
540
|
+
options: {
|
|
541
|
+
minZoom: 0,
|
|
542
|
+
maxZoom: 19,
|
|
543
|
+
subdomains: ["a", "b", "c"],
|
|
544
|
+
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a>',
|
|
545
|
+
tms: false
|
|
546
|
+
},
|
|
547
|
+
roadSelectedOptions: {
|
|
548
|
+
trafficLayer: false,
|
|
549
|
+
transitLayer: false,
|
|
550
|
+
bicyclingLayer: false
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
const TILE_LAYER_GOOGLE = {
|
|
554
|
+
id: "google_rodmap",
|
|
555
|
+
sourceType: "Google",
|
|
556
|
+
iconUrl: MAP_ICONS.MAP_SOURCE_GOOGLE_ROADS,
|
|
557
|
+
mapTypeTile: "roadmap",
|
|
558
|
+
dictionaryId: MAP_DICCTIONARY.LABEL_TILE_GOOGLE,
|
|
559
|
+
urlTemplate: "http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}&key=AIzaSyDfhTK9us4kuqPTeFIm89yB3uvk2_G5AMw",
|
|
560
|
+
hasBicyclingLayer: true,
|
|
561
|
+
hasTrafficLayer: true,
|
|
562
|
+
hasTransitLayer: true,
|
|
563
|
+
options: {
|
|
564
|
+
minZoom: 0,
|
|
565
|
+
maxZoom: 22,
|
|
566
|
+
subdomains: ["mt0", "mt1", "mt2", "mt3"],
|
|
567
|
+
attribution: "Map data \xA9 Google",
|
|
568
|
+
tms: false
|
|
569
|
+
},
|
|
570
|
+
roadSelectedOptions: {
|
|
571
|
+
trafficLayer: false,
|
|
572
|
+
transitLayer: false,
|
|
573
|
+
bicyclingLayer: false
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
const TILE_LAYER_GOOGLE_SATELLITE = {
|
|
577
|
+
id: "google_satellite",
|
|
578
|
+
sourceType: "Google",
|
|
579
|
+
iconUrl: MAP_ICONS.MAP_SOURCE_GOOGLE_SATELLITE,
|
|
580
|
+
mapTypeTile: "satellite",
|
|
581
|
+
dictionaryId: MAP_DICCTIONARY.LABEL_TILE_GOOGLE_SATELLITE,
|
|
582
|
+
urlTemplate: "http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}&key=AIzaSyDfhTK9us4kuqPTeFIm89yB3uvk2_G5AMw",
|
|
583
|
+
options: {
|
|
584
|
+
minZoom: 0,
|
|
585
|
+
maxZoom: 22,
|
|
586
|
+
subdomains: ["mt0", "mt1", "mt2", "mt3"],
|
|
587
|
+
attribution: "Map data \xA9 Google",
|
|
588
|
+
tms: false
|
|
589
|
+
},
|
|
590
|
+
roadSelectedOptions: {
|
|
591
|
+
trafficLayer: false,
|
|
592
|
+
transitLayer: false,
|
|
593
|
+
bicyclingLayer: false
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
const TILE_LAYER_GOOGLE_HYBRID = {
|
|
597
|
+
id: "google_hybrid",
|
|
598
|
+
sourceType: "Google",
|
|
599
|
+
iconUrl: MAP_ICONS.MAP_SOURCE_GOOGLE_HYBRID,
|
|
600
|
+
mapTypeTile: "hybrid",
|
|
601
|
+
dictionaryId: MAP_DICCTIONARY.LABEL_TILE_GOOGLE_HYBRID,
|
|
602
|
+
urlTemplate: "http://{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}&key=AIzaSyDfhTK9us4kuqPTeFIm89yB3uvk2_G5AMw",
|
|
603
|
+
hasBicyclingLayer: true,
|
|
604
|
+
hasTrafficLayer: true,
|
|
605
|
+
hasTransitLayer: true,
|
|
606
|
+
options: {
|
|
607
|
+
minZoom: 0,
|
|
608
|
+
maxZoom: 22,
|
|
609
|
+
subdomains: ["mt0", "mt1", "mt2", "mt3"],
|
|
610
|
+
attribution: "Map data \xA9 Google",
|
|
611
|
+
tms: false
|
|
612
|
+
},
|
|
613
|
+
roadSelectedOptions: {
|
|
614
|
+
trafficLayer: false,
|
|
615
|
+
transitLayer: false,
|
|
616
|
+
bicyclingLayer: false
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
function toQuadKey(x, y, z) {
|
|
620
|
+
let quadKey = "";
|
|
621
|
+
for (let i = z; i > 0; i--) {
|
|
622
|
+
let digit = 0;
|
|
623
|
+
const mask = 1 << i - 1;
|
|
624
|
+
if ((x & mask) !== 0) {
|
|
625
|
+
digit++;
|
|
626
|
+
}
|
|
627
|
+
if ((y & mask) !== 0) {
|
|
628
|
+
digit++;
|
|
629
|
+
digit++;
|
|
630
|
+
}
|
|
631
|
+
quadKey += digit.toString();
|
|
632
|
+
}
|
|
633
|
+
return quadKey;
|
|
634
|
+
}
|
|
635
|
+
const BING_URL_TEMPLATE = "https://{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/|QK|?mkt=en-us&it=G,VE,BX,L,LA&shading=hill&og=22&n=z";
|
|
636
|
+
const BING_SUB_DOMAINS = ["t2", "t3"];
|
|
637
|
+
const TILE_LAYER_BING = {
|
|
638
|
+
id: "bing_rodmap",
|
|
639
|
+
sourceType: "Bing",
|
|
640
|
+
mapTypeTile: "roadmap",
|
|
641
|
+
dictionaryId: MAP_DICCTIONARY.LABEL_TILE_BING,
|
|
642
|
+
iconUrl: MAP_ICONS.MAP_SOURCE_BING,
|
|
643
|
+
urlTemplate: BING_URL_TEMPLATE,
|
|
644
|
+
options: {
|
|
645
|
+
minZoom: 0,
|
|
646
|
+
maxZoom: 21,
|
|
647
|
+
subdomains: BING_SUB_DOMAINS,
|
|
648
|
+
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a>',
|
|
649
|
+
tms: true
|
|
650
|
+
},
|
|
651
|
+
roadSelectedOptions: {
|
|
652
|
+
trafficLayer: false,
|
|
653
|
+
transitLayer: false,
|
|
654
|
+
bicyclingLayer: false
|
|
655
|
+
},
|
|
656
|
+
getTileUrl: (tileCoord) => {
|
|
657
|
+
const i = Math.abs(tileCoord.x + tileCoord.y) % BING_SUB_DOMAINS.length;
|
|
658
|
+
const z = tileCoord.z;
|
|
659
|
+
const x = tileCoord.x;
|
|
660
|
+
const y = tileCoord.y;
|
|
661
|
+
const gk = toQuadKey(x, y, z);
|
|
662
|
+
return BING_URL_TEMPLATE.replace("|QK|", gk).replace("{s}", BING_SUB_DOMAINS[i]);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
function useColumns(props) {
|
|
666
|
+
const {
|
|
667
|
+
rowKeyGetter,
|
|
668
|
+
visibleLayers,
|
|
669
|
+
setVisibleLayers,
|
|
670
|
+
autoFocusLayers,
|
|
671
|
+
setAutoFocusLayers,
|
|
672
|
+
clusterLayers,
|
|
673
|
+
setClusterLayers
|
|
674
|
+
} = props;
|
|
675
|
+
const { getLabel } = useModuleDictionary();
|
|
676
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
677
|
+
const useHook = useCallback(
|
|
678
|
+
(field) => {
|
|
679
|
+
if (field === "visible") {
|
|
680
|
+
return [visibleLayers, setVisibleLayers];
|
|
681
|
+
} else if (field === "autoFocus") {
|
|
682
|
+
return [autoFocusLayers, setAutoFocusLayers];
|
|
683
|
+
} else {
|
|
684
|
+
return [clusterLayers, setClusterLayers];
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
[visibleLayers, autoFocusLayers, clusterLayers]
|
|
688
|
+
);
|
|
689
|
+
const columns = useMemo(
|
|
690
|
+
() => [
|
|
691
|
+
{
|
|
692
|
+
key: "name",
|
|
693
|
+
name: getLabel(MAP_DICCTIONARY.LABEL_NAME),
|
|
694
|
+
type: "string",
|
|
695
|
+
width: 150,
|
|
696
|
+
frozen: true
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
key: "visible",
|
|
700
|
+
name: getLabel(MAP_DICCTIONARY.LABEL_LAYER_VISIBLE),
|
|
701
|
+
width: 50,
|
|
702
|
+
minWidth: 20,
|
|
703
|
+
type: "boolean",
|
|
704
|
+
formatter: ColumnSetCheckFormatter({
|
|
705
|
+
field: "visible",
|
|
706
|
+
rowKeyGetter,
|
|
707
|
+
useHook
|
|
708
|
+
}),
|
|
709
|
+
cellClass: "rdg-cell-align-center",
|
|
710
|
+
headerRenderer: (_p) => /* @__PURE__ */ jsx(Tooltip, { title: getLabel(MAP_DICCTIONARY.LABEL_LAYER_VISIBLE), children: /* @__PURE__ */ jsx(
|
|
711
|
+
Icon,
|
|
712
|
+
{
|
|
713
|
+
size: "medium",
|
|
714
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_VISIBLE}`
|
|
715
|
+
}
|
|
716
|
+
) })
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
key: "autoFocus",
|
|
720
|
+
name: getLabel(MAP_DICCTIONARY.LABEL_LAYER_AUTOFOCUS),
|
|
721
|
+
minWidth: 20,
|
|
722
|
+
width: 50,
|
|
723
|
+
type: "boolean",
|
|
724
|
+
formatter: ColumnSetCheckFormatter({
|
|
725
|
+
field: "autoFocus",
|
|
726
|
+
rowKeyGetter,
|
|
727
|
+
useHook
|
|
728
|
+
}),
|
|
729
|
+
cellClass: "rdg-cell-align-center",
|
|
730
|
+
headerRenderer: (_p) => /* @__PURE__ */ jsx(Tooltip, { title: getLabel(MAP_DICCTIONARY.LABEL_LAYER_AUTOFOCUS), children: /* @__PURE__ */ jsx(
|
|
731
|
+
Icon,
|
|
732
|
+
{
|
|
733
|
+
size: "medium",
|
|
734
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_AUTOFOCUS}`
|
|
735
|
+
}
|
|
736
|
+
) })
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
key: "cluster",
|
|
740
|
+
name: getLabel(MAP_DICCTIONARY.LABEL_LAYER_CLUSTER),
|
|
741
|
+
minWidth: 20,
|
|
742
|
+
width: 50,
|
|
743
|
+
type: "boolean",
|
|
744
|
+
formatter: ColumnSetCheckFormatter({
|
|
745
|
+
field: "cluster",
|
|
746
|
+
disabledGetter: (row) => !row.clusterAble,
|
|
747
|
+
rowKeyGetter,
|
|
748
|
+
useHook
|
|
749
|
+
}),
|
|
750
|
+
cellClass: "rdg-cell-align-center",
|
|
751
|
+
headerRenderer: (_p) => /* @__PURE__ */ jsx(Tooltip, { title: getLabel(MAP_DICCTIONARY.LABEL_LAYER_CLUSTER), children: /* @__PURE__ */ jsx(
|
|
752
|
+
Icon,
|
|
753
|
+
{
|
|
754
|
+
size: "medium",
|
|
755
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_CLUSTER}`
|
|
756
|
+
}
|
|
757
|
+
) })
|
|
758
|
+
}
|
|
759
|
+
],
|
|
760
|
+
[getLabel, useHook]
|
|
761
|
+
);
|
|
762
|
+
return { columns };
|
|
763
|
+
}
|
|
764
|
+
function useCheckedLayers(checkedNameSet) {
|
|
765
|
+
const [checkedLayers, setCheckedLayers] = useMapStore(
|
|
766
|
+
(state) => [
|
|
767
|
+
state[`${checkedNameSet}CheckedLayers`],
|
|
768
|
+
(newSet) => {
|
|
769
|
+
state.mapActions.setCheckedLayers(checkedNameSet, newSet);
|
|
770
|
+
}
|
|
771
|
+
],
|
|
772
|
+
shallow
|
|
773
|
+
);
|
|
774
|
+
return [checkedLayers, setCheckedLayers];
|
|
775
|
+
}
|
|
776
|
+
function useRowActionsGetter() {
|
|
777
|
+
const { getLabel } = useModuleDictionary();
|
|
778
|
+
const { hasPrivilege } = useModulePrivileges();
|
|
779
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
780
|
+
const { removeLayer } = useMapStore((state) => state.mapActions, shallow);
|
|
781
|
+
const [urlIconDelete] = useState(
|
|
782
|
+
`${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_DELETE}`
|
|
783
|
+
);
|
|
784
|
+
const onDelete = useCallback(
|
|
785
|
+
(row) => {
|
|
786
|
+
removeLayer(row.id);
|
|
787
|
+
},
|
|
788
|
+
[getLabel]
|
|
789
|
+
);
|
|
790
|
+
const rowActionsGetter = useCallback(
|
|
791
|
+
(row) => {
|
|
792
|
+
const conditionalItems = [];
|
|
793
|
+
conditionalItems.push({
|
|
794
|
+
urlIcon: urlIconDelete,
|
|
795
|
+
dictionaryId: MAP_DICCTIONARY.ROW_ACTION_LAYER_DELETE,
|
|
796
|
+
onClick: () => {
|
|
797
|
+
onDelete(row);
|
|
798
|
+
},
|
|
799
|
+
disabled: !row.deleteAble
|
|
800
|
+
});
|
|
801
|
+
return conditionalItems;
|
|
802
|
+
},
|
|
803
|
+
[hasPrivilege, onDelete, urlIconDelete]
|
|
804
|
+
);
|
|
805
|
+
return { rowActionsGetter };
|
|
806
|
+
}
|
|
807
|
+
function useMaster() {
|
|
808
|
+
const [hashLayers, layersIds] = useMapStore(
|
|
809
|
+
(state) => [state.hashLayers, state.layersIds],
|
|
810
|
+
shallow
|
|
811
|
+
);
|
|
812
|
+
const rowKeyGetter = useCallback((row) => row.id, []);
|
|
813
|
+
const [visibleLayers, setVisibleLayers] = useCheckedLayers("visible");
|
|
814
|
+
const [autoFocusLayers, setAutoFocusLayers] = useCheckedLayers("autoFocus");
|
|
815
|
+
const [clusterLayers, setClusterLayers] = useCheckedLayers("cluster");
|
|
816
|
+
const rows = useMemo(() => {
|
|
817
|
+
const rows2 = [];
|
|
818
|
+
layersIds.forEach((layerId) => {
|
|
819
|
+
if (hashLayers[layerId]) {
|
|
820
|
+
rows2.push({
|
|
821
|
+
id: layerId,
|
|
822
|
+
name: hashLayers[layerId].name || `*${layerId}`,
|
|
823
|
+
active: hashLayers[layerId].visible,
|
|
824
|
+
clusterAble: hashLayers[layerId].clusterAble || false,
|
|
825
|
+
deleteAble: hashLayers[layerId].deleteAble || false
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
return rows2;
|
|
830
|
+
}, [hashLayers, layersIds]);
|
|
831
|
+
const { rowActionsGetter } = useRowActionsGetter();
|
|
832
|
+
const { columns } = useColumns({
|
|
833
|
+
rowKeyGetter,
|
|
834
|
+
visibleLayers,
|
|
835
|
+
setVisibleLayers,
|
|
836
|
+
autoFocusLayers,
|
|
837
|
+
setAutoFocusLayers,
|
|
838
|
+
clusterLayers,
|
|
839
|
+
setClusterLayers
|
|
840
|
+
});
|
|
841
|
+
return {
|
|
842
|
+
rowKeyGetter,
|
|
843
|
+
columns,
|
|
844
|
+
rows,
|
|
845
|
+
checkedRows: visibleLayers,
|
|
846
|
+
onCheckedRowsChange: setVisibleLayers,
|
|
847
|
+
rowActionsGetter
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
function LayersTool() {
|
|
851
|
+
const { columns, rows, rowKeyGetter, rowActionsGetter } = useMaster();
|
|
852
|
+
const [divRef, setDivRef] = useStateRef(null);
|
|
853
|
+
useDisableZoomEvents(divRef);
|
|
854
|
+
return /* @__PURE__ */ jsx("div", { ref: setDivRef, style: { position: "relative", height: "100%" }, children: /* @__PURE__ */ jsx(
|
|
855
|
+
DataGrid,
|
|
856
|
+
{
|
|
857
|
+
id: "layers",
|
|
858
|
+
columns,
|
|
859
|
+
rows,
|
|
860
|
+
rowActionsGetter,
|
|
861
|
+
rowKeyGetter,
|
|
862
|
+
withActions: true,
|
|
863
|
+
actionsProps: {
|
|
864
|
+
withRowsCount: false,
|
|
865
|
+
withSettings: false,
|
|
866
|
+
withPager: false,
|
|
867
|
+
withLocalFilters: false
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
) });
|
|
871
|
+
}
|
|
872
|
+
function MapSourcesTool() {
|
|
873
|
+
const { getLabel } = useModuleDictionary();
|
|
874
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
875
|
+
const currentMapSourceId = useMapStore((state) => state.currentMapSourceId, shallow);
|
|
876
|
+
const mapSources = useMapStore((state) => {
|
|
877
|
+
return state.mapSourcesIds.map((id) => ({
|
|
878
|
+
id,
|
|
879
|
+
dictionaryId: state.hashMapSources[id].dictionaryId,
|
|
880
|
+
iconUrl: state.hashMapSources[id].iconUrl,
|
|
881
|
+
hasBicyclingLayer: state.hashMapSources[id].hasBicyclingLayer,
|
|
882
|
+
hasTrafficLayer: state.hashMapSources[id].hasTrafficLayer,
|
|
883
|
+
hasTransitLayer: state.hashMapSources[id].hasTransitLayer,
|
|
884
|
+
roadSeletedOptions: state.hashMapSources[id].roadSelectedOptions
|
|
885
|
+
}));
|
|
886
|
+
}, shallow);
|
|
887
|
+
const { setCurrentMapSource, setMapSourceRoadOptions: setMapSourceRoadMapOptions } = useMapStore(
|
|
888
|
+
(state) => state.mapActions,
|
|
889
|
+
shallow
|
|
890
|
+
);
|
|
891
|
+
const [divRef, setDivRef] = useStateRef(null);
|
|
892
|
+
useDisableZoomEvents(divRef);
|
|
893
|
+
const handleChange = (event) => {
|
|
894
|
+
setCurrentMapSource(event.target.value);
|
|
895
|
+
};
|
|
896
|
+
return /* @__PURE__ */ jsx("div", { className: mapClasses.mapSourcesRoot, ref: setDivRef, children: /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
897
|
+
RadioGroup,
|
|
898
|
+
{
|
|
899
|
+
"aria-labelledby": "demo-controlled-radio-buttons-group",
|
|
900
|
+
name: "controlled-radio-buttons-group",
|
|
901
|
+
value: currentMapSourceId,
|
|
902
|
+
onChange: handleChange,
|
|
903
|
+
children: mapSources.map((mapSourceOption) => /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOption, children: [
|
|
904
|
+
/* @__PURE__ */ jsx(
|
|
905
|
+
FormControlLabel,
|
|
906
|
+
{
|
|
907
|
+
className: "",
|
|
908
|
+
value: mapSourceOption.id,
|
|
909
|
+
control: /* @__PURE__ */ jsx(Radio, {}),
|
|
910
|
+
label: /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionIconLabel, children: [
|
|
911
|
+
/* @__PURE__ */ jsx(
|
|
912
|
+
Icon,
|
|
913
|
+
{
|
|
914
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${mapSourceOption.iconUrl}`
|
|
915
|
+
}
|
|
916
|
+
),
|
|
917
|
+
/* @__PURE__ */ jsx("span", { children: getLabel(mapSourceOption.dictionaryId) })
|
|
918
|
+
] })
|
|
919
|
+
}
|
|
920
|
+
),
|
|
921
|
+
(mapSourceOption.hasBicyclingLayer || mapSourceOption.hasTrafficLayer || mapSourceOption.hasTransitLayer) && /* @__PURE__ */ jsxs(
|
|
922
|
+
"div",
|
|
923
|
+
{
|
|
924
|
+
className: clsx(
|
|
925
|
+
mapClasses.mapSourcesOptionRoadOptions,
|
|
926
|
+
currentMapSourceId !== mapSourceOption.id ? mapClasses.disabled : mapClasses.active
|
|
927
|
+
),
|
|
928
|
+
children: [
|
|
929
|
+
mapSourceOption.hasTrafficLayer && /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionRoadOptionsCheck, children: [
|
|
930
|
+
/* @__PURE__ */ jsx(
|
|
931
|
+
CheckBox,
|
|
932
|
+
{
|
|
933
|
+
disabled: currentMapSourceId !== mapSourceOption.id,
|
|
934
|
+
checked: mapSourceOption.roadSeletedOptions?.trafficLayer || false,
|
|
935
|
+
onChange: (_e, checked) => {
|
|
936
|
+
setMapSourceRoadMapOptions({ trafficLayer: checked });
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
/* @__PURE__ */ jsx(
|
|
941
|
+
Icon,
|
|
942
|
+
{
|
|
943
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_SOURCE_ROAD_TRAFFIC}`
|
|
944
|
+
}
|
|
945
|
+
)
|
|
946
|
+
] }),
|
|
947
|
+
mapSourceOption.hasTransitLayer && /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionRoadOptionsCheck, children: [
|
|
948
|
+
/* @__PURE__ */ jsx(
|
|
949
|
+
CheckBox,
|
|
950
|
+
{
|
|
951
|
+
disabled: currentMapSourceId !== mapSourceOption.id,
|
|
952
|
+
checked: mapSourceOption.roadSeletedOptions?.transitLayer || false,
|
|
953
|
+
onChange: (_e, checked) => {
|
|
954
|
+
setMapSourceRoadMapOptions({ transitLayer: checked });
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
),
|
|
958
|
+
/* @__PURE__ */ jsx(
|
|
959
|
+
Icon,
|
|
960
|
+
{
|
|
961
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_SOURCE_ROAD_TRANSIT}`
|
|
962
|
+
}
|
|
963
|
+
)
|
|
964
|
+
] }),
|
|
965
|
+
mapSourceOption.hasBicyclingLayer && /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionRoadOptionsCheck, children: [
|
|
966
|
+
/* @__PURE__ */ jsx(
|
|
967
|
+
CheckBox,
|
|
968
|
+
{
|
|
969
|
+
disabled: currentMapSourceId !== mapSourceOption.id,
|
|
970
|
+
checked: mapSourceOption.roadSeletedOptions?.bicyclingLayer || false,
|
|
971
|
+
label: "Bycicle",
|
|
972
|
+
onChange: (_e, checked) => {
|
|
973
|
+
setMapSourceRoadMapOptions({ bicyclingLayer: checked });
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
),
|
|
977
|
+
/* @__PURE__ */ jsx(
|
|
978
|
+
Icon,
|
|
979
|
+
{
|
|
980
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_SOURCE_ROAD_BICYCLING}`
|
|
981
|
+
}
|
|
982
|
+
)
|
|
983
|
+
] })
|
|
984
|
+
]
|
|
985
|
+
}
|
|
986
|
+
)
|
|
987
|
+
] }, mapSourceOption.dictionaryId))
|
|
988
|
+
}
|
|
989
|
+
) }) });
|
|
990
|
+
}
|
|
991
|
+
function LayersButton(props) {
|
|
992
|
+
const { type } = props;
|
|
993
|
+
const [open, setOpen] = useState(null);
|
|
994
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
995
|
+
const theme = useTheme();
|
|
996
|
+
const handleOpen = (event) => {
|
|
997
|
+
setOpen(event.currentTarget);
|
|
998
|
+
};
|
|
999
|
+
const handleClose = () => {
|
|
1000
|
+
setOpen(null);
|
|
1001
|
+
};
|
|
1002
|
+
return /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
|
|
1003
|
+
/* @__PURE__ */ jsx(
|
|
1004
|
+
IconButton,
|
|
1005
|
+
{
|
|
1006
|
+
onClick: handleOpen,
|
|
1007
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${type === "MapSources" ? MAP_ICONS.MAP_SOURCES_TOOL : MAP_ICONS.MAP_LAYERS_TOOL}`
|
|
1008
|
+
}
|
|
1009
|
+
),
|
|
1010
|
+
/* @__PURE__ */ jsx(
|
|
1011
|
+
Popover,
|
|
1012
|
+
{
|
|
1013
|
+
className: type === "MapSources" ? mapClasses.mapSourcesPopoverRoot : mapClasses.layersPopoverRoot,
|
|
1014
|
+
arrowType: "no-arrow",
|
|
1015
|
+
open: Boolean(open),
|
|
1016
|
+
anchorEl: open,
|
|
1017
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
1018
|
+
onClose: handleClose,
|
|
1019
|
+
sx: {
|
|
1020
|
+
...type === "MapSources" ? theme.components?.M4LMapMapSources?.styleOverrides : theme.components?.M4LMapLayers?.styleOverrides
|
|
1021
|
+
},
|
|
1022
|
+
disableAutoFocus: true,
|
|
1023
|
+
disableRestoreFocus: true,
|
|
1024
|
+
disableEnforceFocus: true,
|
|
1025
|
+
children: type === "MapSources" ? /* @__PURE__ */ jsx(MapSourcesTool, {}) : /* @__PURE__ */ jsx(LayersTool, {})
|
|
1026
|
+
}
|
|
1027
|
+
)
|
|
1028
|
+
] });
|
|
1029
|
+
}
|
|
1030
|
+
export {
|
|
1031
|
+
LayersButton as L,
|
|
1032
|
+
Popover as P,
|
|
1033
|
+
TILE_LAYER_OSM as T,
|
|
1034
|
+
PopoverMenuFields as a,
|
|
1035
|
+
PopoverFilter as b,
|
|
1036
|
+
TILE_LAYER_GOOGLE as c,
|
|
1037
|
+
TILE_LAYER_GOOGLE_SATELLITE as d,
|
|
1038
|
+
TILE_LAYER_GOOGLE_HYBRID as e,
|
|
1039
|
+
TILE_LAYER_BING as f,
|
|
1040
|
+
LanguagePopover as g
|
|
1041
|
+
};
|