@gridsuite/commons-ui 0.134.0 → 0.136.0
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/README.md +10 -0
- package/dist/components/csvDownloader/csv-export.d.ts +1 -1
- package/dist/components/csvDownloader/csv-export.js +20 -2
- package/dist/components/csvDownloader/csv-export.type.d.ts +1 -0
- package/dist/components/csvDownloader/use-csv-export.js +1 -0
- package/dist/components/filter/expert/expertFilterUtils.js +1 -2
- package/dist/components/filter/index.d.ts +0 -1
- package/dist/components/filter/index.js +0 -5
- package/dist/components/filter/utils/filterFormUtils.d.ts +3 -12
- package/dist/components/filter/utils/filterFormUtils.js +15 -74
- package/dist/components/index.js +0 -5
- package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +67 -36
- package/dist/components/inputs/reactHookForm/text/TextInput.d.ts +2 -0
- package/dist/components/inputs/reactHookForm/text/TextInput.js +6 -3
- package/dist/components/parameters/common/widget/parameter-line-slider.js +5 -4
- package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +1 -0
- package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +21 -6
- package/dist/hooks/useSnackMessage.d.ts +2 -1
- package/dist/hooks/useSnackMessage.js +2 -1
- package/dist/index.js +0 -5
- package/dist/utils/constants/fieldConstants.d.ts +0 -1
- package/dist/utils/constants/fieldConstants.js +0 -1
- package/package.json +17 -15
- package/dist/components/contingencyList/criteriaBased/CriteriaBasedForm.d.ts +0 -8
- package/dist/components/contingencyList/criteriaBased/CriteriaBasedForm.js +0 -66
- package/dist/components/contingencyList/criteriaBased/criteriaBasedUtils.d.ts +0 -60
- package/dist/components/contingencyList/criteriaBased/criteriaBasedUtils.js +0 -36
- package/dist/components/contingencyList/criteriaBased/index.d.ts +0 -8
- package/dist/components/contingencyList/criteriaBased/index.js +0 -7
package/README.md
CHANGED
|
@@ -7,6 +7,16 @@ Library for sharing GridSuite apps commons components
|
|
|
7
7
|
The commons-ui library have a demo app in which you can call your components to test them.
|
|
8
8
|
The `npm start` command install the library's dependencies then launches the demo app.
|
|
9
9
|
|
|
10
|
+
##### Development Scripts
|
|
11
|
+
|
|
12
|
+
- **`npm run type-check`** - Runs TypeScript type checking without emitting files. This ensures all developers use the project's local TypeScript version from `node_modules` rather than a potentially different globally-installed version. Run this to verify your code has no type errors before committing.
|
|
13
|
+
|
|
14
|
+
- **`npm run build`** - Builds the library. Note: This automatically runs `npm run prebuild` first.
|
|
15
|
+
|
|
16
|
+
- **`npm run prebuild`** - Runs linting and type checking before the build. This script is executed automatically by npm before `npm run build` and ensures that the build is not executed if linting or type checking fails. You don't need to call this manually unless you want to verify code quality without building.
|
|
17
|
+
|
|
18
|
+
##### Local Testing
|
|
19
|
+
|
|
10
20
|
If you want to test your library integration with a consumer application my-app you have first
|
|
11
21
|
to build commons-ui via
|
|
12
22
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CsvExportProps } from './csv-export.type';
|
|
2
|
-
export declare function CsvExport({ columns, tableNamePrefix, tableName, disabled, skipColumnHeaders, language, exportDataAsCsv, }: CsvExportProps): JSX.Element;
|
|
2
|
+
export declare function CsvExport({ columns, tableNamePrefix, tableName, disabled, skipColumnHeaders, skipPinnedBottom, language, exportDataAsCsv, }: CsvExportProps): JSX.Element;
|
|
@@ -8,13 +8,31 @@ function CsvExport({
|
|
|
8
8
|
tableName,
|
|
9
9
|
disabled,
|
|
10
10
|
skipColumnHeaders = false,
|
|
11
|
+
skipPinnedBottom = false,
|
|
11
12
|
language,
|
|
12
13
|
exportDataAsCsv
|
|
13
14
|
}) {
|
|
14
15
|
const { downloadCSVData } = useCsvExport();
|
|
15
16
|
const download = useCallback(() => {
|
|
16
|
-
downloadCSVData({
|
|
17
|
-
|
|
17
|
+
downloadCSVData({
|
|
18
|
+
columns,
|
|
19
|
+
tableName,
|
|
20
|
+
tableNamePrefix,
|
|
21
|
+
skipColumnHeaders,
|
|
22
|
+
skipPinnedBottom,
|
|
23
|
+
language,
|
|
24
|
+
exportDataAsCsv
|
|
25
|
+
});
|
|
26
|
+
}, [
|
|
27
|
+
downloadCSVData,
|
|
28
|
+
columns,
|
|
29
|
+
tableName,
|
|
30
|
+
tableNamePrefix,
|
|
31
|
+
skipColumnHeaders,
|
|
32
|
+
skipPinnedBottom,
|
|
33
|
+
language,
|
|
34
|
+
exportDataAsCsv
|
|
35
|
+
]);
|
|
18
36
|
return /* @__PURE__ */ jsx(ExportCsvButton, { disabled, onClick: download });
|
|
19
37
|
}
|
|
20
38
|
export {
|
|
@@ -32,6 +32,7 @@ const useCsvExport = () => {
|
|
|
32
32
|
const prefix = props.tableNamePrefix ?? "";
|
|
33
33
|
props.exportDataAsCsv({
|
|
34
34
|
suppressQuotes: false,
|
|
35
|
+
skipPinnedBottom: props.skipPinnedBottom,
|
|
35
36
|
columnSeparator: props.language === LANG_FRENCH ? ";" : ",",
|
|
36
37
|
columnKeys: props.columns.map((col) => col.colId).filter(hasColId),
|
|
37
38
|
skipColumnHeaders: props.skipColumnHeaders,
|
|
@@ -188,8 +188,7 @@ function importExpertRules(query) {
|
|
|
188
188
|
}
|
|
189
189
|
return rule.values.sort();
|
|
190
190
|
}
|
|
191
|
-
convertInputValue(rule.field, parseFloat(rule.value));
|
|
192
|
-
return rule.value;
|
|
191
|
+
return convertInputValue(rule.field, parseFloat(rule.value));
|
|
193
192
|
}
|
|
194
193
|
function transformRule(rule) {
|
|
195
194
|
return {
|
|
@@ -8,7 +8,6 @@ export * from './filter.type';
|
|
|
8
8
|
export * from './FilterCreationDialog';
|
|
9
9
|
export * from './FilterForm';
|
|
10
10
|
export * from './constants/FilterConstants';
|
|
11
|
-
export * from '../contingencyList/criteriaBased';
|
|
12
11
|
export * from './expert';
|
|
13
12
|
export * from './explicitNaming';
|
|
14
13
|
export * from './utils';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { FilterCreationDialog } from "./FilterCreationDialog.js";
|
|
2
2
|
import { FilterForm } from "./FilterForm.js";
|
|
3
3
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./constants/FilterConstants.js";
|
|
4
|
-
import { CriteriaBasedForm } from "../contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
5
|
-
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "../contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
6
4
|
import { ExpertFilterEditionDialog } from "./expert/ExpertFilterEditionDialog.js";
|
|
7
5
|
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData } from "./expert/ExpertFilterForm.js";
|
|
8
6
|
import { CombinatorType, DataType, OperatorType } from "./expert/expertFilter.type.js";
|
|
@@ -18,7 +16,6 @@ export {
|
|
|
18
16
|
CONTINGENCY_LIST_EQUIPMENTS,
|
|
19
17
|
CONVERTERS_MODE_OPTIONS,
|
|
20
18
|
CombinatorType,
|
|
21
|
-
CriteriaBasedForm,
|
|
22
19
|
DISTRIBUTION_KEY,
|
|
23
20
|
DataType,
|
|
24
21
|
ENERGY_SOURCE_OPTIONS,
|
|
@@ -49,8 +46,6 @@ export {
|
|
|
49
46
|
expertFilterSchema,
|
|
50
47
|
explicitNamingFilterSchema,
|
|
51
48
|
exportExpertRules,
|
|
52
|
-
getCriteriaBasedFormData,
|
|
53
|
-
getCriteriaBasedSchema,
|
|
54
49
|
getExpertFilterEmptyFormData,
|
|
55
50
|
getExplicitNamingFilterEmptyFormData,
|
|
56
51
|
getFilterEquipmentTypeLabel,
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export type FormField = {
|
|
4
|
-
renderer: FunctionComponent<any>;
|
|
5
|
-
props: {
|
|
6
|
-
label: string;
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export type FormEquipment = {
|
|
1
|
+
import { EquipmentType } from '../../../utils';
|
|
2
|
+
export type ContingencyListEquipment = {
|
|
11
3
|
id: string;
|
|
12
4
|
label: string;
|
|
13
|
-
fields: FormField[];
|
|
14
5
|
};
|
|
15
|
-
export declare const CONTINGENCY_LIST_EQUIPMENTS: Record<EquipmentType.BUSBAR_SECTION | EquipmentType.LINE | EquipmentType.TWO_WINDINGS_TRANSFORMER | EquipmentType.THREE_WINDINGS_TRANSFORMER | EquipmentType.GENERATOR | EquipmentType.BATTERY | EquipmentType.LOAD | EquipmentType.SHUNT_COMPENSATOR | EquipmentType.STATIC_VAR_COMPENSATOR | EquipmentType.HVDC_LINE | EquipmentType.DANGLING_LINE,
|
|
6
|
+
export declare const CONTINGENCY_LIST_EQUIPMENTS: Record<EquipmentType.BUSBAR_SECTION | EquipmentType.LINE | EquipmentType.TWO_WINDINGS_TRANSFORMER | EquipmentType.THREE_WINDINGS_TRANSFORMER | EquipmentType.GENERATOR | EquipmentType.BATTERY | EquipmentType.LOAD | EquipmentType.SHUNT_COMPENSATOR | EquipmentType.STATIC_VAR_COMPENSATOR | EquipmentType.HVDC_LINE | EquipmentType.DANGLING_LINE, ContingencyListEquipment>;
|
|
16
7
|
export declare const FILTER_EQUIPMENTS: Partial<Record<EquipmentType, {
|
|
17
8
|
id: EquipmentType;
|
|
18
9
|
label: string;
|
|
@@ -1,111 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import "../../../utils/conversionUtils.js";
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
import "@mui/icons-material";
|
|
4
4
|
import { EquipmentType, BASE_EQUIPMENTS } from "../../../utils/types/equipmentType.js";
|
|
5
|
-
|
|
6
|
-
renderer: CountriesInput,
|
|
7
|
-
props: {
|
|
8
|
-
label: "Countries",
|
|
9
|
-
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.COUNTRIES}`
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const countries1 = {
|
|
13
|
-
renderer: CountriesInput,
|
|
14
|
-
props: {
|
|
15
|
-
label: "Countries1",
|
|
16
|
-
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.COUNTRIES_1}`
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const countries2 = {
|
|
20
|
-
renderer: CountriesInput,
|
|
21
|
-
props: {
|
|
22
|
-
label: "Countries2",
|
|
23
|
-
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.COUNTRIES_2}`
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const nominalVoltage = {
|
|
27
|
-
renderer: RangeInput,
|
|
28
|
-
props: {
|
|
29
|
-
label: "nominalVoltage",
|
|
30
|
-
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.NOMINAL_VOLTAGE}`
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const nominalVoltage1 = {
|
|
34
|
-
renderer: RangeInput,
|
|
35
|
-
props: {
|
|
36
|
-
label: "nominalVoltage1",
|
|
37
|
-
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.NOMINAL_VOLTAGE_1}`
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const nominalVoltage2 = {
|
|
41
|
-
renderer: RangeInput,
|
|
42
|
-
props: {
|
|
43
|
-
label: "nominalVoltage2",
|
|
44
|
-
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.NOMINAL_VOLTAGE_2}`
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const nominalVoltage3 = {
|
|
48
|
-
renderer: RangeInput,
|
|
49
|
-
props: {
|
|
50
|
-
label: "nominalVoltage3",
|
|
51
|
-
name: `${FieldConstants.CRITERIA_BASED}.${FieldConstants.NOMINAL_VOLTAGE_3}`
|
|
52
|
-
}
|
|
53
|
-
};
|
|
5
|
+
import "../../../utils/yupConfig.js";
|
|
54
6
|
const CONTINGENCY_LIST_EQUIPMENTS = {
|
|
55
7
|
BUSBAR_SECTION: {
|
|
56
8
|
id: "BUSBAR_SECTION",
|
|
57
|
-
label: "BusBarSections"
|
|
58
|
-
fields: [countries, nominalVoltage]
|
|
9
|
+
label: "BusBarSections"
|
|
59
10
|
},
|
|
60
11
|
LINE: {
|
|
61
12
|
id: "LINE",
|
|
62
|
-
label: "Lines"
|
|
63
|
-
fields: [countries1, countries2, nominalVoltage1, nominalVoltage2]
|
|
13
|
+
label: "Lines"
|
|
64
14
|
},
|
|
65
15
|
TWO_WINDINGS_TRANSFORMER: {
|
|
66
16
|
id: "TWO_WINDINGS_TRANSFORMER",
|
|
67
|
-
label: "TwoWindingsTransformers"
|
|
68
|
-
fields: [countries, nominalVoltage1, nominalVoltage2]
|
|
17
|
+
label: "TwoWindingsTransformers"
|
|
69
18
|
},
|
|
70
19
|
THREE_WINDINGS_TRANSFORMER: {
|
|
71
20
|
id: "THREE_WINDINGS_TRANSFORMER",
|
|
72
|
-
label: "ThreeWindingsTransformers"
|
|
73
|
-
fields: [countries, nominalVoltage1, nominalVoltage2, nominalVoltage3]
|
|
21
|
+
label: "ThreeWindingsTransformers"
|
|
74
22
|
},
|
|
75
23
|
GENERATOR: {
|
|
76
24
|
id: "GENERATOR",
|
|
77
|
-
label: "Generators"
|
|
78
|
-
fields: [countries, nominalVoltage]
|
|
25
|
+
label: "Generators"
|
|
79
26
|
},
|
|
80
27
|
BATTERY: {
|
|
81
28
|
id: "BATTERY",
|
|
82
|
-
label: "Batteries"
|
|
83
|
-
fields: [countries, nominalVoltage]
|
|
29
|
+
label: "Batteries"
|
|
84
30
|
},
|
|
85
31
|
LOAD: {
|
|
86
32
|
id: "LOAD",
|
|
87
|
-
label: "Loads"
|
|
88
|
-
fields: [countries, nominalVoltage]
|
|
33
|
+
label: "Loads"
|
|
89
34
|
},
|
|
90
35
|
SHUNT_COMPENSATOR: {
|
|
91
36
|
id: "SHUNT_COMPENSATOR",
|
|
92
|
-
label: "ShuntCompensators"
|
|
93
|
-
fields: [countries, nominalVoltage]
|
|
37
|
+
label: "ShuntCompensators"
|
|
94
38
|
},
|
|
95
39
|
STATIC_VAR_COMPENSATOR: {
|
|
96
40
|
id: "STATIC_VAR_COMPENSATOR",
|
|
97
|
-
label: "StaticVarCompensators"
|
|
98
|
-
fields: [countries, nominalVoltage]
|
|
41
|
+
label: "StaticVarCompensators"
|
|
99
42
|
},
|
|
100
43
|
HVDC_LINE: {
|
|
101
44
|
id: "HVDC_LINE",
|
|
102
|
-
label: "HvdcLines"
|
|
103
|
-
fields: [countries1, countries2, nominalVoltage]
|
|
45
|
+
label: "HvdcLines"
|
|
104
46
|
},
|
|
105
47
|
DANGLING_LINE: {
|
|
106
48
|
id: "DANGLING_LINE",
|
|
107
|
-
label: "DanglingLines"
|
|
108
|
-
fields: [countries, nominalVoltage]
|
|
49
|
+
label: "DanglingLines"
|
|
109
50
|
}
|
|
110
51
|
};
|
|
111
52
|
const FILTER_EQUIPMENTS = {
|
package/dist/components/index.js
CHANGED
|
@@ -39,8 +39,6 @@ import { TagRenderer } from "./elementSearch/tagRenderer/TagRenderer.js";
|
|
|
39
39
|
import { FilterCreationDialog } from "./filter/FilterCreationDialog.js";
|
|
40
40
|
import { FilterForm } from "./filter/FilterForm.js";
|
|
41
41
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./filter/constants/FilterConstants.js";
|
|
42
|
-
import { CriteriaBasedForm } from "./contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
43
|
-
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
44
42
|
import { ExpertFilterEditionDialog } from "./filter/expert/ExpertFilterEditionDialog.js";
|
|
45
43
|
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData } from "./filter/expert/ExpertFilterForm.js";
|
|
46
44
|
import { CombinatorType, DataType, OperatorType } from "./filter/expert/expertFilter.type.js";
|
|
@@ -211,7 +209,6 @@ export {
|
|
|
211
209
|
CountriesInput,
|
|
212
210
|
CountryValueEditor,
|
|
213
211
|
CreateParameterDialog,
|
|
214
|
-
CriteriaBasedForm,
|
|
215
212
|
CsvExport,
|
|
216
213
|
CsvUploader,
|
|
217
214
|
CustomAGGrid,
|
|
@@ -486,8 +483,6 @@ export {
|
|
|
486
483
|
formatComputingTypeLabel,
|
|
487
484
|
genHelperError,
|
|
488
485
|
generateTreeViewFinderClass,
|
|
489
|
-
getCriteriaBasedFormData,
|
|
490
|
-
getCriteriaBasedSchema,
|
|
491
486
|
getExpertFilterEmptyFormData,
|
|
492
487
|
getExplicitNamingFilterEmptyFormData,
|
|
493
488
|
getFilterEquipmentTypeLabel,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { FormControl, Box, Chip, FormHelperText, Grid, Tooltip, IconButton } from "@mui/material";
|
|
3
3
|
import { Folder } from "@mui/icons-material";
|
|
4
|
-
import { useState, useMemo, useCallback } from "react";
|
|
5
|
-
import { useFieldArray, useController } from "react-hook-form";
|
|
4
|
+
import { useState, useMemo, useCallback, useEffect } from "react";
|
|
5
|
+
import { useFieldArray, useWatch, useController } from "react-hook-form";
|
|
6
6
|
import { useIntl, FormattedMessage } from "react-intl";
|
|
7
7
|
import { RawReadOnlyInput } from "./RawReadOnlyInput.js";
|
|
8
8
|
import { FieldLabel } from "./utils/FieldLabel.js";
|
|
@@ -86,7 +86,8 @@ function DirectoryItemsInput({
|
|
|
86
86
|
name
|
|
87
87
|
});
|
|
88
88
|
const formContext = useCustomFormContext();
|
|
89
|
-
const { getValues, validationSchema } = formContext;
|
|
89
|
+
const { getValues, validationSchema, setError, clearErrors, getFieldState } = formContext;
|
|
90
|
+
const watchedElements = useWatch({ name });
|
|
90
91
|
const {
|
|
91
92
|
fieldState: { error }
|
|
92
93
|
} = useController({
|
|
@@ -148,6 +149,24 @@ function DirectoryItemsInput({
|
|
|
148
149
|
const shouldReplaceElement = useMemo(() => {
|
|
149
150
|
return allowMultiSelect === false && elements?.length === 1;
|
|
150
151
|
}, [allowMultiSelect, elements]);
|
|
152
|
+
const hasElementsWithoutName = useMemo(() => {
|
|
153
|
+
const elementsToCheck = watchedElements ?? elements;
|
|
154
|
+
return (elementsToCheck ?? []).some((item) => !item?.[NAME]);
|
|
155
|
+
}, [elements, watchedElements]);
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
const errorMessage = intl.formatMessage({ id: "elementNotFound" });
|
|
158
|
+
const fieldState = getFieldState(name);
|
|
159
|
+
if (hasElementsWithoutName) {
|
|
160
|
+
if (fieldState.error?.message !== errorMessage) {
|
|
161
|
+
setError(name, {
|
|
162
|
+
type: "manual",
|
|
163
|
+
message: errorMessage
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
} else if (fieldState.error?.type === "manual" && fieldState.error?.message === errorMessage) {
|
|
167
|
+
clearErrors(name);
|
|
168
|
+
}
|
|
169
|
+
}, [clearErrors, getFieldState, hasElementsWithoutName, intl, name, setError]);
|
|
151
170
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
152
171
|
/* @__PURE__ */ jsxs(
|
|
153
172
|
FormControl,
|
|
@@ -166,39 +185,51 @@ function DirectoryItemsInput({
|
|
|
166
185
|
optional: labelRequiredFromContext && !isFieldRequired(name, validationSchema, getValues())
|
|
167
186
|
}
|
|
168
187
|
),
|
|
169
|
-
elements?.length > 0 && /* @__PURE__ */ jsx(FormControl, { sx: styles.formDirectoryElements2, children: elements.map((item, index) =>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
188
|
+
elements?.length > 0 && /* @__PURE__ */ jsx(FormControl, { sx: styles.formDirectoryElements2, children: elements.map((item, index) => {
|
|
189
|
+
const elementName = watchedElements?.[index]?.[NAME] ?? getValues(`${name}.${index}.${NAME}`) ?? item?.[NAME];
|
|
190
|
+
return /* @__PURE__ */ jsxs(
|
|
191
|
+
Box,
|
|
192
|
+
{
|
|
193
|
+
sx: { display: "flex", alignItems: "center", flexDirection: "column", gap: 1 },
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsx(
|
|
196
|
+
Chip,
|
|
197
|
+
{
|
|
198
|
+
size: "small",
|
|
199
|
+
sx: mergeSx(
|
|
200
|
+
{
|
|
201
|
+
backgroundColor: item?.specificMetadata?.equipmentType && equipmentColorsMap?.get(item?.specificMetadata?.equipmentType)
|
|
202
|
+
},
|
|
203
|
+
!elementName ? (theme) => ({
|
|
204
|
+
backgroundColor: theme.palette.error.light,
|
|
205
|
+
borderColor: theme.palette.error.main,
|
|
206
|
+
color: theme.palette.error.contrastText
|
|
207
|
+
}) : void 0
|
|
208
|
+
),
|
|
209
|
+
onDelete: () => removeElements(index),
|
|
210
|
+
onClick: () => handleChipClick(index),
|
|
211
|
+
label: /* @__PURE__ */ jsx(
|
|
212
|
+
OverflowableText,
|
|
213
|
+
{
|
|
214
|
+
text: elementName ? /* @__PURE__ */ jsx(RawReadOnlyInput, { name: `${name}.${index}.${NAME}` }) : intl.formatMessage({ id: "elementNotFound" }),
|
|
215
|
+
sx: { width: "100%" }
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
equipmentColorsMap && /* @__PURE__ */ jsx(FormHelperText, { children: item?.specificMetadata?.equipmentType ? /* @__PURE__ */ jsx(
|
|
221
|
+
FormattedMessage,
|
|
222
|
+
{
|
|
223
|
+
id: getFilterEquipmentTypeLabel(
|
|
224
|
+
item.specificMetadata.equipmentType
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
) : "" })
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
item.id
|
|
231
|
+
);
|
|
232
|
+
}) }),
|
|
202
233
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(Grid, { container: true, direction: "row-reverse", children: /* @__PURE__ */ jsx(Tooltip, { title: intl.formatMessage({ id: titleId }), children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
203
234
|
IconButton,
|
|
204
235
|
{
|
|
@@ -15,6 +15,7 @@ export interface TextInputProps {
|
|
|
15
15
|
outputTransform?: (value: string) => Input | null;
|
|
16
16
|
inputTransform?: (value: Input) => string;
|
|
17
17
|
acceptValue?: (value: string) => boolean;
|
|
18
|
+
onChange?: (value: string) => void;
|
|
18
19
|
previousValue?: Input;
|
|
19
20
|
clearable?: boolean;
|
|
20
21
|
formProps?: Omit<TextFieldWithAdornmentProps | TextFieldProps, 'value' | 'onChange' | 'inputRef' | 'inputProps' | 'InputProps'>;
|
|
@@ -25,5 +26,6 @@ export declare function TextInput({ name, label, labelValues, // this prop is us
|
|
|
25
26
|
id, adornment, customAdornment, outputTransform, // transform materialUi input value before sending it to react hook form, mostly used to deal with number fields
|
|
26
27
|
inputTransform, // transform react hook form value before sending it to materialUi input, mostly used to deal with number fields
|
|
27
28
|
acceptValue, // used to check user entry before committing the input change, used mostly to prevent user from typing a character in number field
|
|
29
|
+
onChange, // method called when input value changed, if you want to manually trigger validation for example (do not update the form here unless you know what you do, it's already done by RHF)
|
|
28
30
|
previousValue, clearable, formProps, disabledTooltip, // In case we don't want to show tooltip on the value and warning/info icons
|
|
29
31
|
disabled, }: TextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,6 +21,8 @@ function TextInput({
|
|
|
21
21
|
// transform react hook form value before sending it to materialUi input, mostly used to deal with number fields
|
|
22
22
|
acceptValue = () => true,
|
|
23
23
|
// used to check user entry before committing the input change, used mostly to prevent user from typing a character in number field
|
|
24
|
+
onChange,
|
|
25
|
+
// method called when input value changed, if you want to manually trigger validation for example (do not update the form here unless you know what you do, it's already done by RHF)
|
|
24
26
|
previousValue,
|
|
25
27
|
clearable,
|
|
26
28
|
formProps,
|
|
@@ -30,7 +32,7 @@ function TextInput({
|
|
|
30
32
|
}) {
|
|
31
33
|
const { validationSchema, getValues, removeOptional, isNodeBuilt, isUpdate } = useCustomFormContext();
|
|
32
34
|
const {
|
|
33
|
-
field: { onChange, value, ref },
|
|
35
|
+
field: { onChange: onChangeRhf, value, ref },
|
|
34
36
|
fieldState: { error }
|
|
35
37
|
} = useController({ name });
|
|
36
38
|
const Field = adornment ? TextFieldWithAdornment : TextField;
|
|
@@ -39,11 +41,12 @@ function TextInput({
|
|
|
39
41
|
adornmentText: adornment?.text ?? ""
|
|
40
42
|
};
|
|
41
43
|
const handleClearValue = () => {
|
|
42
|
-
|
|
44
|
+
onChangeRhf(outputTransform(""));
|
|
43
45
|
};
|
|
44
46
|
const handleValueChanged = (e) => {
|
|
45
47
|
if (acceptValue(e.target.value)) {
|
|
46
|
-
|
|
48
|
+
onChangeRhf(outputTransform(e.target.value));
|
|
49
|
+
onChange?.(e.target.value);
|
|
47
50
|
}
|
|
48
51
|
};
|
|
49
52
|
const transformedValue = inputTransform(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Grid } from "@mui/material";
|
|
3
3
|
import { FormattedMessage } from "react-intl";
|
|
4
4
|
import { parametersStyles } from "../../parameters-style.js";
|
|
@@ -35,7 +35,8 @@ function sanitizePercentageValue(value) {
|
|
|
35
35
|
const styles = {
|
|
36
36
|
container: {
|
|
37
37
|
...parametersStyles.controlItem,
|
|
38
|
-
|
|
38
|
+
paddingTop: 3,
|
|
39
|
+
paddingRight: 3
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
function ParameterLineSlider({
|
|
@@ -46,9 +47,9 @@ function ParameterLineSlider({
|
|
|
46
47
|
minValue = 0,
|
|
47
48
|
maxValue = 100
|
|
48
49
|
}) {
|
|
49
|
-
return /* @__PURE__ */ jsxs(
|
|
50
|
+
return /* @__PURE__ */ jsxs(Grid, { container: true, sx: styles.container, children: [
|
|
50
51
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: 8, sx: parametersStyles.parameterName, children: /* @__PURE__ */ jsx(FormattedMessage, { id: label }) }),
|
|
51
|
-
/* @__PURE__ */ jsx(Grid, { item: true,
|
|
52
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 4, children: /* @__PURE__ */ jsx(
|
|
52
53
|
SliderInput,
|
|
53
54
|
{
|
|
54
55
|
name,
|
|
@@ -124,6 +124,7 @@ const setLimitReductions = (provider, defaultLimitReductions, formMethods) => {
|
|
|
124
124
|
} else {
|
|
125
125
|
formMethods.setValue(PARAM_LIMIT_REDUCTION, DEFAULT_LIMIT_REDUCTION_VALUE);
|
|
126
126
|
formMethods.setValue(LIMIT_REDUCTIONS_FORM, []);
|
|
127
|
+
formMethods.clearErrors(LIMIT_REDUCTIONS_FORM);
|
|
127
128
|
}
|
|
128
129
|
};
|
|
129
130
|
const mapLimitReductions = (vlLimits, formLimits, indexVl) => {
|
|
@@ -58,6 +58,7 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
|
|
|
58
58
|
] = parametersBackend;
|
|
59
59
|
const [currentProvider, setCurrentProvider] = useState(params?.provider);
|
|
60
60
|
const [selectedTab, setSelectedTab] = useState(TabValues.GENERAL);
|
|
61
|
+
const [limitReductionNumber, setLimitReductionNumber] = useState(0);
|
|
61
62
|
const [tabIndexesWithError, setTabIndexesWithError] = useState([]);
|
|
62
63
|
const { snackError } = useSnackMessage();
|
|
63
64
|
const handleTabChange = useCallback((event, newValue) => {
|
|
@@ -83,12 +84,10 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
|
|
|
83
84
|
[PROVIDER]: yup.string().required(),
|
|
84
85
|
[PARAM_LIMIT_REDUCTION]: yup.number().nullable(),
|
|
85
86
|
...getCommonLoadFlowParametersFormSchema().fields,
|
|
86
|
-
...getLimitReductionsFormSchema(
|
|
87
|
-
params?.limitReductions ? params.limitReductions[0]?.temporaryLimitReductions.length : 0
|
|
88
|
-
).fields,
|
|
87
|
+
...getLimitReductionsFormSchema(limitReductionNumber).fields,
|
|
89
88
|
...getSpecificLoadFlowParametersFormSchema(specificParameters).fields
|
|
90
89
|
}).concat(getNameElementEditorSchema(name));
|
|
91
|
-
}, [name,
|
|
90
|
+
}, [name, limitReductionNumber, specificParameters]);
|
|
92
91
|
const formMethods = useForm({
|
|
93
92
|
defaultValues: {
|
|
94
93
|
...getNameElementEditorEmptyFormData(name, description),
|
|
@@ -240,12 +239,28 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
|
|
|
240
239
|
reset(toLoadFlowFormValues(params));
|
|
241
240
|
}, [paramsLoaded, params, reset, specificParamsDescriptions, toLoadFlowFormValues]);
|
|
242
241
|
useEffect(() => {
|
|
243
|
-
if (watchProvider !== currentProvider) {
|
|
242
|
+
if (watchProvider && watchProvider !== currentProvider) {
|
|
244
243
|
setCurrentProvider(watchProvider);
|
|
245
244
|
setSpecificParameters(watchProvider, specificParamsDescriptions, formMethods);
|
|
246
245
|
setLimitReductions(watchProvider, defaultLimitReductions, formMethods);
|
|
246
|
+
if (watchProvider === PARAM_PROVIDER_OPENLOADFLOW) {
|
|
247
|
+
if (currentProvider) {
|
|
248
|
+
setLimitReductionNumber(defaultLimitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
|
|
249
|
+
} else {
|
|
250
|
+
setLimitReductionNumber(params?.limitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
setLimitReductionNumber(0);
|
|
254
|
+
}
|
|
247
255
|
}
|
|
248
|
-
}, [
|
|
256
|
+
}, [
|
|
257
|
+
currentProvider,
|
|
258
|
+
defaultLimitReductions,
|
|
259
|
+
formMethods,
|
|
260
|
+
params?.limitReductions,
|
|
261
|
+
specificParamsDescriptions,
|
|
262
|
+
watchProvider
|
|
263
|
+
]);
|
|
249
264
|
return {
|
|
250
265
|
formMethods,
|
|
251
266
|
formSchema,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { closeSnackbar as closeSnackbarFromNotistack, OptionsObject } from 'notistack';
|
|
2
2
|
interface SnackInputs extends Omit<OptionsObject, 'variant' | 'style'> {
|
|
3
3
|
messageTxt?: string;
|
|
4
4
|
messageId?: string;
|
|
@@ -11,6 +11,7 @@ export interface UseSnackMessageReturn {
|
|
|
11
11
|
snackError: (snackInputs: SnackInputs) => void;
|
|
12
12
|
snackWarning: (snackInputs: SnackInputs) => void;
|
|
13
13
|
snackInfo: (snackInputs: SnackInputs) => void;
|
|
14
|
+
snackSuccess: (snackInputs: SnackInputs) => void;
|
|
14
15
|
closeSnackbar: typeof closeSnackbarFromNotistack;
|
|
15
16
|
}
|
|
16
17
|
export declare function useSnackMessage(): UseSnackMessageReturn;
|
|
@@ -63,7 +63,8 @@ function useSnackMessage() {
|
|
|
63
63
|
);
|
|
64
64
|
const snackWarning = useCallback((snackInputs) => enqueue(snackInputs, "warning"), [enqueue]);
|
|
65
65
|
const snackInfo = useCallback((snackInputs) => enqueue(snackInputs, "info"), [enqueue]);
|
|
66
|
-
|
|
66
|
+
const snackSuccess = useCallback((snackInputs) => enqueue(snackInputs, "success"), [enqueue]);
|
|
67
|
+
return { snackError, snackInfo, snackWarning, snackSuccess, closeSnackbar };
|
|
67
68
|
}
|
|
68
69
|
export {
|
|
69
70
|
useSnackMessage
|
package/dist/index.js
CHANGED
|
@@ -40,8 +40,6 @@ import { TagRenderer } from "./components/elementSearch/tagRenderer/TagRenderer.
|
|
|
40
40
|
import { FilterCreationDialog } from "./components/filter/FilterCreationDialog.js";
|
|
41
41
|
import { FilterForm } from "./components/filter/FilterForm.js";
|
|
42
42
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./components/filter/constants/FilterConstants.js";
|
|
43
|
-
import { CriteriaBasedForm } from "./components/contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
44
|
-
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./components/contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
45
43
|
import { ExpertFilterEditionDialog } from "./components/filter/expert/ExpertFilterEditionDialog.js";
|
|
46
44
|
import { ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData } from "./components/filter/expert/ExpertFilterForm.js";
|
|
47
45
|
import { CombinatorType, DataType, OperatorType } from "./components/filter/expert/expertFilter.type.js";
|
|
@@ -327,7 +325,6 @@ export {
|
|
|
327
325
|
CountriesInput,
|
|
328
326
|
CountryValueEditor,
|
|
329
327
|
CreateParameterDialog,
|
|
330
|
-
CriteriaBasedForm,
|
|
331
328
|
CsvExport,
|
|
332
329
|
CsvUploader,
|
|
333
330
|
CustomAGGrid,
|
|
@@ -737,8 +734,6 @@ export {
|
|
|
737
734
|
getAppName,
|
|
738
735
|
getAvailableComponentLibraries,
|
|
739
736
|
getComputedLanguage,
|
|
740
|
-
getCriteriaBasedFormData,
|
|
741
|
-
getCriteriaBasedSchema,
|
|
742
737
|
getDefaultLoadFlowProvider,
|
|
743
738
|
getEquipmentsInfosForSearchBar,
|
|
744
739
|
getExpertFilterEmptyFormData,
|
|
@@ -16,7 +16,6 @@ export declare enum FieldConstants {
|
|
|
16
16
|
COUNTRIES_1 = "countries1",
|
|
17
17
|
COUNTRIES_2 = "countries2",
|
|
18
18
|
COUNTRIES = "countries",
|
|
19
|
-
CRITERIA_BASED = "criteriaBased",
|
|
20
19
|
CURRENT_PARAMETERS = "currentParameters",
|
|
21
20
|
DESCRIPTION = "description",
|
|
22
21
|
DIRECTORY = "directory",
|
|
@@ -10,7 +10,6 @@ var FieldConstants = /* @__PURE__ */ ((FieldConstants2) => {
|
|
|
10
10
|
FieldConstants2["COUNTRIES_1"] = "countries1";
|
|
11
11
|
FieldConstants2["COUNTRIES_2"] = "countries2";
|
|
12
12
|
FieldConstants2["COUNTRIES"] = "countries";
|
|
13
|
-
FieldConstants2["CRITERIA_BASED"] = "criteriaBased";
|
|
14
13
|
FieldConstants2["CURRENT_PARAMETERS"] = "currentParameters";
|
|
15
14
|
FieldConstants2["DESCRIPTION"] = "description";
|
|
16
15
|
FieldConstants2["DIRECTORY"] = "directory";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridsuite/commons-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.136.0",
|
|
4
4
|
"description": "common react components for gridsuite applications",
|
|
5
5
|
"author": "gridsuite team",
|
|
6
6
|
"homepage": "https://github.com/gridsuite",
|
|
@@ -23,13 +23,16 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"start": "vite demo/ --config vite.config.ts",
|
|
25
25
|
"start:open": "vite demo/ --config vite.config.ts --open",
|
|
26
|
-
"build": "
|
|
26
|
+
"build": "vite build",
|
|
27
27
|
"build:pack": "tsc && vite build && npm pack",
|
|
28
28
|
"prepublishOnly": "npm run build",
|
|
29
29
|
"test": "jest",
|
|
30
30
|
"test:coverage": "jest --coverage",
|
|
31
31
|
"test:watch": "jest --watch",
|
|
32
|
-
"
|
|
32
|
+
"type-check": "tsc",
|
|
33
|
+
"prebuild": "npm run lint && npm run type-check",
|
|
34
|
+
"lint": "eslint . --max-warnings 0",
|
|
35
|
+
"lint:fix": "eslint . --fix",
|
|
33
36
|
"lint:format": "prettier --check --cache .",
|
|
34
37
|
"licenses-check": "license-checker --summary --excludePrivatePackages --production --onlyAllow \"$( jq -r .onlyAllow[] license-checker-config.json | tr '\n' ';')\" --excludePackages \"$( jq -r .excludePackages[] license-checker-config.json | tr '\n' ';')\""
|
|
35
38
|
},
|
|
@@ -80,17 +83,19 @@
|
|
|
80
83
|
"@babel/preset-typescript": "^7.27.1",
|
|
81
84
|
"@emotion/react": "^11.14.0",
|
|
82
85
|
"@emotion/styled": "^11.14.1",
|
|
86
|
+
"@eslint/compat": "^1.4.1",
|
|
87
|
+
"@eslint/js": "^9.38.0",
|
|
83
88
|
"@hookform/resolvers": "^4.1.3",
|
|
84
89
|
"@jest/globals": "^30.1.2",
|
|
85
90
|
"@mui/icons-material": "^5.18.0",
|
|
86
91
|
"@mui/lab": "5.0.0-alpha.175",
|
|
87
92
|
"@mui/material": "^5.18.0",
|
|
88
93
|
"@react-hook/window-size": "^3.1.1",
|
|
94
|
+
"@stylistic/eslint-plugin": "^3.1.0",
|
|
89
95
|
"@testing-library/jest-dom": "^6.8.0",
|
|
90
96
|
"@testing-library/react": "^16.3.0",
|
|
91
97
|
"@testing-library/user-event": "^14.6.1",
|
|
92
98
|
"@types/autosuggest-highlight": "^3.2.3",
|
|
93
|
-
"@types/eslint": "^8.56.12",
|
|
94
99
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
95
100
|
"@types/jest": "^30.0.0",
|
|
96
101
|
"@types/json-logic-js": "^2.0.8",
|
|
@@ -101,25 +106,21 @@
|
|
|
101
106
|
"@types/react": "^18.3.24",
|
|
102
107
|
"@types/react-dom": "^18.3.7",
|
|
103
108
|
"@types/react-resizable": "^3.0.8",
|
|
104
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
105
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
106
109
|
"@vitejs/plugin-react": "^5.0.4",
|
|
107
110
|
"ag-grid-community": "^33.1.0",
|
|
108
111
|
"ag-grid-react": "^33.3.2",
|
|
109
112
|
"babel-eslint": "^10.1.0",
|
|
110
113
|
"babel-preset-airbnb": "^5.0.0",
|
|
111
114
|
"babel-preset-vite": "^1.1.3",
|
|
112
|
-
"eslint": "^
|
|
113
|
-
"eslint-config-airbnb": "^
|
|
114
|
-
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
115
|
+
"eslint": "^9.38.0",
|
|
116
|
+
"eslint-config-airbnb-extended": "^2.3.2",
|
|
115
117
|
"eslint-config-prettier": "^10.1.8",
|
|
116
|
-
"eslint-
|
|
117
|
-
"eslint-plugin-
|
|
118
|
-
"eslint-plugin-import": "^2.32.0",
|
|
118
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
119
|
+
"eslint-plugin-import-x": "^4.16.1",
|
|
119
120
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
120
121
|
"eslint-plugin-prettier": "^5.5.4",
|
|
121
122
|
"eslint-plugin-react": "^7.37.5",
|
|
122
|
-
"eslint-plugin-react-hooks": "^
|
|
123
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
123
124
|
"glob": "^11.0.3",
|
|
124
125
|
"identity-obj-proxy": "^3.0.0",
|
|
125
126
|
"jest": "^30.1.3",
|
|
@@ -136,10 +137,11 @@
|
|
|
136
137
|
"react-resizable": "^3.0.5",
|
|
137
138
|
"react-router": "^7.8.2",
|
|
138
139
|
"ts-node": "^10.9.2",
|
|
139
|
-
"typescript": "~5.
|
|
140
|
+
"typescript": "~5.9.3",
|
|
141
|
+
"typescript-eslint": "^8.46.2",
|
|
140
142
|
"vite": "^7.1.12",
|
|
143
|
+
"vite-plugin-checker": "^0.8.0",
|
|
141
144
|
"vite-plugin-dts": "^4.5.4",
|
|
142
|
-
"vite-plugin-eslint": "^1.8.1",
|
|
143
145
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
144
146
|
"vite-plugin-svgr": "^4.5.0",
|
|
145
147
|
"yup": "^1.7.0"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { FormEquipment } from '../../filter/utils/filterFormUtils';
|
|
3
|
-
export interface CriteriaBasedFormProps {
|
|
4
|
-
equipments: Record<string, FormEquipment>;
|
|
5
|
-
defaultValues: Record<string, any>;
|
|
6
|
-
children?: ReactElement;
|
|
7
|
-
}
|
|
8
|
-
export declare function CriteriaBasedForm({ equipments, defaultValues, children }: Readonly<CriteriaBasedFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
3
|
-
import { Box, Grid } from "@mui/material";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
6
|
-
import { SelectInput } from "../../inputs/reactHookForm/selectInputs/SelectInput.js";
|
|
7
|
-
import { InputWithPopupConfirmation } from "../../inputs/reactHookForm/selectInputs/InputWithPopupConfirmation.js";
|
|
8
|
-
import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
|
|
9
|
-
import { unscrollableDialogStyles } from "../../dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
10
|
-
import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
11
|
-
import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
12
|
-
import "react-intl";
|
|
13
|
-
import "@mui/icons-material";
|
|
14
|
-
import "../../treeViewFinder/TreeViewFinder.js";
|
|
15
|
-
import "../../../utils/conversionUtils.js";
|
|
16
|
-
import "../../../utils/types/equipmentType.js";
|
|
17
|
-
import "../../../utils/yupConfig.js";
|
|
18
|
-
function CriteriaBasedForm({ equipments, defaultValues, children }) {
|
|
19
|
-
const { getValues, setValue } = useFormContext();
|
|
20
|
-
const { snackError } = useSnackMessage();
|
|
21
|
-
const watchEquipmentType = useWatch({
|
|
22
|
-
name: FieldConstants.EQUIPMENT_TYPE
|
|
23
|
-
});
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (watchEquipmentType && !equipments[watchEquipmentType]) {
|
|
26
|
-
snackError({
|
|
27
|
-
headerId: "obsoleteFilter"
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}, [snackError, equipments, watchEquipmentType]);
|
|
31
|
-
const openConfirmationPopup = () => {
|
|
32
|
-
return JSON.stringify(getValues(FieldConstants.CRITERIA_BASED)) !== JSON.stringify(defaultValues);
|
|
33
|
-
};
|
|
34
|
-
const handleResetOnConfirmation = () => {
|
|
35
|
-
Object.keys(defaultValues).forEach(
|
|
36
|
-
(field) => setValue(`${FieldConstants.CRITERIA_BASED}.${field}`, defaultValues[field])
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
40
|
-
/* @__PURE__ */ jsx(Box, { sx: unscrollableDialogStyles.unscrollableHeader, children: /* @__PURE__ */ jsx(
|
|
41
|
-
InputWithPopupConfirmation,
|
|
42
|
-
{
|
|
43
|
-
Input: SelectInput,
|
|
44
|
-
name: FieldConstants.EQUIPMENT_TYPE,
|
|
45
|
-
options: Object.values(equipments),
|
|
46
|
-
label: "equipmentType",
|
|
47
|
-
shouldOpenPopup: openConfirmationPopup,
|
|
48
|
-
resetOnConfirmation: handleResetOnConfirmation,
|
|
49
|
-
message: "changeTypeMessage",
|
|
50
|
-
validateButtonLabel: "button.changeType",
|
|
51
|
-
"data-testid": "EquipmentTypeSelector"
|
|
52
|
-
}
|
|
53
|
-
) }),
|
|
54
|
-
/* @__PURE__ */ jsx(Box, { sx: unscrollableDialogStyles.scrollableContent, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
|
|
55
|
-
watchEquipmentType && equipments[watchEquipmentType] && equipments[watchEquipmentType].fields.map((equipment, index) => {
|
|
56
|
-
const EquipmentForm = equipment.renderer;
|
|
57
|
-
const uniqueKey = `${watchEquipmentType}-${index}`;
|
|
58
|
-
return /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, flexGrow: 1, children: /* @__PURE__ */ jsx(EquipmentForm, { ...equipment.props }) }, uniqueKey);
|
|
59
|
-
}),
|
|
60
|
-
children
|
|
61
|
-
] }) })
|
|
62
|
-
] });
|
|
63
|
-
}
|
|
64
|
-
export {
|
|
65
|
-
CriteriaBasedForm
|
|
66
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ObjectSchema } from 'yup';
|
|
2
|
-
import { FieldConstants } from '../../../utils/constants/fieldConstants';
|
|
3
|
-
import { default as yup } from '../../../utils/yupConfig';
|
|
4
|
-
import { RangeInputData } from '../../inputs/reactHookForm/numbers/RangeInput';
|
|
5
|
-
export type CriteriaBasedData = {
|
|
6
|
-
[FieldConstants.COUNTRIES]?: string[];
|
|
7
|
-
[FieldConstants.COUNTRIES_1]?: string[];
|
|
8
|
-
[FieldConstants.COUNTRIES_2]?: string[];
|
|
9
|
-
[FieldConstants.NOMINAL_VOLTAGE]?: RangeInputData | null;
|
|
10
|
-
[FieldConstants.NOMINAL_VOLTAGE_1]?: RangeInputData | null;
|
|
11
|
-
[FieldConstants.NOMINAL_VOLTAGE_2]?: RangeInputData | null;
|
|
12
|
-
[FieldConstants.NOMINAL_VOLTAGE_3]?: RangeInputData | null;
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
};
|
|
15
|
-
export declare function getCriteriaBasedSchema(extraFields?: Record<string, yup.AnyObject | null>): {
|
|
16
|
-
readonly criteriaBased: ObjectSchema<{
|
|
17
|
-
nominalVoltage3: {
|
|
18
|
-
type: string;
|
|
19
|
-
value1: number | null;
|
|
20
|
-
value2: number | null;
|
|
21
|
-
};
|
|
22
|
-
nominalVoltage2: {
|
|
23
|
-
type: string;
|
|
24
|
-
value1: number | null;
|
|
25
|
-
value2: number | null;
|
|
26
|
-
};
|
|
27
|
-
nominalVoltage1: {
|
|
28
|
-
type: string;
|
|
29
|
-
value1: number | null;
|
|
30
|
-
value2: number | null;
|
|
31
|
-
};
|
|
32
|
-
nominalVoltage: {
|
|
33
|
-
type: string;
|
|
34
|
-
value1: number | null;
|
|
35
|
-
value2: number | null;
|
|
36
|
-
};
|
|
37
|
-
countries: string[] | undefined;
|
|
38
|
-
countries1: string[] | undefined;
|
|
39
|
-
countries2: string[] | undefined;
|
|
40
|
-
}, yup.AnyObject, {
|
|
41
|
-
nominalVoltage3: any;
|
|
42
|
-
nominalVoltage2: any;
|
|
43
|
-
nominalVoltage1: any;
|
|
44
|
-
nominalVoltage: any;
|
|
45
|
-
countries: "";
|
|
46
|
-
countries1: "";
|
|
47
|
-
countries2: "";
|
|
48
|
-
}, "">;
|
|
49
|
-
};
|
|
50
|
-
export declare function getCriteriaBasedFormData(criteriaValues?: Record<string, any>, extraFields?: Record<string, yup.AnyObject | null>): {
|
|
51
|
-
readonly criteriaBased: {
|
|
52
|
-
readonly countries: any;
|
|
53
|
-
readonly countries1: any;
|
|
54
|
-
readonly countries2: any;
|
|
55
|
-
readonly nominalVoltage: any;
|
|
56
|
-
readonly nominalVoltage1: any;
|
|
57
|
-
readonly nominalVoltage2: any;
|
|
58
|
-
readonly nominalVoltage3: any;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
2
|
-
import "../../../utils/yupConfig.js";
|
|
3
|
-
import { getRangeInputSchema, DEFAULT_RANGE_VALUE } from "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
4
|
-
import * as yup from "yup";
|
|
5
|
-
function getCriteriaBasedSchema(extraFields = {}) {
|
|
6
|
-
return {
|
|
7
|
-
[FieldConstants.CRITERIA_BASED]: yup.object().shape({
|
|
8
|
-
[FieldConstants.COUNTRIES]: yup.array().of(yup.string().required()),
|
|
9
|
-
[FieldConstants.COUNTRIES_1]: yup.array().of(yup.string().required()),
|
|
10
|
-
[FieldConstants.COUNTRIES_2]: yup.array().of(yup.string().required()),
|
|
11
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE),
|
|
12
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_1),
|
|
13
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_2),
|
|
14
|
-
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_3),
|
|
15
|
-
...extraFields
|
|
16
|
-
})
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function getCriteriaBasedFormData(criteriaValues, extraFields = {}) {
|
|
20
|
-
return {
|
|
21
|
-
[FieldConstants.CRITERIA_BASED]: {
|
|
22
|
-
[FieldConstants.COUNTRIES]: criteriaValues?.[FieldConstants.COUNTRIES] ?? [],
|
|
23
|
-
[FieldConstants.COUNTRIES_1]: criteriaValues?.[FieldConstants.COUNTRIES_1] ?? [],
|
|
24
|
-
[FieldConstants.COUNTRIES_2]: criteriaValues?.[FieldConstants.COUNTRIES_2] ?? [],
|
|
25
|
-
[FieldConstants.NOMINAL_VOLTAGE]: criteriaValues?.[FieldConstants.NOMINAL_VOLTAGE] ?? DEFAULT_RANGE_VALUE,
|
|
26
|
-
[FieldConstants.NOMINAL_VOLTAGE_1]: criteriaValues?.[FieldConstants.NOMINAL_VOLTAGE_1] ?? DEFAULT_RANGE_VALUE,
|
|
27
|
-
[FieldConstants.NOMINAL_VOLTAGE_2]: criteriaValues?.[FieldConstants.NOMINAL_VOLTAGE_2] ?? DEFAULT_RANGE_VALUE,
|
|
28
|
-
[FieldConstants.NOMINAL_VOLTAGE_3]: criteriaValues?.[FieldConstants.NOMINAL_VOLTAGE_3] ?? DEFAULT_RANGE_VALUE,
|
|
29
|
-
...extraFields
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
getCriteriaBasedFormData,
|
|
35
|
-
getCriteriaBasedSchema
|
|
36
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024, RTE (http://www.rte-france.com)
|
|
3
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
-
*/
|
|
7
|
-
export * from './CriteriaBasedForm';
|
|
8
|
-
export * from './criteriaBasedUtils';
|