@gridsuite/commons-ui 0.72.0 → 0.72.2
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/checkBoxList/DraggableClickableRowItem.js +4 -5
- package/dist/components/dialogs/customMuiDialog/CustomMuiDialog.d.ts +10 -11
- package/dist/components/dialogs/customMuiDialog/CustomMuiDialog.js +11 -6
- package/dist/components/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js +8 -5
- package/dist/components/directoryItemSelector/DirectoryItemSelector.js +11 -11
- package/dist/components/filter/FilterCreationDialog.js +1 -1
- package/dist/components/filter/HeaderFilterForm.js +2 -1
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.d.ts +40 -4
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.js +1 -1
- package/dist/components/filter/criteriaBased/criteriaBasedFilterUtils.d.ts +68 -11
- package/dist/components/filter/criteriaBased/criteriaBasedFilterUtils.js +40 -50
- package/dist/components/filter/expert/expertFilter.type.d.ts +0 -1
- package/dist/components/filter/expert/expertFilter.type.js +0 -1
- package/dist/components/filter/expert/expertFilterConstants.d.ts +0 -7
- package/dist/components/filter/expert/expertFilterConstants.js +2 -18
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js +1 -1
- package/dist/components/filter/utils/filterApi.d.ts +1 -1
- 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/components/inputs/reactQueryBuilder/ValueEditor.js +1 -1
- package/dist/index.js +1 -2
- package/dist/translations/en/filterExpertEn.d.ts +0 -1
- package/dist/translations/en/filterExpertEn.js +0 -1
- package/dist/translations/fr/filterExpertFr.d.ts +0 -1
- package/dist/translations/fr/filterExpertFr.js +0 -1
- package/package.json +1 -1
|
@@ -2,6 +2,9 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import DragIndicatorIcon from "@mui/icons-material/DragIndicator";
|
|
3
3
|
import { ListItemButton, IconButton, ListItemIcon, Checkbox, ListItemText } from "@mui/material";
|
|
4
4
|
import { OverflowableText } from "../overflowableText/OverflowableText.js";
|
|
5
|
+
import "@mui/icons-material";
|
|
6
|
+
import { mergeSx } from "../../utils/styles.js";
|
|
7
|
+
import "../../utils/yupConfig.js";
|
|
5
8
|
const styles = {
|
|
6
9
|
dragIcon: (theme) => ({
|
|
7
10
|
padding: "unset",
|
|
@@ -36,11 +39,7 @@ function DraggableClickableRowItem({
|
|
|
36
39
|
ListItemButton,
|
|
37
40
|
{
|
|
38
41
|
disableTouchRipple: !isItemClickable,
|
|
39
|
-
sx: {
|
|
40
|
-
paddingLeft: 0,
|
|
41
|
-
...sx == null ? void 0 : sx.checkboxButton,
|
|
42
|
-
...!isItemClickable && styles.unclickableItem
|
|
43
|
-
},
|
|
42
|
+
sx: mergeSx({ paddingLeft: 0 }, sx == null ? void 0 : sx.checkboxButton, !isItemClickable ? styles.unclickableItem : void 0),
|
|
44
43
|
disabled,
|
|
45
44
|
onClick: handleItemClick,
|
|
46
45
|
children: [
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FieldErrors, UseFormReturn } from 'react-hook-form';
|
|
3
|
-
import {
|
|
1
|
+
import { ObjectSchema } from 'yup';
|
|
2
|
+
import { FieldErrors, FieldValues, SubmitHandler, UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export interface CustomMuiDialogProps {
|
|
5
|
+
export interface CustomMuiDialogProps<T extends FieldValues = FieldValues> {
|
|
7
6
|
open: boolean;
|
|
8
|
-
formSchema:
|
|
9
|
-
formMethods: UseFormReturn<
|
|
10
|
-
onClose: (event
|
|
11
|
-
onSave:
|
|
7
|
+
formSchema: ObjectSchema<T>;
|
|
8
|
+
formMethods: UseFormReturn<T>;
|
|
9
|
+
onClose: (event?: MouseEvent) => void;
|
|
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;
|
|
@@ -52,4 +51,4 @@ export declare const unscrollableDialogStyles: {
|
|
|
52
51
|
padding: number;
|
|
53
52
|
};
|
|
54
53
|
};
|
|
55
|
-
export declare function CustomMuiDialog({ open, formSchema, formMethods, onClose, onSave, isDataFetching, onValidationError, titleId, disabledSave, removeOptional, onCancel, children, language, confirmationMessageKey, unscrollableFullHeight, }: Readonly<CustomMuiDialogProps
|
|
54
|
+
export declare function CustomMuiDialog<T extends FieldValues = FieldValues>({ open, formSchema, formMethods, onClose, onSave, isDataFetching, onValidationError, titleId, disabledSave, removeOptional, onCancel, children, language, confirmationMessageKey, unscrollableFullHeight, }: Readonly<CustomMuiDialogProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -56,7 +56,7 @@ function CustomMuiDialog({
|
|
|
56
56
|
unscrollableFullHeight = false
|
|
57
57
|
}) {
|
|
58
58
|
const [openConfirmationPopup, setOpenConfirmationPopup] = useState(false);
|
|
59
|
-
const [validatedData, setValidatedData] = useState(
|
|
59
|
+
const [validatedData, setValidatedData] = useState();
|
|
60
60
|
const { handleSubmit } = formMethods;
|
|
61
61
|
const handleCancel = useCallback(
|
|
62
62
|
(event) => {
|
|
@@ -74,7 +74,7 @@ function CustomMuiDialog({
|
|
|
74
74
|
const validate = useCallback(
|
|
75
75
|
(data) => {
|
|
76
76
|
onSave(data);
|
|
77
|
-
onClose(
|
|
77
|
+
onClose();
|
|
78
78
|
},
|
|
79
79
|
[onClose, onSave]
|
|
80
80
|
);
|
|
@@ -91,11 +91,16 @@ function CustomMuiDialog({
|
|
|
91
91
|
);
|
|
92
92
|
const handlePopupConfirmation = useCallback(() => {
|
|
93
93
|
setOpenConfirmationPopup(false);
|
|
94
|
-
|
|
94
|
+
if (validatedData) {
|
|
95
|
+
validate(validatedData);
|
|
96
|
+
}
|
|
95
97
|
}, [validate, validatedData]);
|
|
96
|
-
const handleValidationError = (
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
const handleValidationError = useCallback(
|
|
99
|
+
(errors) => {
|
|
100
|
+
onValidationError == null ? void 0 : onValidationError(errors);
|
|
101
|
+
},
|
|
102
|
+
[onValidationError]
|
|
103
|
+
);
|
|
99
104
|
return /* @__PURE__ */ jsxs(
|
|
100
105
|
CustomFormProvider,
|
|
101
106
|
{
|
package/dist/components/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js
CHANGED
|
@@ -36,13 +36,16 @@ function DescriptionModificationDialog({
|
|
|
36
36
|
};
|
|
37
37
|
const onSubmit = useCallback(
|
|
38
38
|
(data) => {
|
|
39
|
+
var _a;
|
|
39
40
|
updateElement(elementUuid, {
|
|
40
|
-
[FieldConstants.DESCRIPTION]: data[FieldConstants.DESCRIPTION].trim()
|
|
41
|
+
[FieldConstants.DESCRIPTION]: ((_a = data[FieldConstants.DESCRIPTION]) == null ? void 0 : _a.trim()) ?? ""
|
|
41
42
|
}).catch((error) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (error instanceof Object && "message" in error && typeof error.message === "string") {
|
|
44
|
+
snackError({
|
|
45
|
+
messageTxt: error.message,
|
|
46
|
+
headerId: "descriptionModificationError"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
46
49
|
});
|
|
47
50
|
},
|
|
48
51
|
[elementUuid, updateElement, snackError]
|
|
@@ -13,14 +13,14 @@ const styles = {
|
|
|
13
13
|
height: "18px"
|
|
14
14
|
})
|
|
15
15
|
};
|
|
16
|
-
function sameRights(
|
|
17
|
-
if (!
|
|
16
|
+
function sameRights(sourceAccessRights, accessRightsToCompare) {
|
|
17
|
+
if (!sourceAccessRights && !accessRightsToCompare) {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
|
-
if (!
|
|
20
|
+
if (!sourceAccessRights || !accessRightsToCompare) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return sourceAccessRights.isPrivate === accessRightsToCompare.isPrivate;
|
|
24
24
|
}
|
|
25
25
|
function flattenDownNodes(n, cef) {
|
|
26
26
|
const subs = cef(n);
|
|
@@ -29,17 +29,17 @@ function flattenDownNodes(n, cef) {
|
|
|
29
29
|
}
|
|
30
30
|
return Array.prototype.concat([n], ...subs.map((sn) => flattenDownNodes(sn, cef)));
|
|
31
31
|
}
|
|
32
|
-
function refreshedUpNodes(
|
|
33
|
-
if (!(
|
|
32
|
+
function refreshedUpNodes(nodeMap, newElement) {
|
|
33
|
+
if (!(newElement == null ? void 0 : newElement.elementUuid)) {
|
|
34
34
|
return [];
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
37
|
-
return [
|
|
36
|
+
if (newElement.parentUuid === null) {
|
|
37
|
+
return [newElement];
|
|
38
38
|
}
|
|
39
|
-
const parent =
|
|
40
|
-
const nextChildren = parent.children.map((c) => c.elementUuid ===
|
|
39
|
+
const parent = nodeMap[newElement.parentUuid];
|
|
40
|
+
const nextChildren = parent.children.map((c) => c.elementUuid === newElement.elementUuid ? newElement : c);
|
|
41
41
|
const nextParent = { ...parent, children: nextChildren };
|
|
42
|
-
return [
|
|
42
|
+
return [newElement, ...refreshedUpNodes(nodeMap, nextParent)];
|
|
43
43
|
}
|
|
44
44
|
function updatedTree(prevRoots, prevMap, nodeId, children) {
|
|
45
45
|
var _a;
|
|
@@ -16,7 +16,7 @@ import * as yup from "yup";
|
|
|
16
16
|
const emptyFormData = {
|
|
17
17
|
[FieldConstants.NAME]: "",
|
|
18
18
|
[FieldConstants.DESCRIPTION]: "",
|
|
19
|
-
[FieldConstants.FILTER_TYPE]: FilterType.
|
|
19
|
+
[FieldConstants.FILTER_TYPE]: FilterType.EXPERT.id,
|
|
20
20
|
[FieldConstants.EQUIPMENT_TYPE]: null,
|
|
21
21
|
...criteriaBasedFilterEmptyFormData,
|
|
22
22
|
...getExplicitNamingFilterEmptyFormData(),
|
|
@@ -13,6 +13,7 @@ function HeaderFilterForm({
|
|
|
13
13
|
elementExists,
|
|
14
14
|
handleFilterTypeChange
|
|
15
15
|
}) {
|
|
16
|
+
const filterTypes = Object.values(FilterType).filter((value) => value.id !== "CRITERIA");
|
|
16
17
|
return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
|
|
17
18
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
|
|
18
19
|
UniqueNameInput,
|
|
@@ -31,7 +32,7 @@ function HeaderFilterForm({
|
|
|
31
32
|
RadioInput,
|
|
32
33
|
{
|
|
33
34
|
name: FieldConstants.FILTER_TYPE,
|
|
34
|
-
options:
|
|
35
|
+
options: filterTypes,
|
|
35
36
|
formProps: { onChange: handleFilterTypeChange }
|
|
36
37
|
}
|
|
37
38
|
) })
|
|
@@ -1,13 +1,49 @@
|
|
|
1
1
|
import { default as yup } from '../../../utils/yupConfig';
|
|
2
2
|
|
|
3
3
|
export declare const criteriaBasedFilterSchema: {
|
|
4
|
-
criteriaBased: yup.ObjectSchema<{
|
|
5
|
-
|
|
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;
|
|
6
28
|
}, yup.AnyObject, {
|
|
7
|
-
|
|
29
|
+
nominalVoltage3: any;
|
|
30
|
+
nominalVoltage2: any;
|
|
31
|
+
nominalVoltage1: any;
|
|
32
|
+
nominalVoltage: any;
|
|
33
|
+
countries: "";
|
|
34
|
+
countries1: "";
|
|
35
|
+
countries2: "";
|
|
8
36
|
}, "">;
|
|
9
37
|
};
|
|
10
38
|
export declare const criteriaBasedFilterEmptyFormData: {
|
|
11
|
-
criteriaBased:
|
|
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;
|
|
47
|
+
};
|
|
12
48
|
};
|
|
13
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,14 +1,63 @@
|
|
|
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
|
+
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;
|
|
6
41
|
}, yup.AnyObject, {
|
|
7
|
-
|
|
42
|
+
nominalVoltage3: any;
|
|
43
|
+
nominalVoltage2: any;
|
|
44
|
+
nominalVoltage1: any;
|
|
45
|
+
nominalVoltage: any;
|
|
46
|
+
countries: "";
|
|
47
|
+
countries1: "";
|
|
48
|
+
countries2: "";
|
|
8
49
|
}, "">;
|
|
9
50
|
};
|
|
10
|
-
export declare
|
|
11
|
-
criteriaBased:
|
|
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;
|
|
60
|
+
};
|
|
12
61
|
};
|
|
13
62
|
/**
|
|
14
63
|
* Transform
|
|
@@ -21,9 +70,17 @@ export declare const getCriteriaBasedFormData: (criteriaValues: any, extraFields
|
|
|
21
70
|
* {name_property:namesB, prop_values:valuesB}]
|
|
22
71
|
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
23
72
|
*/
|
|
24
|
-
export declare
|
|
25
|
-
criteriaBased:
|
|
26
|
-
|
|
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;
|
|
82
|
+
};
|
|
83
|
+
readonly equipmentType: any;
|
|
27
84
|
};
|
|
28
85
|
/**
|
|
29
86
|
* Transform
|
|
@@ -36,8 +93,8 @@ export declare const backToFrontTweak: (response: any) => {
|
|
|
36
93
|
* freeProperties2.{nameA:valuesC}}
|
|
37
94
|
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
38
95
|
*/
|
|
39
|
-
export declare
|
|
96
|
+
export declare function frontToBackTweak(id?: string, filter?: any): {
|
|
40
97
|
id: string | undefined;
|
|
41
98
|
type: string;
|
|
42
|
-
equipmentFilterForm:
|
|
99
|
+
equipmentFilterForm: any;
|
|
43
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,
|
|
@@ -129,7 +129,6 @@ export declare enum FieldType {
|
|
|
129
129
|
SUBSTATION_PROPERTY = "SUBSTATION_PROPERTIES",
|
|
130
130
|
SUBSTATION_PROPERTY_1 = "SUBSTATION_PROPERTIES_1",
|
|
131
131
|
SUBSTATION_PROPERTY_2 = "SUBSTATION_PROPERTIES_2",
|
|
132
|
-
SUBSTATION_PROPERTY_3 = "SUBSTATION_PROPERTIES_3",
|
|
133
132
|
VOLTAGE_LEVEL_PROPERTY = "VOLTAGE_LEVEL_PROPERTIES",
|
|
134
133
|
VOLTAGE_LEVEL_PROPERTY_1 = "VOLTAGE_LEVEL_PROPERTIES_1",
|
|
135
134
|
VOLTAGE_LEVEL_PROPERTY_2 = "VOLTAGE_LEVEL_PROPERTIES_2",
|
|
@@ -128,7 +128,6 @@ var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
|
128
128
|
FieldType2["SUBSTATION_PROPERTY"] = "SUBSTATION_PROPERTIES";
|
|
129
129
|
FieldType2["SUBSTATION_PROPERTY_1"] = "SUBSTATION_PROPERTIES_1";
|
|
130
130
|
FieldType2["SUBSTATION_PROPERTY_2"] = "SUBSTATION_PROPERTIES_2";
|
|
131
|
-
FieldType2["SUBSTATION_PROPERTY_3"] = "SUBSTATION_PROPERTIES_3";
|
|
132
131
|
FieldType2["VOLTAGE_LEVEL_PROPERTY"] = "VOLTAGE_LEVEL_PROPERTIES";
|
|
133
132
|
FieldType2["VOLTAGE_LEVEL_PROPERTY_1"] = "VOLTAGE_LEVEL_PROPERTIES_1";
|
|
134
133
|
FieldType2["VOLTAGE_LEVEL_PROPERTY_2"] = "VOLTAGE_LEVEL_PROPERTIES_2";
|
|
@@ -870,13 +870,6 @@ export declare const FIELDS_OPTIONS: {
|
|
|
870
870
|
valueEditorType: string;
|
|
871
871
|
defaultValue: string;
|
|
872
872
|
};
|
|
873
|
-
SUBSTATION_PROPERTY_3: {
|
|
874
|
-
name: FieldType;
|
|
875
|
-
label: string;
|
|
876
|
-
dataType: DataType;
|
|
877
|
-
valueEditorType: string;
|
|
878
|
-
defaultValue: string;
|
|
879
|
-
};
|
|
880
873
|
VOLTAGE_LEVEL_PROPERTY: {
|
|
881
874
|
name: FieldType;
|
|
882
875
|
label: string;
|
|
@@ -830,13 +830,6 @@ const FIELDS_OPTIONS = {
|
|
|
830
830
|
valueEditorType: "select",
|
|
831
831
|
defaultValue: ""
|
|
832
832
|
},
|
|
833
|
-
SUBSTATION_PROPERTY_3: {
|
|
834
|
-
name: FieldType.SUBSTATION_PROPERTY_3,
|
|
835
|
-
label: "substationProperty3Twt",
|
|
836
|
-
dataType: DataType.PROPERTY,
|
|
837
|
-
valueEditorType: "select",
|
|
838
|
-
defaultValue: ""
|
|
839
|
-
},
|
|
840
833
|
VOLTAGE_LEVEL_PROPERTY: {
|
|
841
834
|
name: FieldType.VOLTAGE_LEVEL_PROPERTY,
|
|
842
835
|
label: "voltageLevelProperty",
|
|
@@ -1095,8 +1088,7 @@ const EXPERT_FILTER_FIELDS = {
|
|
|
1095
1088
|
FIELDS_OPTIONS.PHASE_REGULATION_MODE,
|
|
1096
1089
|
FIELDS_OPTIONS.PHASE_REGULATION_VALUE,
|
|
1097
1090
|
FIELDS_OPTIONS.PROPERTY,
|
|
1098
|
-
FIELDS_OPTIONS.
|
|
1099
|
-
FIELDS_OPTIONS.SUBSTATION_PROPERTY_2,
|
|
1091
|
+
FIELDS_OPTIONS.SUBSTATION_PROPERTY,
|
|
1100
1092
|
FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_1,
|
|
1101
1093
|
FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_2
|
|
1102
1094
|
],
|
|
@@ -1178,15 +1170,7 @@ const EXPERT_FILTER_FIELDS = {
|
|
|
1178
1170
|
FIELDS_OPTIONS.PHASE_REGULATION_MODE_2,
|
|
1179
1171
|
FIELDS_OPTIONS.PHASE_REGULATION_MODE_3,
|
|
1180
1172
|
FIELDS_OPTIONS.PROPERTY,
|
|
1181
|
-
|
|
1182
|
-
...FIELDS_OPTIONS.SUBSTATION_PROPERTY_1,
|
|
1183
|
-
label: `${FIELDS_OPTIONS.SUBSTATION_PROPERTY_1.label}Twt`
|
|
1184
|
-
},
|
|
1185
|
-
{
|
|
1186
|
-
...FIELDS_OPTIONS.SUBSTATION_PROPERTY_2,
|
|
1187
|
-
label: `${FIELDS_OPTIONS.SUBSTATION_PROPERTY_2.label}Twt`
|
|
1188
|
-
},
|
|
1189
|
-
FIELDS_OPTIONS.SUBSTATION_PROPERTY_3,
|
|
1173
|
+
FIELDS_OPTIONS.SUBSTATION_PROPERTY,
|
|
1190
1174
|
{
|
|
1191
1175
|
...FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_1,
|
|
1192
1176
|
label: `${FIELDS_OPTIONS.VOLTAGE_LEVEL_PROPERTY_1.label}Twt`
|
|
@@ -72,7 +72,7 @@ function ExplicitNamingFilterEditionDialog({
|
|
|
72
72
|
const onSubmit = useCallback(
|
|
73
73
|
(filterForm) => {
|
|
74
74
|
saveExplicitNamingFilter(
|
|
75
|
-
filterForm[FILTER_EQUIPMENTS_ATTRIBUTES],
|
|
75
|
+
filterForm[FILTER_EQUIPMENTS_ATTRIBUTES] ?? [],
|
|
76
76
|
false,
|
|
77
77
|
filterForm[FieldConstants.EQUIPMENT_TYPE],
|
|
78
78
|
filterForm[FieldConstants.NAME],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UUID } from 'crypto';
|
|
2
2
|
|
|
3
|
-
export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (value
|
|
3
|
+
export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (value?: string) => void, handleClose: () => void, activeDirectory?: UUID, token?: string) => void;
|
|
4
4
|
export declare const saveCriteriaBasedFilter: (filter: any, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
|
|
5
5
|
export declare const saveExpertFilter: (id: string | null, query: any, equipmentType: string, name: string, description: string, isFilterCreation: boolean, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
|
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
|
}
|
|
@@ -80,7 +80,7 @@ function ValueEditor(props) {
|
|
|
80
80
|
}
|
|
81
81
|
if (fieldData.dataType === DataType.PROPERTY) {
|
|
82
82
|
let equipmentType;
|
|
83
|
-
if (field === FieldType.SUBSTATION_PROPERTY || field === FieldType.SUBSTATION_PROPERTY_1 || field === FieldType.SUBSTATION_PROPERTY_2
|
|
83
|
+
if (field === FieldType.SUBSTATION_PROPERTY || field === FieldType.SUBSTATION_PROPERTY_1 || field === FieldType.SUBSTATION_PROPERTY_2) {
|
|
84
84
|
equipmentType = Substation.type;
|
|
85
85
|
} else if (field === FieldType.VOLTAGE_LEVEL_PROPERTY || field === FieldType.VOLTAGE_LEVEL_PROPERTY_1 || field === FieldType.VOLTAGE_LEVEL_PROPERTY_2 || field === FieldType.VOLTAGE_LEVEL_PROPERTY_3) {
|
|
86
86
|
equipmentType = VoltageLevel.type;
|
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,
|
|
@@ -94,7 +94,6 @@ export declare const filterExpertEn: {
|
|
|
94
94
|
substationProperty2: string;
|
|
95
95
|
substationProperty1Twt: string;
|
|
96
96
|
substationProperty2Twt: string;
|
|
97
|
-
substationProperty3Twt: string;
|
|
98
97
|
ratedVoltage1KV: string;
|
|
99
98
|
ratedVoltage2KV: string;
|
|
100
99
|
ratedVoltage0KVTwt: string;
|
|
@@ -88,7 +88,6 @@ const filterExpertEn = {
|
|
|
88
88
|
substationProperty2: "Substation property 2",
|
|
89
89
|
substationProperty1Twt: "Substation property 1",
|
|
90
90
|
substationProperty2Twt: "Substation property 2",
|
|
91
|
-
substationProperty3Twt: "Substation property 3",
|
|
92
91
|
ratedVoltage1KV: "Rated Voltage 1 (kV)",
|
|
93
92
|
ratedVoltage2KV: "Rated Voltage 2 (kV)",
|
|
94
93
|
ratedVoltage0KVTwt: "Rated Voltage 0 (kV)",
|
|
@@ -94,7 +94,6 @@ export declare const filterExpertFr: {
|
|
|
94
94
|
substationProperty2: string;
|
|
95
95
|
substationProperty1Twt: string;
|
|
96
96
|
substationProperty2Twt: string;
|
|
97
|
-
substationProperty3Twt: string;
|
|
98
97
|
ratedVoltage1KV: string;
|
|
99
98
|
ratedVoltage2KV: string;
|
|
100
99
|
ratedVoltage0KVTwt: string;
|
|
@@ -88,7 +88,6 @@ const filterExpertFr = {
|
|
|
88
88
|
substationProperty2: "Propriété site 2",
|
|
89
89
|
substationProperty1Twt: "Propriété site 1",
|
|
90
90
|
substationProperty2Twt: "Propriété site 2",
|
|
91
|
-
substationProperty3Twt: "Propriété site 3",
|
|
92
91
|
ratedVoltage1KV: "Tension d'enroulement 1 (kV)",
|
|
93
92
|
ratedVoltage2KV: "Tension d'enroulement 2 (kV)",
|
|
94
93
|
ratedVoltage0KVTwt: "Tension d'enroulement 0 (kV)",
|