@gridsuite/commons-ui 0.255.0 → 0.257.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/dist/components/composite/filter/FilterCreationDialog.js +6 -2
- package/dist/components/composite/filter/HeaderFilterForm.js +3 -2
- package/dist/components/composite/reactQueryBuilder/CustomReactQueryBuilder.js +7 -4
- package/dist/components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js +2 -1
- package/dist/components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js +2 -1
- package/dist/features/index.js +16 -0
- package/dist/features/network-modifications/battery/creation/batteryCreation.utils.js +3 -2
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.d.ts +5 -1
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabsContent.js +50 -10
- package/dist/features/network-modifications/battery/modification/BatteryModificationForm.d.ts +5 -1
- package/dist/features/network-modifications/battery/modification/BatteryModificationForm.js +4 -2
- package/dist/features/network-modifications/battery/modification/batteryModification.types.d.ts +6 -0
- package/dist/features/network-modifications/battery/modification/batteryModification.utils.d.ts +32 -0
- package/dist/features/network-modifications/battery/modification/batteryModification.utils.js +23 -2
- package/dist/features/network-modifications/by-filter/assignment/assignment/assignment-form.js +2 -1
- package/dist/features/network-modifications/by-filter/assignment/assignment/assignment-utils.js +2 -2
- package/dist/features/network-modifications/by-filter/formula/formula/formula-constants.d.ts +10 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-constants.js +10 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-form.d.ts +12 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-form.js +139 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-utils.d.ts +40 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula-utils.js +164 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula.type.d.ts +27 -0
- package/dist/features/network-modifications/by-filter/formula/formula/formula.type.js +1 -0
- package/dist/features/network-modifications/by-filter/formula/formula/reference-autocomplete-input.d.ts +15 -0
- package/dist/features/network-modifications/by-filter/formula/formula/reference-autocomplete-input.js +123 -0
- package/dist/features/network-modifications/by-filter/formula/index.d.ts +11 -0
- package/dist/features/network-modifications/by-filter/formula/index.js +18 -0
- package/dist/features/network-modifications/by-filter/formula/modification-by-formula-form.d.ts +1 -0
- package/dist/features/network-modifications/by-filter/formula/modification-by-formula-form.js +110 -0
- package/dist/features/network-modifications/by-filter/formula/modificationByFormula.utils.d.ts +32 -0
- package/dist/features/network-modifications/by-filter/formula/modificationByFormula.utils.js +126 -0
- package/dist/features/network-modifications/by-filter/index.d.ts +1 -0
- package/dist/features/network-modifications/by-filter/index.js +17 -1
- package/dist/features/network-modifications/common/activePowerControl/activePowerControlForm.utils.js +2 -1
- package/dist/features/network-modifications/common/connectivity/connectivityForm.utils.js +2 -1
- package/dist/features/network-modifications/common/currentLimits/limitsPane.utils.js +2 -1
- package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.js +2 -1
- package/dist/features/network-modifications/common/reactiveLimits/reactiveLimits.utils.js +3 -2
- package/dist/features/network-modifications/common/voltageRegulation/VoltageRegulationForm.js +1 -1
- package/dist/features/network-modifications/common/voltageRegulation/voltageRegulation.utils.js +3 -2
- package/dist/features/network-modifications/generator/creation/generatorCreation.utils.js +4 -3
- package/dist/features/network-modifications/generator/modification/generatorModification.utils.js +5 -4
- package/dist/features/network-modifications/index.js +16 -0
- package/dist/features/network-modifications/line/characteristics/lineCharacteristicsPane.utils.js +7 -6
- package/dist/features/network-modifications/shunt-compensator/common/characteristicsForm.utils.js +7 -6
- package/dist/features/network-modifications/voltageLevel/creation/voltageLevelCreation.utils.js +10 -9
- package/dist/features/network-modifications/voltageLevel/modification/voltageLevelModification.utils.js +6 -5
- package/dist/features/parameters/common/limitreductions/columns-definitions.js +3 -2
- package/dist/features/parameters/dynamic-margin-calculation/loads-variations-parameters.js +2 -2
- package/dist/features/parameters/security-analysis/columns-definitions.js +4 -3
- package/dist/features/parameters/voltage-init/use-voltage-init-parameters-form.js +3 -3
- package/dist/hooks/use-unique-name-validation.js +3 -2
- package/dist/index.js +43 -1
- package/dist/translations/en/descriptionEn.d.ts +0 -6
- package/dist/translations/en/descriptionEn.js +6 -1
- package/dist/translations/en/filterEn.d.ts +0 -2
- package/dist/translations/en/filterEn.js +0 -2
- package/dist/translations/en/generic-validationEn.d.ts +23 -0
- package/dist/translations/en/generic-validationEn.js +25 -0
- package/dist/translations/en/index.d.ts +2 -0
- package/dist/translations/en/index.js +4 -0
- package/dist/translations/en/network-modification-validationEn.d.ts +23 -0
- package/dist/translations/en/network-modification-validationEn.js +31 -0
- package/dist/translations/en/networkModificationsEn.d.ts +16 -30
- package/dist/translations/en/networkModificationsEn.js +10 -35
- package/dist/translations/en/parameters.d.ts +0 -2
- package/dist/translations/en/parameters.js +0 -2
- package/dist/translations/en/use-unique-name-validation-en.d.ts +0 -2
- package/dist/translations/en/use-unique-name-validation-en.js +1 -3
- package/dist/translations/fr/descriptionFr.d.ts +0 -6
- package/dist/translations/fr/descriptionFr.js +6 -1
- package/dist/translations/fr/filterFr.d.ts +0 -2
- package/dist/translations/fr/filterFr.js +0 -2
- package/dist/translations/fr/generic-validationFr.d.ts +17 -0
- package/dist/translations/fr/generic-validationFr.js +25 -0
- package/dist/translations/fr/index.d.ts +2 -0
- package/dist/translations/fr/index.js +4 -0
- package/dist/translations/fr/network-modification-validationFr.d.ts +23 -0
- package/dist/translations/fr/network-modification-validationFr.js +31 -0
- package/dist/translations/fr/networkModificationsFr.d.ts +16 -30
- package/dist/translations/fr/networkModificationsFr.js +10 -35
- package/dist/translations/fr/parameters.d.ts +0 -2
- package/dist/translations/fr/parameters.js +0 -2
- package/dist/translations/fr/use-unique-name-validation-fr.d.ts +0 -2
- package/dist/translations/fr/use-unique-name-validation-fr.js +1 -3
- package/dist/utils/constants/fieldConstants.d.ts +1 -0
- package/dist/utils/constants/fieldConstants.js +1 -0
- package/dist/utils/constants/index.js +19 -1
- package/dist/utils/constants/translationKeys.d.ts +18 -0
- package/dist/utils/constants/translationKeys.js +36 -0
- package/dist/utils/index.js +19 -1
- package/package.json +1 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useWatch } from "react-hook-form";
|
|
3
|
+
import { Grid2 } from "@mui/material";
|
|
4
|
+
import { DragHandle } from "@mui/icons-material";
|
|
5
|
+
import { EQUIPMENTS_FIELDS } from "./formula-utils.js";
|
|
6
|
+
import ReferenceAutocompleteInput from "./reference-autocomplete-input.js";
|
|
7
|
+
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
8
|
+
import { FILTERS } from "../../../../../utils/constants/filterConstant.js";
|
|
9
|
+
import "../../../../../utils/conversionUtils.js";
|
|
10
|
+
import { ElementType } from "../../../../../utils/types/elementType.js";
|
|
11
|
+
import { EquipmentType } from "../../../../../utils/types/equipmentType.js";
|
|
12
|
+
import { getIdOrValue, getLabelOrValue } from "../../../../../utils/ts-utils.js";
|
|
13
|
+
import "react";
|
|
14
|
+
import "react-intl";
|
|
15
|
+
import "localized-countries";
|
|
16
|
+
import "localized-countries/data/fr";
|
|
17
|
+
import "localized-countries/data/en";
|
|
18
|
+
import "notistack";
|
|
19
|
+
import { useFormatLabelWithUnit } from "../../../../../hooks/useFormatLabelWithUnit.js";
|
|
20
|
+
import "../../../../../components/ui/overflowableText/OverflowableText.js";
|
|
21
|
+
import "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
22
|
+
import "yup";
|
|
23
|
+
import { DirectoryItemsInput } from "../../../../../components/ui/reactHookForm/DirectoryItemsInput.js";
|
|
24
|
+
import { AutocompleteInput } from "../../../../../components/ui/reactHookForm/autocompleteInputs/AutocompleteInput.js";
|
|
25
|
+
import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
|
|
26
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
27
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
28
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
29
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
30
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
31
|
+
import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
32
|
+
import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
33
|
+
import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
34
|
+
import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
35
|
+
import "@hello-pangea/dnd";
|
|
36
|
+
import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
37
|
+
import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
38
|
+
import "mui-nested-menu";
|
|
39
|
+
import "react-resizable-panels";
|
|
40
|
+
import "react-papaparse";
|
|
41
|
+
import "react-dom";
|
|
42
|
+
import "autosuggest-highlight/match";
|
|
43
|
+
import "autosuggest-highlight/parse";
|
|
44
|
+
import "clsx";
|
|
45
|
+
import "../../../../../components/composite/filter/FilterCreationDialog.js";
|
|
46
|
+
import "../../../../../components/composite/filter/HeaderFilterForm.js";
|
|
47
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
48
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
49
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
50
|
+
import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
51
|
+
import "react-querybuilder";
|
|
52
|
+
import "uuid";
|
|
53
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
54
|
+
import "../../../../../components/composite/filter/utils/filterFormUtils.js";
|
|
55
|
+
import { GridItem } from "../../../../../components/composite/grid/grid-item.js";
|
|
56
|
+
import "@react-querybuilder/material";
|
|
57
|
+
import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
58
|
+
import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
59
|
+
import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
60
|
+
import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
61
|
+
import "ag-grid-community";
|
|
62
|
+
import "../../../../../components/composite/customAGGrid/customAggrid.js";
|
|
63
|
+
import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
64
|
+
import "mathjs";
|
|
65
|
+
import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
66
|
+
import "react-window";
|
|
67
|
+
import "../../../../../components/composite/report/report-treeview/treeview-item.js";
|
|
68
|
+
import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
69
|
+
import { REFERENCE_FIELD_OR_VALUE_1, OPERATOR, REFERENCE_FIELD_OR_VALUE_2 } from "./formula-constants.js";
|
|
70
|
+
const OPERATOR_OPTIONS = [
|
|
71
|
+
{ id: "ADDITION", label: "+" },
|
|
72
|
+
{ id: "SUBTRACTION", label: "-" },
|
|
73
|
+
{ id: "MULTIPLICATION", label: "*" },
|
|
74
|
+
{ id: "DIVISION", label: "/" },
|
|
75
|
+
{ id: "PERCENTAGE", label: "%" }
|
|
76
|
+
];
|
|
77
|
+
function FormulaForm({ name, index }) {
|
|
78
|
+
const equipmentTypeWatch = useWatch({
|
|
79
|
+
name: FieldConstants.EQUIPMENT_TYPE
|
|
80
|
+
});
|
|
81
|
+
const equipmentFields = EQUIPMENTS_FIELDS[equipmentTypeWatch] ?? [];
|
|
82
|
+
const editableEquipmentFields = equipmentTypeWatch === EquipmentType.TWO_WINDINGS_TRANSFORMER ? EQUIPMENTS_FIELDS[equipmentTypeWatch].filter(
|
|
83
|
+
(field) => field.id !== "RATIO_HIGH_TAP_POSITION" && field.id !== "PHASE_HIGH_TAP_POSITION"
|
|
84
|
+
) ?? [] : EQUIPMENTS_FIELDS[equipmentTypeWatch] ?? [];
|
|
85
|
+
const formatLabelWithUnit = useFormatLabelWithUnit();
|
|
86
|
+
const filtersField = /* @__PURE__ */ jsx(
|
|
87
|
+
DirectoryItemsInput,
|
|
88
|
+
{
|
|
89
|
+
name: `${name}.${index}.${FILTERS}`,
|
|
90
|
+
equipmentTypes: [equipmentTypeWatch],
|
|
91
|
+
elementType: ElementType.FILTER,
|
|
92
|
+
label: "filter",
|
|
93
|
+
titleId: "FiltersListsSelection",
|
|
94
|
+
disable: !equipmentTypeWatch
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
const editedField = /* @__PURE__ */ jsx(
|
|
98
|
+
AutocompleteInput,
|
|
99
|
+
{
|
|
100
|
+
name: `${name}.${index}.${FieldConstants.EDITED_FIELD}`,
|
|
101
|
+
options: editableEquipmentFields,
|
|
102
|
+
label: "EditedField",
|
|
103
|
+
size: "small",
|
|
104
|
+
inputTransform: (value) => editableEquipmentFields.find((option) => option?.id === value) || value,
|
|
105
|
+
outputTransform: (option) => getIdOrValue(option) ?? null,
|
|
106
|
+
getOptionLabel: (option) => formatLabelWithUnit(option)
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
const referenceField1 = /* @__PURE__ */ jsx(ReferenceAutocompleteInput, { name: `${name}.${index}.${REFERENCE_FIELD_OR_VALUE_1}`, options: equipmentFields });
|
|
110
|
+
const inputTransform = (value) => {
|
|
111
|
+
const newVal = value ?? null;
|
|
112
|
+
return OPERATOR_OPTIONS.find((option) => option?.id === getIdOrValue(value)) || newVal;
|
|
113
|
+
};
|
|
114
|
+
const operatorField = /* @__PURE__ */ jsx(
|
|
115
|
+
AutocompleteInput,
|
|
116
|
+
{
|
|
117
|
+
name: `${name}.${index}.${OPERATOR}`,
|
|
118
|
+
options: OPERATOR_OPTIONS,
|
|
119
|
+
readOnly: true,
|
|
120
|
+
label: "Operator",
|
|
121
|
+
size: "small",
|
|
122
|
+
inputTransform,
|
|
123
|
+
outputTransform: getIdOrValue,
|
|
124
|
+
getOptionLabel: getLabelOrValue
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
const referenceField2 = /* @__PURE__ */ jsx(ReferenceAutocompleteInput, { name: `${name}.${index}.${REFERENCE_FIELD_OR_VALUE_2}`, options: equipmentFields });
|
|
128
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
|
+
/* @__PURE__ */ jsx(GridItem, { size: 2.25, children: filtersField }),
|
|
130
|
+
/* @__PURE__ */ jsx(GridItem, { size: 2.25, children: editedField }),
|
|
131
|
+
/* @__PURE__ */ jsx(Grid2, { size: 0.25, sx: { marginTop: 0.75 }, children: /* @__PURE__ */ jsx(DragHandle, {}) }),
|
|
132
|
+
/* @__PURE__ */ jsx(GridItem, { size: 2.5, children: referenceField1 }),
|
|
133
|
+
/* @__PURE__ */ jsx(GridItem, { size: 1.25, children: operatorField }),
|
|
134
|
+
/* @__PURE__ */ jsx(GridItem, { size: 2.5, children: referenceField2 })
|
|
135
|
+
] });
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
FormulaForm as default
|
|
139
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EquipmentType } from '../../../../../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026, RTE (http://www.rte-france.com)
|
|
4
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
|
+
*/
|
|
8
|
+
import * as yup from 'yup';
|
|
9
|
+
export type EquipmentField = {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
unit?: string;
|
|
13
|
+
};
|
|
14
|
+
type EquipmentFieldsKeys = EquipmentType.GENERATOR | EquipmentType.BATTERY | EquipmentType.SHUNT_COMPENSATOR | EquipmentType.VOLTAGE_LEVEL | EquipmentType.LOAD | EquipmentType.TWO_WINDINGS_TRANSFORMER | EquipmentType.LINE;
|
|
15
|
+
type EquipmentFields = {
|
|
16
|
+
[key in EquipmentFieldsKeys]: EquipmentField[];
|
|
17
|
+
};
|
|
18
|
+
export declare const EQUIPMENTS_FIELDS: EquipmentFields;
|
|
19
|
+
export type EquipmentTypeOptionType = keyof typeof EQUIPMENTS_FIELDS;
|
|
20
|
+
export declare const getFormulaInitialValue: () => {
|
|
21
|
+
filters: never[];
|
|
22
|
+
editedField: null;
|
|
23
|
+
referenceFieldOrValue1: null;
|
|
24
|
+
operator: null;
|
|
25
|
+
referenceFieldOrValue2: null;
|
|
26
|
+
};
|
|
27
|
+
export declare function getFormulaSchema(): yup.ArraySchema<{
|
|
28
|
+
filters: {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
specificMetadata: {
|
|
32
|
+
type?: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
}[];
|
|
35
|
+
editedField: string;
|
|
36
|
+
operator: string;
|
|
37
|
+
referenceFieldOrValue1: {};
|
|
38
|
+
referenceFieldOrValue2: {};
|
|
39
|
+
}[] | undefined, yup.AnyObject, "", "">;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
import { OHM, MICRO_SIEMENS, KILO_VOLT, MEGA_VOLT_AMPERE, MEGA_WATT, MEGA_VAR, KILO_AMPERE, SIEMENS, PERCENTAGE } from "../../../../../utils/constants/unitsConstants.js";
|
|
3
|
+
import { FieldConstants } from "../../../../../utils/constants/fieldConstants.js";
|
|
4
|
+
import { FILTERS } from "../../../../../utils/constants/filterConstant.js";
|
|
5
|
+
import { WRONG_REF_OR_VALUE_ERROR, VALUE_MUST_BE_REF_WHEN_PERCENTAGE_ERROR, VALUE_MUST_BE_NUMERIC_WHEN_PERCENTAGE_ERROR, YUP_REQUIRED } from "../../../../../utils/constants/translationKeys.js";
|
|
6
|
+
import "../../../../../utils/conversionUtils.js";
|
|
7
|
+
import { EquipmentType } from "../../../../../utils/types/equipmentType.js";
|
|
8
|
+
import "react/jsx-runtime";
|
|
9
|
+
import "@mui/icons-material";
|
|
10
|
+
import { REFERENCE_FIELD_OR_VALUE_2, OPERATOR, REFERENCE_FIELD_OR_VALUE_1 } from "./formula-constants.js";
|
|
11
|
+
const EQUIPMENTS_FIELDS = {
|
|
12
|
+
[EquipmentType.GENERATOR]: [
|
|
13
|
+
{ id: "RATED_NOMINAL_POWER", label: "RatedNominalPowerText", unit: MEGA_WATT },
|
|
14
|
+
{ id: "MINIMUM_ACTIVE_POWER", label: "MinimumActivePowerText", unit: MEGA_WATT },
|
|
15
|
+
{ id: "MAXIMUM_ACTIVE_POWER", label: "MaximumActivePowerText", unit: MEGA_WATT },
|
|
16
|
+
{ id: "ACTIVE_POWER_SET_POINT", label: "ActivePowerSetPointText", unit: MEGA_WATT },
|
|
17
|
+
{ id: "REACTIVE_POWER_SET_POINT", label: "ReactivePowerSetPointText", unit: MEGA_VAR },
|
|
18
|
+
{ id: "VOLTAGE_SET_POINT", label: "GeneratorTargetV", unit: KILO_VOLT },
|
|
19
|
+
{
|
|
20
|
+
id: "PLANNED_ACTIVE_POWER_SET_POINT",
|
|
21
|
+
label: "PlannedActivePowerSetPointForm",
|
|
22
|
+
unit: MEGA_WATT
|
|
23
|
+
},
|
|
24
|
+
{ id: "MARGINAL_COST", label: "MarginalCost" },
|
|
25
|
+
{ id: "PLANNED_OUTAGE_RATE", label: "plannedOutageRate" },
|
|
26
|
+
{ id: "FORCED_OUTAGE_RATE", label: "forcedOutageRate" },
|
|
27
|
+
{ id: "DROOP", label: "ActivePowerRegulationDroop", unit: PERCENTAGE },
|
|
28
|
+
{ id: "TRANSIENT_REACTANCE", label: "TransientReactanceForm", unit: OHM },
|
|
29
|
+
{
|
|
30
|
+
id: "STEP_UP_TRANSFORMER_REACTANCE",
|
|
31
|
+
label: "TransformerReactanceForm",
|
|
32
|
+
unit: OHM
|
|
33
|
+
},
|
|
34
|
+
{ id: "Q_PERCENT", label: "ReactivePercentageVoltageRegulation", unit: PERCENTAGE }
|
|
35
|
+
],
|
|
36
|
+
[EquipmentType.BATTERY]: [
|
|
37
|
+
{ id: "MINIMUM_ACTIVE_POWER", label: "MinimumActivePowerText", unit: MEGA_WATT },
|
|
38
|
+
{ id: "MAXIMUM_ACTIVE_POWER", label: "MaximumActivePowerText", unit: MEGA_WATT },
|
|
39
|
+
{ id: "ACTIVE_POWER_SET_POINT", label: "ActivePowerSetPointText", unit: MEGA_WATT },
|
|
40
|
+
{ id: "REACTIVE_POWER_SET_POINT", label: "ReactivePowerSetPointText", unit: MEGA_VAR },
|
|
41
|
+
{ id: "DROOP", label: "Droop", unit: PERCENTAGE },
|
|
42
|
+
{ id: "TRANSIENT_REACTANCE", label: "TransientReactanceForm", unit: OHM },
|
|
43
|
+
{
|
|
44
|
+
id: "STEP_UP_TRANSFORMER_REACTANCE",
|
|
45
|
+
label: "TransformerReactanceForm",
|
|
46
|
+
unit: OHM
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
[EquipmentType.SHUNT_COMPENSATOR]: [
|
|
50
|
+
{ id: "MAXIMUM_SECTION_COUNT", label: "maximumSectionCount" },
|
|
51
|
+
{ id: "SECTION_COUNT", label: "sectionCount" },
|
|
52
|
+
{ id: "MAX_SUSCEPTANCE", label: "maxSusceptance", unit: SIEMENS },
|
|
53
|
+
{ id: "MAX_Q_AT_NOMINAL_V", label: "maxQAtNominalV", unit: MEGA_VAR }
|
|
54
|
+
],
|
|
55
|
+
[EquipmentType.VOLTAGE_LEVEL]: [
|
|
56
|
+
{ id: "NOMINAL_VOLTAGE", label: "NominalVoltage", unit: KILO_VOLT },
|
|
57
|
+
{ id: "LOW_VOLTAGE_LIMIT", label: "LowVoltageLimit", unit: KILO_VOLT },
|
|
58
|
+
{ id: "HIGH_VOLTAGE_LIMIT", label: "HighVoltageLimit", unit: KILO_VOLT },
|
|
59
|
+
{
|
|
60
|
+
id: "LOW_SHORT_CIRCUIT_CURRENT_LIMIT",
|
|
61
|
+
label: "LowShortCircuitCurrentLimit",
|
|
62
|
+
unit: KILO_AMPERE
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "HIGH_SHORT_CIRCUIT_CURRENT_LIMIT",
|
|
66
|
+
label: "HighShortCircuitCurrentLimit",
|
|
67
|
+
unit: KILO_AMPERE
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
[EquipmentType.LOAD]: [
|
|
71
|
+
{ id: "ACTIVE_POWER_SET_POINT", label: "ActivePowerSetPointText", unit: MEGA_WATT },
|
|
72
|
+
{ id: "REACTIVE_POWER_SET_POINT", label: "ReactivePowerSetPointText", unit: MEGA_VAR }
|
|
73
|
+
],
|
|
74
|
+
[EquipmentType.TWO_WINDINGS_TRANSFORMER]: [
|
|
75
|
+
{ id: "R", label: "SeriesResistanceText", unit: OHM },
|
|
76
|
+
{ id: "X", label: "SeriesReactanceText", unit: OHM },
|
|
77
|
+
{ id: "G", label: "G", unit: MICRO_SIEMENS },
|
|
78
|
+
{ id: "B", label: "B", unit: MICRO_SIEMENS },
|
|
79
|
+
{ id: "RATED_U1", label: "RatedU1", unit: KILO_VOLT },
|
|
80
|
+
{ id: "RATED_U2", label: "RatedU2", unit: KILO_VOLT },
|
|
81
|
+
{ id: "RATED_S", label: "RatedNominalPowerText", unit: MEGA_VOLT_AMPERE },
|
|
82
|
+
{ id: "TARGET_V", label: "RatioTargetV", unit: KILO_VOLT },
|
|
83
|
+
{ id: "RATIO_LOW_TAP_POSITION", label: "RatioLowTapPosition" },
|
|
84
|
+
{ id: "RATIO_HIGH_TAP_POSITION", label: "RatioHighTapPosition" },
|
|
85
|
+
{ id: "RATIO_TAP_POSITION", label: "RatioTapPosition" },
|
|
86
|
+
{ id: "RATIO_TARGET_DEADBAND", label: "RatioDeadBand", unit: KILO_VOLT },
|
|
87
|
+
{ id: "REGULATION_VALUE", label: "PhaseRegulatingValue" },
|
|
88
|
+
{ id: "PHASE_LOW_TAP_POSITION", label: "PhaseLowTapPosition" },
|
|
89
|
+
{ id: "PHASE_HIGH_TAP_POSITION", label: "PhaseHighTapPosition" },
|
|
90
|
+
{ id: "PHASE_TAP_POSITION", label: "PhaseTapPosition" },
|
|
91
|
+
{ id: "PHASE_TARGET_DEADBAND", label: "PhaseDeadBand" }
|
|
92
|
+
],
|
|
93
|
+
[EquipmentType.LINE]: [
|
|
94
|
+
{ id: "R", label: "SeriesResistanceText", unit: OHM },
|
|
95
|
+
{ id: "X", label: "SeriesReactanceText", unit: OHM },
|
|
96
|
+
{ id: "G1", label: "ShuntConductanceText1", unit: MICRO_SIEMENS },
|
|
97
|
+
{ id: "G2", label: "ShuntConductanceText2", unit: MICRO_SIEMENS },
|
|
98
|
+
{ id: "B1", label: "ShuntSusceptanceText1", unit: MICRO_SIEMENS },
|
|
99
|
+
{ id: "B2", label: "ShuntSusceptanceText2", unit: MICRO_SIEMENS }
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
function isValueInEquipmentFields(context, value) {
|
|
103
|
+
const parent = context.from?.at(-1);
|
|
104
|
+
const equipmentType = parent?.value?.[FieldConstants.EQUIPMENT_TYPE];
|
|
105
|
+
return parent ? (
|
|
106
|
+
// @ts-expect-error missing type in context
|
|
107
|
+
EQUIPMENTS_FIELDS[equipmentType]?.some((field) => field.id === value)
|
|
108
|
+
) : false;
|
|
109
|
+
}
|
|
110
|
+
const checkValueInEquipmentFieldsOrNumeric = (value, context) => {
|
|
111
|
+
const newValue = value.replace(",", ".");
|
|
112
|
+
if (!Number.isNaN(Number.parseFloat(newValue))) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return isValueInEquipmentFields(context, value);
|
|
116
|
+
};
|
|
117
|
+
const checkValueInEquipmentFields = (value, context) => {
|
|
118
|
+
return isValueInEquipmentFields(context, value);
|
|
119
|
+
};
|
|
120
|
+
const getFormulaInitialValue = () => ({
|
|
121
|
+
[FILTERS]: [],
|
|
122
|
+
[FieldConstants.EDITED_FIELD]: null,
|
|
123
|
+
[REFERENCE_FIELD_OR_VALUE_1]: null,
|
|
124
|
+
[OPERATOR]: null,
|
|
125
|
+
[REFERENCE_FIELD_OR_VALUE_2]: null
|
|
126
|
+
});
|
|
127
|
+
function getFormulaSchema() {
|
|
128
|
+
return yup.array().of(
|
|
129
|
+
yup.object().shape({
|
|
130
|
+
[FILTERS]: yup.array().of(
|
|
131
|
+
yup.object().shape({
|
|
132
|
+
[FieldConstants.ID]: yup.string().required(),
|
|
133
|
+
[FieldConstants.NAME]: yup.string().required(),
|
|
134
|
+
[FieldConstants.SPECIFIC_METADATA]: yup.object().shape({
|
|
135
|
+
[FieldConstants.TYPE]: yup.string()
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
).required().min(1, YUP_REQUIRED),
|
|
139
|
+
[FieldConstants.EDITED_FIELD]: yup.string().required(),
|
|
140
|
+
[OPERATOR]: yup.string().required(),
|
|
141
|
+
[REFERENCE_FIELD_OR_VALUE_1]: yup.mixed().required().test("checkRefOrValue", WRONG_REF_OR_VALUE_ERROR, checkValueInEquipmentFieldsOrNumeric).when([OPERATOR], {
|
|
142
|
+
is: "PERCENTAGE",
|
|
143
|
+
then: (schema) => schema.test(
|
|
144
|
+
"checkValueIsReference",
|
|
145
|
+
VALUE_MUST_BE_NUMERIC_WHEN_PERCENTAGE_ERROR,
|
|
146
|
+
(value) => !Number.isNaN(Number.parseFloat(value)) && Number.parseFloat(value) >= 0
|
|
147
|
+
)
|
|
148
|
+
}),
|
|
149
|
+
[REFERENCE_FIELD_OR_VALUE_2]: yup.mixed().required().test("checkRefOrValue", WRONG_REF_OR_VALUE_ERROR, checkValueInEquipmentFieldsOrNumeric).when([OPERATOR], {
|
|
150
|
+
is: "PERCENTAGE",
|
|
151
|
+
then: (schema) => schema.test(
|
|
152
|
+
"checkValueIsReference",
|
|
153
|
+
VALUE_MUST_BE_REF_WHEN_PERCENTAGE_ERROR,
|
|
154
|
+
checkValueInEquipmentFields
|
|
155
|
+
)
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
EQUIPMENTS_FIELDS,
|
|
162
|
+
getFormulaInitialValue,
|
|
163
|
+
getFormulaSchema
|
|
164
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UUID } from 'node:crypto';
|
|
2
|
+
import { ModificationType } from '../../../../../utils';
|
|
3
|
+
export interface FilterInfos {
|
|
4
|
+
id: UUID;
|
|
5
|
+
name: string;
|
|
6
|
+
specificMetadata: {
|
|
7
|
+
type?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface ReferenceFieldOrValue {
|
|
11
|
+
value: number | null;
|
|
12
|
+
equipmentField: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface FormulaInfos {
|
|
15
|
+
id?: UUID;
|
|
16
|
+
fieldOrValue1: ReferenceFieldOrValue;
|
|
17
|
+
fieldOrValue2: ReferenceFieldOrValue;
|
|
18
|
+
filters: FilterInfos[];
|
|
19
|
+
editedField: string;
|
|
20
|
+
operator: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ModificationByFormulaDto {
|
|
23
|
+
type: ModificationType.BY_FORMULA_MODIFICATION;
|
|
24
|
+
uuid?: UUID;
|
|
25
|
+
identifiableType: string;
|
|
26
|
+
formulaInfosList: FormulaInfos[];
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, 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
|
+
interface ReferenceAutocompleteInputProps {
|
|
8
|
+
name: string;
|
|
9
|
+
options: {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
declare function ReferenceAutocompleteInput({ name, options }: ReferenceAutocompleteInputProps): import("react").JSX.Element;
|
|
15
|
+
export default ReferenceAutocompleteInput;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import "../../../../../utils/conversionUtils.js";
|
|
6
|
+
import "../../../../../utils/types/equipmentType.js";
|
|
7
|
+
import "@mui/icons-material";
|
|
8
|
+
import { areIdsEqual } from "../../../../../utils/ts-utils.js";
|
|
9
|
+
import "@mui/material";
|
|
10
|
+
import "../../../../../components/ui/overflowableText/OverflowableText.js";
|
|
11
|
+
import "localized-countries";
|
|
12
|
+
import "localized-countries/data/fr";
|
|
13
|
+
import "localized-countries/data/en";
|
|
14
|
+
import "notistack";
|
|
15
|
+
import "../../../../../components/ui/reactHookForm/provider/CustomFormProvider.js";
|
|
16
|
+
import "yup";
|
|
17
|
+
import "../../../../../components/ui/treeViewFinder/TreeViewFinder.js";
|
|
18
|
+
import { AutocompleteInput } from "../../../../../components/ui/reactHookForm/autocompleteInputs/AutocompleteInput.js";
|
|
19
|
+
import "../../../../../components/ui/reactHookForm/numbers/RangeInput.js";
|
|
20
|
+
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
21
|
+
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
22
|
+
import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
|
|
23
|
+
import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
|
|
24
|
+
import "@material-symbols/svg-400/outlined/add_notes.svg?react";
|
|
25
|
+
import "../../../../../components/ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
26
|
+
import "../../../../../components/ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
27
|
+
import "../../../../../components/ui/reactHookForm/directory-item-input/directory-item-utils.js";
|
|
28
|
+
import "@hello-pangea/dnd";
|
|
29
|
+
import "../../../../../components/ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
30
|
+
import "../../../../../components/ui/snackbarProvider/SnackbarProvider.js";
|
|
31
|
+
import "mui-nested-menu";
|
|
32
|
+
import "react-resizable-panels";
|
|
33
|
+
import "react-papaparse";
|
|
34
|
+
import "react-dom";
|
|
35
|
+
import "autosuggest-highlight/match";
|
|
36
|
+
import "autosuggest-highlight/parse";
|
|
37
|
+
import "clsx";
|
|
38
|
+
import "../../../../../components/composite/filter/FilterCreationDialog.js";
|
|
39
|
+
import "../../../../../components/composite/filter/HeaderFilterForm.js";
|
|
40
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
41
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterForm.js";
|
|
42
|
+
import "../../../../../components/composite/filter/expert/ExpertFilterEditionDialog.js";
|
|
43
|
+
import "../../../../../components/composite/filter/expert/expertFilterConstants.js";
|
|
44
|
+
import "react-querybuilder";
|
|
45
|
+
import "uuid";
|
|
46
|
+
import "../../../../../components/composite/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
47
|
+
import "../../../../../components/composite/filter/utils/filterFormUtils.js";
|
|
48
|
+
import "@react-querybuilder/material";
|
|
49
|
+
import "../../../../../components/composite/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
50
|
+
import "../../../../../components/composite/reactQueryBuilder/PropertyValueEditor.js";
|
|
51
|
+
import "../../../../../components/composite/agGridTable/BottomTableButtons.js";
|
|
52
|
+
import "../../../../../components/composite/agGridTable/CustomAgGridTable.js";
|
|
53
|
+
import "ag-grid-community";
|
|
54
|
+
import "../../../../../components/composite/customAGGrid/customAggrid.js";
|
|
55
|
+
import "../../../../../components/composite/customAGGrid/context/custom-aggrid-context.js";
|
|
56
|
+
import "mathjs";
|
|
57
|
+
import "../../../../../components/composite/report/report-viewer/log-table/log-table.js";
|
|
58
|
+
import "react-window";
|
|
59
|
+
import "../../../../../components/composite/report/report-treeview/treeview-item.js";
|
|
60
|
+
import "../../../../../components/composite/report/report-viewer/context/report-viewer-context.js";
|
|
61
|
+
function ReferenceAutocompleteInput({ name, options }) {
|
|
62
|
+
const intl = useIntl();
|
|
63
|
+
const [displayOptions, setDisplayOptions] = useState(false);
|
|
64
|
+
const {
|
|
65
|
+
fieldState: { error },
|
|
66
|
+
field: { onChange }
|
|
67
|
+
} = useController({
|
|
68
|
+
name
|
|
69
|
+
});
|
|
70
|
+
const handleFilterOptions = useCallback(
|
|
71
|
+
(filteredOptions, state) => {
|
|
72
|
+
if (state.inputValue?.startsWith("#")) {
|
|
73
|
+
const keyword = state.inputValue?.substring(1);
|
|
74
|
+
if (!keyword) {
|
|
75
|
+
return filteredOptions;
|
|
76
|
+
}
|
|
77
|
+
return filteredOptions.filter(
|
|
78
|
+
(option) => intl.formatMessage({ id: state.getOptionLabel(option) }).toLowerCase().startsWith(keyword.toLowerCase())
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return filteredOptions;
|
|
82
|
+
},
|
|
83
|
+
[intl]
|
|
84
|
+
);
|
|
85
|
+
const inputTransform = (value) => options.find((option) => option?.id === value) || value;
|
|
86
|
+
const outputTransform = (value) => {
|
|
87
|
+
return value?.id ?? value;
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
AutocompleteInput,
|
|
91
|
+
{
|
|
92
|
+
name,
|
|
93
|
+
options,
|
|
94
|
+
isOptionEqualToValue: areIdsEqual,
|
|
95
|
+
getOptionLabel: (option) => {
|
|
96
|
+
return option?.label ? intl.formatMessage({ id: option.label }) : option;
|
|
97
|
+
},
|
|
98
|
+
inputTransform,
|
|
99
|
+
outputTransform,
|
|
100
|
+
label: "ReferenceFieldOrValue",
|
|
101
|
+
size: "small",
|
|
102
|
+
open: displayOptions,
|
|
103
|
+
onBlur: () => setDisplayOptions(false),
|
|
104
|
+
allowNewValue: true,
|
|
105
|
+
onInputChange: (event, value) => {
|
|
106
|
+
const displayOption = !!value?.trim()?.startsWith("#");
|
|
107
|
+
setDisplayOptions(displayOption);
|
|
108
|
+
if (value && !Number.isNaN(Number.parseFloat(value))) {
|
|
109
|
+
onChange(value);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
filterOptions: (filteredOptions, state) => handleFilterOptions(filteredOptions, state),
|
|
113
|
+
formProps: {
|
|
114
|
+
helperText: intl.formatMessage({
|
|
115
|
+
id: error?.message ? error.message : "UseDashToSelectField"
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
ReferenceAutocompleteInput as default
|
|
123
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, 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 './modification-by-formula-form';
|
|
8
|
+
export * from './formula/formula-utils';
|
|
9
|
+
export * from './modificationByFormula.utils';
|
|
10
|
+
export * from './formula/formula-constants';
|
|
11
|
+
export * from './formula/formula.type';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ModificationByFormulaForm } from "./modification-by-formula-form.js";
|
|
2
|
+
import { EQUIPMENTS_FIELDS, getFormulaInitialValue, getFormulaSchema } from "./formula/formula-utils.js";
|
|
3
|
+
import { emptyModificationFormData, modificationByFormulaDtoToForm, modificationByFormulaFormSchema, modificationByFormulaFormToDto } from "./modificationByFormula.utils.js";
|
|
4
|
+
import { FORMULAS, OPERATOR, REFERENCE_FIELD_OR_VALUE_1, REFERENCE_FIELD_OR_VALUE_2 } from "./formula/formula-constants.js";
|
|
5
|
+
export {
|
|
6
|
+
EQUIPMENTS_FIELDS,
|
|
7
|
+
FORMULAS,
|
|
8
|
+
ModificationByFormulaForm,
|
|
9
|
+
OPERATOR,
|
|
10
|
+
REFERENCE_FIELD_OR_VALUE_1,
|
|
11
|
+
REFERENCE_FIELD_OR_VALUE_2,
|
|
12
|
+
emptyModificationFormData,
|
|
13
|
+
getFormulaInitialValue,
|
|
14
|
+
getFormulaSchema,
|
|
15
|
+
modificationByFormulaDtoToForm,
|
|
16
|
+
modificationByFormulaFormSchema,
|
|
17
|
+
modificationByFormulaFormToDto
|
|
18
|
+
};
|
package/dist/features/network-modifications/by-filter/formula/modification-by-formula-form.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ModificationByFormulaForm(): import("react").JSX.Element;
|