@cloudscape-design/board-components 3.0.30 → 3.0.31

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/board/internal.js CHANGED
@@ -132,7 +132,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
132
132
  dispatch({ type: "discard" });
133
133
  autoScrollHandlers.removePointerEventHandlers();
134
134
  });
135
- useDragSubscription("acquire", ({ droppableId, draggableItem, acquiredItemElement }) => {
135
+ useDragSubscription("acquire", ({ droppableId, draggableItem, renderAcquiredItem }) => {
136
136
  const placeholder = placeholdersLayout.items.find((it) => it.id === droppableId);
137
137
  // If missing then it does not belong to this board.
138
138
  if (!placeholder) {
@@ -142,7 +142,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
142
142
  type: "acquire-item",
143
143
  position: new Position({ x: placeholder.x, y: placeholder.y }),
144
144
  layoutElement: containerAccessRef.current,
145
- acquiredItemElement: acquiredItemElement,
145
+ acquiredItemElement: renderAcquiredItem(),
146
146
  });
147
147
  focusNextRenderIdRef.current = draggableItem.id;
148
148
  });
@@ -192,7 +192,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
192
192
  else {
193
193
  delete itemContainerRef.current[item.id];
194
194
  }
195
- }, item: item, transform: transforms[item.id], inTransition: !!transition || !!removeTransition, placed: true, acquired: item.id === (acquiredItem === null || acquiredItem === void 0 ? void 0 : acquiredItem.id), getItemSize: () => ({
195
+ }, item: item, transform: transforms[item.id], inTransition: !!transition || !!removeTransition, placed: item.id !== (acquiredItem === null || acquiredItem === void 0 ? void 0 : acquiredItem.id), acquired: item.id === (acquiredItem === null || acquiredItem === void 0 ? void 0 : acquiredItem.id), getItemSize: () => ({
196
196
  width: gridContext.getWidth(itemSize.width),
197
197
  minWidth: gridContext.getWidth(getMinColumnSpan(item, itemsLayout.columns)),
198
198
  maxWidth: gridContext.getWidth(itemMaxSize.width),
@@ -36,7 +36,7 @@ export interface Droppable {
36
36
  interface AcquireData {
37
37
  droppableId: ItemId;
38
38
  draggableItem: Item;
39
- acquiredItemElement?: ReactNode;
39
+ renderAcquiredItem: () => ReactNode;
40
40
  }
41
41
  export interface DragAndDropEvents {
42
42
  start: (data: DragAndDropData) => void;
@@ -54,7 +54,7 @@ export declare function useDraggable({ draggableItem, getCollisionRect, }: {
54
54
  updateTransition(coordinates: Coordinates): void;
55
55
  submitTransition(): void;
56
56
  discardTransition(): void;
57
- acquire(droppableId: ItemId, acquiredItemElement?: ReactNode): void;
57
+ acquire(droppableId: ItemId, renderAcquiredItem: () => ReactNode): void;
58
58
  getDroppables(): [string, Droppable][];
59
59
  };
60
60
  export declare function useDroppable({ itemId, context, getElement, }: {
@@ -43,11 +43,11 @@ class DragAndDropController extends EventEmitter {
43
43
  /**
44
44
  * Issues an "acquire" event to notify the current transition draggable is acquired by the given droppable.
45
45
  */
46
- acquire(droppableId, acquiredItemElement) {
46
+ acquire(droppableId, renderAcquiredItem) {
47
47
  if (!this.transition) {
48
48
  throw new Error("Invariant violation: no transition present for acquire.");
49
49
  }
50
- this.emit("acquire", { droppableId, draggableItem: this.transition.draggableItem, acquiredItemElement });
50
+ this.emit("acquire", { droppableId, draggableItem: this.transition.draggableItem, renderAcquiredItem });
51
51
  }
52
52
  /**
53
53
  * Registers a droppable used for collisions check, acquire, and dropTarget provision.
@@ -115,8 +115,8 @@ export function useDraggable({ draggableItem, getCollisionRect, }) {
115
115
  discardTransition() {
116
116
  controller.discard();
117
117
  },
118
- acquire(droppableId, acquiredItemElement) {
119
- controller.acquire(droppableId, acquiredItemElement);
118
+ acquire(droppableId, renderAcquiredItem) {
119
+ controller.acquire(droppableId, renderAcquiredItem);
120
120
  },
121
121
  getDroppables() {
122
122
  return controller.getDroppables();
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "board-components";
2
- export var PACKAGE_VERSION = "3.0.0 (5dff2947)";
2
+ export var PACKAGE_VERSION = "3.0.0 (222f89e3)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "board-components",
3
- "PACKAGE_VERSION": "3.0.0 (5dff2947)",
3
+ "PACKAGE_VERSION": "3.0.0 (222f89e3)",
4
4
  "THEME": "open-source-visual-refresh",
5
5
  "ALWAYS_VISUAL_REFRESH": true
6
6
  }
@@ -46,7 +46,7 @@ export interface ItemContainerProps {
46
46
  maxHeight: number;
47
47
  };
48
48
  onKeyMove?(direction: Direction): void;
49
- children: () => ReactNode;
49
+ children: (hasDropTarget: boolean) => ReactNode;
50
50
  }
51
51
  export declare const ItemContainer: import("react").ForwardRefExoticComponent<ItemContainerProps & import("react").RefAttributes<ItemContainerRef>>;
52
52
  export {};
@@ -60,6 +60,7 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
60
60
  itemId: draggableItem.id,
61
61
  sizeTransform: dropTarget ? getItemSize(dropTarget) : originalSizeRef.current,
62
62
  positionTransform: { x: coordinates.x - pointerOffset.x, y: coordinates.y - pointerOffset.y },
63
+ hasDropTarget: !!dropTarget,
63
64
  });
64
65
  }
65
66
  }
@@ -154,7 +155,7 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
154
155
  return;
155
156
  }
156
157
  // Notify the respective droppable of the intention to insert the item in it.
157
- draggableApi.acquire(nextDroppable, childrenRef.current);
158
+ draggableApi.acquire(nextDroppable, () => children(true));
158
159
  setIsHidden(true);
159
160
  muteEventsRef.current = true;
160
161
  }
@@ -244,7 +245,7 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
244
245
  if (isHidden) {
245
246
  itemTransitionClassNames.push(styles.hidden);
246
247
  }
247
- if (placed && transform) {
248
+ if (transform) {
248
249
  // The moved items positions are altered with CSS transform.
249
250
  if (transform.type === "move") {
250
251
  itemTransitionClassNames.push(styles.transformed);
@@ -272,7 +273,7 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
272
273
  (transition === null || transition === void 0 ? void 0 : transition.interactionType) === "pointer";
273
274
  const childrenRef = useRef(null);
274
275
  if (!inTransition || isActive) {
275
- childrenRef.current = children();
276
+ childrenRef.current = children(!!(transition === null || transition === void 0 ? void 0 : transition.hasDropTarget));
276
277
  }
277
278
  const content = (_jsx("div", { ref: itemRef, className: clsx(styles.root, ...itemTransitionClassNames), style: itemTransitionStyle, "data-item-id": item.id, onBlur: onBlur, children: _jsx(ItemContext.Provider, { value: {
278
279
  isActive,
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "5dff29478d324c1d9508bb43b94dcef2e723a177"
2
+ "commit": "222f89e36dd7458e8541be32c1e9dc059173a886"
3
3
  }
@@ -18,7 +18,7 @@ export function InternalItemsPalette({ items, renderItem, i18nStrings, __interna
18
18
  itemContainerRef.current[itemId].focusDragHandle();
19
19
  }
20
20
  useDragSubscription("start", ({ draggableItem: { id } }) => {
21
- setDropState({ id, isExpanded: false });
21
+ setDropState({ id });
22
22
  // Announce only if the target item belongs to the palette.
23
23
  if (items.some((it) => it.id === id)) {
24
24
  setAnnouncement(i18nStrings.liveAnnouncementDndStarted);
@@ -27,8 +27,8 @@ export function InternalItemsPalette({ items, renderItem, i18nStrings, __interna
27
27
  setAnnouncement("");
28
28
  }
29
29
  });
30
- useDragSubscription("update", ({ draggableItem: { id }, dropTarget }) => {
31
- setDropState({ id, isExpanded: !!dropTarget });
30
+ useDragSubscription("update", ({ draggableItem: { id } }) => {
31
+ setDropState({ id });
32
32
  });
33
33
  useDragSubscription("submit", () => {
34
34
  setDropState(undefined);
@@ -68,7 +68,5 @@ export function InternalItemsPalette({ items, renderItem, i18nStrings, __interna
68
68
  }
69
69
  const { width, height } = dropContext.scale(item);
70
70
  return { width, minWidth: width, maxWidth: width, height, minHeight: height, maxHeight: height };
71
- }, children: () => renderItem(item, {
72
- showPreview: (dropState === null || dropState === void 0 ? void 0 : dropState.id) === item.id && dropState.isExpanded,
73
- }) }, item.id))) }) }), _jsx(LiveRegion, { children: announcement })] }));
71
+ }, children: (hasDropTarget) => renderItem(item, { showPreview: hasDropTarget }) }, item.id))) }) }), _jsx(LiveRegion, { children: announcement })] }));
74
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudscape-design/board-components",
3
- "version": "3.0.30",
3
+ "version": "3.0.31",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cloudscape-design/board-components.git"