@gridsuite/commons-ui 0.223.0 → 0.225.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 (121) hide show
  1. package/dist/components/composite/dnd-table/dnd-table.d.ts +8 -4
  2. package/dist/components/composite/dnd-table/dnd-table.js +100 -160
  3. package/dist/components/composite/dnd-table/dnd-table.type.d.ts +17 -3
  4. package/dist/components/composite/dnd-table/dnd-table.type.js +2 -0
  5. package/dist/components/composite/dnd-table/index.d.ts +6 -1
  6. package/dist/components/composite/dnd-table/index.js +6 -6
  7. package/dist/components/composite/index.js +6 -6
  8. package/dist/components/index.js +6 -6
  9. package/dist/components/ui/directoryItemSelector/DirectoryItemSelector.js +1 -1
  10. package/dist/components/ui/directoryItemSelector/utils.js +1 -1
  11. package/dist/components/ui/reactHookForm/DirectoryItemsInput.js +1 -1
  12. package/dist/features/index.js +16 -0
  13. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.d.ts +4 -3
  14. package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.js +7 -30
  15. package/dist/features/network-modifications/common/reactiveLimits/reactiveLimits.utils.d.ts +2 -0
  16. package/dist/features/network-modifications/generator/generatorDialog.type.d.ts +0 -60
  17. package/dist/features/network-modifications/generator/index.js +17 -1
  18. package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.d.ts +6 -0
  19. package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.js +109 -0
  20. package/dist/features/network-modifications/generator/modification/GeneratorDialogTabs.d.ts +13 -0
  21. package/dist/features/network-modifications/generator/modification/GeneratorDialogTabs.js +55 -0
  22. package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.d.ts +12 -0
  23. package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.js +277 -0
  24. package/dist/features/network-modifications/generator/modification/GeneratorModificationForm.d.ts +10 -0
  25. package/dist/features/network-modifications/generator/modification/GeneratorModificationForm.js +52 -0
  26. package/dist/features/network-modifications/generator/modification/generatorModification.types.d.ts +3 -5
  27. package/dist/features/network-modifications/generator/modification/generatorModification.utils.d.ts +140 -0
  28. package/dist/features/network-modifications/generator/modification/generatorModification.utils.js +211 -0
  29. package/dist/features/network-modifications/generator/modification/generatorTabs.utils.d.ts +8 -0
  30. package/dist/features/network-modifications/generator/modification/generatorTabs.utils.js +56 -0
  31. package/dist/features/network-modifications/generator/modification/index.d.ts +6 -0
  32. package/dist/features/network-modifications/generator/modification/index.js +18 -1
  33. package/dist/features/network-modifications/index.js +16 -0
  34. package/dist/features/parameters/common/contingency-table/columns-definitions.d.ts +2 -2
  35. package/dist/features/parameters/common/contingency-table/columns-definitions.js +6 -6
  36. package/dist/features/parameters/common/contingency-table/contingency-table.js +1 -1
  37. package/dist/features/parameters/common/contingency-table/types.d.ts +6 -17
  38. package/dist/features/parameters/common/parameter-table-field/parameter-table-field.js +2 -2
  39. package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +1 -1
  40. package/dist/features/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -1
  41. package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +1 -1
  42. package/dist/features/parameters/dynamic-simulation/dynamic-simulation-inline.js +1 -1
  43. package/dist/features/parameters/loadflow/load-flow-parameters-inline.js +1 -1
  44. package/dist/features/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -1
  45. package/dist/features/parameters/pcc-min/pcc-min-parameters-inline.js +1 -1
  46. package/dist/features/parameters/security-analysis/columns-definitions.d.ts +3 -3
  47. package/dist/features/parameters/security-analysis/columns-definitions.js +8 -8
  48. package/dist/features/parameters/security-analysis/security-analysis-parameters-inline.js +2 -2
  49. package/dist/features/parameters/security-analysis/security-analysis-parameters-selector.d.ts +1 -1
  50. package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.d.ts +1 -1
  51. package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -1
  52. package/dist/features/parameters/sensi/columns-definitions.js +1 -1
  53. package/dist/features/parameters/sensi/constants.d.ts +0 -2
  54. package/dist/features/parameters/sensi/constants.js +0 -4
  55. package/dist/features/parameters/sensi/sensitivity-analysis-parameters-inline.js +1 -1
  56. package/dist/features/parameters/sensi/use-sensitivity-analysis-parameters.js +33 -32
  57. package/dist/features/parameters/sensi/utils.d.ts +31 -63
  58. package/dist/features/parameters/sensi/utils.js +49 -61
  59. package/dist/features/parameters/short-circuit/short-circuit-parameters-inline.js +1 -1
  60. package/dist/features/parameters/voltage-init/use-voltage-init-parameters-form.js +1 -1
  61. package/dist/features/parameters/voltage-init/voltage-init-form-utils.js +1 -1
  62. package/dist/features/parameters/voltage-init/voltage-init-parameters-inline.js +1 -1
  63. package/dist/features/parameters/voltage-init/voltage-limits-parameters.js +1 -1
  64. package/dist/hooks/use-unique-name-validation.js +1 -1
  65. package/dist/index.js +30 -11
  66. package/dist/services/directory.d.ts +1 -1
  67. package/dist/services/index.js +6 -3
  68. package/dist/services/pcc-min.d.ts +2 -1
  69. package/dist/services/pcc-min.js +27 -1
  70. package/dist/services/security-analysis.d.ts +2 -1
  71. package/dist/services/security-analysis.js +32 -1
  72. package/dist/services/sensitivity-analysis.d.ts +2 -1
  73. package/dist/services/sensitivity-analysis.js +87 -1
  74. package/dist/translations/en/networkModificationsEn.d.ts +2 -0
  75. package/dist/translations/en/networkModificationsEn.js +2 -0
  76. package/dist/translations/fr/networkModificationsFr.d.ts +2 -0
  77. package/dist/translations/fr/networkModificationsFr.js +2 -0
  78. package/dist/utils/constants/filterConstant.d.ts +1 -1
  79. package/dist/utils/index.js +4 -4
  80. package/dist/utils/types/dynamic-security-analysis.type.d.ts +3 -5
  81. package/dist/utils/types/index.d.ts +1 -0
  82. package/dist/utils/types/index.js +4 -4
  83. package/dist/utils/types/parameters.type.d.ts +1 -1
  84. package/dist/utils/types/pcc-min.type.d.ts +0 -1
  85. package/dist/utils/types/pcc-min.type.js +0 -21
  86. package/dist/utils/types/security-analysis.type.d.ts +26 -0
  87. package/dist/utils/types/security-analysis.type.js +14 -0
  88. package/dist/utils/types/sensitivity-analysis.type.d.ts +3 -7
  89. package/dist/utils/types/sensitivity-analysis.type.js +17 -103
  90. package/dist/utils/types/types.d.ts +7 -0
  91. package/package.json +1 -1
  92. package/dist/components/composite/dnd-table-v2/dnd-table-add-rows-dialog.d.ts +0 -13
  93. package/dist/components/composite/dnd-table-v2/dnd-table-add-rows-dialog.js +0 -69
  94. package/dist/components/composite/dnd-table-v2/dnd-table-bottom-left-buttons.d.ts +0 -17
  95. package/dist/components/composite/dnd-table-v2/dnd-table-bottom-left-buttons.js +0 -47
  96. package/dist/components/composite/dnd-table-v2/dnd-table-bottom-right-buttons.d.ts +0 -17
  97. package/dist/components/composite/dnd-table-v2/dnd-table-bottom-right-buttons.js +0 -100
  98. package/dist/components/composite/dnd-table-v2/dnd-table.d.ts +0 -32
  99. package/dist/components/composite/dnd-table-v2/dnd-table.js +0 -375
  100. package/dist/components/composite/dnd-table-v2/dnd-table.type.d.ts +0 -70
  101. package/dist/components/composite/dnd-table-v2/dnd-table.type.js +0 -19
  102. package/dist/components/composite/dnd-table-v2/index.d.ts +0 -12
  103. package/dist/components/composite/dnd-table-v2/index.js +0 -16
  104. package/dist/features/parameters/common/parameter-table/constants.d.ts +0 -11
  105. package/dist/features/parameters/common/parameter-table/constants.js +0 -12
  106. package/dist/features/parameters/common/parameter-table/parameter-table.d.ts +0 -15
  107. package/dist/features/parameters/common/parameter-table/parameter-table.js +0 -98
  108. package/dist/features/parameters/common/parameter-table/table-cell.d.ts +0 -8
  109. package/dist/features/parameters/common/parameter-table/table-cell.js +0 -83
  110. package/dist/features/parameters/common/parameter-table/table-row.d.ts +0 -11
  111. package/dist/features/parameters/common/parameter-table/table-row.js +0 -41
  112. package/dist/features/parameters/common/parameter-table/types.d.ts +0 -26
  113. package/dist/features/parameters/common/parameter-table/types.js +0 -1
  114. package/dist/features/parameters/security-analysis/types.d.ts +0 -20
  115. package/dist/features/parameters/security-analysis/types.js +0 -42
  116. /package/dist/components/composite/{dnd-table-v2 → dnd-table}/deletable-table-row.d.ts +0 -0
  117. /package/dist/components/composite/{dnd-table-v2 → dnd-table}/deletable-table-row.js +0 -0
  118. /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-row.d.ts +0 -0
  119. /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-row.js +0 -0
  120. /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-utils.d.ts +0 -0
  121. /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-utils.js +0 -0
@@ -1,7 +1,7 @@
1
1
  import { UseFieldArrayReturn } from 'react-hook-form';
2
2
  import { DndColumn } from './dnd-table.type';
3
3
  export interface DndTableProps {
4
- arrayFormName: string;
4
+ name: string;
5
5
  useFieldArrayOutput: UseFieldArrayReturn;
6
6
  columnsDefinition: DndColumn[];
7
7
  tableHeight?: number;
@@ -13,9 +13,9 @@ export interface DndTableProps {
13
13
  withResetButton?: boolean;
14
14
  withAddRowsDialog?: boolean;
15
15
  previousValues?: any[];
16
- disableTableCell?: (rowIndex: number, column: any, arrayFormName: string, temporaryLimits?: any[]) => boolean;
17
- getPreviousValue?: (rowIndex: number, column: any, arrayFormName: string, temporaryLimits?: any[]) => number | undefined;
18
- isValueModified?: (index: number, arrayFormName: string) => boolean;
16
+ disableTableCell?: (rowIndex: number, column: any, tableName: string, previousValues?: any[]) => boolean;
17
+ getPreviousValue?: (rowIndex: number, column: any, tableName: string, previousValues?: any[]) => number | undefined;
18
+ isValueModified?: (index: number, tableName: string) => boolean;
19
19
  disableAddingRows?: boolean;
20
20
  showMoveArrow?: boolean;
21
21
  disableDragAndDrop?: boolean;
@@ -24,5 +24,9 @@ export interface DndTableProps {
24
24
  handleResetButton?: () => void;
25
25
  resetButtonMessageId?: string;
26
26
  maxRows?: number;
27
+ disabledDeletion?: boolean;
28
+ multiselect?: boolean;
29
+ onChange?: (changedRow: any) => void;
30
+ onDelete?: (removedRows: any[]) => void;
27
31
  }
28
32
  export declare function DndTable(props: Readonly<DndTableProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,13 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { createPortal } from "react-dom";
3
- import { useState, useRef, useCallback, useMemo } from "react";
3
+ import { useState, useCallback, useRef, useMemo } from "react";
4
4
  import { useFormContext, useWatch } from "react-hook-form";
5
- import { Grid, TableContainer, Table, TableHead, TableRow, TableCell, Box, TableBody, Checkbox } from "@mui/material";
6
- import { DragIndicator } from "@mui/icons-material";
5
+ import { Grid, TableContainer, Table, TableHead, TableRow, TableCell, Box, IconButton, TableBody, Checkbox } from "@mui/material";
7
6
  import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
8
7
  import { useIntl } from "react-intl";
8
+ import { AddCircle } from "@mui/icons-material";
9
9
  import { CustomTooltip } from "../../ui/tooltip/CustomTooltip.js";
10
- import { MAX_ROWS_NUMBER, SELECTED, DndColumnType } from "./dnd-table.type.js";
10
+ import { MAX_ROWS_NUMBER, SELECTED } from "./dnd-table.type.js";
11
11
  import { DndTableBottomLeftButtons } from "./dnd-table-bottom-left-buttons.js";
12
12
  import { DndTableBottomRightButtons } from "./dnd-table-bottom-right-buttons.js";
13
13
  import { DndTableAddRowsDialog } from "./dnd-table-add-rows-dialog.js";
@@ -15,22 +15,16 @@ import "../../ui/overflowableText/OverflowableText.js";
15
15
  import "../../../utils/conversionUtils.js";
16
16
  import "../../../utils/types/equipmentType.js";
17
17
  import { mergeSx } from "../../../utils/styles.js";
18
- import { ChipItemsInput } from "../../ui/reactHookForm/chip-items-input.js";
19
- import { DirectoryItemsInput } from "../../ui/reactHookForm/DirectoryItemsInput.js";
20
- import { RawReadOnlyInput } from "../../ui/reactHookForm/RawReadOnlyInput.js";
21
- import { AutocompleteInput } from "../../ui/reactHookForm/autocompleteInputs/AutocompleteInput.js";
22
- import { CheckboxInput } from "../../ui/reactHookForm/booleans/CheckboxInput.js";
23
- import { SwitchInput } from "../../ui/reactHookForm/booleans/SwitchInput.js";
24
- import { ErrorInput } from "../../ui/reactHookForm/errorManagement/ErrorInput.js";
25
- import { FieldErrorAlert } from "../../ui/reactHookForm/errorManagement/FieldErrorAlert.js";
26
- import "yup";
27
- import "../../ui/reactHookForm/provider/CustomFormProvider.js";
28
- import "../../ui/reactHookForm/numbers/RangeInput.js";
29
18
  import "localized-countries";
30
19
  import "localized-countries/data/fr";
31
20
  import "localized-countries/data/en";
32
- import { TableNumericalInput } from "../../ui/reactHookForm/tableInputs/table-numerical-input.js";
33
- import { TableTextInput } from "../../ui/reactHookForm/tableInputs/table-text-input.js";
21
+ import "notistack";
22
+ import "../../ui/reactHookForm/provider/CustomFormProvider.js";
23
+ import "yup";
24
+ import { ErrorInput } from "../../ui/reactHookForm/errorManagement/ErrorInput.js";
25
+ import { FieldErrorAlert } from "../../ui/reactHookForm/errorManagement/FieldErrorAlert.js";
26
+ import "../../ui/treeViewFinder/TreeViewFinder.js";
27
+ import "../../ui/reactHookForm/numbers/RangeInput.js";
34
28
  import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
35
29
  import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
36
30
  import "@material-symbols/svg-400/outlined/arrows_input.svg?react";
@@ -38,18 +32,17 @@ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
38
32
  import "@material-symbols/svg-400/outlined/add_notes.svg?react";
39
33
  import "../../ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
40
34
  import "../../ui/reactHookForm/expandableInput/ExpandableInput.js";
41
- import "notistack";
42
35
  import "../../ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
43
- import "../../ui/treeViewFinder/TreeViewFinder.js";
44
36
  import "../../ui/snackbarProvider/SnackbarProvider.js";
45
37
  import "mui-nested-menu";
46
38
  import "react-resizable-panels";
39
+ import { DndTableRow } from "./dnd-table-row.js";
47
40
  const styles = {
48
41
  columnsStyle: {
49
42
  display: "inline-flex",
50
43
  justifyContent: "space-between",
51
44
  alignItems: "center",
52
- margin: 1,
45
+ marginLeft: 1,
53
46
  textTransform: "none"
54
47
  }
55
48
  };
@@ -86,72 +79,9 @@ function MultiCheckbox({
86
79
  }
87
80
  );
88
81
  }
89
- function DefaultTableCell({ arrayFormName, rowIndex, column, width, ...props }) {
90
- return /* @__PURE__ */ jsx(TableCell, { sx: mergeSx({ padding: 1 }, width), children: /* @__PURE__ */ jsx(RawReadOnlyInput, { name: `${arrayFormName}[${rowIndex}].${column.dataKey}`, ...props }) }, column.dataKey);
91
- }
92
- function EditableTableCell({
93
- arrayFormName,
94
- rowIndex,
95
- column,
96
- width,
97
- previousValue,
98
- valueModified,
99
- ...props
100
- }) {
101
- return /* @__PURE__ */ jsxs(TableCell, { sx: mergeSx({ padding: 0.5, maxWidth: column.maxWidth }, width), children: [
102
- column.type === DndColumnType.NUMERIC && /* @__PURE__ */ jsx(
103
- TableNumericalInput,
104
- {
105
- ...props,
106
- name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
107
- previousValue,
108
- valueModified,
109
- adornment: column?.adornment,
110
- isClearable: column?.clearable,
111
- style: {
112
- textAlign: column?.textAlign
113
- }
114
- }
115
- ),
116
- column.type === DndColumnType.TEXT && /* @__PURE__ */ jsx(
117
- TableTextInput,
118
- {
119
- ...props,
120
- name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
121
- hideErrorMessage: column.hideErrorMessage
122
- }
123
- ),
124
- column.type === DndColumnType.AUTOCOMPLETE && /* @__PURE__ */ jsx(
125
- AutocompleteInput,
126
- {
127
- forcePopupIcon: true,
128
- freeSolo: true,
129
- name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
130
- options: column.options,
131
- inputTransform: (value) => value ?? "",
132
- outputTransform: (value) => value,
133
- size: "small"
134
- }
135
- ),
136
- column.type === DndColumnType.DIRECTORY_ITEMS && /* @__PURE__ */ jsx(
137
- DirectoryItemsInput,
138
- {
139
- name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
140
- equipmentTypes: column.equipmentTypes,
141
- elementType: column.elementType,
142
- titleId: column.titleId,
143
- hideErrorMessage: true,
144
- label: void 0
145
- }
146
- ),
147
- column.type === DndColumnType.CHIP_ITEMS && /* @__PURE__ */ jsx(ChipItemsInput, { name: `${arrayFormName}[${rowIndex}].${column.dataKey}`, hideErrorMessage: true }),
148
- column.type === DndColumnType.SWITCH && /* @__PURE__ */ jsx(SwitchInput, { name: `${arrayFormName}[${rowIndex}].${column.dataKey}` }),
149
- column.type === DndColumnType.CUSTOM && column.component(rowIndex)
150
- ] }, column.dataKey);
151
- }
152
82
  function DndTable(props) {
153
83
  const {
154
- arrayFormName,
84
+ name,
155
85
  useFieldArrayOutput,
156
86
  columnsDefinition,
157
87
  tableHeight,
@@ -171,7 +101,11 @@ function DndTable(props) {
171
101
  uploadButtonMessageId = void 0,
172
102
  handleResetButton = void 0,
173
103
  resetButtonMessageId = void 0,
174
- maxRows = MAX_ROWS_NUMBER
104
+ maxRows = MAX_ROWS_NUMBER,
105
+ disabledDeletion,
106
+ multiselect,
107
+ onChange,
108
+ onDelete
175
109
  } = props;
176
110
  const intl = useIntl();
177
111
  const { getValues, setValue, setError, clearErrors } = useFormContext();
@@ -184,25 +118,9 @@ function DndTable(props) {
184
118
  remove
185
119
  } = useFieldArrayOutput;
186
120
  const [openAddRowsDialog, setOpenAddRowsDialog] = useState(false);
187
- function renderTableCell(rowId, rowIndex, column, width) {
188
- const CustomTableCell = column.editable ? EditableTableCell : DefaultTableCell;
189
- return /* @__PURE__ */ jsx(
190
- CustomTableCell,
191
- {
192
- arrayFormName,
193
- rowIndex,
194
- column,
195
- disabled: disableTableCell ? disableTableCell(rowIndex, column, arrayFormName, previousValues) : disabled,
196
- previousValue: getPreviousValue ? getPreviousValue(rowIndex, column, arrayFormName, previousValues) : void 0,
197
- valueModified: isValueModified ? isValueModified(rowIndex, arrayFormName) : false,
198
- width
199
- },
200
- rowId + column.dataKey
201
- );
202
- }
203
121
  const addNewRows = (numberOfRows) => {
204
122
  if (currentRows.length + numberOfRows > maxRows) {
205
- setError(arrayFormName, {
123
+ setError(name, {
206
124
  type: "custom",
207
125
  message: intl.formatMessage(
208
126
  {
@@ -215,11 +133,13 @@ function DndTable(props) {
215
133
  });
216
134
  return;
217
135
  }
218
- clearErrors(arrayFormName);
136
+ clearErrors(name);
219
137
  const rowsToAdd = createRows?.(numberOfRows).map((row) => {
220
138
  return { ...row, [SELECTED]: false };
221
139
  });
222
- append(rowsToAdd);
140
+ if (rowsToAdd) {
141
+ append(rowsToAdd);
142
+ }
223
143
  };
224
144
  const handleAddRowsButton = () => {
225
145
  allowedToAddRows().then((isAllowed) => {
@@ -236,27 +156,37 @@ function DndTable(props) {
236
156
  setOpenAddRowsDialog(false);
237
157
  };
238
158
  const deleteSelectedRows = () => {
239
- const currentRowsValues = getValues(arrayFormName);
159
+ const currentRowsValues = getValues(name);
240
160
  const rowsToDelete = [];
241
161
  for (let i = 0; i < currentRowsValues.length; i++) {
242
162
  if (currentRowsValues[i][SELECTED]) {
243
163
  rowsToDelete.push(i);
244
164
  }
245
165
  }
166
+ const removedRows = rowsToDelete.map((index) => currentRowsValues[index]);
246
167
  remove(rowsToDelete);
168
+ onDelete?.(removedRows);
247
169
  };
170
+ const handleDeleteRow = useCallback(
171
+ (index) => {
172
+ const removedRow = getValues(name)[index];
173
+ remove(index);
174
+ onDelete?.([removedRow]);
175
+ },
176
+ [onDelete, getValues, name, remove]
177
+ );
248
178
  const selectAllRows = () => {
249
179
  for (let i = 0; i < currentRows.length; i++) {
250
- setValue(`${arrayFormName}[${i}].${SELECTED}`, true);
180
+ setValue(`${name}[${i}].${SELECTED}`, true);
251
181
  }
252
182
  };
253
183
  const unselectAllRows = () => {
254
184
  for (let i = 0; i < currentRows.length; i++) {
255
- setValue(`${arrayFormName}[${i}].${SELECTED}`, false);
185
+ setValue(`${name}[${i}].${SELECTED}`, false);
256
186
  }
257
187
  };
258
188
  const moveUpSelectedRows = () => {
259
- const currentRowsValues = getValues(arrayFormName);
189
+ const currentRowsValues = getValues(name);
260
190
  if (currentRowsValues[0][SELECTED]) {
261
191
  return;
262
192
  }
@@ -267,7 +197,7 @@ function DndTable(props) {
267
197
  }
268
198
  };
269
199
  const moveDownSelectedRows = () => {
270
- const currentRowsValues = getValues(arrayFormName);
200
+ const currentRowsValues = getValues(name);
271
201
  if (currentRowsValues[currentRowsValues.length - 1][SELECTED]) {
272
202
  return;
273
203
  }
@@ -277,16 +207,16 @@ function DndTable(props) {
277
207
  }
278
208
  }
279
209
  };
280
- const dragCellWidthsRef = useRef([]);
210
+ const snapshotCellWidthsRef = useRef([]);
281
211
  const cellIdxRef = useRef(0);
282
212
  const onBeforeDragStart = useCallback((start) => {
283
213
  const row = document.querySelector(`[data-rfd-draggable-id="${start.draggableId}"]`);
284
214
  if (row) {
285
- dragCellWidthsRef.current = Array.from(row.cells, (cell) => cell.offsetWidth);
215
+ snapshotCellWidthsRef.current = Array.from(row.cells, (cell) => cell.offsetWidth);
286
216
  }
287
217
  }, []);
288
- const nextLockedWidthSx = useCallback((isDragging) => {
289
- const cellWidths = dragCellWidthsRef.current;
218
+ const nextSnapshotCellWidthSx = useCallback((isDragging) => {
219
+ const cellWidths = snapshotCellWidthsRef.current;
290
220
  const cellIdx = cellIdxRef.current;
291
221
  if (!isDragging || cellWidths[cellIdx] == null) {
292
222
  return void 0;
@@ -295,7 +225,7 @@ function DndTable(props) {
295
225
  return { width: cellWidths[cellIdx], boxSizing: "border-box" };
296
226
  }, []);
297
227
  const onDragEnd = (result) => {
298
- dragCellWidthsRef.current = [];
228
+ snapshotCellWidthsRef.current = [];
299
229
  if (!result.destination) {
300
230
  return;
301
231
  }
@@ -304,21 +234,46 @@ function DndTable(props) {
304
234
  function renderTableHead() {
305
235
  return /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
306
236
  !disableDragAndDrop && /* @__PURE__ */ jsx(TableCell, { sx: { width: "3%" } }),
307
- /* @__PURE__ */ jsx(TableCell, { sx: { width: "5%", textAlign: "center" }, children: /* @__PURE__ */ jsx(
237
+ multiselect && /* @__PURE__ */ jsx(TableCell, { sx: { width: "5%", textAlign: "center" }, children: /* @__PURE__ */ jsx(
308
238
  MultiCheckbox,
309
239
  {
310
- arrayFormName,
240
+ arrayFormName: name,
311
241
  handleClickCheck: selectAllRows,
312
242
  handleClickUncheck: unselectAllRows,
313
243
  disabled: disabled || currentRows.length === 0
314
244
  }
315
245
  ) }),
316
- columnsDefinition.map((column) => /* @__PURE__ */ jsx(TableCell, { sx: { width: column.width, maxWidth: column.maxWidth }, children: /* @__PURE__ */ jsxs(Box, { sx: styles.columnsStyle, children: [
317
- column.label,
318
- column.extra
319
- ] }) }, column.dataKey))
246
+ columnsDefinition.map((column) => /* @__PURE__ */ jsx(
247
+ TableCell,
248
+ {
249
+ sx: mergeSx(
250
+ { width: column.width, maxWidth: column.maxWidth, textAlign: "left" },
251
+ column.sxHeader
252
+ ),
253
+ children: /* @__PURE__ */ jsxs(Box, { sx: styles.columnsStyle, children: [
254
+ column.label,
255
+ column.extra
256
+ ] })
257
+ },
258
+ column.dataKey
259
+ )),
260
+ !disableAddingRows && !multiselect && /* @__PURE__ */ jsx(TableCell, { sx: { width: "5rem", textAlign: "center" }, children: /* @__PURE__ */ jsx(
261
+ CustomTooltip,
262
+ {
263
+ title: intl.formatMessage({
264
+ id: "AddRows"
265
+ }),
266
+ children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { disabled, onClick: handleAddRowsButton, children: /* @__PURE__ */ jsx(AddCircle, {}) }) })
267
+ }
268
+ ) })
320
269
  ] }) });
321
270
  }
271
+ const handleChangeRow = useCallback(
272
+ (index) => {
273
+ onChange?.(getValues(name)[index]);
274
+ },
275
+ [getValues, name, onChange]
276
+ );
322
277
  function renderTableBody(providedDroppable) {
323
278
  return /* @__PURE__ */ jsxs(TableBody, { children: [
324
279
  currentRows.map((row, index) => /* @__PURE__ */ jsx(
@@ -329,43 +284,28 @@ function DndTable(props) {
329
284
  isDragDisabled: disableDragAndDrop,
330
285
  children: (provided, snapshot) => {
331
286
  cellIdxRef.current = 0;
332
- const tableRow = /* @__PURE__ */ jsxs(TableRow, { ref: provided.innerRef, ...provided.draggableProps, children: [
333
- !disableDragAndDrop && /* @__PURE__ */ jsx(
334
- CustomTooltip,
335
- {
336
- title: intl.formatMessage({
337
- id: "DragAndDrop"
338
- }),
339
- children: /* @__PURE__ */ jsx(
340
- TableCell,
341
- {
342
- sx: mergeSx(
343
- { textAlign: "center" },
344
- nextLockedWidthSx(snapshot.isDragging)
345
- ),
346
- ...disabled ? {} : { ...provided.dragHandleProps },
347
- children: /* @__PURE__ */ jsx(DragIndicator, {})
348
- }
349
- )
350
- }
351
- ),
352
- /* @__PURE__ */ jsx(
353
- TableCell,
354
- {
355
- sx: mergeSx({ textAlign: "center" }, nextLockedWidthSx(snapshot.isDragging)),
356
- children: /* @__PURE__ */ jsx(
357
- CheckboxInput,
358
- {
359
- name: `${arrayFormName}[${index}].${SELECTED}`,
360
- formProps: { disabled }
361
- }
362
- )
363
- }
364
- ),
365
- columnsDefinition.map(
366
- (column) => renderTableCell(row.id, index, column, nextLockedWidthSx(snapshot.isDragging))
367
- )
368
- ] });
287
+ const tableRow = /* @__PURE__ */ jsx(
288
+ DndTableRow,
289
+ {
290
+ provided,
291
+ snapshot,
292
+ rowId: row.id,
293
+ tableName: name,
294
+ columnsDefinition,
295
+ index,
296
+ disableDragAndDrop,
297
+ disabled,
298
+ previousValues,
299
+ disableTableCell,
300
+ getPreviousValue,
301
+ isValueModified,
302
+ disabledDeletion,
303
+ onChangeRow: handleChangeRow,
304
+ onDeleteRow: handleDeleteRow,
305
+ multiselect,
306
+ nextSnapshotCellWidthSx
307
+ }
308
+ );
369
309
  return snapshot.isDragging ? createPortal(tableRow, document.body) : tableRow;
370
310
  }
371
311
  },
@@ -391,7 +331,7 @@ function DndTable(props) {
391
331
  ] })
392
332
  }
393
333
  ) }) }),
394
- /* @__PURE__ */ jsx(ErrorInput, { name: arrayFormName, InputField: FieldErrorAlert })
334
+ /* @__PURE__ */ jsx(ErrorInput, { name, InputField: FieldErrorAlert })
395
335
  ] }),
396
336
  /* @__PURE__ */ jsxs(Grid, { container: true, item: true, children: [
397
337
  handleResetButton && handleUploadButton && resetButtonMessageId && uploadButtonMessageId ? /* @__PURE__ */ jsx(
@@ -406,10 +346,10 @@ function DndTable(props) {
406
346
  resetButtonMessageId
407
347
  }
408
348
  ) : null,
409
- /* @__PURE__ */ jsx(
349
+ multiselect && /* @__PURE__ */ jsx(
410
350
  DndTableBottomRightButtons,
411
351
  {
412
- arrayFormName,
352
+ arrayFormName: name,
413
353
  handleAddButton: handleAddRowsButton,
414
354
  handleDeleteButton: deleteSelectedRows,
415
355
  handleMoveUpButton: moveUpSelectedRows,
@@ -1,14 +1,19 @@
1
1
  import { JSX, ReactNode } from 'react';
2
- import { ElementType, EquipmentType } from '../../../utils';
2
+ import { SxProps, Theme } from '@mui/material';
3
+ import { ElementType } from '../../../utils/types/elementType';
4
+ import { EquipmentType } from '../../../utils/types/equipmentType';
5
+ import { Option } from '../../../utils/types/types';
3
6
  export declare const SELECTED = "selected";
4
7
  export declare const MAX_ROWS_NUMBER = 100;
5
8
  export declare enum DndColumnType {
6
9
  TEXT = "TEXT",
7
10
  NUMERIC = "NUMERIC",
8
11
  AUTOCOMPLETE = "AUTOCOMPLETE",
12
+ SELECT = "SELECT",
9
13
  CHIP_ITEMS = "CHIP_ITEMS",
10
14
  DIRECTORY_ITEMS = "DIRECTORY_ITEMS",
11
15
  SWITCH = "SWITCH",
16
+ DESCRIPTIONS = "DESCRIPTIONS",
12
17
  CUSTOM = "CUSTOM"
13
18
  }
14
19
  export interface ColumnBase {
@@ -16,10 +21,12 @@ export interface ColumnBase {
16
21
  maxWidth?: number | string;
17
22
  width?: number | string;
18
23
  label?: string;
24
+ sxHeader?: SxProps<Theme>;
19
25
  extra?: JSX.Element;
20
26
  editable?: boolean;
21
27
  type: DndColumnType;
22
28
  initialValue?: any;
29
+ shouldHandleOnChangeCell?: boolean;
23
30
  hideErrorMessage?: boolean;
24
31
  }
25
32
  export interface ColumnText extends ColumnBase {
@@ -35,7 +42,11 @@ export interface ColumnNumeric extends ColumnBase {
35
42
  }
36
43
  export interface ColumnAutocomplete extends ColumnBase {
37
44
  type: DndColumnType.AUTOCOMPLETE;
38
- options: string[];
45
+ options: Option[];
46
+ }
47
+ export interface ColumnSelect extends ColumnBase {
48
+ type: DndColumnType.SELECT;
49
+ options: Option[];
39
50
  }
40
51
  export interface ColumnDirectoryItem extends ColumnBase {
41
52
  type: DndColumnType.DIRECTORY_ITEMS;
@@ -49,8 +60,11 @@ export interface ColumnChipsItem extends ColumnBase {
49
60
  export interface ColumnSwitchItem extends ColumnBase {
50
61
  type: DndColumnType.SWITCH;
51
62
  }
63
+ export interface ColumnDescriptions extends ColumnBase {
64
+ type: DndColumnType.DESCRIPTIONS;
65
+ }
52
66
  export interface ColumnCustom extends ColumnBase {
53
67
  type: DndColumnType.CUSTOM;
54
68
  component: (rowIndex: number) => ReactNode;
55
69
  }
56
- export type DndColumn = ColumnNumeric | ColumnAutocomplete | ColumnText | ColumnDirectoryItem | ColumnChipsItem | ColumnSwitchItem | ColumnCustom;
70
+ export type DndColumn = ColumnNumeric | ColumnAutocomplete | ColumnSelect | ColumnText | ColumnDirectoryItem | ColumnChipsItem | ColumnSwitchItem | ColumnDescriptions | ColumnCustom;
@@ -4,9 +4,11 @@ var DndColumnType = /* @__PURE__ */ ((DndColumnType2) => {
4
4
  DndColumnType2["TEXT"] = "TEXT";
5
5
  DndColumnType2["NUMERIC"] = "NUMERIC";
6
6
  DndColumnType2["AUTOCOMPLETE"] = "AUTOCOMPLETE";
7
+ DndColumnType2["SELECT"] = "SELECT";
7
8
  DndColumnType2["CHIP_ITEMS"] = "CHIP_ITEMS";
8
9
  DndColumnType2["DIRECTORY_ITEMS"] = "DIRECTORY_ITEMS";
9
10
  DndColumnType2["SWITCH"] = "SWITCH";
11
+ DndColumnType2["DESCRIPTIONS"] = "DESCRIPTIONS";
10
12
  DndColumnType2["CUSTOM"] = "CUSTOM";
11
13
  return DndColumnType2;
12
14
  })(DndColumnType || {});
@@ -4,4 +4,9 @@
4
4
  * License, v. 2.0. If a copy of the MPL was not distributed with this
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
- export * from '../dnd-table-v2';
7
+ export * from './dnd-table';
8
+ export * from './dnd-table.type';
9
+ export * from './dnd-table-utils';
10
+ export * from './dnd-table-add-rows-dialog';
11
+ export * from './dnd-table-bottom-left-buttons';
12
+ export * from './dnd-table-bottom-right-buttons';
@@ -1,9 +1,9 @@
1
- import { DndTable } from "../dnd-table-v2/dnd-table.js";
2
- import { DndColumnType, MAX_ROWS_NUMBER, SELECTED } from "../dnd-table-v2/dnd-table.type.js";
3
- import { getDefaultRowData } from "../dnd-table-v2/dnd-table-utils.js";
4
- import { DndTableAddRowsDialog } from "../dnd-table-v2/dnd-table-add-rows-dialog.js";
5
- import { DndTableBottomLeftButtons } from "../dnd-table-v2/dnd-table-bottom-left-buttons.js";
6
- import { DndTableBottomRightButtons } from "../dnd-table-v2/dnd-table-bottom-right-buttons.js";
1
+ import { DndTable } from "./dnd-table.js";
2
+ import { DndColumnType, MAX_ROWS_NUMBER, SELECTED } from "./dnd-table.type.js";
3
+ import { getDefaultRowData } from "./dnd-table-utils.js";
4
+ import { DndTableAddRowsDialog } from "./dnd-table-add-rows-dialog.js";
5
+ import { DndTableBottomLeftButtons } from "./dnd-table-bottom-left-buttons.js";
6
+ import { DndTableBottomRightButtons } from "./dnd-table-bottom-right-buttons.js";
7
7
  export {
8
8
  DndColumnType,
9
9
  DndTable,
@@ -1,9 +1,9 @@
1
- import { DndTable } from "./dnd-table-v2/dnd-table.js";
2
- import { DndColumnType, MAX_ROWS_NUMBER, SELECTED } from "./dnd-table-v2/dnd-table.type.js";
3
- import { getDefaultRowData } from "./dnd-table-v2/dnd-table-utils.js";
4
- import { DndTableAddRowsDialog } from "./dnd-table-v2/dnd-table-add-rows-dialog.js";
5
- import { DndTableBottomLeftButtons } from "./dnd-table-v2/dnd-table-bottom-left-buttons.js";
6
- import { DndTableBottomRightButtons } from "./dnd-table-v2/dnd-table-bottom-right-buttons.js";
1
+ import { DndTable } from "./dnd-table/dnd-table.js";
2
+ import { DndColumnType, MAX_ROWS_NUMBER, SELECTED } from "./dnd-table/dnd-table.type.js";
3
+ import { getDefaultRowData } from "./dnd-table/dnd-table-utils.js";
4
+ import { DndTableAddRowsDialog } from "./dnd-table/dnd-table-add-rows-dialog.js";
5
+ import { DndTableBottomLeftButtons } from "./dnd-table/dnd-table-bottom-left-buttons.js";
6
+ import { DndTableBottomRightButtons } from "./dnd-table/dnd-table-bottom-right-buttons.js";
7
7
  import { EquipmentItem } from "./elementSearch/elementItem/EquipmentItem.js";
8
8
  import { ElementSearchDialog } from "./elementSearch/elementSearchDialog/ElementSearchDialog.js";
9
9
  import { ElementSearchInput } from "./elementSearch/elementSearchInput/ElementSearchInput.js";
@@ -71,12 +71,12 @@ import { fetchCsvSeparator, useCsvExport } from "./ui/csvDownloader/use-csv-expo
71
71
  import { TreeViewFinder, generateTreeViewFinderClass } from "./ui/treeViewFinder/TreeViewFinder.js";
72
72
  import { doesNodeHasChildren } from "./ui/treeViewFinder/TreeViewUtils.js";
73
73
  import { DirectoryItemSelector } from "./ui/directoryItemSelector/DirectoryItemSelector.js";
74
- import { DndTable } from "./composite/dnd-table-v2/dnd-table.js";
75
- import { DndColumnType, MAX_ROWS_NUMBER, SELECTED } from "./composite/dnd-table-v2/dnd-table.type.js";
76
- import { getDefaultRowData } from "./composite/dnd-table-v2/dnd-table-utils.js";
77
- import { DndTableAddRowsDialog } from "./composite/dnd-table-v2/dnd-table-add-rows-dialog.js";
78
- import { DndTableBottomLeftButtons } from "./composite/dnd-table-v2/dnd-table-bottom-left-buttons.js";
79
- import { DndTableBottomRightButtons } from "./composite/dnd-table-v2/dnd-table-bottom-right-buttons.js";
74
+ import { DndTable } from "./composite/dnd-table/dnd-table.js";
75
+ import { DndColumnType, MAX_ROWS_NUMBER, SELECTED } from "./composite/dnd-table/dnd-table.type.js";
76
+ import { getDefaultRowData } from "./composite/dnd-table/dnd-table-utils.js";
77
+ import { DndTableAddRowsDialog } from "./composite/dnd-table/dnd-table-add-rows-dialog.js";
78
+ import { DndTableBottomLeftButtons } from "./composite/dnd-table/dnd-table-bottom-left-buttons.js";
79
+ import { DndTableBottomRightButtons } from "./composite/dnd-table/dnd-table-bottom-right-buttons.js";
80
80
  import { EquipmentItem } from "./composite/elementSearch/elementItem/EquipmentItem.js";
81
81
  import { ElementSearchDialog } from "./composite/elementSearch/elementSearchDialog/ElementSearchDialog.js";
82
82
  import { ElementSearchInput } from "./composite/elementSearch/elementSearchInput/ElementSearchInput.js";
@@ -5,10 +5,10 @@ import { snackWithFallback } from "../../../utils/error.js";
5
5
  import { arraysContainIdenticalStrings } from "../../../utils/functions.js";
6
6
  import { ElementType } from "../../../utils/types/elementType.js";
7
7
  import "../../../utils/types/equipmentType.js";
8
- import { fetchRootFolders, fetchDirectoryContent } from "../../../services/directory.js";
9
8
  import { getFileIcon } from "../../../utils/mapper/getFileIcon.js";
10
9
  import { TreeViewFinder } from "../treeViewFinder/TreeViewFinder.js";
11
10
  import "react-intl";
11
+ import { fetchRootFolders, fetchDirectoryContent } from "../../../services/directory.js";
12
12
  import { fetchElementsInfos } from "../../../services/explore.js";
13
13
  import "@mui/material";
14
14
  import "localized-countries";
@@ -2,10 +2,10 @@ import { LAST_SELECTED_DIRECTORY, COMMON_APP_NAME } from "../../../utils/constan
2
2
  import "../../../utils/conversionUtils.js";
3
3
  import { ElementType } from "../../../utils/types/elementType.js";
4
4
  import "../../../utils/types/equipmentType.js";
5
- import { fetchDirectoryElementPath } from "../../../services/directory.js";
6
5
  import "react/jsx-runtime";
7
6
  import "@mui/icons-material";
8
7
  import { updateConfigParameter } from "../../../services/config.js";
8
+ import { fetchDirectoryElementPath } from "../../../services/directory.js";
9
9
  function getLastSelectedDirectoryId() {
10
10
  const lastSelectedDirId = localStorage.getItem(LAST_SELECTED_DIRECTORY);
11
11
  if (!lastSelectedDirId || lastSelectedDirId === "null") {
@@ -12,9 +12,9 @@ import { MidFormError } from "./errorManagement/MidFormError.js";
12
12
  import "../../../utils/conversionUtils.js";
13
13
  import "../../../utils/types/equipmentType.js";
14
14
  import { ArrayAction } from "../../../utils/types/types.js";
15
- import { fetchDirectoryElementPath } from "../../../services/directory.js";
16
15
  import { getEquipmentTypeShortLabel } from "../../../utils/labelUtils.js";
17
16
  import { mergeSx } from "../../../utils/styles.js";
17
+ import { fetchDirectoryElementPath } from "../../../services/directory.js";
18
18
  import "localized-countries";
19
19
  import "localized-countries/data/fr";
20
20
  import "localized-countries/data/en";