@cloudscape-design/board-components 3.0.22 → 3.0.23

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.
@@ -134,6 +134,7 @@ export interface Transition<D> {
134
134
  collisionIds: Set<ItemId>;
135
135
  layoutShift: null | LayoutShift;
136
136
  path: readonly Position[];
137
+ acquiredItemElement?: ReactNode;
137
138
  }
138
139
  export interface RemoveTransition<D> {
139
140
  items: readonly BoardProps.Item<D>[];
package/board/internal.js CHANGED
@@ -34,6 +34,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
34
34
  const removeTransition = transitionState.removeTransition;
35
35
  const transitionAnnouncement = transitionState.announcement;
36
36
  const acquiredItem = (_a = transition === null || transition === void 0 ? void 0 : transition.acquiredItem) !== null && _a !== void 0 ? _a : null;
37
+ const acquiredItemElement = transition === null || transition === void 0 ? void 0 : transition.acquiredItemElement;
37
38
  // Using cached columns from transition to ensure no unexpected changes in the process.
38
39
  const columns = transition ? transition.itemsLayout.columns : currentColumns;
39
40
  // Use previous items while remove transition is in progress.
@@ -132,7 +133,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
132
133
  document.body.classList.remove(styles["current-operation-reorder"], styles["current-operation-resize"]);
133
134
  autoScrollHandlers.removePointerEventHandlers();
134
135
  });
135
- useDragSubscription("acquire", ({ droppableId, draggableItem }) => {
136
+ useDragSubscription("acquire", ({ droppableId, draggableItem, acquiredItemElement }) => {
136
137
  const placeholder = placeholdersLayout.items.find((it) => it.id === droppableId);
137
138
  // If missing then it does not belong to this board.
138
139
  if (!placeholder) {
@@ -142,6 +143,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
142
143
  type: "acquire-item",
143
144
  position: new Position({ x: placeholder.x, y: placeholder.y }),
144
145
  layoutElement: containerAccessRef.current,
146
+ acquiredItemElement: acquiredItemElement,
145
147
  });
146
148
  focusNextRenderIdRef.current = draggableItem.id;
147
149
  });
@@ -198,7 +200,9 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
198
200
  height: gridContext.getHeight(itemSize.height),
199
201
  minHeight: gridContext.getHeight(getMinRowSpan(item)),
200
202
  maxHeight: gridContext.getHeight(itemMaxSize.height),
201
- }), onKeyMove: onItemMove, children: () => renderItem(item, { removeItem: () => removeItemAction(item) }) }, item.id));
203
+ }), onKeyMove: onItemMove, children: item.id === (acquiredItem === null || acquiredItem === void 0 ? void 0 : acquiredItem.id) && acquiredItemElement
204
+ ? () => acquiredItemElement
205
+ : () => renderItem(item, { removeItem: () => removeItemAction(item) }) }, item.id));
202
206
  });
203
207
  return children;
204
208
  } })) : (empty) }), _jsx(LiveRegion, { children: announcement })] }));
@@ -1,4 +1,4 @@
1
- import { Dispatch } from "react";
1
+ import { Dispatch, ReactNode } from "react";
2
2
  import { InteractionType, Operation } from "../internal/dnd-controller/controller";
3
3
  import { BoardItemDefinitionBase, Direction, GridLayout, ItemId, Rect } from "../internal/interfaces";
4
4
  import { Coordinates } from "../internal/utils/coordinates";
@@ -45,6 +45,7 @@ interface AcquireItemAction {
45
45
  type: "acquire-item";
46
46
  position: Position;
47
47
  layoutElement: HTMLElement;
48
+ acquiredItemElement?: ReactNode;
48
49
  }
49
50
  export declare function useTransition<D>(): [TransitionState<D>, Dispatch<Action<D>>];
50
51
  export declare function selectTransitionRows<D>(state: TransitionState<D>): number;
@@ -207,7 +207,7 @@ function updateTransitionWithKeyboardEvent(state, { direction }) {
207
207
  return updateManualItemTransition(transition, "down");
208
208
  }
209
209
  }
210
- function acquireTransitionItem(state, { position, layoutElement }) {
210
+ function acquireTransitionItem(state, { position, layoutElement, acquiredItemElement }) {
211
211
  const { transition } = state;
212
212
  if (!transition) {
213
213
  throw new Error("Invariant violation: no transition.");
@@ -224,7 +224,14 @@ function acquireTransitionItem(state, { position, layoutElement }) {
224
224
  const layoutShift = getLayoutShift(transition, path, insertionDirection);
225
225
  // The columnOffset, columnSpan and rowSpan are of no use as of being overridden by the layout shift.
226
226
  const acquiredItem = { ...transition.draggableItem, columnOffset: 0, columnSpan: 1, rowSpan: 1 };
227
- const nextTransition = { ...transition, collisionIds: new Set(), layoutShift, path, acquiredItem };
227
+ const nextTransition = {
228
+ ...transition,
229
+ collisionIds: new Set(),
230
+ layoutShift,
231
+ path,
232
+ acquiredItem,
233
+ acquiredItemElement,
234
+ };
228
235
  return {
229
236
  transition: nextTransition,
230
237
  removeTransition: null,
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from "react";
1
2
  import { BoardItemDefinitionBase, ItemId, Rect } from "../interfaces";
2
3
  import { Coordinates } from "../utils/coordinates";
3
4
  type Item = BoardItemDefinitionBase<unknown>;
@@ -35,6 +36,7 @@ export interface Droppable {
35
36
  interface AcquireData {
36
37
  droppableId: ItemId;
37
38
  draggableItem: Item;
39
+ acquiredItemElement?: ReactNode;
38
40
  }
39
41
  export interface DragAndDropEvents {
40
42
  start: (data: DragAndDropData) => void;
@@ -52,7 +54,7 @@ export declare function useDraggable({ draggableItem, getCollisionRect, }: {
52
54
  updateTransition(coordinates: Coordinates): void;
53
55
  submitTransition(): void;
54
56
  discardTransition(): void;
55
- acquire(droppableId: ItemId): void;
57
+ acquire(droppableId: ItemId, acquiredItemElement?: ReactNode): void;
56
58
  getDroppables(): [string, Droppable][];
57
59
  };
58
60
  export declare function useDroppable({ itemId, context, getElement, }: {
@@ -42,11 +42,11 @@ class DragAndDropController extends EventEmitter {
42
42
  /**
43
43
  * Issues an "acquire" event to notify the current transition draggable is acquired by the given droppable.
44
44
  */
45
- acquire(droppableId) {
45
+ acquire(droppableId, acquiredItemElement) {
46
46
  if (!this.transition) {
47
47
  throw new Error("Invariant violation: no transition present for acquire.");
48
48
  }
49
- this.emit("acquire", { droppableId, draggableItem: this.transition.draggableItem });
49
+ this.emit("acquire", { droppableId, draggableItem: this.transition.draggableItem, acquiredItemElement });
50
50
  }
51
51
  /**
52
52
  * Registers a droppable used for collisions check, acquire, and dropTarget provision.
@@ -113,8 +113,8 @@ export function useDraggable({ draggableItem, getCollisionRect, }) {
113
113
  discardTransition() {
114
114
  controller.discard();
115
115
  },
116
- acquire(droppableId) {
117
- controller.acquire(droppableId);
116
+ acquire(droppableId, acquiredItemElement) {
117
+ controller.acquire(droppableId, acquiredItemElement);
118
118
  },
119
119
  getDroppables() {
120
120
  return controller.getDroppables();
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "board-components";
2
- export var PACKAGE_VERSION = "3.0.0 (6b020a55)";
2
+ export var PACKAGE_VERSION = "3.0.0 (1e40ad14)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -139,7 +139,7 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
139
139
  return;
140
140
  }
141
141
  // Notify the respective droppable of the intention to insert the item in it.
142
- draggableApi.acquire(nextDroppable);
142
+ draggableApi.acquire(nextDroppable, childrenRef.current);
143
143
  }
144
144
  function onHandleKeyDown(operation, event) {
145
145
  const canInsert = transition && operation === "drag" && !placed;
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "6b020a55391b9ef905ace059cebdb51e305faf69"
2
+ "commit": "1e40ad14e04fda613654941bcee13153a5724069"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudscape-design/board-components",
3
- "version": "3.0.22",
3
+ "version": "3.0.23",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cloudscape-design/board-components.git"