@m4l/components 1.0.10 → 1.0.12
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/AccountPopover/{index.85964263.js → index.705c7df5.js} +4 -4
- package/components/AppBar/{index.233917e6.js → index.04816fec.js} +4 -4
- package/components/CommonActions/components/ActionCancel/index.609a78ca.js +12 -0
- package/components/CommonActions/components/ActionFormCancel/index.2a55418d.js +56 -0
- package/components/CommonActions/components/ActionFormIntro/index.34d569d1.js +33 -0
- package/components/CommonActions/components/ActionIntro/index.ebac0bc1.js +25 -0
- package/components/CommonActions/components/Actions/index.258bf919.js +71 -0
- package/components/DataGrid/constants.e334cd50.js +10 -0
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index.30ea5c9a.js +26 -0
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index.512d6ee0.js +22 -0
- package/components/DataGrid/formatters/ColumnDateFormatter/index.e00d0cf2.js +19 -0
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index.5d294f5d.js +23 -0
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index.880e743b.js +14 -0
- package/components/DataGrid/formatters/ColumnPointsFormatter/index.226cc583.js +10 -0
- package/components/DataGrid/formatters/ColumnPriceFormatter/index.bf9d9e60.js +10 -0
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/index.4045b2f2.js +36 -0
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index.a87302d1.js +10 -0
- package/components/DataGrid/formatters/index.2c2f0ae4.js +1 -0
- package/components/DataGrid/index.3ffee8f3.js +915 -0
- package/components/DataGrid/subcomponents/Actions/index.8224ef1a.js +596 -0
- package/components/DataGrid/subcomponents/editors/TextEditor/index.3f0d9e28.js +76 -0
- package/components/DragResizeWindow/{index.8b3e79f7.js → index.917d150b.js} +6 -3
- package/components/DynamicFilter/helpers/index.9baa9ef7.js +556 -0
- package/components/DynamicFilter/index.7e64ade0.js +441 -0
- package/components/DynamicFilter/slots/{index.268c8973.js → index.dbb0936d.js} +32 -32
- package/components/DynamicFilter/store/index.eafe4a4d.js +254 -0
- package/components/DynamicFilter/subcomponents/index.d5bea68c.js +786 -0
- package/components/FieldLabel/{index.61450047.js → index.317f5f6f.js} +4 -4
- package/components/GridLayout/{index.656840a5.js → index.68d907d4.js} +34 -11
- package/components/GridLayout/subcomponents/Griditem/{index.b23625d7.js → index.8955a794.js} +3 -4
- package/components/GridLayout/subcomponents/Responsive/{index.97505a31.js → index.45cecca2.js} +1 -2
- package/components/GridLayout/subcomponents/SizeProvider/{index.36cb4139.js → index.7050ac4f.js} +1 -1
- package/components/HelperText/{index.ebb53dac.js → index.09e80920.js} +1 -1
- package/components/Icon/{index.0d591435.js → index.0598dfb1.js} +10 -26
- package/components/Image/{index.7b1ce7d6.js → index.19aa7ff5.js} +3 -2
- package/components/LanguagePopover/index.921efd11.js +188 -0
- package/components/{mui_extended/LinearProgress/index.e9455b2e.js → LinearProgressIndeterminate/index.ea9c8518.js} +4 -9
- package/components/LoadingError/{index.5b8a819d.js → index.1e464569.js} +11 -7
- package/components/MFLoader/{index.6f690259.js → index.08b59dce.js} +8 -4
- package/components/ModalDialog/{index.bdae9c06.js → index.0dd5af28.js} +14 -5
- package/components/NavLink/{index.9f5d5670.js → index.ad039baf.js} +3 -2
- package/components/NoItemSelected/{index.71727588.js → index.d10603d7.js} +13 -3
- package/components/ObjectLogs/{index.5e18c08e.js → index.72dc8feb.js} +25 -8
- package/components/PDFViewer/{index.e5b7b58c.js → index.35f68e67.js} +2 -2
- package/components/Page/{index.bf61755b.js → index.f4755eba.js} +18 -2
- package/components/PaperForm/{index.2c5d1c14.js → index.5ef72398.js} +2 -2
- package/components/Period/{index.9f3a2531.js → index.301a752f.js} +15 -54
- package/components/PrintingSystem/{index.e166c8d5.js → index.a69a9d85.js} +14 -15
- package/components/PrintingSystem/subcomponents/BodyNode/{index.ff5bd9ba.js → index.528fcfbf.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.e78e9c90.js → index.fbe87257.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.1ff8a100.js → index.f5adab1d.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.7078b267.js → index.f42ca7dc.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.45007400.js → index.041b9cff.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.c19c37d6.js → index.a8140332.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.3a620060.js → index.aabde2bb.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.c158a2b6.js → index.7f75ca46.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.cc08a0f8.js → index.61babb47.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.a37d8efa.js → index.4d0e67a3.js} +1 -1
- package/components/PropertyValue/{index.2e61bd86.js → index.0b5c361c.js} +7 -4
- package/components/Resizeable/{index.414ff687.js → index.4f75c0b5.js} +1 -1
- package/components/ScrollBar/{index.1e89bb44.js → index.21bc5025.js} +1 -1
- package/components/SideBar/{index.a645fbb3.js → index.8fdf28e0.js} +36 -7
- package/components/SplitLayout/{index.7d9edf4e.js → index.15756f0f.js} +3 -1
- package/components/ToastContainer/{index.c1ae5efc.js → index.123d26d9.js} +3 -3
- package/components/animate/variants/index.7a912140.js +1 -0
- package/components/areas/components/AreasAdmin/index.1aec24f3.js +733 -0
- package/components/areas/components/AreasViewer/index.429dbb7b.js +1072 -0
- package/components/areas/components/index.558684b3.js +1 -0
- package/components/areas/constants.66529246.js +6 -0
- package/components/areas/contexts/AreasContext/{index.ed31c72d.js → index.2e7cdc05.js} +6 -5
- package/components/areas/contexts/DynamicMFParmsContext/{index.37d1d444.js → index.3d9ad0ad.js} +2 -2
- package/components/areas/contexts/WindowToolsMFContext/{index.69d95c15.js → index.992ae7a3.js} +2 -2
- package/components/areas/contexts/index.24025b97.js +1 -0
- package/components/areas/dictionary.08cfc4c9.js +36 -0
- package/components/areas/hooks/index.d9dc1e21.js +1 -0
- package/components/areas/hooks/useAreas/{index.dca83673.js → index.8913b7b5.js} +1 -1
- package/components/areas/hooks/useDynamicMFParameters/{index.03ce6078.js → index.9e09e1e3.js} +1 -1
- package/components/areas/hooks/useWindowToolsMF/{index.09801b66.js → index.2fbae9dc.js} +1 -1
- package/components/areas/icons.8266ccc8.js +26 -0
- package/components/areas/index.4cc6a221.js +22 -0
- package/components/commercial/AppBarCommercial/index.cbd55cf8.js +28 -0
- package/components/commercial/SectionCommercial/index.d22ebbd5.js +57 -0
- package/components/commercial/TopBar/index.20c4b2ea.js +234 -0
- package/components/{HamburgerMenu/index.6da952c3.js → commercial/index.504bddfe.js} +5 -3
- package/components/formatters/BooleanFormatter/index.a4abeebc.js +44 -0
- package/components/formatters/DateFormatter/index.2ef6f261.js +43 -0
- package/components/formatters/PointsFormatter/index.d8a4ee54.js +25 -0
- package/components/formatters/PriceFormatter/index.97f75b4b.js +35 -0
- package/components/formatters/UncertaintyFormatter/index.c3ffdebc.js +29 -0
- package/components/formatters/index.18f49751.js +117 -0
- package/components/hook-form/HelperError/{index.2ed03a3c.js → index.c0109d5b.js} +1 -1
- package/components/hook-form/RHFAutocomplete/index.d6dd0f42.js +404 -0
- package/components/hook-form/RHFAutocompleteAsync/{index.58439d31.js → index.35d82ca9.js} +2 -3
- package/components/hook-form/RHFCheckbox/{index.52645cbc.js → index.6a1b97dd.js} +4 -4
- package/components/hook-form/RHFColorPicker/{index.ad3a7448.js → index.dccd7187.js} +6 -6
- package/components/hook-form/RHFDateTime/{index.0bb4279e.js → index.15976fef.js} +5 -5
- package/components/hook-form/RHFPeriod/{index.8075a132.js → index.e6d5c3a6.js} +4 -4
- package/components/hook-form/RHFTextField/{index.8d9e389c.js → index.55f91506.js} +6 -6
- package/components/hook-form/RHFUpload/{index.bb7f617e.js → index.7fd23b2a.js} +5 -5
- package/components/{mui_extended/Tab/index.03742bb6.js → maps/components/GpsTools/index.b126f06c.js} +331 -645
- package/components/maps/{index.595f5894.js → components/Map/index.c163038c.js} +737 -28
- package/components/maps/index.13bb982c.js +7 -0
- package/components/modal/{WindowBase.57f82667.js → WindowBase.6fbd595f.js} +4 -4
- package/components/modal/{WindowConfirm.21342f0a.js → WindowConfirm.a33e1d29.js} +10 -6
- package/components/modal/{index.5bce430d.js → index.81eb6def.js} +5 -1
- package/components/mui_extended/Accordion/{index.232b14c4.js → index.808f22d7.js} +5 -5
- package/components/mui_extended/Avatar/{index.12b96914.js → index.fb9ad158.js} +1 -1
- package/components/mui_extended/Badge/{index.4737c113.js → index.8beaeefc.js} +1 -1
- package/components/mui_extended/Button/{index.6276c580.js → index.d742e9ee.js} +6 -81
- package/components/mui_extended/{CheckBox/index.2bf3b459.js → CheckBox.2f354abf.js} +1 -1
- package/components/mui_extended/IconButton/{index.20a5a0be.js → index.98914ce2.js} +1 -1
- package/components/mui_extended/LinearProgress/index.4092bb69.js +9 -0
- package/components/mui_extended/MenuActions/index.ba7f3376.js +176 -0
- package/components/mui_extended/Pager/{index.2a5203df.js → index.abeb8d39.js} +22 -40
- package/components/mui_extended/Popover/index.2348fc4f.js +143 -0
- package/components/mui_extended/Tab/index.e911930f.js +135 -0
- package/components/mui_extended/ToggleButton/{index.7a4779c7.js → index.b834f5f0.js} +1 -1
- package/components/mui_extended/ToggleIconButton/{index.29fdefaa.js → index.efed3ff5.js} +1 -1
- package/components/mui_extended/Typography/{index.463f613f.js → index.642798f1.js} +1 -1
- package/components/mui_extended/index.b606cd9d.js +1 -0
- package/components/popups/PopupsProvider/{index.6b5befba.js → index.8609e808.js} +1 -1
- package/components/popups/PopupsViewer/{index.c7940ab0.js → index.bfab9357.js} +10 -6
- package/contexts/ModalContext/{index.e126d383.js → index.ad1fb73b.js} +1 -1
- package/contexts/RHFormContext/{index.95ebabc9.js → index.bf3a2812.js} +6 -2
- package/hooks/useFormAddEdit/{index.42356b18.js → index.faafbfae.js} +6 -2
- package/hooks/useModal/index.2003c854.js +11 -0
- package/hooks/useTab/index.8d1a6e63.js +12 -0
- package/index.js +330 -274
- package/package.json +1 -1
- package/{react-draggable.0cc9b257.js → react-draggable.1c1ba224.js} +1 -1
- package/{react-resizable.837c446d.js → react-resizable.a59c14f4.js} +2 -2
- package/test/constants_no_mock.86c553a9.js +4 -0
- package/test/{getNameDataTestId.aee44365.js → getNameDataTestId.0faeade8.js} +2 -2
- package/utils/{index.c64c2dd1.js → index.14912462.js} +1 -54
- package/components/CommonActions/index.5f5362d4.js +0 -170
- package/components/DynamicFilter/index.d698a952.js +0 -1721
- package/components/areas/constants.0d3ba950.js +0 -289
- package/components/areas/dictionary.ffe082b0.js +0 -266
- package/components/areas/icons.504ec098.js +0 -83
- package/components/maps/components/GpsTools/index.a32b12b7.js +0 -251
- package/components/mui_extended/Popover/index.fda32ba1.js +0 -1043
- package/hooks/useModal/index.20c3f2be.js +0 -67
- package/vendor.e16cc0cc.js +0 -3952
|
@@ -1,1721 +0,0 @@
|
|
|
1
|
-
import { Skeleton, alpha } from "@mui/material";
|
|
2
|
-
import { i as isValidDate, c as containerQuery } from "../../utils/index.c64c2dd1.js";
|
|
3
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
4
|
-
import { useMemo, useContext, createContext, useRef, useEffect, useState } from "react";
|
|
5
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
6
|
-
import { useModuleDictionary, useEnvironment, useModuleSkeleton, useFlagsPresent, CommonFlags } from "@m4l/core";
|
|
7
|
-
import { useStore, createStore } from "zustand";
|
|
8
|
-
import { shallow } from "zustand/shallow";
|
|
9
|
-
import { useResponsiveDesktop, useFirstRender, useFormatter } from "@m4l/graphics";
|
|
10
|
-
import { devtools } from "zustand/middleware";
|
|
11
|
-
import { immer } from "zustand/middleware/immer";
|
|
12
|
-
import * as Yup from "yup";
|
|
13
|
-
import { g as getDynamicFilterDictionary, D as DICCTIONARY } from "../areas/dictionary.ffe082b0.js";
|
|
14
|
-
import { B as BOOLEAN_OPERATORS, S as STRING_OPERATORS, b as DATE_TIME_OPERATORS, N as NUMBER_OPERATORS, c as SELECT_OPERATORS, A as ALL_FIELD } from "../areas/constants.0d3ba950.js";
|
|
15
|
-
import { R as RHFAutocomplete } from "../../vendor.e16cc0cc.js";
|
|
16
|
-
import { R as RHFTextField } from "../hook-form/RHFTextField/index.8d9e389c.js";
|
|
17
|
-
import { R as RHFDateTime } from "../hook-form/RHFDateTime/index.0bb4279e.js";
|
|
18
|
-
import { R as RHFAutocompleteAsync } from "../hook-form/RHFAutocompleteAsync/index.58439d31.js";
|
|
19
|
-
import { I as InputFilterStyled, a as InputFilterIconStyled, b as InputFilterInputStyled, A as AppliedFilterChipStyled, c as AppliedFilterChipIconStyled, d as AppliedFilterChipInfoStyled, e as AppliedFilterChipInfoFieldNameStyled, f as AppliedFilterChipInfoOperatorStyled, g as AppliedFilterChipInfoOperandsStyled, h as AppliedFilterChipRemoveButtonStyled, i as AppliedFiltersStyled, j as AppliedFilterInnerContainerStyled, k as ActionsSkeletonButtonStyled, l as ActionsStyled, m as ActionsClearButtonStyled, n as ActionsSubmitButtonStyled, R as RootStyled, o as InnerContainerStyled } from "./slots/index.268c8973.js";
|
|
20
|
-
import { g as getPropDataTestId } from "../../test/getNameDataTestId.aee44365.js";
|
|
21
|
-
import { a as PopoverMenuFields, b as PopoverFilter } from "../mui_extended/Popover/index.fda32ba1.js";
|
|
22
|
-
import { S as ScrollBar } from "../ScrollBar/index.1e89bb44.js";
|
|
23
|
-
function BooleanFilter() {
|
|
24
|
-
const { getLabel } = useModuleDictionary();
|
|
25
|
-
const operators = useMemo(
|
|
26
|
-
() => BOOLEAN_OPERATORS.map((o) => ({
|
|
27
|
-
id: o,
|
|
28
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
|
|
29
|
-
})),
|
|
30
|
-
[getLabel]
|
|
31
|
-
);
|
|
32
|
-
const optionsYesNo = useMemo(
|
|
33
|
-
() => [
|
|
34
|
-
{
|
|
35
|
-
value: true,
|
|
36
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.operand_true))
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
value: false,
|
|
40
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.operand_false))
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
[getLabel]
|
|
44
|
-
);
|
|
45
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
-
RHFAutocomplete,
|
|
48
|
-
{
|
|
49
|
-
name: "formValueOperator",
|
|
50
|
-
autoComplete: "off",
|
|
51
|
-
options: operators,
|
|
52
|
-
getOptionLabel: (option) => option.label,
|
|
53
|
-
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
54
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_boolean_operator))
|
|
55
|
-
}
|
|
56
|
-
),
|
|
57
|
-
/* @__PURE__ */ jsx(
|
|
58
|
-
RHFAutocomplete,
|
|
59
|
-
{
|
|
60
|
-
name: "formValueOperand1",
|
|
61
|
-
autoComplete: "off",
|
|
62
|
-
options: optionsYesNo,
|
|
63
|
-
getOptionLabel: (option) => option.label,
|
|
64
|
-
isOptionEqualToValue: (option, value) => option.value === value.value,
|
|
65
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_boolean_operand1))
|
|
66
|
-
}
|
|
67
|
-
)
|
|
68
|
-
] });
|
|
69
|
-
}
|
|
70
|
-
class BooleanFilterHelpers {
|
|
71
|
-
getComponent() {
|
|
72
|
-
return BooleanFilter;
|
|
73
|
-
}
|
|
74
|
-
getDefaultFilter(field, fixed) {
|
|
75
|
-
const defaultOperand1 = field.defaultOperand1;
|
|
76
|
-
const defaultFilter = {
|
|
77
|
-
id: 0,
|
|
78
|
-
fieldType: "boolean",
|
|
79
|
-
field,
|
|
80
|
-
fixed,
|
|
81
|
-
isSet: true,
|
|
82
|
-
operator: "e",
|
|
83
|
-
operand1: true
|
|
84
|
-
};
|
|
85
|
-
if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "boolean") {
|
|
86
|
-
defaultFilter.operand1 = defaultOperand1;
|
|
87
|
-
}
|
|
88
|
-
return defaultFilter;
|
|
89
|
-
}
|
|
90
|
-
getFilterFromFormValue(formFilterValue) {
|
|
91
|
-
const operator = formFilterValue.formValueOperator.id;
|
|
92
|
-
const operand1 = formFilterValue.formValueOperand1?.value || false;
|
|
93
|
-
return {
|
|
94
|
-
fieldType: "boolean",
|
|
95
|
-
operator,
|
|
96
|
-
operand1
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
getFormValue(field, getLabel, filterValue) {
|
|
100
|
-
const filterValueBoolean = filterValue ? filterValue : void 0;
|
|
101
|
-
const operator = filterValueBoolean ? filterValueBoolean.operator : field.defaultOperator ?? "e";
|
|
102
|
-
const formValueOperand1 = filterValueBoolean ? {
|
|
103
|
-
value: filterValueBoolean.operand1,
|
|
104
|
-
label: getLabel(getDynamicFilterDictionary(`operand_${filterValueBoolean.operand1}`))
|
|
105
|
-
} : null;
|
|
106
|
-
return {
|
|
107
|
-
fieldType: "boolean",
|
|
108
|
-
formValueOperator: {
|
|
109
|
-
id: operator,
|
|
110
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
111
|
-
},
|
|
112
|
-
formValueOperand1
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
getLabels(filter, getLabel, _formatters, _field) {
|
|
116
|
-
const labelOperands = filter.operand1 ? getLabel(getDynamicFilterDictionary("operand_true")) : getLabel(getDynamicFilterDictionary("operand_false"));
|
|
117
|
-
return {
|
|
118
|
-
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
119
|
-
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
120
|
-
labelOperands
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
getSchema(getLabel) {
|
|
124
|
-
return Yup.object({
|
|
125
|
-
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
126
|
-
formValueOperand1: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`))
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
verifyFilter(filter, _field) {
|
|
130
|
-
if (typeof filter.operator !== "string") {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
if (BOOLEAN_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
return typeof filter.operand1 === "boolean";
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function StringFilter() {
|
|
140
|
-
const { getLabel } = useModuleDictionary();
|
|
141
|
-
const operators = useMemo(
|
|
142
|
-
() => STRING_OPERATORS.map((o) => ({
|
|
143
|
-
id: o,
|
|
144
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
|
|
145
|
-
})),
|
|
146
|
-
[getLabel]
|
|
147
|
-
);
|
|
148
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
149
|
-
/* @__PURE__ */ jsx(
|
|
150
|
-
RHFAutocomplete,
|
|
151
|
-
{
|
|
152
|
-
name: "formValueOperator",
|
|
153
|
-
autoComplete: "off",
|
|
154
|
-
options: operators,
|
|
155
|
-
getOptionLabel: (option) => option.label,
|
|
156
|
-
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
157
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_string))
|
|
158
|
-
}
|
|
159
|
-
),
|
|
160
|
-
/* @__PURE__ */ jsx(
|
|
161
|
-
RHFTextField,
|
|
162
|
-
{
|
|
163
|
-
name: "formValueOperand1",
|
|
164
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_string))
|
|
165
|
-
}
|
|
166
|
-
)
|
|
167
|
-
] });
|
|
168
|
-
}
|
|
169
|
-
class StringFilterHelpers {
|
|
170
|
-
getComponent() {
|
|
171
|
-
return StringFilter;
|
|
172
|
-
}
|
|
173
|
-
getDefaultFilter(field, fixed) {
|
|
174
|
-
const defaultOperand1 = field.defaultOperand1;
|
|
175
|
-
const defaultFilter = {
|
|
176
|
-
id: 0,
|
|
177
|
-
fieldType: "string",
|
|
178
|
-
field,
|
|
179
|
-
fixed,
|
|
180
|
-
isSet: false,
|
|
181
|
-
operator: "c",
|
|
182
|
-
operand1: ""
|
|
183
|
-
};
|
|
184
|
-
if (defaultOperand1 !== void 0 && typeof defaultOperand1 === "string") {
|
|
185
|
-
defaultFilter.operand1 = defaultOperand1;
|
|
186
|
-
}
|
|
187
|
-
return defaultFilter;
|
|
188
|
-
}
|
|
189
|
-
getFilterFromFormValue(formFilterValue) {
|
|
190
|
-
const operator = formFilterValue.formValueOperator.id;
|
|
191
|
-
const operand1 = formFilterValue.formValueOperand1;
|
|
192
|
-
return {
|
|
193
|
-
fieldType: "string",
|
|
194
|
-
operator,
|
|
195
|
-
operand1
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
getFormValue(field, getLabel, filterValue) {
|
|
199
|
-
const filterValueString = filterValue;
|
|
200
|
-
const operator = filterValueString ? filterValueString.operator : field.defaultOperator ?? "c";
|
|
201
|
-
const formValueOperand1 = filterValueString ? filterValueString.operand1 : "";
|
|
202
|
-
return {
|
|
203
|
-
fieldType: "string",
|
|
204
|
-
formValueOperator: {
|
|
205
|
-
id: operator,
|
|
206
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
207
|
-
},
|
|
208
|
-
formValueOperand1
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
getLabels(filter, getLabel, _formatters, _field) {
|
|
212
|
-
const labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
|
|
213
|
-
return {
|
|
214
|
-
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
215
|
-
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
216
|
-
labelOperands
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
getSchema(getLabel) {
|
|
220
|
-
return Yup.object({
|
|
221
|
-
formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
|
|
222
|
-
formValueOperand1: Yup.string().required(
|
|
223
|
-
getLabel(getDynamicFilterDictionary(DICCTIONARY.error_operand_required))
|
|
224
|
-
)
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
verifyFilter(filter, _field) {
|
|
228
|
-
if (typeof filter.operator !== "string") {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
if (STRING_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
if (typeof filter.operand1 !== "string") {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
function DateTimeFilter() {
|
|
241
|
-
const { getLabel } = useModuleDictionary();
|
|
242
|
-
const { control } = useFormContext();
|
|
243
|
-
const operator = useWatch({
|
|
244
|
-
control,
|
|
245
|
-
name: "formValueOperator"
|
|
246
|
-
});
|
|
247
|
-
const operators = useMemo(
|
|
248
|
-
() => DATE_TIME_OPERATORS.map((o) => ({
|
|
249
|
-
id: o,
|
|
250
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
|
|
251
|
-
})),
|
|
252
|
-
[getLabel]
|
|
253
|
-
);
|
|
254
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
255
|
-
/* @__PURE__ */ jsx(
|
|
256
|
-
RHFAutocomplete,
|
|
257
|
-
{
|
|
258
|
-
name: "formValueOperator",
|
|
259
|
-
autoComplete: "off",
|
|
260
|
-
options: operators,
|
|
261
|
-
getOptionLabel: (option) => option.label,
|
|
262
|
-
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
263
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_date_time))
|
|
264
|
-
}
|
|
265
|
-
),
|
|
266
|
-
/* @__PURE__ */ jsx(
|
|
267
|
-
RHFDateTime,
|
|
268
|
-
{
|
|
269
|
-
name: "formValueOperand1",
|
|
270
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_date_time))
|
|
271
|
-
}
|
|
272
|
-
),
|
|
273
|
-
operator && operator.id === "b" && /* @__PURE__ */ jsx(
|
|
274
|
-
RHFDateTime,
|
|
275
|
-
{
|
|
276
|
-
name: "formValueOperand2",
|
|
277
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_date_time))
|
|
278
|
-
}
|
|
279
|
-
)
|
|
280
|
-
] });
|
|
281
|
-
}
|
|
282
|
-
class DateTimeFilterHelpers {
|
|
283
|
-
getComponent() {
|
|
284
|
-
return DateTimeFilter;
|
|
285
|
-
}
|
|
286
|
-
getDefaultFilter(field, fixed) {
|
|
287
|
-
const defaultStartDate = new Date();
|
|
288
|
-
const defaultEndDate = new Date();
|
|
289
|
-
defaultStartDate.setHours(0, 0, 0, 0);
|
|
290
|
-
defaultEndDate.setHours(23, 59, 59, 999);
|
|
291
|
-
const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
|
|
292
|
-
const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
|
|
293
|
-
return {
|
|
294
|
-
id: 0,
|
|
295
|
-
fieldType: "datetime",
|
|
296
|
-
field,
|
|
297
|
-
fixed,
|
|
298
|
-
isSet: true,
|
|
299
|
-
operator: "b",
|
|
300
|
-
operand1: defaultOperand1,
|
|
301
|
-
operand2: defaultOperand2
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
getFormValue(field, getLabel, filterValueDateTime) {
|
|
305
|
-
const filterValue = filterValueDateTime;
|
|
306
|
-
const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "b";
|
|
307
|
-
const defaultStartDate = new Date();
|
|
308
|
-
const defaultEndDate = new Date();
|
|
309
|
-
const defaultOperand1 = field.defaultOperand1 && field.defaultOperand1 instanceof Date ? field.defaultOperand1 : defaultStartDate;
|
|
310
|
-
const defaultOperand2 = field.defaultOperand2 && field.defaultOperand2 instanceof Date ? field.defaultOperand2 : defaultEndDate;
|
|
311
|
-
const formValueOperand1 = filterValue ? filterValue.operand1 : defaultOperand1;
|
|
312
|
-
const formValueOperand2 = filterValue && filterValue.operator === "b" ? filterValue.operand2 : defaultOperand2;
|
|
313
|
-
return {
|
|
314
|
-
fieldType: "datetime",
|
|
315
|
-
formValueOperator: {
|
|
316
|
-
id: operator,
|
|
317
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
318
|
-
},
|
|
319
|
-
formValueOperand1,
|
|
320
|
-
formValueOperand2
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
getFilterFromFormValue(formFilterValue) {
|
|
324
|
-
const operator = formFilterValue.formValueOperator.id;
|
|
325
|
-
const operand1 = formFilterValue.formValueOperand1;
|
|
326
|
-
if (operator === "b") {
|
|
327
|
-
const operand2 = formFilterValue.formValueOperand2;
|
|
328
|
-
return {
|
|
329
|
-
fieldType: "datetime",
|
|
330
|
-
operator,
|
|
331
|
-
operand1,
|
|
332
|
-
operand2
|
|
333
|
-
};
|
|
334
|
-
} else {
|
|
335
|
-
return {
|
|
336
|
-
fieldType: "datetime",
|
|
337
|
-
operator,
|
|
338
|
-
operand1
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
getLabels(filter, getLabel, formatters, _field) {
|
|
343
|
-
const { dateFormatter } = formatters;
|
|
344
|
-
let labelOperands;
|
|
345
|
-
if (filter.operator === "b") {
|
|
346
|
-
labelOperands = filter.operand1 && filter.operand2 ? `${dateFormatter.formatDate(
|
|
347
|
-
filter.operand1,
|
|
348
|
-
dateFormatter.datetimeFormat
|
|
349
|
-
)} - ${dateFormatter.formatDate(filter.operand2, dateFormatter.datetimeFormat)}` : "";
|
|
350
|
-
} else {
|
|
351
|
-
labelOperands = filter.operand1 ? dateFormatter.formatDate(filter.operand1, dateFormatter.datetimeFormat) : "";
|
|
352
|
-
}
|
|
353
|
-
return {
|
|
354
|
-
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
355
|
-
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
356
|
-
labelOperands
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
getSchema(getLabel) {
|
|
360
|
-
return Yup.object({
|
|
361
|
-
formValueOperator: Yup.object().nullable().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.operator_required))),
|
|
362
|
-
formValueOperand1: Yup.date().required(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))),
|
|
363
|
-
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
364
|
-
is: "b",
|
|
365
|
-
then: Yup.date().typeError(getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))).min(
|
|
366
|
-
Yup.ref("formValueOperand1"),
|
|
367
|
-
getLabel(getDynamicFilterDictionary(DICCTIONARY.error_invalid_date))
|
|
368
|
-
)
|
|
369
|
-
})
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
verifyFilter(filter, _field) {
|
|
373
|
-
if (typeof filter.operator !== "string") {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
if (DATE_TIME_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
if (typeof filter.operand1 !== "string") {
|
|
380
|
-
return false;
|
|
381
|
-
}
|
|
382
|
-
if (!isValidDate(new Date(filter.operand1))) {
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
if (filter.operator === "b") {
|
|
386
|
-
if (typeof filter.operand2 !== "string") {
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
if (!isValidDate(new Date(filter.operand1))) {
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
function NumberFilter() {
|
|
397
|
-
const { getLabel } = useModuleDictionary();
|
|
398
|
-
const { control } = useFormContext();
|
|
399
|
-
const operator = useWatch({
|
|
400
|
-
control,
|
|
401
|
-
name: "formValueOperator"
|
|
402
|
-
});
|
|
403
|
-
const operators = useMemo(
|
|
404
|
-
() => NUMBER_OPERATORS.map((o) => ({
|
|
405
|
-
id: o,
|
|
406
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
|
|
407
|
-
})),
|
|
408
|
-
[getLabel]
|
|
409
|
-
);
|
|
410
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
411
|
-
/* @__PURE__ */ jsx(
|
|
412
|
-
RHFAutocomplete,
|
|
413
|
-
{
|
|
414
|
-
name: "formValueOperator",
|
|
415
|
-
autoComplete: "off",
|
|
416
|
-
options: operators,
|
|
417
|
-
getOptionLabel: (option) => option.label,
|
|
418
|
-
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
419
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operator_number))
|
|
420
|
-
}
|
|
421
|
-
),
|
|
422
|
-
/* @__PURE__ */ jsx(
|
|
423
|
-
RHFTextField,
|
|
424
|
-
{
|
|
425
|
-
name: "formValueOperand1",
|
|
426
|
-
type: "number",
|
|
427
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand1_number))
|
|
428
|
-
}
|
|
429
|
-
),
|
|
430
|
-
operator && operator.id === "b" && /* @__PURE__ */ jsx(
|
|
431
|
-
RHFTextField,
|
|
432
|
-
{
|
|
433
|
-
name: "formValueOperand2",
|
|
434
|
-
type: "number",
|
|
435
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_operand2_number))
|
|
436
|
-
}
|
|
437
|
-
)
|
|
438
|
-
] });
|
|
439
|
-
}
|
|
440
|
-
class NumberFilterHelpers {
|
|
441
|
-
getComponent() {
|
|
442
|
-
return NumberFilter;
|
|
443
|
-
}
|
|
444
|
-
getDefaultFilter(fieldNumber, fixed) {
|
|
445
|
-
const field = fieldNumber;
|
|
446
|
-
const dOperator = field.defaultOperator ?? "e";
|
|
447
|
-
const defaultOperand1 = field.defaultOperand1 ?? null;
|
|
448
|
-
const defaultOperand2 = field.defaultOperand2 ?? null;
|
|
449
|
-
return {
|
|
450
|
-
id: 0,
|
|
451
|
-
fieldType: "number",
|
|
452
|
-
field,
|
|
453
|
-
fixed,
|
|
454
|
-
isSet: false,
|
|
455
|
-
operator: dOperator,
|
|
456
|
-
operand1: defaultOperand1,
|
|
457
|
-
operand2: defaultOperand2
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
getFormValue(field, getLabel, filterValue) {
|
|
461
|
-
const filterValueNumber = filterValue;
|
|
462
|
-
const operator = filterValueNumber ? filterValueNumber.operator : field.defaultOperator ?? "e";
|
|
463
|
-
const formValueOperand1 = filterValueNumber ? filterValueNumber.operand1 : null;
|
|
464
|
-
const formValueOperand2 = filterValueNumber && filterValueNumber?.operator === "b" ? filterValueNumber.operand2 : null;
|
|
465
|
-
return {
|
|
466
|
-
fieldType: "number",
|
|
467
|
-
formValueOperator: {
|
|
468
|
-
id: operator,
|
|
469
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
470
|
-
},
|
|
471
|
-
formValueOperand1,
|
|
472
|
-
formValueOperand2
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
getFilterFromFormValue(formFilterValue) {
|
|
476
|
-
const operator = formFilterValue.formValueOperator.id;
|
|
477
|
-
const operand1 = formFilterValue.formValueOperand1 ? formFilterValue.formValueOperand1 : 0;
|
|
478
|
-
if (operator === "b") {
|
|
479
|
-
const operand2 = formFilterValue.formValueOperand2 ? formFilterValue.formValueOperand2 : 0;
|
|
480
|
-
return {
|
|
481
|
-
fieldType: "number",
|
|
482
|
-
operator,
|
|
483
|
-
operand1,
|
|
484
|
-
operand2
|
|
485
|
-
};
|
|
486
|
-
} else {
|
|
487
|
-
return {
|
|
488
|
-
fieldType: "number",
|
|
489
|
-
operator,
|
|
490
|
-
operand1
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
getLabels(filter, getLabel, _formatters, _field) {
|
|
495
|
-
let labelOperands;
|
|
496
|
-
if (filter.operator === "b") {
|
|
497
|
-
labelOperands = filter.operand1 && filter.operand2 ? `${filter.operand1} - ${filter.operand2}` : "";
|
|
498
|
-
} else {
|
|
499
|
-
labelOperands = filter.operand1 !== void 0 ? filter.operand1 + "" : "";
|
|
500
|
-
}
|
|
501
|
-
return {
|
|
502
|
-
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
503
|
-
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
504
|
-
labelOperands
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
getSchema(getLabel) {
|
|
508
|
-
return Yup.object({
|
|
509
|
-
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
510
|
-
formValueOperand1: Yup.number().typeError(
|
|
511
|
-
getLabel(`dynamic_filter.error_operand_mustbe_number`)
|
|
512
|
-
),
|
|
513
|
-
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
514
|
-
is: "b",
|
|
515
|
-
then: Yup.number().typeError(getLabel(`dynamic_filter.error_operand_mustbe_number`)).min(Yup.ref("formValueOperand1"), getLabel(`dynamic_filter.error_less_than_start`))
|
|
516
|
-
})
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
verifyFilter(filter, _field) {
|
|
520
|
-
if (typeof filter.operator !== "number") {
|
|
521
|
-
return false;
|
|
522
|
-
}
|
|
523
|
-
if (NUMBER_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
524
|
-
return false;
|
|
525
|
-
}
|
|
526
|
-
if (typeof filter.operand1 !== "number") {
|
|
527
|
-
return false;
|
|
528
|
-
}
|
|
529
|
-
if (filter.operator === "b" && typeof filter.operand2 !== "number") {
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
return true;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
function useDynamicFilterStore(selector, equalityFn) {
|
|
536
|
-
const store = useContext(DynamicFilterContext);
|
|
537
|
-
if (!store)
|
|
538
|
-
throw new Error("useDynamicFilterStore context must be use inside DynamicFilterContext");
|
|
539
|
-
return useStore(store, selector, equalityFn ?? shallow);
|
|
540
|
-
}
|
|
541
|
-
function SelectFilter() {
|
|
542
|
-
const { getLabel } = useModuleDictionary();
|
|
543
|
-
const field = useDynamicFilterStore((state) => state.popoverFilterData?.field);
|
|
544
|
-
if (!field?.selectOptions?.endPoint) {
|
|
545
|
-
throw new Error("El filtro tipo Select requiere la configuraci\xF3n del Endpoint");
|
|
546
|
-
}
|
|
547
|
-
const autocompleteProps = field?.selectOptions;
|
|
548
|
-
const operators = useMemo(
|
|
549
|
-
() => SELECT_OPERATORS.map((o) => ({
|
|
550
|
-
id: o,
|
|
551
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${o}`))
|
|
552
|
-
})),
|
|
553
|
-
[getLabel]
|
|
554
|
-
);
|
|
555
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
556
|
-
/* @__PURE__ */ jsx(
|
|
557
|
-
RHFAutocomplete,
|
|
558
|
-
{
|
|
559
|
-
name: "formValueOperator",
|
|
560
|
-
autoComplete: "off",
|
|
561
|
-
options: operators,
|
|
562
|
-
getOptionLabel: (option) => option.label,
|
|
563
|
-
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
564
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operator))
|
|
565
|
-
}
|
|
566
|
-
),
|
|
567
|
-
/* @__PURE__ */ jsx(
|
|
568
|
-
RHFAutocompleteAsync,
|
|
569
|
-
{
|
|
570
|
-
...autocompleteProps,
|
|
571
|
-
name: "formValueOperandsArray",
|
|
572
|
-
autoComplete: "off",
|
|
573
|
-
label: getLabel(getDynamicFilterDictionary(DICCTIONARY.label_select_operands_array))
|
|
574
|
-
}
|
|
575
|
-
)
|
|
576
|
-
] });
|
|
577
|
-
}
|
|
578
|
-
function filterValidOperandsArraySelect(operandsArray, field) {
|
|
579
|
-
const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
|
|
580
|
-
const getOptionId = field?.selectOptions?.getOptionId;
|
|
581
|
-
const getOptionLabel = field?.selectOptions?.getOptionLabel;
|
|
582
|
-
return operandsArrayFormatted?.filter((operand) => {
|
|
583
|
-
return typeof operand === "object" && getOptionId?.(operand) && getOptionLabel?.(operand);
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
class SelectFilterHelpers {
|
|
587
|
-
getComponent() {
|
|
588
|
-
return SelectFilter;
|
|
589
|
-
}
|
|
590
|
-
getDefaultFilter(field, fixed) {
|
|
591
|
-
const defaultOperand = field.defaultOperandsArray;
|
|
592
|
-
const defaultFilter = {
|
|
593
|
-
id: 0,
|
|
594
|
-
fieldType: "select",
|
|
595
|
-
field,
|
|
596
|
-
fixed,
|
|
597
|
-
isSet: true,
|
|
598
|
-
operator: "in",
|
|
599
|
-
operandsArray: []
|
|
600
|
-
};
|
|
601
|
-
if (defaultOperand !== void 0 && Array.isArray(defaultOperand)) {
|
|
602
|
-
const validOperandsArray = filterValidOperandsArraySelect(defaultOperand, field);
|
|
603
|
-
defaultFilter.operandsArray = validOperandsArray || [];
|
|
604
|
-
}
|
|
605
|
-
return defaultFilter;
|
|
606
|
-
}
|
|
607
|
-
getFormValue(field, getLabel, filterValueSelect) {
|
|
608
|
-
const filterValue = filterValueSelect ? filterValueSelect : void 0;
|
|
609
|
-
const isMultiple = field?.selectOptions?.multiple ?? false;
|
|
610
|
-
const formValueOperandsArray = isMultiple ? filterValueSelect?.operandsArray : filterValueSelect?.operandsArray?.[0] || filterValueSelect?.operandsArray;
|
|
611
|
-
const operator = filterValue ? filterValue.operator : field.defaultOperator ?? "in";
|
|
612
|
-
return {
|
|
613
|
-
fieldType: "select",
|
|
614
|
-
formValueOperator: {
|
|
615
|
-
id: operator,
|
|
616
|
-
label: getLabel(getDynamicFilterDictionary(`operator_${operator}`))
|
|
617
|
-
},
|
|
618
|
-
formValueOperandsArray
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
getFilterFromFormValue(formFilterValue) {
|
|
622
|
-
const operator = formFilterValue.formValueOperator.id;
|
|
623
|
-
const operandsArray = Array.isArray(formFilterValue.formValueOperandsArray) ? formFilterValue.formValueOperandsArray : [formFilterValue.formValueOperandsArray];
|
|
624
|
-
return {
|
|
625
|
-
fieldType: "select",
|
|
626
|
-
operator,
|
|
627
|
-
operandsArray
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
getLabels(filter, getLabel, _formatters, field) {
|
|
631
|
-
const operandsArray = filter.operandsArray;
|
|
632
|
-
const labelOperands = operandsArray?.reduce?.((label, operand) => {
|
|
633
|
-
const textLabel = field.selectOptions?.getOptionLabel?.(operand) || "";
|
|
634
|
-
return label ? `${label} | ${textLabel}` : textLabel;
|
|
635
|
-
}, "")?.toString() || "";
|
|
636
|
-
return {
|
|
637
|
-
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
638
|
-
labelOperator: getLabel(getDynamicFilterDictionary(`operator_${filter.operator}`)),
|
|
639
|
-
labelOperands
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
getSchema(getLabel) {
|
|
643
|
-
return Yup.object({
|
|
644
|
-
formValueOperator: Yup.object().nullable().required(getLabel(`dynamic_filter.error_operator_required`)),
|
|
645
|
-
formValueOperandsArray: Yup.lazy((value) => {
|
|
646
|
-
return Array.isArray(value) ? Yup.array().min(1, getLabel(`dynamic_filter.error_operand_required`)).of(Yup.object().nullable()).required(getLabel(`dynamic_filter.error_operand_required`)) : Yup.object().nullable().required(getLabel(`dynamic_filter.error_operand_required`));
|
|
647
|
-
})
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
verifyFilter(filter, field) {
|
|
651
|
-
if (typeof filter.operator !== "string") {
|
|
652
|
-
return false;
|
|
653
|
-
}
|
|
654
|
-
if (!field) {
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
if (SELECT_OPERATORS.findIndex((f) => f === filter.operator) === -1) {
|
|
658
|
-
return false;
|
|
659
|
-
}
|
|
660
|
-
if (!filter.operandsArray || typeof filter.operandsArray !== "object") {
|
|
661
|
-
return false;
|
|
662
|
-
}
|
|
663
|
-
const validOperandsArray = filterValidOperandsArraySelect(
|
|
664
|
-
filter.operandsArray,
|
|
665
|
-
field
|
|
666
|
-
);
|
|
667
|
-
if (!validOperandsArray || validOperandsArray?.length === 0) {
|
|
668
|
-
return false;
|
|
669
|
-
}
|
|
670
|
-
return true;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
const helpersStrategies = {
|
|
674
|
-
boolean: new BooleanFilterHelpers(),
|
|
675
|
-
string: new StringFilterHelpers(),
|
|
676
|
-
number: new NumberFilterHelpers(),
|
|
677
|
-
datetime: new DateTimeFilterHelpers(),
|
|
678
|
-
select: new SelectFilterHelpers(),
|
|
679
|
-
__default__: () => {
|
|
680
|
-
throw new Error("Type no defined");
|
|
681
|
-
}
|
|
682
|
-
};
|
|
683
|
-
function fieldFactory(type) {
|
|
684
|
-
const selectedHelper = helpersStrategies?.[type];
|
|
685
|
-
if (!selectedHelper) {
|
|
686
|
-
return helpersStrategies.__default__();
|
|
687
|
-
}
|
|
688
|
-
return selectedHelper;
|
|
689
|
-
}
|
|
690
|
-
function getPurgedInitialFiltersApplied(fields, initialFilters, getFieldByName) {
|
|
691
|
-
const newFilters = [];
|
|
692
|
-
const fixedFields = [];
|
|
693
|
-
for (let index = 0; index < initialFilters.length; index++) {
|
|
694
|
-
try {
|
|
695
|
-
const initialFilter = initialFilters[index];
|
|
696
|
-
const field = getFieldByName(initialFilter.name);
|
|
697
|
-
const filter = {
|
|
698
|
-
id: 0,
|
|
699
|
-
isSet: true,
|
|
700
|
-
fixed: false,
|
|
701
|
-
field,
|
|
702
|
-
fieldType: field.type,
|
|
703
|
-
operator: initialFilters[index].operator,
|
|
704
|
-
operand1: initialFilters[index].operand1,
|
|
705
|
-
operand2: initialFilters[index].operand2,
|
|
706
|
-
operandsArray: initialFilters[index].operandsArray
|
|
707
|
-
};
|
|
708
|
-
if (!field)
|
|
709
|
-
continue;
|
|
710
|
-
const canAddField = fieldFactory(field.type).verifyFilter(initialFilter, field);
|
|
711
|
-
if (canAddField) {
|
|
712
|
-
if (filter.fieldType === "datetime") {
|
|
713
|
-
filter.operand1 = new Date(filter.operand1 + "");
|
|
714
|
-
filter.operand2 = new Date(filter.operand2 + "");
|
|
715
|
-
}
|
|
716
|
-
if (field.presence === "fixed") {
|
|
717
|
-
if (fixedFields.findIndex((f) => f === field.name) === -1) {
|
|
718
|
-
filter.fixed = true;
|
|
719
|
-
fixedFields.push(field.name);
|
|
720
|
-
} else {
|
|
721
|
-
filter.fixed = false;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
filter.isSet = true;
|
|
725
|
-
filter.id = newFilters.length + 1;
|
|
726
|
-
newFilters.push(filter);
|
|
727
|
-
}
|
|
728
|
-
} catch (error) {
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
for (let index = 0; index < fields.length; index++) {
|
|
732
|
-
const field = fields[index];
|
|
733
|
-
if (field.presence === "initialized" || field.presence === "fixed") {
|
|
734
|
-
if (!initialFilters.find((f) => f.name === field.name)) {
|
|
735
|
-
const newFilter = fieldFactory(field.type).getDefaultFilter(
|
|
736
|
-
field,
|
|
737
|
-
field.presence === "fixed"
|
|
738
|
-
);
|
|
739
|
-
newFilter.id = newFilters.length + 1;
|
|
740
|
-
newFilters.push(newFilter);
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return newFilters;
|
|
745
|
-
}
|
|
746
|
-
function updateAvailableFields(state) {
|
|
747
|
-
state.availableFields = state.fields.filter((field) => {
|
|
748
|
-
if (field.multiple === void 0 || field.multiple) {
|
|
749
|
-
return true;
|
|
750
|
-
}
|
|
751
|
-
const appliedFilterNames = new Set(state.appliedFilters.map((f) => f.field.name));
|
|
752
|
-
return !appliedFilterNames.has(field.name);
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
function updateOwnerStateIsValid(state) {
|
|
756
|
-
state.ownerState.isValid = state.appliedFilters.every((filter) => filter.isSet);
|
|
757
|
-
}
|
|
758
|
-
const updateAutomatic = (state) => {
|
|
759
|
-
updateOwnerStateIsValid(state);
|
|
760
|
-
updateAvailableFields(state);
|
|
761
|
-
if (state.ownerState.isValid && state.automatic) {
|
|
762
|
-
state.ownerState.isDirty = false;
|
|
763
|
-
state.countOnChangeFiltersApplied++;
|
|
764
|
-
}
|
|
765
|
-
};
|
|
766
|
-
const createAreaStore = (initProps) => {
|
|
767
|
-
const startProps = {
|
|
768
|
-
countOnChangeFiltersApplied: 0,
|
|
769
|
-
appliedFilters: [],
|
|
770
|
-
availableFields: [],
|
|
771
|
-
fnAnchorEl: void 0,
|
|
772
|
-
popoverFilterData: void 0,
|
|
773
|
-
inputData: "",
|
|
774
|
-
...initProps
|
|
775
|
-
};
|
|
776
|
-
return createStore(
|
|
777
|
-
devtools(
|
|
778
|
-
immer((set, get) => ({
|
|
779
|
-
...startProps,
|
|
780
|
-
actions: {
|
|
781
|
-
init: (initialFiltersApplied) => {
|
|
782
|
-
set((state) => {
|
|
783
|
-
state.appliedFilters = getPurgedInitialFiltersApplied(
|
|
784
|
-
state.fields,
|
|
785
|
-
initialFiltersApplied,
|
|
786
|
-
state.actions.getFieldByName
|
|
787
|
-
);
|
|
788
|
-
state.ownerState.isEmpty = state.appliedFilters.length <= 0;
|
|
789
|
-
updateAutomatic(state);
|
|
790
|
-
});
|
|
791
|
-
},
|
|
792
|
-
getFieldByName: (name) => {
|
|
793
|
-
const field = (get().withAllField ? get().fields.concat(get().allField) : get().fields).find((f) => {
|
|
794
|
-
return f.name === name;
|
|
795
|
-
});
|
|
796
|
-
if (field) {
|
|
797
|
-
return field;
|
|
798
|
-
}
|
|
799
|
-
throw new Error("No exist field");
|
|
800
|
-
},
|
|
801
|
-
removeFilter: (id) => {
|
|
802
|
-
set((state) => {
|
|
803
|
-
const indexToRemoved = state.appliedFilters.findIndex((f) => id === f.id && !f.fixed);
|
|
804
|
-
if (indexToRemoved > -1) {
|
|
805
|
-
state.appliedFilters.splice(indexToRemoved, 1);
|
|
806
|
-
state.ownerState.isEmpty = state.appliedFilters.length === 0;
|
|
807
|
-
updateAutomatic(state);
|
|
808
|
-
}
|
|
809
|
-
});
|
|
810
|
-
},
|
|
811
|
-
showPopoverFilterForAdd: (anchorEl, field) => {
|
|
812
|
-
set((state) => {
|
|
813
|
-
state.fnAnchorEl = void 0;
|
|
814
|
-
state.inputData = "";
|
|
815
|
-
state.popoverFilterData = {
|
|
816
|
-
openFor: "add",
|
|
817
|
-
fnAnchorEl: () => anchorEl,
|
|
818
|
-
field
|
|
819
|
-
};
|
|
820
|
-
});
|
|
821
|
-
get().actions.setInEdition(true);
|
|
822
|
-
},
|
|
823
|
-
showPopoverFilterForEdit: (anchorEl, filterToEdit) => {
|
|
824
|
-
set((state) => {
|
|
825
|
-
state.popoverFilterData = {
|
|
826
|
-
openFor: "edit",
|
|
827
|
-
fnAnchorEl: () => anchorEl,
|
|
828
|
-
filter: filterToEdit,
|
|
829
|
-
field: filterToEdit.field
|
|
830
|
-
};
|
|
831
|
-
});
|
|
832
|
-
get().actions.setInEdition(true);
|
|
833
|
-
},
|
|
834
|
-
hidePopoverFilter: (stayInEdition) => {
|
|
835
|
-
set((state) => {
|
|
836
|
-
state.popoverFilterData = void 0;
|
|
837
|
-
});
|
|
838
|
-
get().actions.setInEdition(stayInEdition);
|
|
839
|
-
},
|
|
840
|
-
clearFilters: () => {
|
|
841
|
-
set((state) => {
|
|
842
|
-
state.appliedFilters = state.appliedFilters.filter((f) => f.fixed);
|
|
843
|
-
state.ownerState.isEmpty = state.appliedFilters.length === 0;
|
|
844
|
-
updateAvailableFields(state);
|
|
845
|
-
});
|
|
846
|
-
},
|
|
847
|
-
fireOnChangeFilters: () => {
|
|
848
|
-
set((state) => {
|
|
849
|
-
if (state.ownerState.isValid) {
|
|
850
|
-
state.ownerState.isDirty = false;
|
|
851
|
-
state.countOnChangeFiltersApplied++;
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
},
|
|
855
|
-
getNewId: () => {
|
|
856
|
-
return get().appliedFilters.reduce((prev, filterField) => {
|
|
857
|
-
return filterField.id > prev ? filterField.id : prev;
|
|
858
|
-
}, 0) + 1;
|
|
859
|
-
},
|
|
860
|
-
addFilter: (newFilter) => {
|
|
861
|
-
set((state) => {
|
|
862
|
-
state.appliedFilters.push(newFilter);
|
|
863
|
-
state.ownerState.isEmpty = state.appliedFilters.length === 0;
|
|
864
|
-
updateAutomatic(state);
|
|
865
|
-
});
|
|
866
|
-
},
|
|
867
|
-
updateFilter: (editFilter) => {
|
|
868
|
-
set((state) => {
|
|
869
|
-
const index = state.appliedFilters.findIndex(
|
|
870
|
-
(filterField) => filterField.id === editFilter.id
|
|
871
|
-
);
|
|
872
|
-
if (index > -1) {
|
|
873
|
-
state.appliedFilters[index] = editFilter;
|
|
874
|
-
}
|
|
875
|
-
updateAutomatic(state);
|
|
876
|
-
});
|
|
877
|
-
},
|
|
878
|
-
setInputData: (inputData) => {
|
|
879
|
-
set((state) => {
|
|
880
|
-
state.inputData = inputData;
|
|
881
|
-
});
|
|
882
|
-
},
|
|
883
|
-
setInEdition: (newInEdition) => {
|
|
884
|
-
set((state) => {
|
|
885
|
-
state.ownerState.inEdition = newInEdition;
|
|
886
|
-
});
|
|
887
|
-
},
|
|
888
|
-
setExternalState: (newExternalState) => {
|
|
889
|
-
set((state) => {
|
|
890
|
-
state.ownerState = { ...state.ownerState, ...newExternalState };
|
|
891
|
-
});
|
|
892
|
-
},
|
|
893
|
-
openPopoverMenuFields: (anchorEl) => {
|
|
894
|
-
set((state) => {
|
|
895
|
-
state.fnAnchorEl = () => anchorEl;
|
|
896
|
-
});
|
|
897
|
-
},
|
|
898
|
-
closePopoverMenuFields: (newInEdition) => {
|
|
899
|
-
set((state) => {
|
|
900
|
-
state.fnAnchorEl = void 0;
|
|
901
|
-
state.ownerState.inEdition = newInEdition || false;
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
})),
|
|
906
|
-
{ name: `Dynamic filter` }
|
|
907
|
-
)
|
|
908
|
-
);
|
|
909
|
-
};
|
|
910
|
-
const formatToRawFilter = (appliedFilters) => {
|
|
911
|
-
return appliedFilters.map((af) => {
|
|
912
|
-
let oa = void 0;
|
|
913
|
-
if (af.field.type === "select" && af.operandsArray) {
|
|
914
|
-
oa = Array.isArray(af.operandsArray) ? af.operandsArray.map(af.field.selectOptions.getOptionId) : [af.field.selectOptions.getOptionId(af.operandsArray)];
|
|
915
|
-
}
|
|
916
|
-
return {
|
|
917
|
-
n: af.field.name,
|
|
918
|
-
o: af.operator,
|
|
919
|
-
o1: af.operand1,
|
|
920
|
-
o2: af.operator === "b" ? af.operand2 : void 0,
|
|
921
|
-
oa
|
|
922
|
-
};
|
|
923
|
-
});
|
|
924
|
-
};
|
|
925
|
-
function formatToInitialFilters(appliedFilters) {
|
|
926
|
-
return appliedFilters.map((appliedFilter) => {
|
|
927
|
-
const ret = {
|
|
928
|
-
name: appliedFilter.field.name,
|
|
929
|
-
operator: appliedFilter.operator,
|
|
930
|
-
operand1: appliedFilter.operand1,
|
|
931
|
-
operand2: appliedFilter.operator === "b" ? appliedFilter.operand2 : void 0
|
|
932
|
-
};
|
|
933
|
-
if (appliedFilter.fieldType === "datetime") {
|
|
934
|
-
ret.operand1 = appliedFilter.operand1.toISOString();
|
|
935
|
-
ret.operand2 = appliedFilter.operator === "b" ? appliedFilter.operand2.toISOString() : void 0;
|
|
936
|
-
}
|
|
937
|
-
if (appliedFilter.fieldType === "select") {
|
|
938
|
-
const validOperandsArray = filterValidOperandsArraySelect(
|
|
939
|
-
appliedFilter.operandsArray,
|
|
940
|
-
appliedFilter.field
|
|
941
|
-
);
|
|
942
|
-
if (validOperandsArray && validOperandsArray?.length > 0) {
|
|
943
|
-
ret.operandsArray = validOperandsArray;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
if (ret.operand2 === void 0) {
|
|
947
|
-
delete ret.operand2;
|
|
948
|
-
}
|
|
949
|
-
return ret;
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
const DynamicFilterContext = createContext(null);
|
|
953
|
-
function DynamicFilterProvider(props) {
|
|
954
|
-
const {
|
|
955
|
-
automatic = true,
|
|
956
|
-
withAllField = true,
|
|
957
|
-
fields,
|
|
958
|
-
initialAppliedFilters = [],
|
|
959
|
-
onChangeFilters,
|
|
960
|
-
dataTestId = "",
|
|
961
|
-
children
|
|
962
|
-
} = props;
|
|
963
|
-
const { getLabel } = useModuleDictionary();
|
|
964
|
-
const dynamicFilterStoreRef = useRef();
|
|
965
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
966
|
-
const isDesktop = useResponsiveDesktop();
|
|
967
|
-
const isSkeleton = useModuleSkeleton();
|
|
968
|
-
const isFirstRender = useFirstRender([isDesktop, isSkeleton]);
|
|
969
|
-
if (!dynamicFilterStoreRef.current) {
|
|
970
|
-
dynamicFilterStoreRef.current = createAreaStore({
|
|
971
|
-
allField: {
|
|
972
|
-
...ALL_FIELD,
|
|
973
|
-
urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/all_fields.svg`
|
|
974
|
-
},
|
|
975
|
-
withAllField,
|
|
976
|
-
fields,
|
|
977
|
-
automatic,
|
|
978
|
-
getLabel,
|
|
979
|
-
dataTestId,
|
|
980
|
-
ownerState: {
|
|
981
|
-
isSkeleton,
|
|
982
|
-
isDirty: !automatic,
|
|
983
|
-
inEdition: false,
|
|
984
|
-
isValid: true,
|
|
985
|
-
isMobile: !isDesktop,
|
|
986
|
-
isEmpty: true
|
|
987
|
-
}
|
|
988
|
-
});
|
|
989
|
-
dynamicFilterStoreRef.current.getState().actions.init(initialAppliedFilters);
|
|
990
|
-
}
|
|
991
|
-
const countOnChangeFiltersApplied = useStore(
|
|
992
|
-
dynamicFilterStoreRef.current,
|
|
993
|
-
(state) => state.countOnChangeFiltersApplied,
|
|
994
|
-
shallow
|
|
995
|
-
);
|
|
996
|
-
useEffect(() => {
|
|
997
|
-
if (countOnChangeFiltersApplied === 0) {
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
const state = dynamicFilterStoreRef.current?.getState();
|
|
1001
|
-
if (state) {
|
|
1002
|
-
onChangeFilters?.(
|
|
1003
|
-
formatToInitialFilters(state.appliedFilters),
|
|
1004
|
-
formatToRawFilter(state.appliedFilters)
|
|
1005
|
-
);
|
|
1006
|
-
}
|
|
1007
|
-
}, [countOnChangeFiltersApplied]);
|
|
1008
|
-
useEffect(() => {
|
|
1009
|
-
if (isFirstRender) {
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
dynamicFilterStoreRef.current?.getState().actions.setExternalState({ isMobile: !isDesktop, isSkeleton });
|
|
1013
|
-
}, [isDesktop, isSkeleton]);
|
|
1014
|
-
useEffect(() => {
|
|
1015
|
-
if (automatic) {
|
|
1016
|
-
dynamicFilterStoreRef.current?.getState().actions.fireOnChangeFilters();
|
|
1017
|
-
return;
|
|
1018
|
-
}
|
|
1019
|
-
}, []);
|
|
1020
|
-
return /* @__PURE__ */ jsx(DynamicFilterContext.Provider, { value: dynamicFilterStoreRef.current, children });
|
|
1021
|
-
}
|
|
1022
|
-
function useDynamicFilterBase() {
|
|
1023
|
-
const ownerState = useDynamicFilterStore((state) => state.ownerState);
|
|
1024
|
-
const dataTestId = useDynamicFilterStore((state) => state.dataTestId);
|
|
1025
|
-
return { ownerState, dataTestId };
|
|
1026
|
-
}
|
|
1027
|
-
function useInputFilter() {
|
|
1028
|
-
const [selectedFieldIndex, setSelectedFieldIndex] = useState(-1);
|
|
1029
|
-
const [filteredFields, setFilteredFields] = useState([]);
|
|
1030
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
1031
|
-
const { getLabel } = useModuleDictionary();
|
|
1032
|
-
const isSkeleton = useModuleSkeleton();
|
|
1033
|
-
const anchorEl = useDynamicFilterStore((state) => state.fnAnchorEl);
|
|
1034
|
-
const withAllField = useDynamicFilterStore((state) => state.withAllField);
|
|
1035
|
-
const availableFields = useDynamicFilterStore((state) => state.availableFields);
|
|
1036
|
-
const inputData = useDynamicFilterStore((state) => state.inputData);
|
|
1037
|
-
const {
|
|
1038
|
-
addFilter,
|
|
1039
|
-
closePopoverMenuFields,
|
|
1040
|
-
getFieldByName,
|
|
1041
|
-
getNewId,
|
|
1042
|
-
hidePopoverFilter,
|
|
1043
|
-
openPopoverMenuFields,
|
|
1044
|
-
setInEdition,
|
|
1045
|
-
setInputData,
|
|
1046
|
-
showPopoverFilterForAdd
|
|
1047
|
-
} = useDynamicFilterStore((state) => state.actions);
|
|
1048
|
-
useEffect(() => {
|
|
1049
|
-
if (!anchorEl) {
|
|
1050
|
-
setFilteredFields([]);
|
|
1051
|
-
} else {
|
|
1052
|
-
setFilteredFields(
|
|
1053
|
-
availableFields.filter(
|
|
1054
|
-
(field) => (field.label ?? getLabel(field.dictionaryId)).includes(inputData)
|
|
1055
|
-
)
|
|
1056
|
-
);
|
|
1057
|
-
setSelectedFieldIndex(-1);
|
|
1058
|
-
}
|
|
1059
|
-
}, [anchorEl, inputData, availableFields, getLabel]);
|
|
1060
|
-
function handleOpenPopUpClickItem(field) {
|
|
1061
|
-
closePopoverMenuFields();
|
|
1062
|
-
if (anchorEl)
|
|
1063
|
-
showPopoverFilterForAdd(anchorEl(), field);
|
|
1064
|
-
}
|
|
1065
|
-
const inputHandlersProps = {
|
|
1066
|
-
onFocus: (event) => {
|
|
1067
|
-
openPopoverMenuFields(event.currentTarget);
|
|
1068
|
-
setInEdition(true);
|
|
1069
|
-
},
|
|
1070
|
-
onChange: (event) => {
|
|
1071
|
-
setInputData(event.target.value);
|
|
1072
|
-
if (!anchorEl) {
|
|
1073
|
-
openPopoverMenuFields(event.currentTarget);
|
|
1074
|
-
}
|
|
1075
|
-
hidePopoverFilter(true);
|
|
1076
|
-
},
|
|
1077
|
-
onKeyDown: (event) => {
|
|
1078
|
-
if (event.key === "ArrowDown") {
|
|
1079
|
-
let newIndex = -1;
|
|
1080
|
-
if (filteredFields.length > 0) {
|
|
1081
|
-
if (selectedFieldIndex < filteredFields.length - 1) {
|
|
1082
|
-
newIndex = selectedFieldIndex + 1;
|
|
1083
|
-
} else {
|
|
1084
|
-
newIndex = filteredFields.length - 1;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
setSelectedFieldIndex(newIndex);
|
|
1088
|
-
}
|
|
1089
|
-
if (event.key === "ArrowUp") {
|
|
1090
|
-
let newIndex = -1;
|
|
1091
|
-
if (filteredFields.length > 0) {
|
|
1092
|
-
if (selectedFieldIndex > -1) {
|
|
1093
|
-
newIndex = selectedFieldIndex - 1;
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
setSelectedFieldIndex(newIndex);
|
|
1097
|
-
}
|
|
1098
|
-
if (event.key === "Escape") {
|
|
1099
|
-
closePopoverMenuFields();
|
|
1100
|
-
}
|
|
1101
|
-
if (event.key !== "Enter")
|
|
1102
|
-
return;
|
|
1103
|
-
if (selectedFieldIndex === -1) {
|
|
1104
|
-
if (inputData.trim() === "") {
|
|
1105
|
-
closePopoverMenuFields();
|
|
1106
|
-
return;
|
|
1107
|
-
}
|
|
1108
|
-
if (withAllField) {
|
|
1109
|
-
addFilter({
|
|
1110
|
-
id: getNewId(),
|
|
1111
|
-
fieldType: "string",
|
|
1112
|
-
field: getFieldByName(ALL_FIELD.name),
|
|
1113
|
-
isSet: true,
|
|
1114
|
-
fixed: false,
|
|
1115
|
-
operator: "c",
|
|
1116
|
-
operand1: inputData
|
|
1117
|
-
});
|
|
1118
|
-
setInputData("");
|
|
1119
|
-
closePopoverMenuFields();
|
|
1120
|
-
}
|
|
1121
|
-
} else {
|
|
1122
|
-
handleOpenPopUpClickItem(filteredFields[selectedFieldIndex]);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
};
|
|
1126
|
-
return {
|
|
1127
|
-
iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/filter.svg`,
|
|
1128
|
-
isSkeleton,
|
|
1129
|
-
inputPlaceHolder: getLabel(getDynamicFilterDictionary(DICCTIONARY.input_placeholder)),
|
|
1130
|
-
inputData,
|
|
1131
|
-
inputHandlersProps,
|
|
1132
|
-
canRender: !(!withAllField && availableFields.length === 0),
|
|
1133
|
-
filteredFields,
|
|
1134
|
-
selectedFieldIndex
|
|
1135
|
-
};
|
|
1136
|
-
}
|
|
1137
|
-
function InputFilterSkeleton() {
|
|
1138
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1139
|
-
/* @__PURE__ */ jsx(
|
|
1140
|
-
Skeleton,
|
|
1141
|
-
{
|
|
1142
|
-
variant: "circular",
|
|
1143
|
-
width: "16px",
|
|
1144
|
-
height: "16px",
|
|
1145
|
-
sx: { minWidth: "16px", minHeight: "16px" }
|
|
1146
|
-
}
|
|
1147
|
-
),
|
|
1148
|
-
/* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "100%", height: "16px", sx: { minWidth: "80px" } })
|
|
1149
|
-
] });
|
|
1150
|
-
}
|
|
1151
|
-
var DynamicFilterSlots = /* @__PURE__ */ ((DynamicFilterSlots2) => {
|
|
1152
|
-
DynamicFilterSlots2["root"] = "root";
|
|
1153
|
-
DynamicFilterSlots2["innerContainer"] = "innerContainer";
|
|
1154
|
-
DynamicFilterSlots2["inputFilter"] = "inputFilter";
|
|
1155
|
-
DynamicFilterSlots2["inputFilterInput"] = "inputFilterInput";
|
|
1156
|
-
DynamicFilterSlots2["inputFilterIcon"] = "inputFilterIcon";
|
|
1157
|
-
DynamicFilterSlots2["appliedFilters"] = "appliedFilters";
|
|
1158
|
-
DynamicFilterSlots2["appliedFilterInnerContainer"] = "appliedFilterInnerContainer";
|
|
1159
|
-
DynamicFilterSlots2["appliedFilterChip"] = "appliedFilterChip";
|
|
1160
|
-
DynamicFilterSlots2["appliedFilterChipIcon"] = "appliedFilterChipIcon";
|
|
1161
|
-
DynamicFilterSlots2["appliedFilterChipInfo"] = "appliedFilterChipInfo";
|
|
1162
|
-
DynamicFilterSlots2["appliedFilterChipInfoFieldName"] = "appliedFilterChipInfoFieldName";
|
|
1163
|
-
DynamicFilterSlots2["appliedFilterChipInfoOperator"] = "appliedFilterChipInfoOperator";
|
|
1164
|
-
DynamicFilterSlots2["appliedFilterChipInfoOperands"] = "appliedFilterChipInfoOperands";
|
|
1165
|
-
DynamicFilterSlots2["appliedFilterChipRemoveButton"] = "appliedFilterChipRemoveButton";
|
|
1166
|
-
DynamicFilterSlots2["actions"] = "actions";
|
|
1167
|
-
DynamicFilterSlots2["actionsSkeletonButton"] = "actionsSkeletonButton";
|
|
1168
|
-
DynamicFilterSlots2["actionsClearButton"] = "actionsClearButton";
|
|
1169
|
-
DynamicFilterSlots2["actionsSubmitButton"] = "actionsSubmitButton";
|
|
1170
|
-
DynamicFilterSlots2["popoverMenu"] = "popoverMenu";
|
|
1171
|
-
DynamicFilterSlots2["popoverMenuItem"] = "popoverMenuItem";
|
|
1172
|
-
DynamicFilterSlots2["popoverMenuItemIcon"] = "popoverMenuItemIcon";
|
|
1173
|
-
DynamicFilterSlots2["popoverMenuItemLabel"] = "popoverMenuItemLabel";
|
|
1174
|
-
DynamicFilterSlots2["popoverFilter"] = "popoverFilter";
|
|
1175
|
-
DynamicFilterSlots2["popoverFilterContainerFields"] = "popoverFilterContainerFields";
|
|
1176
|
-
DynamicFilterSlots2["popoverFilterHeader"] = "popoverFilterHeader";
|
|
1177
|
-
DynamicFilterSlots2["popoverFilterHeaderIcon"] = "popoverFilterHeaderIcon";
|
|
1178
|
-
DynamicFilterSlots2["popoverFilterHeaderTitle"] = "popoverFilterHeaderTitle";
|
|
1179
|
-
DynamicFilterSlots2["popoverFilterActions"] = "popoverFilterActions";
|
|
1180
|
-
return DynamicFilterSlots2;
|
|
1181
|
-
})(DynamicFilterSlots || {});
|
|
1182
|
-
const CONTAINER_QUERY_NAME = "dynamic";
|
|
1183
|
-
const dynamicFilterStyles = {
|
|
1184
|
-
root: {
|
|
1185
|
-
containerName: CONTAINER_QUERY_NAME,
|
|
1186
|
-
containerType: "inline-size",
|
|
1187
|
-
width: "100%",
|
|
1188
|
-
height: "auto",
|
|
1189
|
-
padding: 0
|
|
1190
|
-
},
|
|
1191
|
-
innerContainer: ({ theme, ownerState }) => ({
|
|
1192
|
-
display: "grid",
|
|
1193
|
-
gridTemplateColumns: "auto 1fr auto",
|
|
1194
|
-
gridTemplateAreas: '"input-filter applied-filters actions-filter"',
|
|
1195
|
-
alignItems: "center",
|
|
1196
|
-
justifyContent: "flex-start",
|
|
1197
|
-
width: "100%",
|
|
1198
|
-
height: "fit-content",
|
|
1199
|
-
border: "1px solid",
|
|
1200
|
-
borderRadius: "4px",
|
|
1201
|
-
borderColor: theme.vars.palette.state?.borderPrimary,
|
|
1202
|
-
background: theme.vars.palette.background.default,
|
|
1203
|
-
[containerQuery(theme.breakpoints, CONTAINER_QUERY_NAME)]: {
|
|
1204
|
-
minHeight: "auto",
|
|
1205
|
-
height: "auto",
|
|
1206
|
-
gridTemplateColumns: "1fr auto",
|
|
1207
|
-
gridTemplateAreas: `"input-filter actions-filter"
|
|
1208
|
-
"applied-filters applied-filters"`
|
|
1209
|
-
},
|
|
1210
|
-
"&:focus-within": {
|
|
1211
|
-
borderColor: !ownerState.isValid ? theme.vars.palette.state.error.normal : theme.vars.palette.state?.focus
|
|
1212
|
-
},
|
|
1213
|
-
...ownerState.isValid === false ? {
|
|
1214
|
-
borderColor: theme.palette.state.error.normal
|
|
1215
|
-
} : {}
|
|
1216
|
-
}),
|
|
1217
|
-
inputFilter: ({ theme }) => ({
|
|
1218
|
-
gridArea: "input-filter",
|
|
1219
|
-
display: "flex",
|
|
1220
|
-
flexDirection: "row",
|
|
1221
|
-
gap: "8px",
|
|
1222
|
-
padding: "4px 6px 4px 4px",
|
|
1223
|
-
height: "100%",
|
|
1224
|
-
maxWidth: "135px",
|
|
1225
|
-
width: "100%",
|
|
1226
|
-
alignItems: "center",
|
|
1227
|
-
borderTopLeftRadius: "4px",
|
|
1228
|
-
borderBottomLeftRadius: "4px",
|
|
1229
|
-
borderRight: "1px solid",
|
|
1230
|
-
borderColor: theme.vars.palette.state?.borderPrimary,
|
|
1231
|
-
[containerQuery(theme.breakpoints, CONTAINER_QUERY_NAME)]: {
|
|
1232
|
-
height: "32px",
|
|
1233
|
-
width: "100%",
|
|
1234
|
-
maxWidth: "100%",
|
|
1235
|
-
borderRight: "none"
|
|
1236
|
-
},
|
|
1237
|
-
[theme.breakpoints.down("sm")]: {
|
|
1238
|
-
height: "44px",
|
|
1239
|
-
justifyContent: "center"
|
|
1240
|
-
}
|
|
1241
|
-
}),
|
|
1242
|
-
inputFilterInput: ({ theme }) => ({
|
|
1243
|
-
...theme.typography.body,
|
|
1244
|
-
background: theme.vars.palette.background.default,
|
|
1245
|
-
color: theme.vars.palette.text.secondary,
|
|
1246
|
-
border: "1px solid",
|
|
1247
|
-
borderColor: "transparent",
|
|
1248
|
-
padding: "4px 8px",
|
|
1249
|
-
width: "100%",
|
|
1250
|
-
height: "100%",
|
|
1251
|
-
"&::placeholder": {
|
|
1252
|
-
color: theme.vars.palette.text.secondary
|
|
1253
|
-
},
|
|
1254
|
-
"&:focus-visible": {
|
|
1255
|
-
color: theme.vars.palette.text.secondary,
|
|
1256
|
-
border: "1px solid",
|
|
1257
|
-
borderColor: theme.vars.palette.state?.active12,
|
|
1258
|
-
background: theme.vars.palette.state?.active12,
|
|
1259
|
-
BorderRadius: "2px",
|
|
1260
|
-
outline: "none!important"
|
|
1261
|
-
},
|
|
1262
|
-
"&:hover": {
|
|
1263
|
-
borderColor: theme.vars.palette.state?.toneOp,
|
|
1264
|
-
background: theme.vars.palette.state?.hoverDefault
|
|
1265
|
-
}
|
|
1266
|
-
}),
|
|
1267
|
-
inputFilterIcon: {
|
|
1268
|
-
visibility: "visible"
|
|
1269
|
-
},
|
|
1270
|
-
appliedFilters: ({ theme }) => ({
|
|
1271
|
-
gridArea: "applied-filters",
|
|
1272
|
-
width: "100%",
|
|
1273
|
-
height: "fit-content",
|
|
1274
|
-
paddingLeft: theme.spacing(1),
|
|
1275
|
-
borderLeft: "none",
|
|
1276
|
-
margin: "0px",
|
|
1277
|
-
padding: "0px 4px",
|
|
1278
|
-
[containerQuery(theme.breakpoints, CONTAINER_QUERY_NAME)]: {
|
|
1279
|
-
height: "auto",
|
|
1280
|
-
padding: "4px",
|
|
1281
|
-
display: "flex",
|
|
1282
|
-
borderTop: "1px solid ",
|
|
1283
|
-
borderColor: theme.vars.palette.state?.borderSecondary,
|
|
1284
|
-
"&:has(div[class*=appliedFilterInnerContainer]:empty), &:empty": {
|
|
1285
|
-
display: "none"
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
}),
|
|
1289
|
-
appliedFilterInnerContainer: ({ theme }) => ({
|
|
1290
|
-
padding: "2px",
|
|
1291
|
-
gap: "4px",
|
|
1292
|
-
height: "fit-content",
|
|
1293
|
-
display: "flex",
|
|
1294
|
-
flexWrap: "nowrap",
|
|
1295
|
-
width: "100%",
|
|
1296
|
-
justifyContent: "flex-start",
|
|
1297
|
-
alignItems: "center",
|
|
1298
|
-
[containerQuery(theme.breakpoints, CONTAINER_QUERY_NAME)]: {
|
|
1299
|
-
height: "32px",
|
|
1300
|
-
padding: 0,
|
|
1301
|
-
margin: 0,
|
|
1302
|
-
border: 0
|
|
1303
|
-
},
|
|
1304
|
-
[theme.breakpoints.down("sm")]: {
|
|
1305
|
-
padding: 0,
|
|
1306
|
-
height: "44px"
|
|
1307
|
-
}
|
|
1308
|
-
}),
|
|
1309
|
-
appliedFilterChip: ({ theme }) => ({
|
|
1310
|
-
display: "flex",
|
|
1311
|
-
justifyContent: "center",
|
|
1312
|
-
alignItems: "center",
|
|
1313
|
-
overflow: "visible",
|
|
1314
|
-
width: "auto",
|
|
1315
|
-
height: "24px",
|
|
1316
|
-
minHeight: theme.spacing(3),
|
|
1317
|
-
paddingLeft: theme.spacing(1),
|
|
1318
|
-
borderColor: alpha(`${theme.palette.divider}`, 0.1),
|
|
1319
|
-
border: "none",
|
|
1320
|
-
borderRadius: "4px",
|
|
1321
|
-
backgroundColor: theme.palette.state?.default,
|
|
1322
|
-
color: theme.palette.text.secondary,
|
|
1323
|
-
...theme.typography.body,
|
|
1324
|
-
[theme.breakpoints.down("sm")]: {
|
|
1325
|
-
height: "fit-content"
|
|
1326
|
-
}
|
|
1327
|
-
}),
|
|
1328
|
-
appliedFilterChipIcon: {
|
|
1329
|
-
visibility: "visible"
|
|
1330
|
-
},
|
|
1331
|
-
appliedFilterChipInfo: ({ theme }) => ({
|
|
1332
|
-
...theme.typography.body2,
|
|
1333
|
-
display: "flex",
|
|
1334
|
-
justifyContent: "center",
|
|
1335
|
-
alignItems: "center",
|
|
1336
|
-
width: "auto",
|
|
1337
|
-
height: "100%",
|
|
1338
|
-
marginRight: theme.spacing(1),
|
|
1339
|
-
marginLeft: theme.spacing(1),
|
|
1340
|
-
whiteSpace: "nowrap",
|
|
1341
|
-
border: "none",
|
|
1342
|
-
backgroundColor: "transparent"
|
|
1343
|
-
}),
|
|
1344
|
-
appliedFilterChipInfoFieldName: ({ theme }) => ({
|
|
1345
|
-
...theme.typography.subtitle2,
|
|
1346
|
-
color: theme.palette.text.secondary
|
|
1347
|
-
}),
|
|
1348
|
-
appliedFilterChipInfoOperator: ({ theme }) => ({
|
|
1349
|
-
...theme.typography.body2,
|
|
1350
|
-
marginLeft: theme.spacing(1.5),
|
|
1351
|
-
fontStyle: "italic",
|
|
1352
|
-
color: theme.palette.text.secondary
|
|
1353
|
-
}),
|
|
1354
|
-
appliedFilterChipInfoOperands: ({ theme }) => ({
|
|
1355
|
-
...theme.typography.body2,
|
|
1356
|
-
marginLeft: theme.spacing(1.5),
|
|
1357
|
-
color: theme.palette.text.secondary
|
|
1358
|
-
}),
|
|
1359
|
-
appliedFilterChipRemoveButton: {
|
|
1360
|
-
visibility: "visible"
|
|
1361
|
-
},
|
|
1362
|
-
actions: ({ theme }) => ({
|
|
1363
|
-
gridArea: "actions-filter",
|
|
1364
|
-
display: "flex",
|
|
1365
|
-
flexDirection: "row",
|
|
1366
|
-
gap: "8px",
|
|
1367
|
-
padding: "4px",
|
|
1368
|
-
height: "100%",
|
|
1369
|
-
alignItems: "center",
|
|
1370
|
-
borderTopRightRadius: "4px",
|
|
1371
|
-
borderBottomRightRadius: "4px",
|
|
1372
|
-
borderLeft: "1px solid",
|
|
1373
|
-
borderColor: theme.palette.state?.borderPrimary
|
|
1374
|
-
}),
|
|
1375
|
-
actionsSkeletonButton: {
|
|
1376
|
-
display: "flex",
|
|
1377
|
-
justifyContent: "center",
|
|
1378
|
-
alignItems: "center",
|
|
1379
|
-
width: "24px",
|
|
1380
|
-
height: "24px"
|
|
1381
|
-
},
|
|
1382
|
-
actionsClearButton: {
|
|
1383
|
-
visibility: "visible"
|
|
1384
|
-
},
|
|
1385
|
-
actionsSubmitButton: ({ theme, ownerState }) => ({
|
|
1386
|
-
...ownerState.isValid === false ? { border: `1px dashed ${theme.palette.error.main}` } : {
|
|
1387
|
-
visibility: "visible"
|
|
1388
|
-
}
|
|
1389
|
-
}),
|
|
1390
|
-
popoverMenu: ({ theme }) => ({
|
|
1391
|
-
"& .MuiPaper-root": {
|
|
1392
|
-
display: "flex",
|
|
1393
|
-
flexDirection: "column",
|
|
1394
|
-
padding: "8px !important",
|
|
1395
|
-
gap: "4px",
|
|
1396
|
-
borderRadius: "6px",
|
|
1397
|
-
[theme.breakpoints.down("md")]: {
|
|
1398
|
-
gap: "4px"
|
|
1399
|
-
},
|
|
1400
|
-
"& .M4LPopover-arrowStyle": {
|
|
1401
|
-
display: "none"
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
}),
|
|
1405
|
-
popoverMenuItem: ({ theme }) => ({
|
|
1406
|
-
paddingLeft: "4px",
|
|
1407
|
-
paddingRight: "4px",
|
|
1408
|
-
borderRadius: "4px",
|
|
1409
|
-
"&:hover": {
|
|
1410
|
-
...theme.typography.body,
|
|
1411
|
-
color: theme.palette.state?.hover,
|
|
1412
|
-
background: theme.palette.state?.default,
|
|
1413
|
-
borderRadius: "4px",
|
|
1414
|
-
padding: "4px 12px 4px 8px"
|
|
1415
|
-
}
|
|
1416
|
-
}),
|
|
1417
|
-
popoverMenuItemLabel: ({ theme }) => ({
|
|
1418
|
-
...theme.typography.body,
|
|
1419
|
-
color: theme.palette.text.primary
|
|
1420
|
-
}),
|
|
1421
|
-
popoverMenuItemIcon: {
|
|
1422
|
-
visibility: "visible"
|
|
1423
|
-
},
|
|
1424
|
-
popoverFilter: ({ theme }) => ({
|
|
1425
|
-
width: "auto",
|
|
1426
|
-
"& .MuiPaper-root": {
|
|
1427
|
-
padding: "0 !important",
|
|
1428
|
-
minWidth: "220px",
|
|
1429
|
-
maxWidth: "100%",
|
|
1430
|
-
minHeight: "auto",
|
|
1431
|
-
boxShadow: theme.customShadows?.z3,
|
|
1432
|
-
"& .M4LPopover-arrowStyle": {
|
|
1433
|
-
display: "none"
|
|
1434
|
-
},
|
|
1435
|
-
"& .M4LRHFormProvider-root": {
|
|
1436
|
-
gap: "0px",
|
|
1437
|
-
width: "max-content",
|
|
1438
|
-
minWidth: "220px",
|
|
1439
|
-
maxWidth: "420px",
|
|
1440
|
-
height: "fit-content"
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
}),
|
|
1444
|
-
popoverFilterHeader: ({ theme }) => ({
|
|
1445
|
-
backgroundColor: theme.palette.state?.default,
|
|
1446
|
-
display: "flex",
|
|
1447
|
-
alignItems: "center",
|
|
1448
|
-
gap: "8px",
|
|
1449
|
-
padding: "4px 4px 4px 8px",
|
|
1450
|
-
borderTopLeftRadius: "4px",
|
|
1451
|
-
borderTopRightRadius: "4px",
|
|
1452
|
-
borderBottom: "0px",
|
|
1453
|
-
height: "28px",
|
|
1454
|
-
[theme.breakpoints.down("sm")]: {
|
|
1455
|
-
height: "36px"
|
|
1456
|
-
}
|
|
1457
|
-
}),
|
|
1458
|
-
popoverFilterHeaderIcon: {
|
|
1459
|
-
visibility: "visible"
|
|
1460
|
-
},
|
|
1461
|
-
popoverFilterHeaderTitle: ({ theme }) => ({
|
|
1462
|
-
...theme.typography.paragraphDens,
|
|
1463
|
-
color: theme.palette.text.primary
|
|
1464
|
-
}),
|
|
1465
|
-
popoverFilterContainerFields: ({ theme }) => ({
|
|
1466
|
-
height: "fit-content",
|
|
1467
|
-
"& > div": {
|
|
1468
|
-
display: "flex",
|
|
1469
|
-
height: "auto",
|
|
1470
|
-
flexDirection: "column",
|
|
1471
|
-
padding: "12px 12px 0 12px",
|
|
1472
|
-
gap: "8px",
|
|
1473
|
-
[theme.breakpoints.down("sm")]: {
|
|
1474
|
-
padding: "16px 16px 0 16px",
|
|
1475
|
-
gap: "12px"
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
}),
|
|
1479
|
-
popoverFilterActions: ({ theme }) => ({
|
|
1480
|
-
display: "flex",
|
|
1481
|
-
flexDirection: "row",
|
|
1482
|
-
gap: "16px",
|
|
1483
|
-
padding: "16px 12px 12px 12px !important",
|
|
1484
|
-
[theme.breakpoints.down("sm")]: {
|
|
1485
|
-
padding: "24px 16px 16px 16px !important"
|
|
1486
|
-
},
|
|
1487
|
-
"& > .M4LButton-root": {
|
|
1488
|
-
height: "24px",
|
|
1489
|
-
minHeight: "24px",
|
|
1490
|
-
[theme.breakpoints.down("sm")]: {
|
|
1491
|
-
height: "36px"
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
})
|
|
1495
|
-
};
|
|
1496
|
-
const InputFilter = () => {
|
|
1497
|
-
const {
|
|
1498
|
-
iconUrl,
|
|
1499
|
-
isSkeleton,
|
|
1500
|
-
inputPlaceHolder,
|
|
1501
|
-
inputData,
|
|
1502
|
-
inputHandlersProps,
|
|
1503
|
-
canRender,
|
|
1504
|
-
filteredFields,
|
|
1505
|
-
selectedFieldIndex
|
|
1506
|
-
} = useInputFilter();
|
|
1507
|
-
if (!canRender)
|
|
1508
|
-
return null;
|
|
1509
|
-
if (isSkeleton) {
|
|
1510
|
-
return /* @__PURE__ */ jsx(InputFilterStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(InputFilterSkeleton, {}) });
|
|
1511
|
-
}
|
|
1512
|
-
return /* @__PURE__ */ jsxs(InputFilterStyled, { ownerState: {}, children: [
|
|
1513
|
-
/* @__PURE__ */ jsx(InputFilterIconStyled, { src: iconUrl, ownerState: {} }),
|
|
1514
|
-
/* @__PURE__ */ jsx(
|
|
1515
|
-
InputFilterInputStyled,
|
|
1516
|
-
{
|
|
1517
|
-
type: "text",
|
|
1518
|
-
value: inputData,
|
|
1519
|
-
placeholder: inputPlaceHolder,
|
|
1520
|
-
ownerState: {},
|
|
1521
|
-
...inputHandlersProps
|
|
1522
|
-
}
|
|
1523
|
-
),
|
|
1524
|
-
/* @__PURE__ */ jsx(PopoverMenuFields, { fields: filteredFields, selectFieldIndex: selectedFieldIndex })
|
|
1525
|
-
] });
|
|
1526
|
-
};
|
|
1527
|
-
const InputFilter$1 = InputFilter;
|
|
1528
|
-
function useAppliedFilters() {
|
|
1529
|
-
const appliedFilter = useDynamicFilterStore((state) => state.appliedFilters);
|
|
1530
|
-
const isSkeleton = useDynamicFilterStore((state) => state.ownerState.isSkeleton);
|
|
1531
|
-
const appliedFiltersSorted = [...appliedFilter].sort(
|
|
1532
|
-
(filterA, filterB) => filterA.isSet !== filterB.isSet ? Number(filterA.isSet) - Number(filterB.isSet) : filterB.id - filterA.id
|
|
1533
|
-
);
|
|
1534
|
-
return {
|
|
1535
|
-
appliedFiltersSorted,
|
|
1536
|
-
isSkeleton
|
|
1537
|
-
};
|
|
1538
|
-
}
|
|
1539
|
-
function useAppliedFilterChip(filter) {
|
|
1540
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
1541
|
-
const { getLabel } = useModuleDictionary();
|
|
1542
|
-
const formatters = useFormatter();
|
|
1543
|
-
const { hidePopoverFilter, removeFilter, showPopoverFilterForEdit } = useDynamicFilterStore(
|
|
1544
|
-
(state) => state.actions
|
|
1545
|
-
);
|
|
1546
|
-
const removeIconUrl = `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/clear.svg`;
|
|
1547
|
-
const labels = useMemo(() => {
|
|
1548
|
-
return fieldFactory(filter.field.type).getLabels(filter, getLabel, formatters, filter.field);
|
|
1549
|
-
}, [filter, getLabel]);
|
|
1550
|
-
function onDelete() {
|
|
1551
|
-
hidePopoverFilter(false);
|
|
1552
|
-
removeFilter(filter.id);
|
|
1553
|
-
}
|
|
1554
|
-
function onEditFilter(event) {
|
|
1555
|
-
hidePopoverFilter(false);
|
|
1556
|
-
const currentTarget = event.currentTarget;
|
|
1557
|
-
setTimeout(() => showPopoverFilterForEdit(currentTarget, filter), 10);
|
|
1558
|
-
}
|
|
1559
|
-
return {
|
|
1560
|
-
onDelete,
|
|
1561
|
-
onEditFilter,
|
|
1562
|
-
removeIconUrl,
|
|
1563
|
-
iconFieldUrl: filter.field?.urlIcon,
|
|
1564
|
-
labels
|
|
1565
|
-
};
|
|
1566
|
-
}
|
|
1567
|
-
function AppliedFilterChip(props) {
|
|
1568
|
-
const { fixed } = props;
|
|
1569
|
-
const { onEditFilter, onDelete, iconFieldUrl, removeIconUrl, labels } = useAppliedFilterChip(props);
|
|
1570
|
-
return /* @__PURE__ */ jsxs(AppliedFilterChipStyled, { ownerState: {}, children: [
|
|
1571
|
-
iconFieldUrl && /* @__PURE__ */ jsx(AppliedFilterChipIconStyled, { onClick: onEditFilter, src: iconFieldUrl, ownerState: {} }),
|
|
1572
|
-
/* @__PURE__ */ jsxs(AppliedFilterChipInfoStyled, { onClick: onEditFilter, ownerState: {}, children: [
|
|
1573
|
-
/* @__PURE__ */ jsx(AppliedFilterChipInfoFieldNameStyled, { ownerState: {}, children: labels.labelField }),
|
|
1574
|
-
/* @__PURE__ */ jsx(AppliedFilterChipInfoOperatorStyled, { ownerState: {}, children: labels.labelOperator }),
|
|
1575
|
-
/* @__PURE__ */ jsx(AppliedFilterChipInfoOperandsStyled, { ownerState: {}, children: labels.labelOperands })
|
|
1576
|
-
] }),
|
|
1577
|
-
!fixed && /* @__PURE__ */ jsx(
|
|
1578
|
-
AppliedFilterChipRemoveButtonStyled,
|
|
1579
|
-
{
|
|
1580
|
-
src: removeIconUrl,
|
|
1581
|
-
size: "small",
|
|
1582
|
-
dictionaryTooltipId: "dynamic_filter.tooltip_clear_filter",
|
|
1583
|
-
onClick: onDelete,
|
|
1584
|
-
ownerState: {}
|
|
1585
|
-
}
|
|
1586
|
-
)
|
|
1587
|
-
] });
|
|
1588
|
-
}
|
|
1589
|
-
function AppliedFilters() {
|
|
1590
|
-
const { appliedFiltersSorted, isSkeleton } = useAppliedFilters();
|
|
1591
|
-
if (isSkeleton) {
|
|
1592
|
-
return /* @__PURE__ */ jsx(AppliedFiltersStyled, { ownerState: {} });
|
|
1593
|
-
}
|
|
1594
|
-
return /* @__PURE__ */ jsx(AppliedFiltersStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(ScrollBar, { children: /* @__PURE__ */ jsx(AppliedFilterInnerContainerStyled, { ownerState: {}, children: appliedFiltersSorted?.map((filter) => /* @__PURE__ */ jsx(AppliedFilterChip, { ...filter }, filter.id)) }) }) });
|
|
1595
|
-
}
|
|
1596
|
-
const ASSETS_URL = "frontend/components/dynamic_filter/assets/icons";
|
|
1597
|
-
const ASSETS = {
|
|
1598
|
-
refresh: "restart.svg",
|
|
1599
|
-
search: "search.svg"
|
|
1600
|
-
};
|
|
1601
|
-
function useFilterActions() {
|
|
1602
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
1603
|
-
const automatic = useDynamicFilterStore((state) => state.automatic);
|
|
1604
|
-
const isSkeleton = useDynamicFilterStore((state) => state.ownerState.isSkeleton);
|
|
1605
|
-
const isValid = useDynamicFilterStore((state) => state.ownerState.isValid);
|
|
1606
|
-
const isDirty = useDynamicFilterStore((state) => state.ownerState.isDirty);
|
|
1607
|
-
const appliedFilters = useDynamicFilterStore((state) => state.appliedFilters);
|
|
1608
|
-
const { hidePopoverFilter, clearFilters, fireOnChangeFilters } = useDynamicFilterStore(
|
|
1609
|
-
(state) => state.actions
|
|
1610
|
-
);
|
|
1611
|
-
function onClickClearFilters() {
|
|
1612
|
-
hidePopoverFilter(false);
|
|
1613
|
-
clearFilters();
|
|
1614
|
-
fireOnChangeFilters();
|
|
1615
|
-
}
|
|
1616
|
-
const filterIconUrl = `${host_static_assets}/${environment_assets}/${ASSETS_URL}/${automatic ? ASSETS.refresh : ASSETS.search}`;
|
|
1617
|
-
const clearIconUrl = `${host_static_assets}/${environment_assets}/frontend/components/dynamic_filter/assets/icons/close.svg`;
|
|
1618
|
-
const canShowRemoveAction = appliedFilters.findIndex((f) => !f.fixed) > -1;
|
|
1619
|
-
const filterButtonDictionaryTooltip = getDynamicFilterDictionary(
|
|
1620
|
-
isValid ? isDirty ? DICCTIONARY.filter_tooltip_dirty : DICCTIONARY.filter_tooltip_refresh : DICCTIONARY.filter_tooltip_invalid
|
|
1621
|
-
);
|
|
1622
|
-
return {
|
|
1623
|
-
isSkeleton,
|
|
1624
|
-
filterIconUrl,
|
|
1625
|
-
clearIconUrl,
|
|
1626
|
-
canShowRemoveAction,
|
|
1627
|
-
onClickClearFilters,
|
|
1628
|
-
onClickFilter: fireOnChangeFilters,
|
|
1629
|
-
filterButtonDictionaryTooltip,
|
|
1630
|
-
ownerState: { isValid }
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
function FilterActionsSkeleton() {
|
|
1634
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1635
|
-
/* @__PURE__ */ jsx(ActionsSkeletonButtonStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: "16px", height: "16px" }) }),
|
|
1636
|
-
/* @__PURE__ */ jsx(ActionsSkeletonButtonStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: "16px", height: "16px" }) })
|
|
1637
|
-
] });
|
|
1638
|
-
}
|
|
1639
|
-
function FilterActions() {
|
|
1640
|
-
const {
|
|
1641
|
-
isSkeleton,
|
|
1642
|
-
filterIconUrl,
|
|
1643
|
-
clearIconUrl,
|
|
1644
|
-
canShowRemoveAction,
|
|
1645
|
-
onClickClearFilters,
|
|
1646
|
-
onClickFilter,
|
|
1647
|
-
filterButtonDictionaryTooltip,
|
|
1648
|
-
ownerState
|
|
1649
|
-
} = useFilterActions();
|
|
1650
|
-
if (isSkeleton) {
|
|
1651
|
-
return /* @__PURE__ */ jsx(ActionsStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(FilterActionsSkeleton, {}) });
|
|
1652
|
-
}
|
|
1653
|
-
return /* @__PURE__ */ jsxs(ActionsStyled, { ownerState: {}, children: [
|
|
1654
|
-
canShowRemoveAction && /* @__PURE__ */ jsx(
|
|
1655
|
-
ActionsClearButtonStyled,
|
|
1656
|
-
{
|
|
1657
|
-
src: clearIconUrl,
|
|
1658
|
-
onClick: onClickClearFilters,
|
|
1659
|
-
dictionaryTooltipId: "dynamic_filter.tooltip_clear_filters",
|
|
1660
|
-
ownerState: {}
|
|
1661
|
-
}
|
|
1662
|
-
),
|
|
1663
|
-
/* @__PURE__ */ jsx(
|
|
1664
|
-
ActionsSubmitButtonStyled,
|
|
1665
|
-
{
|
|
1666
|
-
src: filterIconUrl,
|
|
1667
|
-
"aria-label": "settings",
|
|
1668
|
-
dictionaryTooltipId: filterButtonDictionaryTooltip,
|
|
1669
|
-
onClick: onClickFilter,
|
|
1670
|
-
ownerState: { ...ownerState }
|
|
1671
|
-
}
|
|
1672
|
-
)
|
|
1673
|
-
] });
|
|
1674
|
-
}
|
|
1675
|
-
function DataTypeComponent(props) {
|
|
1676
|
-
const { formFilter, statusLoad } = props;
|
|
1677
|
-
const { setFocus } = useFormContext();
|
|
1678
|
-
const Component = fieldFactory(formFilter.field.type).getComponent();
|
|
1679
|
-
useEffect(() => {
|
|
1680
|
-
setTimeout(() => setFocus("formValueOperand1"), 100);
|
|
1681
|
-
}, [statusLoad]);
|
|
1682
|
-
return /* @__PURE__ */ jsx(Component, {});
|
|
1683
|
-
}
|
|
1684
|
-
function DynamicFilterBase() {
|
|
1685
|
-
const { ownerState, dataTestId } = useDynamicFilterBase();
|
|
1686
|
-
return /* @__PURE__ */ jsx(
|
|
1687
|
-
RootStyled,
|
|
1688
|
-
{
|
|
1689
|
-
ownerState: { ...ownerState },
|
|
1690
|
-
...getPropDataTestId(dataTestId, DynamicFilterSlots.root),
|
|
1691
|
-
children: /* @__PURE__ */ jsxs(
|
|
1692
|
-
InnerContainerStyled,
|
|
1693
|
-
{
|
|
1694
|
-
ownerState: { ...ownerState },
|
|
1695
|
-
...getPropDataTestId(dataTestId, DynamicFilterSlots.innerContainer),
|
|
1696
|
-
children: [
|
|
1697
|
-
/* @__PURE__ */ jsx(InputFilter$1, {}),
|
|
1698
|
-
/* @__PURE__ */ jsx(AppliedFilters, {}),
|
|
1699
|
-
/* @__PURE__ */ jsx(FilterActions, {}),
|
|
1700
|
-
/* @__PURE__ */ jsx(PopoverFilter, {})
|
|
1701
|
-
]
|
|
1702
|
-
}
|
|
1703
|
-
)
|
|
1704
|
-
}
|
|
1705
|
-
);
|
|
1706
|
-
}
|
|
1707
|
-
function DynamicFilter(props) {
|
|
1708
|
-
const hasPresentFlags = useFlagsPresent([CommonFlags.FLAG_DICTIONARY_LOADED]);
|
|
1709
|
-
if (!hasPresentFlags) {
|
|
1710
|
-
return null;
|
|
1711
|
-
}
|
|
1712
|
-
return /* @__PURE__ */ jsx(DynamicFilterProvider, { ...props, children: /* @__PURE__ */ jsx(DynamicFilterBase, {}) });
|
|
1713
|
-
}
|
|
1714
|
-
export {
|
|
1715
|
-
DynamicFilterSlots as D,
|
|
1716
|
-
DynamicFilter as a,
|
|
1717
|
-
DataTypeComponent as b,
|
|
1718
|
-
dynamicFilterStyles as d,
|
|
1719
|
-
fieldFactory as f,
|
|
1720
|
-
useDynamicFilterStore as u
|
|
1721
|
-
};
|