@m4l/components 0.1.83 → 0.1.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/components/AccountPopover/classes/index.d.ts +4 -0
  2. package/components/AccountPopover/classes/types.d.ts +4 -0
  3. package/components/AccountPopover/dictionary.d.ts +1 -0
  4. package/components/AccountPopover/{index.2677fe77.js → index.bbeb9142.js} +73 -27
  5. package/components/AccountPopover/index.d.ts +1 -0
  6. package/components/AccountPopover/types.d.ts +2 -0
  7. package/components/AppBar/dictionary.d.ts +1 -0
  8. package/components/AppBar/{index.ad2a6f0e.js → index.43f8b54f.js} +17 -10
  9. package/components/AppBar/index.d.ts +1 -0
  10. package/components/CommonActions/components/ActionCancel/{index.b2fc495d.js → index.29517521.js} +1 -1
  11. package/components/CommonActions/components/ActionFormCancel/{index.60d8963e.js → index.89f1ac8e.js} +14 -14
  12. package/components/CommonActions/components/ActionFormIntro/{index.fde4ea51.js → index.bbc35e74.js} +1 -1
  13. package/components/CommonActions/components/ActionIntro/{index.724d8e17.js → index.a9420126.js} +1 -1
  14. package/components/CommonActions/components/Actions/{index.23a2d6ae.js → index.e70e8779.js} +12 -12
  15. package/components/DataGrid/{index.d5d0d62f.js → index.1d0a3dec.js} +13 -12
  16. package/components/DataGrid/subcomponents/Actions/{index.201394f5.js → index.a8fc9f6a.js} +44 -29
  17. package/components/DynamicFilter/{index.7d134537.js → index.912679cc.js} +25 -25
  18. package/components/GridLayout/constants.d.ts +1 -1
  19. package/components/GridLayout/{index.70085b00.js → index.c55f16eb.js} +20 -16
  20. package/components/GridLayout/subcomponents/Griditem/{index.c09681ff.js → index.6c68811f.js} +1 -6
  21. package/components/GridLayout/subcomponents/Responsive/{index.eb04fd5e.js → index.a6e33b8d.js} +1 -2
  22. package/components/GridLayout/subcomponents/SizeProvider/{index.9c5e80b2.js → index.bfa05dfa.js} +3 -6
  23. package/components/GridLayout/types.d.ts +2 -2
  24. package/components/HelperText/{index.28e9105d.js → index.a47ff233.js} +7 -7
  25. package/components/Icon/{index.2414ff25.js → index.d1402200.js} +1 -1
  26. package/components/LanguagePopover/{index.065e0296.js → index.807f5272.js} +7 -7
  27. package/components/ModalDialog/{index.fb148f76.js → index.42e804cf.js} +4 -6
  28. package/components/NavLink/{index.2ef07c44.js → index.ff5a939c.js} +7 -7
  29. package/components/ObjectLogs/{index.5d74dfe0.js → index.dc02715d.js} +16 -16
  30. package/components/PaperForm/{index.f931dc02.js → index.249c2404.js} +1 -1
  31. package/components/Period/{index.0e6512b2.js → index.e129cdec.js} +13 -13
  32. package/components/PropertyValue/{index.a67c9916.js → index.93e40532.js} +1 -1
  33. package/components/SideBar/classes/index.d.ts +0 -1
  34. package/components/SideBar/classes/types.d.ts +0 -1
  35. package/components/SideBar/{index.72564ef2.js → index.327679a6.js} +22 -27
  36. package/components/areas/components/AreasAdmin/classes/types.d.ts +1 -0
  37. package/components/areas/components/AreasAdmin/index.8ab71eb9.js +718 -0
  38. package/components/areas/components/AreasAdmin/index.d.ts +2 -2
  39. package/components/areas/components/AreasAdmin/subcomponents/AreaChip/subcomponents/ChipActionsMobile/types.d.ts +2 -1
  40. package/components/areas/components/AreasAdmin/subcomponents/AreaChip/types.d.ts +2 -0
  41. package/components/areas/components/AreasAdmin/subcomponents/AreaChipMobile/subcomponents/ChipMobile/ChipMobile.d.ts +6 -0
  42. package/components/areas/components/AreasViewer/classes/index.d.ts +1 -1
  43. package/components/areas/components/AreasViewer/classes/types.d.ts +1 -0
  44. package/components/areas/components/AreasViewer/{index.9ed7dfd7.js → index.933e506b.js} +120 -41
  45. package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/AreaGridLayout/index.d.ts +2 -2
  46. package/components/areas/components/{index.654b08aa.js → index.9e48d8ff.js} +10 -10
  47. package/components/areas/contexts/AreasContext/helper.d.ts +7 -0
  48. package/components/areas/contexts/AreasContext/{index.36fe6953.js → index.230d1584.js} +17 -7
  49. package/components/areas/contexts/AreasContext/types.d.ts +8 -0
  50. package/components/areas/contexts/{index.68c53fc9.js → index.f494e241.js} +1 -1
  51. package/components/areas/hooks/useAreas/{index.a4c03e23.js → index.b8449343.js} +1 -1
  52. package/components/areas/index.32db4fa7.js +53 -0
  53. package/components/areas/utils/useOnClickOutside/index.d.ts +4 -0
  54. package/components/formatters/BooleanFormatter/{index.32de0803.js → index.b2f02bc4.js} +1 -1
  55. package/components/formatters/{index.d16d2331.js → index.f9ad88b4.js} +2 -2
  56. package/components/hook-form/RHFAutocomplete/{index.42df8eb4.js → index.d5afb409.js} +9 -8
  57. package/components/hook-form/RHFAutocompleteAsync/{index.0441524c.js → index.a4f00088.js} +1 -1
  58. package/components/hook-form/RHFCheckbox/{index.c66147f7.js → index.9bf6edb0.js} +8 -8
  59. package/components/hook-form/RHFDateTime/{index.4698ca29.js → index.a2c1ed2c.js} +8 -8
  60. package/components/hook-form/RHFPeriod/{index.f653934b.js → index.b5204ce2.js} +2 -2
  61. package/components/hook-form/RHFTextField/{index.1fa07688.js → index.5a0fa776.js} +3 -3
  62. package/components/hook-form/RHFUpload/{index.93c2dcb5.js → index.b36539d6.js} +8 -8
  63. package/components/modal/{WindowBase.92ce9b8f.js → WindowBase.37158e8d.js} +15 -11
  64. package/components/modal/{WindowConfirm.4c3d2cd7.js → WindowConfirm.a68aa0f1.js} +15 -15
  65. package/components/modal/{index.1bd35bd5.js → index.6f281ef8.js} +12 -12
  66. package/components/mui_extended/Accordion/{index.5111314b.js → index.46771196.js} +3 -3
  67. package/components/mui_extended/CheckBox/CheckBox.d.ts +1 -1
  68. package/components/mui_extended/{CheckBox.5f6c78b0.js → CheckBox.38abccd8.js} +5 -3
  69. package/components/mui_extended/IconButton/{index.a318316e.js → index.62aea582.js} +2 -12
  70. package/components/mui_extended/MenuActions/{index.f6bfdd40.js → index.2493b1b1.js} +21 -6
  71. package/components/mui_extended/MenuActions/types.d.ts +2 -0
  72. package/components/mui_extended/Pager/{index.da26e9d4.js → index.a7f87c96.js} +84 -82
  73. package/components/mui_extended/Pager/subcomponents/CustomTablePagination/index.d.ts +5 -0
  74. package/components/mui_extended/Pager/subcomponents/CustomTablePagination/types.d.ts +1 -4
  75. package/components/mui_extended/Tab/{index.0989d15d.js → index.756fe693.js} +1 -1
  76. package/components/mui_extended/{index.813723c5.js → index.ba27649e.js} +7 -7
  77. package/contexts/ModalContext/{index.577bf36b.js → index.51da83de.js} +1 -1
  78. package/hooks/useModal/{index.7a07c208.js → index.7611bf21.js} +1 -1
  79. package/index.js +64 -60
  80. package/package.json +1 -1
  81. package/{vendor.5365cc7e.js → vendor.1af105d6.js} +47 -47
  82. package/components/areas/components/AreasAdmin/index.7bfec13f.js +0 -487
  83. package/components/areas/index.ec4f088c.js +0 -32
  84. /package/components/areas/components/{AreasAdmin/subcomponents/AreaChipMobile → AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header}/subcomponents/PanelWindowPopUp/index.d.ts +0 -0
  85. /package/components/areas/components/{AreasAdmin/subcomponents/AreaChipMobile → AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header}/subcomponents/PanelWindowPopUp/types.d.ts +0 -0
@@ -0,0 +1,718 @@
1
+ import { I as IconButton } from "../../../mui_extended/IconButton/index.62aea582.js";
2
+ import { u as useAreasStore } from "../../hooks/useAreas/index.b8449343.js";
3
+ import { useEnvironment, useModuleDictionary } from "@m4l/core";
4
+ import { useState, useRef, useMemo } from "react";
5
+ import * as Yup from "yup";
6
+ import { generateUtilityClasses, useTheme } from "@mui/material";
7
+ import "../../../mui_extended/Accordion/index.46771196.js";
8
+ import { I as Icon } from "../../../Icon/index.d1402200.js";
9
+ import clsx from "clsx";
10
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
11
+ import { T as Typography } from "../../../mui_extended/Typography/index.443590d6.js";
12
+ import "../../../mui_extended/Avatar/index.75e6ed57.js";
13
+ import "react-router-dom";
14
+ import "@mui/material/Button";
15
+ import { B as Button } from "../../../mui_extended/Button/index.40af964e.js";
16
+ import "../../../mui_extended/CheckBox.38abccd8.js";
17
+ import "../../../mui_extended/Badge/index.cad260fe.js";
18
+ import "../../../Image/index.c18ebf5a.js";
19
+ import "@mui/lab";
20
+ import { M as MenuActions } from "../../../mui_extended/MenuActions/index.2493b1b1.js";
21
+ import { P as Popover } from "../../../mui_extended/Popover/index.9f35d0eb.js";
22
+ import "../../../mui_extended/Pager/index.a7f87c96.js";
23
+ import { useResponsiveDesktop } from "@m4l/graphics";
24
+ import "../../../mui_extended/Tab/index.756fe693.js";
25
+ import "../../../mui_extended/Tooltip/index.5a795dcd.js";
26
+ import { unstable_composeClasses } from "@mui/base";
27
+ import { g as getComponentUtilityClass } from "../../../../utils/index.c43a95f4.js";
28
+ import { A as AREAS_ADMIN_CLASS_NAME } from "../../constants.66529246.js";
29
+ import { I as ICONS } from "../../icons.8266ccc8.js";
30
+ import "../../contexts/DynamicMFParmsContext/index.1607c78e.js";
31
+ import "../../../../contexts/ModalContext/index.51da83de.js";
32
+ import { R as RHFormProvider } from "../../../../contexts/RHFormContext/index.b9266262.js";
33
+ import "react-hook-form";
34
+ import "../../../hook-form/RHFAutocomplete/index.d5afb409.js";
35
+ import "../../../HelperText/index.a47ff233.js";
36
+ import "lodash/debounce";
37
+ import "../../../hook-form/RHFAutocompleteAsync/index.a4f00088.js";
38
+ import "../../../hook-form/RHFCheckbox/index.9bf6edb0.js";
39
+ import "@mui/x-date-pickers";
40
+ import "../../../hook-form/RHFDateTime/index.a2c1ed2c.js";
41
+ import { R as RHFTextField } from "../../../hook-form/RHFTextField/index.5a0fa776.js";
42
+ import "../../../hook-form/RHFPeriod/index.b5204ce2.js";
43
+ import "../../../Period/index.e129cdec.js";
44
+ import { A as Actions } from "../../../CommonActions/components/Actions/index.e70e8779.js";
45
+ import { A as ActionCancel } from "../../../CommonActions/components/ActionCancel/index.29517521.js";
46
+ import { A as ActionIntro } from "../../../CommonActions/components/ActionIntro/index.a9420126.js";
47
+ import "../../../../react-draggable.7abb5d0a.js";
48
+ import "../../../Resizeable/index.9a9c79a4.js";
49
+ import "../../../modal/index.6f281ef8.js";
50
+ import { shallow } from "zustand/shallow";
51
+ import { styled } from "@mui/material/styles";
52
+ import { S as ScrollBar } from "../../../ScrollBar/index.d4410cb5.js";
53
+ import { g as getAreasDictionary, D as DICCTIONARY } from "../../dictionary.afb7e3d9.js";
54
+ import TouchRipple from "@mui/material/ButtonBase/TouchRipple";
55
+ import "../AreasViewer/index.933e506b.js";
56
+ import "../../../LinearProgressIndeterminate/index.60dabc06.js";
57
+ import "../../contexts/AreasContext/index.230d1584.js";
58
+ import "../../contexts/WindowToolsMFContext/index.8f3e2a04.js";
59
+ import "zustand";
60
+ import "lodash/isString";
61
+ import "react-dropzone";
62
+ import "../../../hook-form/RHFUpload/index.b36539d6.js";
63
+ import { u as useOnClickOutside } from "../../index.32db4fa7.js";
64
+ const areasAdminClasses = generateUtilityClasses(AREAS_ADMIN_CLASS_NAME, [
65
+ "root",
66
+ "areaChipRoot",
67
+ "areaChipTitle",
68
+ "areaChipDeleteButton",
69
+ "areasAddButton",
70
+ "areaContainerChipEditButton",
71
+ "areaContainerChips",
72
+ "areaContainerContentChips",
73
+ "areaContainerChipsIcon",
74
+ "areaEditPopover",
75
+ "areaChipMobileRoot",
76
+ "areaChipMobileIconContainer",
77
+ "areaIconLayer",
78
+ "areaIconLayerContent",
79
+ "areaChipEditButton",
80
+ "areasPopoverMobileOptions",
81
+ "areasPopoverListWindows",
82
+ "selected",
83
+ "isMobile",
84
+ "disabled",
85
+ "isFocus"
86
+ ], AREAS_ADMIN_CLASS_NAME);
87
+ const useAreasAdminUtilityClasses = (ownerState) => {
88
+ const slots = {
89
+ root: ["root", ownerState.status, ownerState.isMobile && "isMobile", ownerState.isSkeleton && "isSkeleton", ownerState.focus && "isFocus"],
90
+ areaChipRoot: ["areaChipRoot"],
91
+ areaIconLayer: ["areaIconLayer"],
92
+ areaContainerChipsIcon: ["areaContainerChipsIcon"],
93
+ areaContainerChips: ["areaContainerChips"],
94
+ areaContainerContentChips: ["areaContainerContentChips"],
95
+ areaEditPopover: ["areaEditPopover"],
96
+ areaChipMobileRoot: ["areaChipMobileRoot"],
97
+ areaChipMobileIconContainer: ["areaChipMobileIconContainer"],
98
+ areaChipTitle: ["areaChipTitle"],
99
+ areaContainerChipEditButton: ["areaContainerChipEditButton"],
100
+ areaChipDeleteButton: ["areaChipDeleteButton"],
101
+ areaChipEditButton: ["areaChipEditButton"],
102
+ areasAddButton: ["areasAddButton"],
103
+ areasPopoverMobileOptions: ["areasPopoverMobileOptions"],
104
+ areasPopoverListWindows: ["areasPopoverListWindows"]
105
+ };
106
+ return unstable_composeClasses(slots, getComponentUtilityClass(AREAS_ADMIN_CLASS_NAME), {});
107
+ };
108
+ styled("div")(() => ({
109
+ display: "flex",
110
+ flexDirection: "row",
111
+ border: "1px solid gray",
112
+ "&.active": {
113
+ border: "1px solid red"
114
+ }
115
+ }));
116
+ styled("div")(({
117
+ theme
118
+ }) => ({
119
+ height: "100%",
120
+ width: theme.spacing(1),
121
+ backgroundColor: theme.palette.background.default,
122
+ "&.active": {
123
+ backgroundColor: theme.palette.primary.main
124
+ }
125
+ }));
126
+ const EditAreaHeader = styled("div")(({
127
+ theme
128
+ }) => ({
129
+ display: "flex",
130
+ width: "100%",
131
+ height: "25px",
132
+ borderBottom: "1px solid",
133
+ borderColor: theme.palette.state.default,
134
+ justifyContent: "space-between",
135
+ alignItems: "center"
136
+ }));
137
+ const ChipActionsMobile = (props) => {
138
+ const {
139
+ handlerOpenPopoverEditArea,
140
+ areaId
141
+ } = props;
142
+ const {
143
+ deleteArea
144
+ } = useAreasStore((state) => state.areasActions);
145
+ const {
146
+ setFocus
147
+ } = useAreasStore((state) => state.areaAdminActions, shallow);
148
+ const listAreas = useAreasStore((state) => state.areas, shallow);
149
+ const {
150
+ host_static_assets,
151
+ environment_assets
152
+ } = useEnvironment();
153
+ const {
154
+ getLabel
155
+ } = useModuleDictionary();
156
+ const menuActions = [{
157
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.EDIT_AREA}`,
158
+ onClick: handlerOpenPopoverEditArea,
159
+ label: getLabel(getAreasDictionary(DICCTIONARY.label_edit_area))
160
+ }];
161
+ if (listAreas.length > 1) {
162
+ menuActions.push({
163
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.DELETE_AREA}`,
164
+ onClick: () => {
165
+ deleteArea(areaId);
166
+ setFocus(false);
167
+ },
168
+ label: getLabel(getAreasDictionary(DICCTIONARY.label_delete_area))
169
+ });
170
+ }
171
+ return /* @__PURE__ */ jsx(MenuActions, {
172
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.SHOW_OPTIONS}`,
173
+ arrowType: "no-arrow",
174
+ marginTop: "12px",
175
+ anchorOrigin: {
176
+ vertical: "bottom",
177
+ horizontal: "right"
178
+ },
179
+ transformOrigin: {
180
+ vertical: "top",
181
+ horizontal: "right"
182
+ },
183
+ menuActions,
184
+ externalClose: () => setFocus(false)
185
+ });
186
+ };
187
+ const AreaChip = (props) => {
188
+ const {
189
+ areaId,
190
+ selected,
191
+ disabled,
192
+ setAnchorMenuAreas
193
+ } = props;
194
+ const {
195
+ host_static_assets,
196
+ environment_assets
197
+ } = useEnvironment();
198
+ const {
199
+ deleteArea,
200
+ selectArea,
201
+ editArea
202
+ } = useAreasStore((state) => state.areasActions);
203
+ const {
204
+ setFocus
205
+ } = useAreasStore((state) => state.areaAdminActions);
206
+ const areaName = useAreasStore((state) => state.hashAreas[areaId].name, shallow);
207
+ const listAreas = useAreasStore((state) => state.areas, shallow);
208
+ const [open, setOpen] = useState(false);
209
+ const {
210
+ getLabel
211
+ } = useModuleDictionary();
212
+ const isDesktop = useResponsiveDesktop();
213
+ const anchorRef = useRef(null);
214
+ const theme = useTheme();
215
+ const onClickDeleteArea = (e) => {
216
+ console.log("listAreas", listAreas);
217
+ if (listAreas.length > 1) {
218
+ e.stopPropagation();
219
+ setFocus(true);
220
+ deleteArea(areaId);
221
+ }
222
+ };
223
+ const onSubmit = (data) => {
224
+ editArea(areaId, data.inputEditArea);
225
+ setOpen(false);
226
+ setFocus(false);
227
+ };
228
+ const handlerOpenPopoverEditArea = (e) => {
229
+ e?.stopPropagation();
230
+ setFocus(true);
231
+ setOpen(true);
232
+ };
233
+ const initialValues = {
234
+ inputEditArea: areaName
235
+ };
236
+ const validationSchema = useMemo(() => Yup.object().shape({
237
+ inputEditArea: Yup.string().required(getLabel(getAreasDictionary(DICCTIONARY.validation_edit_area)))
238
+ }), [getLabel]);
239
+ const handlerOnClick = (e) => {
240
+ console.log("evento de handlerOnClick");
241
+ setAnchorMenuAreas && setAnchorMenuAreas(e.currentTarget);
242
+ selectArea(areaId);
243
+ };
244
+ const rippleRef = useRef(null);
245
+ const onRippleStart = (e) => {
246
+ if (rippleRef.current) {
247
+ rippleRef.current.start(e);
248
+ }
249
+ };
250
+ const onRippleStop = (e) => {
251
+ if (rippleRef.current) {
252
+ rippleRef.current.stop(e);
253
+ }
254
+ };
255
+ return /* @__PURE__ */ jsxs(Fragment, {
256
+ children: [/* @__PURE__ */ jsxs("div", {
257
+ role: "presentation",
258
+ ref: anchorRef,
259
+ onMouseDown: onRippleStart,
260
+ onMouseUp: onRippleStop,
261
+ className: clsx(areasAdminClasses.areaChipRoot, selected ? areasAdminClasses.selected : null, disabled ? areasAdminClasses.disabled : null),
262
+ onClick: (e) => {
263
+ handlerOnClick(e);
264
+ },
265
+ children: [/* @__PURE__ */ jsx("div", {
266
+ className: areasAdminClasses.areaChipTitle,
267
+ children: areaName
268
+ }), isDesktop ? /* @__PURE__ */ jsxs("div", {
269
+ className: areasAdminClasses.areaContainerChipEditButton,
270
+ children: [/* @__PURE__ */ jsx(IconButton, {
271
+ className: areasAdminClasses.areaChipEditButton,
272
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.EDIT_AREA}`,
273
+ size: "extraSmall",
274
+ onClick: (e) => {
275
+ handlerOpenPopoverEditArea(e);
276
+ }
277
+ }), /* @__PURE__ */ jsx(IconButton, {
278
+ className: areasAdminClasses.areaChipDeleteButton,
279
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.DELETE_AREA}`,
280
+ size: "extraSmall",
281
+ onClick: (e) => {
282
+ onClickDeleteArea(e);
283
+ }
284
+ })]
285
+ }) : /* @__PURE__ */ jsx(ChipActionsMobile, {
286
+ areaId,
287
+ handlerOpenPopoverEditArea
288
+ })]
289
+ }), /* @__PURE__ */ jsx("div", {
290
+ onClick: (e) => {
291
+ e.stopPropagation();
292
+ },
293
+ children: /* @__PURE__ */ jsx(Popover, {
294
+ arrowType: "top-center",
295
+ open,
296
+ className: areasAdminClasses.areaEditPopover,
297
+ anchorEl: anchorRef.current,
298
+ anchorOrigin: {
299
+ vertical: "bottom",
300
+ horizontal: "center"
301
+ },
302
+ transformOrigin: {
303
+ vertical: "top",
304
+ horizontal: "center"
305
+ },
306
+ onClose: () => {
307
+ setFocus(false);
308
+ setOpen(false);
309
+ },
310
+ sx: {
311
+ mt: "10px",
312
+ ...theme.components?.M4LAreasAdminEditPopover?.styleOverrides
313
+ },
314
+ children: /* @__PURE__ */ jsxs(RHFormProvider, {
315
+ onSubmit,
316
+ values: initialValues,
317
+ validationSchema,
318
+ children: [/* @__PURE__ */ jsxs(EditAreaHeader, {
319
+ children: [/* @__PURE__ */ jsx(Typography, {
320
+ children: getLabel(DICCTIONARY.label_edit_area)
321
+ }), /* @__PURE__ */ jsx(IconButton, {
322
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.CLOSE}`,
323
+ size: "small",
324
+ onClick: () => {
325
+ setFocus(false);
326
+ setOpen(false);
327
+ }
328
+ })]
329
+ }), /* @__PURE__ */ jsx(RHFTextField, {
330
+ name: "inputEditArea",
331
+ skeletonWidth: "70%",
332
+ skeletonHeight: "18px",
333
+ sx: {
334
+ mt: "20px"
335
+ }
336
+ }), /* @__PURE__ */ jsxs(Actions, {
337
+ children: [/* @__PURE__ */ jsx(ActionCancel, {
338
+ onClick: () => {
339
+ setOpen(false);
340
+ setFocus(false);
341
+ },
342
+ variant: "outlined",
343
+ skeletonWidth: "100%"
344
+ }), /* @__PURE__ */ jsx(ActionIntro, {
345
+ skeletonWidth: "100%"
346
+ })]
347
+ })]
348
+ })
349
+ })
350
+ })]
351
+ });
352
+ };
353
+ AreaChip.displayName = "AreaButtons";
354
+ const AreasAdminRoot = styled("div")`
355
+ display: flex;
356
+ position: relative;
357
+ background-color: transparent;
358
+
359
+
360
+
361
+ //areaRoot
362
+ & .${areasAdminClasses.areaChipRoot} {
363
+ display: flex;
364
+ }
365
+
366
+
367
+ ${(props) => props.theme.components?.M4LAreasAdmin?.styleOverrides}
368
+
369
+
370
+ `;
371
+ const ChipMobile = (props) => {
372
+ const {
373
+ areaId,
374
+ selected,
375
+ disabled,
376
+ setAnchorMenuAreas
377
+ } = props;
378
+ const {
379
+ host_static_assets,
380
+ environment_assets
381
+ } = useEnvironment();
382
+ const {
383
+ deleteArea,
384
+ selectArea,
385
+ editArea
386
+ } = useAreasStore((state) => state.areasActions);
387
+ const {
388
+ setFocus
389
+ } = useAreasStore((state) => state.areaAdminActions);
390
+ const areaName = useAreasStore((state) => state.hashAreas[areaId].name, shallow);
391
+ const listAreas = useAreasStore((state) => state.areas, shallow);
392
+ const [open, setOpen] = useState(false);
393
+ const {
394
+ getLabel
395
+ } = useModuleDictionary();
396
+ const isDesktop = useResponsiveDesktop();
397
+ const anchorRef = useRef(null);
398
+ const theme = useTheme();
399
+ const onClickDeleteArea = (e) => {
400
+ console.log("listAreas", listAreas);
401
+ if (listAreas.length > 1) {
402
+ e.stopPropagation();
403
+ setFocus(true);
404
+ deleteArea(areaId);
405
+ }
406
+ };
407
+ const onSubmit = (data) => {
408
+ editArea(areaId, data.inputEditArea);
409
+ setOpen(false);
410
+ setFocus(false);
411
+ };
412
+ const handlerOpenPopoverEditArea = (e) => {
413
+ e?.stopPropagation();
414
+ setFocus(true);
415
+ setOpen(true);
416
+ };
417
+ const initialValues = {
418
+ inputEditArea: areaName
419
+ };
420
+ const validationSchema = useMemo(() => Yup.object().shape({
421
+ inputEditArea: Yup.string().required(getLabel(getAreasDictionary(DICCTIONARY.validation_edit_area)))
422
+ }), [getLabel]);
423
+ const handlerOnClick = (e) => {
424
+ console.log("evento de handlerOnClick");
425
+ setAnchorMenuAreas && setAnchorMenuAreas(e.currentTarget);
426
+ selectArea(areaId);
427
+ };
428
+ const rippleRef = useRef(null);
429
+ const onRippleStart = (e) => {
430
+ if (rippleRef.current) {
431
+ rippleRef.current.start(e);
432
+ }
433
+ };
434
+ const onRippleStop = (e) => {
435
+ if (rippleRef.current) {
436
+ rippleRef.current.stop(e);
437
+ }
438
+ };
439
+ return /* @__PURE__ */ jsxs(Fragment, {
440
+ children: [/* @__PURE__ */ jsxs("div", {
441
+ role: "presentation",
442
+ ref: anchorRef,
443
+ onMouseDown: onRippleStart,
444
+ onMouseUp: onRippleStop,
445
+ className: clsx(areasAdminClasses.areaChipRoot, selected ? areasAdminClasses.selected : null, disabled ? areasAdminClasses.disabled : null),
446
+ onClick: (e) => {
447
+ handlerOnClick(e);
448
+ },
449
+ children: [/* @__PURE__ */ jsx(TouchRipple, {
450
+ ref: rippleRef,
451
+ center: false,
452
+ style: {
453
+ position: "absolute",
454
+ inset: "0"
455
+ }
456
+ }), /* @__PURE__ */ jsx("div", {
457
+ className: areasAdminClasses.areaChipTitle,
458
+ children: areaName
459
+ })]
460
+ }), isDesktop ? /* @__PURE__ */ jsxs("div", {
461
+ className: areasAdminClasses.areaContainerChipEditButton,
462
+ children: [/* @__PURE__ */ jsx(IconButton, {
463
+ className: areasAdminClasses.areaChipEditButton,
464
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.EDIT_AREA}`,
465
+ size: "extraSmall",
466
+ onClick: (e) => {
467
+ handlerOpenPopoverEditArea(e);
468
+ }
469
+ }), /* @__PURE__ */ jsx(IconButton, {
470
+ className: areasAdminClasses.areaChipDeleteButton,
471
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.DELETE_AREA}`,
472
+ size: "extraSmall",
473
+ onClick: (e) => {
474
+ onClickDeleteArea(e);
475
+ }
476
+ })]
477
+ }) : /* @__PURE__ */ jsx(ChipActionsMobile, {
478
+ areaId,
479
+ handlerOpenPopoverEditArea
480
+ }), /* @__PURE__ */ jsx("div", {
481
+ onClick: (e) => {
482
+ e.stopPropagation();
483
+ },
484
+ children: /* @__PURE__ */ jsx(Popover, {
485
+ arrowType: "top-center",
486
+ open,
487
+ className: areasAdminClasses.areaEditPopover,
488
+ anchorEl: anchorRef.current,
489
+ anchorOrigin: {
490
+ vertical: "bottom",
491
+ horizontal: "center"
492
+ },
493
+ transformOrigin: {
494
+ vertical: "top",
495
+ horizontal: "center"
496
+ },
497
+ onClose: () => {
498
+ setFocus(false);
499
+ setOpen(false);
500
+ },
501
+ sx: {
502
+ mt: "10px",
503
+ ...theme.components?.M4LAreasAdminEditPopover?.styleOverrides
504
+ },
505
+ children: /* @__PURE__ */ jsxs(RHFormProvider, {
506
+ onSubmit,
507
+ values: initialValues,
508
+ validationSchema,
509
+ children: [/* @__PURE__ */ jsxs(EditAreaHeader, {
510
+ children: [/* @__PURE__ */ jsx(Typography, {
511
+ children: getLabel(DICCTIONARY.label_edit_area)
512
+ }), /* @__PURE__ */ jsx(IconButton, {
513
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.CLOSE}`,
514
+ size: "small",
515
+ onClick: () => {
516
+ setFocus(false);
517
+ setOpen(false);
518
+ }
519
+ })]
520
+ }), /* @__PURE__ */ jsx(RHFTextField, {
521
+ name: "inputEditArea",
522
+ skeletonWidth: "70%",
523
+ skeletonHeight: "18px",
524
+ sx: {
525
+ mt: "20px"
526
+ }
527
+ }), /* @__PURE__ */ jsxs(Actions, {
528
+ children: [/* @__PURE__ */ jsx(ActionCancel, {
529
+ onClick: () => {
530
+ setOpen(false);
531
+ setFocus(false);
532
+ },
533
+ variant: "outlined",
534
+ skeletonWidth: "100%"
535
+ }), /* @__PURE__ */ jsx(ActionIntro, {
536
+ skeletonWidth: "100%"
537
+ })]
538
+ })]
539
+ })
540
+ })
541
+ })]
542
+ });
543
+ };
544
+ ChipMobile.displayName = "AreaButtons";
545
+ const AreaChipMobile = () => {
546
+ const areas = useAreasStore((state) => state.areas.map((a) => ({
547
+ id: a,
548
+ name: state.hashAreas[a].name
549
+ })), shallow);
550
+ const {
551
+ selectArea
552
+ } = useAreasStore((state) => state.areasActions);
553
+ const currentAreaId = useAreasStore((state) => state.currentAreaId, shallow);
554
+ const {
555
+ addArea
556
+ } = useAreasStore((state) => state.areasActions, shallow);
557
+ const {
558
+ setFocus
559
+ } = useAreasStore((state) => state.areaAdminActions, shallow);
560
+ const [anchorMenuAreas, setAnchorMenuAreas] = useState(null);
561
+ console.log("anchorMenuAreas change", anchorMenuAreas);
562
+ const {
563
+ getLabel
564
+ } = useModuleDictionary();
565
+ const theme = useTheme();
566
+ const currentArea = areas.find((area) => area.id === currentAreaId);
567
+ const {
568
+ host_static_assets,
569
+ environment_assets
570
+ } = useEnvironment();
571
+ const menuActions = useMemo(() => areas.filter((area) => area.id !== currentAreaId).map((area) => {
572
+ return {
573
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.LAYERS}`,
574
+ onClick: () => {
575
+ selectArea(area.id);
576
+ setFocus(false);
577
+ },
578
+ label: area.name
579
+ };
580
+ }), [areas, currentAreaId]);
581
+ const handlerSetAnchorMenuAreas = (element) => {
582
+ setFocus(false);
583
+ setAnchorMenuAreas(element);
584
+ };
585
+ console.log("menuActions areas", menuActions);
586
+ return /* @__PURE__ */ jsx("div", {
587
+ className: areasAdminClasses.areaChipMobileRoot,
588
+ children: /* @__PURE__ */ jsxs("div", {
589
+ className: areasAdminClasses.areaContainerContentChips,
590
+ children: [currentArea ? /* @__PURE__ */ jsx(ChipMobile, {
591
+ areaId: currentArea.id,
592
+ selected: true,
593
+ disabled: true,
594
+ setAnchorMenuAreas
595
+ }, currentArea.id) : null, menuActions.length >= 0 ? /* @__PURE__ */ jsx("div", {
596
+ className: areasAdminClasses.areaChipMobileIconContainer,
597
+ children: /* @__PURE__ */ jsx(MenuActions, {
598
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.CHEVRON_DOWN}`,
599
+ arrowType: "no-arrow",
600
+ marginTop: "12px!important",
601
+ marginLeft: "14px!important",
602
+ anchorOrigin: {
603
+ vertical: "bottom",
604
+ horizontal: "right"
605
+ },
606
+ transformOrigin: {
607
+ vertical: "top",
608
+ horizontal: "right"
609
+ },
610
+ menuActions,
611
+ externalOpen: anchorMenuAreas,
612
+ externalClose: handlerSetAnchorMenuAreas,
613
+ className: areasAdminClasses.areasPopoverMobileOptions,
614
+ menuActionSx: theme.components?.M4LAreasAdminMobilePopoverOptions?.styleOverrides,
615
+ endListElement: /* @__PURE__ */ jsx(Button, {
616
+ onClick: () => {
617
+ addArea();
618
+ setAnchorMenuAreas(null);
619
+ },
620
+ variant: "outlined",
621
+ startIcon: /* @__PURE__ */ jsx(Icon, {
622
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.ADD_AREA}`
623
+ }),
624
+ children: getLabel(getAreasDictionary(DICCTIONARY.area_add_new))
625
+ })
626
+ })
627
+ }) : null]
628
+ })
629
+ });
630
+ };
631
+ function AreasAdmin() {
632
+ const areas = useAreasStore((state) => state.areas, shallow);
633
+ const currentArea = useAreasStore((state) => state.currentAreaId, shallow);
634
+ const status = useAreasStore((state) => state.ownerState.status);
635
+ const {
636
+ setFocus
637
+ } = useAreasStore((state) => state.areaAdminActions, shallow);
638
+ const classesRoot = useAreasStore((state) => state.adminClasses.root);
639
+ const areasLength = useAreasStore((state) => state.areas.length);
640
+ const isDesktop = useResponsiveDesktop();
641
+ const {
642
+ addArea
643
+ } = useAreasStore((state) => state.areasActions, shallow);
644
+ const {
645
+ host_static_assets,
646
+ environment_assets
647
+ } = useEnvironment();
648
+ const divRef = useRef(null);
649
+ const divRefOut = useRef(null);
650
+ const handleClickOutsideFn = () => {
651
+ setFocus(false);
652
+ };
653
+ useOnClickOutside(divRef, handleClickOutsideFn, divRefOut);
654
+ const rippleRef = useRef(null);
655
+ const onRippleStart = (e) => {
656
+ if (rippleRef.current) {
657
+ rippleRef.current.start(e);
658
+ }
659
+ };
660
+ const onRippleStop = (e) => {
661
+ if (rippleRef.current) {
662
+ rippleRef.current.stop(e);
663
+ }
664
+ };
665
+ if (status !== "loaded") {
666
+ return null;
667
+ }
668
+ return /* @__PURE__ */ jsx("div", {
669
+ ref: divRefOut,
670
+ style: {
671
+ width: "100%",
672
+ height: "100%",
673
+ position: "static"
674
+ },
675
+ onMouseDown: onRippleStart,
676
+ onMouseUp: onRippleStop,
677
+ children: /* @__PURE__ */ jsxs(AreasAdminRoot, {
678
+ ref: divRef,
679
+ className: classesRoot,
680
+ onClick: () => setFocus(true),
681
+ children: [/* @__PURE__ */ jsxs("div", {
682
+ className: areasAdminClasses.areaContainerChipsIcon,
683
+ children: [isDesktop ? /* @__PURE__ */ jsx("div", {
684
+ className: areasAdminClasses.areaIconLayer,
685
+ children: /* @__PURE__ */ jsx("div", {
686
+ className: areasAdminClasses.areaIconLayerContent,
687
+ children: /* @__PURE__ */ jsx(Icon, {
688
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.LAYERS}`
689
+ })
690
+ })
691
+ }) : null, /* @__PURE__ */ jsx("div", {
692
+ className: areasAdminClasses.areaContainerChips,
693
+ children: /* @__PURE__ */ jsx("div", {
694
+ className: areasAdminClasses.areaContainerContentChips,
695
+ children: isDesktop ? /* @__PURE__ */ jsx(ScrollBar, {
696
+ children: /* @__PURE__ */ jsx(Fragment, {
697
+ children: areas.map((area) => /* @__PURE__ */ jsx(AreaChip, {
698
+ areaId: area,
699
+ selected: area === currentArea,
700
+ disabled: areasLength === 1
701
+ }, area))
702
+ })
703
+ }) : /* @__PURE__ */ jsx(AreaChipMobile, {})
704
+ })
705
+ })]
706
+ }), isDesktop ? /* @__PURE__ */ jsx(IconButton, {
707
+ className: areasAdminClasses.areasAddButton,
708
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.ADD_AREA}`,
709
+ size: "small",
710
+ onClick: addArea
711
+ }) : null]
712
+ })
713
+ });
714
+ }
715
+ export {
716
+ AreasAdmin as A,
717
+ useAreasAdminUtilityClasses as u
718
+ };