@gridsuite/commons-ui 0.195.0 → 0.197.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 (46) hide show
  1. package/dist/components/csvDownloader/use-csv-export.js +6 -2
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/components/index.js +53 -0
  4. package/dist/components/network-modification-table/columns-definition.d.ts +26 -0
  5. package/dist/components/network-modification-table/columns-definition.js +36 -0
  6. package/dist/components/network-modification-table/index.d.ts +13 -0
  7. package/dist/components/network-modification-table/index.js +55 -0
  8. package/dist/components/network-modification-table/network-modification-table-styles.d.ts +210 -0
  9. package/dist/components/network-modification-table/network-modification-table-styles.js +333 -0
  10. package/dist/components/network-modification-table/network-modifications-table.d.ts +20 -0
  11. package/dist/components/network-modification-table/network-modifications-table.js +166 -0
  12. package/dist/components/network-modification-table/renderers/depth-box.d.ts +6 -0
  13. package/dist/components/network-modification-table/renderers/depth-box.js +21 -0
  14. package/dist/components/network-modification-table/renderers/drag-handle-cell.d.ts +5 -0
  15. package/dist/components/network-modification-table/renderers/drag-handle-cell.js +10 -0
  16. package/dist/components/network-modification-table/renderers/index.d.ts +12 -0
  17. package/dist/components/network-modification-table/renderers/index.js +14 -0
  18. package/dist/components/network-modification-table/renderers/name-cell.d.ts +7 -0
  19. package/dist/components/network-modification-table/renderers/name-cell.js +84 -0
  20. package/dist/components/network-modification-table/renderers/network-modification-node-editor-name-header.d.ts +14 -0
  21. package/dist/components/network-modification-table/renderers/network-modification-node-editor-name-header.js +40 -0
  22. package/dist/components/network-modification-table/renderers/select-cell.d.ts +8 -0
  23. package/dist/components/network-modification-table/renderers/select-cell.js +60 -0
  24. package/dist/components/network-modification-table/renderers/select-header-cell.d.ts +7 -0
  25. package/dist/components/network-modification-table/renderers/select-header-cell.js +26 -0
  26. package/dist/components/network-modification-table/row/drag-row-clone.d.ts +7 -0
  27. package/dist/components/network-modification-table/row/drag-row-clone.js +35 -0
  28. package/dist/components/network-modification-table/row/index.d.ts +8 -0
  29. package/dist/components/network-modification-table/row/index.js +6 -0
  30. package/dist/components/network-modification-table/row/modification-row.d.ts +12 -0
  31. package/dist/components/network-modification-table/row/modification-row.js +117 -0
  32. package/dist/components/network-modification-table/use-modifications-drag-and-drop.d.ts +21 -0
  33. package/dist/components/network-modification-table/use-modifications-drag-and-drop.js +170 -0
  34. package/dist/components/network-modification-table/utils.d.ts +40 -0
  35. package/dist/components/network-modification-table/utils.js +164 -0
  36. package/dist/hooks/useModificationLabelComputer.d.ts +1 -12
  37. package/dist/index.js +59 -1
  38. package/dist/module-tanstack.d.js +1 -0
  39. package/dist/services/index.js +6 -1
  40. package/dist/services/networkModification.d.ts +21 -0
  41. package/dist/services/networkModification.js +34 -0
  42. package/dist/utils/types/index.d.ts +1 -0
  43. package/dist/utils/types/network-modification-metadata.d.ts +15 -0
  44. package/dist/utils/types/network-modification-metadata.js +1 -0
  45. package/dist/utils/types/network-modification-types.d.ts +5 -6
  46. package/package.json +3 -1
@@ -0,0 +1,333 @@
1
+ import { lighten, darken, alpha } from "@mui/material";
2
+ const HIGHLIGHT_COLOR_BASE = "rgba(144, 202, 249, 0.16)";
3
+ const HIGHLIGHT_COLOR_HOVER = "rgba(144, 202, 249, 0.24)";
4
+ const ROW_HOVER_COLOR = "rgba(144, 202, 249, 0.08)";
5
+ const DRAG_OPACITY = 0.5;
6
+ const DEACTIVATED_OPACITY = 0.4;
7
+ const MODIFICATION_ROW_HEIGHT = 41;
8
+ const DEPTH_CELL_WIDTH = 32;
9
+ const createCellBorderColor = (theme) => theme.palette.mode === "light" ? lighten(alpha(theme.palette.divider, 1), 0.88) : darken(alpha(theme.palette.divider, 1), 0.68);
10
+ const networkModificationTableStyles = {
11
+ tableWrapper: (theme) => ({
12
+ display: "flex",
13
+ flexDirection: "column",
14
+ flexGrow: 1,
15
+ margin: theme.spacing(1),
16
+ border: `1px solid ${theme.palette.divider}`,
17
+ overflow: "hidden",
18
+ minHeight: 0
19
+ }),
20
+ container: {
21
+ position: "relative",
22
+ flexGrow: 1,
23
+ overflow: "auto",
24
+ height: "100%"
25
+ },
26
+ table: (theme) => ({
27
+ width: "100%",
28
+ tableLayout: "fixed",
29
+ borderCollapse: "collapse",
30
+ backgroundColor: theme.palette.background.paper
31
+ }),
32
+ thead: (theme) => ({
33
+ backgroundColor: theme.palette.background.paper,
34
+ position: "sticky",
35
+ top: 0,
36
+ zIndex: 1,
37
+ width: "100%",
38
+ "& tr:hover": {
39
+ backgroundColor: "transparent"
40
+ }
41
+ }),
42
+ tableRow: {
43
+ display: "flex",
44
+ alignItems: "center",
45
+ transition: "none",
46
+ opacity: 1
47
+ },
48
+ tableBody: {
49
+ position: "relative"
50
+ },
51
+ tableCell: {
52
+ fontSize: "small",
53
+ minWidth: 0,
54
+ display: "flex"
55
+ },
56
+ dragRowClone: (theme) => ({
57
+ backgroundColor: "background.paper",
58
+ boxShadow: 4,
59
+ opacity: 1,
60
+ border: "1px solid #f5f5f5",
61
+ display: "flex",
62
+ width: "fit-content",
63
+ padding: theme.spacing(1)
64
+ }),
65
+ overflow: {
66
+ whiteSpace: "pre",
67
+ textOverflow: "ellipsis",
68
+ overflow: "hidden"
69
+ },
70
+ selectCheckBox: (theme) => ({
71
+ padding: theme.spacing(0.8)
72
+ }),
73
+ dragHandle: (theme) => ({
74
+ display: "flex",
75
+ alignItems: "center",
76
+ cursor: "grab",
77
+ opacity: 0,
78
+ padding: theme.spacing(0.5),
79
+ "tr:hover &": { opacity: 1 }
80
+ }),
81
+ dragIndicatorIcon: {
82
+ width: "16px",
83
+ height: "16px"
84
+ },
85
+ modificationLabel: {
86
+ textOverflow: "ellipsis",
87
+ overflow: "hidden",
88
+ whiteSpace: "nowrap",
89
+ paddingLeft: "0.5vw"
90
+ },
91
+ rootNetworkHeader: {
92
+ width: "100%",
93
+ display: "flex",
94
+ justifyContent: "center"
95
+ },
96
+ columnCell: {
97
+ select: { padding: 2, justifyContent: "center" },
98
+ modificationName: { cursor: "pointer", minWidth: 0, overflow: "hidden", flex: 1 },
99
+ rootNetworkChip: { textAlign: "center" }
100
+ },
101
+ nameCellInnerRow: {
102
+ position: "relative",
103
+ display: "flex",
104
+ alignItems: "center",
105
+ gap: 0,
106
+ flex: 1,
107
+ minWidth: 0,
108
+ alignSelf: "stretch"
109
+ },
110
+ nameCellTogglerBox: {
111
+ width: `${DEPTH_CELL_WIDTH}px`,
112
+ alignItems: "center",
113
+ justifyContent: "center"
114
+ },
115
+ nameCellToggleButton: {
116
+ padding: "4px",
117
+ width: `${DEPTH_CELL_WIDTH}px`,
118
+ height: `${DEPTH_CELL_WIDTH}px`
119
+ },
120
+ nameCellLabelBoxPlain: {
121
+ flex: 1,
122
+ minWidth: 0
123
+ },
124
+ // depth-box
125
+ folderDepthBox: (theme) => ({
126
+ width: `${DEPTH_CELL_WIDTH / 2}px`,
127
+ display: "flex",
128
+ alignSelf: "stretch",
129
+ position: "relative",
130
+ borderRight: `1px solid ${createCellBorderColor(theme)}`
131
+ }),
132
+ depthBox: (theme) => ({
133
+ width: `${DEPTH_CELL_WIDTH / 2}px`,
134
+ display: "flex",
135
+ justifyContent: "flex-start",
136
+ alignSelf: "stretch",
137
+ position: "relative",
138
+ borderRight: `1px solid ${createCellBorderColor(theme)}`
139
+ }),
140
+ depthBoxTick: (theme) => ({
141
+ position: "absolute",
142
+ top: "50%",
143
+ left: "100%",
144
+ width: "6px",
145
+ height: "1px",
146
+ backgroundColor: createCellBorderColor(theme)
147
+ }),
148
+ // from network-modification-node-editor-utils
149
+ modificationNameHeader: {
150
+ display: "flex",
151
+ flexDirection: "row",
152
+ alignItems: "center",
153
+ minWidth: 0,
154
+ gap: 2,
155
+ "& .MuiTypography-root": {
156
+ fontSize: "inherit"
157
+ }
158
+ },
159
+ icon: (theme) => ({
160
+ width: theme.spacing(1)
161
+ }),
162
+ iconEdit: (theme) => ({
163
+ marginRight: theme.spacing(1)
164
+ }),
165
+ circularProgress: (theme) => ({
166
+ marginRight: theme.spacing(2),
167
+ color: theme.palette.primary.contrastText
168
+ }),
169
+ modificationCircularProgress: (theme) => ({
170
+ marginRight: theme.spacing(2),
171
+ color: theme.palette.primary.main
172
+ }),
173
+ toolbarCircularProgress: (theme) => ({
174
+ display: "flex",
175
+ alignItems: "center",
176
+ justifyContent: "center",
177
+ marginLeft: theme.spacing(1.25),
178
+ marginRight: theme.spacing(2),
179
+ color: theme.palette.secondary.main
180
+ })
181
+ };
182
+ const DROP_INDICATOR_TOP = "inset 0 2px 0 #90caf9";
183
+ const DROP_INDICATOR_BOTTOM = "inset 0 -2px 0 #90caf9";
184
+ const DROP_FORBIDDEN_INDICATOR_TOP = "inset 0 2px 0 #FF3636";
185
+ const DROP_FORBIDDEN_INDICATOR_BOTTOM = "inset 0 -2px 0 #FF3636";
186
+ function getRowBackgroundColor(isHighlighted, isComposite, theme) {
187
+ if (isHighlighted) {
188
+ return HIGHLIGHT_COLOR_BASE;
189
+ }
190
+ if (!isComposite) {
191
+ return "transparent";
192
+ }
193
+ return theme.palette.mode === "light" ? darken(theme.palette.background.paper, 0.04) : lighten(theme.palette.background.paper, 0.08);
194
+ }
195
+ const createRowSx = (theme, isHighlighted, isDragging, virtualRow, depth, isComposite) => ({
196
+ position: "absolute",
197
+ top: 0,
198
+ left: 0,
199
+ right: 0,
200
+ width: "100%",
201
+ height: `${virtualRow.size}px`,
202
+ transform: `translateY(${virtualRow.start}px)`,
203
+ backgroundColor: getRowBackgroundColor(isHighlighted, isComposite, theme),
204
+ opacity: isDragging ? DRAG_OPACITY : 1,
205
+ "&:hover": {
206
+ backgroundColor: isHighlighted ? HIGHLIGHT_COLOR_HOVER : ROW_HOVER_COLOR
207
+ },
208
+ ...isDragging && { zIndex: 1, transform: "none" },
209
+ // 'border' &::before has to be used instead of borderTop in order for the virtualizer to compute the right cell height
210
+ ...depth === 0 && {
211
+ position: "absolute",
212
+ "&::before": {
213
+ content: '""',
214
+ position: "absolute",
215
+ top: 0,
216
+ left: 0,
217
+ right: 0,
218
+ height: "1px",
219
+ backgroundColor: createCellBorderColor(theme),
220
+ pointerEvents: "none"
221
+ }
222
+ }
223
+ });
224
+ const createModificationNameCellStyle = (activated) => ({
225
+ opacity: activated ? 1 : DEACTIVATED_OPACITY
226
+ });
227
+ const createRootNetworkChipCellSx = (activated) => ({
228
+ width: "100%",
229
+ display: "flex",
230
+ justifyContent: "center",
231
+ opacity: activated ? 1 : DEACTIVATED_OPACITY
232
+ });
233
+ const createEditDescriptionStyle = (description) => ({
234
+ opacity: description ? 1 : 0,
235
+ cursor: description ? "pointer" : "default",
236
+ "tr:hover &": { opacity: 1 }
237
+ });
238
+ const createCellStyle = (cell, isAutoExtensible) => {
239
+ const size = cell.column.getSize();
240
+ const { minSize } = cell.column.columnDef;
241
+ return {
242
+ ...cell.column.columnDef.meta?.cellStyle,
243
+ padding: 0,
244
+ flex: isAutoExtensible ? `1 1 ${size}px` : `0 1 ${size}px`,
245
+ minWidth: minSize ? `${minSize}px` : void 0,
246
+ height: "100%",
247
+ display: "flex",
248
+ alignItems: "center",
249
+ borderTop: "none",
250
+ borderBottom: "none"
251
+ };
252
+ };
253
+ const createHeaderCellStyle = (header, theme, isFirst, isLast, isAutoExtensible) => {
254
+ const {
255
+ column: {
256
+ getSize,
257
+ columnDef: { minSize, meta }
258
+ }
259
+ } = header;
260
+ const size = getSize();
261
+ return {
262
+ ...meta?.cellStyle,
263
+ flex: isAutoExtensible ? `1 1 ${size}px` : `0 1 ${size}px`,
264
+ minWidth: minSize ? `${minSize}px` : void 0,
265
+ height: `${MODIFICATION_ROW_HEIGHT}px`,
266
+ padding: "2px",
267
+ textAlign: "left",
268
+ fontWeight: 600,
269
+ display: "flex",
270
+ alignItems: "center",
271
+ paddingTop: "1.5vh",
272
+ paddingBottom: "1.5vh",
273
+ backgroundColor: getRowBackgroundColor(false, true, theme),
274
+ borderBottom: createCellBorderColor(theme),
275
+ borderTop: createCellBorderColor(theme),
276
+ ...isFirst && { borderLeft: createCellBorderColor(theme) },
277
+ ...isLast && { borderRight: createCellBorderColor(theme) }
278
+ };
279
+ };
280
+ const COLUMNS_WITHOUT_BORDER = /* @__PURE__ */ new Set(["dragHandle", "select"]);
281
+ const createCellContentWrapperSx = (theme, withoutBorders) => ({
282
+ display: "flex",
283
+ alignItems: "center",
284
+ width: "100%",
285
+ height: `${MODIFICATION_ROW_HEIGHT}px`,
286
+ borderTop: withoutBorders ? "none" : `1px solid ${createCellBorderColor(theme)}`,
287
+ borderBottom: withoutBorders ? "none" : `1px solid ${createCellBorderColor(theme)}`
288
+ });
289
+ const createNameCellRootStyle = (theme, isExpanded, depth) => ({
290
+ height: "100%",
291
+ width: "100%",
292
+ display: "flex",
293
+ alignItems: "stretch",
294
+ gap: 0,
295
+ ...depth === 0 && !isExpanded && {
296
+ borderTop: `1px solid ${createCellBorderColor(theme)}`,
297
+ borderBottom: `1px solid ${createCellBorderColor(theme)}`
298
+ }
299
+ });
300
+ const createNameCellLabelBoxSx = (isExpanded, depth) => {
301
+ return {
302
+ alignSelf: "stretch",
303
+ display: "flex",
304
+ alignItems: "center",
305
+ flex: 1,
306
+ minWidth: 0,
307
+ ...(depth > 0 || isExpanded) && {
308
+ borderTop: (theme) => `1px solid ${createCellBorderColor(theme)}`,
309
+ borderBottom: (theme) => `1px solid ${createCellBorderColor(theme)}`,
310
+ borderLeft: (theme) => `1px solid ${createCellBorderColor(theme)}`
311
+ }
312
+ };
313
+ };
314
+ export {
315
+ COLUMNS_WITHOUT_BORDER,
316
+ DEPTH_CELL_WIDTH,
317
+ DROP_FORBIDDEN_INDICATOR_BOTTOM,
318
+ DROP_FORBIDDEN_INDICATOR_TOP,
319
+ DROP_INDICATOR_BOTTOM,
320
+ DROP_INDICATOR_TOP,
321
+ MODIFICATION_ROW_HEIGHT,
322
+ createCellBorderColor,
323
+ createCellContentWrapperSx,
324
+ createCellStyle,
325
+ createEditDescriptionStyle,
326
+ createHeaderCellStyle,
327
+ createModificationNameCellStyle,
328
+ createNameCellLabelBoxSx,
329
+ createNameCellRootStyle,
330
+ createRootNetworkChipCellSx,
331
+ createRowSx,
332
+ networkModificationTableStyles
333
+ };
@@ -0,0 +1,20 @@
1
+ import { default as React, SetStateAction } from 'react';
2
+ import { ColumnDef } from '@tanstack/react-table';
3
+ import { UUID } from 'node:crypto';
4
+ import { NetworkModificationEditorNameHeaderProps } from './renderers';
5
+ import { NameHeaderProps } from './columns-definition';
6
+ import { ComposedModificationMetadata, NetworkModificationMetadata } from '../../utils';
7
+ interface NetworkModificationsTableProps extends Omit<NetworkModificationEditorNameHeaderProps, 'modificationCount'> {
8
+ modifications: NetworkModificationMetadata[];
9
+ handleCellClick: (modification: NetworkModificationMetadata) => void;
10
+ isRowDragDisabled?: boolean;
11
+ onRowDragStart: () => void;
12
+ onRowDragEnd: () => void;
13
+ onRowSelected: (selectedRows: ComposedModificationMetadata[]) => void;
14
+ createAllColumns: (isRowDragDisabled: boolean, modificationsCount: number, nameHeaderProps: NameHeaderProps, setModifications: React.Dispatch<SetStateAction<ComposedModificationMetadata[]>>) => ColumnDef<ComposedModificationMetadata>[];
15
+ highlightedModificationUuid: UUID | null;
16
+ studyUuid: UUID | null;
17
+ currentNodeId?: UUID;
18
+ }
19
+ export declare function NetworkModificationsTable({ modifications, handleCellClick, isRowDragDisabled, onRowDragStart, onRowDragEnd, onRowSelected, createAllColumns, highlightedModificationUuid, studyUuid, currentNodeId, ...nameHeaderProps }: Readonly<NetworkModificationsTableProps>): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1,166 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState, useMemo, useEffect, useCallback } from "react";
3
+ import { useTheme, Box, Table, TableHead, TableRow, TableCell, TableBody } from "@mui/material";
4
+ import { useReactTable, getExpandedRowModel, getCoreRowModel, flexRender } from "@tanstack/react-table";
5
+ import { DragDropContext, Droppable } from "@hello-pangea/dnd";
6
+ import { useVirtualizer } from "@tanstack/react-virtual";
7
+ import { MODIFICATION_ROW_HEIGHT, networkModificationTableStyles, createHeaderCellStyle } from "./network-modification-table-styles.js";
8
+ import { AUTO_EXTENSIBLE_COLUMNS } from "./columns-definition.js";
9
+ import { useModificationsDragAndDrop } from "./use-modifications-drag-and-drop.js";
10
+ import { formatToComposedModification, mergeSubModificationsIntoTree, findAllLoadedCompositeModifications, fetchSubModificationsForExpandedRows, isCompositeModification } from "./utils.js";
11
+ import "@mui/icons-material";
12
+ import "react-intl";
13
+ import "../../utils/conversionUtils.js";
14
+ import "../../utils/types/equipmentType.js";
15
+ import "../../utils/yupConfig.js";
16
+ import "localized-countries";
17
+ import "localized-countries/data/fr";
18
+ import "localized-countries/data/en";
19
+ import "notistack";
20
+ import { ModificationRow } from "./row/modification-row.js";
21
+ function NetworkModificationsTable({
22
+ modifications,
23
+ handleCellClick,
24
+ isRowDragDisabled = false,
25
+ onRowDragStart,
26
+ onRowDragEnd,
27
+ onRowSelected,
28
+ createAllColumns,
29
+ highlightedModificationUuid,
30
+ studyUuid = null,
31
+ currentNodeId = void 0,
32
+ ...nameHeaderProps
33
+ }) {
34
+ const theme = useTheme();
35
+ const containerRef = useRef(null);
36
+ const lastClickedIndex = useRef(null);
37
+ const [expanded, setExpanded] = useState({});
38
+ const [composedModifications, setComposedModifications] = useState(
39
+ formatToComposedModification(modifications)
40
+ );
41
+ const columns = useMemo(
42
+ () => createAllColumns(
43
+ isRowDragDisabled ?? false,
44
+ modifications.length,
45
+ nameHeaderProps,
46
+ setComposedModifications
47
+ ),
48
+ [createAllColumns, isRowDragDisabled, modifications.length, nameHeaderProps]
49
+ );
50
+ useEffect(() => {
51
+ setComposedModifications((prevMods) => {
52
+ const nextMods = mergeSubModificationsIntoTree(formatToComposedModification(modifications), prevMods);
53
+ const loadedComposite = [];
54
+ findAllLoadedCompositeModifications(nextMods, loadedComposite);
55
+ fetchSubModificationsForExpandedRows(
56
+ loadedComposite.map((mod) => mod.uuid),
57
+ nextMods,
58
+ setComposedModifications,
59
+ true
60
+ );
61
+ return nextMods;
62
+ });
63
+ }, [modifications]);
64
+ const handleExpandRow = useCallback((updater) => {
65
+ setExpanded((prevExpanded) => {
66
+ const nextExpanded = typeof updater === "function" ? updater(prevExpanded) : updater;
67
+ const prevRecord = prevExpanded === true ? {} : prevExpanded;
68
+ const nextRecord = nextExpanded === true ? {} : nextExpanded;
69
+ const newlyExpandedIds = Object.keys(nextRecord).filter((id) => nextRecord[id] && !prevRecord[id]);
70
+ setComposedModifications((prevMods) => {
71
+ fetchSubModificationsForExpandedRows(newlyExpandedIds, prevMods, setComposedModifications);
72
+ return [...prevMods];
73
+ });
74
+ return nextExpanded;
75
+ });
76
+ }, []);
77
+ const table = useReactTable({
78
+ data: composedModifications,
79
+ columns,
80
+ state: { expanded },
81
+ getCoreRowModel: getCoreRowModel(),
82
+ getExpandedRowModel: getExpandedRowModel(),
83
+ getSubRows: (row) => row.subModifications,
84
+ getRowId: (row) => row.uuid,
85
+ getRowCanExpand: (row) => isCompositeModification(row.original),
86
+ enableRowSelection: true,
87
+ enableSubRowSelection: false,
88
+ enableExpanding: true,
89
+ onExpandedChange: handleExpandRow,
90
+ meta: { lastClickedIndex, onRowSelected }
91
+ });
92
+ const { rows } = table.getRowModel();
93
+ const virtualizer = useVirtualizer({
94
+ count: rows.length,
95
+ getScrollElement: () => containerRef.current,
96
+ overscan: 5,
97
+ estimateSize: () => MODIFICATION_ROW_HEIGHT
98
+ });
99
+ const virtualItems = virtualizer.getVirtualItems();
100
+ const { handleDragUpdate, handleDragEnd, renderClone } = useModificationsDragAndDrop({
101
+ rows,
102
+ containerRef,
103
+ composedModifications,
104
+ setComposedModifications,
105
+ onDragEnd: onRowDragEnd,
106
+ studyUuid,
107
+ currentNodeUuid: currentNodeId
108
+ });
109
+ useEffect(() => {
110
+ table.resetRowSelection();
111
+ table.resetExpanded();
112
+ lastClickedIndex.current = null;
113
+ }, [table]);
114
+ useEffect(() => {
115
+ if (highlightedModificationUuid && containerRef.current) {
116
+ const rowIndex = rows.findIndex((row) => row.original.uuid === highlightedModificationUuid);
117
+ if (rowIndex !== -1) {
118
+ virtualizer.scrollToIndex(rowIndex, { align: "start", behavior: "auto" });
119
+ }
120
+ }
121
+ }, [highlightedModificationUuid, rows, virtualizer]);
122
+ return /* @__PURE__ */ jsx(DragDropContext, { onDragEnd: handleDragEnd, onDragStart: onRowDragStart, onDragUpdate: handleDragUpdate, children: /* @__PURE__ */ jsx(Box, { sx: networkModificationTableStyles.tableWrapper, children: /* @__PURE__ */ jsx(Droppable, { droppableId: "modifications-table", mode: "virtual", renderClone, children: (provided) => /* @__PURE__ */ jsx(Box, { ref: containerRef, sx: networkModificationTableStyles.container, children: /* @__PURE__ */ jsxs(Table, { sx: networkModificationTableStyles.table, children: [
123
+ /* @__PURE__ */ jsx(TableHead, { sx: networkModificationTableStyles.thead, children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { sx: networkModificationTableStyles.tableRow, children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(
124
+ TableCell,
125
+ {
126
+ sx: createHeaderCellStyle(
127
+ header,
128
+ theme,
129
+ header.index === 0,
130
+ header.index === headerGroup.headers.length - 1,
131
+ AUTO_EXTENSIBLE_COLUMNS.includes(header.column.id)
132
+ ),
133
+ children: flexRender(header.column.columnDef.header, header.getContext())
134
+ },
135
+ header.id
136
+ )) }, headerGroup.id)) }),
137
+ /* @__PURE__ */ jsx(
138
+ TableBody,
139
+ {
140
+ ref: provided.innerRef,
141
+ ...provided.droppableProps,
142
+ sx: {
143
+ ...networkModificationTableStyles.tableBody,
144
+ height: `${virtualizer.getTotalSize()}px`
145
+ },
146
+ children: virtualItems.map((virtualRow) => {
147
+ const row = rows[virtualRow.index];
148
+ return /* @__PURE__ */ jsx(
149
+ ModificationRow,
150
+ {
151
+ virtualRow,
152
+ row,
153
+ handleCellClick,
154
+ isRowDragDisabled,
155
+ highlightedModificationUuid
156
+ },
157
+ row.id
158
+ );
159
+ })
160
+ }
161
+ )
162
+ ] }) }) }) }) });
163
+ }
164
+ export {
165
+ NetworkModificationsTable
166
+ };
@@ -0,0 +1,6 @@
1
+ interface DepthBoxProps {
2
+ firstLevel: boolean;
3
+ displayAsFolder?: boolean;
4
+ }
5
+ export declare function DepthBox({ firstLevel, displayAsFolder }: Readonly<DepthBoxProps>): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { Box } from "@mui/material";
3
+ import { networkModificationTableStyles } from "../network-modification-table-styles.js";
4
+ function getDepthBoxStyle(displayAsFolder) {
5
+ if (displayAsFolder) {
6
+ return networkModificationTableStyles.folderDepthBox;
7
+ }
8
+ return networkModificationTableStyles.depthBox;
9
+ }
10
+ function DepthBox({ firstLevel, displayAsFolder = false }) {
11
+ return /* @__PURE__ */ jsxs(Fragment, {
12
+ /* double width depth box only on the first level */
13
+ children: [
14
+ firstLevel && /* @__PURE__ */ jsx(Box, { sx: getDepthBoxStyle(displayAsFolder) }),
15
+ /* @__PURE__ */ jsx(Box, { sx: getDepthBoxStyle(displayAsFolder), children: displayAsFolder && /* @__PURE__ */ jsx(Box, { sx: networkModificationTableStyles.depthBoxTick }) })
16
+ ]
17
+ });
18
+ }
19
+ export {
20
+ DepthBox
21
+ };
@@ -0,0 +1,5 @@
1
+ interface DragHandleCellProps {
2
+ isRowDragDisabled: boolean;
3
+ }
4
+ export declare function DragHandleCell({ isRowDragDisabled }: Readonly<DragHandleCellProps>): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { DragIndicator } from "@mui/icons-material";
3
+ import { Box } from "@mui/material";
4
+ import { networkModificationTableStyles } from "../network-modification-table-styles.js";
5
+ function DragHandleCell({ isRowDragDisabled }) {
6
+ return /* @__PURE__ */ jsx(Box, { sx: networkModificationTableStyles.dragHandle, children: !isRowDragDisabled && /* @__PURE__ */ jsx(DragIndicator, { fontSize: "small", sx: networkModificationTableStyles.dragIndicatorIcon }) });
7
+ }
8
+ export {
9
+ DragHandleCell
10
+ };
@@ -0,0 +1,12 @@
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 * from './depth-box';
8
+ export * from './drag-handle-cell';
9
+ export * from './name-cell';
10
+ export * from './network-modification-node-editor-name-header';
11
+ export * from './select-cell';
12
+ export * from './select-header-cell';
@@ -0,0 +1,14 @@
1
+ import { DepthBox } from "./depth-box.js";
2
+ import { DragHandleCell } from "./drag-handle-cell.js";
3
+ import { NameCell } from "./name-cell.js";
4
+ import { NetworkModificationEditorNameHeader } from "./network-modification-node-editor-name-header.js";
5
+ import { SelectCell } from "./select-cell.js";
6
+ import { SelectHeaderCell } from "./select-header-cell.js";
7
+ export {
8
+ DepthBox,
9
+ DragHandleCell,
10
+ NameCell,
11
+ NetworkModificationEditorNameHeader,
12
+ SelectCell,
13
+ SelectHeaderCell
14
+ };
@@ -0,0 +1,7 @@
1
+ import { Row } from '@tanstack/react-table';
2
+ import { ComposedModificationMetadata } from '../../../utils';
3
+ interface NameCellProps {
4
+ row: Row<ComposedModificationMetadata>;
5
+ }
6
+ export declare function NameCell({ row }: Readonly<NameCellProps>): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,84 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useCallback, useMemo } from "react";
3
+ import { useIntl } from "react-intl";
4
+ import { useTheme, Box, IconButton, Tooltip } from "@mui/material";
5
+ import { KeyboardArrowDown, KeyboardArrowRight } from "@mui/icons-material";
6
+ import { networkModificationTableStyles, createNameCellLabelBoxSx, createModificationNameCellStyle, createNameCellRootStyle } from "../network-modification-table-styles.js";
7
+ import { DepthBox } from "./depth-box.js";
8
+ import { isCompositeModification } from "../utils.js";
9
+ import { useModificationLabelComputer } from "../../../hooks/useModificationLabelComputer.js";
10
+ import "../../../utils/conversionUtils.js";
11
+ import "../../../utils/types/equipmentType.js";
12
+ import { mergeSx } from "../../../utils/styles.js";
13
+ import "../../../utils/yupConfig.js";
14
+ import "localized-countries";
15
+ import "localized-countries/data/fr";
16
+ import "localized-countries/data/en";
17
+ import "notistack";
18
+ function NameCell({ row }) {
19
+ const intl = useIntl();
20
+ const theme = useTheme();
21
+ const { computeLabel } = useModificationLabelComputer();
22
+ const { depth } = row;
23
+ const getModificationLabel = useCallback(
24
+ (modification, formatBold = true) => {
25
+ return intl.formatMessage(
26
+ { id: `network_modifications.${modification.messageType}` },
27
+ { ...modification, ...computeLabel(modification, formatBold) }
28
+ );
29
+ },
30
+ [computeLabel, intl]
31
+ );
32
+ const label = useMemo(() => getModificationLabel(row.original), [getModificationLabel, row.original]);
33
+ const renderDepthBox = () => {
34
+ const depthLevelCount = depth;
35
+ return Array.from({ length: depthLevelCount }, (_, i) => /* @__PURE__ */ jsx(
36
+ DepthBox,
37
+ {
38
+ firstLevel: i === 0,
39
+ displayAsFolder: isCompositeModification(row.original) && i === depthLevelCount - 1
40
+ },
41
+ i
42
+ ));
43
+ };
44
+ return /* @__PURE__ */ jsxs(
45
+ Box,
46
+ {
47
+ sx: mergeSx(
48
+ networkModificationTableStyles.tableCell,
49
+ createNameCellRootStyle(theme, row.getIsExpanded(), depth)
50
+ ),
51
+ children: [
52
+ renderDepthBox(),
53
+ /* @__PURE__ */ jsxs(Box, { sx: networkModificationTableStyles.nameCellInnerRow, children: [
54
+ isCompositeModification(row.original) && /* @__PURE__ */ jsx(Box, { sx: networkModificationTableStyles.nameCellTogglerBox, children: /* @__PURE__ */ jsx(
55
+ IconButton,
56
+ {
57
+ size: "small",
58
+ onClick: (e) => {
59
+ e.stopPropagation();
60
+ row.getToggleExpandedHandler()();
61
+ },
62
+ sx: networkModificationTableStyles.nameCellToggleButton,
63
+ "aria-label": row.getIsExpanded() ? "Collapse" : "Expand",
64
+ children: row.getIsExpanded() ? /* @__PURE__ */ jsx(KeyboardArrowDown, { fontSize: "small" }) : /* @__PURE__ */ jsx(KeyboardArrowRight, { fontSize: "small" })
65
+ }
66
+ ) }),
67
+ /* @__PURE__ */ jsx(Box, { sx: createNameCellLabelBoxSx(row.getIsExpanded(), depth), children: /* @__PURE__ */ jsx(Tooltip, { disableFocusListener: true, disableTouchListener: true, title: label, children: /* @__PURE__ */ jsx(
68
+ Box,
69
+ {
70
+ sx: mergeSx(
71
+ networkModificationTableStyles.modificationLabel,
72
+ createModificationNameCellStyle(row.original.activated)
73
+ ),
74
+ children: label
75
+ }
76
+ ) }) })
77
+ ] })
78
+ ]
79
+ }
80
+ );
81
+ }
82
+ export {
83
+ NameCell
84
+ };