@luscii-healthtech/web-ui 42.5.0 → 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
- let composedIcon = parentItem.icon;
1535
- if (hasChildren) {
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 newItems = sortable.arrayMove(innerItems, currentIndex, newIndex);
1577
- setInnerItems(newItems);
1578
- onDragEnd(draggedListItem.itemId, newIndex, {
1579
- state: newItems
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: innerItems.map((item) => Object.assign(Object.assign({}, item), { draggableIdentifier: `${item.itemId}`, isDraggable: true, onAssetLoadError })), 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 }) })) })] });
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) {
@@ -5257,9 +5267,9 @@ const VerticalMenu = (props) => {
5257
5267
  const shouldShowCollapseButton = localization && Boolean(onCollapseButtonClick);
5258
5268
  const hasHeaderContent = title || shouldShowCollapseButton;
5259
5269
  const contextValue = React.useMemo(() => ({ variant }), [variant]);
5260
- return jsxRuntime.jsx(context$1.Provider, { value: contextValue, children: jsxRuntime.jsxs(Stack, Object.assign({ as: "div", px: "xxs", py: "m", align: "normal", className: classNames__default.default("ui:max-w-full", {
5270
+ return jsxRuntime.jsx(context$1.Provider, { value: contextValue, children: jsxRuntime.jsxs(Stack, Object.assign({ as: "div", px: "xxs", py: "m", align: "normal", className: classNames__default.default("ui:max-w-full", "ui:max-h-full", {
5261
5271
  [DEFAULT_TEXT_CLASS_NAME]: isCollapsed
5262
- }, className) }, rest, { children: [header && jsxRuntime.jsx("div", { children: header }), jsxRuntime.jsxs(Stack, { axis: "x", gap: "xxs", p: hasHeaderContent ? "m" : void 0, align: "start", justify: "between", width: "full", children: [title && jsxRuntime.jsx(Box, { children: jsxRuntime.jsx(Text, { variant: "lg-strong", children: title }) }), shouldShowCollapseButton && jsxRuntime.jsx(
5272
+ }, className) }, rest, { children: [jsxRuntime.jsxs(Stack, { width: "full", children: [header && jsxRuntime.jsx(Box, { width: "full", children: header }), jsxRuntime.jsxs(Stack, { axis: "x", gap: "xxs", p: hasHeaderContent ? "m" : void 0, align: "start", justify: "between", width: "full", children: [title && jsxRuntime.jsx(Box, { children: jsxRuntime.jsx(Text, { variant: "lg-strong", children: title }) }), shouldShowCollapseButton && jsxRuntime.jsx(
5263
5273
  Box,
5264
5274
  {
5265
5275
  /**
@@ -5284,7 +5294,7 @@ const VerticalMenu = (props) => {
5284
5294
  children: jsxRuntime.jsx(SidebarIcon, {})
5285
5295
  }) })
5286
5296
  }
5287
- )] }), isPrimaryVariant && hasHeaderContent && jsxRuntime.jsx(VerticalMenu.Divider, {}), jsxRuntime.jsx(Stack, { width: "full", gap: isCollapsed ? "xxs" : void 0, children: props.children }), jsxRuntime.jsx("div", { className: "ui:mt-auto", children: footer })] })) });
5297
+ )] })] }), isPrimaryVariant && hasHeaderContent && jsxRuntime.jsx(VerticalMenu.Divider, {}), jsxRuntime.jsx(Stack, { width: "full", className: "ui:flex-1 ui:overflow-y-auto", gap: isCollapsed ? "xxs" : void 0, children: props.children }), jsxRuntime.jsx("div", { className: "ui:mt-auto", children: footer })] })) });
5288
5298
  };
5289
5299
  VerticalMenu.Divider = MenuDivider;
5290
5300
  VerticalMenu.Item = MenuItem;