@sis-cc/dotstatsuite-visions 13.9.0 → 14.1.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/README.md +7 -1
- package/dist/Alert/Alert.js +5 -3
- package/dist/Alert/Alert.js.map +1 -1
- package/dist/ApiQueries/ApiQueries.js +2 -1
- package/dist/ApiQueries/ApiQueries.js.map +1 -1
- package/dist/AuthDialog/AuthDialog.js.map +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.js +2 -1
- package/dist/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/Button/Button.js.map +1 -1
- package/dist/ChartsConfig/ChartsConfig.js +12 -7
- package/dist/ChartsConfig/ChartsConfig.js.map +1 -1
- package/dist/CollapseButtons/CollapseButtons.js +14 -8
- package/dist/CollapseButtons/CollapseButtons.js.map +1 -1
- package/dist/CollapsibleTree/CollapsibleTree.js +47 -29
- package/dist/CollapsibleTree/CollapsibleTree.js.map +1 -1
- package/dist/Contact/Contact.js +6 -5
- package/dist/Contact/Contact.js.map +1 -1
- package/dist/DataFooter/DataFooter.js +1 -1
- package/dist/DataFooter/DataFooter.js.map +1 -1
- package/dist/DataHeader/DataHeader.js +8 -6
- package/dist/DataHeader/DataHeader.js.map +1 -1
- package/dist/Dataflow/Dataflow.js +6 -3
- package/dist/Dataflow/Dataflow.js.map +1 -1
- package/dist/DeleteAllChip/DeleteAllChip.js +1 -1
- package/dist/DynamicDrawer/DynamicDrawer.js +8 -9
- package/dist/DynamicDrawer/DynamicDrawer.js.map +1 -1
- package/dist/ExpansionPanel/ExpansionPanel.js +3 -2
- package/dist/ExpansionPanel/ExpansionPanel.js.map +1 -1
- package/dist/GroupedChips/GroupedChips.js +5 -4
- package/dist/GroupedChips/GroupedChips.js.map +1 -1
- package/dist/HierarchicalFilter/HierarchicalFilter.js +1 -1
- package/dist/HierarchicalFilter/HierarchicalFilter.js.map +1 -1
- package/dist/Icons/AccessibilityFilled.js.map +1 -1
- package/dist/Icons/AccessibilityOutlined.js.map +1 -1
- package/dist/Icons/AccountFilled.js.map +1 -1
- package/dist/Icons/AccountOutlined.js.map +1 -1
- package/dist/Icons/Api.js.map +1 -1
- package/dist/Icons/Asterisk.js.map +1 -1
- package/dist/Icons/Bar.js.map +1 -1
- package/dist/Icons/CopyContent.js.map +1 -1
- package/dist/Icons/Cross.js.map +1 -1
- package/dist/Icons/HSymbol.js.map +1 -1
- package/dist/Icons/Row.js.map +1 -1
- package/dist/Icons/Scatter.js.map +1 -1
- package/dist/Icons/StackedBar.js.map +1 -1
- package/dist/Icons/StackedRow.js.map +1 -1
- package/dist/Icons/Timeline.js.map +1 -1
- package/dist/Icons/VSymbol.js.map +1 -1
- package/dist/Input/Input.js.map +1 -1
- package/dist/InputNumber/InputNumber.js.map +1 -1
- package/dist/LabelDivider/LabelDivider.js.map +1 -1
- package/dist/Loading/Loading.js.map +1 -1
- package/dist/Logo/Logo.js +1 -1
- package/dist/Logo/Logo.js.map +1 -1
- package/dist/Mode/Mode.js +5 -4
- package/dist/Mode/Mode.js.map +1 -1
- package/dist/Pagination/Pagination.js +0 -1
- package/dist/Pagination/Pagination.js.map +1 -1
- package/dist/PeriodPicker/PeriodPicker.js +62 -61
- package/dist/PeriodPicker/PeriodPicker.js.map +1 -1
- package/dist/Select/Select.js +13 -11
- package/dist/Select/Select.js.map +1 -1
- package/dist/Share/Share.js +2 -1
- package/dist/Share/Share.js.map +1 -1
- package/dist/ShortUrls/ShortUrls.js.map +1 -1
- package/dist/SisccFooter/SisccFooter.js +30 -20
- package/dist/SisccFooter/SisccFooter.js.map +1 -1
- package/dist/Spotlight/Spotlight.js +8 -7
- package/dist/Spotlight/Spotlight.js.map +1 -1
- package/dist/TableFooter/TableFooter.js.map +1 -1
- package/dist/TableHeader/TableHeader.js.map +1 -1
- package/dist/TableHtml5/TableHtml5.js +25 -19
- package/dist/TableHtml5/TableHtml5.js.map +1 -1
- package/dist/TableLayout/TableLayout.js +293 -165
- package/dist/TableLayout/TableLayout.js.map +1 -1
- package/dist/TablePreview/TablePreview.js +17 -8
- package/dist/TablePreview/TablePreview.js.map +1 -1
- package/dist/Tag/Tag.js.map +1 -1
- package/dist/Tooltip/Tooltip.js.map +1 -1
- package/dist/UserRightForm/UserRightForm.js.map +1 -1
- package/dist/VerticalButton/VerticalButton.js.map +1 -1
- package/dist/chunks/{CustomChip-CMYCIorJ.js → CustomChip-VonwGtLq.js} +7 -7
- package/dist/chunks/CustomChip-VonwGtLq.js.map +1 -0
- package/dist/chunks/{useKeybordEscapeHandler-DRsOrnwc.js → useKeybordEscapeHandler-DZZOPw7k.js} +2 -2
- package/dist/chunks/useKeybordEscapeHandler-DZZOPw7k.js.map +1 -0
- package/dist/chunks/utils-kslX1mzh.js.map +1 -1
- package/dist/chunks/with-input-DRWNlMdA.js.map +1 -1
- package/dist/chunks/{withSpotlight-ooTVUwmd.js → withSpotlight-Bqdm585G.js} +37 -37
- package/dist/chunks/withSpotlight-Bqdm585G.js.map +1 -0
- package/package.json +32 -33
- package/dist/chunks/CustomChip-CMYCIorJ.js.map +0 -1
- package/dist/chunks/useKeybordEscapeHandler-DRsOrnwc.js.map +0 -1
- package/dist/chunks/withSpotlight-ooTVUwmd.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { Fragment, useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import React, { Fragment, useState, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import * as R from 'ramda';
|
|
5
5
|
import Grid from '@mui/material/Grid';
|
|
@@ -7,13 +7,15 @@ import Typography from '@mui/material/Typography';
|
|
|
7
7
|
import { ViewColumnOutlined, Reorder, ViewListOutlined, ViewQuiltOutlined, Done, CheckBoxOutlineBlankOutlined, Undo } from '@mui/icons-material';
|
|
8
8
|
import { visuallyHidden } from '@mui/utils';
|
|
9
9
|
import { makeStyles as makeStyles$1 } from '@mui/styles';
|
|
10
|
-
import {
|
|
10
|
+
import { useDroppable, useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCorners, DragOverlay } from '@dnd-kit/core';
|
|
11
|
+
import { useSortable, SortableContext, verticalListSortingStrategy, sortableKeyboardCoordinates } from '@dnd-kit/sortable';
|
|
11
12
|
import { a as getLight, b as getDark, w as withBlank } from '../chunks/utils-kslX1mzh.js';
|
|
12
13
|
import { TablePreview } from '../TablePreview/TablePreview.js';
|
|
13
14
|
import PropTypes from 'prop-types';
|
|
14
15
|
import makeStyles from '@mui/styles/makeStyles';
|
|
15
16
|
import Select from '@mui/material/Select';
|
|
16
17
|
import MenuItem from '@mui/material/MenuItem';
|
|
18
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
17
19
|
import { Button } from '../Button/Button.js';
|
|
18
20
|
|
|
19
21
|
const BOX = {
|
|
@@ -78,51 +80,94 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
78
80
|
margin: theme.spacing(0, 1, 0, 0)
|
|
79
81
|
}
|
|
80
82
|
}));
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
const ItemBody = React.forwardRef(
|
|
84
|
+
({
|
|
85
|
+
item,
|
|
86
|
+
itemRenderer,
|
|
87
|
+
dropZoneLabel,
|
|
88
|
+
itemButtonProps,
|
|
89
|
+
canDrag,
|
|
90
|
+
style,
|
|
91
|
+
dragHandleProps,
|
|
92
|
+
describedBy
|
|
93
|
+
}, ref) => {
|
|
94
|
+
const classes = useStyles$2();
|
|
95
|
+
const selectItem = R.prop(item.id)(itemButtonProps);
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
ref,
|
|
100
|
+
style,
|
|
101
|
+
"data-testid": `draggable-${item.id}`,
|
|
102
|
+
...dragHandleProps,
|
|
103
|
+
className: cx(
|
|
104
|
+
classes.styledItemContainer,
|
|
105
|
+
classes.containerButton,
|
|
106
|
+
[R.prop(`${dropZoneLabel}Item`)(classes)],
|
|
104
107
|
{
|
|
105
|
-
|
|
106
|
-
className: cx(classes.text, { [classes.spaceButton]: selectItem }),
|
|
107
|
-
children: itemRenderer(item)
|
|
108
|
+
[classes.cantMove]: R.not(canDrag)
|
|
108
109
|
}
|
|
109
110
|
),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
"aria-label": itemRenderer(item),
|
|
112
|
+
"aria-describedby": describedBy,
|
|
113
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
Typography,
|
|
116
|
+
{
|
|
117
|
+
variant: "body2",
|
|
118
|
+
className: cx(classes.text, { [classes.spaceButton]: selectItem }),
|
|
119
|
+
children: itemRenderer(item)
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
selectItem && /* @__PURE__ */ jsx(
|
|
123
|
+
Select,
|
|
124
|
+
{
|
|
125
|
+
id: item.id,
|
|
126
|
+
value: selectItem.value,
|
|
127
|
+
onChange: (e) => selectItem.onChange(e.target.value),
|
|
128
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
129
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
130
|
+
classes: { root: classes.select },
|
|
131
|
+
variant: "outlined",
|
|
132
|
+
size: "small",
|
|
133
|
+
autoWidth: true,
|
|
134
|
+
children: R.map((v) => /* @__PURE__ */ jsx(MenuItem, { value: v, children: v }, v))(selectItem.options)
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] })
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
ItemBody.displayName = "ItemBody";
|
|
143
|
+
const DnDItem = ({ item, index, itemRenderer, dropZoneLabel, itemButtonProps, canDrag }) => {
|
|
144
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
145
|
+
id: item.id,
|
|
146
|
+
data: { containerId: dropZoneLabel, index },
|
|
147
|
+
disabled: R.not(canDrag)
|
|
148
|
+
});
|
|
149
|
+
const style = {
|
|
150
|
+
transform: CSS.Translate.toString(transform),
|
|
151
|
+
transition,
|
|
152
|
+
// The floating copy is rendered by the DragOverlay, so hide the in-list
|
|
153
|
+
// node while keeping its slot to act as the drop placeholder.
|
|
154
|
+
opacity: isDragging ? 0 : void 0
|
|
155
|
+
};
|
|
156
|
+
const describedBy = R.trim(`${R.propOr("", "aria-describedby", attributes)} ${wcagId}`);
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
ItemBody,
|
|
159
|
+
{
|
|
160
|
+
ref: setNodeRef,
|
|
161
|
+
item,
|
|
162
|
+
itemRenderer,
|
|
163
|
+
dropZoneLabel,
|
|
164
|
+
itemButtonProps,
|
|
165
|
+
canDrag,
|
|
166
|
+
style,
|
|
167
|
+
dragHandleProps: { ...attributes, ...listeners },
|
|
168
|
+
describedBy
|
|
124
169
|
}
|
|
125
|
-
)
|
|
170
|
+
);
|
|
126
171
|
};
|
|
127
172
|
DnDItem.propTypes = {
|
|
128
173
|
item: PropTypes.object,
|
|
@@ -180,37 +225,42 @@ const Box = ({
|
|
|
180
225
|
md
|
|
181
226
|
}) => {
|
|
182
227
|
const classes = useStyles$1();
|
|
228
|
+
const itemValues = R.values(items);
|
|
229
|
+
const ids = R.map(R.prop("id"), itemValues);
|
|
183
230
|
const canDrag = R.equals(dropZoneLabel, BOX.rows) ? R.pipe(R.length, R.lt(1))(items) : R.T();
|
|
231
|
+
const { setNodeRef, active, over } = useDroppable({
|
|
232
|
+
id: dropZoneLabel,
|
|
233
|
+
data: { containerId: dropZoneLabel }
|
|
234
|
+
});
|
|
235
|
+
const overContainerId = R.path(["data", "current", "containerId"], over);
|
|
236
|
+
const isDraggingOver = !R.isNil(active) && R.equals(overContainerId, dropZoneLabel);
|
|
184
237
|
return /* @__PURE__ */ jsxs(Grid, { item: true, xs: accessibility ? 4 : 12, md, children: [
|
|
185
238
|
/* @__PURE__ */ jsxs("div", { className: classes.iconTitle, children: [
|
|
186
239
|
/* @__PURE__ */ jsx(Icon, {}),
|
|
187
240
|
/* @__PURE__ */ jsx("span", { className: classes.title, children: title }),
|
|
188
241
|
/* @__PURE__ */ jsx(Typography, { style: visuallyHidden, children: title })
|
|
189
242
|
] }),
|
|
190
|
-
/* @__PURE__ */ jsx(
|
|
243
|
+
/* @__PURE__ */ jsx(SortableContext, { id: dropZoneLabel, items: ids, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsx(
|
|
191
244
|
"div",
|
|
192
245
|
{
|
|
193
246
|
"data-testid": `droppable-${dropZoneLabel}`,
|
|
194
|
-
ref:
|
|
247
|
+
ref: setNodeRef,
|
|
195
248
|
className: cx(classes.blockDnd, R.prop(`${dropZoneLabel}Container`)(classes), {
|
|
196
|
-
[classes.canDrop]:
|
|
249
|
+
[classes.canDrop]: isDraggingOver
|
|
197
250
|
}),
|
|
198
|
-
children:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
))(R.values(items)),
|
|
212
|
-
provided.placeholder
|
|
213
|
-
]
|
|
251
|
+
children: R.addIndex(R.map)((item, index) => /* @__PURE__ */ jsx(
|
|
252
|
+
DnDItem,
|
|
253
|
+
{
|
|
254
|
+
index,
|
|
255
|
+
item,
|
|
256
|
+
itemRenderer,
|
|
257
|
+
dropZoneLabel,
|
|
258
|
+
onChangeLayout,
|
|
259
|
+
itemButtonProps,
|
|
260
|
+
canDrag
|
|
261
|
+
},
|
|
262
|
+
item.id
|
|
263
|
+
))(itemValues)
|
|
214
264
|
}
|
|
215
265
|
) })
|
|
216
266
|
] });
|
|
@@ -235,7 +285,7 @@ const changeLayout = ({ dragIndex, hoverIndex, dragZone, dropZone, currentLayout
|
|
|
235
285
|
const item = R.pipe(R.prop(dragZone), R.nth(dragIndex))(currentLayout);
|
|
236
286
|
return R.pipe(
|
|
237
287
|
R.over(R.lensProp(dragZone), R.without([item])),
|
|
238
|
-
R.over(R.lensProp(dropZone), R.insert(hoverIndex, item))
|
|
288
|
+
R.over(R.lensProp(dropZone), R.insert(hoverIndex, item))
|
|
239
289
|
)(currentLayout);
|
|
240
290
|
};
|
|
241
291
|
|
|
@@ -244,6 +294,24 @@ const getIsOptionalActivated = (layout, optionalId) => {
|
|
|
244
294
|
return !R.isNil(founded);
|
|
245
295
|
};
|
|
246
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Resolve which zone (header/sections/rows) a dnd-kit id belongs to.
|
|
299
|
+
* The id is either a zone key itself (when hovering an empty zone) or an item id.
|
|
300
|
+
* @param {Object} layout - { header: string[], sections: string[], rows: string[] }
|
|
301
|
+
* @param {string} id - a zone key or an item id
|
|
302
|
+
* @returns {string|undefined} the owning zone key, or undefined if not found
|
|
303
|
+
*/
|
|
304
|
+
const findContainer = (layout, id) => {
|
|
305
|
+
if (R.has(id, layout)) {
|
|
306
|
+
return id;
|
|
307
|
+
}
|
|
308
|
+
return R.pipe(
|
|
309
|
+
R.toPairs,
|
|
310
|
+
R.find(([, ids]) => R.includes(id, ids)),
|
|
311
|
+
R.nth(0)
|
|
312
|
+
)(layout);
|
|
313
|
+
};
|
|
314
|
+
|
|
247
315
|
const useStyles = makeStyles$1((theme) => ({
|
|
248
316
|
dnd: {
|
|
249
317
|
userSelect: "none"
|
|
@@ -264,13 +332,13 @@ const useStyles = makeStyles$1((theme) => ({
|
|
|
264
332
|
}
|
|
265
333
|
}
|
|
266
334
|
}));
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
};
|
|
335
|
+
const EMPTY_LAYOUT = {};
|
|
336
|
+
const EMPTY_ITEMS = [];
|
|
337
|
+
const EMPTY_OPTIONAL_ITEM = {};
|
|
270
338
|
const CustomTableLayout = ({
|
|
271
|
-
layout =
|
|
272
|
-
items =
|
|
273
|
-
optionalItem =
|
|
339
|
+
layout = EMPTY_LAYOUT,
|
|
340
|
+
items = EMPTY_ITEMS,
|
|
341
|
+
optionalItem = EMPTY_OPTIONAL_ITEM,
|
|
274
342
|
itemRenderer = R.prop("name"),
|
|
275
343
|
itemButtonProps,
|
|
276
344
|
labels,
|
|
@@ -295,7 +363,14 @@ const CustomTableLayout = ({
|
|
|
295
363
|
}
|
|
296
364
|
return indexed;
|
|
297
365
|
}, [items, optionalItem]);
|
|
298
|
-
const
|
|
366
|
+
const sensors = useSensors(
|
|
367
|
+
useSensor(PointerSensor, { activationConstraint: { distance: 8 } }),
|
|
368
|
+
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
|
|
369
|
+
);
|
|
370
|
+
const [activeId, setActiveId] = useState(null);
|
|
371
|
+
const clonedLayoutRef = useRef(null);
|
|
372
|
+
const layoutRef = useRef(currentLayout);
|
|
373
|
+
layoutRef.current = currentLayout;
|
|
299
374
|
const activateOptionalItem = () => {
|
|
300
375
|
const nextLayout = R.over(R.lensProp("header"), R.append(optionalItem.id), currentLayout);
|
|
301
376
|
setCurrentLayout(nextLayout);
|
|
@@ -313,79 +388,112 @@ const CustomTableLayout = ({
|
|
|
313
388
|
setCurrentLayout(layout);
|
|
314
389
|
}
|
|
315
390
|
};
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const dragLabel = R.pipe(
|
|
320
|
-
R.prop(dragZoneId),
|
|
321
|
-
R.find(R.propEq("id", draggableId)),
|
|
322
|
-
itemRenderer
|
|
323
|
-
)(currentLayout);
|
|
324
|
-
R.pipe(
|
|
325
|
-
R.evolve(transform),
|
|
326
|
-
R.prop("wcagDragStart", labels),
|
|
327
|
-
provided.announce
|
|
328
|
-
)({
|
|
329
|
-
dragZone: R.prop(dragZoneId)(boxLabel),
|
|
330
|
-
...source,
|
|
331
|
-
dragLabel
|
|
332
|
-
});
|
|
333
|
-
}
|
|
391
|
+
const handleDragStart = ({ active }) => {
|
|
392
|
+
clonedLayoutRef.current = currentLayout;
|
|
393
|
+
setActiveId(active.id);
|
|
334
394
|
};
|
|
335
|
-
const
|
|
336
|
-
if (R.isNil(
|
|
395
|
+
const handleDragOver = ({ active, over }) => {
|
|
396
|
+
if (R.isNil(over)) {
|
|
337
397
|
return;
|
|
338
398
|
}
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
R.
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
provided.announce
|
|
350
|
-
)({
|
|
351
|
-
dropZone: R.prop(droppableId)(boxLabel),
|
|
352
|
-
dragZone: R.prop(source.droppableId)(boxLabel),
|
|
353
|
-
index,
|
|
354
|
-
length
|
|
355
|
-
});
|
|
356
|
-
}
|
|
399
|
+
setCurrentLayout((prev) => {
|
|
400
|
+
const dragZone = findContainer(prev, active.id);
|
|
401
|
+
const dropZone = findContainer(prev, over.id);
|
|
402
|
+
if (R.isNil(dragZone) || R.isNil(dropZone) || R.equals(dragZone, dropZone)) {
|
|
403
|
+
return prev;
|
|
404
|
+
}
|
|
405
|
+
const dragIndex = R.indexOf(active.id, prev[dragZone]);
|
|
406
|
+
const hoverIndex = R.has(over.id, prev) ? R.length(prev[dropZone]) : R.indexOf(over.id, prev[dropZone]);
|
|
407
|
+
return changeLayout({ dragIndex, hoverIndex, dragZone, dropZone, currentLayout: prev });
|
|
408
|
+
});
|
|
357
409
|
};
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
410
|
+
const handleDragEnd = ({ active, over }) => {
|
|
411
|
+
const cloned = clonedLayoutRef.current;
|
|
412
|
+
setActiveId(null);
|
|
413
|
+
clonedLayoutRef.current = null;
|
|
414
|
+
if (R.isNil(over)) {
|
|
415
|
+
if (!R.isNil(cloned)) {
|
|
416
|
+
setCurrentLayout(cloned);
|
|
362
417
|
}
|
|
363
|
-
}
|
|
364
|
-
if (R.isNil(destination)) {
|
|
365
418
|
return;
|
|
366
419
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
R.prop("wcagDragEnd", labels),
|
|
373
|
-
provided.announce
|
|
374
|
-
)({
|
|
375
|
-
dropZone: R.prop(droppableId)(boxLabel),
|
|
376
|
-
dragZone: R.prop(source.droppableId)(boxLabel),
|
|
377
|
-
index
|
|
378
|
-
});
|
|
420
|
+
setCurrentLayout((prev) => {
|
|
421
|
+
const dragZone = findContainer(prev, active.id);
|
|
422
|
+
const dropZone = findContainer(prev, over.id);
|
|
423
|
+
if (R.isNil(dragZone) || R.isNil(dropZone) || R.not(R.equals(dragZone, dropZone))) {
|
|
424
|
+
return prev;
|
|
379
425
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
dropZone:
|
|
386
|
-
currentLayout: layout2
|
|
426
|
+
const dragIndex = R.indexOf(active.id, prev[dropZone]);
|
|
427
|
+
const hoverIndex = R.has(over.id, prev) ? R.length(prev[dropZone]) - 1 : R.indexOf(over.id, prev[dropZone]);
|
|
428
|
+
if (hoverIndex < 0 || R.equals(dragIndex, hoverIndex)) {
|
|
429
|
+
return prev;
|
|
430
|
+
}
|
|
431
|
+
return changeLayout({ dragIndex, hoverIndex, dragZone, dropZone, currentLayout: prev });
|
|
387
432
|
});
|
|
388
433
|
};
|
|
434
|
+
const handleDragCancel = () => {
|
|
435
|
+
const cloned = clonedLayoutRef.current;
|
|
436
|
+
clonedLayoutRef.current = null;
|
|
437
|
+
setActiveId(null);
|
|
438
|
+
if (!R.isNil(cloned)) {
|
|
439
|
+
setCurrentLayout(cloned);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const announcements = {
|
|
443
|
+
onDragStart: ({ active }) => {
|
|
444
|
+
if (R.not(R.is(Function, labels.wcagDragStart))) {
|
|
445
|
+
return void 0;
|
|
446
|
+
}
|
|
447
|
+
const dragZone = findContainer(layoutRef.current, active.id);
|
|
448
|
+
const index = R.indexOf(active.id, R.propOr([], dragZone, layoutRef.current));
|
|
449
|
+
return labels.wcagDragStart({
|
|
450
|
+
dragZone: R.prop(dragZone, boxLabel),
|
|
451
|
+
droppableId: dragZone,
|
|
452
|
+
index: index + 1,
|
|
453
|
+
dragLabel: itemRenderer(R.prop(active.id, indexedItems))
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
onDragOver: ({ active, over }) => {
|
|
457
|
+
if (R.isNil(over) || R.not(R.is(Function, labels.wcagDragUpdate))) {
|
|
458
|
+
return void 0;
|
|
459
|
+
}
|
|
460
|
+
const dragZone = findContainer(clonedLayoutRef.current || layoutRef.current, active.id);
|
|
461
|
+
const dropZone = findContainer(layoutRef.current, over.id);
|
|
462
|
+
if (R.isNil(dropZone)) {
|
|
463
|
+
return void 0;
|
|
464
|
+
}
|
|
465
|
+
const dropItems = R.propOr([], dropZone, layoutRef.current);
|
|
466
|
+
const index = R.has(over.id, layoutRef.current) ? R.length(dropItems) : R.indexOf(over.id, dropItems);
|
|
467
|
+
const length = R.equals(dropZone, dragZone) ? R.length(dropItems) : R.length(dropItems) + 1;
|
|
468
|
+
return labels.wcagDragUpdate({
|
|
469
|
+
dropZone: R.prop(dropZone, boxLabel),
|
|
470
|
+
dragZone: R.prop(dragZone, boxLabel),
|
|
471
|
+
index: index + 1,
|
|
472
|
+
length
|
|
473
|
+
});
|
|
474
|
+
},
|
|
475
|
+
onDragEnd: ({ active, over }) => {
|
|
476
|
+
if (R.isNil(over) || R.not(R.is(Function, labels.wcagDragEnd))) {
|
|
477
|
+
return void 0;
|
|
478
|
+
}
|
|
479
|
+
const dragZone = findContainer(clonedLayoutRef.current || layoutRef.current, active.id);
|
|
480
|
+
const dropZone = findContainer(layoutRef.current, over.id);
|
|
481
|
+
if (R.isNil(dropZone)) {
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
const dropItems = R.propOr([], dropZone, layoutRef.current);
|
|
485
|
+
const index = R.has(over.id, layoutRef.current) ? R.length(dropItems) - 1 : R.indexOf(over.id, dropItems);
|
|
486
|
+
return labels.wcagDragEnd({
|
|
487
|
+
dropZone: R.prop(dropZone, boxLabel),
|
|
488
|
+
dragZone: R.prop(dragZone, boxLabel),
|
|
489
|
+
index: index + 1
|
|
490
|
+
});
|
|
491
|
+
},
|
|
492
|
+
onDragCancel: () => R.is(String, labels.wcagDragCancel) ? labels.wcagDragCancel : void 0
|
|
493
|
+
};
|
|
494
|
+
const screenReaderInstructions = R.is(String, labels.wcagDragExplanation) ? { draggable: labels.wcagDragExplanation } : void 0;
|
|
495
|
+
const overlayItem = R.isNil(activeId) ? null : R.prop(activeId, indexedItems);
|
|
496
|
+
const overlayZone = R.isNil(activeId) ? null : findContainer(clonedLayoutRef.current || currentLayout, activeId);
|
|
389
497
|
const getItems = (level) => R.pipe(R.prop(level), (ids) => R.props(ids, indexedItems), R.filter(R.identity))(currentLayout);
|
|
390
498
|
const header = /* @__PURE__ */ jsx(
|
|
391
499
|
Box,
|
|
@@ -434,41 +542,61 @@ const CustomTableLayout = ({
|
|
|
434
542
|
const isOptionalActivated = getIsOptionalActivated(currentLayout, R.prop("id", optionalItem));
|
|
435
543
|
return /* @__PURE__ */ jsxs(Grid, { "data-testid": "table-layout-test-id", container: true, children: [
|
|
436
544
|
/* @__PURE__ */ jsx("div", { id: wcagId, "aria-live": "assertive", style: { display: "none" }, children: labels.wcagDragExplanation }),
|
|
437
|
-
/* @__PURE__ */
|
|
438
|
-
|
|
545
|
+
/* @__PURE__ */ jsxs(
|
|
546
|
+
DndContext,
|
|
439
547
|
{
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
/* @__PURE__ */ jsxs(Grid, { container: true, spacing: 1, children: [
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
/* @__PURE__ */ jsxs("div", { className: classes.iconTitle, children: [
|
|
457
|
-
/* @__PURE__ */ jsx(ViewQuiltOutlined, {}),
|
|
458
|
-
/* @__PURE__ */ jsx(Typography, { tabIndex: 0, variant: "subtitle1", children: labels.table })
|
|
548
|
+
sensors,
|
|
549
|
+
collisionDetection: closestCorners,
|
|
550
|
+
onDragStart: handleDragStart,
|
|
551
|
+
onDragOver: handleDragOver,
|
|
552
|
+
onDragEnd: handleDragEnd,
|
|
553
|
+
onDragCancel: handleDragCancel,
|
|
554
|
+
accessibility: {
|
|
555
|
+
announcements,
|
|
556
|
+
...screenReaderInstructions ? { screenReaderInstructions } : {}
|
|
557
|
+
},
|
|
558
|
+
children: [
|
|
559
|
+
/* @__PURE__ */ jsxs(Grid, { container: true, direction: "row", spacing: 1, className: classes.dnd, children: [
|
|
560
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 1, children: [
|
|
561
|
+
/* @__PURE__ */ jsxs(Grid, { tabIndex: 0, item: true, xs: 12, md: accessibility ? 12 : 6, children: [
|
|
562
|
+
/* @__PURE__ */ jsx("span", { children: labels.help }),
|
|
563
|
+
/* @__PURE__ */ jsx(Typography, { style: visuallyHidden, children: labels.wcagDragExplanation })
|
|
459
564
|
] }),
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
565
|
+
R.not(accessibility) && header
|
|
566
|
+
] }) }),
|
|
567
|
+
/* @__PURE__ */ jsxs(Grid, { container: true, spacing: 1, children: [
|
|
568
|
+
accessibility && header,
|
|
569
|
+
accessibility && sectionsAndRows,
|
|
570
|
+
R.not(accessibility) && /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, md: 6, children: sectionsAndRows }),
|
|
571
|
+
!noPreview && /* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, md: accessibility ? 12 : 6, className: cx(classes.wrapper), children: [
|
|
572
|
+
/* @__PURE__ */ jsxs("div", { className: classes.iconTitle, children: [
|
|
573
|
+
/* @__PURE__ */ jsx(ViewQuiltOutlined, {}),
|
|
574
|
+
/* @__PURE__ */ jsx(Typography, { tabIndex: 0, variant: "subtitle1", children: labels.table })
|
|
575
|
+
] }),
|
|
576
|
+
/* @__PURE__ */ jsx(
|
|
577
|
+
TablePreview,
|
|
578
|
+
{
|
|
579
|
+
header: R.props(R.prop("header", currentLayout), indexedItems),
|
|
580
|
+
sections: R.props(R.prop("sections", currentLayout), indexedItems),
|
|
581
|
+
rows: R.props(R.prop("rows", currentLayout), indexedItems),
|
|
582
|
+
itemRenderer
|
|
583
|
+
}
|
|
584
|
+
)
|
|
585
|
+
] })
|
|
469
586
|
] })
|
|
470
|
-
] })
|
|
471
|
-
|
|
587
|
+
] }),
|
|
588
|
+
/* @__PURE__ */ jsx(DragOverlay, { children: overlayItem ? /* @__PURE__ */ jsx(
|
|
589
|
+
ItemBody,
|
|
590
|
+
{
|
|
591
|
+
item: overlayItem,
|
|
592
|
+
itemRenderer,
|
|
593
|
+
dropZoneLabel: overlayZone,
|
|
594
|
+
itemButtonProps,
|
|
595
|
+
canDrag: true,
|
|
596
|
+
describedBy: wcagId
|
|
597
|
+
}
|
|
598
|
+
) : null })
|
|
599
|
+
]
|
|
472
600
|
}
|
|
473
601
|
),
|
|
474
602
|
/* @__PURE__ */ jsxs(
|