@gridsuite/commons-ui 0.72.1 → 0.72.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/dialogs/customMuiDialog/CustomMuiDialog.d.ts +6 -7
- package/dist/components/dialogs/customMuiDialog/CustomMuiDialog.js +6 -3
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.d.ts +36 -8
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.js +1 -1
- package/dist/components/filter/criteriaBased/criteriaBasedFilterUtils.d.ts +63 -18
- package/dist/components/filter/criteriaBased/criteriaBasedFilterUtils.js +40 -50
- package/dist/components/index.js +1 -2
- package/dist/components/inputs/index.js +1 -2
- package/dist/components/inputs/reactHookForm/index.js +1 -2
- package/dist/components/inputs/reactHookForm/numbers/RangeInput.d.ts +26 -36
- package/dist/components/inputs/reactHookForm/numbers/RangeInput.js +38 -57
- package/dist/components/inputs/reactHookForm/numbers/index.js +1 -2
- package/dist/components/inputs/reactHookForm/provider/CustomFormProvider.d.ts +7 -8
- package/dist/components/inputs/reactHookForm/utils/SubmitButton.d.ts +3 -9
- package/dist/components/inputs/reactHookForm/utils/SubmitButton.js +1 -1
- package/dist/index.js +1 -2
- package/dist/translations/en/networkModificationsEn.d.ts +1 -0
- package/dist/translations/en/networkModificationsEn.js +2 -1
- package/dist/translations/fr/networkModificationsFr.d.ts +1 -0
- package/dist/translations/fr/networkModificationsFr.js +2 -1
- package/dist/utils/types/modificationType.d.ts +9 -1
- package/dist/utils/types/modificationType.js +10 -0
- package/package.json +1 -1
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectSchema } from 'yup';
|
|
2
2
|
import { FieldErrors, FieldValues, SubmitHandler, UseFormReturn } from 'react-hook-form';
|
|
3
|
-
import {
|
|
3
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
-
import * as yup from 'yup';
|
|
6
5
|
export interface CustomMuiDialogProps<T extends FieldValues = FieldValues> {
|
|
7
6
|
open: boolean;
|
|
8
|
-
formSchema:
|
|
9
|
-
formMethods: UseFormReturn<T
|
|
10
|
-
onClose: (event?:
|
|
7
|
+
formSchema: ObjectSchema<T>;
|
|
8
|
+
formMethods: UseFormReturn<T>;
|
|
9
|
+
onClose: (event?: MouseEvent) => void;
|
|
11
10
|
onSave: SubmitHandler<T>;
|
|
12
11
|
onValidationError?: (errors: FieldErrors) => void;
|
|
13
12
|
titleId: string;
|
|
14
13
|
disabledSave?: boolean;
|
|
15
14
|
removeOptional?: boolean;
|
|
16
15
|
onCancel?: () => void;
|
|
17
|
-
children:
|
|
16
|
+
children: ReactNode;
|
|
18
17
|
isDataFetching?: boolean;
|
|
19
18
|
language?: string;
|
|
20
19
|
confirmationMessageKey?: string;
|
|
@@ -95,9 +95,12 @@ function CustomMuiDialog({
|
|
|
95
95
|
validate(validatedData);
|
|
96
96
|
}
|
|
97
97
|
}, [validate, validatedData]);
|
|
98
|
-
const handleValidationError = (
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
const handleValidationError = useCallback(
|
|
99
|
+
(errors) => {
|
|
100
|
+
onValidationError == null ? void 0 : onValidationError(errors);
|
|
101
|
+
},
|
|
102
|
+
[onValidationError]
|
|
103
|
+
);
|
|
101
104
|
return /* @__PURE__ */ jsxs(
|
|
102
105
|
CustomFormProvider,
|
|
103
106
|
{
|
|
@@ -1,21 +1,49 @@
|
|
|
1
1
|
import { default as yup } from '../../../utils/yupConfig';
|
|
2
2
|
|
|
3
3
|
export declare const criteriaBasedFilterSchema: {
|
|
4
|
-
criteriaBased: yup.ObjectSchema<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
readonly criteriaBased: yup.ObjectSchema<{
|
|
5
|
+
nominalVoltage3: {
|
|
6
|
+
value1: number | null;
|
|
7
|
+
value2: number | null;
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
nominalVoltage2: {
|
|
11
|
+
value1: number | null;
|
|
12
|
+
value2: number | null;
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
nominalVoltage1: {
|
|
16
|
+
value1: number | null;
|
|
17
|
+
value2: number | null;
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
nominalVoltage: {
|
|
21
|
+
value1: number | null;
|
|
22
|
+
value2: number | null;
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
countries: string[] | undefined;
|
|
26
|
+
countries1: string[] | undefined;
|
|
27
|
+
countries2: string[] | undefined;
|
|
8
28
|
}, yup.AnyObject, {
|
|
29
|
+
nominalVoltage3: any;
|
|
30
|
+
nominalVoltage2: any;
|
|
31
|
+
nominalVoltage1: any;
|
|
32
|
+
nominalVoltage: any;
|
|
9
33
|
countries: "";
|
|
10
34
|
countries1: "";
|
|
11
35
|
countries2: "";
|
|
12
36
|
}, "">;
|
|
13
37
|
};
|
|
14
38
|
export declare const criteriaBasedFilterEmptyFormData: {
|
|
15
|
-
criteriaBased: {
|
|
16
|
-
countries: any;
|
|
17
|
-
countries1: any;
|
|
18
|
-
countries2: any;
|
|
39
|
+
readonly criteriaBased: {
|
|
40
|
+
readonly countries: any;
|
|
41
|
+
readonly countries1: any;
|
|
42
|
+
readonly countries2: any;
|
|
43
|
+
readonly nominalVoltage: any;
|
|
44
|
+
readonly nominalVoltage1: any;
|
|
45
|
+
readonly nominalVoltage2: any;
|
|
46
|
+
readonly nominalVoltage3: any;
|
|
19
47
|
};
|
|
20
48
|
};
|
|
21
49
|
export declare function CriteriaBasedFilterForm(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,7 +11,7 @@ const criteriaBasedFilterSchema = getCriteriaBasedSchema({
|
|
|
11
11
|
[FieldConstants.ENERGY_SOURCE]: yup.string().nullable(),
|
|
12
12
|
...filterPropertiesYupSchema
|
|
13
13
|
});
|
|
14
|
-
const criteriaBasedFilterEmptyFormData = getCriteriaBasedFormData(
|
|
14
|
+
const criteriaBasedFilterEmptyFormData = getCriteriaBasedFormData(void 0, {
|
|
15
15
|
[FieldConstants.ENERGY_SOURCE]: null,
|
|
16
16
|
[FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES]: [],
|
|
17
17
|
[FreePropertiesTypes.FREE_FILTER_PROPERTIES]: []
|
|
@@ -1,21 +1,62 @@
|
|
|
1
|
+
import { RangeInputData } from '../../inputs/reactHookForm/numbers/RangeInput';
|
|
1
2
|
import { default as yup } from '../../../utils/yupConfig';
|
|
3
|
+
import { FieldConstants } from '../../../utils/constants/fieldConstants';
|
|
4
|
+
import { ObjectSchema } from 'yup';
|
|
2
5
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export type CriteriaBasedData = {
|
|
7
|
+
[FieldConstants.COUNTRIES]?: string[];
|
|
8
|
+
[FieldConstants.COUNTRIES_1]?: string[];
|
|
9
|
+
[FieldConstants.COUNTRIES_2]?: string[];
|
|
10
|
+
[FieldConstants.NOMINAL_VOLTAGE]?: RangeInputData | null;
|
|
11
|
+
[FieldConstants.NOMINAL_VOLTAGE_1]?: RangeInputData | null;
|
|
12
|
+
[FieldConstants.NOMINAL_VOLTAGE_2]?: RangeInputData | null;
|
|
13
|
+
[FieldConstants.NOMINAL_VOLTAGE_3]?: RangeInputData | null;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
export declare function getCriteriaBasedSchema(extraFields?: Record<string, yup.AnyObject | null>): {
|
|
17
|
+
readonly criteriaBased: ObjectSchema<{
|
|
18
|
+
nominalVoltage3: {
|
|
19
|
+
value1: number | null;
|
|
20
|
+
value2: number | null;
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
nominalVoltage2: {
|
|
24
|
+
value1: number | null;
|
|
25
|
+
value2: number | null;
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
nominalVoltage1: {
|
|
29
|
+
value1: number | null;
|
|
30
|
+
value2: number | null;
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
nominalVoltage: {
|
|
34
|
+
value1: number | null;
|
|
35
|
+
value2: number | null;
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
countries: string[] | undefined;
|
|
39
|
+
countries1: string[] | undefined;
|
|
40
|
+
countries2: string[] | undefined;
|
|
8
41
|
}, yup.AnyObject, {
|
|
42
|
+
nominalVoltage3: any;
|
|
43
|
+
nominalVoltage2: any;
|
|
44
|
+
nominalVoltage1: any;
|
|
45
|
+
nominalVoltage: any;
|
|
9
46
|
countries: "";
|
|
10
47
|
countries1: "";
|
|
11
48
|
countries2: "";
|
|
12
49
|
}, "">;
|
|
13
50
|
};
|
|
14
|
-
export declare
|
|
15
|
-
criteriaBased: {
|
|
16
|
-
countries: any;
|
|
17
|
-
countries1: any;
|
|
18
|
-
countries2: any;
|
|
51
|
+
export declare function getCriteriaBasedFormData(criteriaValues?: Record<string, any>, extraFields?: Record<string, yup.AnyObject | null>): {
|
|
52
|
+
readonly criteriaBased: {
|
|
53
|
+
readonly countries: any;
|
|
54
|
+
readonly countries1: any;
|
|
55
|
+
readonly countries2: any;
|
|
56
|
+
readonly nominalVoltage: any;
|
|
57
|
+
readonly nominalVoltage1: any;
|
|
58
|
+
readonly nominalVoltage2: any;
|
|
59
|
+
readonly nominalVoltage3: any;
|
|
19
60
|
};
|
|
20
61
|
};
|
|
21
62
|
/**
|
|
@@ -29,13 +70,17 @@ export declare const getCriteriaBasedFormData: (criteriaValues: any, extraFields
|
|
|
29
70
|
* {name_property:namesB, prop_values:valuesB}]
|
|
30
71
|
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
31
72
|
*/
|
|
32
|
-
export declare
|
|
33
|
-
criteriaBased: {
|
|
34
|
-
countries: any;
|
|
35
|
-
countries1: any;
|
|
36
|
-
countries2: any;
|
|
73
|
+
export declare function backToFrontTweak(response: any): {
|
|
74
|
+
readonly criteriaBased: {
|
|
75
|
+
readonly countries: any;
|
|
76
|
+
readonly countries1: any;
|
|
77
|
+
readonly countries2: any;
|
|
78
|
+
readonly nominalVoltage: any;
|
|
79
|
+
readonly nominalVoltage1: any;
|
|
80
|
+
readonly nominalVoltage2: any;
|
|
81
|
+
readonly nominalVoltage3: any;
|
|
37
82
|
};
|
|
38
|
-
equipmentType: any;
|
|
83
|
+
readonly equipmentType: any;
|
|
39
84
|
};
|
|
40
85
|
/**
|
|
41
86
|
* Transform
|
|
@@ -48,8 +93,8 @@ export declare const backToFrontTweak: (response: any) => {
|
|
|
48
93
|
* freeProperties2.{nameA:valuesC}}
|
|
49
94
|
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
50
95
|
*/
|
|
51
|
-
export declare
|
|
96
|
+
export declare function frontToBackTweak(id?: string, filter?: any): {
|
|
52
97
|
id: string | undefined;
|
|
53
98
|
type: string;
|
|
54
|
-
equipmentFilterForm:
|
|
99
|
+
equipmentFilterForm: any;
|
|
55
100
|
};
|
|
@@ -2,46 +2,38 @@ import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
|
2
2
|
import { PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2, PROPERTY_NAME } from "./FilterProperty.js";
|
|
3
3
|
import { FilterType } from "../constants/FilterConstants.js";
|
|
4
4
|
import "../../../utils/yupConfig.js";
|
|
5
|
-
import { getRangeInputSchema,
|
|
5
|
+
import { getRangeInputSchema, DEFAULT_RANGE_VALUE } from "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
6
6
|
import { FreePropertiesTypes } from "./FilterFreeProperties.js";
|
|
7
7
|
import * as yup from "yup";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[FieldConstants.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
[FieldConstants.
|
|
25
|
-
|
|
26
|
-
FieldConstants.
|
|
27
|
-
(criteriaValues == null ? void 0 : criteriaValues[FieldConstants.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
FieldConstants.
|
|
31
|
-
(criteriaValues == null ? void 0 : criteriaValues[FieldConstants.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...getRangeInputDataForm(
|
|
38
|
-
FieldConstants.NOMINAL_VOLTAGE_3,
|
|
39
|
-
(criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_3]) ?? DEFAULT_RANGE_VALUE
|
|
40
|
-
),
|
|
41
|
-
...extraFields
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const backToFrontTweak = (response) => {
|
|
8
|
+
function getCriteriaBasedSchema(extraFields = {}) {
|
|
9
|
+
return {
|
|
10
|
+
[FieldConstants.CRITERIA_BASED]: yup.object().shape({
|
|
11
|
+
[FieldConstants.COUNTRIES]: yup.array().of(yup.string().required()),
|
|
12
|
+
[FieldConstants.COUNTRIES_1]: yup.array().of(yup.string().required()),
|
|
13
|
+
[FieldConstants.COUNTRIES_2]: yup.array().of(yup.string().required()),
|
|
14
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE),
|
|
15
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_1),
|
|
16
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_2),
|
|
17
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_3),
|
|
18
|
+
...extraFields
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function getCriteriaBasedFormData(criteriaValues, extraFields = {}) {
|
|
23
|
+
return {
|
|
24
|
+
[FieldConstants.CRITERIA_BASED]: {
|
|
25
|
+
[FieldConstants.COUNTRIES]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES]) ?? [],
|
|
26
|
+
[FieldConstants.COUNTRIES_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_1]) ?? [],
|
|
27
|
+
[FieldConstants.COUNTRIES_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_2]) ?? [],
|
|
28
|
+
[FieldConstants.NOMINAL_VOLTAGE]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE]) ?? DEFAULT_RANGE_VALUE,
|
|
29
|
+
[FieldConstants.NOMINAL_VOLTAGE_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_1]) ?? DEFAULT_RANGE_VALUE,
|
|
30
|
+
[FieldConstants.NOMINAL_VOLTAGE_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_2]) ?? DEFAULT_RANGE_VALUE,
|
|
31
|
+
[FieldConstants.NOMINAL_VOLTAGE_3]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_3]) ?? DEFAULT_RANGE_VALUE,
|
|
32
|
+
...extraFields
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function backToFrontTweak(response) {
|
|
45
37
|
const subProps = response.equipmentFilterForm.substationFreeProperties;
|
|
46
38
|
const freeProps = response.equipmentFilterForm.freeProperties;
|
|
47
39
|
const props1 = response.equipmentFilterForm.freeProperties1;
|
|
@@ -86,7 +78,7 @@ const backToFrontTweak = (response) => {
|
|
|
86
78
|
}
|
|
87
79
|
filterFreeProperties.push(prop);
|
|
88
80
|
});
|
|
89
|
-
|
|
81
|
+
return {
|
|
90
82
|
[FieldConstants.EQUIPMENT_TYPE]: response[FieldConstants.EQUIPMENT_TYPE],
|
|
91
83
|
...getCriteriaBasedFormData(response.equipmentFilterForm, {
|
|
92
84
|
[FieldConstants.ENERGY_SOURCE]: response.equipmentFilterForm[FieldConstants.ENERGY_SOURCE],
|
|
@@ -94,8 +86,7 @@ const backToFrontTweak = (response) => {
|
|
|
94
86
|
[FreePropertiesTypes.FREE_FILTER_PROPERTIES]: filterFreeProperties
|
|
95
87
|
})
|
|
96
88
|
};
|
|
97
|
-
|
|
98
|
-
};
|
|
89
|
+
}
|
|
99
90
|
function isNominalVoltageEmpty(nominalVoltage) {
|
|
100
91
|
return nominalVoltage[FieldConstants.VALUE_1] === null && nominalVoltage[FieldConstants.VALUE_2] === null;
|
|
101
92
|
}
|
|
@@ -115,18 +106,12 @@ function cleanNominalVoltages(formValues) {
|
|
|
115
106
|
}
|
|
116
107
|
return cleanedFormValues;
|
|
117
108
|
}
|
|
118
|
-
|
|
109
|
+
function frontToBackTweak(id, filter) {
|
|
119
110
|
const filterSubstationProperties = filter[FieldConstants.CRITERIA_BASED][FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES];
|
|
120
|
-
const ret = {
|
|
121
|
-
id,
|
|
122
|
-
type: FilterType.CRITERIA_BASED.id,
|
|
123
|
-
equipmentFilterForm: void 0
|
|
124
|
-
};
|
|
125
111
|
const eff = {
|
|
126
112
|
[FieldConstants.EQUIPMENT_TYPE]: filter[FieldConstants.EQUIPMENT_TYPE],
|
|
127
113
|
...cleanNominalVoltages(filter[FieldConstants.CRITERIA_BASED])
|
|
128
114
|
};
|
|
129
|
-
ret.equipmentFilterForm = eff;
|
|
130
115
|
delete eff[FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES];
|
|
131
116
|
const props = {};
|
|
132
117
|
const props1 = {};
|
|
@@ -158,8 +143,13 @@ const frontToBackTweak = (id, filter) => {
|
|
|
158
143
|
}
|
|
159
144
|
});
|
|
160
145
|
eff.freeProperties = freeProps;
|
|
161
|
-
return
|
|
162
|
-
|
|
146
|
+
return {
|
|
147
|
+
id,
|
|
148
|
+
type: FilterType.CRITERIA_BASED.id,
|
|
149
|
+
// in the back end we store everything in a field called equipmentFilterForm
|
|
150
|
+
equipmentFilterForm: eff
|
|
151
|
+
};
|
|
152
|
+
}
|
|
163
153
|
export {
|
|
164
154
|
backToFrontTweak,
|
|
165
155
|
frontToBackTweak,
|
package/dist/components/index.js
CHANGED
|
@@ -61,7 +61,7 @@ import { FieldErrorAlert } from "./inputs/reactHookForm/errorManagement/FieldErr
|
|
|
61
61
|
import { MidFormError } from "./inputs/reactHookForm/errorManagement/MidFormError.js";
|
|
62
62
|
import { FloatInput } from "./inputs/reactHookForm/numbers/FloatInput.js";
|
|
63
63
|
import { IntegerInput } from "./inputs/reactHookForm/numbers/IntegerInput.js";
|
|
64
|
-
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType,
|
|
64
|
+
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType, getRangeInputSchema } from "./inputs/reactHookForm/numbers/RangeInput.js";
|
|
65
65
|
import { SliderInput } from "./inputs/reactHookForm/numbers/SliderInput.js";
|
|
66
66
|
import { isFloatNumber, isIntegerNumber } from "./inputs/reactHookForm/numbers/utils.js";
|
|
67
67
|
import { CustomFormContext, CustomFormProvider } from "./inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
@@ -262,7 +262,6 @@ export {
|
|
|
262
262
|
getNumberOfSiblings,
|
|
263
263
|
getOperators,
|
|
264
264
|
getPreLoginPath,
|
|
265
|
-
getRangeInputDataForm,
|
|
266
265
|
getRangeInputSchema,
|
|
267
266
|
gridItem,
|
|
268
267
|
handleSigninCallback,
|
|
@@ -16,7 +16,7 @@ import { FieldErrorAlert } from "./reactHookForm/errorManagement/FieldErrorAlert
|
|
|
16
16
|
import { MidFormError } from "./reactHookForm/errorManagement/MidFormError.js";
|
|
17
17
|
import { FloatInput } from "./reactHookForm/numbers/FloatInput.js";
|
|
18
18
|
import { IntegerInput } from "./reactHookForm/numbers/IntegerInput.js";
|
|
19
|
-
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType,
|
|
19
|
+
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType, getRangeInputSchema } from "./reactHookForm/numbers/RangeInput.js";
|
|
20
20
|
import { SliderInput } from "./reactHookForm/numbers/SliderInput.js";
|
|
21
21
|
import { isFloatNumber, isIntegerNumber } from "./reactHookForm/numbers/utils.js";
|
|
22
22
|
import { CustomFormContext, CustomFormProvider } from "./reactHookForm/provider/CustomFormProvider.js";
|
|
@@ -105,7 +105,6 @@ export {
|
|
|
105
105
|
ValueSelector,
|
|
106
106
|
genHelperError,
|
|
107
107
|
genHelperPreviousValue,
|
|
108
|
-
getRangeInputDataForm,
|
|
109
108
|
getRangeInputSchema,
|
|
110
109
|
gridItem,
|
|
111
110
|
identity,
|
|
@@ -15,7 +15,7 @@ import { FieldErrorAlert } from "./errorManagement/FieldErrorAlert.js";
|
|
|
15
15
|
import { MidFormError } from "./errorManagement/MidFormError.js";
|
|
16
16
|
import { FloatInput } from "./numbers/FloatInput.js";
|
|
17
17
|
import { IntegerInput } from "./numbers/IntegerInput.js";
|
|
18
|
-
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType,
|
|
18
|
+
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType, getRangeInputSchema } from "./numbers/RangeInput.js";
|
|
19
19
|
import { SliderInput } from "./numbers/SliderInput.js";
|
|
20
20
|
import { isFloatNumber, isIntegerNumber } from "./numbers/utils.js";
|
|
21
21
|
import { CustomFormContext, CustomFormProvider } from "./provider/CustomFormProvider.js";
|
|
@@ -73,7 +73,6 @@ export {
|
|
|
73
73
|
UniqueNameInput,
|
|
74
74
|
genHelperError,
|
|
75
75
|
genHelperPreviousValue,
|
|
76
|
-
getRangeInputDataForm,
|
|
77
76
|
getRangeInputSchema,
|
|
78
77
|
gridItem,
|
|
79
78
|
identity,
|
|
@@ -1,50 +1,40 @@
|
|
|
1
|
+
import { FieldConstants } from '../../../../utils/constants/fieldConstants';
|
|
1
2
|
import { default as yup } from '../../../../utils/yupConfig';
|
|
3
|
+
import { ObjectSchema } from 'yup';
|
|
2
4
|
|
|
3
5
|
export declare const RangeType: {
|
|
4
|
-
EQUALITY: {
|
|
5
|
-
id:
|
|
6
|
-
label:
|
|
6
|
+
readonly EQUALITY: {
|
|
7
|
+
readonly id: "EQUALITY";
|
|
8
|
+
readonly label: "equality";
|
|
7
9
|
};
|
|
8
|
-
GREATER_THAN: {
|
|
9
|
-
id:
|
|
10
|
-
label:
|
|
10
|
+
readonly GREATER_THAN: {
|
|
11
|
+
readonly id: "GREATER_THAN";
|
|
12
|
+
readonly label: "greaterThan";
|
|
11
13
|
};
|
|
12
|
-
GREATER_OR_EQUAL: {
|
|
13
|
-
id:
|
|
14
|
-
label:
|
|
14
|
+
readonly GREATER_OR_EQUAL: {
|
|
15
|
+
readonly id: "GREATER_OR_EQUAL";
|
|
16
|
+
readonly label: "greaterOrEqual";
|
|
15
17
|
};
|
|
16
|
-
LESS_THAN: {
|
|
17
|
-
id:
|
|
18
|
-
label:
|
|
18
|
+
readonly LESS_THAN: {
|
|
19
|
+
readonly id: "LESS_THAN";
|
|
20
|
+
readonly label: "lessThan";
|
|
19
21
|
};
|
|
20
|
-
LESS_OR_EQUAL: {
|
|
21
|
-
id:
|
|
22
|
-
label:
|
|
22
|
+
readonly LESS_OR_EQUAL: {
|
|
23
|
+
readonly id: "LESS_OR_EQUAL";
|
|
24
|
+
readonly label: "lessOrEqual";
|
|
23
25
|
};
|
|
24
|
-
RANGE: {
|
|
25
|
-
id:
|
|
26
|
-
label:
|
|
26
|
+
readonly RANGE: {
|
|
27
|
+
readonly id: "RANGE";
|
|
28
|
+
readonly label: "range";
|
|
27
29
|
};
|
|
28
30
|
};
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
export declare const getRangeInputDataForm: (name: string, rangeValue: unknown) => {
|
|
35
|
-
[x: string]: unknown;
|
|
36
|
-
};
|
|
37
|
-
export declare const getRangeInputSchema: (name: string) => {
|
|
38
|
-
[x: string]: yup.ObjectSchema<{
|
|
39
|
-
type: string | undefined;
|
|
40
|
-
value1: number | undefined;
|
|
41
|
-
value2: number | undefined;
|
|
42
|
-
}, yup.AnyObject, {
|
|
43
|
-
type: undefined;
|
|
44
|
-
value1: undefined;
|
|
45
|
-
value2: undefined;
|
|
46
|
-
}, "">;
|
|
31
|
+
export type RangeInputData = {
|
|
32
|
+
[FieldConstants.OPERATION_TYPE]: string;
|
|
33
|
+
[FieldConstants.VALUE_1]: number | null;
|
|
34
|
+
[FieldConstants.VALUE_2]: number | null;
|
|
47
35
|
};
|
|
36
|
+
export declare const DEFAULT_RANGE_VALUE: RangeInputData;
|
|
37
|
+
export declare function getRangeInputSchema<TName extends string>(name: TName): Record<TName, ObjectSchema<RangeInputData, yup.AnyObject, any, "">>;
|
|
48
38
|
interface RangeInputProps {
|
|
49
39
|
name: string;
|
|
50
40
|
label: string;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useWatch } from "react-hook-form";
|
|
3
3
|
import { FormattedMessage } from "react-intl";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import InputLabel from "@mui/material
|
|
6
|
-
import { Grid } from "@mui/material";
|
|
7
|
-
import FormControl from "@mui/material/FormControl";
|
|
5
|
+
import { FormControl, InputLabel, Grid } from "@mui/material";
|
|
8
6
|
import { FloatInput } from "./FloatInput.js";
|
|
9
7
|
import "../../../../utils/yupConfig.js";
|
|
10
8
|
import { MuiSelectInput } from "../selectInputs/MuiSelectInput.js";
|
|
@@ -30,11 +28,8 @@ const DEFAULT_RANGE_VALUE = {
|
|
|
30
28
|
[FieldConstants.VALUE_1]: null,
|
|
31
29
|
[FieldConstants.VALUE_2]: null
|
|
32
30
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
const getRangeInputSchema = (name) => ({
|
|
37
|
-
[name]: yup.object().shape(
|
|
31
|
+
function getRangeInputSchema(name) {
|
|
32
|
+
const result = yup.object().shape(
|
|
38
33
|
{
|
|
39
34
|
[FieldConstants.OPERATION_TYPE]: yup.string(),
|
|
40
35
|
[FieldConstants.VALUE_1]: yup.number().when([FieldConstants.OPERATION_TYPE, FieldConstants.VALUE_2], {
|
|
@@ -49,60 +44,47 @@ const getRangeInputSchema = (name) => ({
|
|
|
49
44
|
})
|
|
50
45
|
},
|
|
51
46
|
[[FieldConstants.VALUE_1, FieldConstants.VALUE_2]]
|
|
52
|
-
)
|
|
53
|
-
}
|
|
47
|
+
);
|
|
48
|
+
return { [name]: result };
|
|
49
|
+
}
|
|
54
50
|
function RangeInput({ name, label }) {
|
|
55
|
-
const watchOperationType = useWatch({
|
|
56
|
-
name: `${name}.${FieldConstants.OPERATION_TYPE}`
|
|
57
|
-
});
|
|
51
|
+
const watchOperationType = useWatch({ name: `${name}.${FieldConstants.OPERATION_TYPE}` });
|
|
58
52
|
const isOperationTypeRange = useMemo(() => watchOperationType === RangeType.RANGE.id, [watchOperationType]);
|
|
59
|
-
const firstValueField = /* @__PURE__ */ jsx(
|
|
60
|
-
FloatInput,
|
|
61
|
-
{
|
|
62
|
-
label: "",
|
|
63
|
-
name: `${name}.${FieldConstants.VALUE_1}`,
|
|
64
|
-
clearable: false,
|
|
65
|
-
formProps: {
|
|
66
|
-
size: "medium",
|
|
67
|
-
placeholder: isOperationTypeRange ? "Min" : ""
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
const secondValueField = /* @__PURE__ */ jsx(
|
|
72
|
-
FloatInput,
|
|
73
|
-
{
|
|
74
|
-
name: `${name}.${FieldConstants.VALUE_2}`,
|
|
75
|
-
clearable: false,
|
|
76
|
-
label: "",
|
|
77
|
-
formProps: {
|
|
78
|
-
size: "medium",
|
|
79
|
-
placeholder: "Max"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
const operationTypeField = /* @__PURE__ */ jsx(
|
|
84
|
-
MuiSelectInput,
|
|
85
|
-
{
|
|
86
|
-
name: `${name}.${FieldConstants.OPERATION_TYPE}`,
|
|
87
|
-
options: Object.values(RangeType),
|
|
88
|
-
fullWidth: true
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
53
|
return /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, children: [
|
|
92
54
|
/* @__PURE__ */ jsx(InputLabel, { sx: style.inputLegend, shrink: true, children: /* @__PURE__ */ jsx(FormattedMessage, { id: label }) }),
|
|
93
55
|
/* @__PURE__ */ jsxs(Grid, { container: true, spacing: 0, children: [
|
|
94
|
-
/* @__PURE__ */ jsx(
|
|
95
|
-
|
|
56
|
+
/* @__PURE__ */ jsx(Grid, { item: true, style: isOperationTypeRange ? { flex: "min-content" } : {}, children: /* @__PURE__ */ jsx(
|
|
57
|
+
MuiSelectInput,
|
|
58
|
+
{
|
|
59
|
+
name: `${name}.${FieldConstants.OPERATION_TYPE}`,
|
|
60
|
+
options: Object.values(RangeType),
|
|
61
|
+
fullWidth: true
|
|
62
|
+
}
|
|
63
|
+
) }),
|
|
64
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
65
|
+
FloatInput,
|
|
66
|
+
{
|
|
67
|
+
label: "",
|
|
68
|
+
name: `${name}.${FieldConstants.VALUE_1}`,
|
|
69
|
+
clearable: false,
|
|
70
|
+
formProps: {
|
|
71
|
+
size: "medium",
|
|
72
|
+
placeholder: isOperationTypeRange ? "Min" : ""
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
) }),
|
|
76
|
+
isOperationTypeRange && /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
77
|
+
FloatInput,
|
|
96
78
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
79
|
+
name: `${name}.${FieldConstants.VALUE_2}`,
|
|
80
|
+
clearable: false,
|
|
81
|
+
label: "",
|
|
82
|
+
formProps: {
|
|
83
|
+
size: "medium",
|
|
84
|
+
placeholder: "Max"
|
|
85
|
+
}
|
|
102
86
|
}
|
|
103
|
-
)
|
|
104
|
-
/* @__PURE__ */ jsx(Grid, { item: true, children: firstValueField }),
|
|
105
|
-
isOperationTypeRange && /* @__PURE__ */ jsx(Grid, { item: true, children: secondValueField })
|
|
87
|
+
) })
|
|
106
88
|
] })
|
|
107
89
|
] });
|
|
108
90
|
}
|
|
@@ -110,6 +92,5 @@ export {
|
|
|
110
92
|
DEFAULT_RANGE_VALUE,
|
|
111
93
|
RangeInput,
|
|
112
94
|
RangeType,
|
|
113
|
-
getRangeInputDataForm,
|
|
114
95
|
getRangeInputSchema
|
|
115
96
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FloatInput } from "./FloatInput.js";
|
|
2
2
|
import { IntegerInput } from "./IntegerInput.js";
|
|
3
|
-
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType,
|
|
3
|
+
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType, getRangeInputSchema } from "./RangeInput.js";
|
|
4
4
|
import { SliderInput } from "./SliderInput.js";
|
|
5
5
|
import { isFloatNumber, isIntegerNumber } from "./utils.js";
|
|
6
6
|
export {
|
|
@@ -10,7 +10,6 @@ export {
|
|
|
10
10
|
RangeInput,
|
|
11
11
|
RangeType,
|
|
12
12
|
SliderInput,
|
|
13
|
-
getRangeInputDataForm,
|
|
14
13
|
getRangeInputSchema,
|
|
15
14
|
isFloatNumber,
|
|
16
15
|
isIntegerNumber
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectSchema } from 'yup';
|
|
2
|
+
import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
2
3
|
import { default as React, PropsWithChildren } from 'react';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
type CustomFormContextProps = {
|
|
5
|
+
type CustomFormContextProps<TFieldValues extends FieldValues = FieldValues> = {
|
|
6
6
|
removeOptional?: boolean;
|
|
7
|
-
validationSchema:
|
|
7
|
+
validationSchema: ObjectSchema<TFieldValues>;
|
|
8
8
|
language?: string;
|
|
9
9
|
};
|
|
10
|
-
export type MergedFormContextProps = UseFormReturn<
|
|
11
|
-
|
|
12
|
-
export declare
|
|
13
|
-
export declare function CustomFormProvider(props: CustomFormProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export type MergedFormContextProps<TFieldValues extends FieldValues = FieldValues> = UseFormReturn<TFieldValues> & CustomFormContextProps<TFieldValues>;
|
|
11
|
+
export declare const CustomFormContext: React.Context<CustomFormContextProps<FieldValues>>;
|
|
12
|
+
export declare function CustomFormProvider<TFieldValues extends FieldValues = FieldValues>(props: PropsWithChildren<MergedFormContextProps<TFieldValues>>): import("react/jsx-runtime").JSX.Element;
|
|
14
13
|
export {};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 declare function SubmitButton({ ...buttonProps }: {
|
|
8
|
-
[x: string]: any;
|
|
9
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
export declare function SubmitButton(buttonProps: Readonly<ButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Button } from "@mui/material";
|
|
3
3
|
import { useFormState } from "react-hook-form";
|
|
4
4
|
import { FormattedMessage } from "react-intl";
|
|
5
|
-
function SubmitButton(
|
|
5
|
+
function SubmitButton(buttonProps) {
|
|
6
6
|
const { isDirty } = useFormState();
|
|
7
7
|
return /* @__PURE__ */ jsx(Button, { ...buttonProps, disabled: !isDirty || ((buttonProps == null ? void 0 : buttonProps.disabled) ?? false), children: /* @__PURE__ */ jsx(FormattedMessage, { id: "validate" }) });
|
|
8
8
|
}
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import { FieldErrorAlert } from "./components/inputs/reactHookForm/errorManageme
|
|
|
62
62
|
import { MidFormError } from "./components/inputs/reactHookForm/errorManagement/MidFormError.js";
|
|
63
63
|
import { FloatInput } from "./components/inputs/reactHookForm/numbers/FloatInput.js";
|
|
64
64
|
import { IntegerInput } from "./components/inputs/reactHookForm/numbers/IntegerInput.js";
|
|
65
|
-
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType,
|
|
65
|
+
import { DEFAULT_RANGE_VALUE, RangeInput, RangeType, getRangeInputSchema } from "./components/inputs/reactHookForm/numbers/RangeInput.js";
|
|
66
66
|
import { SliderInput } from "./components/inputs/reactHookForm/numbers/SliderInput.js";
|
|
67
67
|
import { isFloatNumber, isIntegerNumber } from "./components/inputs/reactHookForm/numbers/utils.js";
|
|
68
68
|
import { CustomFormContext, CustomFormProvider } from "./components/inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
@@ -420,7 +420,6 @@ export {
|
|
|
420
420
|
getNumberOfSiblings,
|
|
421
421
|
getOperators,
|
|
422
422
|
getPreLoginPath,
|
|
423
|
-
getRangeInputDataForm,
|
|
424
423
|
getRangeInputSchema,
|
|
425
424
|
getRequestParamFromList,
|
|
426
425
|
getSystemLanguage,
|
|
@@ -57,4 +57,5 @@ export declare const networkModificationsEn: {
|
|
|
57
57
|
'network_modifications.tabular.SUBSTATION_MODIFICATION': string;
|
|
58
58
|
'network_modifications.TABULAR_CREATION': string;
|
|
59
59
|
'network_modifications.tabular.GENERATOR_CREATION': string;
|
|
60
|
+
'network_modifications.LCC_CREATION': string;
|
|
60
61
|
};
|
|
@@ -50,7 +50,8 @@ const networkModificationsEn = {
|
|
|
50
50
|
"network_modifications.tabular.SHUNT_COMPENSATOR_MODIFICATION": "linear shunt compensator modifications",
|
|
51
51
|
"network_modifications.tabular.SUBSTATION_MODIFICATION": "substation modifications",
|
|
52
52
|
"network_modifications.TABULAR_CREATION": "Tabular creation - {computedLabel}",
|
|
53
|
-
"network_modifications.tabular.GENERATOR_CREATION": "generator creations"
|
|
53
|
+
"network_modifications.tabular.GENERATOR_CREATION": "generator creations",
|
|
54
|
+
"network_modifications.LCC_CREATION": "Creating HVDC (LCC) {computedLabel}"
|
|
54
55
|
};
|
|
55
56
|
export {
|
|
56
57
|
networkModificationsEn
|
|
@@ -57,4 +57,5 @@ export declare const networkModificationsFr: {
|
|
|
57
57
|
'network_modifications.tabular.SUBSTATION_MODIFICATION': string;
|
|
58
58
|
'network_modifications.TABULAR_CREATION': string;
|
|
59
59
|
'network_modifications.tabular.GENERATOR_CREATION': string;
|
|
60
|
+
'network_modifications.LCC_CREATION': string;
|
|
60
61
|
};
|
|
@@ -50,7 +50,8 @@ const networkModificationsFr = {
|
|
|
50
50
|
"network_modifications.tabular.SHUNT_COMPENSATOR_MODIFICATION": "modifications de MCS linéaires",
|
|
51
51
|
"network_modifications.tabular.SUBSTATION_MODIFICATION": "modifications de sites",
|
|
52
52
|
"network_modifications.TABULAR_CREATION": "Création tabulaire - {computedLabel}",
|
|
53
|
-
"network_modifications.tabular.GENERATOR_CREATION": "créations de générateurs"
|
|
53
|
+
"network_modifications.tabular.GENERATOR_CREATION": "créations de générateurs",
|
|
54
|
+
"network_modifications.LCC_CREATION": "Création de la HVDC (LCC) {computedLabel}"
|
|
54
55
|
};
|
|
55
56
|
export {
|
|
56
57
|
networkModificationsFr
|
|
@@ -44,7 +44,9 @@ export declare enum ModificationType {
|
|
|
44
44
|
TABULAR_CREATION = "TABULAR_CREATION",
|
|
45
45
|
VSC_MODIFICATION = "VSC_MODIFICATION",
|
|
46
46
|
CONVERTER_STATION_MODIFICATION = "CONVERTER_STATION_MODIFICATION",
|
|
47
|
-
COMPOSITE_MODIFICATION = "COMPOSITE_MODIFICATION"
|
|
47
|
+
COMPOSITE_MODIFICATION = "COMPOSITE_MODIFICATION",
|
|
48
|
+
LCC_CONVERTER_STATION_CREATION = "LCC_CONVERTER_STATION_CREATION",
|
|
49
|
+
LCC_CREATION = "LCC_CREATION"
|
|
48
50
|
}
|
|
49
51
|
export declare const MODIFICATION_TYPES: {
|
|
50
52
|
GROOVY_SCRIPT: {
|
|
@@ -167,4 +169,10 @@ export declare const MODIFICATION_TYPES: {
|
|
|
167
169
|
COMPOSITE_MODIFICATION: {
|
|
168
170
|
type: ModificationType;
|
|
169
171
|
};
|
|
172
|
+
LCC_CONVERTER_STATION_CREATION: {
|
|
173
|
+
type: ModificationType;
|
|
174
|
+
};
|
|
175
|
+
LCC_CREATION: {
|
|
176
|
+
type: ModificationType;
|
|
177
|
+
};
|
|
170
178
|
};
|
|
@@ -39,6 +39,8 @@ var ModificationType = /* @__PURE__ */ ((ModificationType2) => {
|
|
|
39
39
|
ModificationType2["VSC_MODIFICATION"] = "VSC_MODIFICATION";
|
|
40
40
|
ModificationType2["CONVERTER_STATION_MODIFICATION"] = "CONVERTER_STATION_MODIFICATION";
|
|
41
41
|
ModificationType2["COMPOSITE_MODIFICATION"] = "COMPOSITE_MODIFICATION";
|
|
42
|
+
ModificationType2["LCC_CONVERTER_STATION_CREATION"] = "LCC_CONVERTER_STATION_CREATION";
|
|
43
|
+
ModificationType2["LCC_CREATION"] = "LCC_CREATION";
|
|
42
44
|
return ModificationType2;
|
|
43
45
|
})(ModificationType || {});
|
|
44
46
|
const MODIFICATION_TYPES = {
|
|
@@ -200,6 +202,14 @@ const MODIFICATION_TYPES = {
|
|
|
200
202
|
COMPOSITE_MODIFICATION: {
|
|
201
203
|
type: "COMPOSITE_MODIFICATION"
|
|
202
204
|
/* COMPOSITE_MODIFICATION */
|
|
205
|
+
},
|
|
206
|
+
LCC_CONVERTER_STATION_CREATION: {
|
|
207
|
+
type: "LCC_CONVERTER_STATION_CREATION"
|
|
208
|
+
/* LCC_CONVERTER_STATION_CREATION */
|
|
209
|
+
},
|
|
210
|
+
LCC_CREATION: {
|
|
211
|
+
type: "LCC_CREATION"
|
|
212
|
+
/* LCC_CREATION */
|
|
203
213
|
}
|
|
204
214
|
};
|
|
205
215
|
export {
|