@luscii-healthtech/web-ui 42.5.1 → 42.5.2
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.
|
@@ -1488,9 +1488,9 @@ const SortableBaseListItem = (_a) => {
|
|
|
1488
1488
|
});
|
|
1489
1489
|
const styleTransform = utilities.CSS.Transform.toString(transform);
|
|
1490
1490
|
if (isDragging) {
|
|
1491
|
-
return jsxRuntime.jsxs("div", { style: { transform: styleTransform, position: "relative" }, children: [jsxRuntime.jsx(DropzonePresentation, { className: "ui:absolute ui:h-full ui:w-full" }), jsxRuntime.jsx("div", { className: "ui:invisible", children: jsxRuntime.jsx(BaseListItem, Object.assign({}, props, { ref: setNodeRef, htmlProps: { style: { transform: styleTransform } }, isDraggable: true, renderDragHandle: () => jsxRuntime.jsx(DragHandle, Object.assign({}, attributes, listeners, { disabled: !props.isDraggable, grabbing: isDragging })) })) })] });
|
|
1491
|
+
return jsxRuntime.jsxs("div", { style: { transform: styleTransform, position: "relative" }, children: [jsxRuntime.jsx(DropzonePresentation, { className: "ui:absolute ui:h-full ui:w-full" }), jsxRuntime.jsx("div", { className: "ui:invisible", children: jsxRuntime.jsx(BaseListItem, Object.assign({}, props, { ref: setNodeRef, htmlProps: { style: { transform: styleTransform } }, isDraggable: props.__isNested ? false : true, renderDragHandle: () => jsxRuntime.jsx(DragHandle, Object.assign({}, attributes, listeners, { disabled: !props.isDraggable, grabbing: isDragging })) })) })] });
|
|
1492
1492
|
}
|
|
1493
|
-
return jsxRuntime.jsx(BaseListItem, Object.assign({}, props, { ref: setNodeRef, htmlProps: { style: { transform: styleTransform } }, isDraggable: true, renderDragHandle: () => jsxRuntime.jsx(DragHandle, Object.assign({}, attributes, listeners, { disabled: !props.isDraggable, grabbing: isDragging })) }));
|
|
1493
|
+
return jsxRuntime.jsx(BaseListItem, Object.assign({}, props, { ref: setNodeRef, htmlProps: { style: { transform: styleTransform } }, isDraggable: props.__isNested ? false : true, renderDragHandle: () => jsxRuntime.jsx(DragHandle, Object.assign({}, attributes, listeners, { disabled: !props.isDraggable, grabbing: isDragging })) }));
|
|
1494
1494
|
};
|
|
1495
1495
|
|
|
1496
1496
|
const SortableBaseList = (_a) => {
|
|
@@ -1525,28 +1525,28 @@ const DefaultList = (_a) => {
|
|
|
1525
1525
|
return next;
|
|
1526
1526
|
});
|
|
1527
1527
|
};
|
|
1528
|
+
const composeIconWithChevron = (parentItem, isExpanded) => {
|
|
1529
|
+
return jsxRuntime.jsxs(Stack, { axis: "x", gap: "xs", align: "center", children: [jsxRuntime.jsx("button", { type: "button", "aria-expanded": isExpanded, onClick: (e) => {
|
|
1530
|
+
e.stopPropagation();
|
|
1531
|
+
toggleExpand(parentItem.itemId);
|
|
1532
|
+
}, onKeyDown: (e) => {
|
|
1533
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1534
|
+
e.preventDefault();
|
|
1535
|
+
e.stopPropagation();
|
|
1536
|
+
toggleExpand(parentItem.itemId);
|
|
1537
|
+
}
|
|
1538
|
+
}, children: jsxRuntime.jsx(ChevronRightIcon, { color: "neutral-interactive", "aria-hidden": "true", className: classNames__default.default("ui:shrink-0 ui:transition-transform", {
|
|
1539
|
+
"ui:rotate-90": isExpanded
|
|
1540
|
+
}) }) }), parentItem.icon ? jsxRuntime.jsx(BaseListIcon, { icon: parentItem.icon }) : null] });
|
|
1541
|
+
};
|
|
1528
1542
|
const flattenedItems = React.useMemo(() => {
|
|
1529
1543
|
const result = [];
|
|
1530
|
-
innerItems.forEach((parentItem) => {
|
|
1544
|
+
innerItems.forEach((parentItem, parentIndex) => {
|
|
1531
1545
|
var _a2;
|
|
1532
1546
|
const hasChildren = Boolean((_a2 = parentItem.children) === null || _a2 === void 0 ? void 0 : _a2.length);
|
|
1533
1547
|
const isExpanded = expandedIds.has(parentItem.itemId);
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
composedIcon = jsxRuntime.jsxs(Stack, { axis: "x", gap: "xs", align: "center", children: [jsxRuntime.jsx("button", { type: "button", "aria-expanded": isExpanded, onClick: (e) => {
|
|
1537
|
-
e.stopPropagation();
|
|
1538
|
-
toggleExpand(parentItem.itemId);
|
|
1539
|
-
}, onKeyDown: (e) => {
|
|
1540
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
1541
|
-
e.preventDefault();
|
|
1542
|
-
e.stopPropagation();
|
|
1543
|
-
toggleExpand(parentItem.itemId);
|
|
1544
|
-
}
|
|
1545
|
-
}, children: jsxRuntime.jsx(ChevronRightIcon, { color: "neutral-interactive", "aria-hidden": "true", className: classNames__default.default("ui:shrink-0 ui:transition-transform", {
|
|
1546
|
-
"ui:rotate-90": isExpanded
|
|
1547
|
-
}) }) }), parentItem.icon ? jsxRuntime.jsx(BaseListIcon, { icon: parentItem.icon }) : null] });
|
|
1548
|
-
}
|
|
1549
|
-
result.push(Object.assign(Object.assign(Object.assign({}, parentItem), { icon: composedIcon, htmlProps: Object.assign(Object.assign({}, parentItem.htmlProps), { id: `list-item-${parentItem.itemId}` }) }), parentItem.handleItemClick ? {
|
|
1548
|
+
const composedIcon = hasChildren ? composeIconWithChevron(parentItem, isExpanded) : parentItem.icon;
|
|
1549
|
+
result.push(Object.assign(Object.assign(Object.assign({}, parentItem), { icon: composedIcon, __parentIndex: parentIndex, htmlProps: Object.assign(Object.assign({}, parentItem.htmlProps), { id: `list-item-${parentItem.itemId}` }) }), parentItem.handleItemClick ? {
|
|
1550
1550
|
handleItemClick: (e) => {
|
|
1551
1551
|
var _a3;
|
|
1552
1552
|
(_a3 = parentItem.handleItemClick) === null || _a3 === void 0 ? void 0 : _a3.call(parentItem, e);
|
|
@@ -1565,22 +1565,32 @@ const DefaultList = (_a) => {
|
|
|
1565
1565
|
}
|
|
1566
1566
|
return jsxRuntime.jsxs(core.DndContext, { sensors: [sensor], onDragStart: (event) => {
|
|
1567
1567
|
setDraggedListItem(getDndListItemProps(event.active));
|
|
1568
|
+
setExpandedIds(/* @__PURE__ */ new Set());
|
|
1568
1569
|
}, onDragEnd: (event) => {
|
|
1569
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1570
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1570
1571
|
if (!draggedListItem) {
|
|
1571
1572
|
return;
|
|
1572
1573
|
}
|
|
1573
1574
|
const currentIndex = (_d = (_c = (_b = (_a2 = event.active) === null || _a2 === void 0 ? void 0 : _a2.data) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.sortable) === null || _d === void 0 ? void 0 : _d.index;
|
|
1574
1575
|
const newIndex = (_h = (_g = (_f = (_e = event.over) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.current) === null || _g === void 0 ? void 0 : _g.sortable) === null || _h === void 0 ? void 0 : _h.index;
|
|
1575
1576
|
if (typeof currentIndex === "number" && typeof newIndex === "number") {
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1577
|
+
const currentParentIndex = flattenedItems[currentIndex].__parentIndex;
|
|
1578
|
+
const newParentIndex = (_j = flattenedItems[newIndex]) === null || _j === void 0 ? void 0 : _j.__parentIndex;
|
|
1579
|
+
if (typeof newParentIndex === "number") {
|
|
1580
|
+
const newItems = sortable.arrayMove(innerItems, currentParentIndex, newParentIndex);
|
|
1581
|
+
setInnerItems(newItems);
|
|
1582
|
+
onDragEnd(draggedListItem.itemId, newParentIndex, {
|
|
1583
|
+
state: newItems
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1581
1586
|
}
|
|
1582
1587
|
setDraggedListItem(null);
|
|
1583
|
-
}, children: [jsxRuntime.jsx(SortableBaseList, Object.assign({ draggableIdentifier: "sortable-list-identifier", items:
|
|
1588
|
+
}, children: [jsxRuntime.jsx(SortableBaseList, Object.assign({ draggableIdentifier: "sortable-list-identifier", items: flattenedItems.map((item) => Object.assign(Object.assign({}, item), {
|
|
1589
|
+
draggableIdentifier: `${item.itemId}`,
|
|
1590
|
+
isDraggable: item.__parentIndex !== void 0,
|
|
1591
|
+
// Only top-level items are draggable
|
|
1592
|
+
onAssetLoadError
|
|
1593
|
+
})), subtitle }, props)), jsxRuntime.jsx(core.DragOverlay, { dropAnimation: null, wrapperElement: "ul", className: "ui:shadow-lg", children: draggedListItem && jsxRuntime.jsx(ListItem, Object.assign({}, draggedListItem, { renderDragHandle: () => jsxRuntime.jsx(DragHandle, { grabbing: true }) })) })] });
|
|
1584
1594
|
};
|
|
1585
1595
|
const List = (props) => {
|
|
1586
1596
|
if ("draggableListType" in props) {
|