@m4l/components 9.2.18 → 9.2.19
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.
- package/components/DynamicFilter/DynamicFilter.d.ts +7 -3
- package/components/DynamicFilter/DynamicFilter.js +4 -3
- package/components/DynamicFilter/{DynamicFIlter.styles.d.ts → DynamicFilter.styles.d.ts} +1 -1
- package/components/DynamicFilter/{DynamicFIlter.styles.js → DynamicFilter.styles.js} +20 -2
- package/components/DynamicFilter/dictionary.d.ts +6 -1
- package/components/DynamicFilter/helpers/frontEndHelpers.js +2 -2
- package/components/DynamicFilter/index.d.ts +3 -3
- package/components/DynamicFilter/slots/dynamicFilterSlots.js +2 -2
- package/components/DynamicFilter/store/DynamicFilterContext.d.ts +4 -4
- package/components/DynamicFilter/store/DynamicFilterContext.js +25 -10
- package/components/DynamicFilter/store/DynamicFilterStore.js +32 -17
- package/components/DynamicFilter/store/types.d.ts +10 -33
- package/components/DynamicFilter/subcomponents/AppliedFilterChip/useAppliedFilterChip.js +1 -1
- package/components/DynamicFilter/subcomponents/AppliedFilters/AppliedFilters.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/AppliedFilters/useAppliedFilters.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.js +3 -3
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/useDynamicFilterBase.d.ts +4 -3
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/useDynamicFilterBase.js +2 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.d.ts +9 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +7 -7
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index.js +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/DataTypeComponent.d.ts +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.d.ts +8 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +7 -7
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index.js +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/FieldTypeInterface.d.ts +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.d.ts +8 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +7 -7
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index.js +2 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.d.ts +8 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +7 -7
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/index.js +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.d.ts +6 -6
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +5 -5
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index.js +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.d.ts +8 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +7 -7
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index.js +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/fieldFactory.d.ts +3 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/fieldFactory.js +1 -1
- package/components/DynamicFilter/subcomponents/FilterActions/FilterActions.js +5 -5
- package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/FilterActions/useFilterActions.js +1 -1
- package/components/DynamicFilter/subcomponents/InputFilter/useInputFilter.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/InputFilter/useInputFilter.js +2 -2
- package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +3 -3
- package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.d.ts +3 -3
- package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.js +2 -2
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.js +1 -1
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/usePopoverMenuFields.d.ts +1 -1
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/usePopoverMenuFields.js +1 -1
- package/components/DynamicFilter/types.d.ts +23 -8
- package/components/DynamicSort/DynamicSort.d.ts +2 -2
- package/components/DynamicSort/DynamicSort.js +4 -3
- package/components/DynamicSort/DynamicSort.styles.js +20 -2
- package/components/DynamicSort/dictionary.d.ts +6 -1
- package/components/DynamicSort/dictionary.js +2 -3
- package/components/DynamicSort/helpers/getPurgedInitialSortApplyed.d.ts +1 -1
- package/components/DynamicSort/index.d.ts +2 -2
- package/components/DynamicSort/store/DynamicSortContext.d.ts +3 -3
- package/components/DynamicSort/store/DynamicSortContext.js +24 -9
- package/components/DynamicSort/store/DynamicSortStore.d.ts +2 -2
- package/components/DynamicSort/store/DynamicSortStore.js +31 -16
- package/components/DynamicSort/store/types.d.ts +9 -15
- package/components/DynamicSort/subcomponents/AppliedSortChip/useAppliedSortChip.js +1 -1
- package/components/DynamicSort/subcomponents/AppliedSorts/AppliedSorts.js +1 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +2 -3
- package/components/DynamicSort/subcomponents/DynamicSortBase/useDynamicSortBase.d.ts +2 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/useDynamicSortBase.js +2 -1
- package/components/DynamicSort/subcomponents/FieldTypes/DataTypeComponent.d.ts +1 -1
- package/components/DynamicSort/subcomponents/FieldTypes/FieldTypeInterface.d.ts +2 -2
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.d.ts +1 -1
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.js +1 -1
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/index.js +2 -2
- package/components/DynamicSort/subcomponents/InputSort/useInputSort.d.ts +1 -1
- package/components/DynamicSort/subcomponents/InputSort/useInputSort.js +3 -3
- package/components/DynamicSort/subcomponents/PopoverMenuFields/PopoverMenuFields.d.ts +1 -1
- package/components/DynamicSort/subcomponents/PopoverMenuFields/PopoverMenuFields.js +1 -1
- package/components/DynamicSort/subcomponents/PopoverMenuFields/usePopoverMenuFields.d.ts +1 -1
- package/components/DynamicSort/subcomponents/PopoverMenuFields/usePopoverMenuFields.js +1 -1
- package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.d.ts +1 -1
- package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.d.ts +2 -2
- package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.js +2 -2
- package/components/DynamicSort/subcomponents/SortActions/SortActions.d.ts +3 -1
- package/components/DynamicSort/subcomponents/SortActions/SortActions.js +7 -7
- package/components/DynamicSort/subcomponents/SortActions/useSortActions.d.ts +1 -1
- package/components/DynamicSort/subcomponents/SortActions/useSortActions.js +2 -2
- package/components/DynamicSort/types.d.ts +25 -8
- package/hooks/useDynamicFilterAndSort/styles.js +4 -2
- package/hooks/useDynamicFilterAndSort/types.d.ts +2 -1
- package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js +31 -9
- package/index.js +29 -29
- package/package.json +1 -1
- package/storybook/components/DataGrid/DataGrid.stories.d.ts +8 -2
- package/storybook/components/DataGrid/subcomponents/DataGridRender.d.ts +2 -0
- package/storybook/components/DynamicFilter/DynamicFilter.stories.d.ts +4 -0
- package/storybook/components/DynamicSort/DynamicSort.stories.d.ts +5 -1
- /package/components/DynamicSort/{slots → store}/tests/DynamicSort.test.d.ts +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { DynamicFilterProps } from './types';
|
|
1
|
+
import { DynamicFilterProps, DynamicFilterRef } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* DynamicFilter: Componente que renderiza filtros dinámicos para una lista de elementos.
|
|
4
|
+
*
|
|
5
|
+
* ### Dependecias:
|
|
6
|
+
*- **`useFlagsPresent:`** Hook que permite verificar si una lista de flags se encuentran presentes.
|
|
7
|
+
*
|
|
4
8
|
*/
|
|
5
|
-
export declare
|
|
9
|
+
export declare const DynamicFilter: import('react').ForwardRefExoticComponent<DynamicFilterProps & import('react').RefAttributes<DynamicFilterRef>>;
|
|
@@ -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 DynamicFilterProvider } from "./store/DynamicFilterContext.js";
|
|
4
5
|
import { D as DynamicFilterBase } from "./subcomponents/DynamicFilterBase/DynamicFilterBase.js";
|
|
5
|
-
|
|
6
|
+
const DynamicFilter = 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(DynamicFilterProvider, { ...props, children: /* @__PURE__ */ jsx(DynamicFilterBase, {}) });
|
|
11
|
-
}
|
|
11
|
+
return /* @__PURE__ */ jsx(DynamicFilterProvider, { ...props, ref, children: /* @__PURE__ */ jsx(DynamicFilterBase, {}) });
|
|
12
|
+
});
|
|
12
13
|
export {
|
|
13
14
|
DynamicFilter as D
|
|
14
15
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DynamicFilterStyles } from '
|
|
1
|
+
import { DynamicFilterStyles } from './types';
|
|
2
2
|
export declare const dynamicFilterStyles: DynamicFilterStyles;
|
|
@@ -128,7 +128,7 @@ const dynamicFilterStyles = {
|
|
|
128
128
|
/**
|
|
129
129
|
* actions: Estilos del contenedor de los botones de acción.
|
|
130
130
|
*/
|
|
131
|
-
actions: ({ theme }) => ({
|
|
131
|
+
actions: ({ theme, ownerState }) => ({
|
|
132
132
|
gridArea: "actions-filter",
|
|
133
133
|
overflow: "hidden",
|
|
134
134
|
display: "flex",
|
|
@@ -139,7 +139,7 @@ const dynamicFilterStyles = {
|
|
|
139
139
|
alignItems: "center",
|
|
140
140
|
borderTopRightRadius: theme.vars.size.borderRadius.r1,
|
|
141
141
|
borderBottomRightRadius: theme.vars.size.borderRadius.r1,
|
|
142
|
-
borderLeft: theme.vars.size.borderStroke.container,
|
|
142
|
+
borderLeft: !ownerState.visibleRefresh && !ownerState.isDirty ? "none" : theme.vars.size.borderStroke.container,
|
|
143
143
|
borderColor: theme.vars.palette.border?.default
|
|
144
144
|
}),
|
|
145
145
|
actionsClearButton: {
|
|
@@ -151,6 +151,24 @@ const dynamicFilterStyles = {
|
|
|
151
151
|
actionsSubmitButton: ({ theme, ownerState }) => ({
|
|
152
152
|
...ownerState.isValid === false ? { border: `1px dashed ${theme.vars.palette.error.enabled}` } : {
|
|
153
153
|
visibility: "visible"
|
|
154
|
+
},
|
|
155
|
+
...ownerState.isDirty ? {
|
|
156
|
+
animation: "changeBgColor 0.9s ease infinite",
|
|
157
|
+
"& .M4LIcon-icon": {
|
|
158
|
+
background: `${theme.vars.palette.primary.main} !important`
|
|
159
|
+
}
|
|
160
|
+
} : null,
|
|
161
|
+
//Create and apply animation with change background color red and green
|
|
162
|
+
"@keyframes changeBgColor": {
|
|
163
|
+
"0%": {
|
|
164
|
+
background: theme.vars.palette.primary.hoverOpacity
|
|
165
|
+
},
|
|
166
|
+
"50%": {
|
|
167
|
+
background: theme.vars.palette.primary.activeOpacity
|
|
168
|
+
},
|
|
169
|
+
"100%": {
|
|
170
|
+
background: theme.vars.palette.primary.hoverOpacity
|
|
171
|
+
}
|
|
154
172
|
}
|
|
155
173
|
}),
|
|
156
174
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const DYNAMIC_FILTER_DICTIONARY_ID = "dynamic_filter";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* getDynamicFilterComponentsDictionary: Devuelve un array con los ids de los componentes que
|
|
4
|
+
* componente DynamicFilter.
|
|
4
5
|
*/
|
|
5
6
|
export declare function getDynamicFilterComponentsDictionary(): string[];
|
|
6
7
|
export declare const DICCTIONARY: {
|
|
@@ -39,4 +40,8 @@ export declare const DICCTIONARY: {
|
|
|
39
40
|
readonly error_operand_required: "error_operand_required";
|
|
40
41
|
};
|
|
41
42
|
export type TypeDictionary = typeof DICCTIONARY;
|
|
43
|
+
/**
|
|
44
|
+
* getDynamicFilterDictionary: Devuelve el id del diccionario de un componente DynamicFilter.
|
|
45
|
+
* @param key - Clave del diccionario.
|
|
46
|
+
*/
|
|
42
47
|
export declare const getDynamicFilterDictionary: (key: keyof TypeDictionary) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './DynamicFilter';
|
|
2
1
|
export { getDynamicFilterComponentsDictionary } from './dictionary';
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
2
|
+
export * from './DynamicFilter';
|
|
3
|
+
export type { FilterField, FilterFieldApplied as FilterFieldApply, InitialFilterApplied, RawFilterFieldApply, } from './types';
|
|
4
|
+
export { getFilterGroupFieldsByName, getIsIfInDynamicFilter } from './helpers/frontEndHelpers';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { S as Skeleton } from "../../mui_extended/Skeleton/Skeleton.js";
|
|
2
3
|
import { D as DYNAMIC_FILTER_KEY_COMPONENT } from "../constants.js";
|
|
3
|
-
import { d as dynamicFilterStyles } from "../
|
|
4
|
+
import { d as dynamicFilterStyles } from "../DynamicFilter.styles.js";
|
|
4
5
|
import { D as DynamicFilterSlots } from "./SlotsEnum.js";
|
|
5
|
-
import { S as Skeleton } from "../../mui_extended/Skeleton/Skeleton.js";
|
|
6
6
|
import { I as IconButton } from "../../mui_extended/IconButton/IconButton.js";
|
|
7
7
|
import { T as Typography } from "../../mui_extended/Typography/Typography.js";
|
|
8
8
|
import { A as ActionsContainer } from "../../CommonActions/components/ActionsContainer/ActionsContainer.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { DynamicFilterProps } from '../types';
|
|
2
|
+
import { DynamicFilterProps, DynamicFilterRef } from '../types';
|
|
3
3
|
declare const DynamicFilterContext: import('react').Context<import('zustand').StoreApi<import('./types').DynamicFilterStateWithActions> | null>;
|
|
4
4
|
interface DynamicFilterContextProps extends DynamicFilterProps {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Proveedor de contexto para el componente DynamicFilter
|
|
9
9
|
*/
|
|
10
|
-
declare
|
|
11
|
-
export {
|
|
10
|
+
declare const DynamicFilterProvider: import('react').ForwardRefExoticComponent<DynamicFilterContextProps & import('react').RefAttributes<DynamicFilterRef>>;
|
|
11
|
+
export { DynamicFilterContext, DynamicFilterProvider };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useRef, useEffect } from "react";
|
|
3
|
-
import { useStore } from "zustand";
|
|
4
|
-
import { shallow } from "zustand/shallow";
|
|
5
2
|
import { useModuleDictionary, useEnvironment, useModuleSkeleton } from "@m4l/core";
|
|
6
3
|
import { useIsMobile, useFirstRender } from "@m4l/graphics";
|
|
4
|
+
import { createContext, forwardRef, useRef, useImperativeHandle, useEffect } from "react";
|
|
5
|
+
import { useStore } from "zustand";
|
|
6
|
+
import { shallow } from "zustand/shallow";
|
|
7
7
|
import { A as ALL_FIELD } from "../constants.js";
|
|
8
|
-
import { f as formatToRawFilter } from "../helpers/formatToRowFilter.js";
|
|
9
8
|
import { f as formatToInitialFilters } from "../helpers/formatToInitialFilters.js";
|
|
9
|
+
import { f as formatToRawFilter } from "../helpers/formatToRowFilter.js";
|
|
10
10
|
import { c as createDynamicFilterStore } from "./DynamicFilterStore.js";
|
|
11
11
|
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
12
12
|
const DynamicFilterContext = createContext(null);
|
|
13
|
-
|
|
13
|
+
const DynamicFilterProvider = forwardRef((props, ref) => {
|
|
14
14
|
const {
|
|
15
15
|
automatic = true,
|
|
16
16
|
withAllField = true,
|
|
@@ -21,7 +21,8 @@ function DynamicFilterProvider(props) {
|
|
|
21
21
|
size = "medium",
|
|
22
22
|
children,
|
|
23
23
|
storeId,
|
|
24
|
-
storeDevtoolsEnabled = false
|
|
24
|
+
storeDevtoolsEnabled = false,
|
|
25
|
+
visibleRefresh = true
|
|
25
26
|
} = props;
|
|
26
27
|
const { currentSize } = useComponentSize(size);
|
|
27
28
|
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
@@ -44,9 +45,10 @@ function DynamicFilterProvider(props) {
|
|
|
44
45
|
dataTestId,
|
|
45
46
|
size,
|
|
46
47
|
storeId,
|
|
48
|
+
visibleRefresh,
|
|
47
49
|
ownerState: {
|
|
48
50
|
isSkeleton,
|
|
49
|
-
isDirty:
|
|
51
|
+
isDirty: false,
|
|
50
52
|
inEdition: false,
|
|
51
53
|
isValid: true,
|
|
52
54
|
isMobile: !isDesktop,
|
|
@@ -56,6 +58,14 @@ function DynamicFilterProvider(props) {
|
|
|
56
58
|
}, storeDevtoolsEnabled);
|
|
57
59
|
dynamicFilterStoreRef.current.getState().actions.init(initialAppliedFilters);
|
|
58
60
|
}
|
|
61
|
+
const fireOnChangeFilters = useStore(
|
|
62
|
+
dynamicFilterStoreRef.current,
|
|
63
|
+
(state) => state.actions.fireOnChangeFilters,
|
|
64
|
+
shallow
|
|
65
|
+
);
|
|
66
|
+
useImperativeHandle(ref, () => ({
|
|
67
|
+
fireOnChangeFilter: fireOnChangeFilters
|
|
68
|
+
}));
|
|
59
69
|
const countOnChangeFiltersApplied = useStore(
|
|
60
70
|
dynamicFilterStoreRef.current,
|
|
61
71
|
(state) => state.countOnChangeFiltersApplied,
|
|
@@ -86,10 +96,15 @@ function DynamicFilterProvider(props) {
|
|
|
86
96
|
}
|
|
87
97
|
}, []);
|
|
88
98
|
useEffect(() => {
|
|
89
|
-
dynamicFilterStoreRef.current?.getState().
|
|
90
|
-
|
|
99
|
+
if (dynamicFilterStoreRef.current?.getState().size !== adjustedSize) {
|
|
100
|
+
dynamicFilterStoreRef.current?.getState().actions.setSize(adjustedSize);
|
|
101
|
+
}
|
|
102
|
+
if (dynamicFilterStoreRef.current?.getState().visibleRefresh !== visibleRefresh) {
|
|
103
|
+
dynamicFilterStoreRef.current?.getState().actions.setVisibleRefresh(visibleRefresh);
|
|
104
|
+
}
|
|
105
|
+
}, [adjustedSize, visibleRefresh]);
|
|
91
106
|
return /* @__PURE__ */ jsx(DynamicFilterContext.Provider, { value: dynamicFilterStoreRef.current, children });
|
|
92
|
-
}
|
|
107
|
+
});
|
|
93
108
|
export {
|
|
94
109
|
DynamicFilterProvider as D,
|
|
95
110
|
DynamicFilterContext as a
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createStore } from "zustand";
|
|
2
2
|
import { devtools } from "zustand/middleware";
|
|
3
3
|
import { immer } from "zustand/middleware/immer";
|
|
4
|
-
import { g as getPurgedInitialFiltersApplied } from "../helpers/getPurgedInitialFiltersApplied.js";
|
|
5
4
|
import { a as DYNAMIC_FILTER_SOTORE_ID } from "../constants.js";
|
|
5
|
+
import { g as getPurgedInitialFiltersApplied } from "../helpers/getPurgedInitialFiltersApplied.js";
|
|
6
6
|
function updateAvailableFields(state) {
|
|
7
7
|
state.availableFields = state.fields.filter((field) => {
|
|
8
8
|
if (field.multiple === void 0 || field.multiple) {
|
|
@@ -47,7 +47,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
47
47
|
...startProps,
|
|
48
48
|
actions: {
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* init: Inicializa el store, se debe llamar al iniciar el componente
|
|
51
51
|
*/
|
|
52
52
|
init: (initialFiltersApplied) => {
|
|
53
53
|
set((state) => {
|
|
@@ -70,7 +70,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
70
70
|
return elementRef;
|
|
71
71
|
},
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Actualiza el listado de campos disponibles para filtrar
|
|
74
74
|
*/
|
|
75
75
|
getFieldByName: (name) => {
|
|
76
76
|
const field = (get().withAllField ? get().fields.concat(get().allField) : get().fields).find((f) => {
|
|
@@ -82,7 +82,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
82
82
|
throw new Error("No exist field");
|
|
83
83
|
},
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* Elimina un campo filter por su id
|
|
86
86
|
*/
|
|
87
87
|
removeFilter: (id) => {
|
|
88
88
|
set((state) => {
|
|
@@ -91,11 +91,14 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
91
91
|
state.appliedFilters.splice(indexToRemoved, 1);
|
|
92
92
|
state.ownerState.isEmpty = state.appliedFilters.length === 0;
|
|
93
93
|
updateAutomatic(state);
|
|
94
|
+
if (state.appliedFilters.length === 0) {
|
|
95
|
+
state.ownerState.isDirty = false;
|
|
96
|
+
}
|
|
94
97
|
}
|
|
95
98
|
});
|
|
96
99
|
},
|
|
97
100
|
/**
|
|
98
|
-
*
|
|
101
|
+
* muestra el popover para agregar un nuevo filtro
|
|
99
102
|
*/
|
|
100
103
|
showPopoverFilterForAdd: (field) => {
|
|
101
104
|
set((state) => {
|
|
@@ -109,7 +112,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
109
112
|
});
|
|
110
113
|
},
|
|
111
114
|
/**
|
|
112
|
-
*
|
|
115
|
+
* muestra el popover para editar un filtro
|
|
113
116
|
*/
|
|
114
117
|
showPopoverFilterForEdit: (filterToEdit) => {
|
|
115
118
|
set((state) => {
|
|
@@ -122,7 +125,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
122
125
|
get().actions.setInEdition(true);
|
|
123
126
|
},
|
|
124
127
|
/**
|
|
125
|
-
*
|
|
128
|
+
* oculta el popover de filtros
|
|
126
129
|
*/
|
|
127
130
|
hidePopoverFilter: (stayInEdition) => {
|
|
128
131
|
set((state) => {
|
|
@@ -131,7 +134,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
131
134
|
get().actions.setInEdition(stayInEdition);
|
|
132
135
|
},
|
|
133
136
|
/**
|
|
134
|
-
*
|
|
137
|
+
* Limpia todos los filters aplicados
|
|
135
138
|
*/
|
|
136
139
|
clearFilters: () => {
|
|
137
140
|
set((state) => {
|
|
@@ -139,11 +142,12 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
139
142
|
state.ownerState.isEmpty = state.appliedFilters.length === 0;
|
|
140
143
|
state.popoverFilterData = void 0;
|
|
141
144
|
state.ownerState.inEdition = false;
|
|
145
|
+
state.ownerState.isDirty = false;
|
|
142
146
|
updateAutomatic(state);
|
|
143
147
|
});
|
|
144
148
|
},
|
|
145
149
|
/**
|
|
146
|
-
*
|
|
150
|
+
* Acción que se ejecuta al aplicar los filtros
|
|
147
151
|
*/
|
|
148
152
|
fireOnChangeFilters: () => {
|
|
149
153
|
set((state) => {
|
|
@@ -154,7 +158,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
154
158
|
});
|
|
155
159
|
},
|
|
156
160
|
/**
|
|
157
|
-
*
|
|
161
|
+
* obtiene el id del nuevo filtro
|
|
158
162
|
*/
|
|
159
163
|
getNewId: () => {
|
|
160
164
|
return get().appliedFilters.reduce((prev, filterField) => {
|
|
@@ -162,17 +166,20 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
162
166
|
}, 0) + 1;
|
|
163
167
|
},
|
|
164
168
|
/**
|
|
165
|
-
*
|
|
169
|
+
* agrega un nuevo filtro
|
|
166
170
|
*/
|
|
167
171
|
addFilter: (newFilter) => {
|
|
168
172
|
set((state) => {
|
|
173
|
+
if (!state.automatic) {
|
|
174
|
+
state.ownerState.isDirty = true;
|
|
175
|
+
}
|
|
169
176
|
state.appliedFilters.push(newFilter);
|
|
170
177
|
state.ownerState.isEmpty = state.appliedFilters.length === 0;
|
|
171
178
|
updateAutomatic(state);
|
|
172
179
|
});
|
|
173
180
|
},
|
|
174
181
|
/**
|
|
175
|
-
*
|
|
182
|
+
* actualiza un filtro
|
|
176
183
|
*/
|
|
177
184
|
updateFilter: (editFilter) => {
|
|
178
185
|
set((state) => {
|
|
@@ -186,7 +193,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
186
193
|
});
|
|
187
194
|
},
|
|
188
195
|
/**
|
|
189
|
-
*
|
|
196
|
+
* actualiza el inputData
|
|
190
197
|
*/
|
|
191
198
|
setInputData: (inputData) => {
|
|
192
199
|
set((state) => {
|
|
@@ -194,7 +201,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
194
201
|
});
|
|
195
202
|
},
|
|
196
203
|
/**
|
|
197
|
-
*
|
|
204
|
+
* actualiza el editor de filtros
|
|
198
205
|
*/
|
|
199
206
|
setInEdition: (newInEdition) => {
|
|
200
207
|
set((state) => {
|
|
@@ -202,7 +209,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
202
209
|
});
|
|
203
210
|
},
|
|
204
211
|
/**
|
|
205
|
-
*
|
|
212
|
+
* actualiza el estado externo del componente
|
|
206
213
|
*/
|
|
207
214
|
setExternalState: (newExternalState) => {
|
|
208
215
|
set((state) => {
|
|
@@ -210,7 +217,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
210
217
|
});
|
|
211
218
|
},
|
|
212
219
|
/**
|
|
213
|
-
*
|
|
220
|
+
* abre el popover para seleccionar los campos a filtrar
|
|
214
221
|
*/
|
|
215
222
|
openPopoverMenuFields: () => {
|
|
216
223
|
set((state) => {
|
|
@@ -219,7 +226,7 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
219
226
|
});
|
|
220
227
|
},
|
|
221
228
|
/**
|
|
222
|
-
*
|
|
229
|
+
* cierra el popover para seleccionar los campos a filtrar
|
|
223
230
|
*/
|
|
224
231
|
closePopoverMenuFields: (newInEdition) => {
|
|
225
232
|
set((state) => {
|
|
@@ -235,6 +242,14 @@ const createDynamicFilterStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
235
242
|
state.size = newSize;
|
|
236
243
|
state.ownerState.size = newSize;
|
|
237
244
|
});
|
|
245
|
+
},
|
|
246
|
+
/**
|
|
247
|
+
* actualiza el visibleRefresh del componente
|
|
248
|
+
*/
|
|
249
|
+
setVisibleRefresh: (newVisibleRefresh) => {
|
|
250
|
+
set((state) => {
|
|
251
|
+
state.visibleRefresh = newVisibleRefresh;
|
|
252
|
+
});
|
|
238
253
|
}
|
|
239
254
|
}
|
|
240
255
|
})),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MutableRefObject } from 'react';
|
|
2
1
|
import { GetLabelType } from '@m4l/core';
|
|
3
2
|
import { Sizes } from '@m4l/styles';
|
|
4
|
-
import {
|
|
3
|
+
import { MutableRefObject } from 'react';
|
|
4
|
+
import { DynamicFilterProps, FilterField, FilterFieldApplied, FilterToEditApply, InitialFilterApplied, OwnerState } from '../types';
|
|
5
5
|
export type OpenFor = 'add' | 'edit';
|
|
6
6
|
export interface PopoverFilterDataBase {
|
|
7
7
|
/**
|
|
@@ -35,19 +35,7 @@ export type ExternalOwnerState = Pick<OwnerState, 'isMobile' | 'isSkeleton'>;
|
|
|
35
35
|
/**
|
|
36
36
|
* Interface que define el estado del componente
|
|
37
37
|
*/
|
|
38
|
-
export interface DynamicFilterState {
|
|
39
|
-
/**
|
|
40
|
-
* "storeId" identificador del store
|
|
41
|
-
*/
|
|
42
|
-
storeId?: string;
|
|
43
|
-
/**
|
|
44
|
-
* "fields" Campos por los que se puede filtrar
|
|
45
|
-
*/
|
|
46
|
-
fields: Array<FilterField>;
|
|
47
|
-
/**
|
|
48
|
-
* "withAllField" indica si permite o no filtrar por todos los campos
|
|
49
|
-
*/
|
|
50
|
-
withAllField: boolean;
|
|
38
|
+
export interface DynamicFilterState extends Pick<DynamicFilterProps, 'visibleRefresh' | 'size' | 'dataTestId' | 'automatic' | 'storeId' | 'withAllField' | 'fields'> {
|
|
51
39
|
/**
|
|
52
40
|
* "ownerState" estado a nivel de clases del componente
|
|
53
41
|
*/
|
|
@@ -56,19 +44,10 @@ export interface DynamicFilterState {
|
|
|
56
44
|
* "allField" Campo que se usa cuando se puede buscar por todos los campos
|
|
57
45
|
*/
|
|
58
46
|
allField: FilterField;
|
|
59
|
-
/**
|
|
60
|
-
* "automatic" Configura si el filtro se ejecuta automaticamente cuando se agrega o se modifica un filtro
|
|
61
|
-
*/
|
|
62
|
-
automatic: boolean;
|
|
63
47
|
/**
|
|
64
48
|
* "isOpenPopoverMenuFields" determina si se debe abrir el menú de campos
|
|
65
49
|
*/
|
|
66
50
|
isOpenPopoverMenuFields?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Funcion que retorna el elemento (inputFilter) desde donde se desprende el listado de campos
|
|
69
|
-
* Si no está definida, el menú de campos no se muestra
|
|
70
|
-
* @returns
|
|
71
|
-
*/
|
|
72
51
|
/**
|
|
73
52
|
* "inputData" texto en el InputFilter
|
|
74
53
|
*/
|
|
@@ -90,16 +69,10 @@ export interface DynamicFilterState {
|
|
|
90
69
|
* :popoverFilterData" para emerger el popuup de modificación campos
|
|
91
70
|
*/
|
|
92
71
|
popoverFilterData?: PopoverFilterData;
|
|
93
|
-
getLabel: GetLabelType;
|
|
94
72
|
/**
|
|
95
|
-
*
|
|
96
|
-
* Esta propiedad sirve para generar identificadores únicos.
|
|
73
|
+
* Función utilizada para el dictionary
|
|
97
74
|
*/
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* size: tamaño del componente
|
|
101
|
-
*/
|
|
102
|
-
size: Extract<Sizes, 'small' | 'medium'>;
|
|
75
|
+
getLabel: GetLabelType;
|
|
103
76
|
}
|
|
104
77
|
export interface DynamicFilterStateWithActions extends DynamicFilterState {
|
|
105
78
|
actions: {
|
|
@@ -203,6 +176,10 @@ export interface DynamicFilterStateWithActions extends DynamicFilterState {
|
|
|
203
176
|
* actualiza el tamaño del componente
|
|
204
177
|
*/
|
|
205
178
|
setSize: (size: Extract<Sizes, 'small' | 'medium'>) => void;
|
|
179
|
+
/**
|
|
180
|
+
* actualiza el estado del componente
|
|
181
|
+
*/
|
|
182
|
+
setVisibleRefresh: (newVisibleRefresh: boolean) => void;
|
|
206
183
|
};
|
|
207
184
|
}
|
|
208
|
-
export type InitialStoreProps = Pick<DynamicFilterState, 'automatic' | 'fields' | 'withAllField' | 'getLabel' | 'allField' | 'ownerState' | 'dataTestId' | 'size' | 'storeId'>;
|
|
185
|
+
export type InitialStoreProps = Pick<DynamicFilterState, 'automatic' | 'fields' | 'withAllField' | 'getLabel' | 'allField' | 'ownerState' | 'dataTestId' | 'size' | 'storeId' | 'visibleRefresh'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
1
|
import { useModuleDictionary } from "@m4l/core";
|
|
3
2
|
import { useFormatter } from "@m4l/graphics";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
4
|
import { u as useDynamicFilterStore } from "../../store/useDynamicFilterStore.js";
|
|
5
5
|
import { f as fieldFactory } from "../FieldTypes/fieldFactory.js";
|
|
6
6
|
function useAppliedFilterChip(filter) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { u as useDynamicFilterBase } from "./useDynamicFilterBase.js";
|
|
3
2
|
import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
|
|
4
3
|
import { a as getComponentSlotRoot } from "../../../../utils/getComponentSlotRoot.js";
|
|
5
4
|
import { D as DYNAMIC_FILTER_KEY_COMPONENT } from "../../constants.js";
|
|
5
|
+
import { u as useDynamicFilterBase } from "./useDynamicFilterBase.js";
|
|
6
6
|
import { R as RootStyled, I as InnerContainerStyled } from "../../slots/dynamicFilterSlots.js";
|
|
7
7
|
import { D as DynamicFilterSlots } from "../../slots/SlotsEnum.js";
|
|
8
8
|
import { I as InputFilter } from "../InputFilter/InputFilter.js";
|
|
@@ -17,12 +17,12 @@ function DynamicFilterBase() {
|
|
|
17
17
|
{
|
|
18
18
|
className: classRoot,
|
|
19
19
|
ownerState: { ...ownerState },
|
|
20
|
-
...getPropDataTestId(
|
|
20
|
+
...getPropDataTestId(DYNAMIC_FILTER_KEY_COMPONENT, DynamicFilterSlots.root, dataTestId),
|
|
21
21
|
children: /* @__PURE__ */ jsxs(
|
|
22
22
|
InnerContainerStyled,
|
|
23
23
|
{
|
|
24
24
|
ownerState: { ...ownerState },
|
|
25
|
-
...getPropDataTestId(
|
|
25
|
+
...getPropDataTestId(DYNAMIC_FILTER_KEY_COMPONENT, DynamicFilterSlots.innerContainer, dataTestId),
|
|
26
26
|
children: [
|
|
27
27
|
/* @__PURE__ */ jsx(InputFilter, {}),
|
|
28
28
|
/* @__PURE__ */ jsx(AppliedFilters, {}),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Hook que hace uso del store del dynamicFilterStore
|
|
3
3
|
*/
|
|
4
4
|
export default function useDynamicFilterBase(): {
|
|
5
5
|
ownerState: import('../../types').OwnerState;
|
|
6
|
-
dataTestId: string;
|
|
7
|
-
size: "small" | "medium";
|
|
6
|
+
dataTestId: string | undefined;
|
|
7
|
+
size: "small" | "medium" | undefined;
|
|
8
|
+
visibleRefresh: boolean | undefined;
|
|
8
9
|
};
|
|
@@ -3,7 +3,8 @@ function useDynamicFilterBase() {
|
|
|
3
3
|
const ownerState = useDynamicFilterStore((state) => state.ownerState);
|
|
4
4
|
const dataTestId = useDynamicFilterStore((state) => state.dataTestId);
|
|
5
5
|
const size = useDynamicFilterStore((state) => state.size);
|
|
6
|
-
|
|
6
|
+
const visibleRefresh = useDynamicFilterStore((state) => state.visibleRefresh);
|
|
7
|
+
return { ownerState, dataTestId, size, visibleRefresh };
|
|
7
8
|
}
|
|
8
9
|
export {
|
|
9
10
|
useDynamicFilterBase as u
|
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
|
-
import { IFieldType, YupSchema } from '../FieldTypeInterface';
|
|
4
3
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FormFilterValueBoolean, InitialFilterApplied } from '../../../types';
|
|
4
|
+
import { IFieldType, YupSchema } from '../FieldTypeInterface';
|
|
5
5
|
import { BooleanFilter } from './index';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* BooleanFilterHelpers es una clase que implementa la interfaz IFieldType
|
|
8
|
+
* para manejar filtros booleanos en un componente de filtro dinámico.
|
|
8
9
|
*/
|
|
9
10
|
export declare class BooleanFilterHelpers implements IFieldType<FormFilterValueBoolean> {
|
|
10
11
|
getComponent(): typeof BooleanFilter;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* getDefaultFilter devuelve un filtro por defecto para un campo booleano.
|
|
13
14
|
*/
|
|
14
15
|
getDefaultFilter(field: FilterField, fixed: boolean): FilterFieldApplied;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* getFilterFromFormValue convierte un valor de formulario en un valor de filtro.
|
|
17
18
|
*/
|
|
18
19
|
getFilterFromFormValue(formFilterValue: FormFilterValueBoolean): FilterValue;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* getFormValue convierte un valor de filtro en un valor de formulario.
|
|
21
22
|
*/
|
|
22
23
|
getFormValue(field: FilterField, getLabel: GetLabelType, filterValue?: FilterValue): FormFilterValueBoolean;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* getLabel devuelve las etiquetas para el filtro booleano.
|
|
25
26
|
*/
|
|
26
27
|
getLabels(filter: FilterFieldApplied, getLabel: GetLabelType, _formatters: Formatters, _field: FilterField): DataTypeFilerLabels;
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* getschema devuelve un esquema de validación para el filtro booleano.
|
|
29
30
|
*/
|
|
30
31
|
getSchema(getLabel: GetLabelType): YupSchema;
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* verifyFilter verifica si el filtro es válido.
|
|
33
34
|
*/
|
|
34
35
|
verifyFilter(filter: InitialFilterApplied, _field?: FilterField): boolean;
|
|
35
36
|
}
|