@gridsuite/commons-ui 0.107.1 → 0.108.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/dialogs/elementSaveDialog/ElementSaveDialog.js +10 -10
- package/dist/components/dnd-table/dnd-table-add-rows-dialog.d.ts +13 -0
- package/dist/components/dnd-table/dnd-table-add-rows-dialog.js +69 -0
- package/dist/components/dnd-table/dnd-table-bottom-left-buttons.d.ts +17 -0
- package/dist/components/dnd-table/dnd-table-bottom-left-buttons.js +48 -0
- package/dist/components/dnd-table/dnd-table-bottom-right-buttons.d.ts +17 -0
- package/dist/components/dnd-table/dnd-table-bottom-right-buttons.js +104 -0
- package/dist/components/dnd-table/dnd-table.d.ts +28 -0
- package/dist/components/dnd-table/dnd-table.js +394 -0
- package/dist/components/dnd-table/dnd-table.type.d.ts +51 -0
- package/dist/components/dnd-table/dnd-table.type.js +16 -0
- package/dist/components/dnd-table/index.d.ts +11 -0
- package/dist/components/dnd-table/index.js +14 -0
- package/dist/components/filter/HeaderFilterForm.js +4 -4
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +57 -1
- package/dist/components/inputs/index.js +6 -0
- package/dist/components/inputs/reactHookForm/chip-items-input.d.ts +13 -0
- package/dist/components/inputs/reactHookForm/chip-items-input.js +129 -0
- package/dist/components/inputs/reactHookForm/index.d.ts +2 -0
- package/dist/components/inputs/reactHookForm/index.js +6 -0
- package/dist/components/inputs/reactHookForm/tableInputs/index.d.ts +8 -0
- package/dist/components/inputs/reactHookForm/tableInputs/index.js +6 -0
- package/dist/components/inputs/reactHookForm/tableInputs/table-numerical-input.d.ts +12 -0
- package/dist/components/inputs/reactHookForm/tableInputs/table-numerical-input.js +110 -0
- package/dist/components/inputs/reactHookForm/tableInputs/table-text-input.d.ts +8 -0
- package/dist/components/inputs/reactHookForm/tableInputs/table-text-input.js +43 -0
- package/dist/components/parameters/common/ProviderParam.js +6 -6
- package/dist/components/parameters/common/constant.d.ts +8 -0
- package/dist/components/parameters/common/constant.js +12 -1
- package/dist/components/parameters/common/index.js +3 -1
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.js +7 -7
- package/dist/components/parameters/common/limitreductions/limit-reductions-table-form.js +6 -6
- package/dist/components/parameters/common/name-element-editor/name-element-editor-form.js +8 -8
- package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.js +11 -10
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-cell.js +7 -7
- package/dist/components/parameters/common/widget/parameter-float.js +6 -6
- package/dist/components/parameters/common/widget/parameter-line-directory-items-input.js +11 -10
- package/dist/components/parameters/common/widget/parameter-line-slider.js +6 -6
- package/dist/components/parameters/index.d.ts +1 -0
- package/dist/components/parameters/index.js +39 -1
- package/dist/components/parameters/loadflow/load-flow-general-parameters.js +6 -6
- package/dist/components/parameters/loadflow/load-flow-parameter-field.js +6 -6
- package/dist/components/parameters/loadflow/load-flow-parameters-form.js +6 -6
- package/dist/components/parameters/loadflow/load-flow-parameters-header.js +6 -6
- package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +3 -3
- package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +2 -1
- package/dist/components/parameters/network-visualizations/network-area-diagram-parameters.js +6 -6
- package/dist/components/parameters/network-visualizations/network-visualizations-form.js +7 -7
- package/dist/components/parameters/network-visualizations/network-visualizations-parameters-dialog.js +3 -3
- package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +2 -2
- package/dist/components/parameters/network-visualizations/use-network-visualizations-parameters-form.js +12 -11
- package/dist/components/parameters/short-circuit/short-circuit-fields.js +5 -5
- package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +3 -3
- package/dist/components/parameters/short-circuit/short-circuit-parameters-form.js +6 -6
- package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +2 -2
- package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +11 -10
- package/dist/components/parameters/voltage-init/constants.d.ts +39 -0
- package/dist/components/parameters/voltage-init/constants.js +65 -0
- package/dist/components/parameters/voltage-init/equipment-selection-parameters.d.ts +7 -0
- package/dist/components/parameters/voltage-init/equipment-selection-parameters.js +119 -0
- package/dist/components/parameters/voltage-init/general-parameters.d.ts +4 -0
- package/dist/components/parameters/voltage-init/general-parameters.js +112 -0
- package/dist/components/parameters/voltage-init/index.d.ts +10 -0
- package/dist/components/parameters/voltage-init/index.js +38 -0
- package/dist/components/parameters/voltage-init/use-voltage-init-parameters-form.d.ts +32 -0
- package/dist/components/parameters/voltage-init/use-voltage-init-parameters-form.js +218 -0
- package/dist/components/parameters/voltage-init/voltage-init-form-utils.d.ts +4 -0
- package/dist/components/parameters/voltage-init/voltage-init-form-utils.js +220 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-dialog.d.ts +2 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-dialog.js +97 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-form.d.ts +30 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-form.js +150 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.d.ts +8 -0
- package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +152 -0
- package/dist/components/parameters/voltage-init/voltage-init.type.d.ts +33 -0
- package/dist/components/parameters/voltage-init/voltage-init.type.js +8 -0
- package/dist/components/parameters/voltage-init/voltage-limits-parameters.d.ts +7 -0
- package/dist/components/parameters/voltage-init/voltage-limits-parameters.js +188 -0
- package/dist/index.js +69 -2
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +6 -2
- package/dist/services/study.d.ts +2 -0
- package/dist/services/study.js +15 -1
- package/dist/services/voltage-init.d.ts +4 -0
- package/dist/services/voltage-init.js +14 -0
- package/dist/translations/en/dndTableEn.d.ts +16 -0
- package/dist/translations/en/dndTableEn.js +13 -0
- package/dist/translations/en/index.d.ts +1 -0
- package/dist/translations/en/index.js +2 -0
- package/dist/translations/en/parameters.d.ts +30 -0
- package/dist/translations/en/parameters.js +31 -1
- package/dist/translations/fr/dndTableFr.d.ts +16 -0
- package/dist/translations/fr/dndTableFr.js +13 -0
- package/dist/translations/fr/index.d.ts +1 -0
- package/dist/translations/fr/index.js +2 -0
- package/dist/translations/fr/parameters.d.ts +31 -0
- package/dist/translations/fr/parameters.js +32 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/validation-functions.d.ts +8 -0
- package/dist/utils/validation-functions.js +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo } from "react";
|
|
3
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
4
|
+
import { Grid, TableContainer, Table, TableHead, TableRow, TableCell, Box, TableBody, Tooltip, Checkbox } from "@mui/material";
|
|
5
|
+
import { DragIndicator } from "@mui/icons-material";
|
|
6
|
+
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
7
|
+
import { useIntl } from "react-intl";
|
|
8
|
+
import { SELECTED, MAX_ROWS_NUMBER, DndColumnType } from "./dnd-table.type.js";
|
|
9
|
+
import { DndTableBottomLeftButtons } from "./dnd-table-bottom-left-buttons.js";
|
|
10
|
+
import { DndTableBottomRightButtons } from "./dnd-table-bottom-right-buttons.js";
|
|
11
|
+
import { DndTableAddRowsDialog } from "./dnd-table-add-rows-dialog.js";
|
|
12
|
+
import { ChipItemsInput } from "../inputs/reactHookForm/chip-items-input.js";
|
|
13
|
+
import { DirectoryItemsInput } from "../inputs/reactHookForm/DirectoryItemsInput.js";
|
|
14
|
+
import { RawReadOnlyInput } from "../inputs/reactHookForm/RawReadOnlyInput.js";
|
|
15
|
+
import "../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
16
|
+
import "../customAGGrid/customAggrid.js";
|
|
17
|
+
import "ag-grid-community";
|
|
18
|
+
import "react-papaparse";
|
|
19
|
+
import "react-csv-downloader";
|
|
20
|
+
import { AutocompleteInput } from "../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
|
|
21
|
+
import { CheckboxInput } from "../inputs/reactHookForm/booleans/CheckboxInput.js";
|
|
22
|
+
import { ErrorInput } from "../inputs/reactHookForm/errorManagement/ErrorInput.js";
|
|
23
|
+
import { FieldErrorAlert } from "../inputs/reactHookForm/errorManagement/FieldErrorAlert.js";
|
|
24
|
+
import "yup";
|
|
25
|
+
import "../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
26
|
+
import "../inputs/reactHookForm/numbers/RangeInput.js";
|
|
27
|
+
import "localized-countries";
|
|
28
|
+
import "localized-countries/data/fr";
|
|
29
|
+
import "localized-countries/data/en";
|
|
30
|
+
import { TableNumericalInput } from "../inputs/reactHookForm/tableInputs/table-numerical-input.js";
|
|
31
|
+
import { TableTextInput } from "../inputs/reactHookForm/tableInputs/table-text-input.js";
|
|
32
|
+
import "../../utils/conversionUtils.js";
|
|
33
|
+
import "../../utils/types/equipmentType.js";
|
|
34
|
+
import "../../utils/yupConfig.js";
|
|
35
|
+
import "notistack";
|
|
36
|
+
import "@react-querybuilder/material";
|
|
37
|
+
import "../filter/expert/expertFilterConstants.js";
|
|
38
|
+
import "../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
39
|
+
import "uuid";
|
|
40
|
+
import "../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
41
|
+
import "react-querybuilder";
|
|
42
|
+
const styles = {
|
|
43
|
+
columnsStyle: {
|
|
44
|
+
display: "inline-flex",
|
|
45
|
+
justifyContent: "space-between",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
margin: 1,
|
|
48
|
+
textTransform: "none"
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function MultiCheckbox({
|
|
52
|
+
arrayFormName,
|
|
53
|
+
handleClickCheck,
|
|
54
|
+
handleClickUncheck,
|
|
55
|
+
...props
|
|
56
|
+
}) {
|
|
57
|
+
const arrayToWatch = useWatch({
|
|
58
|
+
name: arrayFormName
|
|
59
|
+
});
|
|
60
|
+
const allRowSelected = useMemo(
|
|
61
|
+
() => arrayToWatch ? arrayToWatch == null ? void 0 : arrayToWatch.every((row) => row[SELECTED]) : false,
|
|
62
|
+
[arrayToWatch]
|
|
63
|
+
);
|
|
64
|
+
const someRowSelected = useMemo(
|
|
65
|
+
() => arrayToWatch ? arrayToWatch == null ? void 0 : arrayToWatch.some((row) => row[SELECTED]) : false,
|
|
66
|
+
[arrayToWatch]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ jsx(
|
|
69
|
+
Checkbox,
|
|
70
|
+
{
|
|
71
|
+
checked: (arrayToWatch == null ? void 0 : arrayToWatch.length) > 0 && allRowSelected,
|
|
72
|
+
indeterminate: someRowSelected && !allRowSelected,
|
|
73
|
+
onChange: (event) => {
|
|
74
|
+
if (event.target.checked) {
|
|
75
|
+
handleClickCheck();
|
|
76
|
+
} else {
|
|
77
|
+
handleClickUncheck();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
...props
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function DefaultTableCell({ arrayFormName, rowIndex, column, ...props }) {
|
|
85
|
+
return /* @__PURE__ */ jsx(TableCell, { sx: { padding: 1 }, children: /* @__PURE__ */ jsx(RawReadOnlyInput, { name: `${arrayFormName}[${rowIndex}].${column.dataKey}`, ...props }) }, column.dataKey);
|
|
86
|
+
}
|
|
87
|
+
function EditableTableCell({
|
|
88
|
+
arrayFormName,
|
|
89
|
+
rowIndex,
|
|
90
|
+
column,
|
|
91
|
+
previousValue,
|
|
92
|
+
valueModified,
|
|
93
|
+
...props
|
|
94
|
+
}) {
|
|
95
|
+
return /* @__PURE__ */ jsxs(TableCell, { sx: { padding: 0.5, maxWidth: column.maxWidth }, children: [
|
|
96
|
+
column.type === DndColumnType.NUMERIC && /* @__PURE__ */ jsx(
|
|
97
|
+
TableNumericalInput,
|
|
98
|
+
{
|
|
99
|
+
...props,
|
|
100
|
+
name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
|
|
101
|
+
previousValue,
|
|
102
|
+
valueModified,
|
|
103
|
+
adornment: column == null ? void 0 : column.adornment,
|
|
104
|
+
isClearable: column == null ? void 0 : column.clearable,
|
|
105
|
+
style: {
|
|
106
|
+
textAlign: column == null ? void 0 : column.textAlign
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
column.type === DndColumnType.TEXT && /* @__PURE__ */ jsx(
|
|
111
|
+
TableTextInput,
|
|
112
|
+
{
|
|
113
|
+
...props,
|
|
114
|
+
name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
|
|
115
|
+
showErrorMsg: column.showErrorMsg
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
column.type === DndColumnType.AUTOCOMPLETE && /* @__PURE__ */ jsx(
|
|
119
|
+
AutocompleteInput,
|
|
120
|
+
{
|
|
121
|
+
forcePopupIcon: true,
|
|
122
|
+
freeSolo: true,
|
|
123
|
+
name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
|
|
124
|
+
options: column.options,
|
|
125
|
+
inputTransform: (value) => value ?? "",
|
|
126
|
+
outputTransform: (value) => value,
|
|
127
|
+
size: "small"
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
column.type === DndColumnType.DIRECTORY_ITEMS && /* @__PURE__ */ jsx(
|
|
131
|
+
DirectoryItemsInput,
|
|
132
|
+
{
|
|
133
|
+
name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
|
|
134
|
+
equipmentTypes: column.equipmentTypes,
|
|
135
|
+
elementType: column.elementType,
|
|
136
|
+
titleId: column.titleId,
|
|
137
|
+
hideErrorMessage: true,
|
|
138
|
+
label: void 0
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
column.type === DndColumnType.CHIP_ITEMS && /* @__PURE__ */ jsx(ChipItemsInput, { name: `${arrayFormName}[${rowIndex}].${column.dataKey}`, hideErrorMessage: true }),
|
|
142
|
+
column.type === DndColumnType.CUSTOM && column.component(rowIndex)
|
|
143
|
+
] }, column.dataKey);
|
|
144
|
+
}
|
|
145
|
+
function DndTable(props) {
|
|
146
|
+
const {
|
|
147
|
+
arrayFormName,
|
|
148
|
+
useFieldArrayOutput,
|
|
149
|
+
columnsDefinition,
|
|
150
|
+
tableHeight,
|
|
151
|
+
allowedToAddRows = () => Promise.resolve(true),
|
|
152
|
+
createRows,
|
|
153
|
+
disabled = false,
|
|
154
|
+
withResetButton = false,
|
|
155
|
+
withAddRowsDialog = true,
|
|
156
|
+
previousValues,
|
|
157
|
+
disableTableCell,
|
|
158
|
+
getPreviousValue,
|
|
159
|
+
isValueModified,
|
|
160
|
+
disableAddingRows = false,
|
|
161
|
+
showMoveArrow = true,
|
|
162
|
+
disableDragAndDrop = false,
|
|
163
|
+
handleUploadButton = void 0,
|
|
164
|
+
uploadButtonMessageId = void 0,
|
|
165
|
+
handleResetButton = void 0,
|
|
166
|
+
resetButtonMessageId = void 0
|
|
167
|
+
} = props;
|
|
168
|
+
const intl = useIntl();
|
|
169
|
+
const { getValues, setValue, setError, clearErrors } = useFormContext();
|
|
170
|
+
const {
|
|
171
|
+
fields: currentRows,
|
|
172
|
+
// don't use it to access form data ! check doc
|
|
173
|
+
move,
|
|
174
|
+
swap,
|
|
175
|
+
append,
|
|
176
|
+
remove
|
|
177
|
+
} = useFieldArrayOutput;
|
|
178
|
+
const [openAddRowsDialog, setOpenAddRowsDialog] = useState(false);
|
|
179
|
+
function renderTableCell(rowId, rowIndex, column) {
|
|
180
|
+
const CustomTableCell = column.editable ? EditableTableCell : DefaultTableCell;
|
|
181
|
+
return /* @__PURE__ */ jsx(
|
|
182
|
+
CustomTableCell,
|
|
183
|
+
{
|
|
184
|
+
arrayFormName,
|
|
185
|
+
rowIndex,
|
|
186
|
+
column,
|
|
187
|
+
disabled: disableTableCell ? disableTableCell(rowIndex, column, arrayFormName, previousValues) : disabled,
|
|
188
|
+
previousValue: getPreviousValue ? getPreviousValue(rowIndex, column, arrayFormName, previousValues) : void 0,
|
|
189
|
+
valueModified: isValueModified ? isValueModified(rowIndex, arrayFormName) : false
|
|
190
|
+
},
|
|
191
|
+
rowId + column.dataKey
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
const addNewRows = (numberOfRows) => {
|
|
195
|
+
if (currentRows.length + numberOfRows > MAX_ROWS_NUMBER) {
|
|
196
|
+
setError(arrayFormName, {
|
|
197
|
+
type: "custom",
|
|
198
|
+
message: intl.formatMessage(
|
|
199
|
+
{
|
|
200
|
+
id: "MaximumRowNumberError"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
value: MAX_ROWS_NUMBER
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
});
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
clearErrors(arrayFormName);
|
|
210
|
+
const rowsToAdd = createRows == null ? void 0 : createRows(numberOfRows).map((row) => {
|
|
211
|
+
return { ...row, [SELECTED]: false };
|
|
212
|
+
});
|
|
213
|
+
append(rowsToAdd);
|
|
214
|
+
};
|
|
215
|
+
const handleAddRowsButton = () => {
|
|
216
|
+
allowedToAddRows().then((isAllowed) => {
|
|
217
|
+
if (isAllowed) {
|
|
218
|
+
if (withAddRowsDialog) {
|
|
219
|
+
setOpenAddRowsDialog(true);
|
|
220
|
+
} else {
|
|
221
|
+
addNewRows(1);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
const handleCloseAddRowsDialog = () => {
|
|
227
|
+
setOpenAddRowsDialog(false);
|
|
228
|
+
};
|
|
229
|
+
const deleteSelectedRows = () => {
|
|
230
|
+
const currentRowsValues = getValues(arrayFormName);
|
|
231
|
+
const rowsToDelete = [];
|
|
232
|
+
for (let i = 0; i < currentRowsValues.length; i++) {
|
|
233
|
+
if (currentRowsValues[i][SELECTED]) {
|
|
234
|
+
rowsToDelete.push(i);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
remove(rowsToDelete);
|
|
238
|
+
};
|
|
239
|
+
const selectAllRows = () => {
|
|
240
|
+
for (let i = 0; i < currentRows.length; i++) {
|
|
241
|
+
setValue(`${arrayFormName}[${i}].${SELECTED}`, true);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const unselectAllRows = () => {
|
|
245
|
+
for (let i = 0; i < currentRows.length; i++) {
|
|
246
|
+
setValue(`${arrayFormName}[${i}].${SELECTED}`, false);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const moveUpSelectedRows = () => {
|
|
250
|
+
const currentRowsValues = getValues(arrayFormName);
|
|
251
|
+
if (currentRowsValues[0][SELECTED]) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
for (let i = 1; i < currentRowsValues.length; i++) {
|
|
255
|
+
if (currentRowsValues[i][SELECTED]) {
|
|
256
|
+
swap(i - 1, i);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const moveDownSelectedRows = () => {
|
|
261
|
+
const currentRowsValues = getValues(arrayFormName);
|
|
262
|
+
if (currentRowsValues[currentRowsValues.length - 1][SELECTED]) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
for (let i = currentRowsValues.length - 2; i >= 0; i--) {
|
|
266
|
+
if (currentRowsValues[i][SELECTED]) {
|
|
267
|
+
swap(i, i + 1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const onDragEnd = (result) => {
|
|
272
|
+
if (!result.destination) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
move(result.source.index, result.destination.index);
|
|
276
|
+
};
|
|
277
|
+
function renderTableHead() {
|
|
278
|
+
return /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
279
|
+
!disableDragAndDrop && /* @__PURE__ */ jsx(TableCell, { sx: { width: "3%" } }),
|
|
280
|
+
/* @__PURE__ */ jsx(TableCell, { sx: { width: "5%", textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
281
|
+
MultiCheckbox,
|
|
282
|
+
{
|
|
283
|
+
arrayFormName,
|
|
284
|
+
handleClickCheck: selectAllRows,
|
|
285
|
+
handleClickUncheck: unselectAllRows,
|
|
286
|
+
disabled: disabled || currentRows.length === 0
|
|
287
|
+
}
|
|
288
|
+
) }),
|
|
289
|
+
columnsDefinition.map((column) => /* @__PURE__ */ jsx(TableCell, { sx: { width: column.width, maxWidth: column.maxWidth }, children: /* @__PURE__ */ jsxs(Box, { sx: styles.columnsStyle, children: [
|
|
290
|
+
column.label,
|
|
291
|
+
column.extra
|
|
292
|
+
] }) }, column.dataKey))
|
|
293
|
+
] }) });
|
|
294
|
+
}
|
|
295
|
+
function renderTableBody(providedDroppable) {
|
|
296
|
+
return /* @__PURE__ */ jsxs(TableBody, { children: [
|
|
297
|
+
currentRows.map((row, index) => /* @__PURE__ */ jsx(
|
|
298
|
+
Draggable,
|
|
299
|
+
{
|
|
300
|
+
draggableId: row.id.toString(),
|
|
301
|
+
index,
|
|
302
|
+
isDragDisabled: disableDragAndDrop,
|
|
303
|
+
children: (provided) => /* @__PURE__ */ jsxs(TableRow, { ref: provided.innerRef, ...provided.draggableProps, children: [
|
|
304
|
+
!disableDragAndDrop && /* @__PURE__ */ jsx(
|
|
305
|
+
Tooltip,
|
|
306
|
+
{
|
|
307
|
+
title: intl.formatMessage({
|
|
308
|
+
id: "DragAndDrop"
|
|
309
|
+
}),
|
|
310
|
+
placement: "right",
|
|
311
|
+
children: /* @__PURE__ */ jsx(
|
|
312
|
+
TableCell,
|
|
313
|
+
{
|
|
314
|
+
sx: { textAlign: "center" },
|
|
315
|
+
...disabled ? {} : { ...provided.dragHandleProps },
|
|
316
|
+
children: /* @__PURE__ */ jsx(DragIndicator, {})
|
|
317
|
+
}
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
/* @__PURE__ */ jsx(TableCell, { sx: { textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
322
|
+
CheckboxInput,
|
|
323
|
+
{
|
|
324
|
+
name: `${arrayFormName}[${index}].${SELECTED}`,
|
|
325
|
+
formProps: { disabled }
|
|
326
|
+
}
|
|
327
|
+
) }),
|
|
328
|
+
columnsDefinition.map((column) => renderTableCell(row.id, index, column))
|
|
329
|
+
] })
|
|
330
|
+
},
|
|
331
|
+
row.id
|
|
332
|
+
)),
|
|
333
|
+
providedDroppable.placeholder
|
|
334
|
+
] });
|
|
335
|
+
}
|
|
336
|
+
return /* @__PURE__ */ jsxs(Grid, { item: true, container: true, spacing: 1, children: [
|
|
337
|
+
/* @__PURE__ */ jsxs(Grid, { item: true, container: true, children: [
|
|
338
|
+
/* @__PURE__ */ jsx(DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsx(Droppable, { droppableId: "tapTable", isDropDisabled: disabled, children: (provided) => /* @__PURE__ */ jsx(
|
|
339
|
+
TableContainer,
|
|
340
|
+
{
|
|
341
|
+
ref: provided.innerRef,
|
|
342
|
+
...provided.droppableProps,
|
|
343
|
+
sx: {
|
|
344
|
+
height: tableHeight,
|
|
345
|
+
border: "solid 1px rgba(0,0,0,0.1)"
|
|
346
|
+
},
|
|
347
|
+
children: /* @__PURE__ */ jsxs(Table, { stickyHeader: true, size: "small", padding: "none", children: [
|
|
348
|
+
renderTableHead(),
|
|
349
|
+
renderTableBody(provided)
|
|
350
|
+
] })
|
|
351
|
+
}
|
|
352
|
+
) }) }),
|
|
353
|
+
/* @__PURE__ */ jsx(ErrorInput, { name: arrayFormName, InputField: FieldErrorAlert })
|
|
354
|
+
] }),
|
|
355
|
+
/* @__PURE__ */ jsxs(Grid, { container: true, item: true, children: [
|
|
356
|
+
handleResetButton && handleUploadButton && resetButtonMessageId && uploadButtonMessageId ? /* @__PURE__ */ jsx(
|
|
357
|
+
DndTableBottomLeftButtons,
|
|
358
|
+
{
|
|
359
|
+
withResetButton,
|
|
360
|
+
disableUploadButton: disableAddingRows,
|
|
361
|
+
disabled,
|
|
362
|
+
handleUploadButton,
|
|
363
|
+
uploadButtonMessageId,
|
|
364
|
+
handleResetButton,
|
|
365
|
+
resetButtonMessageId
|
|
366
|
+
}
|
|
367
|
+
) : null,
|
|
368
|
+
/* @__PURE__ */ jsx(
|
|
369
|
+
DndTableBottomRightButtons,
|
|
370
|
+
{
|
|
371
|
+
arrayFormName,
|
|
372
|
+
handleAddButton: handleAddRowsButton,
|
|
373
|
+
handleDeleteButton: deleteSelectedRows,
|
|
374
|
+
handleMoveUpButton: moveUpSelectedRows,
|
|
375
|
+
handleMoveDownButton: moveDownSelectedRows,
|
|
376
|
+
disableAddingRows,
|
|
377
|
+
showMoveArrow,
|
|
378
|
+
disabled
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
] }),
|
|
382
|
+
/* @__PURE__ */ jsx(
|
|
383
|
+
DndTableAddRowsDialog,
|
|
384
|
+
{
|
|
385
|
+
open: openAddRowsDialog,
|
|
386
|
+
handleAddButton: addNewRows,
|
|
387
|
+
onClose: handleCloseAddRowsDialog
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
] });
|
|
391
|
+
}
|
|
392
|
+
export {
|
|
393
|
+
DndTable
|
|
394
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ElementType, EquipmentType } from '../../utils';
|
|
3
|
+
export declare const SELECTED = "selected";
|
|
4
|
+
export declare const MAX_ROWS_NUMBER = 100;
|
|
5
|
+
export declare enum DndColumnType {
|
|
6
|
+
TEXT = "TEXT",
|
|
7
|
+
NUMERIC = "NUMERIC",
|
|
8
|
+
AUTOCOMPLETE = "AUTOCOMPLETE",
|
|
9
|
+
CHIP_ITEMS = "CHIP_ITEMS",
|
|
10
|
+
DIRECTORY_ITEMS = "DIRECTORY_ITEMS",
|
|
11
|
+
CUSTOM = "CUSTOM"
|
|
12
|
+
}
|
|
13
|
+
export interface ColumnBase {
|
|
14
|
+
dataKey: string;
|
|
15
|
+
maxWidth?: number | string;
|
|
16
|
+
width?: number | string;
|
|
17
|
+
label?: string;
|
|
18
|
+
extra?: JSX.Element;
|
|
19
|
+
editable?: boolean;
|
|
20
|
+
type: DndColumnType;
|
|
21
|
+
}
|
|
22
|
+
export interface ColumnText extends ColumnBase {
|
|
23
|
+
type: DndColumnType.TEXT;
|
|
24
|
+
showErrorMsg?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ColumnNumeric extends ColumnBase {
|
|
27
|
+
type: DndColumnType.NUMERIC;
|
|
28
|
+
adornment?: {
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
clearable?: boolean;
|
|
32
|
+
textAlign?: 'right' | 'left';
|
|
33
|
+
}
|
|
34
|
+
export interface ColumnAutocomplete extends ColumnBase {
|
|
35
|
+
type: DndColumnType.AUTOCOMPLETE;
|
|
36
|
+
options: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface ColumnDirectoryItem extends ColumnBase {
|
|
39
|
+
type: DndColumnType.DIRECTORY_ITEMS;
|
|
40
|
+
equipmentTypes: EquipmentType[];
|
|
41
|
+
elementType: ElementType;
|
|
42
|
+
titleId: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ColumnChipsItem extends ColumnBase {
|
|
45
|
+
type: DndColumnType.CHIP_ITEMS;
|
|
46
|
+
}
|
|
47
|
+
export interface ColumnCustom extends ColumnBase {
|
|
48
|
+
type: DndColumnType.CUSTOM;
|
|
49
|
+
component: (rowIndex: number) => ReactNode;
|
|
50
|
+
}
|
|
51
|
+
export type DndColumn = ColumnNumeric | ColumnAutocomplete | ColumnText | ColumnDirectoryItem | ColumnChipsItem | ColumnCustom;
|
|
@@ -0,0 +1,16 @@
|
|
|
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["CHIP_ITEMS"] = "CHIP_ITEMS";
|
|
8
|
+
DndColumnType2["DIRECTORY_ITEMS"] = "DIRECTORY_ITEMS";
|
|
9
|
+
DndColumnType2["CUSTOM"] = "CUSTOM";
|
|
10
|
+
return DndColumnType2;
|
|
11
|
+
})(DndColumnType || {});
|
|
12
|
+
export {
|
|
13
|
+
DndColumnType,
|
|
14
|
+
MAX_ROWS_NUMBER,
|
|
15
|
+
SELECTED
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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-add-rows-dialog';
|
|
10
|
+
export * from './dnd-table-bottom-left-buttons';
|
|
11
|
+
export * from './dnd-table-bottom-right-buttons';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DndTable } from "./dnd-table.js";
|
|
2
|
+
import { DndColumnType, MAX_ROWS_NUMBER, SELECTED } from "./dnd-table.type.js";
|
|
3
|
+
import { DndTableAddRowsDialog } from "./dnd-table-add-rows-dialog.js";
|
|
4
|
+
import { DndTableBottomLeftButtons } from "./dnd-table-bottom-left-buttons.js";
|
|
5
|
+
import { DndTableBottomRightButtons } from "./dnd-table-bottom-right-buttons.js";
|
|
6
|
+
export {
|
|
7
|
+
DndColumnType,
|
|
8
|
+
DndTable,
|
|
9
|
+
DndTableAddRowsDialog,
|
|
10
|
+
DndTableBottomLeftButtons,
|
|
11
|
+
DndTableBottomRightButtons,
|
|
12
|
+
MAX_ROWS_NUMBER,
|
|
13
|
+
SELECTED
|
|
14
|
+
};
|
|
@@ -10,9 +10,12 @@ import "../../utils/yupConfig.js";
|
|
|
10
10
|
import "react-intl";
|
|
11
11
|
import "react";
|
|
12
12
|
import "react-hook-form";
|
|
13
|
+
import "localized-countries";
|
|
14
|
+
import "localized-countries/data/fr";
|
|
15
|
+
import "localized-countries/data/en";
|
|
16
|
+
import "notistack";
|
|
13
17
|
import "../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
14
18
|
import * as yup from "yup";
|
|
15
|
-
import "notistack";
|
|
16
19
|
import "../overflowableText/OverflowableText.js";
|
|
17
20
|
import "../treeViewFinder/TreeViewFinder.js";
|
|
18
21
|
import "../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
@@ -21,9 +24,6 @@ import "ag-grid-community";
|
|
|
21
24
|
import "react-papaparse";
|
|
22
25
|
import "react-csv-downloader";
|
|
23
26
|
import "../inputs/reactHookForm/numbers/RangeInput.js";
|
|
24
|
-
import "localized-countries";
|
|
25
|
-
import "localized-countries/data/fr";
|
|
26
|
-
import "localized-countries/data/en";
|
|
27
27
|
import { DescriptionField } from "../inputs/reactHookForm/text/DescriptionField.js";
|
|
28
28
|
import { UniqueNameInput } from "../inputs/reactHookForm/text/UniqueNameInput.js";
|
|
29
29
|
import "@react-querybuilder/material";
|
|
@@ -11,6 +11,7 @@ export * from './checkBoxList';
|
|
|
11
11
|
export * from './customAGGrid';
|
|
12
12
|
export * from './dialogs';
|
|
13
13
|
export * from './directoryItemSelector/DirectoryItemSelector';
|
|
14
|
+
export * from './dnd-table';
|
|
14
15
|
export * from './elementSearch';
|
|
15
16
|
export * from './filter';
|
|
16
17
|
export * from './flatParameters';
|