@m4l/components 1.0.14 → 1.0.16

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 (69) hide show
  1. package/components/AccountPopover/{index.404f01d4.js → index.97a78be9.js} +1 -1
  2. package/components/AppBar/{index.a153e334.js → index.47dbe6f1.js} +1 -1
  3. package/components/CommonActions/components/ActionFormCancel/{index.108b4887.js → index.ad1b361f.js} +1 -1
  4. package/components/DataGrid/formatters/ColumnBooleanFormatter/{index.aa98f7b6.js → index.3e0b387f.js} +1 -1
  5. package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/{index.59b04e57.js → index.f33eb24e.js} +1 -1
  6. package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/{index.7fc4c5f0.js → index.381342ab.js} +1 -1
  7. package/components/DataGrid/{index.d05b9542.js → index.804af87c.js} +2 -2
  8. package/components/DataGrid/subcomponents/Actions/{index.afc466b3.js → index.7421063b.js} +6 -6
  9. package/components/DragResizeWindow/{index.2b36dc1f.js → index.c957a1e6.js} +2 -2
  10. package/components/DynamicFilter/{dictionary.ce375e8f.js → dictionary.3b52457e.js} +1 -1
  11. package/components/DynamicFilter/helpers/{index.0eab89ef.js → index.32ea6e4a.js} +7 -2
  12. package/components/DynamicFilter/{index.ef6c3a4f.js → index.107ff9cd.js} +2 -2
  13. package/components/DynamicFilter/slots/constants.13968194.js +34 -0
  14. package/components/DynamicFilter/slots/{index.6f8fcccb.js → index.1590336a.js} +30 -61
  15. package/components/DynamicFilter/store/{index.6319d445.js → index.17676a1e.js} +1 -1
  16. package/components/DynamicFilter/subcomponents/AppliedFilterChip/index.99e063cc.js +60 -0
  17. package/components/DynamicFilter/subcomponents/AppliedFilters/index.883e90f5.js +26 -0
  18. package/components/DynamicFilter/subcomponents/DynamicFilterBase/index.909c1836.js +40 -0
  19. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.b718be41.js +56 -0
  20. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index.d44591da.js +53 -0
  21. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index.3e5853fd.js +55 -0
  22. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index.740042db.js +48 -0
  23. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index.636d6e6e.js +40 -0
  24. package/components/DynamicFilter/subcomponents/FieldTypes/index.339d175f.js +34 -0
  25. package/components/DynamicFilter/subcomponents/FilterActions/index.c549da68.js +88 -0
  26. package/components/DynamicFilter/subcomponents/InputFilter/index.ce036c20.js +168 -0
  27. package/components/DynamicFilter/subcomponents/PopoverFilter/index.3655469c.js +157 -0
  28. package/components/DynamicFilter/subcomponents/PopoverMenuFields/index.50fc58b0.js +63 -0
  29. package/components/FieldLabel/{index.b220bfbb.js → index.e951e11f.js} +1 -1
  30. package/components/Icon/{index.717cf69c.js → index.9615b1f6.js} +2 -2
  31. package/components/LoadingError/{index.4cfeee6f.js → index.2cdebf59.js} +1 -1
  32. package/components/MFLoader/{index.46805ba6.js → index.fb82993d.js} +1 -1
  33. package/components/ObjectLogs/{index.86dd71c3.js → index.6bd7a872.js} +5 -5
  34. package/components/PaperForm/{index.7a73a394.js → index.afbd86d1.js} +1 -1
  35. package/components/Period/{index.0d3ea00c.js → index.a6ea5000.js} +1 -1
  36. package/components/PropertyValue/{index.d02bea18.js → index.914a6cad.js} +2 -2
  37. package/components/SideBar/{index.90321e9f.js → index.a25eaad8.js} +2 -2
  38. package/components/ToastContainer/{index.f5bff00f.js → index.d2064c6b.js} +1 -1
  39. package/components/areas/components/AreasAdmin/{index.8290b7ac.js → index.15bd47d9.js} +5 -5
  40. package/components/areas/components/AreasViewer/{index.c1b3b741.js → index.316d5487.js} +7 -7
  41. package/components/areas/contexts/AreasContext/{index.8a80127b.js → index.765faaee.js} +2 -2
  42. package/components/areas/hooks/useAreas/{index.16d6b5a7.js → index.1b499976.js} +1 -1
  43. package/components/commercial/TopBar/{index.9eb26752.js → index.c55da9c3.js} +2 -2
  44. package/components/commercial/{index.192900c0.js → index.1248a029.js} +2 -2
  45. package/components/formatters/BooleanFormatter/{index.790bdc9d.js → index.117465b4.js} +2 -2
  46. package/components/formatters/{index.0b95012a.js → index.a8f46cab.js} +1 -1
  47. package/components/hook-form/RHFAutocomplete/{index.4caa6e3d.js → index.709756f6.js} +2 -2
  48. package/components/hook-form/RHFAutocompleteAsync/{index.21fe8f74.js → index.92180d10.js} +1 -1
  49. package/components/hook-form/RHFCheckbox/{index.d6c22f91.js → index.8c3ed4a0.js} +1 -1
  50. package/components/hook-form/RHFColorPicker/{index.e7f1ddab.js → index.fe1a3466.js} +2 -2
  51. package/components/hook-form/RHFDateTime/{index.d3683024.js → index.07030dcc.js} +2 -2
  52. package/components/hook-form/RHFPeriod/{index.b871e169.js → index.755de1db.js} +2 -2
  53. package/components/hook-form/RHFTextField/{index.ea988842.js → index.e1c51719.js} +2 -2
  54. package/components/maps/components/GpsTools/{index.16d5fdbf.js → index.a8ece5d5.js} +11 -11
  55. package/components/maps/components/Map/{index.b259ecde.js → index.e4045b3e.js} +8 -8
  56. package/components/modal/{WindowBase.f6adf7bc.js → WindowBase.2f606ead.js} +2 -2
  57. package/components/modal/{WindowConfirm.3e0d2457.js → WindowConfirm.6eea8ea6.js} +1 -1
  58. package/components/mui_extended/Accordion/{index.59a7e7e8.js → index.c4551873.js} +2 -2
  59. package/components/mui_extended/{CheckBox.c2f296af.js → CheckBox.09cbd444.js} +1 -1
  60. package/components/mui_extended/IconButton/{index.7ff17cea.js → index.47be7d35.js} +1 -1
  61. package/components/mui_extended/MenuActions/{index.5b65b116.js → index.ab55b9b7.js} +2 -2
  62. package/components/mui_extended/Pager/{index.4231bc79.js → index.a453d8b5.js} +2 -2
  63. package/components/mui_extended/ToggleIconButton/{index.709e2a4b.js → index.61269519.js} +1 -1
  64. package/components/popups/PopupsProvider/{index.59c39aa5.js → index.88f09c2a.js} +1 -1
  65. package/components/popups/PopupsViewer/{index.a10114d0.js → index.e80c69c5.js} +4 -4
  66. package/hooks/useFormAddEdit/{index.e53d7d2c.js → index.d718efd0.js} +1 -1
  67. package/index.js +66 -53
  68. package/package.json +1 -1
  69. package/components/DynamicFilter/subcomponents/index.f5d4a81d.js +0 -787
@@ -1,787 +0,0 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { useMemo, useState, useEffect, useRef, useCallback } from "react";
3
- import { useModuleDictionary, useEnvironment, useModuleSkeleton } from "@m4l/core";
4
- import { B as BOOLEAN_OPERATORS, S as STRING_OPERATORS, D as DATE_TIME_OPERATORS, N as NUMBER_OPERATORS, a as SELECT_OPERATORS, A as ALL_FIELD } from "../constants.1dddd09c.js";
5
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../dictionary.ce375e8f.js";
6
- import { R as RHFAutocomplete } from "../../hook-form/RHFAutocomplete/index.4caa6e3d.js";
7
- import { R as RHFTextField } from "../../hook-form/RHFTextField/index.ea988842.js";
8
- import { useFormContext, useWatch } from "react-hook-form";
9
- import { R as RHFDateTime } from "../../hook-form/RHFDateTime/index.d3683024.js";
10
- import { u as useDynamicFilterStore } from "../store/index.6319d445.js";
11
- import { R as RHFAutocompleteAsync } from "../../hook-form/RHFAutocompleteAsync/index.21fe8f74.js";
12
- import { P as PopoverMenuStyled, a as PopoverMenuItemStyled, b as PopoverMenuItemIconStyled, c as PopoverMenuItemLabelStyled, I as InputFilterStyled, d as InputFilterIconStyled, e as InputFilterInputStyled, A as AppliedFilterChipStyled, f as AppliedFilterChipIconStyled, g as AppliedFilterChipInfoStyled, h as AppliedFilterChipInfoFieldNameStyled, i as AppliedFilterChipInfoOperatorStyled, j as AppliedFilterChipInfoOperandsStyled, k as AppliedFilterChipRemoveButtonStyled, l as AppliedFiltersStyled, m as AppliedFilterInnerContainerStyled, n as ActionsSkeletonButtonStyled, o as ActionsStyled, p as ActionsClearButtonStyled, q as ActionsSubmitButtonStyled, r as PopoverStyled, s as PopoverHeaderStyled, t as PopoverHeaderIconStyled, u as PopoverHeaderTitleStyled, v as PopoverContainerFieldsStyled, w as PopoverHeaderActionsStyled, R as RootStyled, D as DynamicFilterSlots, x as InnerContainerStyled } from "../slots/index.6f8fcccb.js";
13
- import { a as getPropDataTestId } from "../../../test/getNameDataTestId.0faeade8.js";
14
- import { Skeleton } from "@mui/material";
15
- import { S as ScrollBar } from "../../ScrollBar/index.21bc5025.js";
16
- import { useFormatter } from "@m4l/graphics";
17
- import { B as BooleanFilterHelpers, S as StringFilterHelpers, N as NumberFilterHelpers, D as DateTimeFilterHelpers, b as SelectFilterHelpers } from "../helpers/index.0eab89ef.js";
18
- import { R as RHFormProvider } from "../../../contexts/RHFormContext/index.bf3a2812.js";
19
- import { A as ActionCancel } from "../../CommonActions/components/ActionCancel/index.609a78ca.js";
20
- import { A as ActionIntro } from "../../CommonActions/components/ActionIntro/index.ebac0bc1.js";
21
- function BooleanFilter() {
22
- const { getLabel } = useModuleDictionary();
23
- const operators = useMemo(
24
- () => BOOLEAN_OPERATORS.map((o) => ({
25
- id: o,
26
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
27
- })),
28
- [getLabel]
29
- );
30
- const optionsYesNo = useMemo(
31
- () => [
32
- {
33
- value: true,
34
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.operand_true))
35
- },
36
- {
37
- value: false,
38
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.operand_false))
39
- }
40
- ],
41
- [getLabel]
42
- );
43
- return /* @__PURE__ */ jsxs("div", { children: [
44
- /* @__PURE__ */ jsx(
45
- RHFAutocomplete,
46
- {
47
- name: "formValueOperator",
48
- autoComplete: "off",
49
- options: operators,
50
- getOptionLabel: (option) => option.label,
51
- isOptionEqualToValue: (option, value) => option.id === value.id,
52
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_boolean_operator))
53
- }
54
- ),
55
- /* @__PURE__ */ jsx(
56
- RHFAutocomplete,
57
- {
58
- name: "formValueOperand1",
59
- autoComplete: "off",
60
- options: optionsYesNo,
61
- getOptionLabel: (option) => option.label,
62
- isOptionEqualToValue: (option, value) => option.value === value.value,
63
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_boolean_operand1))
64
- }
65
- )
66
- ] });
67
- }
68
- function StringFilter() {
69
- const { getLabel } = useModuleDictionary();
70
- const operators = useMemo(
71
- () => STRING_OPERATORS.map((o) => ({
72
- id: o,
73
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
74
- })),
75
- [getLabel]
76
- );
77
- return /* @__PURE__ */ jsxs("div", { children: [
78
- /* @__PURE__ */ jsx(
79
- RHFAutocomplete,
80
- {
81
- name: "formValueOperator",
82
- autoComplete: "off",
83
- options: operators,
84
- getOptionLabel: (option) => option.label,
85
- isOptionEqualToValue: (option, value) => option.id === value.id,
86
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_string))
87
- }
88
- ),
89
- /* @__PURE__ */ jsx(
90
- RHFTextField,
91
- {
92
- name: "formValueOperand1",
93
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_string))
94
- }
95
- )
96
- ] });
97
- }
98
- function DateTimeFilter() {
99
- const { getLabel } = useModuleDictionary();
100
- const { control } = useFormContext();
101
- const operator = useWatch({
102
- control,
103
- name: "formValueOperator"
104
- });
105
- const operators = useMemo(
106
- () => DATE_TIME_OPERATORS.map((o) => ({
107
- id: o,
108
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
109
- })),
110
- [getLabel]
111
- );
112
- return /* @__PURE__ */ jsxs("div", { children: [
113
- /* @__PURE__ */ jsx(
114
- RHFAutocomplete,
115
- {
116
- name: "formValueOperator",
117
- autoComplete: "off",
118
- options: operators,
119
- getOptionLabel: (option) => option.label,
120
- isOptionEqualToValue: (option, value) => option.id === value.id,
121
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_date_time))
122
- }
123
- ),
124
- /* @__PURE__ */ jsx(
125
- RHFDateTime,
126
- {
127
- name: "formValueOperand1",
128
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_date_time))
129
- }
130
- ),
131
- operator && operator.id === "b" && /* @__PURE__ */ jsx(
132
- RHFDateTime,
133
- {
134
- name: "formValueOperand2",
135
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_date_time))
136
- }
137
- )
138
- ] });
139
- }
140
- function NumberFilter() {
141
- const { getLabel } = useModuleDictionary();
142
- const { control } = useFormContext();
143
- const operator = useWatch({
144
- control,
145
- name: "formValueOperator"
146
- });
147
- const operators = useMemo(
148
- () => NUMBER_OPERATORS.map((o) => ({
149
- id: o,
150
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
151
- })),
152
- [getLabel]
153
- );
154
- return /* @__PURE__ */ jsxs("div", { children: [
155
- /* @__PURE__ */ jsx(
156
- RHFAutocomplete,
157
- {
158
- name: "formValueOperator",
159
- autoComplete: "off",
160
- options: operators,
161
- getOptionLabel: (option) => option.label,
162
- isOptionEqualToValue: (option, value) => option.id === value.id,
163
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_number))
164
- }
165
- ),
166
- /* @__PURE__ */ jsx(
167
- RHFTextField,
168
- {
169
- name: "formValueOperand1",
170
- type: "number",
171
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_number))
172
- }
173
- ),
174
- operator && operator.id === "b" && /* @__PURE__ */ jsx(
175
- RHFTextField,
176
- {
177
- name: "formValueOperand2",
178
- type: "number",
179
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_number))
180
- }
181
- )
182
- ] });
183
- }
184
- function SelectFilter() {
185
- const { getLabel } = useModuleDictionary();
186
- const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
187
- if (!field?.selectOptions?.endPoint) {
188
- throw new Error("El filtro tipo Select requiere la configuraci\xF3n del Endpoint");
189
- }
190
- const autocompleteProps = field?.selectOptions;
191
- const operators = useMemo(
192
- () => SELECT_OPERATORS.map((o) => ({
193
- id: o,
194
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
195
- })),
196
- [getLabel]
197
- );
198
- return /* @__PURE__ */ jsxs("div", { children: [
199
- /* @__PURE__ */ jsx(
200
- RHFAutocomplete,
201
- {
202
- name: "formValueOperator",
203
- autoComplete: "off",
204
- options: operators,
205
- getOptionLabel: (option) => option.label,
206
- isOptionEqualToValue: (option, value) => option.id === value.id,
207
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operator))
208
- }
209
- ),
210
- /* @__PURE__ */ jsx(
211
- RHFAutocompleteAsync,
212
- {
213
- ...autocompleteProps,
214
- name: "formValueOperandsArray",
215
- autoComplete: "off",
216
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operands_array))
217
- }
218
- )
219
- ] });
220
- }
221
- const helpersStrategies = {
222
- boolean: new BooleanFilterHelpers(),
223
- string: new StringFilterHelpers(),
224
- number: new NumberFilterHelpers(),
225
- datetime: new DateTimeFilterHelpers(),
226
- select: new SelectFilterHelpers(),
227
- __default__: () => {
228
- throw new Error("Type no defined");
229
- }
230
- };
231
- function fieldFactory(type) {
232
- const selectedHelper = helpersStrategies?.[type];
233
- if (!selectedHelper) {
234
- return helpersStrategies.__default__();
235
- }
236
- return selectedHelper;
237
- }
238
- function useDynamicFilterBase() {
239
- const ownerState = useDynamicFilterStore((state) => state.ownerState);
240
- const dataTestId = useDynamicFilterStore((state) => state.dataTestId);
241
- return { ownerState, dataTestId };
242
- }
243
- function useInputFilter() {
244
- const [selectedFieldIndex, setSelectedFieldIndex] = useState(-1);
245
- const [filteredFields, setFilteredFields] = useState([]);
246
- const { host_static_assets, environment_assets } = useEnvironment();
247
- const { getLabel } = useModuleDictionary();
248
- const isSkeleton = useModuleSkeleton();
249
- const anchorEl = useDynamicFilterStore((state) => state.fnAnchorEl);
250
- const withAllField = useDynamicFilterStore((state) => state.withAllField);
251
- const availableFields = useDynamicFilterStore((state) => state.availableFields);
252
- const inputData = useDynamicFilterStore((state) => state.inputData);
253
- const {
254
- addFilter,
255
- closePopoverMenuFields,
256
- getFieldByName,
257
- getNewId,
258
- hidePopoverFilter,
259
- openPopoverMenuFields,
260
- setInEdition,
261
- setInputData,
262
- showPopoverFilterForAdd
263
- } = useDynamicFilterStore((state) => state.actions);
264
- useEffect(() => {
265
- if (!anchorEl) {
266
- setFilteredFields([]);
267
- } else {
268
- setFilteredFields(
269
- availableFields.filter(
270
- (field) => (field.label ?? getLabel(field.dictionaryId)).includes(inputData)
271
- )
272
- );
273
- setSelectedFieldIndex(-1);
274
- }
275
- }, [anchorEl, inputData, availableFields, getLabel]);
276
- function handleOpenPopUpClickItem(field) {
277
- closePopoverMenuFields();
278
- if (anchorEl)
279
- showPopoverFilterForAdd(anchorEl(), field);
280
- }
281
- const inputHandlersProps = {
282
- onFocus: (event) => {
283
- openPopoverMenuFields(event.currentTarget);
284
- setInEdition(true);
285
- },
286
- onChange: (event) => {
287
- setInputData(event.target.value);
288
- if (!anchorEl) {
289
- openPopoverMenuFields(event.currentTarget);
290
- }
291
- hidePopoverFilter(true);
292
- },
293
- onKeyDown: (event) => {
294
- if (event.key === "ArrowDown") {
295
- let newIndex = -1;
296
- if (filteredFields.length > 0) {
297
- if (selectedFieldIndex < filteredFields.length - 1) {
298
- newIndex = selectedFieldIndex + 1;
299
- } else {
300
- newIndex = filteredFields.length - 1;
301
- }
302
- }
303
- setSelectedFieldIndex(newIndex);
304
- }
305
- if (event.key === "ArrowUp") {
306
- let newIndex = -1;
307
- if (filteredFields.length > 0) {
308
- if (selectedFieldIndex > -1) {
309
- newIndex = selectedFieldIndex - 1;
310
- }
311
- }
312
- setSelectedFieldIndex(newIndex);
313
- }
314
- if (event.key === "Escape") {
315
- closePopoverMenuFields();
316
- }
317
- if (event.key !== "Enter")
318
- return;
319
- if (selectedFieldIndex === -1) {
320
- if (inputData.trim() === "") {
321
- closePopoverMenuFields();
322
- return;
323
- }
324
- if (withAllField) {
325
- addFilter({
326
- id: getNewId(),
327
- fieldType: "string",
328
- field: getFieldByName(ALL_FIELD.name),
329
- isSet: true,
330
- fixed: false,
331
- operator: "c",
332
- operand1: inputData
333
- });
334
- setInputData("");
335
- closePopoverMenuFields();
336
- }
337
- } else {
338
- handleOpenPopUpClickItem(filteredFields[selectedFieldIndex]);
339
- }
340
- }
341
- };
342
- return {
343
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/filter.svg`,
344
- isSkeleton,
345
- inputPlaceHolder: getLabel(getDynamicFilterDictionary(DICCTIONARY.input_placeholder)),
346
- inputData,
347
- inputHandlersProps,
348
- canRender: !(!withAllField && availableFields.length === 0),
349
- filteredFields,
350
- selectedFieldIndex
351
- };
352
- }
353
- function InputFilterSkeleton() {
354
- return /* @__PURE__ */ jsxs(Fragment, { children: [
355
- /* @__PURE__ */ jsx(
356
- Skeleton,
357
- {
358
- variant: "circular",
359
- width: "16px",
360
- height: "16px",
361
- sx: { minWidth: "16px", minHeight: "16px" }
362
- }
363
- ),
364
- /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "100%", height: "16px", sx: { minWidth: "80px" } })
365
- ] });
366
- }
367
- function usePopoverMenuFields() {
368
- const { getLabel } = useModuleDictionary();
369
- const fnAnchorEl = useDynamicFilterStore((state) => state.fnAnchorEl);
370
- const { showPopoverFilterForAdd, closePopoverMenuFields } = useDynamicFilterStore(
371
- (state) => state.actions
372
- );
373
- function handleOpenPopUpClickItem(_event, field) {
374
- if (fnAnchorEl) {
375
- showPopoverFilterForAdd(fnAnchorEl(), field);
376
- }
377
- }
378
- function handleClosePopover() {
379
- closePopoverMenuFields(false);
380
- }
381
- function getItemLabel(field) {
382
- return field.label ?? getLabel(field.dictionaryId);
383
- }
384
- return {
385
- fnAnchorEl,
386
- getItemLabel,
387
- handleClosePopover,
388
- handleOpenPopUpClickItem
389
- };
390
- }
391
- function PopoverMenuFields(props) {
392
- const { fields, selectFieldIndex } = props;
393
- const { fnAnchorEl, handleOpenPopUpClickItem, handleClosePopover, getItemLabel } = usePopoverMenuFields();
394
- return /* @__PURE__ */ jsx(
395
- PopoverMenuStyled,
396
- {
397
- disableAutoFocus: true,
398
- disableRestoreFocus: true,
399
- arrowType: "top-left",
400
- anchorOrigin: { vertical: "bottom", horizontal: "left" },
401
- transformOrigin: { vertical: "top", horizontal: "left" },
402
- open: Boolean(fnAnchorEl),
403
- onClose: handleClosePopover,
404
- anchorEl: fnAnchorEl?.(),
405
- ownerState: {},
406
- children: Boolean(fnAnchorEl) && fields.map((field, index) => /* @__PURE__ */ jsxs(
407
- PopoverMenuItemStyled,
408
- {
409
- dense: true,
410
- selected: index === selectFieldIndex,
411
- onClick: (event) => handleOpenPopUpClickItem(event, field),
412
- ownerState: {},
413
- children: [
414
- /* @__PURE__ */ jsx(PopoverMenuItemIconStyled, { src: field.urlIcon, ownerState: {} }),
415
- /* @__PURE__ */ jsx(PopoverMenuItemLabelStyled, { ownerState: {}, children: getItemLabel(field) })
416
- ]
417
- },
418
- `menu_action_${getItemLabel(field)}`
419
- ))
420
- }
421
- );
422
- }
423
- const InputFilter = () => {
424
- const {
425
- iconUrl,
426
- isSkeleton,
427
- inputPlaceHolder,
428
- inputData,
429
- inputHandlersProps,
430
- canRender,
431
- filteredFields,
432
- selectedFieldIndex
433
- } = useInputFilter();
434
- if (!canRender)
435
- return null;
436
- if (isSkeleton) {
437
- return /* @__PURE__ */ jsx(InputFilterStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(InputFilterSkeleton, {}) });
438
- }
439
- return /* @__PURE__ */ jsxs(InputFilterStyled, { ownerState: {}, children: [
440
- /* @__PURE__ */ jsx(InputFilterIconStyled, { src: iconUrl, ownerState: {} }),
441
- /* @__PURE__ */ jsx(
442
- InputFilterInputStyled,
443
- {
444
- type: "text",
445
- value: inputData,
446
- placeholder: inputPlaceHolder,
447
- ownerState: {},
448
- ...inputHandlersProps
449
- }
450
- ),
451
- /* @__PURE__ */ jsx(PopoverMenuFields, { fields: filteredFields, selectFieldIndex: selectedFieldIndex })
452
- ] });
453
- };
454
- const InputFilter$1 = InputFilter;
455
- function useAppliedFilters() {
456
- const appliedFilter = useDynamicFilterStore((state) => state.appliedFilters);
457
- const isSkeleton = useDynamicFilterStore((state) => state.ownerState.isSkeleton);
458
- const appliedFiltersSorted = [...appliedFilter].sort(
459
- (filterA, filterB) => filterA.isSet !== filterB.isSet ? Number(filterA.isSet) - Number(filterB.isSet) : filterB.id - filterA.id
460
- );
461
- return {
462
- appliedFiltersSorted,
463
- isSkeleton
464
- };
465
- }
466
- function useAppliedFilterChip(filter) {
467
- const { host_static_assets, environment_assets } = useEnvironment();
468
- const { getLabel } = useModuleDictionary();
469
- const formatters = useFormatter();
470
- const { hidePopoverFilter, removeFilter, showPopoverFilterForEdit } = useDynamicFilterStore(
471
- (state) => state.actions
472
- );
473
- const removeIconUrl = `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/clear.svg`;
474
- const labels = useMemo(() => {
475
- return fieldFactory(filter.field.type).getLabels(filter, getLabel, formatters, filter.field);
476
- }, [filter, getLabel]);
477
- function onDelete() {
478
- hidePopoverFilter(false);
479
- removeFilter(filter.id);
480
- }
481
- function onEditFilter(event) {
482
- hidePopoverFilter(false);
483
- const currentTarget = event.currentTarget;
484
- setTimeout(() => showPopoverFilterForEdit(currentTarget, filter), 10);
485
- }
486
- return {
487
- onDelete,
488
- onEditFilter,
489
- removeIconUrl,
490
- iconFieldUrl: filter.field?.urlIcon,
491
- labels
492
- };
493
- }
494
- function AppliedFilterChip(props) {
495
- const { fixed } = props;
496
- const { onEditFilter, onDelete, iconFieldUrl, removeIconUrl, labels } = useAppliedFilterChip(props);
497
- return /* @__PURE__ */ jsxs(AppliedFilterChipStyled, { ownerState: {}, children: [
498
- iconFieldUrl && /* @__PURE__ */ jsx(AppliedFilterChipIconStyled, { onClick: onEditFilter, src: iconFieldUrl, ownerState: {} }),
499
- /* @__PURE__ */ jsxs(AppliedFilterChipInfoStyled, { onClick: onEditFilter, ownerState: {}, children: [
500
- /* @__PURE__ */ jsx(AppliedFilterChipInfoFieldNameStyled, { ownerState: {}, children: labels.labelField }),
501
- /* @__PURE__ */ jsx(AppliedFilterChipInfoOperatorStyled, { ownerState: {}, children: labels.labelOperator }),
502
- /* @__PURE__ */ jsx(AppliedFilterChipInfoOperandsStyled, { ownerState: {}, children: labels.labelOperands })
503
- ] }),
504
- !fixed && /* @__PURE__ */ jsx(
505
- AppliedFilterChipRemoveButtonStyled,
506
- {
507
- src: removeIconUrl,
508
- size: "small",
509
- dictionaryTooltipId: "dynamic_filter.tooltip_clear_filter",
510
- onClick: onDelete,
511
- ownerState: {}
512
- }
513
- )
514
- ] });
515
- }
516
- function AppliedFilters() {
517
- const { appliedFiltersSorted, isSkeleton } = useAppliedFilters();
518
- if (isSkeleton) {
519
- return /* @__PURE__ */ jsx(AppliedFiltersStyled, { ownerState: {} });
520
- }
521
- return /* @__PURE__ */ jsx(AppliedFiltersStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(ScrollBar, { children: /* @__PURE__ */ jsx(AppliedFilterInnerContainerStyled, { ownerState: {}, children: appliedFiltersSorted?.map((filter) => /* @__PURE__ */ jsx(AppliedFilterChip, { ...filter }, filter.id)) }) }) });
522
- }
523
- const ASSETS_URL = "frontend/components/dynamic_filter/assets/icons";
524
- const ASSETS = {
525
- refresh: "restart.svg",
526
- search: "search.svg"
527
- };
528
- function useFilterActions() {
529
- const { host_static_assets, environment_assets } = useEnvironment();
530
- const automatic = useDynamicFilterStore((state) => state.automatic);
531
- const isSkeleton = useDynamicFilterStore((state) => state.ownerState.isSkeleton);
532
- const isValid = useDynamicFilterStore((state) => state.ownerState.isValid);
533
- const isDirty = useDynamicFilterStore((state) => state.ownerState.isDirty);
534
- const appliedFilters = useDynamicFilterStore((state) => state.appliedFilters);
535
- const { hidePopoverFilter, clearFilters, fireOnChangeFilters } = useDynamicFilterStore(
536
- (state) => state.actions
537
- );
538
- function onClickClearFilters() {
539
- hidePopoverFilter(false);
540
- clearFilters();
541
- fireOnChangeFilters();
542
- }
543
- const filterIconUrl = `${host_static_assets}/${environment_assets}/${ASSETS_URL}/${automatic ? ASSETS.refresh : ASSETS.search}`;
544
- const clearIconUrl = `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/close.svg`;
545
- const canShowRemoveAction = appliedFilters.findIndex((f) => !f.fixed) > -1;
546
- const filterButtonDictionaryTooltip = getDynamicFilterDictionary(
547
- isValid ? isDirty ? DICCTIONARY.filter_tooltip_dirty : DICCTIONARY.filter_tooltip_refresh : DICCTIONARY.filter_tooltip_invalid
548
- );
549
- return {
550
- isSkeleton,
551
- filterIconUrl,
552
- clearIconUrl,
553
- canShowRemoveAction,
554
- onClickClearFilters,
555
- onClickFilter: fireOnChangeFilters,
556
- filterButtonDictionaryTooltip,
557
- ownerState: { isValid }
558
- };
559
- }
560
- function FilterActionsSkeleton() {
561
- return /* @__PURE__ */ jsxs(Fragment, { children: [
562
- /* @__PURE__ */ jsx(ActionsSkeletonButtonStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: "16px", height: "16px" }) }),
563
- /* @__PURE__ */ jsx(ActionsSkeletonButtonStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: "16px", height: "16px" }) })
564
- ] });
565
- }
566
- function FilterActions() {
567
- const {
568
- isSkeleton,
569
- filterIconUrl,
570
- clearIconUrl,
571
- canShowRemoveAction,
572
- onClickClearFilters,
573
- onClickFilter,
574
- filterButtonDictionaryTooltip,
575
- ownerState
576
- } = useFilterActions();
577
- if (isSkeleton) {
578
- return /* @__PURE__ */ jsx(ActionsStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(FilterActionsSkeleton, {}) });
579
- }
580
- return /* @__PURE__ */ jsxs(ActionsStyled, { ownerState: {}, children: [
581
- canShowRemoveAction && /* @__PURE__ */ jsx(
582
- ActionsClearButtonStyled,
583
- {
584
- src: clearIconUrl,
585
- onClick: onClickClearFilters,
586
- dictionaryTooltipId: "dynamic_filter.tooltip_clear_filters",
587
- ownerState: {}
588
- }
589
- ),
590
- /* @__PURE__ */ jsx(
591
- ActionsSubmitButtonStyled,
592
- {
593
- src: filterIconUrl,
594
- "aria-label": "settings",
595
- dictionaryTooltipId: filterButtonDictionaryTooltip,
596
- onClick: onClickFilter,
597
- ownerState: { ...ownerState }
598
- }
599
- )
600
- ] });
601
- }
602
- function usePopoverFilter() {
603
- let anchorEl;
604
- let field;
605
- let formFilter;
606
- let filterFormValue;
607
- let popupValidationSchema;
608
- const { getLabel } = useModuleDictionary();
609
- const popoverFilterData = useDynamicFilterStore((state) => state.popoverFilterData);
610
- const { hidePopoverFilter, addFilter, updateFilter, getNewId } = useDynamicFilterStore(
611
- (state) => state.actions
612
- );
613
- const refPreviousPopoverFilterData = useRef(popoverFilterData);
614
- const statusLoad = useMemo(() => {
615
- let returnStatus;
616
- if (popoverFilterData && refPreviousPopoverFilterData.current === void 0) {
617
- returnStatus = "ready";
618
- } else if (!popoverFilterData) {
619
- returnStatus = "initial";
620
- } else {
621
- returnStatus = "reload_values_provider";
622
- }
623
- refPreviousPopoverFilterData.current = popoverFilterData;
624
- return returnStatus;
625
- }, [popoverFilterData]);
626
- if (popoverFilterData?.openFor === "add") {
627
- anchorEl = popoverFilterData?.fnAnchorEl();
628
- field = popoverFilterData.field;
629
- const helperField = fieldFactory(field.type);
630
- popupValidationSchema = helperField.getSchema(getLabel);
631
- filterFormValue = helperField.getFormValue(field, getLabel);
632
- formFilter = {
633
- field,
634
- id: getNewId(),
635
- isSet: true,
636
- fixed: false,
637
- ...filterFormValue
638
- };
639
- } else if (popoverFilterData) {
640
- anchorEl = popoverFilterData?.fnAnchorEl();
641
- field = popoverFilterData?.filter.field;
642
- const helperField = fieldFactory(field.type);
643
- popupValidationSchema = helperField.getSchema(getLabel);
644
- filterFormValue = helperField.getFormValue(field, getLabel, popoverFilterData.filter);
645
- formFilter = { ...popoverFilterData?.filter, ...filterFormValue };
646
- } else {
647
- filterFormValue = {};
648
- field = {};
649
- formFilter = {};
650
- anchorEl = {};
651
- }
652
- const onClose = useCallback(() => {
653
- hidePopoverFilter(false);
654
- }, []);
655
- const handleKeyDownPopper = useCallback((event) => {
656
- if (event.key === "Escape") {
657
- onClose();
658
- }
659
- }, []);
660
- function handleClosePopover() {
661
- hidePopoverFilter(false);
662
- }
663
- async function onSubmit(dataFieldValues) {
664
- const filterField = { ...filterFormValue, ...dataFieldValues };
665
- const newFilter = {
666
- ...formFilter,
667
- ...fieldFactory(filterField.fieldType).getFilterFromFormValue(filterField),
668
- isSet: true
669
- };
670
- if (popoverFilterData?.openFor === "add") {
671
- addFilter(newFilter);
672
- } else {
673
- updateFilter(newFilter);
674
- }
675
- hidePopoverFilter(false);
676
- }
677
- const labelField = field?.label ?? getLabel(field?.dictionaryId ?? "");
678
- return {
679
- field,
680
- labelField,
681
- canRender: Boolean(popoverFilterData),
682
- anchorEl,
683
- handleKeyDownPopper,
684
- handleClosePopover,
685
- onSubmit,
686
- onClose,
687
- filterFormValue,
688
- formFilter,
689
- popupValidationSchema,
690
- statusLoad
691
- };
692
- }
693
- function DataTypeComponent(props) {
694
- const { formFilter, statusLoad } = props;
695
- const { setFocus } = useFormContext();
696
- const Component = fieldFactory(formFilter.field.type).getComponent();
697
- useEffect(() => {
698
- setTimeout(() => setFocus("formValueOperand1"), 100);
699
- }, [statusLoad]);
700
- return /* @__PURE__ */ jsx(Component, {});
701
- }
702
- function PopoverFilter() {
703
- const {
704
- field,
705
- labelField,
706
- anchorEl,
707
- handleKeyDownPopper,
708
- handleClosePopover,
709
- onSubmit,
710
- onClose,
711
- filterFormValue,
712
- formFilter,
713
- popupValidationSchema,
714
- statusLoad,
715
- canRender
716
- } = usePopoverFilter();
717
- if (!canRender) {
718
- return null;
719
- }
720
- return /* @__PURE__ */ jsx(
721
- PopoverStyled,
722
- {
723
- open: true,
724
- disableRestoreFocus: true,
725
- transitionDuration: 0,
726
- anchorOrigin: { vertical: "bottom", horizontal: "left" },
727
- transformOrigin: { vertical: "top", horizontal: "left" },
728
- arrowType: "top-left",
729
- anchorEl,
730
- onKeyDown: handleKeyDownPopper,
731
- onClose: handleClosePopover,
732
- ownerState: {},
733
- children: /* @__PURE__ */ jsxs(
734
- RHFormProvider,
735
- {
736
- onSubmit,
737
- values: filterFormValue,
738
- validationSchema: popupValidationSchema,
739
- statusLoad,
740
- children: [
741
- /* @__PURE__ */ jsxs(PopoverHeaderStyled, { ownerState: {}, children: [
742
- field.urlIcon && /* @__PURE__ */ jsx(PopoverHeaderIconStyled, { src: field.urlIcon, ownerState: {} }),
743
- /* @__PURE__ */ jsx(PopoverHeaderTitleStyled, { variant: "paragraphDens", ownerState: {}, children: labelField })
744
- ] }),
745
- /* @__PURE__ */ jsx(PopoverContainerFieldsStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(DataTypeComponent, { formFilter, statusLoad }) }),
746
- /* @__PURE__ */ jsxs(PopoverHeaderActionsStyled, { ownerState: {}, children: [
747
- /* @__PURE__ */ jsx(ActionCancel, { onClick: onClose, skeletonWidth: "68px" }),
748
- /* @__PURE__ */ jsx(ActionIntro, { skeletonWidth: "64px" })
749
- ] })
750
- ]
751
- }
752
- )
753
- }
754
- );
755
- }
756
- function DynamicFilterBase() {
757
- const { ownerState, dataTestId } = useDynamicFilterBase();
758
- return /* @__PURE__ */ jsx(
759
- RootStyled,
760
- {
761
- ownerState: { ...ownerState },
762
- ...getPropDataTestId(dataTestId, DynamicFilterSlots.root),
763
- children: /* @__PURE__ */ jsxs(
764
- InnerContainerStyled,
765
- {
766
- ownerState: { ...ownerState },
767
- ...getPropDataTestId(dataTestId, DynamicFilterSlots.innerContainer),
768
- children: [
769
- /* @__PURE__ */ jsx(InputFilter$1, {}),
770
- /* @__PURE__ */ jsx(AppliedFilters, {}),
771
- /* @__PURE__ */ jsx(FilterActions, {}),
772
- /* @__PURE__ */ jsx(PopoverFilter, {})
773
- ]
774
- }
775
- )
776
- }
777
- );
778
- }
779
- export {
780
- BooleanFilter as B,
781
- DateTimeFilter as D,
782
- NumberFilter as N,
783
- StringFilter as S,
784
- SelectFilter as a,
785
- DynamicFilterBase as b,
786
- fieldFactory as f
787
- };