@m4l/components 9.2.49 → 9.2.50-beta.1

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 +1 -1
  164. package/components/PropertyValue/styles.d.ts +0 -1
@@ -1,24 +1,26 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useModuleDictionary } from "@m4l/core";
3
3
  import { useMemo } from "react";
4
- import { S as SELECT_OPERATORS } from "../../../constants.js";
5
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
4
+ import { S as SELECT_ASYNC_OPERATORS_MULTIPLE, c as SELECT_ASYNC_OPERATORS_SINGLE } from "../../../constants.js";
5
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
6
6
  import { u as useDynamicFilterStore } from "../../../store/useDynamicFilterStore.js";
7
7
  import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
8
8
  import { R as RHFAutocompleteAsync } from "../../../../hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js";
9
9
  function SelectAsyncFilter() {
10
10
  const { getLabel } = useModuleDictionary();
11
11
  const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
12
+ const selectAsyncProps = field?.selectAsyncOptions;
13
+ const isMultiple = selectAsyncProps?.multiple ?? false;
14
+ const restritcOperatorsTo = field?.restritcOperatorsTo;
12
15
  if (!field?.selectAsyncOptions?.endPoint) {
13
16
  throw new Error("El filtro tipo Select requiere la configuración del Endpoint");
14
17
  }
15
- const autocompleteProps = field?.selectAsyncOptions;
16
18
  const operators = useMemo(
17
- () => SELECT_OPERATORS.map((o) => ({
19
+ () => (isMultiple ? SELECT_ASYNC_OPERATORS_MULTIPLE : SELECT_ASYNC_OPERATORS_SINGLE).map((o) => ({
18
20
  id: o,
19
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
20
- })),
21
- [getLabel]
21
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${o}`)
22
+ })).filter((o) => restritcOperatorsTo ? restritcOperatorsTo.includes(o.id) : true),
23
+ [getLabel, isMultiple, restritcOperatorsTo]
22
24
  );
23
25
  return /* @__PURE__ */ jsxs("div", { children: [
24
26
  /* @__PURE__ */ jsx(
@@ -30,16 +32,16 @@ function SelectAsyncFilter() {
30
32
  options: operators,
31
33
  getOptionLabel: (option) => option.label,
32
34
  isOptionEqualToValue: (option, value) => option.id === value.id,
33
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operator))
35
+ label: getLabel(DICCTIONARY.label_select_operator)
34
36
  }
35
37
  ),
36
38
  /* @__PURE__ */ jsx(
37
39
  RHFAutocompleteAsync,
38
40
  {
39
- ...autocompleteProps,
40
- name: "formValueOperandsArray",
41
+ ...selectAsyncProps,
42
+ name: isMultiple ? "formValueOperandsArray" : "formValueOperand1",
41
43
  autoComplete: "off",
42
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operands_array))
44
+ label: isMultiple ? getLabel(DICCTIONARY.label_select_async_operands_array) : getLabel(DICCTIONARY.label_select_async_operand1)
43
45
  }
44
46
  )
45
47
  ] });
@@ -1,6 +1,6 @@
1
1
  import { GetLabelType } from '@m4l/core';
2
2
  import { Formatters } from '@m4l/graphics';
3
- import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FormFilterValueSelect, FormOperandSelect, InitialFilterApplied } from '../../../types';
3
+ import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FilterValueSelect, FormFilterValueSelect, OperandSelect, InitialFilterApplied } from '../../../types';
4
4
  import { IFieldType, YupSchema } from '../FieldTypeInterface';
5
5
  import { SelectFilter } from './index';
6
6
  /**
@@ -9,7 +9,7 @@ import { SelectFilter } from './index';
9
9
  * @param field Propiedades del field
10
10
  * @returns FormOperandSelect[] operandArray filtrado con valores validados
11
11
  */
12
- export declare function filterValidOperandsArraySelect(operandsArray: FormOperandSelect[] | FormOperandSelect, _field: FilterField): (string | number)[];
12
+ export declare function filterValidOperandsArraySelect(operandsArray: OperandSelect[] | OperandSelect, _field: FilterField): (string | number)[];
13
13
  /**
14
14
  * SelectFilterHelpers es una clase que implementa la interfaz IFieldType
15
15
  */
@@ -17,20 +17,21 @@ export declare class SelectFilterHelpers implements IFieldType<FormFilterValueSe
17
17
  getComponent(): typeof SelectFilter;
18
18
  /**
19
19
  * getDefaultFilter devuelve un filtro por defecto para un campo de selección.
20
+ * Cuando es initialized o fixed
20
21
  */
21
- getDefaultFilter(field: FilterField, fixed: boolean): FilterFieldApplied;
22
+ getDefaultFilter(fieldSelect: FilterField, fixed: boolean): FilterFieldApplied;
22
23
  /**
23
24
  * Función para obtener el valor en terminos de HookForm desde los ids de los values.
24
25
  */
25
- getFormValue(field: FilterField, getLabel: GetLabelType, filterValueSelect?: FilterValue): FormFilterValueSelect;
26
+ getFormValue(fieldSelect: FilterField, getLabel: GetLabelType, filterValueSelect?: FilterValue): FormFilterValueSelect;
26
27
  /**
27
28
  * getFilterFromFormValue convierte un valor de formulario en un valor de filtro.
28
29
  */
29
- getFilterFromFormValue(formFilterValue: FormFilterValueSelect): FilterValue;
30
+ getFilterFromFormValue(formFilterValue: FormFilterValueSelect): FilterValueSelect;
30
31
  /**
31
32
  * getLabels devuelve las etiquetas para el filtro de selección.
32
33
  */
33
- getLabels(filter: FilterFieldApplied, getLabel: GetLabelType, _formatters: Formatters, field: FilterField): DataTypeFilerLabels;
34
+ getLabels(filter: FilterFieldApplied, getLabel: GetLabelType, _formatters: Formatters, fieldSelect: FilterField): DataTypeFilerLabels;
34
35
  /**
35
36
  * getSchema devuelve el esquema de validación de Yup para un filtro de selección.
36
37
  */
@@ -38,5 +39,5 @@ export declare class SelectFilterHelpers implements IFieldType<FormFilterValueSe
38
39
  /**
39
40
  * TODO: Documentar
40
41
  */
41
- verifyFilter(filter: InitialFilterApplied, field?: FilterField): boolean;
42
+ verifyFilter(filter: InitialFilterApplied, fieldSelect?: FilterField): boolean;
42
43
  }
@@ -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 { d as SELECT_OPERATORS_MULTIPLE, e as SELECT_OPERATORS_SINGLE } from "../../../constants.js";
4
3
  import { S as SelectFilter } from "./index.js";
4
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
5
5
  function filterValidOperandsArraySelect(operandsArray, _field) {
6
6
  const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
7
7
  return operandsArrayFormatted?.filter((operand) => {
@@ -14,65 +14,124 @@ class SelectFilterHelpers {
14
14
  }
15
15
  /**
16
16
  * getDefaultFilter devuelve un filtro por defecto para un campo de selección.
17
+ * Cuando es initialized o fixed
17
18
  */
18
- getDefaultFilter(field, fixed) {
19
- const defaultOperand = field.defaultOperandsArray;
20
- const defaultFilter = {
19
+ getDefaultFilter(fieldSelect, fixed) {
20
+ const field = fieldSelect;
21
+ const defaultOperandsArray = field.defaultOperandsArray ?? [];
22
+ const defaultOperand1 = field.defaultOperand1;
23
+ const isMultiple = field?.selectOptions?.multiple ?? false;
24
+ let dOperator;
25
+ let isSet = false;
26
+ let operandsArray = [];
27
+ if (isMultiple) {
28
+ dOperator = field.defaultOperator ?? "in";
29
+ isSet = fixed ? defaultOperandsArray !== null && defaultOperandsArray.length > 0 ? true : false : false;
30
+ if (field.defaultOperandsArray !== void 0 && Array.isArray(field.defaultOperandsArray)) {
31
+ operandsArray = filterValidOperandsArraySelect(field.defaultOperandsArray);
32
+ }
33
+ } else {
34
+ dOperator = field.defaultOperator ?? "e";
35
+ isSet = fixed ? defaultOperand1 !== null ? true : false : false;
36
+ }
37
+ const defaultCommonFilter = {
21
38
  id: 0,
22
39
  fieldType: "select",
23
40
  field,
24
41
  fixed,
25
- isSet: true,
26
- operator: "in",
27
- operandsArray: []
42
+ isSet,
43
+ operator: dOperator
28
44
  };
29
- if (defaultOperand !== void 0 && Array.isArray(defaultOperand)) {
30
- const validOperandsArray = filterValidOperandsArraySelect(defaultOperand);
31
- defaultFilter.operandsArray = validOperandsArray || [];
32
- }
33
- return defaultFilter;
45
+ const defaultFilterMultiple = {
46
+ ...defaultCommonFilter,
47
+ fieldType: "select",
48
+ multiple: true,
49
+ operandsArray
50
+ };
51
+ const defaultFilterSingle = {
52
+ ...defaultCommonFilter,
53
+ fieldType: "select",
54
+ multiple: false,
55
+ operand1: defaultOperand1
56
+ };
57
+ return isMultiple ? defaultFilterMultiple : defaultFilterSingle;
34
58
  }
35
59
  /**
36
60
  * Función para obtener el valor en terminos de HookForm desde los ids de los values.
37
61
  */
38
- getFormValue(field, getLabel, filterValueSelect) {
39
- const filterValue = filterValueSelect ? filterValueSelect : void 0;
62
+ getFormValue(fieldSelect, getLabel, filterValueSelect) {
63
+ const field = fieldSelect;
64
+ const filterValue = filterValueSelect ?? void 0;
40
65
  const isMultiple = field?.selectOptions?.multiple ?? false;
41
- const formValueOperandsArray = isMultiple ? filterValueSelect?.operandsArray : filterValueSelect?.operandsArray?.[0] || filterValueSelect?.operandsArray;
42
- const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
43
- return {
66
+ let formValueOperandsArray = void 0;
67
+ let formValueOperand1 = void 0;
68
+ let operator;
69
+ if (isMultiple) {
70
+ operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
71
+ formValueOperandsArray = filterValueSelect?.operandsArray;
72
+ } else {
73
+ operator = filterValue ? filterValue.operator : field.defaultOperator ?? "e";
74
+ formValueOperand1 = filterValueSelect?.operand1;
75
+ }
76
+ const formCommon = {
44
77
  fieldType: "select",
45
78
  formValueOperator: {
46
79
  id: operator,
47
- label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
48
- },
80
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${operator}`)
81
+ }
82
+ };
83
+ const formMultiple = {
84
+ ...formCommon,
85
+ multiple: true,
49
86
  formValueOperandsArray
50
87
  };
88
+ const formSingle = {
89
+ ...formCommon,
90
+ multiple: false,
91
+ formValueOperand1
92
+ };
93
+ return isMultiple ? formMultiple : formSingle;
51
94
  }
52
95
  /**
53
96
  * getFilterFromFormValue convierte un valor de formulario en un valor de filtro.
54
97
  */
55
98
  getFilterFromFormValue(formFilterValue) {
56
99
  const operator = formFilterValue.formValueOperator.id;
57
- const operandsArray = Array.isArray(formFilterValue.formValueOperandsArray) ? formFilterValue.formValueOperandsArray : [formFilterValue.formValueOperandsArray];
58
- return {
100
+ const isMultiple = formFilterValue.multiple;
101
+ const filterCommon = {
59
102
  fieldType: "select",
60
- operator,
61
- operandsArray
103
+ operator
104
+ };
105
+ const filterMultiple = {
106
+ ...filterCommon,
107
+ multiple: true,
108
+ operandsArray: formFilterValue.formValueOperandsArray
62
109
  };
110
+ const filterSingle = {
111
+ ...filterCommon,
112
+ operand1: formFilterValue.formValueOperand1
113
+ };
114
+ return isMultiple ? filterMultiple : filterSingle;
63
115
  }
64
116
  /**
65
117
  * getLabels devuelve las etiquetas para el filtro de selección.
66
118
  */
67
- getLabels(filter, getLabel, _formatters, field) {
119
+ getLabels(filter, getLabel, _formatters, fieldSelect) {
120
+ const field = fieldSelect;
121
+ const isMultiple = field?.selectOptions?.multiple ?? false;
68
122
  const operandsArray = filter.operandsArray;
69
- const labelOperands = operandsArray?.reduce?.((label, operand) => {
70
- const textLabel = field.selectOptions?.options.find((option) => option.id === operand)?.label || "";
71
- return label ? `${label} | ${textLabel}` : textLabel;
72
- }, "")?.toString() || "";
123
+ let labelOperands = "";
124
+ if (isMultiple) {
125
+ labelOperands = operandsArray?.reduce?.((label, operand) => {
126
+ const textLabel = field.selectOptions?.options.find((option) => option.id === operand)?.label || "";
127
+ return label ? `${label} | ${textLabel}` : textLabel;
128
+ }, "")?.toString() || "?";
129
+ } else {
130
+ labelOperands = (filter.operand1 ?? "?") + "";
131
+ }
73
132
  return {
74
133
  labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
75
- labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
134
+ labelOperator: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`),
76
135
  labelOperands
77
136
  };
78
137
  }
@@ -81,37 +140,59 @@ class SelectFilterHelpers {
81
140
  */
82
141
  getSchema(getLabel) {
83
142
  return Yup.object({
84
- formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
85
- formValueOperandsArray: Yup.lazy((value) => {
86
- return Array.isArray(value) ? Yup.array().min(1, getLabel(`dynamic_filter.error_operand_required`)).required(getLabel(`dynamic_filter.error_operand_required`)) : Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`));
143
+ formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
144
+ formValueOperandsArray: Yup.mixed().when(["multiple"], {
145
+ is: true,
146
+ then: Yup.array().min(1, getLabel(DICCTIONARY.error_operand_required)).required(getLabel(DICCTIONARY.error_operand_required))
147
+ }),
148
+ formValueOperand1: Yup.mixed().when(["multiple"], {
149
+ is: false,
150
+ then: Yup.mixed().test("is-string-or-number", getLabel(DICCTIONARY.error_operand_required), (value) => {
151
+ return typeof value === "string" || typeof value === "number";
152
+ }).required(getLabel(DICCTIONARY.error_operand_required))
87
153
  })
88
154
  });
89
155
  }
90
156
  /**
91
157
  * TODO: Documentar
92
158
  */
93
- verifyFilter(filter, field) {
159
+ verifyFilter(filter, fieldSelect) {
160
+ const field = fieldSelect;
161
+ const isMultiple = field?.selectOptions?.multiple ?? false;
94
162
  if (typeof filter.operator !== "string") {
95
163
  return false;
96
164
  }
97
165
  if (!field) {
98
166
  return false;
99
167
  }
100
- if (SELECT_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
101
- return false;
102
- }
103
- if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
104
- return false;
105
- }
106
- const validOperandsArray = filterValidOperandsArraySelect(
107
- filter.operandsArray
108
- );
109
- if (!validOperandsArray || validOperandsArray?.length === 0) {
110
- return false;
168
+ if (isMultiple) {
169
+ if (SELECT_OPERATORS_MULTIPLE.findIndex((f) => f === filter.operator) === -1) {
170
+ return false;
171
+ }
172
+ if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
173
+ return false;
174
+ }
175
+ if (Array.isArray(filter.operandsArray) && filter.operandsArray.length === 0) {
176
+ return false;
177
+ }
178
+ const validOperandsArray = filterValidOperandsArraySelect(
179
+ filter.operandsArray
180
+ );
181
+ if (!validOperandsArray || validOperandsArray?.length === 0) {
182
+ return false;
183
+ }
184
+ } else {
185
+ if (SELECT_OPERATORS_SINGLE.findIndex((f) => f === filter.operator) === -1) {
186
+ return false;
187
+ }
188
+ if (!filter.operand1 || typeof filter.operand1 !== "string" && typeof filter.operand1 !== "number") {
189
+ return false;
190
+ }
111
191
  }
112
192
  return true;
113
193
  }
114
194
  }
115
195
  export {
116
- SelectFilterHelpers as S
196
+ SelectFilterHelpers as S,
197
+ filterValidOperandsArraySelect as f
117
198
  };
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useModuleDictionary } from "@m4l/core";
3
3
  import { useMemo } from "react";
4
- import { S as SELECT_OPERATORS } from "../../../constants.js";
5
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
4
+ import { d as SELECT_OPERATORS_MULTIPLE, e as SELECT_OPERATORS_SINGLE } from "../../../constants.js";
5
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
6
6
  import { u as useDynamicFilterStore } from "../../../store/useDynamicFilterStore.js";
7
7
  import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
8
8
  import { R as RHFSelect } from "../../../../hook-form/RHFSelect/RHFSelect.js";
@@ -10,12 +10,14 @@ function SelectFilter() {
10
10
  const { getLabel } = useModuleDictionary();
11
11
  const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
12
12
  const selectProps = field?.selectOptions;
13
+ const isMultiple = selectProps?.multiple ?? false;
14
+ const restritcOperatorsTo = field?.restritcOperatorsTo;
13
15
  const operators = useMemo(
14
- () => SELECT_OPERATORS.map((o) => ({
16
+ () => (isMultiple ? SELECT_OPERATORS_MULTIPLE : SELECT_OPERATORS_SINGLE).map((o) => ({
15
17
  id: o,
16
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
17
- })),
18
- [getLabel]
18
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${o}`)
19
+ })).filter((o) => restritcOperatorsTo ? restritcOperatorsTo.includes(o.id) : true),
20
+ [getLabel, isMultiple, restritcOperatorsTo]
19
21
  );
20
22
  return /* @__PURE__ */ jsxs("div", { children: [
21
23
  /* @__PURE__ */ jsx(
@@ -27,7 +29,7 @@ function SelectFilter() {
27
29
  options: operators,
28
30
  getOptionLabel: (option) => option.label,
29
31
  isOptionEqualToValue: (option, value) => option.id === value.id,
30
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operator))
32
+ label: getLabel(DICCTIONARY.label_select_operator)
31
33
  }
32
34
  ),
33
35
  /* @__PURE__ */ jsx(
@@ -35,8 +37,8 @@ function SelectFilter() {
35
37
  {
36
38
  ...selectProps,
37
39
  options: field?.selectOptions?.options || [],
38
- name: "formValueOperandsArray",
39
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operands_array))
40
+ name: isMultiple ? "formValueOperandsArray" : "formValueOperand1",
41
+ label: isMultiple ? getLabel(DICCTIONARY.label_select_operands_array) : getLabel(DICCTIONARY.label_select_operand1)
40
42
  }
41
43
  )
42
44
  ] });
@@ -1,6 +1,6 @@
1
1
  import * as Yup from "yup";
2
- import { c as STRING_OPERATORS } from "../../../constants.js";
3
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
2
+ import { f as STRING_OPERATORS } from "../../../constants.js";
3
+ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
4
4
  import { S as StringFilter } from "./index.js";
5
5
  class StringFilterHelpers {
6
6
  getComponent() {
@@ -11,12 +11,16 @@ class StringFilterHelpers {
11
11
  */
12
12
  getDefaultFilter(field, fixed) {
13
13
  const defaultOperand1 = field.defaultOperand1;
14
+ let isSet = false;
15
+ if (fixed) {
16
+ isSet = defaultOperand1 !== null ? true : false;
17
+ }
14
18
  const defaultFilter = {
15
19
  id: 0,
16
20
  fieldType: "string",
17
21
  field,
18
22
  fixed,
19
- isSet: false,
23
+ isSet,
20
24
  operator: "c",
21
25
  operand1: ""
22
26
  };
@@ -48,7 +52,7 @@ class StringFilterHelpers {
48
52
  fieldType: "string",
49
53
  formValueOperator: {
50
54
  id: operator,
51
- label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
55
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${operator}`)
52
56
  },
53
57
  formValueOperand1
54
58
  };
@@ -60,7 +64,7 @@ class StringFilterHelpers {
60
64
  const labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
61
65
  return {
62
66
  labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
63
- labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
67
+ labelOperator: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${filter.operator}`),
64
68
  labelOperands
65
69
  };
66
70
  }
@@ -69,9 +73,9 @@ class StringFilterHelpers {
69
73
  */
70
74
  getSchema(getLabel) {
71
75
  return Yup.object({
72
- formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
76
+ formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
73
77
  formValueOperand1: Yup.string().required(
74
- getLabel(getDynamicFilterDictionary(DICCTIONARY.error_operand_required))
78
+ getLabel(DICCTIONARY.error_operand_required)
75
79
  )
76
80
  });
77
81
  }
@@ -1,18 +1,21 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useModuleDictionary } from "@m4l/core";
3
3
  import { useMemo } from "react";
4
- import { c as STRING_OPERATORS } from "../../../constants.js";
5
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
4
+ import { f as STRING_OPERATORS } from "../../../constants.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
  import { R as RHFTextField } from "../../../../hook-form/RHFTextField/RHFTextField.js";
8
9
  function StringFilter() {
9
10
  const { getLabel } = useModuleDictionary();
11
+ const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
12
+ const restritcOperatorsTo = field?.restritcOperatorsTo;
10
13
  const operators = useMemo(
11
14
  () => STRING_OPERATORS.map((o) => ({
12
15
  id: o,
13
- label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
14
- })),
15
- [getLabel]
16
+ label: getLabel(`${DYNAMIC_FILTER_DICTIONARY_ID}.operator_${o}`)
17
+ })).filter((o) => restritcOperatorsTo ? restritcOperatorsTo.includes(o.id) : true),
18
+ [getLabel, restritcOperatorsTo]
16
19
  );
17
20
  return /* @__PURE__ */ jsxs("div", { children: [
18
21
  /* @__PURE__ */ jsx(
@@ -24,14 +27,14 @@ function StringFilter() {
24
27
  options: operators,
25
28
  getOptionLabel: (option) => option.label,
26
29
  isOptionEqualToValue: (option, value) => option.id === value.id,
27
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_string))
30
+ label: getLabel(DICCTIONARY.label_operator_string)
28
31
  }
29
32
  ),
30
33
  /* @__PURE__ */ jsx(
31
34
  RHFTextField,
32
35
  {
33
36
  name: "formValueOperand1",
34
- label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_string))
37
+ label: getLabel(DICCTIONARY.label_operand1_string)
35
38
  }
36
39
  )
37
40
  ] });
@@ -8,4 +8,4 @@ import { StringFilterHelpers } from './StringFilter/helpers';
8
8
  /**
9
9
  * fieldFactory es una función que devuelve un helper para un tipo de campo específico.
10
10
  */
11
- export declare function fieldFactory(type: FieldType): SelectAsyncFilterHelpers | BooleanFilterHelpers | DateTimeFilterHelpers | NumberFilterHelpers | SelectFilterHelpers | StringFilterHelpers;
11
+ export declare function fieldFactory(type: FieldType): SelectAsyncFilterHelpers | SelectFilterHelpers | BooleanFilterHelpers | DateTimeFilterHelpers | NumberFilterHelpers | StringFilterHelpers;
@@ -2,6 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useModuleDictionary } from "@m4l/core";
3
3
  import { u as useDynamicFilterBase } from "../DynamicFilterBase/useDynamicFilterBase.js";
4
4
  import { u as useFilterActions } from "./useFilterActions.js";
5
+ import { a as DICCTIONARY } from "../../dictionary.js";
5
6
  import { b as ActionsStyled, c as ActionsClearButtonStyled, d as ActionsSubmitButtonStyled } from "../../slots/dynamicFilterSlots.js";
6
7
  function FilterActions() {
7
8
  const {
@@ -22,7 +23,7 @@ function FilterActions() {
22
23
  icon: clearIconUrl,
23
24
  size,
24
25
  onClick: onClickClearFilters,
25
- tooltip: getLabel("dynamic_filter.tooltip_clear_filters"),
26
+ tooltip: getLabel(DICCTIONARY.tooltip_clear_filters),
26
27
  ownerState: {}
27
28
  }
28
29
  ),
@@ -12,7 +12,7 @@ declare function useFilterActions(): {
12
12
  canShowRemoveAction: boolean;
13
13
  onClickClearFilters: () => void;
14
14
  onClickFilter: VoidFunction;
15
- filterButtonDictionaryTooltip: string;
15
+ filterButtonDictionaryTooltip: "dynamic_filter.filter_tooltip_refresh" | "dynamic_filter.filter_tooltip_dirty" | "dynamic_filter.filter_tooltip_invalid";
16
16
  ownerState: {
17
17
  isValid: boolean;
18
18
  };
@@ -1,5 +1,5 @@
1
1
  import { useEnvironment } from "@m4l/core";
2
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../dictionary.js";
2
+ import { a as DICCTIONARY } from "../../dictionary.js";
3
3
  import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
4
4
  const ASSETS_URL = "frontend/components/dynamic_filter/assets/icons";
5
5
  const ASSETS = {
@@ -21,9 +21,7 @@ function useFilterActions() {
21
21
  const filterIconUrl = `${host_static_assets}/${environment_assets}/${ASSETS_URL}/${automatic ? ASSETS.refresh : ASSETS.search}`;
22
22
  const clearIconUrl = `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/close.svg`;
23
23
  const canShowRemoveAction = appliedFilters.findIndex((f) => !f.fixed) > -1;
24
- const filterButtonDictionaryTooltip = getDynamicFilterDictionary(
25
- isValid ? isDirty ? DICCTIONARY.filter_tooltip_dirty : DICCTIONARY.filter_tooltip_refresh : DICCTIONARY.filter_tooltip_invalid
26
- );
24
+ const filterButtonDictionaryTooltip = isValid ? isDirty ? DICCTIONARY.filter_tooltip_dirty : DICCTIONARY.filter_tooltip_refresh : DICCTIONARY.filter_tooltip_invalid;
27
25
  return {
28
26
  filterIconUrl,
29
27
  clearIconUrl,
@@ -1,7 +1,7 @@
1
1
  import { useEnvironment, useModuleDictionary, useModuleSkeleton } from "@m4l/core";
2
2
  import { useState, useEffect } from "react";
3
3
  import { A as ALL_FIELD } from "../../constants.js";
4
- import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../dictionary.js";
4
+ import { a as DICCTIONARY } from "../../dictionary.js";
5
5
  import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
6
6
  function useInputFilter() {
7
7
  const [selectedFieldIndex, setSelectedFieldIndex] = useState(-1);
@@ -123,7 +123,7 @@ function useInputFilter() {
123
123
  /**
124
124
  * Texto de placeholder del inputFilter
125
125
  */
126
- inputPlaceHolder: getLabel(getDynamicFilterDictionary(DICCTIONARY.input_placeholder)),
126
+ inputPlaceHolder: getLabel(DICCTIONARY.input_placeholder),
127
127
  /**
128
128
  * Texto del inputFilter
129
129
  */
@@ -1,16 +1,19 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { M as MenuItem } from "../../../mui_extended/MenuItem/MenuItem.js";
3
3
  import { u as usePopoverMenuFields } from "./usePopoverMenuFields.js";
4
4
  import { u as useDynamicFilterBase } from "../DynamicFilterBase/useDynamicFilterBase.js";
5
+ import { useModuleDictionary } from "@m4l/core";
6
+ import { a as DICCTIONARY } from "../../dictionary.js";
5
7
  import { u as usePopoverContainer } from "../../../../hooks/usePopoverContainer/usePopoverContainer.js";
6
8
  import { l as PopoverMenuStyled } from "../../slots/dynamicFilterSlots.js";
7
9
  function PopoverMenuFields(props) {
8
10
  const { fields, selectFieldIndex } = props;
9
11
  const { elementRef, handleOpenPopUpClickItem, handleClosePopover, getItemLabel, isOpenPopoverMenuFields } = usePopoverMenuFields();
10
12
  const anchorEl = elementRef?.current;
13
+ const { getLabel } = useModuleDictionary();
11
14
  const popoverContainerRef = usePopoverContainer();
12
15
  const { size } = useDynamicFilterBase();
13
- return /* @__PURE__ */ jsx(
16
+ return /* @__PURE__ */ jsxs(
14
17
  PopoverMenuStyled,
15
18
  {
16
19
  disableAutoFocus: true,
@@ -23,18 +26,29 @@ function PopoverMenuFields(props) {
23
26
  anchorEl,
24
27
  ownerState: {},
25
28
  container: popoverContainerRef.current,
26
- children: isOpenPopoverMenuFields && fields.map((field, index) => /* @__PURE__ */ jsx(
27
- MenuItem,
28
- {
29
- dense: true,
30
- size,
31
- selected: index === selectFieldIndex,
32
- onClick: (event) => handleOpenPopUpClickItem(event, field),
33
- startIcon: field.urlIcon,
34
- label: getItemLabel(field)
35
- },
36
- `menu_action_${getItemLabel(field)}`
37
- ))
29
+ children: [
30
+ isOpenPopoverMenuFields && fields.map((field, index) => /* @__PURE__ */ jsx(
31
+ MenuItem,
32
+ {
33
+ dense: true,
34
+ size,
35
+ selected: index === selectFieldIndex,
36
+ onClick: (event) => handleOpenPopUpClickItem(event, field),
37
+ startIcon: field.urlIcon,
38
+ label: getItemLabel(field)
39
+ },
40
+ `menu_action_${getItemLabel(field)}`
41
+ )),
42
+ isOpenPopoverMenuFields && fields.length === 0 && /* @__PURE__ */ jsx(
43
+ MenuItem,
44
+ {
45
+ dense: true,
46
+ size,
47
+ label: getLabel(DICCTIONARY.label_no_fields_available),
48
+ disabled: true
49
+ }
50
+ )
51
+ ]
38
52
  }
39
53
  );
40
54
  }