@m4l/components 1.0.15 → 1.0.17

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.e29a3c5c.js → index.f2226cb9.js} +1 -1
  2. package/components/AppBar/{index.4f4bb61f.js → index.50d090b7.js} +1 -1
  3. package/components/CommonActions/components/ActionFormCancel/{index.b325f1e2.js → index.03a5915a.js} +1 -1
  4. package/components/DataGrid/formatters/ColumnBooleanFormatter/{index.ff18b2a6.js → index.e0dbec18.js} +1 -1
  5. package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/{index.1487b238.js → index.671116f2.js} +1 -1
  6. package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/{index.2999445b.js → index.f7b20493.js} +1 -1
  7. package/components/DataGrid/{index.4a2e0f22.js → index.447c4e44.js} +2 -2
  8. package/components/DataGrid/subcomponents/Actions/{index.0a3db350.js → index.aff74341.js} +6 -6
  9. package/components/DragResizeWindow/{index.f23525c7.js → index.132406ef.js} +2 -2
  10. package/components/DynamicFilter/{constants.1dddd09c.js → constants.095f1dbb.js} +4 -4
  11. package/components/DynamicFilter/{dictionary.da8046c7.js → dictionary.80fc7baf.js} +1 -1
  12. package/components/DynamicFilter/{index.952f8480.js → index.a7cb7710.js} +106 -3
  13. package/components/DynamicFilter/slots/{index.b55f3ebc.js → index.e2218307.js} +30 -30
  14. package/components/DynamicFilter/store/{index.370765c1.js → index.b9c2fe0b.js} +2 -2
  15. package/components/DynamicFilter/subcomponents/AppliedFilterChip/index.f0fe22f7.js +60 -0
  16. package/components/DynamicFilter/subcomponents/AppliedFilters/index.30d89b6c.js +26 -0
  17. package/components/DynamicFilter/subcomponents/DynamicFilterBase/index.edd7ed6f.js +40 -0
  18. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.f926af49.js +126 -0
  19. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index.2382297a.js +169 -0
  20. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index.7b4dccf7.js +151 -0
  21. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index.2258fceb.js +145 -0
  22. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index.82ca3e32.js +112 -0
  23. package/components/DynamicFilter/subcomponents/FieldTypes/index.f4457f31.js +38 -0
  24. package/components/DynamicFilter/subcomponents/FilterActions/index.ba70cf6a.js +88 -0
  25. package/components/DynamicFilter/subcomponents/InputFilter/index.c7d72fb4.js +168 -0
  26. package/components/DynamicFilter/subcomponents/PopoverFilter/index.c2014303.js +157 -0
  27. package/components/DynamicFilter/subcomponents/PopoverMenuFields/index.895fbe45.js +63 -0
  28. package/components/FieldLabel/{index.31998491.js → index.9fd6697a.js} +1 -1
  29. package/components/Icon/{index.7c470582.js → index.5cf594aa.js} +2 -2
  30. package/components/LoadingError/{index.42a55f4c.js → index.427a569c.js} +1 -1
  31. package/components/MFLoader/{index.aa7f5a2e.js → index.12ccba1a.js} +1 -1
  32. package/components/ObjectLogs/{index.92ef4170.js → index.a3ed9816.js} +5 -5
  33. package/components/PaperForm/{index.c7495338.js → index.9ed65352.js} +1 -1
  34. package/components/Period/{index.798f8392.js → index.78867b45.js} +1 -1
  35. package/components/PropertyValue/{index.2d2911e8.js → index.4f0da54d.js} +2 -2
  36. package/components/SideBar/{index.6cfca08a.js → index.0298ead4.js} +2 -2
  37. package/components/ToastContainer/{index.18d8fe7c.js → index.e6d48658.js} +1 -1
  38. package/components/areas/components/AreasAdmin/{index.4b10abad.js → index.5af510af.js} +5 -5
  39. package/components/areas/components/AreasViewer/{index.7573f13c.js → index.343f0452.js} +7 -7
  40. package/components/areas/contexts/AreasContext/{index.11779442.js → index.91e1acfc.js} +2 -2
  41. package/components/areas/hooks/useAreas/{index.62f5aa0a.js → index.98ea6788.js} +1 -1
  42. package/components/commercial/TopBar/{index.7c61f79e.js → index.df994f5f.js} +2 -2
  43. package/components/commercial/{index.ecc02533.js → index.73cf794c.js} +2 -2
  44. package/components/formatters/BooleanFormatter/{index.a9d5ac7d.js → index.699e0aee.js} +2 -2
  45. package/components/formatters/{index.7b777849.js → index.8abccc30.js} +1 -1
  46. package/components/hook-form/RHFAutocomplete/{index.e5e8baae.js → index.1efaddc9.js} +2 -2
  47. package/components/hook-form/RHFAutocompleteAsync/{index.5d539214.js → index.2f123535.js} +1 -1
  48. package/components/hook-form/RHFCheckbox/{index.63c87daa.js → index.a9cf6faf.js} +1 -1
  49. package/components/hook-form/RHFColorPicker/{index.9d34e1f3.js → index.963323e4.js} +2 -2
  50. package/components/hook-form/RHFDateTime/{index.64804ca3.js → index.b3d0b2de.js} +2 -2
  51. package/components/hook-form/RHFPeriod/{index.15a61515.js → index.d1f45273.js} +2 -2
  52. package/components/hook-form/RHFTextField/{index.d2af30c0.js → index.97ba17ae.js} +2 -2
  53. package/components/maps/components/GpsTools/{index.6d2dab3c.js → index.0c6dff10.js} +11 -11
  54. package/components/maps/components/Map/{index.2c31ea9e.js → index.50447504.js} +8 -8
  55. package/components/modal/{WindowBase.6bf7201e.js → WindowBase.bf119f28.js} +2 -2
  56. package/components/modal/{WindowConfirm.ca443b26.js → WindowConfirm.b70c4b0f.js} +1 -1
  57. package/components/mui_extended/Accordion/{index.c51c5787.js → index.427d380a.js} +2 -2
  58. package/components/mui_extended/{CheckBox.511980a0.js → CheckBox.84c57702.js} +1 -1
  59. package/components/mui_extended/IconButton/{index.31343834.js → index.ee45bba2.js} +1 -1
  60. package/components/mui_extended/MenuActions/{index.520a26d8.js → index.06aaa091.js} +2 -2
  61. package/components/mui_extended/Pager/{index.225cd67f.js → index.c77a7694.js} +2 -2
  62. package/components/mui_extended/ToggleIconButton/{index.27848408.js → index.50ce11e4.js} +1 -1
  63. package/components/popups/PopupsProvider/{index.13be398e.js → index.7ed83556.js} +1 -1
  64. package/components/popups/PopupsViewer/{index.31407dfb.js → index.9b734a0a.js} +4 -4
  65. package/hooks/useFormAddEdit/{index.ab256ea9.js → index.3468c18c.js} +1 -1
  66. package/index.js +65 -54
  67. package/package.json +1 -1
  68. package/components/DynamicFilter/helpers/index.a13deed7.js +0 -557
  69. package/components/DynamicFilter/subcomponents/index.e32811b5.js +0 -788
@@ -0,0 +1,169 @@
1
+ import * as Yup from "yup";
2
+ import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.80fc7baf.js";
3
+ import { a as DATE_TIME_OPERATORS } from "../../../constants.095f1dbb.js";
4
+ import { jsxs, jsx } from "react/jsx-runtime";
5
+ import { useMemo } from "react";
6
+ import { useFormContext, useWatch } from "react-hook-form";
7
+ import { useModuleDictionary } from "@m4l/core";
8
+ import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/index.1efaddc9.js";
9
+ import { R as RHFDateTime } from "../../../../hook-form/RHFDateTime/index.b3d0b2de.js";
10
+ import { i as isValidDate } from "../../../../../utils/index.14912462.js";
11
+ function DateTimeFilter() {
12
+ const { getLabel } = useModuleDictionary();
13
+ const { control } = useFormContext();
14
+ const operator = useWatch({
15
+ control,
16
+ name: "formValueOperator"
17
+ });
18
+ const operators = useMemo(
19
+ () => DATE_TIME_OPERATORS.map((o) => ({
20
+ id: o,
21
+ label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
22
+ })),
23
+ [getLabel]
24
+ );
25
+ return /* @__PURE__ */ jsxs("div", { children: [
26
+ /* @__PURE__ */ jsx(
27
+ RHFAutocomplete,
28
+ {
29
+ name: "formValueOperator",
30
+ autoComplete: "off",
31
+ options: operators,
32
+ getOptionLabel: (option) => option.label,
33
+ isOptionEqualToValue: (option, value) => option.id === value.id,
34
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_date_time))
35
+ }
36
+ ),
37
+ /* @__PURE__ */ jsx(
38
+ RHFDateTime,
39
+ {
40
+ name: "formValueOperand1",
41
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_date_time))
42
+ }
43
+ ),
44
+ operator && operator.id === "b" && /* @__PURE__ */ jsx(
45
+ RHFDateTime,
46
+ {
47
+ name: "formValueOperand2",
48
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_date_time))
49
+ }
50
+ )
51
+ ] });
52
+ }
53
+ class DateTimeFilterHelpers {
54
+ getComponent() {
55
+ return DateTimeFilter;
56
+ }
57
+ getDefaultFilter(field, fixed) {
58
+ const defaultStartDate = new Date();
59
+ const defaultEndDate = new Date();
60
+ defaultStartDate.setHours(0, 0, 0, 0);
61
+ defaultEndDate.setHours(23, 59, 59, 999);
62
+ const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
63
+ const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
64
+ return {
65
+ id: 0,
66
+ fieldType: "datetime",
67
+ field,
68
+ fixed,
69
+ isSet: true,
70
+ operator: "b",
71
+ operand1: defaultOperand1,
72
+ operand2: defaultOperand2
73
+ };
74
+ }
75
+ getFormValue(field, getLabel, filterValueDateTime) {
76
+ const filterValue = filterValueDateTime;
77
+ const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "b";
78
+ const defaultStartDate = new Date();
79
+ const defaultEndDate = new Date();
80
+ const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
81
+ const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
82
+ const formValueOperand1 = filterValue ? filterValue.operand1 : defaultOperand1;
83
+ const formValueOperand2 = filterValue && filterValue.operator === "b" ? filterValue.operand2 : defaultOperand2;
84
+ return {
85
+ fieldType: "datetime",
86
+ formValueOperator: {
87
+ id: operator,
88
+ label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
89
+ },
90
+ formValueOperand1,
91
+ formValueOperand2
92
+ };
93
+ }
94
+ getFilterFromFormValue(formFilterValue) {
95
+ const operator = formFilterValue.formValueOperator.id;
96
+ const operand1 = formFilterValue.formValueOperand1;
97
+ if (operator === "b") {
98
+ const operand2 = formFilterValue.formValueOperand2;
99
+ return {
100
+ fieldType: "datetime",
101
+ operator,
102
+ operand1,
103
+ operand2
104
+ };
105
+ } else {
106
+ return {
107
+ fieldType: "datetime",
108
+ operator,
109
+ operand1
110
+ };
111
+ }
112
+ }
113
+ getLabels(filter, getLabel, formatters, _field) {
114
+ const { dateFormatter } = formatters;
115
+ let labelOperands;
116
+ if (filter.operator === "b") {
117
+ labelOperands = filter.operand1 && filter.operand2 ? `${dateFormatter.formatDate(
118
+ filter.operand1,
119
+ dateFormatter.datetimeFormat
120
+ )} - ${dateFormatter.formatDate(filter.operand2, dateFormatter.datetimeFormat)}` : "";
121
+ } else {
122
+ labelOperands = filter.operand1 ? dateFormatter.formatDate(filter.operand1, dateFormatter.datetimeFormat) : "";
123
+ }
124
+ return {
125
+ labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
126
+ labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
127
+ labelOperands
128
+ };
129
+ }
130
+ getSchema(getLabel) {
131
+ return Yup.object({
132
+ formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
133
+ formValueOperand1: Yup.date().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))),
134
+ formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
135
+ is: "b",
136
+ then: Yup.date().typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).min(
137
+ Yup.ref("formValueOperand1"),
138
+ getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))
139
+ )
140
+ })
141
+ });
142
+ }
143
+ verifyFilter(filter, _field) {
144
+ if (typeof filter.operator !== "string") {
145
+ return false;
146
+ }
147
+ if (DATE_TIME_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
148
+ return false;
149
+ }
150
+ if (typeof filter.operand1 !== "string") {
151
+ return false;
152
+ }
153
+ if (!isValidDate(new Date(filter.operand1))) {
154
+ return false;
155
+ }
156
+ if (filter.operator === "b") {
157
+ if (typeof filter.operand2 !== "string") {
158
+ return false;
159
+ }
160
+ if (!isValidDate(new Date(filter.operand1))) {
161
+ return false;
162
+ }
163
+ }
164
+ return true;
165
+ }
166
+ }
167
+ export {
168
+ DateTimeFilterHelpers as D
169
+ };
@@ -0,0 +1,151 @@
1
+ import * as Yup from "yup";
2
+ import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.80fc7baf.js";
3
+ import { jsxs, jsx } from "react/jsx-runtime";
4
+ import { useMemo } from "react";
5
+ import { useFormContext, useWatch } from "react-hook-form";
6
+ import { useModuleDictionary } from "@m4l/core";
7
+ import { N as NUMBER_OPERATORS } from "../../../constants.095f1dbb.js";
8
+ import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/index.1efaddc9.js";
9
+ import { R as RHFTextField } from "../../../../hook-form/RHFTextField/index.97ba17ae.js";
10
+ function NumberFilter() {
11
+ const { getLabel } = useModuleDictionary();
12
+ const { control } = useFormContext();
13
+ const operator = useWatch({
14
+ control,
15
+ name: "formValueOperator"
16
+ });
17
+ const operators = useMemo(
18
+ () => NUMBER_OPERATORS.map((o) => ({
19
+ id: o,
20
+ label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
21
+ })),
22
+ [getLabel]
23
+ );
24
+ return /* @__PURE__ */ jsxs("div", { children: [
25
+ /* @__PURE__ */ jsx(
26
+ RHFAutocomplete,
27
+ {
28
+ name: "formValueOperator",
29
+ autoComplete: "off",
30
+ options: operators,
31
+ getOptionLabel: (option) => option.label,
32
+ isOptionEqualToValue: (option, value) => option.id === value.id,
33
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_number))
34
+ }
35
+ ),
36
+ /* @__PURE__ */ jsx(
37
+ RHFTextField,
38
+ {
39
+ name: "formValueOperand1",
40
+ type: "number",
41
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_number))
42
+ }
43
+ ),
44
+ operator && operator.id === "b" && /* @__PURE__ */ jsx(
45
+ RHFTextField,
46
+ {
47
+ name: "formValueOperand2",
48
+ type: "number",
49
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_number))
50
+ }
51
+ )
52
+ ] });
53
+ }
54
+ class NumberFilterHelpers {
55
+ getComponent() {
56
+ return NumberFilter;
57
+ }
58
+ getDefaultFilter(fieldNumber, fixed) {
59
+ const field = fieldNumber;
60
+ const dOperator = field.defaultOperator ?? "e";
61
+ const defaultOperand1 = field.defaultOperand1 ?? null;
62
+ const defaultOperand2 = field.defaultOperand2 ?? null;
63
+ return {
64
+ id: 0,
65
+ fieldType: "number",
66
+ field,
67
+ fixed,
68
+ isSet: false,
69
+ operator: dOperator,
70
+ operand1: defaultOperand1,
71
+ operand2: defaultOperand2
72
+ };
73
+ }
74
+ getFormValue(field, getLabel, filterValue) {
75
+ const filterValueNumber = filterValue;
76
+ const operator = filterValueNumber ? filterValueNumber.operator : field.defaultOperator ?? "e";
77
+ const formValueOperand1 = filterValueNumber ? filterValueNumber.operand1 : null;
78
+ const formValueOperand2 = filterValueNumber && filterValueNumber?.operator === "b" ? filterValueNumber.operand2 : null;
79
+ return {
80
+ fieldType: "number",
81
+ formValueOperator: {
82
+ id: operator,
83
+ label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
84
+ },
85
+ formValueOperand1,
86
+ formValueOperand2
87
+ };
88
+ }
89
+ getFilterFromFormValue(formFilterValue) {
90
+ const operator = formFilterValue.formValueOperator.id;
91
+ const operand1 = formFilterValue.formValueOperand1 ? formFilterValue.formValueOperand1 : 0;
92
+ if (operator === "b") {
93
+ const operand2 = formFilterValue.formValueOperand2 ? formFilterValue.formValueOperand2 : 0;
94
+ return {
95
+ fieldType: "number",
96
+ operator,
97
+ operand1,
98
+ operand2
99
+ };
100
+ } else {
101
+ return {
102
+ fieldType: "number",
103
+ operator,
104
+ operand1
105
+ };
106
+ }
107
+ }
108
+ getLabels(filter, getLabel, _formatters, _field) {
109
+ let labelOperands;
110
+ if (filter.operator === "b") {
111
+ labelOperands = filter.operand1 && filter.operand2 ? `${filter.operand1} - ${filter.operand2}` : "";
112
+ } else {
113
+ labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
114
+ }
115
+ return {
116
+ labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
117
+ labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
118
+ labelOperands
119
+ };
120
+ }
121
+ getSchema(getLabel) {
122
+ return Yup.object({
123
+ formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
124
+ formValueOperand1: Yup.number().typeError(
125
+ getLabel(`dynamic_filter.error_operand_mustbe_number`)
126
+ ),
127
+ formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
128
+ is: "b",
129
+ then: Yup.number().typeError(getLabel(`dynamic_filter.error_operand_mustbe_number`)).min(Yup.ref("formValueOperand1"), getLabel(`dynamic_filter.error_less_than_start`))
130
+ })
131
+ });
132
+ }
133
+ verifyFilter(filter, _field) {
134
+ if (typeof filter.operator !== "number") {
135
+ return false;
136
+ }
137
+ if (NUMBER_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
138
+ return false;
139
+ }
140
+ if (typeof filter.operand1 !== "number") {
141
+ return false;
142
+ }
143
+ if (filter.operator === "b" && typeof filter.operand2 !== "number") {
144
+ return false;
145
+ }
146
+ return true;
147
+ }
148
+ }
149
+ export {
150
+ NumberFilterHelpers as N
151
+ };
@@ -0,0 +1,145 @@
1
+ import * as Yup from "yup";
2
+ import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.80fc7baf.js";
3
+ import { jsxs, jsx } from "react/jsx-runtime";
4
+ import { useMemo } from "react";
5
+ import { useModuleDictionary } from "@m4l/core";
6
+ import { S as SELECT_OPERATORS } from "../../../constants.095f1dbb.js";
7
+ import { u as useDynamicFilterStore } from "../../../store/index.b9c2fe0b.js";
8
+ import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/index.1efaddc9.js";
9
+ import { R as RHFAutocompleteAsync } from "../../../../hook-form/RHFAutocompleteAsync/index.2f123535.js";
10
+ function SelectFilter() {
11
+ const { getLabel } = useModuleDictionary();
12
+ const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
13
+ if (!field?.selectOptions?.endPoint) {
14
+ throw new Error("El filtro tipo Select requiere la configuraci\xF3n del Endpoint");
15
+ }
16
+ const autocompleteProps = field?.selectOptions;
17
+ const operators = useMemo(
18
+ () => SELECT_OPERATORS.map((o) => ({
19
+ id: o,
20
+ label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
21
+ })),
22
+ [getLabel]
23
+ );
24
+ return /* @__PURE__ */ jsxs("div", { children: [
25
+ /* @__PURE__ */ jsx(
26
+ RHFAutocomplete,
27
+ {
28
+ name: "formValueOperator",
29
+ autoComplete: "off",
30
+ options: operators,
31
+ getOptionLabel: (option) => option.label,
32
+ isOptionEqualToValue: (option, value) => option.id === value.id,
33
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operator))
34
+ }
35
+ ),
36
+ /* @__PURE__ */ jsx(
37
+ RHFAutocompleteAsync,
38
+ {
39
+ ...autocompleteProps,
40
+ name: "formValueOperandsArray",
41
+ autoComplete: "off",
42
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operands_array))
43
+ }
44
+ )
45
+ ] });
46
+ }
47
+ function filterValidOperandsArraySelect(operandsArray, field) {
48
+ const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
49
+ const getOptionId = field?.selectOptions?.getOptionId;
50
+ const getOptionLabel = field?.selectOptions?.getOptionLabel;
51
+ return operandsArrayFormatted?.filter((operand) => {
52
+ return typeof operand === "object" && getOptionId?.(operand) && getOptionLabel?.(operand);
53
+ });
54
+ }
55
+ class SelectFilterHelpers {
56
+ getComponent() {
57
+ return SelectFilter;
58
+ }
59
+ getDefaultFilter(field, fixed) {
60
+ const defaultOperand = field.defaultOperandsArray;
61
+ const defaultFilter = {
62
+ id: 0,
63
+ fieldType: "select",
64
+ field,
65
+ fixed,
66
+ isSet: true,
67
+ operator: "in",
68
+ operandsArray: []
69
+ };
70
+ if (defaultOperand !== void 0 && Array.isArray(defaultOperand)) {
71
+ const validOperandsArray = filterValidOperandsArraySelect(defaultOperand, field);
72
+ defaultFilter.operandsArray = validOperandsArray || [];
73
+ }
74
+ return defaultFilter;
75
+ }
76
+ getFormValue(field, getLabel, filterValueSelect) {
77
+ const filterValue = filterValueSelect ? filterValueSelect : void 0;
78
+ const isMultiple = field?.selectOptions?.multiple ?? false;
79
+ const formValueOperandsArray = isMultiple ? filterValueSelect?.operandsArray : filterValueSelect?.operandsArray?.[0] || filterValueSelect?.operandsArray;
80
+ const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
81
+ return {
82
+ fieldType: "select",
83
+ formValueOperator: {
84
+ id: operator,
85
+ label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
86
+ },
87
+ formValueOperandsArray
88
+ };
89
+ }
90
+ getFilterFromFormValue(formFilterValue) {
91
+ const operator = formFilterValue.formValueOperator.id;
92
+ const operandsArray = Array.isArray(formFilterValue.formValueOperandsArray) ? formFilterValue.formValueOperandsArray : [formFilterValue.formValueOperandsArray];
93
+ return {
94
+ fieldType: "select",
95
+ operator,
96
+ operandsArray
97
+ };
98
+ }
99
+ getLabels(filter, getLabel, _formatters, field) {
100
+ const operandsArray = filter.operandsArray;
101
+ const labelOperands = operandsArray?.reduce?.((label, operand) => {
102
+ const textLabel = field.selectOptions?.getOptionLabel?.(operand) || "";
103
+ return label ? `${label} | ${textLabel}` : textLabel;
104
+ }, "")?.toString() || "";
105
+ return {
106
+ labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
107
+ labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
108
+ labelOperands
109
+ };
110
+ }
111
+ getSchema(getLabel) {
112
+ return Yup.object({
113
+ formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
114
+ formValueOperandsArray: Yup.lazy((value) => {
115
+ return Array.isArray(value) ? Yup.array().min(1, getLabel(`dynamic_filter.error_operand_required`)).of(Yup.object().nullable()).required(getLabel(`dynamic_filter.error_operand_required`)) : Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`));
116
+ })
117
+ });
118
+ }
119
+ verifyFilter(filter, field) {
120
+ if (typeof filter.operator !== "string") {
121
+ return false;
122
+ }
123
+ if (!field) {
124
+ return false;
125
+ }
126
+ if (SELECT_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
127
+ return false;
128
+ }
129
+ if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
130
+ return false;
131
+ }
132
+ const validOperandsArray = filterValidOperandsArraySelect(
133
+ filter.operandsArray,
134
+ field
135
+ );
136
+ if (!validOperandsArray || validOperandsArray?.length === 0) {
137
+ return false;
138
+ }
139
+ return true;
140
+ }
141
+ }
142
+ export {
143
+ SelectFilterHelpers as S,
144
+ filterValidOperandsArraySelect as f
145
+ };
@@ -0,0 +1,112 @@
1
+ import * as Yup from "yup";
2
+ import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.80fc7baf.js";
3
+ import { b as STRING_OPERATORS } from "../../../constants.095f1dbb.js";
4
+ import { jsxs, jsx } from "react/jsx-runtime";
5
+ import { useMemo } from "react";
6
+ import { useModuleDictionary } from "@m4l/core";
7
+ import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/index.1efaddc9.js";
8
+ import { R as RHFTextField } from "../../../../hook-form/RHFTextField/index.97ba17ae.js";
9
+ function StringFilter() {
10
+ const { getLabel } = useModuleDictionary();
11
+ const operators = useMemo(
12
+ () => STRING_OPERATORS.map((o) => ({
13
+ id: o,
14
+ label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
15
+ })),
16
+ [getLabel]
17
+ );
18
+ return /* @__PURE__ */ jsxs("div", { children: [
19
+ /* @__PURE__ */ jsx(
20
+ RHFAutocomplete,
21
+ {
22
+ name: "formValueOperator",
23
+ autoComplete: "off",
24
+ options: operators,
25
+ getOptionLabel: (option) => option.label,
26
+ isOptionEqualToValue: (option, value) => option.id === value.id,
27
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_string))
28
+ }
29
+ ),
30
+ /* @__PURE__ */ jsx(
31
+ RHFTextField,
32
+ {
33
+ name: "formValueOperand1",
34
+ label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_string))
35
+ }
36
+ )
37
+ ] });
38
+ }
39
+ class StringFilterHelpers {
40
+ getComponent() {
41
+ return StringFilter;
42
+ }
43
+ getDefaultFilter(field, fixed) {
44
+ const defaultOperand1 = field.defaultOperand1;
45
+ const defaultFilter = {
46
+ id: 0,
47
+ fieldType: "string",
48
+ field,
49
+ fixed,
50
+ isSet: false,
51
+ operator: "c",
52
+ operand1: ""
53
+ };
54
+ if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "string") {
55
+ defaultFilter.operand1 = defaultOperand1;
56
+ }
57
+ return defaultFilter;
58
+ }
59
+ getFilterFromFormValue(formFilterValue) {
60
+ const operator = formFilterValue.formValueOperator.id;
61
+ const operand1 = formFilterValue.formValueOperand1;
62
+ return {
63
+ fieldType: "string",
64
+ operator,
65
+ operand1
66
+ };
67
+ }
68
+ getFormValue(field, getLabel, filterValue) {
69
+ const filterValueString = filterValue;
70
+ const operator = filterValueString ? filterValueString.operator : field.defaultOperator ?? "c";
71
+ const formValueOperand1 = filterValueString ? filterValueString.operand1 : "";
72
+ return {
73
+ fieldType: "string",
74
+ formValueOperator: {
75
+ id: operator,
76
+ label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
77
+ },
78
+ formValueOperand1
79
+ };
80
+ }
81
+ getLabels(filter, getLabel, _formatters, _field) {
82
+ const labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
83
+ return {
84
+ labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
85
+ labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
86
+ labelOperands
87
+ };
88
+ }
89
+ getSchema(getLabel) {
90
+ return Yup.object({
91
+ formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
92
+ formValueOperand1: Yup.string().required(
93
+ getLabel(getDynamicFilterDictionary(DICCTIONARY.error_operand_required))
94
+ )
95
+ });
96
+ }
97
+ verifyFilter(filter, _field) {
98
+ if (typeof filter.operator !== "string") {
99
+ return false;
100
+ }
101
+ if (STRING_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
102
+ return false;
103
+ }
104
+ if (typeof filter.operand1 !== "string") {
105
+ return false;
106
+ }
107
+ return true;
108
+ }
109
+ }
110
+ export {
111
+ StringFilterHelpers as S
112
+ };
@@ -0,0 +1,38 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { useFormContext } from "react-hook-form";
4
+ import { B as BooleanFilterHelpers } from "./BooleanFilter/index.f926af49.js";
5
+ import { S as StringFilterHelpers } from "./StringFilter/index.82ca3e32.js";
6
+ import { D as DateTimeFilterHelpers } from "./DateTimeFilter/index.2382297a.js";
7
+ import { N as NumberFilterHelpers } from "./NumberFilter/index.7b4dccf7.js";
8
+ import { S as SelectFilterHelpers } from "./SelectFilter/index.2258fceb.js";
9
+ const helpersStrategies = {
10
+ boolean: new BooleanFilterHelpers(),
11
+ string: new StringFilterHelpers(),
12
+ number: new NumberFilterHelpers(),
13
+ datetime: new DateTimeFilterHelpers(),
14
+ select: new SelectFilterHelpers(),
15
+ __default__: () => {
16
+ throw new Error("Type no defined");
17
+ }
18
+ };
19
+ function fieldFactory(type) {
20
+ const selectedHelper = helpersStrategies?.[type];
21
+ if (!selectedHelper) {
22
+ return helpersStrategies.__default__();
23
+ }
24
+ return selectedHelper;
25
+ }
26
+ function DataTypeComponent(props) {
27
+ const { formFilter, statusLoad } = props;
28
+ const { setFocus } = useFormContext();
29
+ const Component = fieldFactory(formFilter.field.type).getComponent();
30
+ useEffect(() => {
31
+ setTimeout(() => setFocus("formValueOperand1"), 100);
32
+ }, [statusLoad]);
33
+ return /* @__PURE__ */ jsx(Component, {});
34
+ }
35
+ export {
36
+ DataTypeComponent as D,
37
+ fieldFactory as f
38
+ };