@m4l/components 9.2.18 → 9.2.20

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 (105) hide show
  1. package/components/DynamicFilter/DynamicFilter.d.ts +7 -3
  2. package/components/DynamicFilter/DynamicFilter.js +4 -3
  3. package/components/DynamicFilter/{DynamicFIlter.styles.d.ts → DynamicFilter.styles.d.ts} +1 -1
  4. package/components/DynamicFilter/{DynamicFIlter.styles.js → DynamicFilter.styles.js} +20 -2
  5. package/components/DynamicFilter/dictionary.d.ts +6 -1
  6. package/components/DynamicFilter/helpers/frontEndHelpers.js +2 -2
  7. package/components/DynamicFilter/index.d.ts +3 -3
  8. package/components/DynamicFilter/slots/dynamicFilterSlots.js +2 -2
  9. package/components/DynamicFilter/store/DynamicFilterContext.d.ts +4 -4
  10. package/components/DynamicFilter/store/DynamicFilterContext.js +25 -10
  11. package/components/DynamicFilter/store/DynamicFilterStore.js +32 -17
  12. package/components/DynamicFilter/store/types.d.ts +10 -33
  13. package/components/DynamicFilter/subcomponents/AppliedFilterChip/useAppliedFilterChip.js +1 -1
  14. package/components/DynamicFilter/subcomponents/AppliedFilters/AppliedFilters.d.ts +1 -1
  15. package/components/DynamicFilter/subcomponents/AppliedFilters/useAppliedFilters.d.ts +1 -1
  16. package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.d.ts +1 -1
  17. package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.js +3 -3
  18. package/components/DynamicFilter/subcomponents/DynamicFilterBase/useDynamicFilterBase.d.ts +4 -3
  19. package/components/DynamicFilter/subcomponents/DynamicFilterBase/useDynamicFilterBase.js +2 -1
  20. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.d.ts +9 -8
  21. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +7 -7
  22. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.d.ts +1 -1
  23. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.js +1 -1
  24. package/components/DynamicFilter/subcomponents/FieldTypes/DataTypeComponent.d.ts +2 -2
  25. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.d.ts +8 -8
  26. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +7 -7
  27. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index.js +1 -1
  28. package/components/DynamicFilter/subcomponents/FieldTypes/FieldTypeInterface.d.ts +2 -2
  29. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.d.ts +8 -8
  30. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +7 -7
  31. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index.js +2 -2
  32. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.d.ts +8 -8
  33. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +7 -7
  34. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/index.js +1 -1
  35. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.d.ts +6 -6
  36. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +5 -5
  37. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index.js +1 -1
  38. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.d.ts +8 -8
  39. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +7 -7
  40. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index.js +1 -1
  41. package/components/DynamicFilter/subcomponents/FieldTypes/fieldFactory.d.ts +3 -3
  42. package/components/DynamicFilter/subcomponents/FieldTypes/fieldFactory.js +1 -1
  43. package/components/DynamicFilter/subcomponents/FilterActions/FilterActions.js +5 -5
  44. package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.d.ts +1 -1
  45. package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.js +1 -1
  46. package/components/DynamicFilter/subcomponents/InputFilter/useInputFilter.d.ts +1 -1
  47. package/components/DynamicFilter/subcomponents/InputFilter/useInputFilter.js +2 -2
  48. package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.d.ts +1 -1
  49. package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +3 -3
  50. package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.d.ts +3 -3
  51. package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.js +2 -2
  52. package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.d.ts +1 -1
  53. package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.js +1 -1
  54. package/components/DynamicFilter/subcomponents/PopoverMenuFields/usePopoverMenuFields.d.ts +1 -1
  55. package/components/DynamicFilter/subcomponents/PopoverMenuFields/usePopoverMenuFields.js +1 -1
  56. package/components/DynamicFilter/types.d.ts +23 -8
  57. package/components/DynamicSort/DynamicSort.d.ts +2 -2
  58. package/components/DynamicSort/DynamicSort.js +4 -3
  59. package/components/DynamicSort/DynamicSort.styles.js +20 -2
  60. package/components/DynamicSort/dictionary.d.ts +6 -1
  61. package/components/DynamicSort/dictionary.js +2 -3
  62. package/components/DynamicSort/helpers/getPurgedInitialSortApplyed.d.ts +1 -1
  63. package/components/DynamicSort/index.d.ts +2 -2
  64. package/components/DynamicSort/store/DynamicSortContext.d.ts +3 -3
  65. package/components/DynamicSort/store/DynamicSortContext.js +24 -9
  66. package/components/DynamicSort/store/DynamicSortStore.d.ts +2 -2
  67. package/components/DynamicSort/store/DynamicSortStore.js +31 -16
  68. package/components/DynamicSort/store/types.d.ts +9 -15
  69. package/components/DynamicSort/subcomponents/AppliedSortChip/useAppliedSortChip.js +1 -1
  70. package/components/DynamicSort/subcomponents/AppliedSorts/AppliedSorts.js +1 -1
  71. package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +2 -3
  72. package/components/DynamicSort/subcomponents/DynamicSortBase/useDynamicSortBase.d.ts +2 -1
  73. package/components/DynamicSort/subcomponents/DynamicSortBase/useDynamicSortBase.js +2 -1
  74. package/components/DynamicSort/subcomponents/FieldTypes/DataTypeComponent.d.ts +1 -1
  75. package/components/DynamicSort/subcomponents/FieldTypes/FieldTypeInterface.d.ts +2 -2
  76. package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.d.ts +1 -1
  77. package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.js +1 -1
  78. package/components/DynamicSort/subcomponents/FieldTypes/StringSort/index.js +2 -2
  79. package/components/DynamicSort/subcomponents/InputSort/useInputSort.d.ts +1 -1
  80. package/components/DynamicSort/subcomponents/InputSort/useInputSort.js +3 -3
  81. package/components/DynamicSort/subcomponents/PopoverMenuFields/PopoverMenuFields.d.ts +1 -1
  82. package/components/DynamicSort/subcomponents/PopoverMenuFields/PopoverMenuFields.js +1 -1
  83. package/components/DynamicSort/subcomponents/PopoverMenuFields/usePopoverMenuFields.d.ts +1 -1
  84. package/components/DynamicSort/subcomponents/PopoverMenuFields/usePopoverMenuFields.js +1 -1
  85. package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.d.ts +1 -1
  86. package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.d.ts +2 -2
  87. package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.js +2 -2
  88. package/components/DynamicSort/subcomponents/SortActions/SortActions.d.ts +3 -1
  89. package/components/DynamicSort/subcomponents/SortActions/SortActions.js +7 -7
  90. package/components/DynamicSort/subcomponents/SortActions/useSortActions.d.ts +1 -1
  91. package/components/DynamicSort/subcomponents/SortActions/useSortActions.js +2 -2
  92. package/components/DynamicSort/types.d.ts +25 -8
  93. package/components/mui_extended/CheckBox/CheckBox.styles.js +1 -2
  94. package/hooks/useDynamicFilterAndSort/styles.js +4 -2
  95. package/hooks/useDynamicFilterAndSort/types.d.ts +2 -1
  96. package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js +31 -9
  97. package/index.js +29 -29
  98. package/package.json +1 -1
  99. package/storybook/components/DataGrid/DataGrid.stories.d.ts +8 -2
  100. package/storybook/components/DataGrid/subcomponents/DataGridRender.d.ts +2 -0
  101. package/storybook/components/DynamicFilter/DynamicFilter.stories.d.ts +4 -0
  102. package/storybook/components/DynamicSort/DynamicSort.stories.d.ts +5 -1
  103. package/test/constants.d.ts +0 -2
  104. package/test/mocks.d.ts +2 -0
  105. /package/components/DynamicSort/{slots → store}/tests/DynamicSort.test.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
2
  import { useModuleDictionary } from "@m4l/core";
3
+ import { useMemo } from "react";
4
4
  import { c as STRING_OPERATORS } from "../../../constants.js";
5
5
  import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../../dictionary.js";
6
6
  import { R as RHFAutocomplete } from "../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
@@ -1,11 +1,11 @@
1
1
  import { FieldType } from '../../types';
2
2
  import { BooleanFilterHelpers } from './BooleanFilter/helpers';
3
- import { StringFilterHelpers } from './StringFilter/helpers';
4
3
  import { DateTimeFilterHelpers } from './DateTimeFilter/helpers';
5
4
  import { NumberFilterHelpers } from './NumberFilter/helpers';
6
5
  import { SelectAsyncFilterHelpers } from './SelectAsyncFilter/helpers';
7
6
  import { SelectFilterHelpers } from './SelectFilter/helpers';
7
+ import { StringFilterHelpers } from './StringFilter/helpers';
8
8
  /**
9
- * TODO: Documentar
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 | StringFilterHelpers | DateTimeFilterHelpers | NumberFilterHelpers | SelectFilterHelpers;
11
+ export declare function fieldFactory(type: FieldType): SelectAsyncFilterHelpers | BooleanFilterHelpers | DateTimeFilterHelpers | NumberFilterHelpers | SelectFilterHelpers | StringFilterHelpers;
@@ -1,9 +1,9 @@
1
1
  import { B as BooleanFilterHelpers } from "./BooleanFilter/helpers.js";
2
- import { S as StringFilterHelpers } from "./StringFilter/helpers.js";
3
2
  import { D as DateTimeFilterHelpers } from "./DateTimeFilter/helpers.js";
4
3
  import { N as NumberFilterHelpers } from "./NumberFilter/helpers.js";
5
4
  import { S as SelectAsyncFilterHelpers } from "./SelectAsyncFilter/helpers.js";
6
5
  import { S as SelectFilterHelpers } from "./SelectFilter/helpers.js";
6
+ import { S as StringFilterHelpers } from "./StringFilter/helpers.js";
7
7
  const helpersStrategies = {
8
8
  boolean: new BooleanFilterHelpers(),
9
9
  string: new StringFilterHelpers(),
@@ -12,8 +12,8 @@ function FilterActions() {
12
12
  filterButtonDictionaryTooltip,
13
13
  ownerState
14
14
  } = useFilterActions();
15
- const { size } = useDynamicFilterBase();
16
- return /* @__PURE__ */ jsxs(ActionsStyled, { ownerState: {}, children: [
15
+ const { size, ownerState: { isDirty }, visibleRefresh } = useDynamicFilterBase();
16
+ return /* @__PURE__ */ jsxs(ActionsStyled, { ownerState: { isDirty: canShowRemoveAction, visibleRefresh }, children: [
17
17
  canShowRemoveAction && /* @__PURE__ */ jsx(
18
18
  ActionsClearButtonStyled,
19
19
  {
@@ -24,7 +24,7 @@ function FilterActions() {
24
24
  ownerState: {}
25
25
  }
26
26
  ),
27
- /* @__PURE__ */ jsx(
27
+ visibleRefresh ? /* @__PURE__ */ jsx(
28
28
  ActionsSubmitButtonStyled,
29
29
  {
30
30
  icon: filterIconUrl,
@@ -32,9 +32,9 @@ function FilterActions() {
32
32
  "aria-label": "settings",
33
33
  dictionaryTooltipId: filterButtonDictionaryTooltip,
34
34
  onClick: onClickFilter,
35
- ownerState: { ...ownerState }
35
+ ownerState: { ...ownerState, isDirty }
36
36
  }
37
- )
37
+ ) : null
38
38
  ] });
39
39
  }
40
40
  export {
@@ -4,7 +4,7 @@ export declare const ASSETS: {
4
4
  readonly search: "search.svg";
5
5
  };
6
6
  /**
7
- * TODO: Documentar
7
+ * useFilterActions es un hook que se encarga de manejar las acciones del filtro
8
8
  */
9
9
  declare function useFilterActions(): {
10
10
  filterIconUrl: string;
@@ -1,6 +1,6 @@
1
1
  import { useEnvironment } from "@m4l/core";
2
- import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
3
2
  import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../dictionary.js";
3
+ import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
4
4
  const ASSETS_URL = "frontend/components/dynamic_filter/assets/icons";
5
5
  const ASSETS = {
6
6
  refresh: "restart.svg",
@@ -1,7 +1,7 @@
1
1
  import { ChangeEvent, FocusEvent, KeyboardEvent } from 'react';
2
2
  import { FilterField } from '../../types';
3
3
  /**
4
- * TODO: Documentar
4
+ * Hook manejador de eventos para el componente InputFilter
5
5
  */
6
6
  declare function useInputFilter(): {
7
7
  /**
@@ -1,8 +1,8 @@
1
- import { useState, useEffect } from "react";
2
1
  import { useEnvironment, useModuleDictionary, useModuleSkeleton } from "@m4l/core";
2
+ import { useState, useEffect } from "react";
3
+ import { A as ALL_FIELD } from "../../constants.js";
3
4
  import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../../dictionary.js";
4
5
  import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
5
- import { A as ALL_FIELD } from "../../constants.js";
6
6
  function useInputFilter() {
7
7
  const [selectedFieldIndex, setSelectedFieldIndex] = useState(-1);
8
8
  const [filteredFields, setFilteredFields] = useState([]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TODO: Documentar
2
+ * PopoverFilter: Componente que renderiza el popover de filtros
3
3
  */
4
4
  declare function PopoverFilter(): import("react/jsx-runtime").JSX.Element | null;
5
5
  export default PopoverFilter;
@@ -1,8 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { u as usePopoverFilter } from "./usePopoverFilter.js";
3
- import { D as DataTypeComponent } from "../FieldTypes/DataTypeComponent.js";
4
- import { u as useDynamicFilterBase } from "../DynamicFilterBase/useDynamicFilterBase.js";
5
2
  import { I as Icon } from "../../../Icon/Icon.js";
3
+ import { u as useDynamicFilterBase } from "../DynamicFilterBase/useDynamicFilterBase.js";
4
+ import { D as DataTypeComponent } from "../FieldTypes/DataTypeComponent.js";
5
+ import { u as usePopoverFilter } from "./usePopoverFilter.js";
6
6
  import { P as PopoverStyled, h as PopoverHeaderStyled, i as PopoverHeaderTitleStyled, C as ContentFilterStyled, j as PopoverContainerFieldsStyled, k as PopoverHeaderActionsStyled } from "../../slots/dynamicFilterSlots.js";
7
7
  import { R as RHFormProvider } from "../../../hook-form/RHFormContext/index.js";
8
8
  import { A as ActionCancel } from "../../../CommonActions/components/ActionCancel/ActionCancel.js";
@@ -1,9 +1,9 @@
1
+ import { Maybe } from '@m4l/core';
1
2
  import { KeyboardEvent } from 'react';
2
3
  import { FieldValues } from 'react-hook-form';
3
- import { Maybe } from '@m4l/core';
4
- import { FormFilterFieldApplied, FilterField, FormFilterValue } from '../../types';
4
+ import { FilterField, FormFilterFieldApplied, FormFilterValue } from '../../types';
5
5
  /**
6
- * TODO: Documentar
6
+ * usePopoverFilter: Hook que maneja el estado del popover de filtros
7
7
  */
8
8
  declare function usePopoverFilter(): {
9
9
  field: FilterField;
@@ -1,8 +1,8 @@
1
- import { useRef, useMemo, useCallback } from "react";
2
1
  import { useModuleDictionary } from "@m4l/core";
2
+ import { useRef, useMemo, useCallback } from "react";
3
+ import { shallow } from "zustand/shallow";
3
4
  import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
4
5
  import { f as fieldFactory } from "../FieldTypes/fieldFactory.js";
5
- import { shallow } from "zustand/shallow";
6
6
  function usePopoverFilter() {
7
7
  let anchorEl;
8
8
  let field;
@@ -4,7 +4,7 @@ export type PopoverMenuFieldsProps = {
4
4
  fields: FilterField[];
5
5
  };
6
6
  /**
7
- * TODO: Documentar
7
+ * PopoverMenuFields: Componente encargado de mostrar el menú de campos para filtrar
8
8
  */
9
9
  declare function PopoverMenuFields(props: PopoverMenuFieldsProps): import("react/jsx-runtime").JSX.Element;
10
10
  export default PopoverMenuFields;
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { M as MenuItem } from "../../../mui_extended/MenuItem/MenuItem.js";
2
3
  import { u as usePopoverMenuFields } from "./usePopoverMenuFields.js";
3
4
  import { useRef, useEffect } from "react";
4
5
  import { d as DYNAMIC_FILTER_POPOVER_CONTAINER_ID } from "../../constants.js";
5
6
  import { u as useDynamicFilterBase } from "../DynamicFilterBase/useDynamicFilterBase.js";
6
- import { M as MenuItem } from "../../../mui_extended/MenuItem/MenuItem.js";
7
7
  import { l as PopoverMenuStyled } from "../../slots/dynamicFilterSlots.js";
8
8
  function PopoverMenuFields(props) {
9
9
  const { fields, selectFieldIndex } = props;
@@ -1,7 +1,7 @@
1
1
  import { MouseEvent } from 'react';
2
2
  import { FilterField } from '../../types';
3
3
  /**
4
- * TODO: Documentar
4
+ * usePopoverMenuFields: Hook que maneja el estado del popover de campos
5
5
  */
6
6
  declare function usePopoverMenuFields(): {
7
7
  elementRef: import('react').MutableRefObject<HTMLElement | null> | null;
@@ -1,6 +1,6 @@
1
1
  import { useModuleDictionary } from "@m4l/core";
2
- import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
3
2
  import { shallow } from "zustand/shallow";
3
+ import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
4
4
  function usePopoverMenuFields() {
5
5
  const { getLabel } = useModuleDictionary();
6
6
  const elementRef = useDynamicFilterStore((state) => state.actions.getElementRef(), shallow);
@@ -1,10 +1,10 @@
1
+ import { Maybe } from '@m4l/core';
1
2
  import { Sizes } from '@m4l/styles';
2
3
  import { Theme } from '@mui/material/styles';
3
- import { Maybe } from '@m4l/core';
4
+ import { M4LOverridesStyleRules } from '../../@types/augmentations';
4
5
  import { RHFAutocompleteAsyncBaseProps } from '../hook-form/RHFAutocompleteAsync/types';
5
- import { DynamicFilterSlots } from './slots';
6
6
  import { RHFSelectProps } from '../hook-form/RHFSelect';
7
- import { M4LOverridesStyleRules } from '../../@types/augmentations';
7
+ import { DynamicFilterSlots } from './slots';
8
8
  export type FieldType = 'number' | 'string' | 'boolean' | 'datetime' | 'select' | 'selectAsync';
9
9
  export type OperandType = number | string | boolean | Date | [] | object;
10
10
  export type OperandInitialFilterType = number | string | boolean | [] | object;
@@ -248,23 +248,35 @@ export interface DynamicFilterProps {
248
248
  * @default true
249
249
  */
250
250
  withAllField?: boolean;
251
- /** Array con la configuración de cada campo por el que se podrá filtrar. */
251
+ /**
252
+ * Array con la configuración de cada campo por el que se podrá filtrar.
253
+ */
252
254
  fields: Array<FilterField>;
253
- /** Array con la configuración de cada campo por el que se podrá filtrar.*/
255
+ /**
256
+ * Array con la configuración de cada campo por el que se podrá filtrar.
257
+ */
254
258
  initialAppliedFilters?: Array<InitialFilterApplied>;
255
- /** Handler que se dispara cuando el filtro cambia en automatico, o cuando es manual y se presion el boton de filtrar */
259
+ /**
260
+ * Handler que se dispara cuando el filtro cambia en automatico, o cuando es manual y se presion el boton de filtrar
261
+ */
256
262
  onChangeFilters?: OnChangeFilters;
257
- /** Key único necesario para las pruebas del componente. */
263
+ /**
264
+ * Key único necesario para las pruebas del componente.
265
+ */
258
266
  dataTestId?: string;
259
267
  /**
260
268
  * Size del componente
261
269
  */
262
270
  size?: Extract<Sizes, 'small' | 'medium'>;
271
+ /**
272
+ * visibleRefresh: indica si el boton de refresh debe estar visible
273
+ */
274
+ visibleRefresh?: boolean;
263
275
  }
264
276
  /**
265
277
  * Interface que define la variables que se van a usar en clases del componente
266
278
  */
267
- export interface OwnerState {
279
+ export interface OwnerState extends Pick<DynamicFilterProps, 'visibleRefresh'> {
268
280
  /**
269
281
  * "isSkeleton" indica si el componente está estado skeleton.
270
282
  */
@@ -298,4 +310,7 @@ export interface DynamicFilterOwnerState extends DynamicFilterProps, OwnerState
298
310
  }
299
311
  export type DynamicFilterSlotsType = keyof typeof DynamicFilterSlots;
300
312
  export type DynamicFilterStyles = M4LOverridesStyleRules<DynamicFilterSlotsType, 'M4LDynamicFilter', Theme>;
313
+ export interface DynamicFilterRef {
314
+ fireOnChangeFilter: () => void;
315
+ }
301
316
  export {};
@@ -1,8 +1,8 @@
1
- import { DynamicSortProps } from './types';
1
+ import { DynamicSortProps, DynamicSortRef } from './types';
2
2
  /**
3
3
  * El DynamicSort es un componente que permite ordenar de manera acendentente o descendente una lista de elementos.
4
4
  *
5
5
  * ### Dependecias:
6
6
  *- **`useFlagsPresent:`** Hook que permite verificar si una lista de flags se encuentran presentes.
7
7
  */
8
- export declare function DynamicSort(props: DynamicSortProps): import("react/jsx-runtime").JSX.Element | null;
8
+ export declare const DynamicSort: import('react').ForwardRefExoticComponent<DynamicSortProps & import('react').RefAttributes<DynamicSortRef>>;
@@ -1,14 +1,15 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useFlagsPresent, CommonFlags } from "@m4l/core";
3
+ import { forwardRef } from "react";
3
4
  import { D as DynamicSortProvider } from "./store/DynamicSortContext.js";
4
5
  import { D as DynamicSortBase } from "./subcomponents/DynamicSortBase/DynamicSortBase.js";
5
- function DynamicSort(props) {
6
+ const DynamicSort = forwardRef((props, ref) => {
6
7
  const hasPresentFlags = useFlagsPresent([CommonFlags.FLAG_DICTIONARY_LOADED]);
7
8
  if (!hasPresentFlags) {
8
9
  return null;
9
10
  }
10
- return /* @__PURE__ */ jsx(DynamicSortProvider, { ...props, children: /* @__PURE__ */ jsx(DynamicSortBase, {}) });
11
- }
11
+ return /* @__PURE__ */ jsx(DynamicSortProvider, { ...props, ref, children: /* @__PURE__ */ jsx(DynamicSortBase, {}) });
12
+ });
12
13
  export {
13
14
  DynamicSort as D
14
15
  };
@@ -131,7 +131,7 @@ const dynamicSortStyles = {
131
131
  /**
132
132
  * actions: Estilos del contenedor de los botones de acción.
133
133
  */
134
- actions: ({ theme }) => ({
134
+ actions: ({ theme, ownerState }) => ({
135
135
  gridArea: "actions-sort",
136
136
  overflow: "hidden",
137
137
  display: "flex",
@@ -142,7 +142,7 @@ const dynamicSortStyles = {
142
142
  alignItems: "center",
143
143
  borderTopRightRadius: theme.vars.size.borderRadius.r1,
144
144
  borderBottomRightRadius: theme.vars.size.borderRadius.r1,
145
- borderLeft: theme.vars.size.borderStroke.container,
145
+ borderLeft: !ownerState.visibleRefresh && !ownerState.isDirty ? "none" : theme.vars.size.borderStroke.container,
146
146
  borderColor: theme.vars.palette.border?.default
147
147
  }),
148
148
  actionsClearButton: {
@@ -154,6 +154,24 @@ const dynamicSortStyles = {
154
154
  actionsSubmitButton: ({ theme, ownerState }) => ({
155
155
  ...ownerState.isValid === false ? { border: `1px dashed ${theme.vars.palette.error.enabled}` } : {
156
156
  visibility: "visible"
157
+ },
158
+ ...ownerState.isDirty ? {
159
+ animation: "changeBgColor 0.9s ease infinite",
160
+ "& .M4LIcon-icon": {
161
+ background: `${theme.vars.palette.primary.main} !important`
162
+ }
163
+ } : null,
164
+ //Create and apply animation with change background color red and green
165
+ "@keyframes changeBgColor": {
166
+ "0%": {
167
+ background: theme.vars.palette.primary.hoverOpacity
168
+ },
169
+ "50%": {
170
+ background: theme.vars.palette.primary.activeOpacity
171
+ },
172
+ "100%": {
173
+ background: theme.vars.palette.primary.hoverOpacity
174
+ }
157
175
  }
158
176
  }),
159
177
  /**
@@ -1,6 +1,7 @@
1
1
  export declare const DYNAMICSORT_DICTIONARY_ID = "dynamic_sort";
2
2
  /**
3
- * TODO: Documentar
3
+ * getDynamicSortComponentsDictionary: Devuelve un array con los ids de los componentes que
4
+ * componente DynamicSort.
4
5
  */
5
6
  export declare function getDynamicSortComponentsDictionary(): string[];
6
7
  export declare const DICCTIONARY: {
@@ -16,4 +17,8 @@ export declare const DICCTIONARY: {
16
17
  readonly label_boolean_operand1: "label_boolean_operand1";
17
18
  };
18
19
  export type TypeDictionary = typeof DICCTIONARY;
20
+ /**
21
+ * getDynamicSortDictionary: Devuelve el id del diccionario de un componente DynamicSort.
22
+ * @param key - Clave del diccionario.
23
+ */
19
24
  export declare const getDynamicSortDictionary: (key: keyof TypeDictionary) => string;
@@ -22,8 +22,7 @@ const getDynamicSortDictionary = (key) => {
22
22
  return `${DYNAMICSORT_DICTIONARY_ID}.${key}`;
23
23
  };
24
24
  export {
25
- DYNAMICSORT_DICTIONARY_ID as D,
26
- DICCTIONARY as a,
27
- getDynamicSortComponentsDictionary as b,
25
+ DICCTIONARY as D,
26
+ getDynamicSortComponentsDictionary as a,
28
27
  getDynamicSortDictionary as g
29
28
  };
@@ -1,4 +1,4 @@
1
- import { SortField, SortFieldApplied, InitialSortApplied } from '../types';
1
+ import { InitialSortApplied, SortField, SortFieldApplied } from '../types';
2
2
  /**
3
3
  * Función encargada de purgar cualquier error que pueda venir del endpoint, por algun cambio de versión
4
4
  * @param fields todos los campos que pueden aparecer en el sort
@@ -1,4 +1,4 @@
1
- export * from './DynamicSort';
2
1
  export { getDynamicSortComponentsDictionary } from './dictionary';
3
- export type { SortFieldApplied, RawSortFieldApply, InitialSortApplied, SortField, SortFieldType, SortOperator, } from './types';
2
+ export * from './DynamicSort';
4
3
  export { SortCompareValues } from './helpers/frontEndHelpers';
4
+ export type { InitialSortApplied, RawSortFieldApply, SortField, SortFieldApplied, SortFieldType, SortOperator, } from './types';
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { DynamicSortProps } from '../types';
2
+ import { DynamicSortProps, DynamicSortRef } from '../types';
3
3
  declare const DynamicSortContext: import('react').Context<(Omit<Omit<import('zustand').StoreApi<import('./types').DynamicSortStateWithActions>, "setState"> & {
4
4
  setState<A extends string | {
5
5
  type: unknown;
@@ -17,5 +17,5 @@ interface DynamicSortContextProps extends DynamicSortProps {
17
17
  * @param props DynamicSortProps
18
18
  * @returns Proveedor de contexto, y el contexto
19
19
  */
20
- declare function DynamicSortProvider(props: DynamicSortContextProps): import("react/jsx-runtime").JSX.Element;
21
- export { DynamicSortProvider, DynamicSortContext };
20
+ declare const DynamicSortProvider: import('react').ForwardRefExoticComponent<DynamicSortContextProps & import('react').RefAttributes<DynamicSortRef>>;
21
+ export { DynamicSortContext, DynamicSortProvider };
@@ -1,14 +1,14 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { createContext, useRef, useEffect } from "react";
2
+ import { useModuleDictionary } from "@m4l/core";
3
+ import { createContext, forwardRef, useRef, useImperativeHandle, useEffect } from "react";
3
4
  import { useStore } from "zustand";
4
5
  import { shallow } from "zustand/shallow";
5
- import { useModuleDictionary } from "@m4l/core";
6
6
  import { f as formatToInitialSorts } from "../helpers/formatToInitialSorts.js";
7
7
  import { f as formatToRowSort } from "../helpers/formatToRowSort.js";
8
- import { c as createAreaStore } from "./DynamicSortStore.js";
8
+ import { c as createDynamicSortStore } from "./DynamicSortStore.js";
9
9
  import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
10
10
  const DynamicSortContext = createContext(null);
11
- function DynamicSortProvider(props) {
11
+ const DynamicSortProvider = forwardRef((props, ref) => {
12
12
  const {
13
13
  automatic = true,
14
14
  fields,
@@ -18,6 +18,7 @@ function DynamicSortProvider(props) {
18
18
  size = "medium",
19
19
  storeId,
20
20
  storeDevtoolsEnabled,
21
+ visibleRefresh = true,
21
22
  children
22
23
  } = props;
23
24
  const { currentSize } = useComponentSize(size);
@@ -25,15 +26,16 @@ function DynamicSortProvider(props) {
25
26
  const { getLabel } = useModuleDictionary();
26
27
  const dynamicSortStoreRef = useRef();
27
28
  if (!dynamicSortStoreRef.current) {
28
- dynamicSortStoreRef.current = createAreaStore({
29
+ dynamicSortStoreRef.current = createDynamicSortStore({
29
30
  fields,
30
31
  automatic,
31
32
  getLabel,
32
33
  dataTestId,
33
34
  size,
34
35
  storeId,
36
+ visibleRefresh,
35
37
  ownerState: {
36
- isDirty: !automatic,
38
+ isDirty: false,
37
39
  inEdition: false,
38
40
  isValid: true,
39
41
  isEmpty: true,
@@ -42,6 +44,14 @@ function DynamicSortProvider(props) {
42
44
  }, storeDevtoolsEnabled);
43
45
  dynamicSortStoreRef.current.getState().actions.init(initialAppliedSorts);
44
46
  }
47
+ const fireOnChangeSort = useStore(
48
+ dynamicSortStoreRef.current,
49
+ (state) => state.actions.fireOnChangeSorts,
50
+ shallow
51
+ );
52
+ useImperativeHandle(ref, () => ({
53
+ fireOnChangeSort
54
+ }));
45
55
  const countOnChangeSortsApplyed = useStore(
46
56
  dynamicSortStoreRef.current,
47
57
  (state) => state.countOnChangeSortsApplyed,
@@ -60,10 +70,15 @@ function DynamicSortProvider(props) {
60
70
  }
61
71
  }, [countOnChangeSortsApplyed]);
62
72
  useEffect(() => {
63
- dynamicSortStoreRef.current?.getState().actions.setSize(adjustedSize);
64
- }, [adjustedSize]);
73
+ if (dynamicSortStoreRef.current?.getState().size !== adjustedSize) {
74
+ dynamicSortStoreRef.current?.getState().actions.setSize(adjustedSize);
75
+ }
76
+ if (dynamicSortStoreRef.current?.getState().visibleRefresh !== visibleRefresh) {
77
+ dynamicSortStoreRef.current?.getState().actions.setVisibleRefresh(visibleRefresh);
78
+ }
79
+ }, [adjustedSize, visibleRefresh]);
65
80
  return /* @__PURE__ */ jsx(DynamicSortContext.Provider, { value: dynamicSortStoreRef.current, children });
66
- }
81
+ });
67
82
  export {
68
83
  DynamicSortProvider as D,
69
84
  DynamicSortContext as a
@@ -6,7 +6,7 @@ export type OpenFor = 'add' | 'edit';
6
6
  * @param initProps Variables iniciales que necesita store para poder inicializarlo
7
7
  * @returns
8
8
  */
9
- export declare const createAreaStore: (initProps: InitialStoreProps, storeDevtoolsEnabled?: boolean) => Omit<Omit<import('zustand').StoreApi<DynamicSortStateWithActions>, "setState"> & {
9
+ export declare const createDynamicSortStore: (initProps: InitialStoreProps, storeDevtoolsEnabled?: boolean) => Omit<Omit<import('zustand').StoreApi<DynamicSortStateWithActions>, "setState"> & {
10
10
  setState<A extends string | {
11
11
  type: unknown;
12
12
  }>(partial: DynamicSortStateWithActions | Partial<DynamicSortStateWithActions> | ((state: DynamicSortStateWithActions) => DynamicSortStateWithActions | Partial<DynamicSortStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
@@ -15,4 +15,4 @@ export declare const createAreaStore: (initProps: InitialStoreProps, storeDevtoo
15
15
  type: unknown;
16
16
  } | undefined): void;
17
17
  };
18
- export type DynamicSortStore = ReturnType<typeof createAreaStore>;
18
+ export type DynamicSortStore = ReturnType<typeof createDynamicSortStore>;