@gridsuite/commons-ui 0.201.0 → 0.203.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.
Files changed (85) hide show
  1. package/dist/components/addButton/AddButton.d.ts +10 -0
  2. package/dist/components/addButton/AddButton.js +16 -0
  3. package/dist/components/addButton/index.d.ts +1 -0
  4. package/dist/components/addButton/index.js +5 -0
  5. package/dist/components/cardErrorBoundary/CardErrorBoundary.d.ts +1 -1
  6. package/dist/components/dialogs/popupConfirmationDialog/PopupConfirmationDialog.d.ts +2 -1
  7. package/dist/components/dialogs/popupConfirmationDialog/PopupConfirmationDialog.js +2 -1
  8. package/dist/components/index.d.ts +1 -0
  9. package/dist/components/index.js +36 -1
  10. package/dist/components/inputs/index.js +0 -2
  11. package/dist/components/inputs/reactHookForm/expandableInput/ExpandableInput.js +3 -28
  12. package/dist/components/inputs/reactHookForm/text/DescriptionField.js +4 -4
  13. package/dist/components/inputs/reactQueryBuilder/index.d.ts +0 -1
  14. package/dist/components/inputs/reactQueryBuilder/index.js +0 -2
  15. package/dist/components/network-modifications/common/activePowerControl/ActivePowerControlForm.d.ts +6 -0
  16. package/dist/components/network-modifications/common/activePowerControl/ActivePowerControlForm.js +97 -0
  17. package/dist/components/network-modifications/common/activePowerControl/activePowerControlForm.type.d.ts +10 -0
  18. package/dist/components/network-modifications/common/activePowerControl/activePowerControlForm.type.js +1 -0
  19. package/dist/components/network-modifications/common/activePowerControl/activePowerControlForm.utils.d.ts +8 -0
  20. package/dist/components/network-modifications/common/activePowerControl/activePowerControlForm.utils.js +26 -0
  21. package/dist/components/network-modifications/common/activePowerControl/index.d.ts +9 -0
  22. package/dist/components/network-modifications/common/activePowerControl/index.js +7 -0
  23. package/dist/components/network-modifications/common/connectivity/BranchConnectivityForm.js +0 -2
  24. package/dist/components/network-modifications/common/connectivity/ConnectivityForm.d.ts +9 -17
  25. package/dist/components/network-modifications/common/connectivity/ConnectivityForm.js +56 -219
  26. package/dist/components/network-modifications/common/connectivity/PositionForm.d.ts +11 -0
  27. package/dist/components/network-modifications/common/connectivity/PositionForm.js +111 -0
  28. package/dist/components/network-modifications/common/connectivity/VoltageLevelConnectivityForm.d.ts +13 -0
  29. package/dist/components/network-modifications/common/connectivity/VoltageLevelConnectivityForm.js +164 -0
  30. package/dist/components/network-modifications/common/connectivity/connectivityForm.utils.js +3 -3
  31. package/dist/components/network-modifications/common/connectivity/index.d.ts +1 -0
  32. package/dist/components/network-modifications/common/connectivity/index.js +2 -0
  33. package/dist/components/network-modifications/common/index.d.ts +3 -0
  34. package/dist/components/network-modifications/common/index.js +35 -1
  35. package/dist/components/network-modifications/common/reactiveLimits/ReactiveLimitsForm.d.ts +8 -0
  36. package/dist/components/network-modifications/common/reactiveLimits/ReactiveLimitsForm.js +102 -0
  37. package/dist/components/network-modifications/common/reactiveLimits/index.d.ts +10 -0
  38. package/dist/components/network-modifications/common/reactiveLimits/index.js +23 -0
  39. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveRowForm.d.ts +12 -0
  40. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveRowForm.js +101 -0
  41. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveTableForm.d.ts +10 -0
  42. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/ReactiveCapabilityCurveTableForm.js +118 -0
  43. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/index.d.ts +9 -0
  44. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/index.js +15 -0
  45. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.d.ts +20 -0
  46. package/dist/components/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.js +152 -0
  47. package/dist/components/network-modifications/common/reactiveLimits/reactiveLimits.type.d.ts +21 -0
  48. package/dist/components/network-modifications/common/reactiveLimits/reactiveLimits.type.js +1 -0
  49. package/dist/components/network-modifications/common/reactiveLimits/reactiveLimits.utils.d.ts +55 -0
  50. package/dist/components/network-modifications/common/reactiveLimits/reactiveLimits.utils.js +66 -0
  51. package/dist/components/network-modifications/common/setpoints/setPoints.utils.js +3 -3
  52. package/dist/components/network-modifications/common/shortCircuit/ShortCircuitForm.d.ts +5 -0
  53. package/dist/components/network-modifications/common/shortCircuit/ShortCircuitForm.js +68 -0
  54. package/dist/components/network-modifications/common/shortCircuit/index.d.ts +9 -0
  55. package/dist/components/network-modifications/common/shortCircuit/index.js +8 -0
  56. package/dist/components/network-modifications/common/shortCircuit/shortCircuitForm.type.d.ts +10 -0
  57. package/dist/components/network-modifications/common/shortCircuit/shortCircuitForm.type.js +1 -0
  58. package/dist/components/network-modifications/common/shortCircuit/shortCircuitForm.utils.d.ts +15 -0
  59. package/dist/components/network-modifications/common/shortCircuit/shortCircuitForm.utils.js +37 -0
  60. package/dist/components/network-modifications/generator/creation/generatorCreation.types.d.ts +40 -0
  61. package/dist/components/network-modifications/generator/creation/generatorCreation.types.js +1 -0
  62. package/dist/components/network-modifications/generator/creation/index.d.ts +7 -0
  63. package/dist/components/network-modifications/generator/creation/index.js +1 -0
  64. package/dist/components/network-modifications/generator/generatorDialog.type.d.ts +102 -0
  65. package/dist/components/network-modifications/generator/generatorDialog.type.js +1 -0
  66. package/dist/components/network-modifications/generator/index.d.ts +9 -0
  67. package/dist/components/network-modifications/generator/index.js +1 -0
  68. package/dist/components/network-modifications/generator/modification/generatorModification.types.d.ts +41 -0
  69. package/dist/components/network-modifications/generator/modification/generatorModification.types.js +1 -0
  70. package/dist/components/network-modifications/generator/modification/index.d.ts +7 -0
  71. package/dist/components/network-modifications/generator/modification/index.js +1 -0
  72. package/dist/components/network-modifications/index.d.ts +1 -0
  73. package/dist/components/network-modifications/index.js +34 -0
  74. package/dist/components/network-modifications/load/common/LoadDialogTabsContent.js +0 -1
  75. package/dist/components/network-modifications/load/creation/loadCreation.utils.js +1 -1
  76. package/dist/components/network-modifications/voltageLevel/creation/tabs/substationTab/SubstationTab.js +4 -3
  77. package/dist/components/parameters/common/hook/use-parameters-form.js +1 -1
  78. package/dist/index.js +36 -1
  79. package/dist/translations/en/networkModificationsEn.d.ts +26 -0
  80. package/dist/translations/en/networkModificationsEn.js +26 -0
  81. package/dist/translations/fr/networkModificationsFr.d.ts +26 -0
  82. package/dist/translations/fr/networkModificationsFr.js +26 -0
  83. package/dist/utils/constants/fieldConstants.d.ts +22 -1
  84. package/dist/utils/constants/fieldConstants.js +22 -1
  85. package/package.json +1 -1
@@ -1,23 +1,19 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { IconButton, Tooltip, Grid } from "@mui/material";
3
- import { ExploreOutlined, ExploreOffOutlined } from "@mui/icons-material";
4
- import { useState, useRef, useMemo, useEffect, useCallback } from "react";
5
- import { useWatch } from "react-hook-form";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Grid } from "@mui/material";
3
+ import { useMemo } from "react";
6
4
  import { useIntl } from "react-intl";
7
- import { getConnectivityVoltageLevelData, getConnectivityBusBarSectionData } from "./connectivityForm.utils.js";
8
- import { fetchBusBarSectionsForNewCoupler } from "../../../../services/networkModification.js";
9
5
  import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
10
6
  import "../../../../utils/conversionUtils.js";
11
7
  import { getConnectionDirectionLabel, CONNECTION_DIRECTIONS } from "../../../../utils/types/equipmentType.js";
12
- import { getObjectId, areIdsEqual } from "../../../../utils/ts-utils.js";
8
+ import "@mui/icons-material";
13
9
  import "../../../../utils/yupConfig.js";
14
10
  import "../../../overflowableText/OverflowableText.js";
11
+ import "react-hook-form";
15
12
  import "localized-countries";
16
13
  import "localized-countries/data/fr";
17
14
  import "localized-countries/data/en";
18
15
  import "notistack";
19
16
  import "../../../inputs/reactHookForm/provider/CustomFormProvider.js";
20
- import { useCustomFormContext } from "../../../inputs/reactHookForm/provider/useCustomFormContext.js";
21
17
  import "yup";
22
18
  import "../../../treeViewFinder/TreeViewFinder.js";
23
19
  import "../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
@@ -25,10 +21,8 @@ import "../../../customAGGrid/customAggrid.js";
25
21
  import "ag-grid-community";
26
22
  import "react-papaparse";
27
23
  import "react-csv-downloader";
28
- import { AutocompleteInput } from "../../../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
29
24
  import { SwitchInput } from "../../../inputs/reactHookForm/booleans/SwitchInput.js";
30
25
  import { TextInput } from "../../../inputs/reactHookForm/text/TextInput.js";
31
- import { IntegerInput } from "../../../inputs/reactHookForm/numbers/IntegerInput.js";
32
26
  import "../../../inputs/reactHookForm/numbers/RangeInput.js";
33
27
  import { SelectInput } from "../../../inputs/reactHookForm/selectInputs/SelectInput.js";
34
28
  import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
@@ -44,12 +38,11 @@ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
44
38
  import "uuid";
45
39
  import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
46
40
  import "react-querybuilder";
41
+ import { PositionForm } from "./PositionForm.js";
42
+ import { VoltageLevelConnectivityForm } from "./VoltageLevelConnectivityForm.js";
47
43
  function ConnectivityForm({
48
44
  id = FieldConstants.CONNECTIVITY,
49
45
  voltageLevelSelectLabel = "VOLTAGE_LEVEL",
50
- direction = "row",
51
- withDirectionsInfos = true,
52
- withPosition = false,
53
46
  onVoltageLevelChangeCallback = void 0,
54
47
  isEquipmentModification = false,
55
48
  previousValues,
@@ -57,221 +50,65 @@ function ConnectivityForm({
57
50
  PositionDiagramPane,
58
51
  fetchBusesOrBusbarSections
59
52
  }) {
60
- const [busOrBusbarSectionOptions, setBusOrBusbarSectionOptions] = useState([]);
61
- const [isDiagramPaneOpen, setIsDiagramPaneOpen] = useState(false);
62
- const lastFetchedBusesVlIds = useRef(null);
63
53
  const intl = useIntl();
64
- const { getValues, isNodeBuilt, setValue } = useCustomFormContext();
65
- const watchVoltageLevelId = useWatch({
66
- name: `${id}.${FieldConstants.VOLTAGE_LEVEL}.${FieldConstants.ID}`
67
- });
68
- const vlOptions = useMemo(
69
- () => voltageLevelOptions.map((item) => ({
70
- id: item.id,
71
- label: item.name ?? "",
72
- exist: item.exist
73
- })),
74
- [voltageLevelOptions]
75
- );
76
- useEffect(() => {
77
- if (watchVoltageLevelId) {
78
- const selectedOption = voltageLevelOptions.find((option) => option.id === watchVoltageLevelId);
79
- if (selectedOption) {
80
- if (selectedOption.exist === false) {
81
- fetchBusBarSectionsForNewCoupler(
82
- watchVoltageLevelId,
83
- selectedOption.busbarCount,
84
- selectedOption.sectionCount,
85
- selectedOption.switchKinds
86
- ).then((ids) => {
87
- lastFetchedBusesVlIds.current = watchVoltageLevelId;
88
- setBusOrBusbarSectionOptions(ids.map((bbsId) => ({ id: bbsId, label: "" })));
89
- }).catch((error) => {
90
- console.error("Failed to fetch busbar sections for new coupler:", error);
91
- setBusOrBusbarSectionOptions([]);
92
- });
93
- } else if (fetchBusesOrBusbarSections) {
94
- fetchBusesOrBusbarSections(watchVoltageLevelId).then((busesOrbusbarSections) => {
95
- lastFetchedBusesVlIds.current = watchVoltageLevelId;
96
- setBusOrBusbarSectionOptions(
97
- busesOrbusbarSections?.map((busesOrbusbarSection) => ({
98
- id: busesOrbusbarSection.id,
99
- label: busesOrbusbarSection?.name ?? ""
100
- })) || []
101
- );
102
- }).catch((error) => {
103
- console.error("Failed to fetch buses or busbar sections:", error);
104
- setBusOrBusbarSectionOptions([]);
105
- });
106
- }
107
- }
108
- if (watchVoltageLevelId !== lastFetchedBusesVlIds.current) {
109
- setBusOrBusbarSectionOptions([]);
110
- }
111
- } else {
112
- setBusOrBusbarSectionOptions([]);
113
- }
114
- }, [fetchBusesOrBusbarSections, voltageLevelOptions, watchVoltageLevelId]);
115
- const handleChangeVoltageLevel = useCallback(() => {
116
- onVoltageLevelChangeCallback?.();
117
- setValue(`${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`, null);
118
- }, [id, onVoltageLevelChangeCallback, setValue]);
119
- useEffect(() => {
120
- const currentBusOrBusbarSection = getValues(`${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`);
121
- if (busOrBusbarSectionOptions?.length > 0 && currentBusOrBusbarSection?.id !== null) {
122
- setValue(`${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`, currentBusOrBusbarSection);
123
- }
124
- }, [busOrBusbarSectionOptions, setValue, id, getValues]);
125
- const newVoltageLevelField = /* @__PURE__ */ jsx(
126
- AutocompleteInput,
127
- {
128
- isOptionEqualToValue: areIdsEqual,
129
- outputTransform: (value) => {
130
- if (typeof value === "string") {
131
- const data = getConnectivityVoltageLevelData({ voltageLevelId: value });
132
- return { id: data?.id ?? "", label: "" };
133
- }
134
- return value;
135
- },
136
- previousValue: isEquipmentModification ? previousValues?.voltageLevelId : void 0,
137
- onChangeCallback: handleChangeVoltageLevel,
138
- allowNewValue: true,
139
- forcePopupIcon: true,
140
- selectOnFocus: true,
141
- name: `${id}.${FieldConstants.VOLTAGE_LEVEL}`,
142
- label: voltageLevelSelectLabel,
143
- options: vlOptions,
144
- getOptionLabel: getObjectId,
145
- size: "small"
146
- }
147
- );
148
54
  const previousConnectedField = useMemo(() => {
149
55
  if (!isEquipmentModification || previousValues?.terminalConnected == null) {
150
56
  return null;
151
57
  }
152
58
  return previousValues.terminalConnected ? intl.formatMessage({ id: "connected" }) : intl.formatMessage({ id: "disconnected" });
153
59
  }, [intl, previousValues, isEquipmentModification]);
154
- const connectedField = isEquipmentModification ? /* @__PURE__ */ jsx(
155
- CheckboxNullableInput,
156
- {
157
- name: `${id}.${FieldConstants.CONNECTED}`,
158
- label: "connected",
159
- previousValue: previousConnectedField ?? void 0
160
- }
161
- ) : /* @__PURE__ */ jsx(SwitchInput, { name: `${id}.${FieldConstants.CONNECTED}`, label: "connected" });
162
- const newBusOrBusbarSectionField = /* @__PURE__ */ jsx(
163
- AutocompleteInput,
164
- {
165
- allowNewValue: true,
166
- forcePopupIcon: true,
167
- name: `${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`,
168
- label: "BusBarBus",
169
- options: busOrBusbarSectionOptions,
170
- previousValue: isEquipmentModification ? previousValues?.busOrBusbarSectionId : void 0,
171
- getOptionLabel: getObjectId,
172
- isOptionEqualToValue: areIdsEqual,
173
- inputTransform: (value) => value ?? "",
174
- outputTransform: (value) => {
175
- if (typeof value === "string") {
176
- const data = getConnectivityBusBarSectionData({ busbarSectionId: value });
177
- return { id: data?.id ?? "", label: "" };
178
- }
179
- return value;
180
- },
181
- size: "small"
182
- }
183
- );
184
- const newConnectionNameField = /* @__PURE__ */ jsx(
185
- TextInput,
186
- {
187
- name: `${id}.${FieldConstants.CONNECTION_NAME}`,
188
- label: "ConnectionName",
189
- previousValue: isEquipmentModification ? previousValues?.connectablePosition?.connectionName ?? void 0 : void 0
190
- }
191
- );
192
60
  const previousConnectionDirectionLabel = isEquipmentModification ? getConnectionDirectionLabel(previousValues?.connectablePosition?.connectionDirection) ?? null : null;
193
- const newConnectionDirectionField = /* @__PURE__ */ jsx(
194
- SelectInput,
195
- {
196
- name: `${id}.${FieldConstants.CONNECTION_DIRECTION}`,
197
- label: "ConnectionDirection",
198
- options: Object.values(CONNECTION_DIRECTIONS),
199
- previousValue: (previousConnectionDirectionLabel && intl.formatMessage({
200
- id: previousConnectionDirectionLabel
201
- })) ?? void 0,
202
- fullWidth: true,
203
- size: "small"
204
- }
205
- );
206
- const handleClickOpenDiagramPane = useCallback(() => {
207
- setIsDiagramPaneOpen(true);
208
- }, []);
209
- const handleCloseDiagramPane = useCallback(() => {
210
- setIsDiagramPaneOpen(false);
211
- }, []);
212
- const newConnectionPositionField = /* @__PURE__ */ jsx(
213
- IntegerInput,
214
- {
215
- name: `${id}.${FieldConstants.CONNECTION_POSITION}`,
216
- label: "ConnectionPosition",
217
- previousValue: isEquipmentModification ? previousValues?.connectablePosition?.connectionPosition ?? void 0 : void 0,
218
- clearable: true
219
- }
220
- );
221
- const voltageLevelForPositionIcon = useMemo(
222
- () => watchVoltageLevelId ?? (isEquipmentModification ? previousValues?.voltageLevelId : void 0),
223
- [watchVoltageLevelId, isEquipmentModification, previousValues?.voltageLevelId]
224
- );
225
- const getPositionIconTooltipMessageId = useMemo(() => {
226
- if (!isNodeBuilt) {
227
- return "NodeNotBuildPositionMessage";
228
- }
229
- if (voltageLevelForPositionIcon) {
230
- return "DisplayTakenPositions";
231
- }
232
- return "NoVoltageLevelPositionMessage";
233
- }, [isNodeBuilt, voltageLevelForPositionIcon]);
234
- const newPositionIconField = /* @__PURE__ */ jsx(
235
- IconButton,
236
- {
237
- ...isNodeBuilt && voltageLevelForPositionIcon && { onClick: handleClickOpenDiagramPane },
238
- disableRipple: !isNodeBuilt || !voltageLevelForPositionIcon,
239
- edge: "start",
240
- children: /* @__PURE__ */ jsx(
241
- Tooltip,
242
- {
243
- title: intl.formatMessage({
244
- id: getPositionIconTooltipMessageId
245
- }),
246
- children: isNodeBuilt && voltageLevelForPositionIcon ? /* @__PURE__ */ jsx(ExploreOutlined, { color: "action" }) : /* @__PURE__ */ jsx(ExploreOffOutlined, { color: "action" })
247
- }
248
- )
249
- }
250
- );
251
- const gridSize = direction && (direction === "column" || direction === "column-reverse") ? 24 : 12;
252
- const conditionalSize = withPosition && withDirectionsInfos ? 8 : gridSize;
253
- return /* @__PURE__ */ jsxs(Fragment, { children: [
254
- /* @__PURE__ */ jsxs(Grid, { container: true, direction: direction || "row", spacing: 2, columns: 24, children: [
255
- /* @__PURE__ */ jsx(Grid, { item: true, xs: conditionalSize, sx: { align: "start" }, children: newVoltageLevelField }),
256
- /* @__PURE__ */ jsx(Grid, { item: true, xs: conditionalSize, sx: { align: "start" }, children: newBusOrBusbarSectionField }),
257
- withDirectionsInfos && /* @__PURE__ */ jsxs(Fragment, { children: [
258
- /* @__PURE__ */ jsx(Grid, { item: true, xs: conditionalSize, sx: { align: "start" }, children: connectedField }),
259
- /* @__PURE__ */ jsx(Grid, { item: true, xs: conditionalSize, sx: { align: "start" }, children: newConnectionNameField }),
260
- /* @__PURE__ */ jsx(Grid, { item: true, xs: conditionalSize, sx: { align: "start" }, children: newConnectionDirectionField }),
261
- withPosition && /* @__PURE__ */ jsxs(Fragment, { children: [
262
- /* @__PURE__ */ jsx(Grid, { xs: conditionalSize - 1, item: true, sx: { align: "start" }, children: newConnectionPositionField }),
263
- PositionDiagramPane && /* @__PURE__ */ jsx(Grid, { xs: 1, item: true, sx: { align: "start" }, children: newPositionIconField })
264
- ] })
265
- ] })
266
- ] }),
267
- PositionDiagramPane && /* @__PURE__ */ jsx(
268
- PositionDiagramPane,
61
+ return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
62
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 8, children: /* @__PURE__ */ jsx(
63
+ VoltageLevelConnectivityForm,
64
+ {
65
+ id,
66
+ voltageLevelSelectLabel,
67
+ onVoltageLevelChangeCallback,
68
+ isEquipmentModification,
69
+ previousValues,
70
+ voltageLevelOptions,
71
+ fetchBusesOrBusbarSections
72
+ }
73
+ ) }),
74
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 4, children: isEquipmentModification ? /* @__PURE__ */ jsx(
75
+ CheckboxNullableInput,
76
+ {
77
+ name: `${id}.${FieldConstants.CONNECTED}`,
78
+ label: "connected",
79
+ previousValue: previousConnectedField ?? void 0
80
+ }
81
+ ) : /* @__PURE__ */ jsx(SwitchInput, { name: `${id}.${FieldConstants.CONNECTED}`, label: "connected" }) }),
82
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 4, children: /* @__PURE__ */ jsx(
83
+ TextInput,
84
+ {
85
+ name: `${id}.${FieldConstants.CONNECTION_NAME}`,
86
+ label: "ConnectionName",
87
+ previousValue: isEquipmentModification ? previousValues?.connectablePosition?.connectionName ?? void 0 : void 0
88
+ }
89
+ ) }),
90
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 4, children: /* @__PURE__ */ jsx(
91
+ SelectInput,
92
+ {
93
+ name: `${id}.${FieldConstants.CONNECTION_DIRECTION}`,
94
+ label: "ConnectionDirection",
95
+ options: Object.values(CONNECTION_DIRECTIONS),
96
+ previousValue: (previousConnectionDirectionLabel && intl.formatMessage({
97
+ id: previousConnectionDirectionLabel
98
+ })) ?? void 0,
99
+ fullWidth: true,
100
+ size: "small"
101
+ }
102
+ ) }),
103
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 4, children: /* @__PURE__ */ jsx(
104
+ PositionForm,
269
105
  {
270
- open: isDiagramPaneOpen,
271
- onClose: handleCloseDiagramPane,
272
- voltageLevelId: voltageLevelForPositionIcon
106
+ id,
107
+ PositionDiagramPane,
108
+ previousValues,
109
+ isEquipmentModification
273
110
  }
274
- )
111
+ ) })
275
112
  ] });
276
113
  }
277
114
  export {
@@ -0,0 +1,11 @@
1
+ import { ConnectablePositionFormInfos, ConnectivityNetworkProps } from './connectivity.type';
2
+ interface PositionFormProps extends Pick<ConnectivityNetworkProps, 'PositionDiagramPane'> {
3
+ id?: string;
4
+ isEquipmentModification?: boolean;
5
+ previousValues?: {
6
+ connectablePosition?: ConnectablePositionFormInfos;
7
+ voltageLevelId?: string;
8
+ };
9
+ }
10
+ export declare function PositionForm({ id, isEquipmentModification, previousValues, PositionDiagramPane, }: Readonly<PositionFormProps>): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,111 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { Grid, IconButton, Tooltip } from "@mui/material";
3
+ import { ExploreOutlined, ExploreOffOutlined } from "@mui/icons-material";
4
+ import { useState, useCallback, useMemo } from "react";
5
+ import { useWatch } from "react-hook-form";
6
+ import { useIntl } from "react-intl";
7
+ import "../../../overflowableText/OverflowableText.js";
8
+ import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
9
+ import "../../../../utils/conversionUtils.js";
10
+ import "../../../../utils/types/equipmentType.js";
11
+ import "../../../../utils/yupConfig.js";
12
+ import "localized-countries";
13
+ import "localized-countries/data/fr";
14
+ import "localized-countries/data/en";
15
+ import "notistack";
16
+ import "../../../inputs/reactHookForm/provider/CustomFormProvider.js";
17
+ import { useCustomFormContext } from "../../../inputs/reactHookForm/provider/useCustomFormContext.js";
18
+ import "yup";
19
+ import "../../../treeViewFinder/TreeViewFinder.js";
20
+ import "../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
21
+ import "../../../customAGGrid/customAggrid.js";
22
+ import "ag-grid-community";
23
+ import "react-papaparse";
24
+ import "react-csv-downloader";
25
+ import { IntegerInput } from "../../../inputs/reactHookForm/numbers/IntegerInput.js";
26
+ import "../../../inputs/reactHookForm/numbers/RangeInput.js";
27
+ import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
28
+ import "@material-symbols/svg-400/outlined/arrows_output.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 "../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
32
+ import "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
33
+ import "@react-querybuilder/material";
34
+ import "../../../filter/expert/expertFilterConstants.js";
35
+ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
36
+ import "uuid";
37
+ import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
38
+ import "react-querybuilder";
39
+ function PositionForm({
40
+ id = FieldConstants.CONNECTIVITY,
41
+ isEquipmentModification = false,
42
+ previousValues,
43
+ PositionDiagramPane
44
+ }) {
45
+ const intl = useIntl();
46
+ const [isDiagramPaneOpen, setIsDiagramPaneOpen] = useState(false);
47
+ const { isNodeBuilt } = useCustomFormContext();
48
+ const watchVoltageLevelId = useWatch({
49
+ name: `${id}.${FieldConstants.VOLTAGE_LEVEL}.${FieldConstants.ID}`
50
+ });
51
+ const handleClickOpenDiagramPane = useCallback(() => {
52
+ setIsDiagramPaneOpen(true);
53
+ }, []);
54
+ const handleCloseDiagramPane = useCallback(() => {
55
+ setIsDiagramPaneOpen(false);
56
+ }, []);
57
+ const voltageLevelForPositionIcon = useMemo(
58
+ () => watchVoltageLevelId ?? (isEquipmentModification ? previousValues?.voltageLevelId : void 0),
59
+ [watchVoltageLevelId, isEquipmentModification, previousValues?.voltageLevelId]
60
+ );
61
+ const getPositionIconTooltipMessageId = useMemo(() => {
62
+ if (!isNodeBuilt) {
63
+ return "NodeNotBuildPositionMessage";
64
+ }
65
+ if (voltageLevelForPositionIcon) {
66
+ return "DisplayTakenPositions";
67
+ }
68
+ return "NoVoltageLevelPositionMessage";
69
+ }, [isNodeBuilt, voltageLevelForPositionIcon]);
70
+ return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
71
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(
72
+ IntegerInput,
73
+ {
74
+ name: `${id}.${FieldConstants.CONNECTION_POSITION}`,
75
+ label: "ConnectionPosition",
76
+ previousValue: isEquipmentModification ? previousValues?.connectablePosition?.connectionPosition ?? void 0 : void 0,
77
+ clearable: true
78
+ }
79
+ ) }),
80
+ PositionDiagramPane && /* @__PURE__ */ jsxs(Fragment, { children: [
81
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 1, children: /* @__PURE__ */ jsx(
82
+ IconButton,
83
+ {
84
+ ...isNodeBuilt && voltageLevelForPositionIcon && { onClick: handleClickOpenDiagramPane },
85
+ disableRipple: !isNodeBuilt || !voltageLevelForPositionIcon,
86
+ edge: "start",
87
+ children: /* @__PURE__ */ jsx(
88
+ Tooltip,
89
+ {
90
+ title: intl.formatMessage({
91
+ id: getPositionIconTooltipMessageId
92
+ }),
93
+ children: isNodeBuilt && voltageLevelForPositionIcon ? /* @__PURE__ */ jsx(ExploreOutlined, { color: "action" }) : /* @__PURE__ */ jsx(ExploreOffOutlined, { color: "action" })
94
+ }
95
+ )
96
+ }
97
+ ) }),
98
+ voltageLevelForPositionIcon && /* @__PURE__ */ jsx(
99
+ PositionDiagramPane,
100
+ {
101
+ open: isDiagramPaneOpen,
102
+ onClose: handleCloseDiagramPane,
103
+ voltageLevelId: voltageLevelForPositionIcon
104
+ }
105
+ )
106
+ ] })
107
+ ] });
108
+ }
109
+ export {
110
+ PositionForm
111
+ };
@@ -0,0 +1,13 @@
1
+ import { ConnectivityNetworkProps } from './connectivity.type';
2
+ export interface VoltageLevelConnectivityFormPreviousValuesProps {
3
+ voltageLevelId?: string;
4
+ busOrBusbarSectionId?: string;
5
+ }
6
+ export interface VoltageLevelConnectivityFormProps extends ConnectivityNetworkProps {
7
+ id?: string;
8
+ voltageLevelSelectLabel?: string;
9
+ onVoltageLevelChangeCallback?: () => void;
10
+ isEquipmentModification?: boolean;
11
+ previousValues?: VoltageLevelConnectivityFormPreviousValuesProps;
12
+ }
13
+ export declare function VoltageLevelConnectivityForm({ id, voltageLevelSelectLabel, onVoltageLevelChangeCallback, isEquipmentModification, previousValues, voltageLevelOptions, fetchBusesOrBusbarSections, }: Readonly<VoltageLevelConnectivityFormProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,164 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Grid } from "@mui/material";
3
+ import { useState, useRef, useCallback, useMemo, useEffect } from "react";
4
+ import { useWatch } from "react-hook-form";
5
+ import "react-intl";
6
+ import "../../../overflowableText/OverflowableText.js";
7
+ import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
8
+ import "../../../../utils/conversionUtils.js";
9
+ import "../../../../utils/types/equipmentType.js";
10
+ import "@mui/icons-material";
11
+ import { getObjectId, areIdsEqual } from "../../../../utils/ts-utils.js";
12
+ import "../../../../utils/yupConfig.js";
13
+ import { fetchBusBarSectionsForNewCoupler } from "../../../../services/networkModification.js";
14
+ import "localized-countries";
15
+ import "localized-countries/data/fr";
16
+ import "localized-countries/data/en";
17
+ import "notistack";
18
+ import "../../../inputs/reactHookForm/provider/CustomFormProvider.js";
19
+ import { useCustomFormContext } from "../../../inputs/reactHookForm/provider/useCustomFormContext.js";
20
+ import "yup";
21
+ import "../../../treeViewFinder/TreeViewFinder.js";
22
+ import "../../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
23
+ import "../../../customAGGrid/customAggrid.js";
24
+ import "ag-grid-community";
25
+ import "react-papaparse";
26
+ import "react-csv-downloader";
27
+ import { AutocompleteInput } from "../../../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
28
+ import "../../../inputs/reactHookForm/numbers/RangeInput.js";
29
+ import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
30
+ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
31
+ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
32
+ import "@material-symbols/svg-400/outlined/add_notes.svg?react";
33
+ import "../../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
34
+ import "../../../inputs/reactHookForm/expandableInput/ExpandableInput.js";
35
+ import "@react-querybuilder/material";
36
+ import "../../../filter/expert/expertFilterConstants.js";
37
+ import "../../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
38
+ import "uuid";
39
+ import "../../../inputs/reactQueryBuilder/PropertyValueEditor.js";
40
+ import "react-querybuilder";
41
+ import { getConnectivityVoltageLevelData, getConnectivityBusBarSectionData } from "./connectivityForm.utils.js";
42
+ function VoltageLevelConnectivityForm({
43
+ id = FieldConstants.CONNECTIVITY,
44
+ voltageLevelSelectLabel = "VOLTAGE_LEVEL",
45
+ onVoltageLevelChangeCallback = void 0,
46
+ isEquipmentModification = false,
47
+ previousValues,
48
+ voltageLevelOptions = [],
49
+ fetchBusesOrBusbarSections
50
+ }) {
51
+ const [busOrBusbarSectionOptions, setBusOrBusbarSectionOptions] = useState([]);
52
+ const { setValue, getValues } = useCustomFormContext();
53
+ const lastFetchedBusesVlIds = useRef(null);
54
+ const watchVoltageLevelId = useWatch({
55
+ name: `${id}.${FieldConstants.VOLTAGE_LEVEL}.${FieldConstants.ID}`
56
+ });
57
+ const handleChangeVoltageLevel = useCallback(() => {
58
+ onVoltageLevelChangeCallback?.();
59
+ setValue(`${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`, null);
60
+ }, [id, onVoltageLevelChangeCallback, setValue]);
61
+ const vlOptions = useMemo(
62
+ () => voltageLevelOptions.map((item) => ({
63
+ id: item.id,
64
+ label: item.name ?? "",
65
+ exist: item.exist
66
+ })),
67
+ [voltageLevelOptions]
68
+ );
69
+ useEffect(() => {
70
+ const currentBusOrBusbarSection = getValues(`${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`);
71
+ if (busOrBusbarSectionOptions?.length > 0 && currentBusOrBusbarSection?.id !== null) {
72
+ setValue(`${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`, currentBusOrBusbarSection);
73
+ }
74
+ }, [busOrBusbarSectionOptions, setValue, id, getValues]);
75
+ useEffect(() => {
76
+ if (watchVoltageLevelId) {
77
+ const selectedOption = voltageLevelOptions.find((option) => option.id === watchVoltageLevelId);
78
+ if (selectedOption) {
79
+ if (selectedOption.exist === false) {
80
+ fetchBusBarSectionsForNewCoupler(
81
+ watchVoltageLevelId,
82
+ selectedOption.busbarCount,
83
+ selectedOption.sectionCount,
84
+ selectedOption.switchKinds
85
+ ).then((ids) => {
86
+ lastFetchedBusesVlIds.current = watchVoltageLevelId;
87
+ setBusOrBusbarSectionOptions(ids.map((bbsId) => ({ id: bbsId, label: "" })));
88
+ }).catch((error) => {
89
+ console.error("Failed to fetch busbar sections for new coupler:", error);
90
+ setBusOrBusbarSectionOptions([]);
91
+ });
92
+ } else if (fetchBusesOrBusbarSections) {
93
+ fetchBusesOrBusbarSections(watchVoltageLevelId).then((busesOrbusbarSections) => {
94
+ lastFetchedBusesVlIds.current = watchVoltageLevelId;
95
+ setBusOrBusbarSectionOptions(
96
+ busesOrbusbarSections?.map((busesOrbusbarSection) => ({
97
+ id: busesOrbusbarSection.id,
98
+ label: busesOrbusbarSection?.name ?? ""
99
+ })) || []
100
+ );
101
+ }).catch((error) => {
102
+ console.error("Failed to fetch buses or busbar sections:", error);
103
+ setBusOrBusbarSectionOptions([]);
104
+ });
105
+ }
106
+ }
107
+ if (watchVoltageLevelId !== lastFetchedBusesVlIds.current) {
108
+ setBusOrBusbarSectionOptions([]);
109
+ }
110
+ } else {
111
+ setBusOrBusbarSectionOptions([]);
112
+ }
113
+ }, [fetchBusesOrBusbarSections, voltageLevelOptions, watchVoltageLevelId]);
114
+ return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
115
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(
116
+ AutocompleteInput,
117
+ {
118
+ isOptionEqualToValue: areIdsEqual,
119
+ outputTransform: (value) => {
120
+ if (typeof value === "string") {
121
+ const data = getConnectivityVoltageLevelData({ voltageLevelId: value });
122
+ return { id: data?.id ?? "", label: "" };
123
+ }
124
+ return value;
125
+ },
126
+ previousValue: isEquipmentModification ? previousValues?.voltageLevelId : void 0,
127
+ onChangeCallback: handleChangeVoltageLevel,
128
+ allowNewValue: true,
129
+ forcePopupIcon: true,
130
+ selectOnFocus: true,
131
+ name: `${id}.${FieldConstants.VOLTAGE_LEVEL}`,
132
+ label: voltageLevelSelectLabel,
133
+ options: vlOptions,
134
+ getOptionLabel: getObjectId,
135
+ size: "small"
136
+ }
137
+ ) }),
138
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(
139
+ AutocompleteInput,
140
+ {
141
+ allowNewValue: true,
142
+ forcePopupIcon: true,
143
+ name: `${id}.${FieldConstants.BUS_OR_BUSBAR_SECTION}`,
144
+ label: "BusBarBus",
145
+ options: busOrBusbarSectionOptions,
146
+ previousValue: isEquipmentModification ? previousValues?.busOrBusbarSectionId : void 0,
147
+ getOptionLabel: getObjectId,
148
+ isOptionEqualToValue: areIdsEqual,
149
+ inputTransform: (value) => value ?? "",
150
+ outputTransform: (value) => {
151
+ if (typeof value === "string") {
152
+ const data = getConnectivityBusBarSectionData({ busbarSectionId: value });
153
+ return { id: data?.id ?? "", label: "" };
154
+ }
155
+ return value;
156
+ },
157
+ size: "small"
158
+ }
159
+ ) })
160
+ ] });
161
+ }
162
+ export {
163
+ VoltageLevelConnectivityForm
164
+ };
@@ -1,6 +1,6 @@
1
1
  import { object, bool, number, string } from "yup";
2
2
  import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
3
- import { YUP_NOT_TYPE_NUMBER } from "../../../../utils/constants/translationKeys.js";
3
+ import { YUP_REQUIRED, YUP_NOT_TYPE_NUMBER } from "../../../../utils/constants/translationKeys.js";
4
4
  import "../../../../utils/conversionUtils.js";
5
5
  import "../../../../utils/types/equipmentType.js";
6
6
  import "react/jsx-runtime";
@@ -9,7 +9,7 @@ import "../../../../utils/yupConfig.js";
9
9
  const getVoltageLevelAndBusOrBusBarSectionFieldsSchema = (isEquipmentModification, relatedFieldName) => {
10
10
  return object().nullable().when({
11
11
  is: () => !isEquipmentModification,
12
- then: (schema) => schema.required()
12
+ then: (schema) => schema.required(YUP_REQUIRED)
13
13
  }).shape({
14
14
  [FieldConstants.ID]: string().when([], {
15
15
  is: () => isEquipmentModification,
@@ -39,7 +39,7 @@ const getConnectivityWithPositionSchema = (isEquipmentModification = false) => o
39
39
  [FieldConstants.CONNECTION_POSITION]: number().typeError(YUP_NOT_TYPE_NUMBER).nullable(),
40
40
  [FieldConstants.CONNECTED]: bool().nullable().when([], {
41
41
  is: () => !isEquipmentModification,
42
- then: (schema) => schema.required()
42
+ then: (schema) => schema.required(YUP_REQUIRED)
43
43
  }),
44
44
  ...getConnectivityPropertiesValidationSchema(isEquipmentModification)
45
45
  });
@@ -8,3 +8,4 @@ export * from './connectivity.type';
8
8
  export * from './connectivityForm.utils';
9
9
  export * from './ConnectivityForm';
10
10
  export * from './BranchConnectivityForm';
11
+ export * from './VoltageLevelConnectivityForm';