@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
|
@@ -45,7 +45,7 @@ const createDevtools = (immerMiddlewere, config) => {
|
|
|
45
45
|
}
|
|
46
46
|
return immerMiddlewere;
|
|
47
47
|
};
|
|
48
|
-
const
|
|
48
|
+
const createDynamicSortStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
49
49
|
const startProps = {
|
|
50
50
|
countOnChangeSortsApplyed: 0,
|
|
51
51
|
appliedSorts: [],
|
|
@@ -62,7 +62,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
62
62
|
...startProps,
|
|
63
63
|
actions: {
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* init es la acción que se ejecuta al inicializar el store
|
|
66
66
|
*/
|
|
67
67
|
init: (initialSortApplyed) => {
|
|
68
68
|
set((state) => {
|
|
@@ -96,7 +96,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
96
96
|
throw new Error("Field does not exist");
|
|
97
97
|
},
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
99
|
+
* Elimina un campo sort por su id
|
|
100
100
|
*/
|
|
101
101
|
removeSort: (id) => {
|
|
102
102
|
set((state) => {
|
|
@@ -104,11 +104,14 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
104
104
|
if (index_to_remove > -1) {
|
|
105
105
|
state.appliedSorts.splice(index_to_remove, 1);
|
|
106
106
|
updateAutomatic(state);
|
|
107
|
+
if (state.appliedSorts.length === 0) {
|
|
108
|
+
state.ownerState.isDirty = false;
|
|
109
|
+
}
|
|
107
110
|
}
|
|
108
111
|
});
|
|
109
112
|
},
|
|
110
113
|
/**
|
|
111
|
-
*
|
|
114
|
+
* showPopoverSortForAdd es la acción que se ejecuta al abrir el popover para agregar un nuevo sort
|
|
112
115
|
*/
|
|
113
116
|
showPopoverSortForAdd: (field) => {
|
|
114
117
|
set((state) => {
|
|
@@ -122,7 +125,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
122
125
|
});
|
|
123
126
|
},
|
|
124
127
|
/**
|
|
125
|
-
*
|
|
128
|
+
* showPopoverSortForEdit es la acción que se ejecuta al abrir el popover para editar un sort existente
|
|
126
129
|
*/
|
|
127
130
|
showPopoverSortForEdit: (sortToEdit) => {
|
|
128
131
|
set((state) => {
|
|
@@ -134,7 +137,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
134
137
|
get().actions.setInEdition(true);
|
|
135
138
|
},
|
|
136
139
|
/**
|
|
137
|
-
*
|
|
140
|
+
* hidepopoverSort oculta el popover de sort
|
|
138
141
|
*/
|
|
139
142
|
hidePopoverSort: (stayInEditon) => {
|
|
140
143
|
set((state) => {
|
|
@@ -143,16 +146,17 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
143
146
|
get().actions.setInEdition(stayInEditon);
|
|
144
147
|
},
|
|
145
148
|
/**
|
|
146
|
-
*
|
|
149
|
+
* Limpia todos los campos/atributos usados para aplicar un sort
|
|
147
150
|
*/
|
|
148
151
|
clearSorts: () => {
|
|
149
152
|
set((state) => {
|
|
153
|
+
state.ownerState.isDirty = false;
|
|
150
154
|
state.appliedSorts = state.appliedSorts.filter((f) => f.fixed);
|
|
151
155
|
updateAvailableFields(state);
|
|
152
156
|
});
|
|
153
157
|
},
|
|
154
158
|
/**
|
|
155
|
-
*
|
|
159
|
+
* Acción que se ejecuta al aplicar los filtros
|
|
156
160
|
*/
|
|
157
161
|
fireOnChangeSorts: () => {
|
|
158
162
|
set((state) => {
|
|
@@ -163,7 +167,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
163
167
|
});
|
|
164
168
|
},
|
|
165
169
|
/**
|
|
166
|
-
*
|
|
170
|
+
* getNewId es la acción que se ejecuta al crear un nuevo sort
|
|
167
171
|
*/
|
|
168
172
|
getNewId: () => {
|
|
169
173
|
return get().appliedSorts.reduce((prev, n) => {
|
|
@@ -171,16 +175,19 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
171
175
|
}, 0) + 1;
|
|
172
176
|
},
|
|
173
177
|
/**
|
|
174
|
-
*
|
|
178
|
+
* Agrega un nuevo campo/atributo por el cual se va aplicar el sort
|
|
175
179
|
*/
|
|
176
180
|
addSort: (newSort) => {
|
|
177
181
|
set((state) => {
|
|
182
|
+
if (!state.automatic) {
|
|
183
|
+
state.ownerState.isDirty = true;
|
|
184
|
+
}
|
|
178
185
|
state.appliedSorts.push(newSort);
|
|
179
186
|
updateAutomatic(state);
|
|
180
187
|
});
|
|
181
188
|
},
|
|
182
189
|
/**
|
|
183
|
-
*
|
|
190
|
+
* Actualiza un sort existente
|
|
184
191
|
*/
|
|
185
192
|
updateSort: (editSort) => {
|
|
186
193
|
set((state) => {
|
|
@@ -192,7 +199,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
192
199
|
});
|
|
193
200
|
},
|
|
194
201
|
/**
|
|
195
|
-
*
|
|
202
|
+
* Actualiza el valor del input de busqueda
|
|
196
203
|
*/
|
|
197
204
|
setInputData: (inputData) => {
|
|
198
205
|
set((state) => {
|
|
@@ -200,7 +207,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
200
207
|
});
|
|
201
208
|
},
|
|
202
209
|
/**
|
|
203
|
-
*
|
|
210
|
+
* Actualiza en edicion el estado del componente
|
|
204
211
|
*/
|
|
205
212
|
setInEdition: (newInEdition) => {
|
|
206
213
|
set((state) => {
|
|
@@ -208,7 +215,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
208
215
|
});
|
|
209
216
|
},
|
|
210
217
|
/**
|
|
211
|
-
*
|
|
218
|
+
* abre el popover para seleccionar los campos a filtrar
|
|
212
219
|
*/
|
|
213
220
|
openPopoverMenuFields: () => {
|
|
214
221
|
set((state) => {
|
|
@@ -217,7 +224,7 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
217
224
|
});
|
|
218
225
|
},
|
|
219
226
|
/**
|
|
220
|
-
*
|
|
227
|
+
* cierra el popover para seleccionar los campos a filtrar
|
|
221
228
|
*/
|
|
222
229
|
closePopoverMenuFields: (newInEdition) => {
|
|
223
230
|
set((state) => {
|
|
@@ -233,6 +240,14 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
233
240
|
state.size = newSize;
|
|
234
241
|
state.ownerState.size = newSize;
|
|
235
242
|
});
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* actualiza el visibleRefresh del componente
|
|
246
|
+
*/
|
|
247
|
+
setVisibleRefresh: (newVisibleRefresh) => {
|
|
248
|
+
set((state) => {
|
|
249
|
+
state.visibleRefresh = newVisibleRefresh;
|
|
250
|
+
});
|
|
236
251
|
}
|
|
237
252
|
}
|
|
238
253
|
})),
|
|
@@ -241,5 +256,5 @@ const createAreaStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
241
256
|
);
|
|
242
257
|
};
|
|
243
258
|
export {
|
|
244
|
-
|
|
259
|
+
createDynamicSortStore as c
|
|
245
260
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Sizes } from '@m4l/styles';
|
|
3
|
-
import { SortField, SortFieldApplied, SortToEditApply, InitialSortApplied, OwnerState } from '../types';
|
|
4
3
|
import { MutableRefObject } from 'react';
|
|
4
|
+
import { DynamicSortProps, InitialSortApplied, OwnerState, SortField, SortFieldApplied, SortToEditApply } from '../types';
|
|
5
5
|
export type OpenFor = 'add' | 'edit';
|
|
6
6
|
export interface PopoverSortDataBase {
|
|
7
7
|
/**
|
|
@@ -31,23 +31,15 @@ export type PopoverSortData = PopoverSortDataAdd | PopoverSortDataEdit;
|
|
|
31
31
|
/**
|
|
32
32
|
* Interface que define el estado del componente
|
|
33
33
|
*/
|
|
34
|
-
export interface DynamicSortState {
|
|
34
|
+
export interface DynamicSortState extends Pick<DynamicSortProps, 'fields' | 'automatic' | 'dataTestId' | 'size' | 'visibleRefresh'> {
|
|
35
35
|
/**
|
|
36
36
|
* "storeId" identificador del store
|
|
37
37
|
*/
|
|
38
38
|
storeId?: string;
|
|
39
|
-
/**
|
|
40
|
-
* "fields" Campos por los que se puede filtrar
|
|
41
|
-
*/
|
|
42
|
-
fields: Array<SortField>;
|
|
43
39
|
/**
|
|
44
40
|
* "ownerState" estado a nivel de clases del componente
|
|
45
41
|
*/
|
|
46
42
|
ownerState: OwnerState;
|
|
47
|
-
/**
|
|
48
|
-
* "automatic" Configura si el sort se ejecuta automaticamente cuando se agrega o se modifica un sort
|
|
49
|
-
*/
|
|
50
|
-
automatic: boolean;
|
|
51
43
|
/**
|
|
52
44
|
* "isOpenPopoverMenuFields" determina si se debe abrir el menú de campos
|
|
53
45
|
*/
|
|
@@ -71,12 +63,10 @@ export interface DynamicSortState {
|
|
|
71
63
|
countOnChangeSortsApplyed: number;
|
|
72
64
|
/** popoverFilterData: para emerger el popuup de modificación campos */
|
|
73
65
|
popoverSortData?: PopoverSortData;
|
|
74
|
-
getLabel: GetLabelType;
|
|
75
66
|
/**
|
|
76
|
-
*
|
|
77
|
-
* Esta propiedad sirve para generar identificadores únicos.
|
|
67
|
+
* Función utilizada para el dictionary
|
|
78
68
|
*/
|
|
79
|
-
|
|
69
|
+
getLabel: GetLabelType;
|
|
80
70
|
/**
|
|
81
71
|
* size: tamaño del componente
|
|
82
72
|
*/
|
|
@@ -178,6 +168,10 @@ export interface DynamicSortStateWithActions extends DynamicSortState {
|
|
|
178
168
|
* actualiza el tamaño del componente
|
|
179
169
|
*/
|
|
180
170
|
setSize: (size: Extract<Sizes, 'small' | 'medium'>) => void;
|
|
171
|
+
/**
|
|
172
|
+
* actualiza el estado del componente
|
|
173
|
+
*/
|
|
174
|
+
setVisibleRefresh: (newVisibleRefresh: boolean) => void;
|
|
181
175
|
};
|
|
182
176
|
}
|
|
183
|
-
export type InitialStoreProps = Pick<DynamicSortState, 'automatic' | 'fields' | 'getLabel' | 'ownerState' | 'dataTestId' | 'size' | 'storeId'>;
|
|
177
|
+
export type InitialStoreProps = Pick<DynamicSortState, 'automatic' | 'fields' | 'getLabel' | 'ownerState' | 'dataTestId' | 'size' | 'storeId' | 'visibleRefresh'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
1
|
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
3
2
|
import { useFormatter } from "@m4l/graphics";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
4
|
import { u as useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
5
5
|
import { S as SORT_ICONS } from "../../icons.js";
|
|
6
6
|
import { f as fieldFactory } from "../FieldTypes/fieldFactory.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { u as useDynamicSortBase } from "../DynamicSortBase/useDynamicSortBase.js";
|
|
3
2
|
import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
|
|
4
3
|
import { D as DYNAMIC_SORT_KEY_COMPONENT } from "../../constants.js";
|
|
5
4
|
import { D as DynamicSortSlots } from "../../slots/SlotsEnum.js";
|
|
5
|
+
import { u as useDynamicSortBase } from "../DynamicSortBase/useDynamicSortBase.js";
|
|
6
6
|
import { u as useAppliedSorts } from "./useAppliedSorts.js";
|
|
7
7
|
import { A as AppliedSortsStyled, a as AppliedSortInnerContainerStyled } from "../../slots/DynamicSortSlots.js";
|
|
8
8
|
import { A as AppliedSortChip } from "../AppliedSortChip/AppliedSortChip.js";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
|
|
3
|
+
import { a as getComponentSlotRoot } from "../../../../utils/getComponentSlotRoot.js";
|
|
3
4
|
import { D as DYNAMIC_SORT_KEY_COMPONENT } from "../../constants.js";
|
|
4
5
|
import { u as useDynamicSortBase } from "./useDynamicSortBase.js";
|
|
5
|
-
import { D as DYNAMICSORT_DICTIONARY_ID } from "../../dictionary.js";
|
|
6
|
-
import { a as getComponentSlotRoot } from "../../../../utils/getComponentSlotRoot.js";
|
|
7
6
|
import { R as RootStyled, I as InnerContainerStyled } from "../../slots/DynamicSortSlots.js";
|
|
8
7
|
import { D as DynamicSortSlots } from "../../slots/SlotsEnum.js";
|
|
9
8
|
import { I as InputSort } from "../InputSort/InputSort.js";
|
|
@@ -12,7 +11,7 @@ import { S as SortActions } from "../SortActions/SortActions.js";
|
|
|
12
11
|
import { P as PopoverSort } from "../PopoverSort/PopoverSort.js";
|
|
13
12
|
function DynamicSortBase() {
|
|
14
13
|
const { ownerState, dataTestId } = useDynamicSortBase();
|
|
15
|
-
const classRoot = getComponentSlotRoot(
|
|
14
|
+
const classRoot = getComponentSlotRoot(DYNAMIC_SORT_KEY_COMPONENT);
|
|
16
15
|
return /* @__PURE__ */ jsx(
|
|
17
16
|
RootStyled,
|
|
18
17
|
{
|
|
@@ -3,7 +3,8 @@ function useDynamicSortBase() {
|
|
|
3
3
|
const ownerState = useDynamicSortStore((state) => state.ownerState);
|
|
4
4
|
const dataTestId = useDynamicSortStore((state) => state.dataTestId);
|
|
5
5
|
const size = useDynamicSortStore((state) => state.size);
|
|
6
|
-
|
|
6
|
+
const visibleRefresh = useDynamicSortStore((state) => state.visibleRefresh);
|
|
7
|
+
return { ownerState, dataTestId, size, visibleRefresh };
|
|
7
8
|
}
|
|
8
9
|
export {
|
|
9
10
|
useDynamicSortBase as u
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
1
|
import { GetLabelType } from '@m4l/core';
|
|
3
2
|
import { Formatters } from '@m4l/graphics';
|
|
4
|
-
import {
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
import { DataTypeFilerLabels, FormSortValueBase, InitialSortApplied, SortField, SortFieldApplied, SortValue } from '../../types';
|
|
5
5
|
import * as Yup from 'yup';
|
|
6
6
|
export type YupSchema = Yup.SchemaOf<any>;
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
|
+
import { DataTypeFilerLabels, FormSortValueBase, InitialSortApplied, SortField, SortFieldApplied, SortValue } from '../../../types';
|
|
3
4
|
import { IFieldType, YupSchema } from '../FieldTypeInterface';
|
|
4
|
-
import { DataTypeFilerLabels, SortField, SortFieldApplied, SortValue, FormSortValueBase, InitialSortApplied } from '../../../types';
|
|
5
5
|
import { StringSort } from './index';
|
|
6
6
|
/**
|
|
7
7
|
* Clase que implementa los métodos necesarios para el tipo de campo string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Yup from "yup";
|
|
2
|
-
import { g as getDynamicSortDictionary } from "../../../dictionary.js";
|
|
3
2
|
import { O as OPERATORS } from "../../../constants.js";
|
|
3
|
+
import { g as getDynamicSortDictionary } from "../../../dictionary.js";
|
|
4
4
|
import { S as StringSort } from "./index.js";
|
|
5
5
|
class SortHelpers {
|
|
6
6
|
getComponent() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
2
|
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
4
|
import { S as SORT_ICONS } from "../../../icons.js";
|
|
5
|
-
import { g as getDynamicSortDictionary,
|
|
5
|
+
import { g as getDynamicSortDictionary, D as DICCTIONARY } from "../../../dictionary.js";
|
|
6
6
|
import { u as useDynamicSortBase } from "../../DynamicSortBase/useDynamicSortBase.js";
|
|
7
7
|
import { R as RHFSelect } from "../../../../hook-form/RHFSelect/RHFSelect.js";
|
|
8
8
|
import { I as Icon } from "../../../../Icon/Icon.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
1
|
import { useEnvironment, useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
3
|
-
import {
|
|
4
|
-
import { u as useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
5
3
|
import { A as ASSETS_URL, b as ASSETS } from "../../constants.js";
|
|
4
|
+
import { g as getDynamicSortDictionary, D as DICCTIONARY } from "../../dictionary.js";
|
|
5
|
+
import { u as useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
6
6
|
function useInputSort() {
|
|
7
7
|
const [selectedFieldIndex, setSelectedFieldIndex] = useState(-1);
|
|
8
8
|
const [sortFields, setSortedFields] = useState([]);
|
|
@@ -4,7 +4,7 @@ export type PopoverMenuFieldsProps = {
|
|
|
4
4
|
fields: SortField[];
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* PopoverMenuFields es un componente que permite mostrar un menú desplegable con los campos disponibles para ordenar.
|
|
8
8
|
*/
|
|
9
9
|
declare function PopoverMenuFields(props: PopoverMenuFieldsProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export default PopoverMenuFields;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { u as usePopoverMenuFields } from "./usePopoverMenuFields.js";
|
|
3
2
|
import { u as useDynamicSortBase } from "../DynamicSortBase/useDynamicSortBase.js";
|
|
3
|
+
import { u as usePopoverMenuFields } from "./usePopoverMenuFields.js";
|
|
4
4
|
import { useRef, useEffect } from "react";
|
|
5
5
|
import { c as DYNAMIC_SORT_POPOVER_CONTAINER_ID } from "../../constants.js";
|
|
6
6
|
import { M as MenuItem } from "../../../mui_extended/MenuItem/MenuItem.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
2
|
import { SortField } from '../../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Hook que maneja la lógica del popoverMenuFields
|
|
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 useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
3
2
|
import { shallow } from "zustand/shallow";
|
|
3
|
+
import { u as useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
4
4
|
function usePopoverMenuFields() {
|
|
5
5
|
const { getLabel } = useModuleDictionary();
|
|
6
6
|
const isOpenPopoverMenuFields = useDynamicSortStore((state) => state.isOpenPopoverMenuFields);
|
|
@@ -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
4
|
import { FormSortFieldApplied, SortField } from '../../types';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* usePopoverSort es un hook que maneja la lógica del popoverSort
|
|
7
7
|
*/
|
|
8
8
|
declare function usePopoverSort(): {
|
|
9
9
|
field: SortField;
|
|
@@ -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 useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
4
5
|
import { f as fieldFactory } from "../FieldTypes/fieldFactory.js";
|
|
5
|
-
import { shallow } from "zustand/shallow";
|
|
6
6
|
function usePopoverSort() {
|
|
7
7
|
let anchorEl;
|
|
8
8
|
let field;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Acciones del sort, muestra la accion de clean
|
|
3
|
+
* para limpiar los campos y el boton refresh
|
|
4
|
+
* para aplicar el sort con los campos del input
|
|
3
5
|
*/
|
|
4
6
|
declare function SortActions(): import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
export default SortActions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { g as getDynamicSortDictionary, a as DICCTIONARY } from "../../dictionary.js";
|
|
2
|
+
import { g as getDynamicSortDictionary, D as DICCTIONARY } from "../../dictionary.js";
|
|
4
3
|
import { u as useDynamicSortBase } from "../DynamicSortBase/useDynamicSortBase.js";
|
|
4
|
+
import { u as useSortActions } from "./useSortActions.js";
|
|
5
5
|
import { j as ActionsStyled, k as ActionsClearButtonStyled, l as ActionsSubmitButtonStyled } from "../../slots/DynamicSortSlots.js";
|
|
6
6
|
function SortActions() {
|
|
7
7
|
const {
|
|
@@ -13,8 +13,8 @@ function SortActions() {
|
|
|
13
13
|
sortButtonDictionaryTooltip,
|
|
14
14
|
ownerState
|
|
15
15
|
} = useSortActions();
|
|
16
|
-
const { size } = useDynamicSortBase();
|
|
17
|
-
return /* @__PURE__ */ jsxs(ActionsStyled, { ownerState: {}, children: [
|
|
16
|
+
const { size, visibleRefresh, ownerState: { isDirty } } = useDynamicSortBase();
|
|
17
|
+
return /* @__PURE__ */ jsxs(ActionsStyled, { ownerState: { isDirty: canShowRemoveAction, visibleRefresh }, children: [
|
|
18
18
|
canShowRemoveAction && /* @__PURE__ */ jsx(
|
|
19
19
|
ActionsClearButtonStyled,
|
|
20
20
|
{
|
|
@@ -25,7 +25,7 @@ function SortActions() {
|
|
|
25
25
|
ownerState: {}
|
|
26
26
|
}
|
|
27
27
|
),
|
|
28
|
-
/* @__PURE__ */ jsx(
|
|
28
|
+
visibleRefresh ? /* @__PURE__ */ jsx(
|
|
29
29
|
ActionsSubmitButtonStyled,
|
|
30
30
|
{
|
|
31
31
|
size,
|
|
@@ -33,9 +33,9 @@ function SortActions() {
|
|
|
33
33
|
"aria-label": "settings",
|
|
34
34
|
dictionaryTooltipId: sortButtonDictionaryTooltip,
|
|
35
35
|
onClick: onClickSort,
|
|
36
|
-
ownerState: { ...ownerState }
|
|
36
|
+
ownerState: { ...ownerState, isDirty }
|
|
37
37
|
}
|
|
38
|
-
)
|
|
38
|
+
) : null
|
|
39
39
|
] });
|
|
40
40
|
}
|
|
41
41
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEnvironment, useModuleSkeleton } from "@m4l/core";
|
|
2
|
-
import { u as useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
3
|
-
import { g as getDynamicSortDictionary, a as DICCTIONARY } from "../../dictionary.js";
|
|
4
2
|
import { A as ASSETS_URL, b as ASSETS } from "../../constants.js";
|
|
3
|
+
import { g as getDynamicSortDictionary, D as DICCTIONARY } from "../../dictionary.js";
|
|
4
|
+
import { u as useDynamicSortStore } from "../../store/useDynamicSortStore.js";
|
|
5
5
|
function useSortActions() {
|
|
6
6
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
7
7
|
const automatic = useDynamicSortStore((state) => state.automatic);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Maybe } from '@m4l/core';
|
|
2
|
+
import { Sizes } from '@m4l/styles';
|
|
1
3
|
import { Theme } from '@mui/material/styles';
|
|
2
4
|
import { M4LOverridesStyleRules } from '../../@types/augmentations';
|
|
3
|
-
import { Sizes } from '@m4l/styles';
|
|
4
|
-
import { Maybe } from '@m4l/core';
|
|
5
5
|
import { DYNAMIC_SORT_KEY_COMPONENT } from './constants';
|
|
6
6
|
import { DynamicSortSlots } from './slots';
|
|
7
7
|
export type SortFieldType = 'string' | 'number' | 'date' | 'boolean';
|
|
@@ -120,21 +120,35 @@ export interface DynamicSortProps {
|
|
|
120
120
|
* @default true
|
|
121
121
|
*/
|
|
122
122
|
automatic?: boolean;
|
|
123
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Array con la configuración de cada campo por el que se podrá filtrar.
|
|
125
|
+
*/
|
|
124
126
|
fields: Array<SortField>;
|
|
125
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Array con la configuración de cada campo por el que se podrá hacer Sort.
|
|
129
|
+
*/
|
|
126
130
|
initialAppliedSorts?: Array<InitialSortApplied>;
|
|
127
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Handler que se dispara cuando el filtro cambia en automatico, o cuando es manual y se presion el boton de filtrar
|
|
133
|
+
*/
|
|
128
134
|
onChangeSorts?: OnChangeSorts;
|
|
129
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Key único para necesario para las pruebas del componente.
|
|
137
|
+
*/
|
|
130
138
|
dataTestId?: string;
|
|
131
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Propiedad para las variantes de tamaño
|
|
141
|
+
*/
|
|
132
142
|
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
143
|
+
/**
|
|
144
|
+
* visibleRefresh: indica si el boton de refresh debe estar visible
|
|
145
|
+
*/
|
|
146
|
+
visibleRefresh?: boolean;
|
|
133
147
|
}
|
|
134
148
|
/**
|
|
135
149
|
* Interface que define la variables que se van a usar en clases del componente
|
|
136
150
|
*/
|
|
137
|
-
export interface OwnerState {
|
|
151
|
+
export interface OwnerState extends Pick<DynamicSortProps, 'automatic'> {
|
|
138
152
|
/**
|
|
139
153
|
* "inEdition" se establece cuando se está en edición.
|
|
140
154
|
*/
|
|
@@ -160,3 +174,6 @@ export interface DynamicSortOwnerState extends DynamicSortProps, OwnerState {
|
|
|
160
174
|
}
|
|
161
175
|
export type DynamicSortSlotsType = keyof typeof DynamicSortSlots;
|
|
162
176
|
export type DynamicSortStyles = M4LOverridesStyleRules<DynamicSortSlotsType, typeof DYNAMIC_SORT_KEY_COMPONENT, Theme>;
|
|
177
|
+
export interface DynamicSortRef {
|
|
178
|
+
fireOnChangeSort: () => void;
|
|
179
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { D as DYNAMIC_FILTER_KEY_COMPONENT } from "../../components/DynamicFilter/constants.js";
|
|
2
|
+
import { D as DYNAMIC_SORT_KEY_COMPONENT } from "../../components/DynamicSort/constants.js";
|
|
1
3
|
const dynamicFilterAndSortStyles = {
|
|
2
4
|
/**
|
|
3
5
|
* Estilos para los leftActions
|
|
@@ -19,12 +21,12 @@ const dynamicFilterAndSortStyles = {
|
|
|
19
21
|
flexDirection: theme.generalSettings.isMobile ? "column" : "row",
|
|
20
22
|
gap: theme.vars.size.baseSpacings.sp3,
|
|
21
23
|
padding: `0 ${theme.vars.size.baseSpacings.sp1}`,
|
|
22
|
-
|
|
24
|
+
[`& [class*="${DYNAMIC_FILTER_KEY_COMPONENT}-root"]`]: {
|
|
23
25
|
display: ownerState.showDynamicFilter ? "block" : "none",
|
|
24
26
|
width: "auto",
|
|
25
27
|
flexGrow: theme.generalSettings.isMobile ? 1 : 2
|
|
26
28
|
},
|
|
27
|
-
|
|
29
|
+
[`& [class*="${DYNAMIC_SORT_KEY_COMPONENT}-root"]`]: {
|
|
28
30
|
display: ownerState.showDynamicSort ? "block" : "none",
|
|
29
31
|
width: "auto",
|
|
30
32
|
flexGrow: 1
|
|
@@ -17,7 +17,7 @@ export interface ChangeFilterSort {
|
|
|
17
17
|
eventFilters?: ChangeFilter;
|
|
18
18
|
eventSorts?: ChangeSort;
|
|
19
19
|
}
|
|
20
|
-
export interface UseDynamicFilterAndSortProps extends Pick<DynamicFilterProps, 'fields' | 'withAllField'> {
|
|
20
|
+
export interface UseDynamicFilterAndSortProps extends Pick<DynamicFilterProps, 'fields' | 'withAllField' | 'visibleRefresh'> {
|
|
21
21
|
setCookie?: WindowToolsMF['setCookie'];
|
|
22
22
|
getCookie?: WindowToolsMF['getCookie'];
|
|
23
23
|
prefixCookie?: string;
|
|
@@ -27,6 +27,7 @@ export interface UseDynamicFilterAndSortProps extends Pick<DynamicFilterProps, '
|
|
|
27
27
|
onChangeFilterSort: (params: ChangeFilterSort) => void;
|
|
28
28
|
dataTestId?: string;
|
|
29
29
|
sorts?: DynamicSortProps['fields'];
|
|
30
|
+
filterSortAutomatic?: boolean;
|
|
30
31
|
}
|
|
31
32
|
export interface DynamicFilterAndSortOwnerState {
|
|
32
33
|
showDynamicFilter: boolean;
|