@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.
- package/dist/components/composite/dnd-table/dnd-table.d.ts +8 -4
- package/dist/components/composite/dnd-table/dnd-table.js +100 -160
- package/dist/components/composite/dnd-table/dnd-table.type.d.ts +17 -3
- package/dist/components/composite/dnd-table/dnd-table.type.js +2 -0
- package/dist/components/composite/dnd-table/index.d.ts +6 -1
- package/dist/components/composite/dnd-table/index.js +6 -6
- package/dist/components/composite/index.js +6 -6
- package/dist/components/index.js +6 -6
- package/dist/components/ui/directoryItemSelector/DirectoryItemSelector.js +1 -1
- package/dist/components/ui/directoryItemSelector/utils.js +1 -1
- package/dist/components/ui/reactHookForm/DirectoryItemsInput.js +1 -1
- package/dist/features/index.js +16 -0
- package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.d.ts +4 -3
- package/dist/features/network-modifications/common/reactiveLimits/reactiveCapabilityCurve/reactiveCapability.utils.js +7 -30
- package/dist/features/network-modifications/common/reactiveLimits/reactiveLimits.utils.d.ts +2 -0
- package/dist/features/network-modifications/generator/generatorDialog.type.d.ts +0 -60
- package/dist/features/network-modifications/generator/index.js +17 -1
- package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.d.ts +6 -0
- package/dist/features/network-modifications/generator/modification/GeneratorDialogHeader.js +109 -0
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabs.d.ts +13 -0
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabs.js +55 -0
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.d.ts +12 -0
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabsContent.js +277 -0
- package/dist/features/network-modifications/generator/modification/GeneratorModificationForm.d.ts +10 -0
- package/dist/features/network-modifications/generator/modification/GeneratorModificationForm.js +52 -0
- package/dist/features/network-modifications/generator/modification/generatorModification.types.d.ts +3 -5
- package/dist/features/network-modifications/generator/modification/generatorModification.utils.d.ts +140 -0
- package/dist/features/network-modifications/generator/modification/generatorModification.utils.js +211 -0
- package/dist/features/network-modifications/generator/modification/generatorTabs.utils.d.ts +8 -0
- package/dist/features/network-modifications/generator/modification/generatorTabs.utils.js +56 -0
- package/dist/features/network-modifications/generator/modification/index.d.ts +6 -0
- package/dist/features/network-modifications/generator/modification/index.js +18 -1
- package/dist/features/network-modifications/index.js +16 -0
- package/dist/features/parameters/common/contingency-table/columns-definitions.d.ts +2 -2
- package/dist/features/parameters/common/contingency-table/columns-definitions.js +6 -6
- package/dist/features/parameters/common/contingency-table/contingency-table.js +1 -1
- package/dist/features/parameters/common/contingency-table/types.d.ts +6 -17
- package/dist/features/parameters/common/parameter-table-field/parameter-table-field.js +2 -2
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +1 -1
- package/dist/features/parameters/dynamic-margin-calculation/loads-variations-parameters.js +1 -1
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +1 -1
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation-inline.js +1 -1
- package/dist/features/parameters/loadflow/load-flow-parameters-inline.js +1 -1
- package/dist/features/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -1
- package/dist/features/parameters/pcc-min/pcc-min-parameters-inline.js +1 -1
- package/dist/features/parameters/security-analysis/columns-definitions.d.ts +3 -3
- package/dist/features/parameters/security-analysis/columns-definitions.js +8 -8
- package/dist/features/parameters/security-analysis/security-analysis-parameters-inline.js +2 -2
- package/dist/features/parameters/security-analysis/security-analysis-parameters-selector.d.ts +1 -1
- package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.d.ts +1 -1
- package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -1
- package/dist/features/parameters/sensi/columns-definitions.js +1 -1
- package/dist/features/parameters/sensi/constants.d.ts +0 -2
- package/dist/features/parameters/sensi/constants.js +0 -4
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-inline.js +1 -1
- package/dist/features/parameters/sensi/use-sensitivity-analysis-parameters.js +33 -32
- package/dist/features/parameters/sensi/utils.d.ts +31 -63
- package/dist/features/parameters/sensi/utils.js +49 -61
- package/dist/features/parameters/short-circuit/short-circuit-parameters-inline.js +1 -1
- package/dist/features/parameters/voltage-init/use-voltage-init-parameters-form.js +1 -1
- package/dist/features/parameters/voltage-init/voltage-init-form-utils.js +1 -1
- package/dist/features/parameters/voltage-init/voltage-init-parameters-inline.js +1 -1
- package/dist/features/parameters/voltage-init/voltage-limits-parameters.js +1 -1
- package/dist/hooks/use-unique-name-validation.js +1 -1
- package/dist/index.js +30 -11
- package/dist/services/directory.d.ts +1 -1
- package/dist/services/index.js +6 -3
- package/dist/services/pcc-min.d.ts +2 -1
- package/dist/services/pcc-min.js +27 -1
- package/dist/services/security-analysis.d.ts +2 -1
- package/dist/services/security-analysis.js +32 -1
- package/dist/services/sensitivity-analysis.d.ts +2 -1
- package/dist/services/sensitivity-analysis.js +87 -1
- package/dist/translations/en/networkModificationsEn.d.ts +2 -0
- package/dist/translations/en/networkModificationsEn.js +2 -0
- package/dist/translations/fr/networkModificationsFr.d.ts +2 -0
- package/dist/translations/fr/networkModificationsFr.js +2 -0
- package/dist/utils/constants/filterConstant.d.ts +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/types/dynamic-security-analysis.type.d.ts +3 -5
- package/dist/utils/types/index.d.ts +1 -0
- package/dist/utils/types/index.js +4 -4
- package/dist/utils/types/parameters.type.d.ts +1 -1
- package/dist/utils/types/pcc-min.type.d.ts +0 -1
- package/dist/utils/types/pcc-min.type.js +0 -21
- package/dist/utils/types/security-analysis.type.d.ts +26 -0
- package/dist/utils/types/security-analysis.type.js +14 -0
- package/dist/utils/types/sensitivity-analysis.type.d.ts +3 -7
- package/dist/utils/types/sensitivity-analysis.type.js +17 -103
- package/dist/utils/types/types.d.ts +7 -0
- package/package.json +1 -1
- package/dist/components/composite/dnd-table-v2/dnd-table-add-rows-dialog.d.ts +0 -13
- package/dist/components/composite/dnd-table-v2/dnd-table-add-rows-dialog.js +0 -69
- package/dist/components/composite/dnd-table-v2/dnd-table-bottom-left-buttons.d.ts +0 -17
- package/dist/components/composite/dnd-table-v2/dnd-table-bottom-left-buttons.js +0 -47
- package/dist/components/composite/dnd-table-v2/dnd-table-bottom-right-buttons.d.ts +0 -17
- package/dist/components/composite/dnd-table-v2/dnd-table-bottom-right-buttons.js +0 -100
- package/dist/components/composite/dnd-table-v2/dnd-table.d.ts +0 -32
- package/dist/components/composite/dnd-table-v2/dnd-table.js +0 -375
- package/dist/components/composite/dnd-table-v2/dnd-table.type.d.ts +0 -70
- package/dist/components/composite/dnd-table-v2/dnd-table.type.js +0 -19
- package/dist/components/composite/dnd-table-v2/index.d.ts +0 -12
- package/dist/components/composite/dnd-table-v2/index.js +0 -16
- package/dist/features/parameters/common/parameter-table/constants.d.ts +0 -11
- package/dist/features/parameters/common/parameter-table/constants.js +0 -12
- package/dist/features/parameters/common/parameter-table/parameter-table.d.ts +0 -15
- package/dist/features/parameters/common/parameter-table/parameter-table.js +0 -98
- package/dist/features/parameters/common/parameter-table/table-cell.d.ts +0 -8
- package/dist/features/parameters/common/parameter-table/table-cell.js +0 -83
- package/dist/features/parameters/common/parameter-table/table-row.d.ts +0 -11
- package/dist/features/parameters/common/parameter-table/table-row.js +0 -41
- package/dist/features/parameters/common/parameter-table/types.d.ts +0 -26
- package/dist/features/parameters/common/parameter-table/types.js +0 -1
- package/dist/features/parameters/security-analysis/types.d.ts +0 -20
- package/dist/features/parameters/security-analysis/types.js +0 -42
- /package/dist/components/composite/{dnd-table-v2 → dnd-table}/deletable-table-row.d.ts +0 -0
- /package/dist/components/composite/{dnd-table-v2 → dnd-table}/deletable-table-row.js +0 -0
- /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-row.d.ts +0 -0
- /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-row.js +0 -0
- /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-utils.d.ts +0 -0
- /package/dist/components/composite/{dnd-table-v2 → dnd-table}/dnd-table-utils.js +0 -0
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
import { useState, useCallback, useRef, useMemo } from "react";
|
|
4
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
5
|
-
import { Grid, TableContainer, Table, TableHead, TableRow, TableCell, Box, IconButton, TableBody, Checkbox } from "@mui/material";
|
|
6
|
-
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
7
|
-
import { useIntl } from "react-intl";
|
|
8
|
-
import { AddCircle } from "@mui/icons-material";
|
|
9
|
-
import { CustomTooltip } from "../../ui/tooltip/CustomTooltip.js";
|
|
10
|
-
import { MAX_ROWS_NUMBER, SELECTED } from "./dnd-table.type.js";
|
|
11
|
-
import { DndTableBottomLeftButtons } from "./dnd-table-bottom-left-buttons.js";
|
|
12
|
-
import { DndTableBottomRightButtons } from "./dnd-table-bottom-right-buttons.js";
|
|
13
|
-
import { DndTableAddRowsDialog } from "./dnd-table-add-rows-dialog.js";
|
|
14
|
-
import "../../ui/overflowableText/OverflowableText.js";
|
|
15
|
-
import "../../../utils/conversionUtils.js";
|
|
16
|
-
import "../../../utils/types/equipmentType.js";
|
|
17
|
-
import { mergeSx } from "../../../utils/styles.js";
|
|
18
|
-
import "localized-countries";
|
|
19
|
-
import "localized-countries/data/fr";
|
|
20
|
-
import "localized-countries/data/en";
|
|
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";
|
|
28
|
-
import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
|
|
29
|
-
import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
|
|
30
|
-
import "@material-symbols/svg-400/outlined/arrows_input.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 "../../ui/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
34
|
-
import "../../ui/reactHookForm/expandableInput/ExpandableInput.js";
|
|
35
|
-
import "../../ui/dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
36
|
-
import "../../ui/snackbarProvider/SnackbarProvider.js";
|
|
37
|
-
import "mui-nested-menu";
|
|
38
|
-
import "react-resizable-panels";
|
|
39
|
-
import { DndTableRow } from "./dnd-table-row.js";
|
|
40
|
-
const styles = {
|
|
41
|
-
columnsStyle: {
|
|
42
|
-
display: "inline-flex",
|
|
43
|
-
justifyContent: "space-between",
|
|
44
|
-
alignItems: "center",
|
|
45
|
-
marginLeft: 1,
|
|
46
|
-
textTransform: "none"
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
function MultiCheckbox({
|
|
50
|
-
arrayFormName,
|
|
51
|
-
handleClickCheck,
|
|
52
|
-
handleClickUncheck,
|
|
53
|
-
...props
|
|
54
|
-
}) {
|
|
55
|
-
const arrayToWatch = useWatch({
|
|
56
|
-
name: arrayFormName
|
|
57
|
-
});
|
|
58
|
-
const allRowSelected = useMemo(
|
|
59
|
-
() => arrayToWatch ? arrayToWatch?.every((row) => row[SELECTED]) : false,
|
|
60
|
-
[arrayToWatch]
|
|
61
|
-
);
|
|
62
|
-
const someRowSelected = useMemo(
|
|
63
|
-
() => arrayToWatch ? arrayToWatch?.some((row) => row[SELECTED]) : false,
|
|
64
|
-
[arrayToWatch]
|
|
65
|
-
);
|
|
66
|
-
return /* @__PURE__ */ jsx(
|
|
67
|
-
Checkbox,
|
|
68
|
-
{
|
|
69
|
-
checked: arrayToWatch?.length > 0 && allRowSelected,
|
|
70
|
-
indeterminate: someRowSelected && !allRowSelected,
|
|
71
|
-
onChange: (event) => {
|
|
72
|
-
if (event.target.checked) {
|
|
73
|
-
handleClickCheck();
|
|
74
|
-
} else {
|
|
75
|
-
handleClickUncheck();
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
...props
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
function DndTable(props) {
|
|
83
|
-
const {
|
|
84
|
-
name,
|
|
85
|
-
useFieldArrayOutput,
|
|
86
|
-
columnsDefinition,
|
|
87
|
-
tableHeight,
|
|
88
|
-
allowedToAddRows = () => Promise.resolve(true),
|
|
89
|
-
createRows,
|
|
90
|
-
disabled = false,
|
|
91
|
-
withResetButton = false,
|
|
92
|
-
withAddRowsDialog = true,
|
|
93
|
-
previousValues,
|
|
94
|
-
disableTableCell,
|
|
95
|
-
getPreviousValue,
|
|
96
|
-
isValueModified,
|
|
97
|
-
disableAddingRows = false,
|
|
98
|
-
showMoveArrow = true,
|
|
99
|
-
disableDragAndDrop = false,
|
|
100
|
-
handleUploadButton = void 0,
|
|
101
|
-
uploadButtonMessageId = void 0,
|
|
102
|
-
handleResetButton = void 0,
|
|
103
|
-
resetButtonMessageId = void 0,
|
|
104
|
-
maxRows = MAX_ROWS_NUMBER,
|
|
105
|
-
disabledDeletion,
|
|
106
|
-
multiselect,
|
|
107
|
-
onChange,
|
|
108
|
-
onDelete
|
|
109
|
-
} = props;
|
|
110
|
-
const intl = useIntl();
|
|
111
|
-
const { getValues, setValue, setError, clearErrors } = useFormContext();
|
|
112
|
-
const {
|
|
113
|
-
fields: currentRows,
|
|
114
|
-
// don't use it to access form data ! check doc
|
|
115
|
-
move,
|
|
116
|
-
swap,
|
|
117
|
-
append,
|
|
118
|
-
remove
|
|
119
|
-
} = useFieldArrayOutput;
|
|
120
|
-
const [openAddRowsDialog, setOpenAddRowsDialog] = useState(false);
|
|
121
|
-
const addNewRows = (numberOfRows) => {
|
|
122
|
-
if (currentRows.length + numberOfRows > maxRows) {
|
|
123
|
-
setError(name, {
|
|
124
|
-
type: "custom",
|
|
125
|
-
message: intl.formatMessage(
|
|
126
|
-
{
|
|
127
|
-
id: "MaximumRowNumberError"
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
value: maxRows
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
});
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
clearErrors(name);
|
|
137
|
-
const rowsToAdd = createRows?.(numberOfRows).map((row) => {
|
|
138
|
-
return { ...row, [SELECTED]: false };
|
|
139
|
-
});
|
|
140
|
-
if (rowsToAdd) {
|
|
141
|
-
append(rowsToAdd);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
const handleAddRowsButton = () => {
|
|
145
|
-
allowedToAddRows().then((isAllowed) => {
|
|
146
|
-
if (isAllowed) {
|
|
147
|
-
if (withAddRowsDialog) {
|
|
148
|
-
setOpenAddRowsDialog(true);
|
|
149
|
-
} else {
|
|
150
|
-
addNewRows(1);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
const handleCloseAddRowsDialog = () => {
|
|
156
|
-
setOpenAddRowsDialog(false);
|
|
157
|
-
};
|
|
158
|
-
const deleteSelectedRows = () => {
|
|
159
|
-
const currentRowsValues = getValues(name);
|
|
160
|
-
const rowsToDelete = [];
|
|
161
|
-
for (let i = 0; i < currentRowsValues.length; i++) {
|
|
162
|
-
if (currentRowsValues[i][SELECTED]) {
|
|
163
|
-
rowsToDelete.push(i);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const removedRows = rowsToDelete.map((index) => currentRowsValues[index]);
|
|
167
|
-
remove(rowsToDelete);
|
|
168
|
-
onDelete?.(removedRows);
|
|
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
|
-
);
|
|
178
|
-
const selectAllRows = () => {
|
|
179
|
-
for (let i = 0; i < currentRows.length; i++) {
|
|
180
|
-
setValue(`${name}[${i}].${SELECTED}`, true);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
const unselectAllRows = () => {
|
|
184
|
-
for (let i = 0; i < currentRows.length; i++) {
|
|
185
|
-
setValue(`${name}[${i}].${SELECTED}`, false);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
const moveUpSelectedRows = () => {
|
|
189
|
-
const currentRowsValues = getValues(name);
|
|
190
|
-
if (currentRowsValues[0][SELECTED]) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
for (let i = 1; i < currentRowsValues.length; i++) {
|
|
194
|
-
if (currentRowsValues[i][SELECTED]) {
|
|
195
|
-
swap(i - 1, i);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
const moveDownSelectedRows = () => {
|
|
200
|
-
const currentRowsValues = getValues(name);
|
|
201
|
-
if (currentRowsValues[currentRowsValues.length - 1][SELECTED]) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
for (let i = currentRowsValues.length - 2; i >= 0; i--) {
|
|
205
|
-
if (currentRowsValues[i][SELECTED]) {
|
|
206
|
-
swap(i, i + 1);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
const snapshotCellWidthsRef = useRef([]);
|
|
211
|
-
const cellIdxRef = useRef(0);
|
|
212
|
-
const onBeforeDragStart = useCallback((start) => {
|
|
213
|
-
const row = document.querySelector(`[data-rfd-draggable-id="${start.draggableId}"]`);
|
|
214
|
-
if (row) {
|
|
215
|
-
snapshotCellWidthsRef.current = Array.from(row.cells, (cell) => cell.offsetWidth);
|
|
216
|
-
}
|
|
217
|
-
}, []);
|
|
218
|
-
const nextSnapshotCellWidthSx = useCallback((isDragging) => {
|
|
219
|
-
const cellWidths = snapshotCellWidthsRef.current;
|
|
220
|
-
const cellIdx = cellIdxRef.current;
|
|
221
|
-
if (!isDragging || cellWidths[cellIdx] == null) {
|
|
222
|
-
return void 0;
|
|
223
|
-
}
|
|
224
|
-
cellIdxRef.current += 1;
|
|
225
|
-
return { width: cellWidths[cellIdx], boxSizing: "border-box" };
|
|
226
|
-
}, []);
|
|
227
|
-
const onDragEnd = (result) => {
|
|
228
|
-
snapshotCellWidthsRef.current = [];
|
|
229
|
-
if (!result.destination) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
move(result.source.index, result.destination.index);
|
|
233
|
-
};
|
|
234
|
-
function renderTableHead() {
|
|
235
|
-
return /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
236
|
-
!disableDragAndDrop && /* @__PURE__ */ jsx(TableCell, { sx: { width: "3%" } }),
|
|
237
|
-
multiselect && /* @__PURE__ */ jsx(TableCell, { sx: { width: "5%", textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
238
|
-
MultiCheckbox,
|
|
239
|
-
{
|
|
240
|
-
arrayFormName: name,
|
|
241
|
-
handleClickCheck: selectAllRows,
|
|
242
|
-
handleClickUncheck: unselectAllRows,
|
|
243
|
-
disabled: disabled || currentRows.length === 0
|
|
244
|
-
}
|
|
245
|
-
) }),
|
|
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: disableAddingRows, onClick: handleAddRowsButton, children: /* @__PURE__ */ jsx(AddCircle, {}) }) })
|
|
267
|
-
}
|
|
268
|
-
) })
|
|
269
|
-
] }) });
|
|
270
|
-
}
|
|
271
|
-
const handleChangeRow = useCallback(
|
|
272
|
-
(index) => {
|
|
273
|
-
onChange?.(getValues(name)[index]);
|
|
274
|
-
},
|
|
275
|
-
[getValues, name, onChange]
|
|
276
|
-
);
|
|
277
|
-
function renderTableBody(providedDroppable) {
|
|
278
|
-
return /* @__PURE__ */ jsxs(TableBody, { children: [
|
|
279
|
-
currentRows.map((row, index) => /* @__PURE__ */ jsx(
|
|
280
|
-
Draggable,
|
|
281
|
-
{
|
|
282
|
-
draggableId: row.id.toString(),
|
|
283
|
-
index,
|
|
284
|
-
isDragDisabled: disableDragAndDrop,
|
|
285
|
-
children: (provided, snapshot) => {
|
|
286
|
-
cellIdxRef.current = 0;
|
|
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
|
-
);
|
|
309
|
-
return snapshot.isDragging ? createPortal(tableRow, document.body) : tableRow;
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
row.id
|
|
313
|
-
)),
|
|
314
|
-
providedDroppable.placeholder
|
|
315
|
-
] });
|
|
316
|
-
}
|
|
317
|
-
return /* @__PURE__ */ jsxs(Grid, { item: true, container: true, spacing: 1, children: [
|
|
318
|
-
/* @__PURE__ */ jsxs(Grid, { item: true, container: true, children: [
|
|
319
|
-
/* @__PURE__ */ jsx(DragDropContext, { onBeforeDragStart, onDragEnd, children: /* @__PURE__ */ jsx(Droppable, { droppableId: "tapTable", isDropDisabled: disabled, children: (provided) => /* @__PURE__ */ jsx(
|
|
320
|
-
TableContainer,
|
|
321
|
-
{
|
|
322
|
-
ref: provided.innerRef,
|
|
323
|
-
...provided.droppableProps,
|
|
324
|
-
sx: {
|
|
325
|
-
height: tableHeight,
|
|
326
|
-
border: "solid 1px rgba(0,0,0,0.1)"
|
|
327
|
-
},
|
|
328
|
-
children: /* @__PURE__ */ jsxs(Table, { stickyHeader: true, size: "small", padding: "none", children: [
|
|
329
|
-
renderTableHead(),
|
|
330
|
-
renderTableBody(provided)
|
|
331
|
-
] })
|
|
332
|
-
}
|
|
333
|
-
) }) }),
|
|
334
|
-
/* @__PURE__ */ jsx(ErrorInput, { name, InputField: FieldErrorAlert })
|
|
335
|
-
] }),
|
|
336
|
-
/* @__PURE__ */ jsxs(Grid, { container: true, item: true, children: [
|
|
337
|
-
handleResetButton && handleUploadButton && resetButtonMessageId && uploadButtonMessageId ? /* @__PURE__ */ jsx(
|
|
338
|
-
DndTableBottomLeftButtons,
|
|
339
|
-
{
|
|
340
|
-
withResetButton,
|
|
341
|
-
disableUploadButton: disableAddingRows,
|
|
342
|
-
disabled,
|
|
343
|
-
handleUploadButton,
|
|
344
|
-
uploadButtonMessageId,
|
|
345
|
-
handleResetButton,
|
|
346
|
-
resetButtonMessageId
|
|
347
|
-
}
|
|
348
|
-
) : null,
|
|
349
|
-
multiselect && /* @__PURE__ */ jsx(
|
|
350
|
-
DndTableBottomRightButtons,
|
|
351
|
-
{
|
|
352
|
-
arrayFormName: name,
|
|
353
|
-
handleAddButton: handleAddRowsButton,
|
|
354
|
-
handleDeleteButton: deleteSelectedRows,
|
|
355
|
-
handleMoveUpButton: moveUpSelectedRows,
|
|
356
|
-
handleMoveDownButton: moveDownSelectedRows,
|
|
357
|
-
disableAddingRows,
|
|
358
|
-
showMoveArrow,
|
|
359
|
-
disabled
|
|
360
|
-
}
|
|
361
|
-
)
|
|
362
|
-
] }),
|
|
363
|
-
/* @__PURE__ */ jsx(
|
|
364
|
-
DndTableAddRowsDialog,
|
|
365
|
-
{
|
|
366
|
-
open: openAddRowsDialog,
|
|
367
|
-
handleAddButton: addNewRows,
|
|
368
|
-
onClose: handleCloseAddRowsDialog
|
|
369
|
-
}
|
|
370
|
-
)
|
|
371
|
-
] });
|
|
372
|
-
}
|
|
373
|
-
export {
|
|
374
|
-
DndTable
|
|
375
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { JSX, ReactNode } from 'react';
|
|
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';
|
|
6
|
-
export declare const SELECTED = "selected";
|
|
7
|
-
export declare const MAX_ROWS_NUMBER = 100;
|
|
8
|
-
export declare enum DndColumnType {
|
|
9
|
-
TEXT = "TEXT",
|
|
10
|
-
NUMERIC = "NUMERIC",
|
|
11
|
-
AUTOCOMPLETE = "AUTOCOMPLETE",
|
|
12
|
-
SELECT = "SELECT",
|
|
13
|
-
CHIP_ITEMS = "CHIP_ITEMS",
|
|
14
|
-
DIRECTORY_ITEMS = "DIRECTORY_ITEMS",
|
|
15
|
-
SWITCH = "SWITCH",
|
|
16
|
-
DESCRIPTIONS = "DESCRIPTIONS",
|
|
17
|
-
CUSTOM = "CUSTOM"
|
|
18
|
-
}
|
|
19
|
-
export interface ColumnBase {
|
|
20
|
-
dataKey: string;
|
|
21
|
-
maxWidth?: number | string;
|
|
22
|
-
width?: number | string;
|
|
23
|
-
label?: string;
|
|
24
|
-
sxHeader?: SxProps<Theme>;
|
|
25
|
-
extra?: JSX.Element;
|
|
26
|
-
editable?: boolean;
|
|
27
|
-
type: DndColumnType;
|
|
28
|
-
initialValue?: any;
|
|
29
|
-
shouldHandleOnChangeCell?: boolean;
|
|
30
|
-
hideErrorMessage?: boolean;
|
|
31
|
-
}
|
|
32
|
-
export interface ColumnText extends ColumnBase {
|
|
33
|
-
type: DndColumnType.TEXT;
|
|
34
|
-
}
|
|
35
|
-
export interface ColumnNumeric extends ColumnBase {
|
|
36
|
-
type: DndColumnType.NUMERIC;
|
|
37
|
-
adornment?: {
|
|
38
|
-
text: string;
|
|
39
|
-
};
|
|
40
|
-
clearable?: boolean;
|
|
41
|
-
textAlign?: 'right' | 'left';
|
|
42
|
-
}
|
|
43
|
-
export interface ColumnAutocomplete extends ColumnBase {
|
|
44
|
-
type: DndColumnType.AUTOCOMPLETE;
|
|
45
|
-
options: Option[];
|
|
46
|
-
}
|
|
47
|
-
export interface ColumnSelect extends ColumnBase {
|
|
48
|
-
type: DndColumnType.SELECT;
|
|
49
|
-
options: Option[];
|
|
50
|
-
}
|
|
51
|
-
export interface ColumnDirectoryItem extends ColumnBase {
|
|
52
|
-
type: DndColumnType.DIRECTORY_ITEMS;
|
|
53
|
-
equipmentTypes: EquipmentType[];
|
|
54
|
-
elementType: ElementType;
|
|
55
|
-
titleId: string;
|
|
56
|
-
}
|
|
57
|
-
export interface ColumnChipsItem extends ColumnBase {
|
|
58
|
-
type: DndColumnType.CHIP_ITEMS;
|
|
59
|
-
}
|
|
60
|
-
export interface ColumnSwitchItem extends ColumnBase {
|
|
61
|
-
type: DndColumnType.SWITCH;
|
|
62
|
-
}
|
|
63
|
-
export interface ColumnDescriptions extends ColumnBase {
|
|
64
|
-
type: DndColumnType.DESCRIPTIONS;
|
|
65
|
-
}
|
|
66
|
-
export interface ColumnCustom extends ColumnBase {
|
|
67
|
-
type: DndColumnType.CUSTOM;
|
|
68
|
-
component: (rowIndex: number) => ReactNode;
|
|
69
|
-
}
|
|
70
|
-
export type DndColumn = ColumnNumeric | ColumnAutocomplete | ColumnSelect | ColumnText | ColumnDirectoryItem | ColumnChipsItem | ColumnSwitchItem | ColumnDescriptions | ColumnCustom;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const SELECTED = "selected";
|
|
2
|
-
const MAX_ROWS_NUMBER = 100;
|
|
3
|
-
var DndColumnType = /* @__PURE__ */ ((DndColumnType2) => {
|
|
4
|
-
DndColumnType2["TEXT"] = "TEXT";
|
|
5
|
-
DndColumnType2["NUMERIC"] = "NUMERIC";
|
|
6
|
-
DndColumnType2["AUTOCOMPLETE"] = "AUTOCOMPLETE";
|
|
7
|
-
DndColumnType2["SELECT"] = "SELECT";
|
|
8
|
-
DndColumnType2["CHIP_ITEMS"] = "CHIP_ITEMS";
|
|
9
|
-
DndColumnType2["DIRECTORY_ITEMS"] = "DIRECTORY_ITEMS";
|
|
10
|
-
DndColumnType2["SWITCH"] = "SWITCH";
|
|
11
|
-
DndColumnType2["DESCRIPTIONS"] = "DESCRIPTIONS";
|
|
12
|
-
DndColumnType2["CUSTOM"] = "CUSTOM";
|
|
13
|
-
return DndColumnType2;
|
|
14
|
-
})(DndColumnType || {});
|
|
15
|
-
export {
|
|
16
|
-
DndColumnType,
|
|
17
|
-
MAX_ROWS_NUMBER,
|
|
18
|
-
SELECTED
|
|
19
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025, RTE (http://www.rte-france.com)
|
|
3
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
-
*/
|
|
7
|
-
export * from './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,16 +0,0 @@
|
|
|
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
|
-
export {
|
|
8
|
-
DndColumnType,
|
|
9
|
-
DndTable,
|
|
10
|
-
DndTableAddRowsDialog,
|
|
11
|
-
DndTableBottomLeftButtons,
|
|
12
|
-
DndTableBottomRightButtons,
|
|
13
|
-
MAX_ROWS_NUMBER,
|
|
14
|
-
SELECTED,
|
|
15
|
-
getDefaultRowData
|
|
16
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026, RTE (http://www.rte-france.com)
|
|
3
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
-
*/
|
|
7
|
-
export declare const MAX_ROWS_NUMBER = 100;
|
|
8
|
-
export declare const NAME = "name";
|
|
9
|
-
export declare const ID = "id";
|
|
10
|
-
export declare const ACTIVATED = "activated";
|
|
11
|
-
export declare const DESCRIPTION = "description";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FieldValues, UseFieldArrayReturn } from 'react-hook-form';
|
|
2
|
-
import { ColumnsDef } from './types';
|
|
3
|
-
interface ParameterTableProps {
|
|
4
|
-
arrayFormName: string;
|
|
5
|
-
useFieldArrayOutput: UseFieldArrayReturn;
|
|
6
|
-
columnsDefinition: ColumnsDef[];
|
|
7
|
-
tableHeight: number;
|
|
8
|
-
createRows: (a: number) => void;
|
|
9
|
-
disableAdd?: boolean;
|
|
10
|
-
disableDelete?: boolean;
|
|
11
|
-
onFormChanged: () => void;
|
|
12
|
-
isValidParameterRow: (fieldValue: FieldValues) => any;
|
|
13
|
-
}
|
|
14
|
-
export declare function ParameterTable({ arrayFormName, useFieldArrayOutput, columnsDefinition, tableHeight, createRows, disableAdd, disableDelete, onFormChanged, isValidParameterRow, }: Readonly<ParameterTableProps>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { TableContainer, Table, TableHead, TableRow, TableCell, Box, IconButton, TableBody } from "@mui/material";
|
|
3
|
-
import { AddCircle } from "@mui/icons-material";
|
|
4
|
-
import { useRef, useCallback } from "react";
|
|
5
|
-
import { useIntl } from "react-intl";
|
|
6
|
-
import { useFormContext } from "react-hook-form";
|
|
7
|
-
import { CustomTooltip } from "../../../../components/ui/tooltip/CustomTooltip.js";
|
|
8
|
-
import { TableRowComponent } from "./table-row.js";
|
|
9
|
-
import { MAX_ROWS_NUMBER } from "./constants.js";
|
|
10
|
-
function ParameterTable({
|
|
11
|
-
arrayFormName,
|
|
12
|
-
useFieldArrayOutput,
|
|
13
|
-
columnsDefinition,
|
|
14
|
-
tableHeight,
|
|
15
|
-
createRows,
|
|
16
|
-
disableAdd,
|
|
17
|
-
disableDelete = false,
|
|
18
|
-
onFormChanged,
|
|
19
|
-
isValidParameterRow
|
|
20
|
-
}) {
|
|
21
|
-
const intl = useIntl();
|
|
22
|
-
const { getValues } = useFormContext();
|
|
23
|
-
const { fields: currentRows, append, remove } = useFieldArrayOutput;
|
|
24
|
-
const validRowCountRef = useRef(
|
|
25
|
-
(getValues(arrayFormName) || []).filter((row) => isValidParameterRow(row)).length
|
|
26
|
-
);
|
|
27
|
-
const handleRowChanged = useCallback(
|
|
28
|
-
(index) => {
|
|
29
|
-
const currentRowValues = getValues(arrayFormName);
|
|
30
|
-
const row = currentRowValues[index];
|
|
31
|
-
const currentValidRowCount = currentRowValues.filter((r) => isValidParameterRow(r)).length;
|
|
32
|
-
const previousValidRowCount = validRowCountRef.current;
|
|
33
|
-
validRowCountRef.current = currentValidRowCount;
|
|
34
|
-
if (currentValidRowCount !== previousValidRowCount || isValidParameterRow(row)) {
|
|
35
|
-
onFormChanged();
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
[getValues, arrayFormName, isValidParameterRow, onFormChanged]
|
|
39
|
-
);
|
|
40
|
-
const handleAddRowsButton = useCallback(() => {
|
|
41
|
-
if (currentRows.length >= MAX_ROWS_NUMBER) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
append(createRows(1));
|
|
45
|
-
}, [append, createRows, currentRows.length]);
|
|
46
|
-
const handleDeleteButton = useCallback(
|
|
47
|
-
(index) => {
|
|
48
|
-
const currentRowsValues = getValues(arrayFormName);
|
|
49
|
-
if (index >= 0 && index < currentRowsValues.length) {
|
|
50
|
-
const wasValid = isValidParameterRow(currentRowsValues[index]);
|
|
51
|
-
remove(index);
|
|
52
|
-
if (wasValid) {
|
|
53
|
-
validRowCountRef.current -= 1;
|
|
54
|
-
onFormChanged();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
[arrayFormName, getValues, isValidParameterRow, onFormChanged, remove]
|
|
59
|
-
);
|
|
60
|
-
return /* @__PURE__ */ jsx(
|
|
61
|
-
TableContainer,
|
|
62
|
-
{
|
|
63
|
-
sx: {
|
|
64
|
-
height: tableHeight,
|
|
65
|
-
border: "solid 0px rgba(0,0,0,0.1)"
|
|
66
|
-
},
|
|
67
|
-
children: /* @__PURE__ */ jsxs(Table, { stickyHeader: true, size: "small", sx: { tableLayout: "fixed" }, children: [
|
|
68
|
-
/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
69
|
-
columnsDefinition.map((column) => /* @__PURE__ */ jsx(TableCell, { sx: { width: column.width, textAlign: "center" }, children: /* @__PURE__ */ jsx(Box, { children: column.label }) }, column.dataKey)),
|
|
70
|
-
/* @__PURE__ */ jsx(TableCell, { sx: { width: "5rem", textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
71
|
-
CustomTooltip,
|
|
72
|
-
{
|
|
73
|
-
title: intl.formatMessage({
|
|
74
|
-
id: "AddRows"
|
|
75
|
-
}),
|
|
76
|
-
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { disabled: disableAdd, onClick: handleAddRowsButton, children: /* @__PURE__ */ jsx(AddCircle, {}) }) })
|
|
77
|
-
}
|
|
78
|
-
) })
|
|
79
|
-
] }) }),
|
|
80
|
-
/* @__PURE__ */ jsx(TableBody, { children: currentRows.map((row, index) => /* @__PURE__ */ jsx(
|
|
81
|
-
TableRowComponent,
|
|
82
|
-
{
|
|
83
|
-
arrayFormName,
|
|
84
|
-
columnsDefinition,
|
|
85
|
-
index,
|
|
86
|
-
handleDeleteButton,
|
|
87
|
-
disableDelete,
|
|
88
|
-
handleRowChanged
|
|
89
|
-
},
|
|
90
|
-
row.id
|
|
91
|
-
)) })
|
|
92
|
-
] })
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
export {
|
|
97
|
-
ParameterTable
|
|
98
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
-
*/
|
|
7
|
-
declare function EditableTableCell(arrayFormName: string, rowIndex: number, column: any, onRowChanged: () => void): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export default EditableTableCell;
|