@luscii-healthtech/web-ui 2.56.1 → 2.56.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.
@@ -3,3 +3,4 @@ export { BaseListItem } from "./BaseListItem";
3
3
  export type { BaseListProps, BaseListItemProps, OnAssetLoadErrorPayload, DraggableBaseListProps, DraggableBaseListItemProps, } from "./BaseList.types";
4
4
  export { DraggableBaseList, DraggableBaseListItem } from "./DraggableBaseList";
5
5
  export { SortableBaseList, SortableBaseListItem } from "./SortableBaseList";
6
+ export { getDndListItemProps } from "./utils";
@@ -1,3 +1,10 @@
1
+ import { Active, Over } from "@dnd-kit/core";
1
2
  import { ListItemProps } from "../List/List";
2
- import { BaseListItemProps } from ".";
3
- export declare const toBaseListItemProps: (props: ListItemProps) => BaseListItemProps;
3
+ declare const draggableListItemPropsPointer: {
4
+ readonly symbol: symbol;
5
+ };
6
+ declare type DraggableListItemProps = WeakMap<typeof draggableListItemPropsPointer, Pick<ListItemProps, "itemId" | "title" | "subtitle" | "icon" | "isDraggable" | "isSelected">>;
7
+ export declare const createDraggableListProps: ({ itemId, title, subtitle, icon, isDraggable, isSelected, }: ListItemProps) => DraggableListItemProps;
8
+ export declare const draggableListPropsKey: "listItem";
9
+ export declare const getDndListItemProps: (subject: Active | Over) => ListItemProps | null;
10
+ export {};
@@ -1,4 +1,5 @@
1
1
  export { default as List } from "./List";
2
2
  export { ListItem } from "./ListItem";
3
3
  export type { ListProps, ListItemProps, DraggableListProps, SortableListProps, SortableListItemProps, } from "./List.types";
4
- export type { OnAssetLoadErrorPayload } from "./../BaseList";
4
+ export type { OnAssetLoadErrorPayload } from "../BaseList";
5
+ export { getDndListItemProps } from "../BaseList";
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { Table, TableProps } from "./components/Table/Table";
31
31
  export { TableFieldConfig, TableFieldContent, TableFieldText, TableFieldAction, } from "./components/Table/Table.types";
32
32
  export { LoadingIndicator, LoadingIndicatorProps, } from "./components/LoadingIndicator/LoadingIndicator";
33
33
  export { default as Menu } from "./components/Menu/Menu";
34
- export { List, ListItem, ListProps, ListItemProps, DraggableListProps, SortableListProps, SortableListItemProps, OnAssetLoadErrorPayload, } from "./components/List";
34
+ export { List, ListItem, ListProps, ListItemProps, DraggableListProps, SortableListProps, SortableListItemProps, OnAssetLoadErrorPayload, getDndListItemProps, } from "./components/List";
35
35
  export { CheckboxList, CheckboxListProps, } from "./components/CheckboxList/CheckboxList";
36
36
  export { CheckboxListModal, CheckboxListModalProps, } from "./components/CheckBoxListModal/CheckboxListModal";
37
37
  export { MultiSelect } from "./components/MultiSelect/MultiSelect";
@@ -2497,18 +2497,61 @@ function isIconKey(key) {
2497
2497
  return false;
2498
2498
  }
2499
2499
 
2500
+ // You should be able to just use a non-registered Symbol as a key in a WeakMap
2501
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
2502
+ // TS doesn't allow it (registered and non-registered Symbols are both of type symbol), so we have to use an object
2503
+ var draggableListItemPropsPointer = {
2504
+ symbol: /*#__PURE__*/Symbol("draggable-list-item-props")
2505
+ };
2506
+ var createDraggableListProps = function createDraggableListProps(_ref) {
2507
+ var itemId = _ref.itemId,
2508
+ title = _ref.title,
2509
+ subtitle = _ref.subtitle,
2510
+ icon = _ref.icon,
2511
+ isDraggable = _ref.isDraggable,
2512
+ isSelected = _ref.isSelected;
2513
+ return new WeakMap([[draggableListItemPropsPointer, Object.freeze({
2514
+ itemId: itemId,
2515
+ title: title,
2516
+ subtitle: subtitle,
2517
+ icon: icon,
2518
+ isDraggable: isDraggable,
2519
+ isSelected: isSelected
2520
+ })]]);
2521
+ };
2522
+
2523
+ var isDraggableListItemProps = function isDraggableListItemProps(subject) {
2524
+ if (subject instanceof WeakMap) {
2525
+ return subject.has(draggableListItemPropsPointer);
2526
+ }
2527
+
2528
+ return false;
2529
+ };
2530
+
2531
+ var draggableListPropsKey = "listItem";
2532
+ var getDndListItemProps = function getDndListItemProps(subject) {
2533
+ var _subject$data, _subject$data$current, _possibleDraggableLis;
2534
+
2535
+ var possibleDraggableListItemProps = (_subject$data = subject.data) == null ? void 0 : (_subject$data$current = _subject$data.current) == null ? void 0 : _subject$data$current[draggableListPropsKey];
2536
+
2537
+ if (!isDraggableListItemProps(possibleDraggableListItemProps)) {
2538
+ return null;
2539
+ }
2540
+
2541
+ return (_possibleDraggableLis = possibleDraggableListItemProps.get(draggableListItemPropsPointer)) != null ? _possibleDraggableLis : null;
2542
+ };
2543
+
2500
2544
  var _excluded$3 = ["draggableData"];
2501
2545
  var DraggableBaseListItem = function DraggableBaseListItem(_ref) {
2546
+ var _data;
2547
+
2502
2548
  var draggableData = _ref.draggableData,
2503
2549
  props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
2504
2550
 
2505
2551
  var _useDraggable = core.useDraggable({
2506
2552
  id: props.draggableIdentifier,
2507
2553
  disabled: !props.isDraggable,
2508
- data: {
2509
- item: props,
2510
- draggableData: draggableData
2511
- }
2554
+ data: (_data = {}, _data[draggableListPropsKey] = createDraggableListProps(props), _data.draggableData = draggableData, _data)
2512
2555
  }),
2513
2556
  setNodeRef = _useDraggable.setNodeRef,
2514
2557
  listeners = _useDraggable.listeners,
@@ -2636,16 +2679,15 @@ var Dropzone = function Dropzone(_ref3) {
2636
2679
 
2637
2680
  var _excluded$6 = ["draggableData"];
2638
2681
  var SortableBaseListItem = function SortableBaseListItem(_ref) {
2682
+ var _data;
2683
+
2639
2684
  var draggableData = _ref.draggableData,
2640
2685
  props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
2641
2686
 
2642
2687
  var _useSortable = sortable.useSortable({
2643
2688
  id: props.draggableIdentifier,
2644
2689
  disabled: !props.isDraggable,
2645
- data: {
2646
- item: props,
2647
- draggableData: draggableData
2648
- }
2690
+ data: (_data = {}, _data[draggableListPropsKey] = createDraggableListProps(props), _data.draggableData = draggableData, _data)
2649
2691
  }),
2650
2692
  setNodeRef = _useSortable.setNodeRef,
2651
2693
  listeners = _useSortable.listeners,
@@ -8667,5 +8709,6 @@ exports.Title = Title;
8667
8709
  exports.Toaster = Toaster;
8668
8710
  exports.ViewItem = ViewItem;
8669
8711
  exports.WarningIcon = WarningIcon;
8712
+ exports.getDndListItemProps = getDndListItemProps;
8670
8713
  exports.toast = toast;
8671
8714
  //# sourceMappingURL=web-ui.cjs.development.js.map