@gridsuite/commons-ui 0.222.0 → 0.223.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 (38) hide show
  1. package/dist/components/ui/directoryItemSelector/DirectoryItemSelector.d.ts +2 -1
  2. package/dist/components/ui/directoryItemSelector/DirectoryItemSelector.js +2 -0
  3. package/dist/components/ui/treeViewFinder/TreeViewFinder.d.ts +2 -0
  4. package/dist/components/ui/treeViewFinder/TreeViewFinder.js +53 -45
  5. package/dist/features/index.js +9 -1
  6. package/dist/features/network-modification-table/index.js +2 -1
  7. package/dist/features/network-modification-table/network-modifications-table.d.ts +4 -2
  8. package/dist/features/network-modification-table/network-modifications-table.js +54 -6
  9. package/dist/features/network-modification-table/renderers/cell-renderers.d.ts +1 -1
  10. package/dist/features/network-modification-table/renderers/cell-renderers.js +2 -2
  11. package/dist/features/network-modification-table/renderers/name-cell.d.ts +3 -2
  12. package/dist/features/network-modification-table/renderers/name-cell.js +24 -15
  13. package/dist/features/network-modification-table/utils.d.ts +1 -0
  14. package/dist/features/network-modification-table/utils.js +11 -0
  15. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.d.ts +3 -2
  16. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.js +29 -7
  17. package/dist/features/network-modifications/common/regulatingTerminal/RegulatingTerminalForm.js +1 -1
  18. package/dist/features/network-modifications/common/regulatingTerminal/regulatingTerminal.utils.d.ts +4 -4
  19. package/dist/features/network-modifications/generator/creation/GeneratorCreationForm.d.ts +8 -0
  20. package/dist/features/network-modifications/generator/creation/GeneratorCreationForm.js +192 -0
  21. package/dist/features/network-modifications/generator/creation/generatorCreation.types.d.ts +2 -3
  22. package/dist/features/network-modifications/generator/creation/generatorCreation.utils.d.ts +123 -0
  23. package/dist/features/network-modifications/generator/creation/generatorCreation.utils.js +200 -0
  24. package/dist/features/network-modifications/generator/creation/index.d.ts +2 -0
  25. package/dist/features/network-modifications/generator/creation/index.js +9 -1
  26. package/dist/features/network-modifications/generator/generatorDialog.type.d.ts +0 -3
  27. package/dist/features/network-modifications/generator/index.js +9 -1
  28. package/dist/features/network-modifications/index.js +7 -0
  29. package/dist/index.js +12 -2
  30. package/dist/translations/en/networkModificationsEn.d.ts +7 -0
  31. package/dist/translations/en/networkModificationsEn.js +7 -0
  32. package/dist/translations/fr/networkModificationsFr.d.ts +7 -0
  33. package/dist/translations/fr/networkModificationsFr.js +7 -0
  34. package/dist/utils/index.js +3 -1
  35. package/dist/utils/types/equipmentType.d.ts +20 -0
  36. package/dist/utils/types/equipmentType.js +13 -0
  37. package/dist/utils/types/index.js +3 -1
  38. package/package.json +1 -1
@@ -6,6 +6,7 @@ export interface DirectoryItemSelectorProps extends TreeViewFinderProps {
6
6
  equipmentTypes?: string[];
7
7
  itemFilter?: (val: ElementAttributes) => boolean;
8
8
  expanded?: UUID[];
9
+ inline?: boolean;
9
10
  selected?: UUID[];
10
11
  }
11
- export declare function DirectoryItemSelector({ open, types, equipmentTypes, itemFilter, expanded, selected, onClose, ...otherTreeViewFinderProps }: Readonly<DirectoryItemSelectorProps>): import("react/jsx-runtime").JSX.Element;
12
+ export declare function DirectoryItemSelector({ open, inline, types, equipmentTypes, itemFilter, expanded, selected, onClose, ...otherTreeViewFinderProps }: Readonly<DirectoryItemSelectorProps>): import("react/jsx-runtime").JSX.Element;
@@ -112,6 +112,7 @@ function sortHandlingDirectories(a, b) {
112
112
  }
113
113
  function DirectoryItemSelector({
114
114
  open,
115
+ inline,
115
116
  types,
116
117
  equipmentTypes,
117
118
  itemFilter,
@@ -290,6 +291,7 @@ function DirectoryItemSelector({
290
291
  sortMethod: sortHandlingDirectories,
291
292
  multiSelect: true,
292
293
  open,
294
+ inline,
293
295
  expanded: autoExpandedNodes,
294
296
  onlyLeaves: true,
295
297
  selected,
@@ -35,5 +35,7 @@ export interface TreeViewFinderProps {
35
35
  data?: TreeViewFinderNodeProps[];
36
36
  onTreeBrowse?: (itemId: string) => void;
37
37
  sortMethod?: (a: TreeViewFinderNodeProps, b: TreeViewFinderNodeProps) => number;
38
+ inline?: boolean;
39
+ onSelectionChange?: (nodes: TreeViewFinderNodeProps[]) => void;
38
40
  }
39
41
  export declare const TreeViewFinder: import('@emotion/styled').StyledComponent<Readonly<TreeViewFinderProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
@@ -1,7 +1,7 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useState, useRef, useCallback, useEffect } from "react";
3
3
  import { useIntl } from "react-intl";
4
- import { styled, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Typography } from "@mui/material";
4
+ import { styled, Button, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Typography } from "@mui/material";
5
5
  import { SimpleTreeView, TreeItem } from "@mui/x-tree-view";
6
6
  import { ExpandMore, ChevronRight, Check } from "@mui/icons-material";
7
7
  import { toNestedGlobalSelectors, makeComposeClasses } from "../../../utils/styles.js";
@@ -60,7 +60,9 @@ function TreeViewFinderComponant(props) {
60
60
  className,
61
61
  cancelButtonProps,
62
62
  selected: selectedProp,
63
- expanded: expandedProp
63
+ expanded: expandedProp,
64
+ inline = false,
65
+ onSelectionChange
64
66
  } = props;
65
67
  const [mapPrintedNodes, setMapPrintedNodes] = useState({});
66
68
  const [expanded, setExpanded] = useState(defaultExpanded ?? []);
@@ -171,15 +173,21 @@ function TreeViewFinderComponant(props) {
171
173
  }
172
174
  }, [expanded, selectedProp, expandedProp, data, autoScrollAllowed]);
173
175
  const handleNodeSelect = (_e, values) => {
176
+ let newSelected = [];
174
177
  if (multiSelect && Array.isArray(values)) {
175
- setSelected(values.filter((itemId) => isSelectable(mapPrintedNodes[itemId])));
178
+ newSelected = values.filter((itemId) => isSelectable(mapPrintedNodes[itemId]));
176
179
  } else if (typeof values === "string") {
177
180
  if (selected?.includes(values)) {
178
- setSelected([]);
181
+ newSelected = [];
179
182
  } else {
180
- setSelected(isSelectable(mapPrintedNodes[values]) ? [values] : []);
183
+ newSelected = isSelectable(mapPrintedNodes[values]) ? [values] : [];
181
184
  }
182
185
  }
186
+ setSelected(newSelected);
187
+ if (inline && onSelectionChange) {
188
+ const nodes = newSelected.map((itemId) => mapPrintedNodes[itemId]).filter(Boolean);
189
+ onSelectionChange(nodes);
190
+ }
183
191
  };
184
192
  const getValidationButtonText = () => {
185
193
  if (validationButtonText) {
@@ -270,6 +278,43 @@ function TreeViewFinderComponant(props) {
270
278
  selected: selected ?? []
271
279
  };
272
280
  };
281
+ const renderTreeView = /* @__PURE__ */ jsx(
282
+ SimpleTreeView,
283
+ {
284
+ expandedItems: expanded,
285
+ onExpandedItemsChange: handleNodeToggle,
286
+ onSelectedItemsChange: handleNodeSelect,
287
+ ...getTreeViewSelectionProps(),
288
+ children: data && Array.isArray(data) ? data.sort(sortMethod).map((child) => renderTree(child)) : null
289
+ }
290
+ );
291
+ const handleCancel = () => {
292
+ onClose?.([]);
293
+ setSelected([]);
294
+ setAutoScrollAllowed(true);
295
+ };
296
+ const handleValidate = () => {
297
+ onClose?.(computeSelectedNodes());
298
+ setSelected([]);
299
+ setAutoScrollAllowed(true);
300
+ };
301
+ const actionButtons = /* @__PURE__ */ jsxs(Fragment, { children: [
302
+ /* @__PURE__ */ jsx(CancelButton, { style: { float: "left", margin: "5px" }, onClick: handleCancel, ...cancelButtonProps }),
303
+ /* @__PURE__ */ jsx(
304
+ Button,
305
+ {
306
+ variant: "outlined",
307
+ style: { float: "left", margin: "5px" },
308
+ onClick: handleValidate,
309
+ disabled: isValidationDisabled(),
310
+ "data-testid": "SubmitButton",
311
+ children: getValidationButtonText()
312
+ }
313
+ )
314
+ ] });
315
+ if (inline) {
316
+ return /* @__PURE__ */ jsx("div", { className, "data-testid": "InlineTreeViewFinder", children: renderTreeView });
317
+ }
273
318
  return /* @__PURE__ */ jsxs(
274
319
  Dialog,
275
320
  {
@@ -291,46 +336,9 @@ function TreeViewFinderComponant(props) {
291
336
  /* @__PURE__ */ jsx(DialogTitle, { id: "TreeViewFindertitle", "data-testid": "DialogTitle", children: title ?? intl.formatMessage({ id: "treeview_finder/finderTitle" }, { multiSelect }) }),
292
337
  /* @__PURE__ */ jsxs(DialogContent, { children: [
293
338
  /* @__PURE__ */ jsx(DialogContentText, { children: contentText ?? intl.formatMessage({ id: "treeview_finder/contentText" }, { multiSelect }) }),
294
- /* @__PURE__ */ jsx(
295
- SimpleTreeView,
296
- {
297
- expandedItems: expanded,
298
- onExpandedItemsChange: handleNodeToggle,
299
- onSelectedItemsChange: handleNodeSelect,
300
- ...getTreeViewSelectionProps(),
301
- children: data && Array.isArray(data) ? data.sort(sortMethod).map((child) => renderTree(child)) : null
302
- }
303
- )
339
+ renderTreeView
304
340
  ] }),
305
- /* @__PURE__ */ jsxs(DialogActions, { children: [
306
- /* @__PURE__ */ jsx(
307
- CancelButton,
308
- {
309
- style: { float: "left", margin: "5px" },
310
- onClick: () => {
311
- onClose?.([]);
312
- setSelected([]);
313
- setAutoScrollAllowed(true);
314
- },
315
- ...cancelButtonProps
316
- }
317
- ),
318
- /* @__PURE__ */ jsx(
319
- Button,
320
- {
321
- variant: "outlined",
322
- style: { float: "left", margin: "5px" },
323
- onClick: () => {
324
- onClose?.(computeSelectedNodes());
325
- setSelected([]);
326
- setAutoScrollAllowed(true);
327
- },
328
- disabled: isValidationDisabled(),
329
- "data-testid": "SubmitButton",
330
- children: getValidationButtonText()
331
- }
332
- )
333
- ] })
341
+ /* @__PURE__ */ jsx(DialogActions, { children: actionButtons })
334
342
  ]
335
343
  }
336
344
  );
@@ -155,6 +155,8 @@ import { EQUIPMENT_TYPE_ORDER, byFilterDeletionDtoToForm, byFilterDeletionFormSc
155
155
  import { ModificationByAssignmentForm } from "./network-modifications/by-filter/assignment/modification-by-assignment-form.js";
156
156
  import { emptyModificationByAssignmentFormData, modificationByAssignmentDtoToForm, modificationByAssignmentFormSchema, modificationByAssignmentFormToDto } from "./network-modifications/by-filter/assignment/modificationByAssignment.utils.js";
157
157
  import { DataType } from "./network-modifications/by-filter/assignment/assignment/assignment.type.js";
158
+ import { generatorCreationDtoToForm, generatorCreationEmptyFormData, generatorCreationFormSchema, generatorCreationFormToDto } from "./network-modifications/generator/creation/generatorCreation.utils.js";
159
+ import { GeneratorCreationForm } from "./network-modifications/generator/creation/GeneratorCreationForm.js";
158
160
  import { batteryCreationDtoToForm, batteryCreationEmptyFormData, batteryCreationFormSchema, batteryCreationFormToDto } from "./network-modifications/battery/creation/batteryCreation.utils.js";
159
161
  import { BatteryCreationForm } from "./network-modifications/battery/creation/BatteryCreationForm.js";
160
162
  import { batteryModificationDtoToForm, batteryModificationEmptyFormData, batteryModificationFormSchema, batteryModificationFormToDto } from "./network-modifications/battery/modification/batteryModification.utils.js";
@@ -188,7 +190,7 @@ import { SelectHeaderCell } from "./network-modification-table/renderers/select-
188
190
  import { SwitchCell } from "./network-modification-table/renderers/switch-cell.js";
189
191
  import { DragCloneRow } from "./network-modification-table/row/drag-row-clone.js";
190
192
  import { ModificationRow } from "./network-modification-table/row/modification-row.js";
191
- import { MAX_COMPOSITE_NESTING_DEPTH, fetchSubModificationsForExpandedRows, findAllLoadedCompositeModifications, findModificationInTree, formatToComposedModification, isCompositeModification, mergeSubModificationsIntoTree, moveSubModificationInTree, updateModificationFieldInTree, updateSubModificationsOfACompositeInTree } from "./network-modification-table/utils.js";
193
+ import { MAX_COMPOSITE_NESTING_DEPTH, fetchSubModificationsForExpandedRows, findAllLoadedCompositeModifications, findDepth, findModificationInTree, formatToComposedModification, isCompositeModification, mergeSubModificationsIntoTree, moveSubModificationInTree, updateModificationFieldInTree, updateSubModificationsOfACompositeInTree } from "./network-modification-table/utils.js";
192
194
  import { AnnouncementBanner } from "./announcement/AnnouncementBanner.js";
193
195
  import { AnnouncementNotification } from "./announcement/AnnouncementNotification.js";
194
196
  import { useGlobalAnnouncement } from "./announcement/useGlobalAnnouncement.js";
@@ -281,6 +283,7 @@ export {
281
283
  GENERAL,
282
284
  GENERAL_APPLY_MODIFICATIONS,
283
285
  GENERATORS_SELECTION_TYPE,
286
+ GeneratorCreationForm,
284
287
  GridLogo,
285
288
  HIGH_VOLTAGE_LIMIT,
286
289
  HVDC_AC_EMULATION,
@@ -523,9 +526,14 @@ export {
523
526
  fetchSubModificationsForExpandedRows,
524
527
  filledTextField,
525
528
  findAllLoadedCompositeModifications,
529
+ findDepth,
526
530
  findModificationInTree,
527
531
  formatComputingTypeLabel,
528
532
  formatToComposedModification,
533
+ generatorCreationDtoToForm,
534
+ generatorCreationEmptyFormData,
535
+ generatorCreationFormSchema,
536
+ generatorCreationFormToDto,
529
537
  getActivePowerControlEmptyFormData,
530
538
  getActivePowerControlSchema,
531
539
  getActivePowerSetPointSchema,
@@ -14,7 +14,7 @@ import { SelectHeaderCell } from "./renderers/select-header-cell.js";
14
14
  import { SwitchCell } from "./renderers/switch-cell.js";
15
15
  import { DragCloneRow } from "./row/drag-row-clone.js";
16
16
  import { ModificationRow } from "./row/modification-row.js";
17
- import { MAX_COMPOSITE_NESTING_DEPTH, fetchSubModificationsForExpandedRows, findAllLoadedCompositeModifications, findModificationInTree, formatToComposedModification, isCompositeModification, mergeSubModificationsIntoTree, moveSubModificationInTree, updateModificationFieldInTree, updateSubModificationsOfACompositeInTree } from "./utils.js";
17
+ import { MAX_COMPOSITE_NESTING_DEPTH, fetchSubModificationsForExpandedRows, findAllLoadedCompositeModifications, findDepth, findModificationInTree, formatToComposedModification, isCompositeModification, mergeSubModificationsIntoTree, moveSubModificationInTree, updateModificationFieldInTree, updateSubModificationsOfACompositeInTree } from "./utils.js";
18
18
  export {
19
19
  AUTO_EXTENSIBLE_COLUMNS,
20
20
  BASE_MODIFICATION_TABLE_COLUMNS,
@@ -60,6 +60,7 @@ export {
60
60
  createRowSx,
61
61
  fetchSubModificationsForExpandedRows,
62
62
  findAllLoadedCompositeModifications,
63
+ findDepth,
63
64
  findModificationInTree,
64
65
  formatToComposedModification,
65
66
  isCompositeModification,
@@ -9,9 +9,11 @@ interface NetworkModificationsTableProps extends Omit<NetworkModificationEditorN
9
9
  isRowDragDisabled?: boolean;
10
10
  onRowDragStart: () => void;
11
11
  onRowDragEnd: () => void;
12
- onRowSelected: (selectedRows: ComposedModificationMetadata[]) => void;
12
+ onSelectedRowsChange: (selectedRows: ComposedModificationMetadata[], isAssemblyDepthExceeded: boolean) => void;
13
13
  columns: ColumnDef<ComposedModificationMetadata>[];
14
14
  highlightedModificationUuid: UUID | null;
15
+ modificationUuidsToReset?: UUID[];
16
+ modificationToEditLabel: UUID | null;
15
17
  studyUuid: UUID | null;
16
18
  currentNodeId?: UUID;
17
19
  currentRootNetworkUuid?: UUID;
@@ -20,5 +22,5 @@ interface NetworkModificationsTableProps extends Omit<NetworkModificationEditorN
20
22
  setModificationsToExclude?: Dispatch<SetStateAction<ExcludedNetworkModifications[]>>;
21
23
  isDisabled?: boolean;
22
24
  }
23
- export declare function NetworkModificationsTable({ modifications, handleCellClick, isRowDragDisabled, onRowDragStart, onRowDragEnd, onRowSelected, columns, highlightedModificationUuid, studyUuid, currentNodeId, currentRootNetworkUuid, rootNetworks, modificationsToExclude, setModificationsToExclude, isDisabled, isImpactedByNotification, notificationMessageId, isFetchingModifications, pendingState, }: Readonly<NetworkModificationsTableProps>): import("react/jsx-runtime").JSX.Element;
25
+ export declare function NetworkModificationsTable({ modifications, handleCellClick, isRowDragDisabled, onRowDragStart, onRowDragEnd, onSelectedRowsChange, columns, highlightedModificationUuid, modificationToEditLabel, modificationUuidsToReset, studyUuid, currentNodeId, currentRootNetworkUuid, rootNetworks, modificationsToExclude, setModificationsToExclude, isDisabled, isImpactedByNotification, notificationMessageId, isFetchingModifications, pendingState, }: Readonly<NetworkModificationsTableProps>): import("react/jsx-runtime").JSX.Element;
24
26
  export {};
@@ -8,7 +8,7 @@ import { MODIFICATION_ROW_HEIGHT, networkModificationTableStyles, createHeaderCe
8
8
  import { AUTO_EXTENSIBLE_COLUMNS } from "./columns-definition.js";
9
9
  import { useModificationsDragAndDrop } from "./use-modifications-drag-and-drop.js";
10
10
  import { useModificationsSelection } from "./use-modifications-selection.js";
11
- import { formatToComposedModification, mergeSubModificationsIntoTree, findAllLoadedCompositeModifications, fetchSubModificationsForExpandedRows, isCompositeModification } from "./utils.js";
11
+ import { formatToComposedModification, findDepth, MAX_COMPOSITE_NESTING_DEPTH, mergeSubModificationsIntoTree, findAllLoadedCompositeModifications, fetchSubModificationsForExpandedRows, isCompositeModification } from "./utils.js";
12
12
  import "@mui/icons-material";
13
13
  import "react-intl";
14
14
  import "../../utils/conversionUtils.js";
@@ -24,9 +24,11 @@ function NetworkModificationsTable({
24
24
  isRowDragDisabled = false,
25
25
  onRowDragStart,
26
26
  onRowDragEnd,
27
- onRowSelected,
27
+ onSelectedRowsChange,
28
28
  columns,
29
29
  highlightedModificationUuid,
30
+ modificationToEditLabel,
31
+ modificationUuidsToReset,
30
32
  studyUuid = null,
31
33
  currentNodeId = void 0,
32
34
  currentRootNetworkUuid,
@@ -45,9 +47,24 @@ function NetworkModificationsTable({
45
47
  const [composedModifications, setComposedModifications] = useState(
46
48
  formatToComposedModification(modifications)
47
49
  );
50
+ const composedModificationsRef = useRef(composedModifications);
51
+ useEffect(() => {
52
+ composedModificationsRef.current = composedModifications;
53
+ }, [composedModifications]);
54
+ const isAssemblyDepthExceeded = useCallback((rows2) => {
55
+ if (rows2.length === 0) return false;
56
+ const firstSelectedRowDepth = findDepth(composedModificationsRef.current, rows2[0].uuid);
57
+ return rows2.some((row) => firstSelectedRowDepth + (row.maxDepth ?? 0) >= MAX_COMPOSITE_NESTING_DEPTH);
58
+ }, []);
59
+ const handleRowSelected = useCallback(
60
+ (selectedRows) => {
61
+ onSelectedRowsChange(selectedRows, isAssemblyDepthExceeded(selectedRows));
62
+ },
63
+ [onSelectedRowsChange, isAssemblyDepthExceeded]
64
+ );
48
65
  const { rowSelection, onRowSelectionChange, lastClickedRowId, emitSelection } = useModificationsSelection({
49
66
  modifications: composedModifications,
50
- onRowSelected
67
+ onRowSelected: handleRowSelected
51
68
  });
52
69
  useEffect(() => {
53
70
  setComposedModifications((prevMods) => {
@@ -91,8 +108,9 @@ function NetworkModificationsTable({
91
108
  },
92
109
  interaction: {
93
110
  lastClickedRowId,
94
- onRowSelected,
95
- isRowDragDisabled
111
+ onRowSelected: handleRowSelected,
112
+ isRowDragDisabled,
113
+ modificationToEditLabel
96
114
  },
97
115
  status: {
98
116
  isImpactedByNotification,
@@ -111,7 +129,8 @@ function NetworkModificationsTable({
111
129
  modificationsToExclude,
112
130
  setModificationsToExclude,
113
131
  lastClickedRowId,
114
- onRowSelected,
132
+ handleRowSelected,
133
+ modificationToEditLabel,
115
134
  isRowDragDisabled,
116
135
  isImpactedByNotification,
117
136
  notificationMessageId,
@@ -156,6 +175,35 @@ function NetworkModificationsTable({
156
175
  studyUuid,
157
176
  currentNodeUuid: currentNodeId
158
177
  });
178
+ useEffect(() => {
179
+ if (!modificationUuidsToReset?.length) {
180
+ return;
181
+ }
182
+ table.resetRowSelection();
183
+ const uuidsToReset = new Set(modificationUuidsToReset);
184
+ const collectAll = (mod) => {
185
+ uuidsToReset.add(mod.uuid);
186
+ mod.subModifications?.forEach(collectAll);
187
+ };
188
+ const collectDescendants = (mods) => {
189
+ mods.forEach((mod) => {
190
+ if (uuidsToReset.has(mod.uuid)) {
191
+ mod.subModifications?.forEach(collectAll);
192
+ } else {
193
+ collectDescendants(mod.subModifications ?? []);
194
+ }
195
+ });
196
+ };
197
+ collectDescendants(composedModificationsRef.current);
198
+ setExpanded((prev) => {
199
+ if (prev === true) {
200
+ return prev;
201
+ }
202
+ const next = { ...prev };
203
+ uuidsToReset.forEach((uuid) => delete next[uuid]);
204
+ return next;
205
+ });
206
+ }, [modificationUuidsToReset, table]);
159
207
  useEffect(() => {
160
208
  table.resetRowSelection();
161
209
  table.resetExpanded();
@@ -15,7 +15,7 @@ export declare function DragHandleRenderer({ table }: CCtx): import("react/jsx-r
15
15
  export declare function SelectHeaderRenderer({ table }: HCtx): import("react/jsx-runtime").JSX.Element;
16
16
  export declare function SelectCellRenderer({ row, table }: CCtx): import("react/jsx-runtime").JSX.Element;
17
17
  export declare function NameHeaderRenderer({ table }: HCtx): import("react/jsx-runtime").JSX.Element;
18
- export declare function NameCellRenderer({ row, column }: CCtx): import("react/jsx-runtime").JSX.Element;
18
+ export declare function NameCellRenderer({ row, table, column }: CCtx): import("react/jsx-runtime").JSX.Element;
19
19
  export declare function DescriptionCellRenderer({ row, table }: CCtx): import("react/jsx-runtime").JSX.Element;
20
20
  export declare function SwitchCellRenderer({ row, table }: CCtx): import("react/jsx-runtime").JSX.Element;
21
21
  export declare function RootNetworkHeaderRenderer({ column, table }: HCtx): import("react/jsx-runtime").JSX.Element | null;
@@ -33,8 +33,8 @@ function NameHeaderRenderer({ table }) {
33
33
  }
34
34
  );
35
35
  }
36
- function NameCellRenderer({ row, column }) {
37
- return /* @__PURE__ */ jsx(NameCell, { row, onChange: column.columnDef.meta?.onChange });
36
+ function NameCellRenderer({ row, table, column }) {
37
+ return /* @__PURE__ */ jsx(NameCell, { row, table, onChange: column.columnDef.meta?.onChange });
38
38
  }
39
39
  function DescriptionCellRenderer({ row, table }) {
40
40
  const { meta } = table.options;
@@ -1,8 +1,9 @@
1
- import { Row } from '@tanstack/react-table';
1
+ import { Row, Table } from '@tanstack/react-table';
2
2
  import { ComposedModificationMetadata } from '../../../utils';
3
3
  interface NameCellProps {
4
4
  row: Row<ComposedModificationMetadata>;
5
+ table: Table<ComposedModificationMetadata>;
5
6
  onChange?: (modification: ComposedModificationMetadata, newValue: string) => Promise<unknown>;
6
7
  }
7
- export declare function NameCell({ row, onChange }: Readonly<NameCellProps>): import("react/jsx-runtime").JSX.Element;
8
+ export declare function NameCell({ row, table, onChange }: Readonly<NameCellProps>): import("react/jsx-runtime").JSX.Element;
8
9
  export {};
@@ -25,13 +25,14 @@ function measureTextPx(text, font) {
25
25
  }
26
26
  return text.length * 8;
27
27
  }
28
- function NameCell({ row, onChange }) {
28
+ function NameCell({ row, table, onChange }) {
29
29
  const intl = useIntl();
30
30
  const theme = useTheme();
31
31
  const { computeLabel } = useModificationLabelComputer();
32
32
  const { snackError } = useSnackMessage();
33
33
  const { depth } = row;
34
34
  const isComposite = isCompositeModification(row.original);
35
+ const modificationToEditLabel = table.options.meta?.interaction.modificationToEditLabel;
35
36
  const getModificationLabel = useCallback(
36
37
  (modification, formatBold = true) => {
37
38
  return intl.formatMessage(
@@ -90,24 +91,32 @@ function NameCell({ row, onChange }) {
90
91
  }
91
92
  stopEditing();
92
93
  }, [compositeName, draftName, updateName, stopEditing]);
94
+ const beginEditingName = useCallback((originalName) => {
95
+ setDraftName(originalName);
96
+ if (labelRef.current) {
97
+ const style = globalThis.getComputedStyle(labelRef.current);
98
+ const font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
99
+ const px = originalName.length >= MIN_CHAR_WIDTH ? measureTextPx(originalName, font) + 20 : measureTextPx("a".repeat(MIN_CHAR_WIDTH), font) + 20;
100
+ setInputBaseWidthPx(px);
101
+ }
102
+ isEditingRef.current = true;
103
+ setIsEditing(true);
104
+ requestAnimationFrame(() => {
105
+ inputRef.current?.focus();
106
+ inputRef.current?.select();
107
+ });
108
+ }, []);
109
+ useEffect(() => {
110
+ if (isComposite && modificationToEditLabel === row.original.uuid) {
111
+ beginEditingName(intl.formatMessage({ id: "CompositeModification" }));
112
+ }
113
+ }, [modificationToEditLabel, intl, isComposite, row.original.uuid, beginEditingName]);
93
114
  const handleLabelClick = useCallback(
94
115
  (e) => {
95
116
  e.stopPropagation();
96
- setDraftName(compositeName);
97
- if (labelRef.current) {
98
- const style = globalThis.getComputedStyle(labelRef.current);
99
- const font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
100
- const px = compositeName.length >= MIN_CHAR_WIDTH ? measureTextPx(compositeName, font) + 20 : measureTextPx("a".repeat(MIN_CHAR_WIDTH), font) + 20;
101
- setInputBaseWidthPx(px);
102
- }
103
- isEditingRef.current = true;
104
- setIsEditing(true);
105
- requestAnimationFrame(() => {
106
- inputRef.current?.focus();
107
- inputRef.current?.select();
108
- });
117
+ beginEditingName(compositeName);
109
118
  },
110
- [compositeName]
119
+ [beginEditingName, compositeName]
111
120
  );
112
121
  const handleKeyDown = useCallback(
113
122
  (e) => {
@@ -4,6 +4,7 @@ import { ComposedModificationMetadata, NetworkModificationMetadata } from '../..
4
4
  export declare const MAX_COMPOSITE_NESTING_DEPTH = 5;
5
5
  export declare const formatToComposedModification: (modifications: NetworkModificationMetadata[]) => ComposedModificationMetadata[];
6
6
  export declare function isCompositeModification(modification: ComposedModificationMetadata | undefined): boolean;
7
+ export declare function findDepth(mods: ComposedModificationMetadata[], uuid: UUID, currentDepth?: number): number;
7
8
  /**
8
9
  *
9
10
  * @param modifications source where the composite modifications are looked for
@@ -11,6 +11,16 @@ const formatToComposedModification = (modifications) => {
11
11
  function isCompositeModification(modification) {
12
12
  return modification?.messageType === MODIFICATION_TYPES.COMPOSITE_MODIFICATION.type;
13
13
  }
14
+ function findDepth(mods, uuid, currentDepth = 0) {
15
+ for (const mod of mods) {
16
+ if (mod.uuid === uuid) return currentDepth;
17
+ if (mod.subModifications?.length) {
18
+ const found = findDepth(mod.subModifications, uuid, currentDepth + 1);
19
+ if (found >= 0) return found;
20
+ }
21
+ }
22
+ return -1;
23
+ }
14
24
  function findAllLoadedCompositeModifications(modifications, composites) {
15
25
  modifications.forEach((modification) => {
16
26
  if (isCompositeModification(modification) && modification.subModifications.length > 0) {
@@ -155,6 +165,7 @@ export {
155
165
  MAX_COMPOSITE_NESTING_DEPTH,
156
166
  fetchSubModificationsForExpandedRows,
157
167
  findAllLoadedCompositeModifications,
168
+ findDepth,
158
169
  findModificationInTree,
159
170
  formatToComposedModification,
160
171
  isCompositeModification,
@@ -1,7 +1,8 @@
1
1
  import { FieldValues, UseFormSetValue } from 'react-hook-form';
2
2
  import { ReactiveCapabilityCurve, ReactiveCapabilityCurvePoints } from '../reactiveLimits.type';
3
3
  import { FieldConstants } from '../../../../../utils';
4
- import { GeneratorCreationDialogSchemaForm, GeneratorModificationDialogSchemaForm } from '../../../generator/generatorDialog.type';
4
+ import { GeneratorModificationDialogSchemaForm } from '../../../generator/generatorDialog.type';
5
+ import { GeneratorCreationFormData } from '../../../generator/creation/generatorCreation.utils';
5
6
  import { GeneratorCreationDto } from '../../../generator/creation/generatorCreation.types';
6
7
  import { GeneratorModificationDto } from '../../../generator/modification/generatorModification.types';
7
8
  export declare const INSERT = "INSERT";
@@ -25,5 +26,5 @@ export declare const getReactiveCapabilityCurveValidationSchema: (id?: FieldCons
25
26
  };
26
27
  export declare function setSelectedReactiveLimits(id: string, minMaxReactiveLimits: number, setValue: UseFormSetValue<FieldValues>): void;
27
28
  export declare function setCurrentReactiveCapabilityCurveTable(previousReactiveCapabilityCurveTable: ReactiveCapabilityCurve, fieldKey: string, setValue: UseFormSetValue<FieldValues>): void;
28
- export declare function toReactiveCapabilityCurveChoiceForGeneratorCreation(currentReactiveLimits: GeneratorCreationDialogSchemaForm[typeof FieldConstants.REACTIVE_LIMITS], editData: GeneratorCreationDto | null | undefined): "CURVE" | "MINMAX";
29
+ export declare function toReactiveCapabilityCurveChoiceForGeneratorCreation(form: GeneratorCreationFormData, dto?: GeneratorCreationDto): "CURVE" | "MINMAX";
29
30
  export declare function toReactiveCapabilityCurveChoiceForGeneratorModification(currentReactiveLimits: GeneratorModificationDialogSchemaForm[typeof FieldConstants.REACTIVE_LIMITS], editData: GeneratorModificationDto | null | undefined, networkPoints: ReactiveCapabilityCurvePoints[] | null | undefined): "CURVE" | "MINMAX";
@@ -101,7 +101,9 @@ function setSelectedReactiveLimits(id, minMaxReactiveLimits, setValue) {
101
101
  function setCurrentReactiveCapabilityCurveTable(previousReactiveCapabilityCurveTable, fieldKey, setValue) {
102
102
  setValue(fieldKey, previousReactiveCapabilityCurveTable);
103
103
  }
104
- function handleReactiveCapabilityCurveChoice(currentChoice, previousChoice, currentReactiveLimits) {
104
+ function handleReactiveCapabilityCurveChoice(previousChoice, form) {
105
+ const currentReactiveLimits = form[FieldConstants.REACTIVE_LIMITS];
106
+ const currentChoice = currentReactiveLimits?.[FieldConstants.REACTIVE_CAPABILITY_CURVE_CHOICE];
105
107
  if (currentChoice === "MINMAX") {
106
108
  const hasAnyValue = currentReactiveLimits?.[FieldConstants.MAXIMUM_REACTIVE_POWER] || currentReactiveLimits?.[FieldConstants.MINIMUM_REACTIVE_POWER];
107
109
  if (previousChoice === "CURVE" && !hasAnyValue) {
@@ -122,13 +124,33 @@ function handleReactiveCapabilityCurveChoice(currentChoice, previousChoice, curr
122
124
  );
123
125
  return "MINMAX";
124
126
  }
125
- function toReactiveCapabilityCurveChoiceForGeneratorCreation(currentReactiveLimits, editData) {
126
- const currentChoice = currentReactiveLimits?.[FieldConstants.REACTIVE_CAPABILITY_CURVE_CHOICE];
127
+ function toReactiveCapabilityCurveChoiceForGeneratorCreation(form, dto) {
127
128
  let previousChoice;
128
- if (editData) {
129
- previousChoice = editData.reactiveCapabilityCurve ? "CURVE" : "MINMAX";
129
+ if (dto) {
130
+ previousChoice = dto.reactiveCapabilityCurve ? "CURVE" : "MINMAX";
131
+ }
132
+ return handleReactiveCapabilityCurveChoice(previousChoice, form);
133
+ }
134
+ function handleReactiveCapabilityCurveChoiceForModification(currentChoice, previousChoice, currentReactiveLimits) {
135
+ if (currentChoice === "MINMAX") {
136
+ const hasAnyValue = currentReactiveLimits?.[FieldConstants.MAXIMUM_REACTIVE_POWER] || currentReactiveLimits?.[FieldConstants.MINIMUM_REACTIVE_POWER];
137
+ if (previousChoice === "CURVE" && !hasAnyValue) {
138
+ return "CURVE";
139
+ }
140
+ return "MINMAX";
130
141
  }
131
- return handleReactiveCapabilityCurveChoice(currentChoice, previousChoice, currentReactiveLimits);
142
+ if (currentChoice === "CURVE") {
143
+ const currentPoints = currentReactiveLimits?.[FieldConstants.REACTIVE_CAPABILITY_CURVE_TABLE];
144
+ const hasAnyValue = currentPoints?.some((v) => v.p != null || v.maxQ != null || v.minQ != null);
145
+ if (previousChoice === "MINMAX" && !hasAnyValue) {
146
+ return "MINMAX";
147
+ }
148
+ return "CURVE";
149
+ }
150
+ console.error(
151
+ "Reactive capability curve choice is not valid, it should be either MINMAX or CURVE. We return MINMAX by default."
152
+ );
153
+ return "MINMAX";
132
154
  }
133
155
  function toReactiveCapabilityCurveChoiceForGeneratorModification(currentReactiveLimits, editData, networkPoints) {
134
156
  const currentChoice = currentReactiveLimits?.[FieldConstants.REACTIVE_CAPABILITY_CURVE_CHOICE];
@@ -138,7 +160,7 @@ function toReactiveCapabilityCurveChoiceForGeneratorModification(currentReactive
138
160
  }
139
161
  const networkChoice = networkPoints ? "CURVE" : "MINMAX";
140
162
  const previousChoice = editDataChoice ?? networkChoice;
141
- return handleReactiveCapabilityCurveChoice(currentChoice, previousChoice, currentReactiveLimits);
163
+ return handleReactiveCapabilityCurveChoiceForModification(currentChoice, previousChoice, currentReactiveLimits);
142
164
  }
143
165
  export {
144
166
  INSERT,
@@ -59,7 +59,7 @@ function RegulatingTerminalForm({
59
59
  const itemSize = isColumnDirection ? 12 : 6;
60
60
  useEffect(() => {
61
61
  if (!watchVoltageLevelId || !voltageLevelOptions.some((vlOption) => vlOption.id === watchVoltageLevelId)) {
62
- setEquipmentsOptions([]);
62
+ setEquipmentsOptions((prev) => prev.length === 0 ? prev : []);
63
63
  } else {
64
64
  fetchVoltageLevelEquipments(watchVoltageLevelId).then((equipments) => {
65
65
  setEquipmentsOptions(
@@ -24,11 +24,11 @@ export declare const getRegulatingTerminalVoltageLevelData: ({ voltageLevelId, v
24
24
  export declare const getRegulatingTerminalEquipmentData: ({ equipmentId, equipmentName, equipmentType, }: {
25
25
  equipmentId?: string | null;
26
26
  equipmentName?: string | null;
27
- equipmentType?: string | null;
27
+ equipmentType?: string;
28
28
  }) => {
29
29
  id: string;
30
30
  name: string | null;
31
- type: string | null;
31
+ type: string;
32
32
  } | null;
33
33
  export declare const getRegulatingTerminalFormData: ({ voltageLevelId, voltageLevelName, voltageLevelNominalVoltage, voltageLevelSubstationId, voltageLevelTopologyKind, equipmentId, equipmentName, equipmentType, }: {
34
34
  voltageLevelId?: string | null;
@@ -38,7 +38,7 @@ export declare const getRegulatingTerminalFormData: ({ voltageLevelId, voltageLe
38
38
  voltageLevelTopologyKind?: string;
39
39
  equipmentId?: string | null;
40
40
  equipmentName?: string | null;
41
- equipmentType?: string | null;
41
+ equipmentType?: string;
42
42
  }) => {
43
43
  voltageLevel: {
44
44
  id: string;
@@ -50,6 +50,6 @@ export declare const getRegulatingTerminalFormData: ({ voltageLevelId, voltageLe
50
50
  equipment: {
51
51
  id: string;
52
52
  name: string | null;
53
- type: string | null;
53
+ type: string;
54
54
  } | null;
55
55
  };
@@ -0,0 +1,8 @@
1
+ import { ConnectivityNetworkProps } from '../../common';
2
+ import { EquipmentType, Identifiable } from '../../../../utils';
3
+ export interface GeneratorCreationFormProps extends ConnectivityNetworkProps {
4
+ fetchVoltageLevelEquipments: (voltageLevelId: string) => Promise<(Identifiable & {
5
+ type: EquipmentType;
6
+ })[]>;
7
+ }
8
+ export declare function GeneratorCreationForm({ voltageLevelOptions, fetchBusesOrBusbarSections, PositionDiagramPane, fetchVoltageLevelEquipments, }: Readonly<GeneratorCreationFormProps>): import("react/jsx-runtime").JSX.Element;