@m4l/components 9.2.49 → 9.2.50-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/@types/types.d.ts +8 -1
  2. package/components/Chip/ChipStyles.js +1 -1
  3. package/components/DataGrid/contexts/DataGridContext/index.js +1 -1
  4. package/components/DataGrid/contexts/FilterContext/index.js +1 -1
  5. package/components/DataGrid/dictionary.js +0 -3
  6. package/components/DataGrid/formatters/ColumnChipStatusFormatter/formatter.js +4 -3
  7. package/components/DataGrid/formatters/ColumnNestedValueFormatter/formatter.js +2 -1
  8. package/components/DataGrid/formatters/ColumnNestedValueFormatter/useColumnNestedValue.d.ts +1 -1
  9. package/components/DataGrid/formatters/ColumnNestedValueFormatter/useColumnNestedValue.js +4 -3
  10. package/components/DataGrid/slots/DataGridEnum.js +2 -2
  11. package/components/DataGrid/slots/DataGridSlot.js +1 -1
  12. package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +2 -0
  13. package/components/DataGrid/subcomponents/Table/subcomponents/CheckboxFormatter.js +1 -1
  14. package/components/DataGrid/subcomponents/Table/subcomponents/CustomIcons.js +2 -2
  15. package/components/DragResizeWindowRND/DragResizeWindowRND.js +0 -1
  16. package/components/DynamicFilter/DynamicFilter.styles.js +0 -1
  17. package/components/DynamicFilter/constants.d.ts +5 -2
  18. package/components/DynamicFilter/constants.js +9 -3
  19. package/components/DynamicFilter/dictionary.d.ts +40 -38
  20. package/components/DynamicFilter/dictionary.js +33 -39
  21. package/components/DynamicFilter/helpers/formatToInitialFilters.d.ts +3 -1
  22. package/components/DynamicFilter/helpers/formatToInitialFilters.js +30 -20
  23. package/components/DynamicFilter/helpers/formatToRowFilter.js +15 -6
  24. package/components/DynamicFilter/helpers/getPurgedInitialFiltersApplied.js +1 -1
  25. package/components/DynamicFilter/store/DynamicFilterContext.js +1 -1
  26. package/components/DynamicFilter/subcomponents/AppliedFilterChip/AppliedFilterChip.d.ts +1 -1
  27. package/components/DynamicFilter/subcomponents/AppliedFilterChip/AppliedFilterChip.js +4 -3
  28. package/components/DynamicFilter/subcomponents/AppliedFilters/useAppliedFilters.js +10 -3
  29. package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.js +1 -1
  30. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +7 -7
  31. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.js +11 -8
  32. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +7 -7
  33. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index.js +10 -7
  34. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +17 -9
  35. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index.js +13 -9
  36. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.d.ts +7 -7
  37. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +121 -46
  38. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/index.js +13 -11
  39. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.d.ts +8 -7
  40. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +127 -46
  41. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index.js +11 -9
  42. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +11 -7
  43. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index.js +10 -7
  44. package/components/DynamicFilter/subcomponents/FieldTypes/fieldFactory.d.ts +1 -1
  45. package/components/DynamicFilter/subcomponents/FilterActions/FilterActions.js +2 -1
  46. package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.d.ts +1 -1
  47. package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.js +2 -4
  48. package/components/DynamicFilter/subcomponents/InputFilter/useInputFilter.js +2 -2
  49. package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.js +28 -14
  50. package/components/DynamicFilter/types.d.ts +60 -18
  51. package/components/DynamicSort/dictionary.d.ts +1 -0
  52. package/components/DynamicSort/dictionary.js +1 -5
  53. package/components/DynamicSort/slots/DynamicSortSlots.js +1 -1
  54. package/components/DynamicSort/store/DynamicSortContext.js +1 -1
  55. package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +1 -1
  56. package/components/DynamicSort/subcomponents/PopoverMenuFields/PopoverMenuFields.js +28 -14
  57. package/components/GridLayout/GridLayout.js +1 -1
  58. package/components/GridLayout/styles.js +1 -1
  59. package/components/GridLayout/subcomponents/GridItem/index.js +1 -1
  60. package/components/GridLayout/subcomponents/Responsive/helper.js +1 -1
  61. package/components/GridLayout/subcomponents/Responsive/index.js +1 -1
  62. package/components/GridLayout/subcomponents/Responsive/responsiveUtils.js +3 -3
  63. package/components/GridLayout/subcomponents/withSizeProvider/index.js +1 -1
  64. package/components/Icon/Icon.js +1 -1
  65. package/components/Icon/constants.js +2 -2
  66. package/components/Icon/slots/IconSlots.js +1 -1
  67. package/components/Image/Image.js +1 -1
  68. package/components/Image/constant.js +2 -2
  69. package/components/Image/slots/ImageSlots.js +1 -1
  70. package/components/Image/subcomponents/IntersectComponent/index.js +1 -1
  71. package/components/LanguagePopover/LanguagePopover.js +1 -1
  72. package/components/LoadingError/LoadingError.js +1 -1
  73. package/components/LoadingError/slots/LoadingErrorSlots.js +1 -1
  74. package/components/MFIsolationApp/MFIsolationApp.js +2 -2
  75. package/components/MFIsolationApp/subcomponents/MFAuthApp/MFAuthApp.js +1 -1
  76. package/components/NoItemSelected/NoItemSelected.js +1 -1
  77. package/components/NumberInput/hooks/useNumberInput/NumberInputReducer.js +1 -1
  78. package/components/NumberInput/hooks/useNumberInput/useNumberInput.js +5 -3
  79. package/components/ObjectLogs/dictionary.js +1 -1
  80. package/components/Pager/Pager.styles.js +0 -8
  81. package/components/Pager/dicctionary.js +0 -5
  82. package/components/PrintingSystem/subcomponents/ChartNode/index.js +1 -1
  83. package/components/PropertyValue/PropertyValue.js +3 -3
  84. package/components/PropertyValue/PropertyValue.styles.js +4 -2
  85. package/components/PropertyValue/index.d.ts +1 -0
  86. package/components/PropertyValue/types.d.ts +0 -2
  87. package/components/ScrollBar/ScrollBar.js +1 -1
  88. package/components/SideBar/slots/SideBarEnum.js +4 -4
  89. package/components/SideBar/slots/SideBarSlots.js +1 -1
  90. package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/styles.js +1 -1
  91. package/components/ToastContainer/ToastContainer.js +1 -1
  92. package/components/WindowBase/slots/WindowBaseSlots.js +1 -1
  93. package/components/animate/variants/bounce.js +1 -1
  94. package/components/animate/variants/fade.js +1 -1
  95. package/components/animate/variants/transition.js +2 -2
  96. package/components/areas/components/AreasAdmin/AreasAdmin.js +1 -1
  97. package/components/areas/components/AreasViewer/AreasViewer.js +1 -1
  98. package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/AreaGridLayout/AreaGridLayout.js +1 -1
  99. package/components/areas/contexts/AreasContext/helpers/helper.js +14 -14
  100. package/components/areas/contexts/AreasContext/store.js +5 -5
  101. package/components/areas/icons.js +0 -8
  102. package/components/commercial/HamburgerMenu/classes/index.js +1 -1
  103. package/components/extended/React-Splitter-Layout/slots/SplitLayoutSlots.d.ts +9 -3
  104. package/components/extended/React-resizable-panels/SplitLayout.js +25 -5
  105. package/components/extended/React-resizable-panels/SplitLayout.styles.js +20 -6
  106. package/components/extended/React-resizable-panels/slots/SplitLayoutSlots.d.ts +12 -4
  107. package/components/extended/React-resizable-panels/types.d.ts +7 -0
  108. package/components/formatters/BooleanFormatter/BooleanFormatter.js +1 -1
  109. package/components/formatters/BooleanFormatter/slots/BooleanFormatterSlots.js +3 -3
  110. package/components/formatters/PeriodFormatter/PeriodFormatter.js +1 -1
  111. package/components/formatters/PeriodFormatter/slots/PeriodFormatterSlots.js +2 -2
  112. package/components/hook-form/RHFCheckbox/slots/RHFCheckBoxSlots.js +1 -1
  113. package/components/hook-form/RHFNumberInput/index.d.ts +1 -0
  114. package/components/hook-form/RHFNumberInput/index.js +1 -0
  115. package/components/hook-form/RHFPeriod/RHFPeriod.js +1 -1
  116. package/components/hook-form/RHFTextField/RHFTextField.styles.js +1 -3
  117. package/components/hook-form/RHFTextFieldPassword/slots/RHFTextFieldPasswordSlots.js +1 -1
  118. package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js +1 -1
  119. package/components/hook-form/RHFormContext/classes/index.js +1 -1
  120. package/components/hook-form/RHFormContext/index.js +1 -1
  121. package/components/hook-form/index.d.ts +1 -1
  122. package/components/index.d.ts +1 -1
  123. package/components/mui_extended/Accordion/Accordion.js +1 -1
  124. package/components/mui_extended/Accordion/slots/AccordionSlots.js +2 -2
  125. package/components/mui_extended/Accordion/styles.js +1 -0
  126. package/components/mui_extended/Autocomplete/Autocomplete.js +25 -12
  127. package/components/mui_extended/Autocomplete/Autocomplete.styles.js +1 -1
  128. package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +3 -3
  129. package/components/mui_extended/CheckBox/CheckBox.js +1 -1
  130. package/components/mui_extended/CheckBox/slots/CheckBoxSlots.js +2 -2
  131. package/components/mui_extended/DateTimePicker/slots/DateTimePickerSlots.js +1 -1
  132. package/components/mui_extended/IconButton/slots/IconButtonSlots.js +1 -1
  133. package/components/mui_extended/ImageButton/utils/Clases/index.js +1 -1
  134. package/components/mui_extended/MenuItem/slots/MenuItemSlots.js +1 -1
  135. package/components/mui_extended/NavLink/NavLink.js +1 -1
  136. package/components/mui_extended/NavLink/constants.js +2 -2
  137. package/components/mui_extended/NavLink/slots/NavLinkSlots.js +1 -1
  138. package/components/mui_extended/Popover/Popover.js +1 -1
  139. package/components/mui_extended/Popover/Popover.styles.js +1 -5
  140. package/components/mui_extended/Popover/constants.js +2 -2
  141. package/components/mui_extended/Select/Select.js +1 -1
  142. package/components/mui_extended/Select/Select.styles.js +1 -1
  143. package/components/mui_extended/Select/constants.js +1 -1
  144. package/components/mui_extended/Select/slots/SelectSlots.js +1 -1
  145. package/components/mui_extended/Tab/Tab.js +1 -1
  146. package/components/mui_extended/TabContent/TabContent.styles.js +2 -1
  147. package/components/mui_extended/TextField/constants.js +1 -1
  148. package/components/mui_extended/Tooltip/Tooltip.js +2 -2
  149. package/components/mui_extended/Tooltip/slots/TooltipSlots.js +2 -2
  150. package/components/mui_extended/Typography/Typography.js +1 -1
  151. package/components/mui_extended/Typography/constants.js +3 -3
  152. package/components/mui_extended/Typography/slots/typographySlots.js +1 -1
  153. package/components/popups/components/PopupsViewer/icons.js +0 -1
  154. package/hooks/useDataGridPersistence/constants.js +2 -2
  155. package/hooks/useDataGridPersistence/useDataGridPersistence.js +1 -1
  156. package/hooks/useDynamicFilterAndSort/styles.js +2 -0
  157. package/hooks/useDynamicFilterAndSort/types.d.ts +1 -0
  158. package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js +56 -12
  159. package/hooks/useSvgColor/constants.js +2 -2
  160. package/hooks/useSvgColor/helpers.js +1 -1
  161. package/hooks/useSvgColor/useSvgColor.js +1 -1
  162. package/index.js +109 -109
  163. package/package.json +3 -3
  164. package/components/PropertyValue/styles.d.ts +0 -1
@@ -1,7 +1,7 @@
1
1
  import * as Yup from "yup";
2
2
  import { B as BOOLEAN_OPERATORS } from "../../../constants.js";
3
- import { g as getDynamicFilterDictionary } from "../../../dictionary.js";
4
3
  import { B as BooleanFilter } from "./index.js";
4
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
5
5
  class BooleanFilterHelpers {
6
6
  getComponent() {
7
7
  return BooleanFilter;
@@ -45,13 +45,13 @@ class BooleanFilterHelpers {
45
45
  const operator = filterValueBoolean ? filterValueBoolean.operator : field.defaultOperator ?? "e";
46
46
  const formValueOperand1 = filterValueBoolean ? {
47
47
  value: filterValueBoolean.operand1,
48
- label: getLabel(getDynamicFilterDictionary(`operand_${filterValueBoolean.operand1}`))
48
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operand_${filterValueBoolean.operand1}`)
49
49
  } : null;
50
50
  return {
51
51
  fieldType: "boolean",
52
52
  formValueOperator: {
53
53
  id: operator,
54
- label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
54
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${operator}`)
55
55
  },
56
56
  formValueOperand1
57
57
  };
@@ -60,10 +60,10 @@ class BooleanFilterHelpers {
60
60
  * getLabel devuelve las etiquetas para el filtro booleano.
61
61
  */
62
62
  getLabels(filter, getLabel, _formatters, _field) {
63
- const labelOperands = filter.operand1 ? getLabel(getDynamicFilterDictionary("operand_true")) : getLabel(getDynamicFilterDictionary("operand_false"));
63
+ const labelOperands = filter.operand1 ? getLabel(DICCTIONARY.operand_true) : getLabel(DICCTIONARY.operand_false);
64
64
  return {
65
65
  labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
66
- labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
66
+ labelOperator: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`),
67
67
  labelOperands
68
68
  };
69
69
  }
@@ -72,8 +72,8 @@ class BooleanFilterHelpers {
72
72
  */
73
73
  getSchema(getLabel) {
74
74
  return Yup.object({
75
- formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
76
- formValueOperand1: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`))
75
+ formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
76
+ formValueOperand1: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operand_required))
77
77
  });
78
78
  }
79
79
  /**
@@ -2,26 +2,29 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useModuleDictionary } from "@m4l/core";
3
3
  import { useMemo } from "react";
4
4
  import { B as BOOLEAN_OPERATORS } from "../../../constants.js";
5
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
5
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
6
+ import { u as useDynamicFilterStore } from "../../../store/useDynamicFilterStore.js";
6
7
  import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
7
8
  function BooleanFilter() {
8
9
  const { getLabel } = useModuleDictionary();
10
+ const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
11
+ const restritcOperatorsTo = field?.restritcOperatorsTo;
9
12
  const operators = useMemo(
10
13
  () => BOOLEAN_OPERATORS.map((o) => ({
11
14
  id: o,
12
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
13
- })),
14
- [getLabel]
15
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${o}`)
16
+ })).filter((o) => restritcOperatorsTo ? restritcOperatorsTo.includes(o.id) : true),
17
+ [getLabel, restritcOperatorsTo]
15
18
  );
16
19
  const optionsYesNo = useMemo(
17
20
  () => [
18
21
  {
19
22
  value: true,
20
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.operand_true))
23
+ label: getLabel(DICCTIONARY.operand_true)
21
24
  },
22
25
  {
23
26
  value: false,
24
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.operand_false))
27
+ label: getLabel(DICCTIONARY.operand_false)
25
28
  }
26
29
  ],
27
30
  [getLabel]
@@ -36,7 +39,7 @@ function BooleanFilter() {
36
39
  options: operators,
37
40
  getOptionLabel: (option) => option.label,
38
41
  isOptionEqualToValue: (option, value) => option.id === value.id,
39
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_boolean_operator))
42
+ label: getLabel(DICCTIONARY.label_boolean_operator)
40
43
  }
41
44
  ),
42
45
  /* @__PURE__ */ jsx(
@@ -48,7 +51,7 @@ function BooleanFilter() {
48
51
  options: optionsYesNo,
49
52
  getOptionLabel: (option) => option.label,
50
53
  isOptionEqualToValue: (option, value) => option.value === value.value,
51
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_boolean_operand1))
54
+ label: getLabel(DICCTIONARY.label_boolean_operand1)
52
55
  }
53
56
  )
54
57
  ] });
@@ -1,6 +1,6 @@
1
1
  import * as Yup from "yup";
2
2
  import { b as DATE_TIME_OPERATORS } from "../../../constants.js";
3
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
3
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
4
4
  import { D as DateTimeFilter } from "./index.js";
5
5
  import { i as isValidDate } from "../../../../../utils/isValidDate.js";
6
6
  class DateTimeFilterHelpers {
@@ -44,7 +44,7 @@ class DateTimeFilterHelpers {
44
44
  fieldType: "datetime",
45
45
  formValueOperator: {
46
46
  id: operator,
47
- label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
47
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${operator}`)
48
48
  },
49
49
  formValueOperand1,
50
50
  formValueOperand2
@@ -88,7 +88,7 @@ class DateTimeFilterHelpers {
88
88
  }
89
89
  return {
90
90
  labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
91
- labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
91
+ labelOperator: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`),
92
92
  labelOperands
93
93
  };
94
94
  }
@@ -97,13 +97,13 @@ class DateTimeFilterHelpers {
97
97
  */
98
98
  getSchema(getLabel) {
99
99
  return Yup.object({
100
- formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
101
- formValueOperand1: Yup.date().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))),
100
+ formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
101
+ formValueOperand1: Yup.date().required(getLabel(DICCTIONARY.error_invalid_date)).typeError(getLabel(DICCTIONARY.error_invalid_date)),
102
102
  formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
103
103
  is: "b",
104
- then: Yup.date().typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).min(
104
+ then: Yup.date().typeError(getLabel(DICCTIONARY.error_invalid_date)).min(
105
105
  Yup.ref("formValueOperand1"),
106
- getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))
106
+ getLabel(DICCTIONARY.error_invalid_date)
107
107
  )
108
108
  })
109
109
  });
@@ -3,12 +3,15 @@ import { useModuleDictionary } from "@m4l/core";
3
3
  import { useMemo } from "react";
4
4
  import { useFormContext, useWatch } from "react-hook-form";
5
5
  import { b as DATE_TIME_OPERATORS } from "../../../constants.js";
6
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
6
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
7
+ import { u as useDynamicFilterStore } from "../../../store/useDynamicFilterStore.js";
7
8
  import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
8
9
  import { R as RHFDateTime } from "../../../../hook-form/RHFDateTime/RHFDateTime.js";
9
10
  function DateTimeFilter() {
10
11
  const { getLabel } = useModuleDictionary();
11
12
  const { control } = useFormContext();
13
+ const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
14
+ const restritcOperatorsTo = field?.restritcOperatorsTo;
12
15
  const operator = useWatch({
13
16
  control,
14
17
  name: "formValueOperator"
@@ -16,9 +19,9 @@ function DateTimeFilter() {
16
19
  const operators = useMemo(
17
20
  () => DATE_TIME_OPERATORS.map((o) => ({
18
21
  id: o,
19
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
20
- })),
21
- [getLabel]
22
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${o}`)
23
+ })).filter((o) => restritcOperatorsTo ? restritcOperatorsTo.includes(o.id) : true),
24
+ [getLabel, restritcOperatorsTo]
22
25
  );
23
26
  return /* @__PURE__ */ jsxs("div", { children: [
24
27
  /* @__PURE__ */ jsx(
@@ -30,21 +33,21 @@ function DateTimeFilter() {
30
33
  options: operators,
31
34
  getOptionLabel: (option) => option.label,
32
35
  isOptionEqualToValue: (option, value) => option.id === value.id,
33
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_date_time))
36
+ label: getLabel(DICCTIONARY.label_operator_date_time)
34
37
  }
35
38
  ),
36
39
  /* @__PURE__ */ jsx(
37
40
  RHFDateTime,
38
41
  {
39
42
  name: "formValueOperand1",
40
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_date_time))
43
+ label: getLabel(DICCTIONARY.label_operand1_date_time)
41
44
  }
42
45
  ),
43
46
  operator && operator.id === "b" && /* @__PURE__ */ jsx(
44
47
  RHFDateTime,
45
48
  {
46
49
  name: "formValueOperand2",
47
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_date_time))
50
+ label: getLabel(DICCTIONARY.label_operand2_date_time)
48
51
  }
49
52
  )
50
53
  ] });
@@ -1,7 +1,7 @@
1
1
  import * as Yup from "yup";
2
2
  import { N as NUMBER_OPERATORS } from "../../../constants.js";
3
- import { g as getDynamicFilterDictionary } from "../../../dictionary.js";
4
3
  import { N as NumberFilter } from "./index.js";
4
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
5
5
  class NumberFilterHelpers {
6
6
  getComponent() {
7
7
  return NumberFilter;
@@ -14,15 +14,23 @@ class NumberFilterHelpers {
14
14
  const dOperator = field.defaultOperator ?? "e";
15
15
  const defaultOperand1 = field.defaultOperand1 ?? null;
16
16
  const defaultOperand2 = field.defaultOperand2 ?? null;
17
+ let isSet = false;
18
+ if (fixed) {
19
+ if (["b"].includes(dOperator)) {
20
+ isSet = defaultOperand1 !== null && defaultOperand2 !== null ? true : false;
21
+ } else {
22
+ isSet = defaultOperand1 !== null ? true : false;
23
+ }
24
+ }
17
25
  return {
18
26
  id: 0,
19
27
  fieldType: "number",
20
28
  field,
21
29
  fixed,
22
- isSet: false,
23
30
  operator: dOperator,
24
31
  operand1: defaultOperand1,
25
- operand2: defaultOperand2
32
+ operand2: defaultOperand2,
33
+ isSet
26
34
  };
27
35
  }
28
36
  /**
@@ -37,7 +45,7 @@ class NumberFilterHelpers {
37
45
  fieldType: "number",
38
46
  formValueOperator: {
39
47
  id: operator,
40
- label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
48
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${operator}`)
41
49
  },
42
50
  formValueOperand1,
43
51
  formValueOperand2
@@ -73,11 +81,11 @@ class NumberFilterHelpers {
73
81
  if (filter.operator === "b") {
74
82
  labelOperands = filter.operand1 && filter.operand2 ? `${filter.operand1} - ${filter.operand2}` : "";
75
83
  } else {
76
- labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
84
+ labelOperands = (filter.operand1 ?? "?") + "";
77
85
  }
78
86
  return {
79
87
  labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
80
- labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
88
+ labelOperator: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`),
81
89
  labelOperands
82
90
  };
83
91
  }
@@ -86,13 +94,13 @@ class NumberFilterHelpers {
86
94
  */
87
95
  getSchema(getLabel) {
88
96
  return Yup.object({
89
- formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
97
+ formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
90
98
  formValueOperand1: Yup.number().typeError(
91
- getLabel(`dynamic_filter.error_operand_mustbe_number`)
99
+ getLabel(DICCTIONARY.error_operand_mustbe_number)
92
100
  ),
93
101
  formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
94
102
  is: "b",
95
- then: Yup.number().typeError(getLabel(`dynamic_filter.error_operand_mustbe_number`)).min(Yup.ref("formValueOperand1"), getLabel(`dynamic_filter.error_less_than_start`))
103
+ then: Yup.number().typeError(getLabel(DICCTIONARY.error_operand_mustbe_number)).min(Yup.ref("formValueOperand1"), getLabel(DICCTIONARY.error_less_than_start))
96
104
  })
97
105
  });
98
106
  }
@@ -3,12 +3,16 @@ import { useModuleDictionary } from "@m4l/core";
3
3
  import { useMemo } from "react";
4
4
  import { useFormContext, useWatch } from "react-hook-form";
5
5
  import { N as NUMBER_OPERATORS } from "../../../constants.js";
6
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
6
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
7
+ import { u as useDynamicFilterStore } from "../../../store/useDynamicFilterStore.js";
7
8
  import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
9
+ import { R as RHFNumberInput } from "../../../../hook-form/RHFNumberInput/RHFNumberInput.js";
8
10
  import { R as RHFTextField } from "../../../../hook-form/RHFTextField/RHFTextField.js";
9
11
  function NumberFilter() {
10
12
  const { getLabel } = useModuleDictionary();
11
13
  const { control } = useFormContext();
14
+ const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
15
+ const restritcOperatorsTo = field?.restritcOperatorsTo;
12
16
  const operator = useWatch({
13
17
  control,
14
18
  name: "formValueOperator"
@@ -16,9 +20,9 @@ function NumberFilter() {
16
20
  const operators = useMemo(
17
21
  () => NUMBER_OPERATORS.map((o) => ({
18
22
  id: o,
19
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
20
- })),
21
- [getLabel]
23
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${o}`)
24
+ })).filter((o) => restritcOperatorsTo ? restritcOperatorsTo.includes(o.id) : true),
25
+ [getLabel, restritcOperatorsTo]
22
26
  );
23
27
  return /* @__PURE__ */ jsxs("div", { children: [
24
28
  /* @__PURE__ */ jsx(
@@ -30,15 +34,15 @@ function NumberFilter() {
30
34
  options: operators,
31
35
  getOptionLabel: (option) => option.label,
32
36
  isOptionEqualToValue: (option, value) => option.id === value.id,
33
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_number))
37
+ label: getLabel(DICCTIONARY.label_operator_number)
34
38
  }
35
39
  ),
36
40
  /* @__PURE__ */ jsx(
37
- RHFTextField,
41
+ RHFNumberInput,
38
42
  {
39
43
  name: "formValueOperand1",
40
- type: "number",
41
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_number))
44
+ withDecimal: false,
45
+ label: getLabel(DICCTIONARY.label_operand1_number)
42
46
  }
43
47
  ),
44
48
  operator && operator.id === "b" && /* @__PURE__ */ jsx(
@@ -46,7 +50,7 @@ function NumberFilter() {
46
50
  {
47
51
  name: "formValueOperand2",
48
52
  type: "number",
49
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_number))
53
+ label: getLabel(DICCTIONARY.label_operand2_number)
50
54
  }
51
55
  )
52
56
  ] });
@@ -1,6 +1,6 @@
1
1
  import { GetLabelType } from '@m4l/core';
2
2
  import { Formatters } from '@m4l/graphics';
3
- import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FormFilterValueSelectAsync, FormOperandSelectAsync, InitialFilterApplied } from '../../../types';
3
+ import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FilterValueSelectAsync, FormFilterValueSelectAsync, OperandSelectAsync, InitialFilterApplied } from '../../../types';
4
4
  import { IFieldType, YupSchema } from '../FieldTypeInterface';
5
5
  import { SelectAsyncFilter } from './index';
6
6
  /**
@@ -9,7 +9,7 @@ import { SelectAsyncFilter } from './index';
9
9
  * @param field Propiedades del field
10
10
  * @returns FormOperandSelect[] operandArray filtrado con valores validados
11
11
  */
12
- export declare function filterValidOperandsArraySelectAsync(operandsArray: FormOperandSelectAsync[] | FormOperandSelectAsync, field: FilterField): any[];
12
+ export declare function filterValidOperandsArraySelectAsync(operandsArray: OperandSelectAsync[] | OperandSelectAsync, field: FilterField): any[];
13
13
  /**
14
14
  * SelectAsyncFilterHelpers es una clase que implementa la interfaz IFieldType
15
15
  */
@@ -18,19 +18,19 @@ export declare class SelectAsyncFilterHelpers implements IFieldType<FormFilterVa
18
18
  /**
19
19
  * getDefaultFilter devuelve un filtro por defecto para un campo de selección asíncrona.
20
20
  */
21
- getDefaultFilter(field: FilterField, fixed: boolean): FilterFieldApplied;
21
+ getDefaultFilter(fieldSelectAsync: FilterField, fixed: boolean): FilterFieldApplied;
22
22
  /**
23
23
  * getFormValue convierte un valor de filtro en un valor de formulario.
24
24
  */
25
- getFormValue(field: FilterField, getLabel: GetLabelType, filterValueSelect?: FilterValue): FormFilterValueSelectAsync;
25
+ getFormValue(fieldSelectAsync: FilterField, getLabel: GetLabelType, filterValueSelectAsync?: FilterValue): FormFilterValueSelectAsync;
26
26
  /**
27
27
  * getFilterFromFormValue convierte un valor de formulario en un valor de filtro.
28
28
  */
29
- getFilterFromFormValue(formFilterValue: FormFilterValueSelectAsync): FilterValue;
29
+ getFilterFromFormValue(formFilterValue: FormFilterValueSelectAsync): FilterValueSelectAsync;
30
30
  /**
31
31
  * getLabels devuelve las etiquetas para el campo, operador y operandos.
32
32
  */
33
- getLabels(filter: FilterFieldApplied, getLabel: GetLabelType, _formatters: Formatters, field: FilterField): DataTypeFilerLabels;
33
+ getLabels(filter: FilterFieldApplied, getLabel: GetLabelType, _formatters: Formatters, fieldSelectAsync: FilterField): DataTypeFilerLabels;
34
34
  /**
35
35
  * getschema devuelve el esquema de validación de Yup para el filtro.
36
36
  */
@@ -38,5 +38,5 @@ export declare class SelectAsyncFilterHelpers implements IFieldType<FormFilterVa
38
38
  /**
39
39
  * verifyFilter verifica si el filtro es válido.
40
40
  */
41
- verifyFilter(filter: InitialFilterApplied, field?: FilterField): boolean;
41
+ verifyFilter(filter: InitialFilterApplied, fieldSelectAsync?: FilterField): boolean;
42
42
  }
@@ -1,7 +1,7 @@
1
1
  import * as Yup from "yup";
2
- import { S as SELECT_OPERATORS } from "../../../constants.js";
3
- import { g as getDynamicFilterDictionary } from "../../../dictionary.js";
2
+ import { S as SELECT_ASYNC_OPERATORS_MULTIPLE, c as SELECT_ASYNC_OPERATORS_SINGLE } from "../../../constants.js";
4
3
  import { S as SelectAsyncFilter } from "./index.js";
4
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
5
5
  function filterValidOperandsArraySelectAsync(operandsArray, field) {
6
6
  const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
7
7
  const getOptionId = field?.selectAsyncOptions?.getOptionId;
@@ -17,64 +17,120 @@ class SelectAsyncFilterHelpers {
17
17
  /**
18
18
  * getDefaultFilter devuelve un filtro por defecto para un campo de selección asíncrona.
19
19
  */
20
- getDefaultFilter(field, fixed) {
21
- const defaultOperand = field.defaultOperandsArray;
22
- const defaultFilter = {
20
+ getDefaultFilter(fieldSelectAsync, fixed) {
21
+ const field = fieldSelectAsync;
22
+ const defaultOperandsArray = field.defaultOperandsArray ?? [];
23
+ const defaultOperand1 = field.defaultOperand1;
24
+ const isMultiple = field?.selectAsyncOptions?.multiple ?? false;
25
+ let dOperator;
26
+ let isSet = false;
27
+ let operandsArray = [];
28
+ if (isMultiple) {
29
+ dOperator = field.defaultOperator ?? "in";
30
+ isSet = fixed ? defaultOperandsArray !== null && defaultOperandsArray.length > 0 ? true : false : false;
31
+ if (field.defaultOperandsArray !== void 0 && Array.isArray(field.defaultOperandsArray)) {
32
+ operandsArray = filterValidOperandsArraySelectAsync(field.defaultOperandsArray, field);
33
+ }
34
+ } else {
35
+ dOperator = field.defaultOperator ?? "e";
36
+ isSet = fixed ? defaultOperand1 ? true : false : false;
37
+ }
38
+ const defaultCommonFilter = {
23
39
  id: 0,
24
40
  fieldType: "selectAsync",
25
41
  field,
26
42
  fixed,
27
- isSet: true,
28
- operator: "in",
29
- operandsArray: []
43
+ isSet,
44
+ operator: dOperator
30
45
  };
31
- if (defaultOperand !== void 0 && Array.isArray(defaultOperand)) {
32
- const validOperandsArray = filterValidOperandsArraySelectAsync(defaultOperand, field);
33
- defaultFilter.operandsArray = validOperandsArray || [];
34
- }
35
- return defaultFilter;
46
+ const defaultFilterMultiple = {
47
+ ...defaultCommonFilter,
48
+ multiple: true,
49
+ operandsArray
50
+ };
51
+ const defaultFilterSingle = {
52
+ ...defaultCommonFilter,
53
+ multiple: false,
54
+ operand1: defaultOperand1
55
+ };
56
+ return isMultiple ? defaultFilterMultiple : defaultFilterSingle;
36
57
  }
37
58
  /**
38
59
  * getFormValue convierte un valor de filtro en un valor de formulario.
39
60
  */
40
- getFormValue(field, getLabel, filterValueSelect) {
41
- const filterValue = filterValueSelect ? filterValueSelect : void 0;
61
+ getFormValue(fieldSelectAsync, getLabel, filterValueSelectAsync) {
62
+ const field = fieldSelectAsync;
63
+ const filterValue = filterValueSelectAsync ?? void 0;
42
64
  const isMultiple = field?.selectAsyncOptions?.multiple ?? false;
43
- const formValueOperandsArray = isMultiple ? filterValueSelect?.operandsArray : filterValueSelect?.operandsArray?.[0] || filterValueSelect?.operandsArray;
44
- const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
45
- return {
65
+ let formValueOperandsArray = void 0;
66
+ let formValueOperand1 = void 0;
67
+ let operator;
68
+ if (isMultiple) {
69
+ operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
70
+ formValueOperandsArray = filterValueSelectAsync?.operandsArray;
71
+ } else {
72
+ operator = filterValue ? filterValue.operator : field.defaultOperator ?? "e";
73
+ formValueOperand1 = filterValueSelectAsync?.operand1;
74
+ }
75
+ const formCommon = {
46
76
  fieldType: "selectAsync",
47
77
  formValueOperator: {
48
78
  id: operator,
49
- label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
50
- },
79
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${operator}`)
80
+ }
81
+ };
82
+ const formMultiple = {
83
+ ...formCommon,
84
+ multiple: true,
51
85
  formValueOperandsArray
52
86
  };
87
+ const formSingle = {
88
+ ...formCommon,
89
+ multiple: false,
90
+ formValueOperand1
91
+ };
92
+ return isMultiple ? formMultiple : formSingle;
53
93
  }
54
94
  /**
55
95
  * getFilterFromFormValue convierte un valor de formulario en un valor de filtro.
56
96
  */
57
97
  getFilterFromFormValue(formFilterValue) {
58
98
  const operator = formFilterValue.formValueOperator.id;
59
- const operandsArray = Array.isArray(formFilterValue.formValueOperandsArray) ? formFilterValue.formValueOperandsArray : [formFilterValue.formValueOperandsArray];
60
- return {
99
+ const isMultiple = formFilterValue.multiple;
100
+ const filterCommon = {
61
101
  fieldType: "selectAsync",
62
- operator,
63
- operandsArray
102
+ operator
103
+ };
104
+ const filterMultiple = {
105
+ ...filterCommon,
106
+ multiple: true,
107
+ operandsArray: formFilterValue.formValueOperandsArray
108
+ };
109
+ const filterSingle = {
110
+ ...filterCommon,
111
+ operand1: formFilterValue.formValueOperand1
64
112
  };
113
+ return isMultiple ? filterMultiple : filterSingle;
65
114
  }
66
115
  /**
67
116
  * getLabels devuelve las etiquetas para el campo, operador y operandos.
68
117
  */
69
- getLabels(filter, getLabel, _formatters, field) {
118
+ getLabels(filter, getLabel, _formatters, fieldSelectAsync) {
119
+ const field = fieldSelectAsync;
120
+ const isMultiple = field?.selectAsyncOptions?.multiple ?? false;
70
121
  const operandsArray = filter.operandsArray;
71
- const labelOperands = operandsArray?.reduce?.((label, operand) => {
72
- const textLabel = field.selectAsyncOptions?.getOptionLabel?.(operand) || "";
73
- return label ? `${label} | ${textLabel}` : textLabel;
74
- }, "")?.toString() || "";
122
+ let labelOperands = "";
123
+ if (isMultiple) {
124
+ labelOperands = operandsArray?.reduce?.((label, operand) => {
125
+ const textLabel = field.selectAsyncOptions?.getOptionLabel?.(operand) || "";
126
+ return label ? `${label} | ${textLabel}` : textLabel;
127
+ }, "")?.toString() || "?";
128
+ } else {
129
+ labelOperands = (field.selectAsyncOptions?.getOptionLabel?.(filter.operand1) ?? "?") + "";
130
+ }
75
131
  return {
76
132
  labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
77
- labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
133
+ labelOperator: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`),
78
134
  labelOperands
79
135
  };
80
136
  }
@@ -83,34 +139,53 @@ class SelectAsyncFilterHelpers {
83
139
  */
84
140
  getSchema(getLabel) {
85
141
  return Yup.object({
86
- formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
87
- formValueOperandsArray: Yup.lazy((value) => {
88
- 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`));
142
+ formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
143
+ formValueOperandsArray: Yup.mixed().when(["multiple"], {
144
+ is: true,
145
+ then: Yup.array().min(1, getLabel(DICCTIONARY.error_operand_required)).required(getLabel(DICCTIONARY.error_operand_required))
146
+ }),
147
+ formValueOperand1: Yup.mixed().when(["multiple"], {
148
+ is: false,
149
+ then: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operand_required))
89
150
  })
90
151
  });
91
152
  }
92
153
  /**
93
154
  * verifyFilter verifica si el filtro es válido.
94
155
  */
95
- verifyFilter(filter, field) {
156
+ verifyFilter(filter, fieldSelectAsync) {
157
+ const field = fieldSelectAsync;
158
+ const isMultiple = field?.selectAsyncOptions?.multiple ?? false;
96
159
  if (typeof filter.operator !== "string") {
97
160
  return false;
98
161
  }
99
162
  if (!field) {
100
163
  return false;
101
164
  }
102
- if (SELECT_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
103
- return false;
104
- }
105
- if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
106
- return false;
107
- }
108
- const validOperandsArray = filterValidOperandsArraySelectAsync(
109
- filter.operandsArray,
110
- field
111
- );
112
- if (!validOperandsArray || validOperandsArray?.length === 0) {
113
- return false;
165
+ if (isMultiple) {
166
+ if (SELECT_ASYNC_OPERATORS_MULTIPLE.findIndex((f) => f === filter.operator) === -1) {
167
+ return false;
168
+ }
169
+ if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
170
+ return false;
171
+ }
172
+ if (Array.isArray(filter.operandsArray) && filter.operandsArray.length === 0) {
173
+ return false;
174
+ }
175
+ const validOperandsArray = filterValidOperandsArraySelectAsync(
176
+ filter.operandsArray,
177
+ field
178
+ );
179
+ if (!validOperandsArray || validOperandsArray?.length === 0) {
180
+ return false;
181
+ }
182
+ } else {
183
+ if (SELECT_ASYNC_OPERATORS_SINGLE.findIndex((f) => f === filter.operator) === -1) {
184
+ return false;
185
+ }
186
+ if (!filter.operand1 || typeof filter.operand1 !== "object") {
187
+ return false;
188
+ }
114
189
  }
115
190
  return true;
116
191
  }