@m4l/components 0.0.28 → 0.0.31
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/dist/components/CompanyLogo/index.js +0 -1
- package/dist/components/DataGrid/index.js +0 -2
- package/dist/components/DynamicFilter/components/ApplyedFilters/components/ApplyedFilter/index.d.ts +3 -0
- package/dist/components/DynamicFilter/components/ApplyedFilters/components/ApplyedFilter/styles.d.ts +6 -0
- package/dist/components/DynamicFilter/components/ApplyedFilters/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/ApplyedFilters/styles.d.ts +2 -0
- package/dist/components/DynamicFilter/components/ClearFilters/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/ClearFilters/styles.d.ts +3 -0
- package/dist/components/DynamicFilter/components/FilterButton/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/FilterButton/styles.d.ts +4 -0
- package/dist/components/DynamicFilter/components/InputFilter/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/InputFilter/styles.d.ts +3 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/BooleanFilter/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/BooleanFilter/styles.d.ts +3 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/DateTimeFilter/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/DateTimeFilter/styles.d.ts +3 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/StringFilter/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/StringFilter/styles.d.ts +3 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/factory.d.ts +6 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/components/validations.d.ts +5 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/index.d.ts +2 -0
- package/dist/components/DynamicFilter/components/PopupEditFilter/styles.d.ts +5 -0
- package/dist/components/DynamicFilter/contexts/BaseContext/index.d.ts +5 -0
- package/dist/components/DynamicFilter/contexts/BaseContext/types.d.ts +42 -0
- package/dist/components/DynamicFilter/hooks/useFilter.d.ts +1 -0
- package/dist/components/DynamicFilter/index.d.ts +3 -0
- package/dist/components/DynamicFilter/index.js +1392 -0
- package/dist/components/DynamicFilter/styles.d.ts +8 -0
- package/dist/components/DynamicFilter/types.d.ts +65 -0
- package/dist/components/Icon/index.js +4 -2
- package/dist/components/Icon/styles.d.ts +1 -2
- package/dist/components/Icon/types.d.ts +4 -2
- package/dist/components/Image/index.js +1 -2
- package/dist/components/ObjectLogs/index.js +51 -98
- package/dist/components/ObjectLogs/types.d.ts +0 -2
- package/dist/components/ScrollBar/index.d.ts +6 -3
- package/dist/components/ScrollBar/index.js +7 -15
- package/dist/components/hook-form/FormProvider/index.js +0 -1
- package/dist/components/hook-form/RHFAutocomplete/index.d.ts +4 -0
- package/dist/components/hook-form/RHFAutocomplete/styles.d.ts +5 -0
- package/dist/components/hook-form/RHFAutocomplete/types.d.ts +13 -0
- package/dist/components/hook-form/RHFAutocompleteAsync/index.js +0 -2
- package/dist/components/hook-form/RHFDateTime/index.d.ts +4 -0
- package/dist/components/hook-form/RHFDateTime/styles.d.ts +2 -0
- package/dist/components/hook-form/RHFDateTime/types.d.ts +9 -0
- package/dist/components/hook-form/RHFDateTime.js +72 -0
- package/dist/components/hook-form/RHFTextField/index.d.ts +1 -2
- package/dist/components/hook-form/RHFTextField/index.js +6 -3
- package/dist/components/hook-form/RHFUpload/RHFUploadImage/components/UploadImage/index.d.ts +3 -0
- package/dist/components/hook-form/RHFUpload/RHFUploadImage/components/UploadImage/styles.d.ts +4 -0
- package/dist/components/hook-form/RHFUpload/RHFUploadImage/components/UploadImage/types.d.ts +11 -0
- package/dist/components/hook-form/RHFUpload/RHFUploadImage/index.d.ts +3 -0
- package/dist/components/hook-form/RHFUpload/RHFUploadImage/types.d.ts +14 -0
- package/dist/components/hook-form/RHFUpload/index.d.ts +1 -0
- package/dist/components/hook-form/RHFUpload/types.d.ts +4 -0
- package/dist/components/hook-form/RHFUpload.js +182 -0
- package/dist/components/hook-form/index.d.ts +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/mui_extended/MenuActions/index.js +1 -1
- package/dist/index.js +18 -14
- package/dist/lodash.js +61 -1
- package/dist/node_modules.js +1307 -1
- package/dist/simplebar.js +1 -0
- package/dist/style.css +1 -0
- package/dist/vendor.js +150 -11
- package/package.json +9 -7
- package/dist/components/ScrollBar/styles.d.ts +0 -6
- package/dist/components/ScrollBar/types.d.ts +0 -7
|
@@ -0,0 +1,1392 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { useRef, useState, useMemo, useCallback, useEffect, createContext, useContext } from "react";
|
|
3
|
+
import { useModuleDictionary, voidFunction, useHostTools, useEnvironment, useFlagsPresent } from "@m4l/core";
|
|
4
|
+
import * as Yup from "yup";
|
|
5
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
6
|
+
import { F as FormProvider } from "../hook-form/FormProvider/index.js";
|
|
7
|
+
import "react-router-dom";
|
|
8
|
+
import "@mui/lab";
|
|
9
|
+
import { styled as styled$1, Skeleton, MenuItem, Popper, Button } from "@mui/material";
|
|
10
|
+
import "../../contexts/ModalContext/index.js";
|
|
11
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { R as RHFAutocomplete } from "../../vendor.js";
|
|
13
|
+
import "../hook-form/RHFAutocompleteAsync/index.js";
|
|
14
|
+
import "../hook-form/RHFCheckbox/index.js";
|
|
15
|
+
import { R as RHFDateTime } from "../hook-form/RHFDateTime.js";
|
|
16
|
+
import "@mui/x-date-pickers";
|
|
17
|
+
import { R as RHFTextField } from "../hook-form/RHFTextField/index.js";
|
|
18
|
+
import "../../lodash.js";
|
|
19
|
+
import "../../react-lazy-load-image-component.js";
|
|
20
|
+
import "../Image/index.js";
|
|
21
|
+
import "../hook-form/RHFUpload.js";
|
|
22
|
+
import { format } from "date-fns";
|
|
23
|
+
import { I as IconButton } from "../mui_extended/IconButton/index.js";
|
|
24
|
+
import { I as Icon } from "../Icon/index.js";
|
|
25
|
+
import "../../simplebar.js";
|
|
26
|
+
import { S as Scrollbar } from "../ScrollBar/index.js";
|
|
27
|
+
import { L as LabelMemuItem } from "../mui_extended/MenuActions/index.js";
|
|
28
|
+
import { M as MenuPopover } from "../mui_extended/MenuPopover/index.js";
|
|
29
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
30
|
+
const WrapperApplyedFilters = styled("div")(({
|
|
31
|
+
theme
|
|
32
|
+
}) => ({
|
|
33
|
+
width: "100%",
|
|
34
|
+
display: "flex",
|
|
35
|
+
justifyContent: "flex-start",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
height: theme.spacing(3.75),
|
|
38
|
+
gap: theme.spacing(1.5)
|
|
39
|
+
}));
|
|
40
|
+
const STRING_OPERATORS = ["c", "nc"];
|
|
41
|
+
const BOOLEAN_OPERATORS = ["e", "ne"];
|
|
42
|
+
const DATE_TIME_OPERATORS = [
|
|
43
|
+
"b",
|
|
44
|
+
"e",
|
|
45
|
+
"ne",
|
|
46
|
+
"gt",
|
|
47
|
+
"gte",
|
|
48
|
+
"lt",
|
|
49
|
+
"lte"
|
|
50
|
+
];
|
|
51
|
+
const ALL_FIELDS = {
|
|
52
|
+
name: "all",
|
|
53
|
+
label: "filter.all_fields",
|
|
54
|
+
urlIcon: "https://s3.amazonaws.com/static.made4labs/environments/d1/frontend/components/icon/assets/icons/default.svg",
|
|
55
|
+
type: "string",
|
|
56
|
+
multiple: true,
|
|
57
|
+
fixed: false
|
|
58
|
+
};
|
|
59
|
+
const WrapperStringFilter = styled("div")(({
|
|
60
|
+
theme
|
|
61
|
+
}) => ({
|
|
62
|
+
display: "flex",
|
|
63
|
+
flexDirection: "column",
|
|
64
|
+
justifyContent: "center",
|
|
65
|
+
alignItems: "center",
|
|
66
|
+
width: "100%",
|
|
67
|
+
minWidth: theme.spacing(3.75),
|
|
68
|
+
padding: theme.spacing(3, 0),
|
|
69
|
+
gap: theme.spacing(3)
|
|
70
|
+
}));
|
|
71
|
+
const WrapperAutoComplete$2 = styled("div")(() => ({
|
|
72
|
+
width: "100%"
|
|
73
|
+
}));
|
|
74
|
+
function StringFilter() {
|
|
75
|
+
const {
|
|
76
|
+
popupData: {
|
|
77
|
+
filter,
|
|
78
|
+
field
|
|
79
|
+
},
|
|
80
|
+
setPoupEditValidationSchema,
|
|
81
|
+
setFnTransformFormValuesIntoValues: setTransformFunctionFormValuesToValues,
|
|
82
|
+
getLabelOperator
|
|
83
|
+
} = useBase();
|
|
84
|
+
const {
|
|
85
|
+
getLabel
|
|
86
|
+
} = useModuleDictionary();
|
|
87
|
+
const inputRef = useRef(null);
|
|
88
|
+
const {
|
|
89
|
+
setValue
|
|
90
|
+
} = useFormContext();
|
|
91
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
92
|
+
const options = useMemo(() => STRING_OPERATORS.map((o) => ({
|
|
93
|
+
id: o,
|
|
94
|
+
label: getLabelOperator(o)
|
|
95
|
+
})), [getLabelOperator]);
|
|
96
|
+
const transformFunctionFormValuesToValues = useCallback((data) => {
|
|
97
|
+
if (!filter || !field)
|
|
98
|
+
return void 0;
|
|
99
|
+
const newFilter = {
|
|
100
|
+
id: filter.id,
|
|
101
|
+
fieldName: field.name,
|
|
102
|
+
fixed: filter.fixed,
|
|
103
|
+
isSetted: true,
|
|
104
|
+
operator: data.valueOperator.id,
|
|
105
|
+
labelOperator: data.valueOperator.label,
|
|
106
|
+
operand1: data.valueOperand1,
|
|
107
|
+
labelOperands: data.valueOperand1
|
|
108
|
+
};
|
|
109
|
+
return newFilter;
|
|
110
|
+
}, []);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!isLoaded) {
|
|
113
|
+
setPoupEditValidationSchema({
|
|
114
|
+
valueOperator: Yup.object().nullable().required(getLabel(`operator_required`)),
|
|
115
|
+
valueOperand1: Yup.string().required(getLabel(`operand_required`))
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
setTransformFunctionFormValuesToValues(transformFunctionFormValuesToValues);
|
|
119
|
+
if (filter && field) {
|
|
120
|
+
setValue("valueOperand1", filter.operand1, {
|
|
121
|
+
shouldTouch: false,
|
|
122
|
+
shouldValidate: false
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
setIsLoaded(true);
|
|
126
|
+
}, [getLabel, filter, field]);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
console.debug("InputRef", inputRef);
|
|
129
|
+
inputRef.current?.focus();
|
|
130
|
+
}, [isLoaded]);
|
|
131
|
+
return /* @__PURE__ */ jsx(WrapperStringFilter, {
|
|
132
|
+
children: isLoaded && /* @__PURE__ */ jsxs(Fragment, {
|
|
133
|
+
children: [/* @__PURE__ */ jsx(WrapperAutoComplete$2, {
|
|
134
|
+
children: /* @__PURE__ */ jsx(RHFAutocomplete, {
|
|
135
|
+
name: "valueOperator",
|
|
136
|
+
autoComplete: "off",
|
|
137
|
+
options,
|
|
138
|
+
getOptionLabel: (option) => option.label,
|
|
139
|
+
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
140
|
+
label: ""
|
|
141
|
+
})
|
|
142
|
+
}), /* @__PURE__ */ jsx(RHFTextField, {
|
|
143
|
+
name: "valueOperand1",
|
|
144
|
+
ref: inputRef,
|
|
145
|
+
focused: true
|
|
146
|
+
})]
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const WrapperAllFieldsFilter$1 = styled("div")(({
|
|
151
|
+
theme
|
|
152
|
+
}) => ({
|
|
153
|
+
display: "flex",
|
|
154
|
+
flexDirection: "column",
|
|
155
|
+
justifyContent: "center",
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
width: "100%",
|
|
158
|
+
minWidth: theme.spacing(3.75),
|
|
159
|
+
height: "100%",
|
|
160
|
+
padding: theme.spacing(3, 0),
|
|
161
|
+
gap: theme.spacing(3)
|
|
162
|
+
}));
|
|
163
|
+
const WrapperAutoComplete$1 = styled("div")(() => ({
|
|
164
|
+
width: "100%"
|
|
165
|
+
}));
|
|
166
|
+
function BooleanFilter() {
|
|
167
|
+
const {
|
|
168
|
+
setPoupEditValidationSchema,
|
|
169
|
+
setFnTransformFormValuesIntoValues: setTransformFunctionFormValuesToValues,
|
|
170
|
+
getLabelOperator
|
|
171
|
+
} = useBase();
|
|
172
|
+
const {
|
|
173
|
+
getLabel
|
|
174
|
+
} = useModuleDictionary();
|
|
175
|
+
const {
|
|
176
|
+
popupData: {
|
|
177
|
+
filter,
|
|
178
|
+
field
|
|
179
|
+
}
|
|
180
|
+
} = useBase();
|
|
181
|
+
const {
|
|
182
|
+
setValue
|
|
183
|
+
} = useFormContext();
|
|
184
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
185
|
+
const operators = useMemo(() => BOOLEAN_OPERATORS.map((o) => ({
|
|
186
|
+
id: o,
|
|
187
|
+
label: getLabelOperator(o)
|
|
188
|
+
})), [getLabelOperator]);
|
|
189
|
+
const optionsYesNo = useMemo(() => [{
|
|
190
|
+
value: true,
|
|
191
|
+
label: getLabel("filter.operand_true")
|
|
192
|
+
}, {
|
|
193
|
+
value: false,
|
|
194
|
+
label: getLabel("filter.operand_false")
|
|
195
|
+
}], [getLabel]);
|
|
196
|
+
const transformFunctionFormValuesToValues = useCallback((data) => {
|
|
197
|
+
if (!filter || !field)
|
|
198
|
+
return void 0;
|
|
199
|
+
const newFilter = {
|
|
200
|
+
id: filter.id,
|
|
201
|
+
fieldName: field.name,
|
|
202
|
+
fixed: filter.fixed,
|
|
203
|
+
isSetted: true,
|
|
204
|
+
operator: data.valueOperator.id,
|
|
205
|
+
labelOperator: data.valueOperator.label,
|
|
206
|
+
operand1: data.valueOperand1.value,
|
|
207
|
+
labelOperands: data.valueOperand1.label
|
|
208
|
+
};
|
|
209
|
+
return newFilter;
|
|
210
|
+
}, []);
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
if (!isLoaded) {
|
|
213
|
+
setPoupEditValidationSchema({
|
|
214
|
+
valueOperator: Yup.object().nullable().required(getLabel(`operator_required`)),
|
|
215
|
+
valueOperand1: Yup.object().nullable().required(getLabel(`operand_required`))
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
setTransformFunctionFormValuesToValues(transformFunctionFormValuesToValues);
|
|
219
|
+
if (filter && field) {
|
|
220
|
+
setValue("valueOperand1", {
|
|
221
|
+
value: filter.operand1,
|
|
222
|
+
label: getLabel(`filter.operand_${filter.operand1}`)
|
|
223
|
+
}, {
|
|
224
|
+
shouldTouch: false,
|
|
225
|
+
shouldValidate: false
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
setIsLoaded(true);
|
|
229
|
+
}, [getLabel]);
|
|
230
|
+
return /* @__PURE__ */ jsx(WrapperAllFieldsFilter$1, {
|
|
231
|
+
id: "WrapperAllFieldsFilter",
|
|
232
|
+
children: isLoaded && /* @__PURE__ */ jsxs(Fragment, {
|
|
233
|
+
children: [/* @__PURE__ */ jsx(WrapperAutoComplete$1, {
|
|
234
|
+
children: /* @__PURE__ */ jsx(RHFAutocomplete, {
|
|
235
|
+
name: "valueOperator",
|
|
236
|
+
autoComplete: "off",
|
|
237
|
+
options: operators,
|
|
238
|
+
getOptionLabel: (option) => option.label,
|
|
239
|
+
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
240
|
+
label: ""
|
|
241
|
+
})
|
|
242
|
+
}), /* @__PURE__ */ jsx(WrapperAutoComplete$1, {
|
|
243
|
+
children: /* @__PURE__ */ jsx(RHFAutocomplete, {
|
|
244
|
+
name: "valueOperand1",
|
|
245
|
+
autoComplete: "off",
|
|
246
|
+
options: optionsYesNo,
|
|
247
|
+
getOptionLabel: (option) => option.label,
|
|
248
|
+
isOptionEqualToValue: (option, value) => option.value === value.value,
|
|
249
|
+
label: ""
|
|
250
|
+
})
|
|
251
|
+
})]
|
|
252
|
+
})
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const WrapperAllFieldsFilter = styled("div")(({
|
|
256
|
+
theme
|
|
257
|
+
}) => ({
|
|
258
|
+
display: "flex",
|
|
259
|
+
flexDirection: "column",
|
|
260
|
+
justifyContent: "center",
|
|
261
|
+
alignItems: "center",
|
|
262
|
+
width: "100%",
|
|
263
|
+
minWidth: theme.spacing(3.75),
|
|
264
|
+
padding: theme.spacing(3, 0),
|
|
265
|
+
gap: theme.spacing(3)
|
|
266
|
+
}));
|
|
267
|
+
const WrapperAutoComplete = styled("div")(() => ({
|
|
268
|
+
width: "100%"
|
|
269
|
+
}));
|
|
270
|
+
function DateTimeFilter() {
|
|
271
|
+
const {
|
|
272
|
+
setPoupEditValidationSchema,
|
|
273
|
+
setFnTransformFormValuesIntoValues: setTransformFunctionFormValuesToValues,
|
|
274
|
+
getLabelOperator
|
|
275
|
+
} = useBase();
|
|
276
|
+
const {
|
|
277
|
+
getLabel
|
|
278
|
+
} = useModuleDictionary();
|
|
279
|
+
const {
|
|
280
|
+
popupData: {
|
|
281
|
+
filter,
|
|
282
|
+
field
|
|
283
|
+
}
|
|
284
|
+
} = useBase();
|
|
285
|
+
const {
|
|
286
|
+
control,
|
|
287
|
+
setValue
|
|
288
|
+
} = useFormContext();
|
|
289
|
+
const operator = useWatch({
|
|
290
|
+
control,
|
|
291
|
+
name: "valueOperator"
|
|
292
|
+
});
|
|
293
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
294
|
+
const options = useMemo(() => DATE_TIME_OPERATORS.map((o) => ({
|
|
295
|
+
id: o,
|
|
296
|
+
label: getLabelOperator(o)
|
|
297
|
+
})), [getLabelOperator]);
|
|
298
|
+
const transformFunctionFormValuesToValues = useCallback((data) => {
|
|
299
|
+
if (!filter || !field)
|
|
300
|
+
return void 0;
|
|
301
|
+
const newFilter = {
|
|
302
|
+
id: filter.id,
|
|
303
|
+
fieldName: field.name,
|
|
304
|
+
fixed: filter.fixed,
|
|
305
|
+
isSetted: true,
|
|
306
|
+
operator: data.valueOperator.id,
|
|
307
|
+
operand1: data.valueOperand1.toISOString(),
|
|
308
|
+
labelOperator: data.valueOperator.label,
|
|
309
|
+
labelOperands: ""
|
|
310
|
+
};
|
|
311
|
+
if (data.valueOperator.id === "b") {
|
|
312
|
+
newFilter.operand2 = data.valueOperand2.toISOString();
|
|
313
|
+
newFilter.labelOperands = `${format(data.valueOperand1, "yyyy-MM-dd HH:mm:ss")} - ${format(data.valueOperand2, "yyyy-MM-dd HH:mm:ss")}`;
|
|
314
|
+
} else {
|
|
315
|
+
newFilter.operand2 = newFilter.operand2 ? newFilter.operand2 : newFilter.operand1;
|
|
316
|
+
newFilter.labelOperands = format(data.valueOperand1, "yyyy-MM-dd HH:mm:ss");
|
|
317
|
+
}
|
|
318
|
+
return newFilter;
|
|
319
|
+
}, []);
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
console.debug("useEffect Datetime", isLoaded, filter?.operand1, filter?.operand2);
|
|
322
|
+
if (!isLoaded) {
|
|
323
|
+
setPoupEditValidationSchema({
|
|
324
|
+
valueOperator: Yup.object().nullable().required(getLabel(`operator_required`)),
|
|
325
|
+
valueOperand1: Yup.date().test("valueOperand1", getLabel(`filter.error_invalid_date1`), (value) => {
|
|
326
|
+
return Boolean(value);
|
|
327
|
+
}),
|
|
328
|
+
valueOperand2: Yup.date().when(["valueOperator.id"], {
|
|
329
|
+
is: "b",
|
|
330
|
+
then: Yup.date().test("DOB", getLabel(`filter.error_invalid_date2`), (value) => {
|
|
331
|
+
return Boolean(value);
|
|
332
|
+
})
|
|
333
|
+
})
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
if (filter && field) {
|
|
337
|
+
setValue("valueOperand1", new Date(filter.operand1), {
|
|
338
|
+
shouldTouch: false,
|
|
339
|
+
shouldValidate: false
|
|
340
|
+
});
|
|
341
|
+
setValue("valueOperand2", new Date(filter.operand2), {
|
|
342
|
+
shouldTouch: false,
|
|
343
|
+
shouldValidate: false
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
setTransformFunctionFormValuesToValues(transformFunctionFormValuesToValues);
|
|
347
|
+
setIsLoaded(true);
|
|
348
|
+
}, [getLabel, filter, field]);
|
|
349
|
+
return /* @__PURE__ */ jsx(WrapperAllFieldsFilter, {
|
|
350
|
+
children: isLoaded && /* @__PURE__ */ jsxs(Fragment, {
|
|
351
|
+
children: [/* @__PURE__ */ jsx(WrapperAutoComplete, {
|
|
352
|
+
children: /* @__PURE__ */ jsx(RHFAutocomplete, {
|
|
353
|
+
name: "valueOperator",
|
|
354
|
+
autoComplete: "off",
|
|
355
|
+
options,
|
|
356
|
+
getOptionLabel: (option) => option.label,
|
|
357
|
+
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
358
|
+
label: ""
|
|
359
|
+
})
|
|
360
|
+
}), /* @__PURE__ */ jsx(RHFDateTime, {
|
|
361
|
+
name: "valueOperand1",
|
|
362
|
+
autoComplete: "off",
|
|
363
|
+
label: ""
|
|
364
|
+
}), operator && operator.id === "b" && /* @__PURE__ */ jsx(RHFDateTime, {
|
|
365
|
+
name: "valueOperand2",
|
|
366
|
+
autoComplete: "off",
|
|
367
|
+
label: ""
|
|
368
|
+
})]
|
|
369
|
+
})
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function isValidDate(d) {
|
|
373
|
+
return d && d instanceof Date;
|
|
374
|
+
}
|
|
375
|
+
const verifyStringFilter = (filter) => {
|
|
376
|
+
if (typeof filter.operator !== "string") {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
if (STRING_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
if (typeof filter.operand1 !== "string") {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
return true;
|
|
386
|
+
};
|
|
387
|
+
const verifyBooleanFilter = (filter) => {
|
|
388
|
+
if (typeof filter.operator !== "string") {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
if (BOOLEAN_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
if (typeof filter.operand1 !== "boolean") {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
return true;
|
|
398
|
+
};
|
|
399
|
+
const verifyDateTime = (filter) => {
|
|
400
|
+
if (typeof filter.operator !== "string") {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
if (DATE_TIME_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
if (typeof filter.operand1 !== "string") {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
if (filter.operator === "b" && typeof filter.operand2 !== "string") {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
return true;
|
|
413
|
+
};
|
|
414
|
+
const getDefaultFilterValues = (field, fixed, getLabelOperator) => {
|
|
415
|
+
const defaultStartDate = new Date();
|
|
416
|
+
const defaultEndDate = new Date();
|
|
417
|
+
let dfop1 = field.defaultOperand1;
|
|
418
|
+
let dfop2 = field.defaultOperand2;
|
|
419
|
+
const defaultFilter = {
|
|
420
|
+
id: 0,
|
|
421
|
+
fieldName: field.name,
|
|
422
|
+
fixed,
|
|
423
|
+
isSetted: false,
|
|
424
|
+
operator: "c",
|
|
425
|
+
labelOperator: "",
|
|
426
|
+
operand1: "",
|
|
427
|
+
labelOperands: ""
|
|
428
|
+
};
|
|
429
|
+
switch (field.type) {
|
|
430
|
+
case "string":
|
|
431
|
+
break;
|
|
432
|
+
case "number":
|
|
433
|
+
case "boolean":
|
|
434
|
+
defaultFilter.operator = "e";
|
|
435
|
+
if (dfop1 !== void 0 && typeof dfop1 === "boolean") {
|
|
436
|
+
defaultFilter.operand1 = dfop1;
|
|
437
|
+
} else {
|
|
438
|
+
defaultFilter.operand1 = true;
|
|
439
|
+
}
|
|
440
|
+
break;
|
|
441
|
+
case "time":
|
|
442
|
+
case "date":
|
|
443
|
+
case "datetime":
|
|
444
|
+
if (dfop1) {
|
|
445
|
+
if (isValidDate(dfop1)) {
|
|
446
|
+
defaultStartDate.setDate(dfop1.getDate());
|
|
447
|
+
} else {
|
|
448
|
+
dfop1 = void 0;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (dfop1 === void 0) {
|
|
452
|
+
defaultStartDate.setHours(0, 0, 0, 0);
|
|
453
|
+
}
|
|
454
|
+
if (dfop2) {
|
|
455
|
+
if (isValidDate(dfop2)) {
|
|
456
|
+
defaultEndDate.setDate(dfop2.getDate());
|
|
457
|
+
} else {
|
|
458
|
+
dfop2 = void 0;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (dfop2 === void 0) {
|
|
462
|
+
defaultEndDate.setHours(23, 59, 59, 999);
|
|
463
|
+
}
|
|
464
|
+
defaultFilter.operator = "b";
|
|
465
|
+
defaultFilter.operand1 = defaultStartDate.toISOString();
|
|
466
|
+
defaultFilter.operand2 = defaultEndDate.toISOString();
|
|
467
|
+
defaultFilter.labelOperands = `${format(defaultStartDate, "yyyy-MM-dd HH:mm:ss")} - ${format(defaultEndDate, "yyyy-MM-dd HH:mm:ss")}`;
|
|
468
|
+
defaultFilter.isSetted = true;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
defaultFilter.labelOperator = getLabelOperator(defaultFilter.operator);
|
|
472
|
+
console.log("operator", defaultFilter);
|
|
473
|
+
return defaultFilter;
|
|
474
|
+
};
|
|
475
|
+
const PopupEditFilterComponent = (props) => {
|
|
476
|
+
const {
|
|
477
|
+
getFieldByName
|
|
478
|
+
} = useBase();
|
|
479
|
+
const field = getFieldByName(props.filter.fieldName);
|
|
480
|
+
if (!field)
|
|
481
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
482
|
+
switch (field.type) {
|
|
483
|
+
case "string":
|
|
484
|
+
return /* @__PURE__ */ jsx(StringFilter, {});
|
|
485
|
+
case "boolean":
|
|
486
|
+
return /* @__PURE__ */ jsx(BooleanFilter, {});
|
|
487
|
+
case "datetime":
|
|
488
|
+
return /* @__PURE__ */ jsx(DateTimeFilter, {});
|
|
489
|
+
default:
|
|
490
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
const initialState = {
|
|
494
|
+
fields: [],
|
|
495
|
+
withAllField: true,
|
|
496
|
+
isDirty: false,
|
|
497
|
+
isValid: true,
|
|
498
|
+
automatic: false,
|
|
499
|
+
availableFields: [],
|
|
500
|
+
getFieldByName: () => void 0,
|
|
501
|
+
getLabelOperator: () => "",
|
|
502
|
+
applyedFilters: [],
|
|
503
|
+
addFilter: voidFunction,
|
|
504
|
+
updateFilter: voidFunction,
|
|
505
|
+
removeFilter: voidFunction,
|
|
506
|
+
clearFilters: voidFunction,
|
|
507
|
+
fireOnChangeFilters: voidFunction,
|
|
508
|
+
openAnchorEl: null,
|
|
509
|
+
openMenuFields: voidFunction,
|
|
510
|
+
closeMenuFields: voidFunction,
|
|
511
|
+
popupData: {
|
|
512
|
+
popupAnchorEl: null,
|
|
513
|
+
filter: null,
|
|
514
|
+
field: null
|
|
515
|
+
},
|
|
516
|
+
popupValidationSchema: {},
|
|
517
|
+
setPoupEditValidationSchema: voidFunction,
|
|
518
|
+
showPopupForAddFilter: voidFunction,
|
|
519
|
+
showPopupForEditFilter: voidFunction,
|
|
520
|
+
hidePopupEdit: voidFunction,
|
|
521
|
+
setInEdition: voidFunction,
|
|
522
|
+
inEdition: false,
|
|
523
|
+
setFnTransformFormValuesIntoValues: voidFunction,
|
|
524
|
+
fnTransformFormValuesIntoRawValues: () => void 0
|
|
525
|
+
};
|
|
526
|
+
const BaseContext = createContext(initialState);
|
|
527
|
+
const getMaxId = (applyedFilters) => {
|
|
528
|
+
return applyedFilters.reduce((prev, n) => {
|
|
529
|
+
return n.id > prev ? n.id : prev;
|
|
530
|
+
}, 0);
|
|
531
|
+
};
|
|
532
|
+
const getFilterById = (id, applyedFilters) => {
|
|
533
|
+
return applyedFilters.findIndex((f) => f.id === id);
|
|
534
|
+
};
|
|
535
|
+
const getRawFilter = (applyedFilter) => {
|
|
536
|
+
return applyedFilter.map((af) => ({
|
|
537
|
+
n: af.fieldName,
|
|
538
|
+
o: af.operator,
|
|
539
|
+
o1: af.operand1,
|
|
540
|
+
o2: af.operand2
|
|
541
|
+
}));
|
|
542
|
+
};
|
|
543
|
+
const getInitialFilters = (fields, filters, getFieldByName, getLabelOperator) => {
|
|
544
|
+
const newFilters = [];
|
|
545
|
+
const fixedFields = [];
|
|
546
|
+
for (let index = 0; index < filters.length; index++) {
|
|
547
|
+
let add;
|
|
548
|
+
const filter = {
|
|
549
|
+
...filters[index],
|
|
550
|
+
id: 0,
|
|
551
|
+
isSetted: true,
|
|
552
|
+
fixed: false
|
|
553
|
+
};
|
|
554
|
+
const field = getFieldByName(filter.fieldName);
|
|
555
|
+
if (!field)
|
|
556
|
+
continue;
|
|
557
|
+
switch (field.type) {
|
|
558
|
+
case "string":
|
|
559
|
+
add = verifyStringFilter(filter);
|
|
560
|
+
break;
|
|
561
|
+
case "boolean":
|
|
562
|
+
add = verifyBooleanFilter(filter);
|
|
563
|
+
break;
|
|
564
|
+
case "datetime":
|
|
565
|
+
add = verifyDateTime(filter);
|
|
566
|
+
break;
|
|
567
|
+
default:
|
|
568
|
+
add = false;
|
|
569
|
+
}
|
|
570
|
+
if (add) {
|
|
571
|
+
if (field.fixed) {
|
|
572
|
+
if (fixedFields.findIndex((f) => f === field.name) === -1) {
|
|
573
|
+
filter.fixed = true;
|
|
574
|
+
fixedFields.push(field.name);
|
|
575
|
+
} else {
|
|
576
|
+
filter.fixed = false;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
filter.isSetted = true;
|
|
580
|
+
filter.id = newFilters.length + 1;
|
|
581
|
+
newFilters.push(filter);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
for (let index = 0; index < fields.length; index++) {
|
|
585
|
+
const field = fields[index];
|
|
586
|
+
if (field.fixed) {
|
|
587
|
+
if (!filters.find((f) => f.fieldName === field.name)) {
|
|
588
|
+
const newFilter = getDefaultFilterValues(field, true, getLabelOperator);
|
|
589
|
+
newFilter.id = newFilters.length + 1;
|
|
590
|
+
newFilters.push(newFilter);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return newFilters;
|
|
595
|
+
};
|
|
596
|
+
function BaseProvider(props) {
|
|
597
|
+
const {
|
|
598
|
+
isSkeleton = false,
|
|
599
|
+
fields,
|
|
600
|
+
initialFilters = [],
|
|
601
|
+
withAllField = true,
|
|
602
|
+
onChangeFilter,
|
|
603
|
+
automatic = true,
|
|
604
|
+
children
|
|
605
|
+
} = props;
|
|
606
|
+
const [openAnchorEl, setOpenAnchorEl] = useState(null);
|
|
607
|
+
const [popupData, setPopupData] = useState({
|
|
608
|
+
popupAnchorEl: null,
|
|
609
|
+
filter: null,
|
|
610
|
+
field: null
|
|
611
|
+
});
|
|
612
|
+
const {
|
|
613
|
+
getLabel
|
|
614
|
+
} = useModuleDictionary();
|
|
615
|
+
const [popupValidationSchema, setInternalPopupValidationSchema] = useState(Yup.object().shape({}));
|
|
616
|
+
const [fnTransformFormValuesIntoRawValues, setInternalfnTransormFormValuesIntoRawValues] = useState(() => void 0);
|
|
617
|
+
const all_fields = useMemo(() => {
|
|
618
|
+
return {
|
|
619
|
+
...ALL_FIELDS,
|
|
620
|
+
label: getLabel("filter.all_fields")
|
|
621
|
+
};
|
|
622
|
+
}, [getLabel]);
|
|
623
|
+
const [inEdition, setInEdition] = useState(false);
|
|
624
|
+
const [isDirty, setIsDirty] = useState(!automatic);
|
|
625
|
+
const [isValid, setIsValid] = useState(false);
|
|
626
|
+
const {
|
|
627
|
+
toast
|
|
628
|
+
} = useHostTools();
|
|
629
|
+
const getFieldByName = useCallback((name) => {
|
|
630
|
+
return fields.concat(all_fields).find((f) => {
|
|
631
|
+
return f.name === name;
|
|
632
|
+
});
|
|
633
|
+
}, [fields, all_fields]);
|
|
634
|
+
const getLabelOperator = useCallback((operator) => {
|
|
635
|
+
return getLabel(`filter.operator_${operator}`);
|
|
636
|
+
}, [getLabel]);
|
|
637
|
+
const [applyedFilters, setApplyedFilters] = useState(getInitialFilters(fields, initialFilters, getFieldByName, getLabelOperator));
|
|
638
|
+
const availableFields = useMemo(() => {
|
|
639
|
+
const newFields = [];
|
|
640
|
+
for (let index = 0; index < fields.length; index++) {
|
|
641
|
+
let add;
|
|
642
|
+
const field = fields[index];
|
|
643
|
+
add = true;
|
|
644
|
+
if (field.multiple !== void 0 && field.multiple === false) {
|
|
645
|
+
const fIndx = applyedFilters.findIndex((f) => f.fieldName === field.name);
|
|
646
|
+
if (fIndx > -1) {
|
|
647
|
+
add = false;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (add) {
|
|
651
|
+
newFields.push(field);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
return newFields;
|
|
655
|
+
}, [fields, applyedFilters]);
|
|
656
|
+
const fireOnChangeFilters = useCallback(() => {
|
|
657
|
+
if (isValid) {
|
|
658
|
+
if (!automatic)
|
|
659
|
+
setIsDirty(false);
|
|
660
|
+
onChangeFilter(applyedFilters, getRawFilter(applyedFilters));
|
|
661
|
+
} else {
|
|
662
|
+
toast(getLabel("filter.error_filters_no_setted"), {
|
|
663
|
+
type: "error",
|
|
664
|
+
autoClose: 1e4
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}, [isValid, applyedFilters]);
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
const NoValid = applyedFilters.findIndex((f) => !f.isSetted) > -1;
|
|
670
|
+
if (NoValid) {
|
|
671
|
+
setIsValid(false);
|
|
672
|
+
} else {
|
|
673
|
+
setIsValid(true);
|
|
674
|
+
}
|
|
675
|
+
if (!automatic) {
|
|
676
|
+
setIsDirty(true);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (!NoValid) {
|
|
680
|
+
console.log("Ingrese");
|
|
681
|
+
setIsDirty(false);
|
|
682
|
+
onChangeFilter(applyedFilters, getRawFilter(applyedFilters));
|
|
683
|
+
}
|
|
684
|
+
}, [applyedFilters]);
|
|
685
|
+
const addFilter = useCallback((newFilter) => {
|
|
686
|
+
setApplyedFilters((lastApplyedFilters) => {
|
|
687
|
+
const newArray = [...lastApplyedFilters];
|
|
688
|
+
const newFilterFull = {
|
|
689
|
+
...newFilter,
|
|
690
|
+
id: getMaxId(lastApplyedFilters) + 1,
|
|
691
|
+
labelOperator: getLabelOperator(newFilter.operator)
|
|
692
|
+
};
|
|
693
|
+
newArray.push(newFilterFull);
|
|
694
|
+
return newArray;
|
|
695
|
+
});
|
|
696
|
+
}, []);
|
|
697
|
+
const updateFilter = useCallback((newFilter) => {
|
|
698
|
+
setApplyedFilters((lastApplyedFilters) => {
|
|
699
|
+
const newArray = [...lastApplyedFilters];
|
|
700
|
+
const findedFilter = getFilterById(newFilter.id, newArray);
|
|
701
|
+
if (findedFilter > -1) {
|
|
702
|
+
newArray.splice(findedFilter, 1, {
|
|
703
|
+
...newFilter,
|
|
704
|
+
labelOperator: getLabelOperator(newFilter.operator)
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
return newArray;
|
|
708
|
+
});
|
|
709
|
+
}, []);
|
|
710
|
+
const clearFilters = useCallback(() => {
|
|
711
|
+
setApplyedFilters((lastFilters) => {
|
|
712
|
+
const newFilters = [];
|
|
713
|
+
for (let index = 0; index < lastFilters.length; index++) {
|
|
714
|
+
const filter = lastFilters[index];
|
|
715
|
+
if (filter.fixed) {
|
|
716
|
+
newFilters.push(filter);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return newFilters;
|
|
720
|
+
});
|
|
721
|
+
}, []);
|
|
722
|
+
const openMenuFields = useCallback((anchorEl) => {
|
|
723
|
+
setOpenAnchorEl(anchorEl);
|
|
724
|
+
setInEdition(true);
|
|
725
|
+
}, [applyedFilters]);
|
|
726
|
+
const closeMenuFields = useCallback(() => {
|
|
727
|
+
setOpenAnchorEl(null);
|
|
728
|
+
setInEdition(false);
|
|
729
|
+
}, []);
|
|
730
|
+
const hidePopupEdit = useCallback((stayInEditon) => {
|
|
731
|
+
if (popupData.popupAnchorEl) {
|
|
732
|
+
setPopupData({
|
|
733
|
+
popupAnchorEl: null,
|
|
734
|
+
filter: null,
|
|
735
|
+
field: null
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
if (!stayInEditon && inEdition) {
|
|
739
|
+
setInEdition(false);
|
|
740
|
+
}
|
|
741
|
+
}, [popupData, inEdition]);
|
|
742
|
+
const showPopupForAddFilter = useCallback((anchorEl, field) => {
|
|
743
|
+
setPopupData({
|
|
744
|
+
popupAnchorEl: anchorEl,
|
|
745
|
+
filter: getDefaultFilterValues(field, false, getLabelOperator),
|
|
746
|
+
field
|
|
747
|
+
});
|
|
748
|
+
setInEdition(true);
|
|
749
|
+
}, []);
|
|
750
|
+
const showPopupForEditFilter = useCallback((anchorEl, filterToEdit) => {
|
|
751
|
+
setPopupData({
|
|
752
|
+
popupAnchorEl: anchorEl,
|
|
753
|
+
filter: filterToEdit,
|
|
754
|
+
field: getFieldByName(filterToEdit.fieldName)
|
|
755
|
+
});
|
|
756
|
+
setInEdition(true);
|
|
757
|
+
}, []);
|
|
758
|
+
const removeFilter = useCallback((id) => {
|
|
759
|
+
setApplyedFilters((lastApplyedFilters) => {
|
|
760
|
+
const newArray = [...lastApplyedFilters];
|
|
761
|
+
const index_to_remove = lastApplyedFilters.findIndex((filter) => id === filter.id);
|
|
762
|
+
if (index_to_remove > -1) {
|
|
763
|
+
if (!newArray[index_to_remove].fixed) {
|
|
764
|
+
newArray.splice(index_to_remove, 1);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return newArray;
|
|
768
|
+
});
|
|
769
|
+
}, []);
|
|
770
|
+
const setPoupEditValidationSchema = useCallback((validationSchema) => {
|
|
771
|
+
setInternalPopupValidationSchema(Yup.object().shape({
|
|
772
|
+
...validationSchema
|
|
773
|
+
}));
|
|
774
|
+
}, []);
|
|
775
|
+
const setFnTransformFormValuesIntoValues = useCallback((fn) => {
|
|
776
|
+
setInternalfnTransormFormValuesIntoRawValues(() => fn);
|
|
777
|
+
}, []);
|
|
778
|
+
console.log("popupData value", popupData);
|
|
779
|
+
return /* @__PURE__ */ jsx(BaseContext.Provider, {
|
|
780
|
+
value: {
|
|
781
|
+
isSkeleton,
|
|
782
|
+
inEdition,
|
|
783
|
+
automatic,
|
|
784
|
+
isDirty,
|
|
785
|
+
isValid,
|
|
786
|
+
withAllField,
|
|
787
|
+
fields,
|
|
788
|
+
availableFields,
|
|
789
|
+
getFieldByName,
|
|
790
|
+
getLabelOperator,
|
|
791
|
+
applyedFilters,
|
|
792
|
+
addFilter,
|
|
793
|
+
updateFilter,
|
|
794
|
+
removeFilter,
|
|
795
|
+
clearFilters,
|
|
796
|
+
fireOnChangeFilters,
|
|
797
|
+
openAnchorEl,
|
|
798
|
+
openMenuFields,
|
|
799
|
+
closeMenuFields,
|
|
800
|
+
popupData,
|
|
801
|
+
popupValidationSchema,
|
|
802
|
+
showPopupForAddFilter,
|
|
803
|
+
showPopupForEditFilter,
|
|
804
|
+
hidePopupEdit,
|
|
805
|
+
setInEdition,
|
|
806
|
+
setPoupEditValidationSchema,
|
|
807
|
+
fnTransformFormValuesIntoRawValues,
|
|
808
|
+
setFnTransformFormValuesIntoValues
|
|
809
|
+
},
|
|
810
|
+
children
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
const useBase = () => useContext(BaseContext);
|
|
814
|
+
const WrapperApplyedFilter = styled("div")(({
|
|
815
|
+
theme
|
|
816
|
+
}) => ({
|
|
817
|
+
width: "auto",
|
|
818
|
+
display: "flex",
|
|
819
|
+
justifyContent: "center",
|
|
820
|
+
alignItems: "center",
|
|
821
|
+
height: theme.spacing(3.75),
|
|
822
|
+
padding: theme.spacing(1),
|
|
823
|
+
backgroundColor: theme.palette.action.disabledBackground,
|
|
824
|
+
borderRadius: theme.spacing(1),
|
|
825
|
+
"&.waf_no_setted": {
|
|
826
|
+
border: `1px solid ${theme.palette.error.main}`
|
|
827
|
+
}
|
|
828
|
+
}));
|
|
829
|
+
const AplyedFilterStyled = styled("div")(({
|
|
830
|
+
theme
|
|
831
|
+
}) => ({
|
|
832
|
+
...theme.typography.body2,
|
|
833
|
+
display: "flex",
|
|
834
|
+
justifyContent: "center",
|
|
835
|
+
alignItems: "center",
|
|
836
|
+
width: "auto",
|
|
837
|
+
height: theme.spacing(3.75),
|
|
838
|
+
marginRight: theme.spacing(1),
|
|
839
|
+
marginLeft: theme.spacing(1),
|
|
840
|
+
whiteSpace: "nowrap"
|
|
841
|
+
}));
|
|
842
|
+
const ContainerField = styled("span")(({
|
|
843
|
+
theme
|
|
844
|
+
}) => ({
|
|
845
|
+
...theme.typography.subtitle2
|
|
846
|
+
}));
|
|
847
|
+
const ContainerOperator = styled("span")(({
|
|
848
|
+
theme
|
|
849
|
+
}) => ({
|
|
850
|
+
...theme.typography.body2,
|
|
851
|
+
marginLeft: theme.spacing(1.5),
|
|
852
|
+
fontStyle: "italic"
|
|
853
|
+
}));
|
|
854
|
+
const ContainerOperands = styled("span")(({
|
|
855
|
+
theme
|
|
856
|
+
}) => ({
|
|
857
|
+
...theme.typography.body2,
|
|
858
|
+
marginLeft: theme.spacing(1.5)
|
|
859
|
+
}));
|
|
860
|
+
function ApplyedFilter(props) {
|
|
861
|
+
const {
|
|
862
|
+
fieldName,
|
|
863
|
+
id,
|
|
864
|
+
isSetted,
|
|
865
|
+
fixed,
|
|
866
|
+
labelOperator,
|
|
867
|
+
labelOperands
|
|
868
|
+
} = props;
|
|
869
|
+
console.log("props ApplyedFilter ", props);
|
|
870
|
+
const {
|
|
871
|
+
removeFilter,
|
|
872
|
+
showPopupForEditFilter,
|
|
873
|
+
hidePopupEdit,
|
|
874
|
+
getFieldByName,
|
|
875
|
+
isSkeleton
|
|
876
|
+
} = useBase();
|
|
877
|
+
const {
|
|
878
|
+
host_static_assets,
|
|
879
|
+
environment
|
|
880
|
+
} = useEnvironment();
|
|
881
|
+
console.log("fieldName by ApplyedFilter 1", getFieldByName(fieldName));
|
|
882
|
+
const field = useMemo(() => {
|
|
883
|
+
return getFieldByName(fieldName);
|
|
884
|
+
}, [getFieldByName]);
|
|
885
|
+
console.log("fieldName by ApplyedFilter 2", field);
|
|
886
|
+
const urlIcon = useMemo(() => {
|
|
887
|
+
if (!field)
|
|
888
|
+
return;
|
|
889
|
+
if (field && field.urlIcon !== "") {
|
|
890
|
+
return field.urlIcon;
|
|
891
|
+
}
|
|
892
|
+
return "";
|
|
893
|
+
}, [field]);
|
|
894
|
+
console.log("urlIcon value", urlIcon);
|
|
895
|
+
const onDelete = () => {
|
|
896
|
+
hidePopupEdit(false);
|
|
897
|
+
removeFilter(id);
|
|
898
|
+
};
|
|
899
|
+
const onClick = (event) => {
|
|
900
|
+
showPopupForEditFilter(event.currentTarget, props);
|
|
901
|
+
};
|
|
902
|
+
if (!field) {
|
|
903
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
904
|
+
}
|
|
905
|
+
return /* @__PURE__ */ jsxs(WrapperApplyedFilter, {
|
|
906
|
+
id: "WrapperApplyedFilter",
|
|
907
|
+
className: !isSetted ? "waf_no_setted" : "",
|
|
908
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
909
|
+
src: urlIcon,
|
|
910
|
+
onClick
|
|
911
|
+
}), /* @__PURE__ */ jsxs(AplyedFilterStyled, {
|
|
912
|
+
onClick,
|
|
913
|
+
children: [/* @__PURE__ */ jsx(ContainerField, {
|
|
914
|
+
children: field.label
|
|
915
|
+
}), /* @__PURE__ */ jsx(ContainerOperator, {
|
|
916
|
+
children: labelOperator
|
|
917
|
+
}), /* @__PURE__ */ jsx(ContainerOperands, {
|
|
918
|
+
children: labelOperands
|
|
919
|
+
})]
|
|
920
|
+
}), !fixed && /* @__PURE__ */ jsx(IconButton, {
|
|
921
|
+
src: `${host_static_assets}/${environment}/frontend/components/dynamic_filter/assets/icons/close.svg`,
|
|
922
|
+
onClick: onDelete
|
|
923
|
+
})]
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
function ApplyedFilters() {
|
|
927
|
+
const {
|
|
928
|
+
applyedFilters,
|
|
929
|
+
isSkeleton
|
|
930
|
+
} = useBase();
|
|
931
|
+
if (isSkeleton) {
|
|
932
|
+
return /* @__PURE__ */ jsx(WrapperApplyedFilters, {
|
|
933
|
+
id: "WrapperApplyedFilters"
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
return /* @__PURE__ */ jsx("div", {
|
|
937
|
+
style: {
|
|
938
|
+
width: "100%"
|
|
939
|
+
},
|
|
940
|
+
children: /* @__PURE__ */ jsx(Scrollbar, {
|
|
941
|
+
children: /* @__PURE__ */ jsx(WrapperApplyedFilters, {
|
|
942
|
+
id: "WrapperApplyedFilters",
|
|
943
|
+
children: [...applyedFilters].sort((a, b) => a.isSetted === b.isSetted ? 0 : a.isSetted ? -1 : 1).reverse().map((filter) => /* @__PURE__ */ jsx(ApplyedFilter, {
|
|
944
|
+
...filter
|
|
945
|
+
}, filter.id))
|
|
946
|
+
})
|
|
947
|
+
})
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
const SKTClearFilters = styled$1("div")(({
|
|
951
|
+
theme
|
|
952
|
+
}) => ({
|
|
953
|
+
display: "flex",
|
|
954
|
+
justifyContent: "center",
|
|
955
|
+
alignItems: "center",
|
|
956
|
+
minWidth: theme.spacing(3.75),
|
|
957
|
+
height: theme.spacing(3.75)
|
|
958
|
+
}));
|
|
959
|
+
const WrapperClearFilters = styled$1("div")(({
|
|
960
|
+
theme
|
|
961
|
+
}) => ({
|
|
962
|
+
[theme.breakpoints.up("sm")]: {
|
|
963
|
+
paddingLeft: theme.spacing(1.5),
|
|
964
|
+
marginLeft: theme.spacing(1.5),
|
|
965
|
+
borderLeft: `1px solid ${theme.palette.divider}`
|
|
966
|
+
}
|
|
967
|
+
}));
|
|
968
|
+
const ClearFilters = () => {
|
|
969
|
+
const {
|
|
970
|
+
host_static_assets,
|
|
971
|
+
environment
|
|
972
|
+
} = useEnvironment();
|
|
973
|
+
const {
|
|
974
|
+
clearFilters,
|
|
975
|
+
isSkeleton
|
|
976
|
+
} = useBase();
|
|
977
|
+
if (isSkeleton) {
|
|
978
|
+
return /* @__PURE__ */ jsx(SKTClearFilters, {
|
|
979
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
980
|
+
variant: "circular",
|
|
981
|
+
width: "20px",
|
|
982
|
+
height: "20px"
|
|
983
|
+
})
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
return /* @__PURE__ */ jsx(WrapperClearFilters, {
|
|
987
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
988
|
+
src: `${host_static_assets}/${environment}/frontend/components/dynamic_filter/assets/icons/clear.svg`,
|
|
989
|
+
onClick: clearFilters
|
|
990
|
+
})
|
|
991
|
+
});
|
|
992
|
+
};
|
|
993
|
+
const SKTWrapperFilterButton = styled("div")(({
|
|
994
|
+
theme
|
|
995
|
+
}) => ({
|
|
996
|
+
display: "flex",
|
|
997
|
+
justifyContent: "center",
|
|
998
|
+
alignItems: "center",
|
|
999
|
+
minWidth: theme.spacing(3.75),
|
|
1000
|
+
height: theme.spacing(3.75)
|
|
1001
|
+
}));
|
|
1002
|
+
styled("div")(({
|
|
1003
|
+
theme
|
|
1004
|
+
}) => ({
|
|
1005
|
+
display: "flex",
|
|
1006
|
+
justifyContent: "center",
|
|
1007
|
+
alignItems: "center",
|
|
1008
|
+
minWidth: theme.spacing(3.75),
|
|
1009
|
+
height: theme.spacing(3.75)
|
|
1010
|
+
}));
|
|
1011
|
+
const WrapperFilterButton = styled("div")(() => ({
|
|
1012
|
+
"&.isDirty": {
|
|
1013
|
+
"@keyframes dirtyEffect": {
|
|
1014
|
+
from: {
|
|
1015
|
+
opacity: 1
|
|
1016
|
+
},
|
|
1017
|
+
to: {
|
|
1018
|
+
opacity: 0
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
animation: "dirtyEffect 2s infinite ease"
|
|
1022
|
+
},
|
|
1023
|
+
"&.isDirtyError": {}
|
|
1024
|
+
}));
|
|
1025
|
+
function FilterButton() {
|
|
1026
|
+
const {
|
|
1027
|
+
isSkeleton,
|
|
1028
|
+
fireOnChangeFilters,
|
|
1029
|
+
automatic,
|
|
1030
|
+
isDirty,
|
|
1031
|
+
isValid
|
|
1032
|
+
} = useBase();
|
|
1033
|
+
const {
|
|
1034
|
+
host_static_assets,
|
|
1035
|
+
environment
|
|
1036
|
+
} = useEnvironment();
|
|
1037
|
+
console.log("Render isDirty", isDirty, automatic);
|
|
1038
|
+
if (isSkeleton) {
|
|
1039
|
+
return /* @__PURE__ */ jsx(SKTWrapperFilterButton, {
|
|
1040
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
1041
|
+
variant: "circular",
|
|
1042
|
+
width: 20,
|
|
1043
|
+
height: 20
|
|
1044
|
+
})
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
const color = useMemo(() => {
|
|
1048
|
+
if (automatic) {
|
|
1049
|
+
return "default";
|
|
1050
|
+
}
|
|
1051
|
+
if (!isValid) {
|
|
1052
|
+
return "error";
|
|
1053
|
+
}
|
|
1054
|
+
return "primary";
|
|
1055
|
+
}, [automatic, isValid]);
|
|
1056
|
+
return /* @__PURE__ */ jsx(WrapperFilterButton, {
|
|
1057
|
+
className: isDirty && isValid ? "isDirty" : "",
|
|
1058
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1059
|
+
color,
|
|
1060
|
+
dictionaryTooltip: "filter.filter_tooltip",
|
|
1061
|
+
onClick: () => fireOnChangeFilters(),
|
|
1062
|
+
"aria-label": "settings",
|
|
1063
|
+
src: `${host_static_assets}/${environment}/frontend/components/dynamic_filter/assets/icons/${automatic ? "refresh" : "search"}.svg`
|
|
1064
|
+
})
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
const WrapperInputFilter = styled("div")(({
|
|
1068
|
+
theme
|
|
1069
|
+
}) => ({
|
|
1070
|
+
display: "flex",
|
|
1071
|
+
justifyContent: "center",
|
|
1072
|
+
alignItems: "center",
|
|
1073
|
+
width: "100%",
|
|
1074
|
+
height: theme.spacing(3.75),
|
|
1075
|
+
margin: theme.spacing(0, 1.5),
|
|
1076
|
+
padding: theme.spacing(0, 1.5),
|
|
1077
|
+
borderRight: `1px solid ${theme.palette.divider}`,
|
|
1078
|
+
borderLeft: `1px solid ${theme.palette.divider}`,
|
|
1079
|
+
[theme.breakpoints.up("sm")]: {
|
|
1080
|
+
width: theme.spacing(25)
|
|
1081
|
+
}
|
|
1082
|
+
}));
|
|
1083
|
+
const StyledInputFilter = styled("input")(({
|
|
1084
|
+
theme
|
|
1085
|
+
}) => ({
|
|
1086
|
+
display: "flex",
|
|
1087
|
+
justifyContent: "center",
|
|
1088
|
+
alignItems: "center",
|
|
1089
|
+
minWidth: theme.spacing(3.75),
|
|
1090
|
+
height: theme.spacing(3.75),
|
|
1091
|
+
width: "100%",
|
|
1092
|
+
"&": {
|
|
1093
|
+
outline: "none",
|
|
1094
|
+
border: "none"
|
|
1095
|
+
},
|
|
1096
|
+
[theme.breakpoints.up("sm")]: {
|
|
1097
|
+
width: "auto"
|
|
1098
|
+
}
|
|
1099
|
+
}));
|
|
1100
|
+
function InputFilter() {
|
|
1101
|
+
const {
|
|
1102
|
+
isSkeleton,
|
|
1103
|
+
withAllField,
|
|
1104
|
+
availableFields,
|
|
1105
|
+
showPopupForAddFilter,
|
|
1106
|
+
addFilter,
|
|
1107
|
+
openAnchorEl,
|
|
1108
|
+
openMenuFields,
|
|
1109
|
+
closeMenuFields,
|
|
1110
|
+
hidePopupEdit
|
|
1111
|
+
} = useBase();
|
|
1112
|
+
useModuleDictionary();
|
|
1113
|
+
const [valueFilter, setValueFilter] = useState("");
|
|
1114
|
+
const finalFields = useMemo(() => {
|
|
1115
|
+
if (!openAnchorEl) {
|
|
1116
|
+
return [];
|
|
1117
|
+
}
|
|
1118
|
+
return availableFields.filter((field) => field.label.includes(valueFilter));
|
|
1119
|
+
}, [valueFilter, openAnchorEl]);
|
|
1120
|
+
if (isSkeleton) {
|
|
1121
|
+
return /* @__PURE__ */ jsx(WrapperInputFilter, {
|
|
1122
|
+
id: "SKTWrapperInputFilter",
|
|
1123
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
1124
|
+
variant: "text",
|
|
1125
|
+
width: "100%",
|
|
1126
|
+
height: 24
|
|
1127
|
+
})
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
const handleClose = () => {
|
|
1131
|
+
closeMenuFields();
|
|
1132
|
+
};
|
|
1133
|
+
const handleClickItem = (field) => {
|
|
1134
|
+
closeMenuFields();
|
|
1135
|
+
showPopupForAddFilter(openAnchorEl, field);
|
|
1136
|
+
};
|
|
1137
|
+
const onClickFilter = (event) => {
|
|
1138
|
+
openMenuFields(event.currentTarget);
|
|
1139
|
+
};
|
|
1140
|
+
const onChangeFilter = (event) => {
|
|
1141
|
+
setValueFilter(event.target.value);
|
|
1142
|
+
if (!openAnchorEl) {
|
|
1143
|
+
openMenuFields(event.currentTarget);
|
|
1144
|
+
}
|
|
1145
|
+
hidePopupEdit(true);
|
|
1146
|
+
};
|
|
1147
|
+
const handleKeyPressMenu = (event) => {
|
|
1148
|
+
if (event.key !== "Enter")
|
|
1149
|
+
return;
|
|
1150
|
+
if (valueFilter.trim() === "") {
|
|
1151
|
+
closeMenuFields();
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
if (withAllField) {
|
|
1155
|
+
addFilter({
|
|
1156
|
+
fieldName: ALL_FIELDS.name,
|
|
1157
|
+
isSetted: true,
|
|
1158
|
+
fixed: false,
|
|
1159
|
+
operator: "c",
|
|
1160
|
+
operand1: valueFilter,
|
|
1161
|
+
labelOperands: valueFilter
|
|
1162
|
+
});
|
|
1163
|
+
setValueFilter("");
|
|
1164
|
+
closeMenuFields();
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
console.log("Render InputFilter");
|
|
1168
|
+
return /* @__PURE__ */ jsxs(WrapperInputFilter, {
|
|
1169
|
+
id: "WrapperInputFilter",
|
|
1170
|
+
children: [/* @__PURE__ */ jsx(StyledInputFilter, {
|
|
1171
|
+
type: "text",
|
|
1172
|
+
value: valueFilter,
|
|
1173
|
+
placeholder: "filter",
|
|
1174
|
+
onClick: onClickFilter,
|
|
1175
|
+
onChange: onChangeFilter,
|
|
1176
|
+
onKeyPress: handleKeyPressMenu
|
|
1177
|
+
}), /* @__PURE__ */ jsx(MenuPopover, {
|
|
1178
|
+
id: "MenuPopover",
|
|
1179
|
+
open: Boolean(openAnchorEl),
|
|
1180
|
+
anchorEl: openAnchorEl,
|
|
1181
|
+
onClose: handleClose,
|
|
1182
|
+
disableAutoFocus: true,
|
|
1183
|
+
arrow: "right-top",
|
|
1184
|
+
sx: {
|
|
1185
|
+
"& .MuiMenuItem-root": {
|
|
1186
|
+
px: 1,
|
|
1187
|
+
typography: "body2",
|
|
1188
|
+
borderRadius: 0.75
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
children: Boolean(openAnchorEl) && finalFields.map((field, index) => /* @__PURE__ */ jsxs(MenuItem, {
|
|
1192
|
+
dense: true,
|
|
1193
|
+
onClick: () => handleClickItem(field),
|
|
1194
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1195
|
+
src: field.urlIcon
|
|
1196
|
+
}), /* @__PURE__ */ jsx(LabelMemuItem, {
|
|
1197
|
+
children: field.label
|
|
1198
|
+
})]
|
|
1199
|
+
}, `menu_action_${index}`))
|
|
1200
|
+
})]
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
const WrapperPopupEditFilter = styled("div")(({
|
|
1204
|
+
theme
|
|
1205
|
+
}) => ({
|
|
1206
|
+
display: "flex",
|
|
1207
|
+
flexDirection: "column",
|
|
1208
|
+
justifyContent: "center",
|
|
1209
|
+
alignItems: "center",
|
|
1210
|
+
padding: theme.spacing(1.4, 3, 3, 3),
|
|
1211
|
+
backgroundColor: theme.palette.background.default,
|
|
1212
|
+
borderRadius: theme.spacing(1)
|
|
1213
|
+
}));
|
|
1214
|
+
const PopperActionsContainer = styled("div")(({
|
|
1215
|
+
theme
|
|
1216
|
+
}) => ({
|
|
1217
|
+
display: "flex",
|
|
1218
|
+
justifyContent: "center",
|
|
1219
|
+
gap: theme.spacing(3),
|
|
1220
|
+
paddingTop: theme.spacing(3)
|
|
1221
|
+
}));
|
|
1222
|
+
const TitleContainer = styled("div")(({
|
|
1223
|
+
theme
|
|
1224
|
+
}) => ({
|
|
1225
|
+
...theme.typography.subtitle2,
|
|
1226
|
+
width: "100%",
|
|
1227
|
+
display: "flex",
|
|
1228
|
+
justifyContent: "flex-start",
|
|
1229
|
+
alignItems: "center",
|
|
1230
|
+
padding: theme.spacing(2, 0),
|
|
1231
|
+
marginLeft: theme.spacing(1.5)
|
|
1232
|
+
}));
|
|
1233
|
+
const HeaderContainer = styled("div")(({
|
|
1234
|
+
theme
|
|
1235
|
+
}) => ({
|
|
1236
|
+
width: "100%",
|
|
1237
|
+
display: "flex",
|
|
1238
|
+
justifyContent: "flex-start",
|
|
1239
|
+
alignItems: "center",
|
|
1240
|
+
borderBottom: `1px solid ${theme.palette.divider}`
|
|
1241
|
+
}));
|
|
1242
|
+
const PopupEditFilter = () => {
|
|
1243
|
+
const {
|
|
1244
|
+
popupValidationSchema,
|
|
1245
|
+
popupData: {
|
|
1246
|
+
popupAnchorEl,
|
|
1247
|
+
filter,
|
|
1248
|
+
field
|
|
1249
|
+
},
|
|
1250
|
+
hidePopupEdit,
|
|
1251
|
+
addFilter,
|
|
1252
|
+
updateFilter,
|
|
1253
|
+
getLabelOperator,
|
|
1254
|
+
fnTransformFormValuesIntoRawValues
|
|
1255
|
+
} = useBase();
|
|
1256
|
+
const {
|
|
1257
|
+
getLabel
|
|
1258
|
+
} = useModuleDictionary();
|
|
1259
|
+
const values = useMemo(() => {
|
|
1260
|
+
if (!filter || !field)
|
|
1261
|
+
return {};
|
|
1262
|
+
const valuesFilter = {
|
|
1263
|
+
...filter,
|
|
1264
|
+
valueOperator: {
|
|
1265
|
+
id: filter.operator,
|
|
1266
|
+
label: getLabelOperator(filter.operator)
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
return valuesFilter;
|
|
1270
|
+
}, [filter, field, getLabelOperator, getLabel]);
|
|
1271
|
+
const onSubmit = async (data) => {
|
|
1272
|
+
if (!filter || !field)
|
|
1273
|
+
return;
|
|
1274
|
+
const newFilter = fnTransformFormValuesIntoRawValues(data);
|
|
1275
|
+
if (!newFilter)
|
|
1276
|
+
return;
|
|
1277
|
+
if (filter.id === 0) {
|
|
1278
|
+
addFilter(newFilter);
|
|
1279
|
+
} else {
|
|
1280
|
+
updateFilter(newFilter);
|
|
1281
|
+
}
|
|
1282
|
+
hidePopupEdit(false);
|
|
1283
|
+
};
|
|
1284
|
+
const onClose = () => {
|
|
1285
|
+
hidePopupEdit(false);
|
|
1286
|
+
};
|
|
1287
|
+
console.log("Render PopupEditFilter");
|
|
1288
|
+
return /* @__PURE__ */ jsx(Popper, {
|
|
1289
|
+
id: "MenuPopover",
|
|
1290
|
+
open: Boolean(popupAnchorEl),
|
|
1291
|
+
anchorEl: popupAnchorEl,
|
|
1292
|
+
sx: {
|
|
1293
|
+
boxShadow: "0 8px 16px 0 rgb(0 0 0 / 12%)",
|
|
1294
|
+
borderRadius: 1
|
|
1295
|
+
},
|
|
1296
|
+
children: /* @__PURE__ */ jsx(Fragment, {
|
|
1297
|
+
children: filter && /* @__PURE__ */ jsx(FormProvider, {
|
|
1298
|
+
onSubmit,
|
|
1299
|
+
values,
|
|
1300
|
+
validationSchema: popupValidationSchema,
|
|
1301
|
+
urlCancel: -1,
|
|
1302
|
+
children: /* @__PURE__ */ jsxs(WrapperPopupEditFilter, {
|
|
1303
|
+
children: [/* @__PURE__ */ jsxs(HeaderContainer, {
|
|
1304
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1305
|
+
src: field?.urlIcon
|
|
1306
|
+
}), /* @__PURE__ */ jsx(TitleContainer, {
|
|
1307
|
+
children: field?.label
|
|
1308
|
+
})]
|
|
1309
|
+
}), /* @__PURE__ */ jsx(PopupEditFilterComponent, {
|
|
1310
|
+
filter
|
|
1311
|
+
}), /* @__PURE__ */ jsxs(PopperActionsContainer, {
|
|
1312
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1313
|
+
variant: "outlined",
|
|
1314
|
+
color: "inherit",
|
|
1315
|
+
onClick: onClose,
|
|
1316
|
+
children: `Cerrar`
|
|
1317
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1318
|
+
variant: "contained",
|
|
1319
|
+
color: "primary",
|
|
1320
|
+
type: "submit",
|
|
1321
|
+
children: `Agregar ${filter.id}`
|
|
1322
|
+
})]
|
|
1323
|
+
})]
|
|
1324
|
+
})
|
|
1325
|
+
})
|
|
1326
|
+
})
|
|
1327
|
+
});
|
|
1328
|
+
};
|
|
1329
|
+
const WrapperFilter = styled("div", {
|
|
1330
|
+
shouldForwardProp: (prop) => prop !== "inEdition"
|
|
1331
|
+
})(({
|
|
1332
|
+
theme,
|
|
1333
|
+
inEdition
|
|
1334
|
+
}) => ({
|
|
1335
|
+
display: "flex",
|
|
1336
|
+
alignItems: "center",
|
|
1337
|
+
justifyContent: "flex-start",
|
|
1338
|
+
height: "auto",
|
|
1339
|
+
padding: theme.spacing(1.5),
|
|
1340
|
+
borderRadius: theme.spacing(1),
|
|
1341
|
+
border: inEdition ? `1px solid ${theme.palette.primary.main}` : `1px solid ${theme.palette.divider}`
|
|
1342
|
+
}));
|
|
1343
|
+
const WrapperFilterMobile = styled("div", {
|
|
1344
|
+
shouldForwardProp: (prop) => prop !== "inEdition"
|
|
1345
|
+
})(({
|
|
1346
|
+
theme,
|
|
1347
|
+
inEdition
|
|
1348
|
+
}) => ({
|
|
1349
|
+
display: "flex",
|
|
1350
|
+
flexDirection: "column",
|
|
1351
|
+
alignItems: "center",
|
|
1352
|
+
justifyContent: "space-between",
|
|
1353
|
+
minWidth: theme.spacing(25),
|
|
1354
|
+
height: "auto",
|
|
1355
|
+
padding: theme.spacing(1.5),
|
|
1356
|
+
borderRadius: theme.spacing(1),
|
|
1357
|
+
border: inEdition ? `1px solid ${theme.palette.primary.main}` : `1px solid ${theme.palette.divider}`,
|
|
1358
|
+
gap: theme.spacing(1.5)
|
|
1359
|
+
}));
|
|
1360
|
+
const ContainerFistRow = styled("div")(({
|
|
1361
|
+
theme
|
|
1362
|
+
}) => ({
|
|
1363
|
+
display: "flex",
|
|
1364
|
+
width: "100%"
|
|
1365
|
+
}));
|
|
1366
|
+
const DynamicFilter = (props) => {
|
|
1367
|
+
const isDesktop = useResponsiveDesktop();
|
|
1368
|
+
const render = useFlagsPresent(["dictionary_loaded"]);
|
|
1369
|
+
if (!render) {
|
|
1370
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
1371
|
+
}
|
|
1372
|
+
return /* @__PURE__ */ jsx(BaseProvider, {
|
|
1373
|
+
...props,
|
|
1374
|
+
children: /* @__PURE__ */ jsx(BaseContext.Consumer, {
|
|
1375
|
+
children: ({
|
|
1376
|
+
inEdition
|
|
1377
|
+
}) => isDesktop ? /* @__PURE__ */ jsxs(WrapperFilter, {
|
|
1378
|
+
id: "WrapperDynamicFilter",
|
|
1379
|
+
inEdition,
|
|
1380
|
+
children: [/* @__PURE__ */ jsx(FilterButton, {}), /* @__PURE__ */ jsx(InputFilter, {}), /* @__PURE__ */ jsx(ApplyedFilters, {}), /* @__PURE__ */ jsx(PopupEditFilter, {}), /* @__PURE__ */ jsx(ClearFilters, {})]
|
|
1381
|
+
}) : /* @__PURE__ */ jsxs(WrapperFilterMobile, {
|
|
1382
|
+
id: "WrapperFilterMobile",
|
|
1383
|
+
inEdition,
|
|
1384
|
+
children: [/* @__PURE__ */ jsxs(ContainerFistRow, {
|
|
1385
|
+
id: "ContainerFistRow",
|
|
1386
|
+
children: [/* @__PURE__ */ jsx(FilterButton, {}), /* @__PURE__ */ jsx(InputFilter, {}), /* @__PURE__ */ jsx(ClearFilters, {})]
|
|
1387
|
+
}), /* @__PURE__ */ jsx(ApplyedFilters, {}), /* @__PURE__ */ jsx(PopupEditFilter, {})]
|
|
1388
|
+
})
|
|
1389
|
+
})
|
|
1390
|
+
});
|
|
1391
|
+
};
|
|
1392
|
+
export { DynamicFilter as D };
|