@cloudscape-design/board-components 3.0.33 → 3.0.35
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/internal/dnd-controller/controller.js +2 -2
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/item-container/index.js +1 -2
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/internal/utils/use-stable-event-handler.d.ts +0 -9
- package/internal/utils/use-stable-event-handler.js +0 -19
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useStableCallback } from "@cloudscape-design/component-toolkit/internal";
|
|
3
4
|
import { useEffect } from "react";
|
|
4
5
|
import { Coordinates } from "../utils/coordinates";
|
|
5
|
-
import { useStableEventHandler } from "../utils/use-stable-event-handler";
|
|
6
6
|
import { EventEmitter } from "./event-emitter";
|
|
7
7
|
import { getHoveredDroppables } from "./get-hovered-droppables";
|
|
8
8
|
class DragAndDropController extends EventEmitter {
|
|
@@ -98,7 +98,7 @@ class DragAndDropController extends EventEmitter {
|
|
|
98
98
|
// Controller is a singleton and is shared between all d&d elements.
|
|
99
99
|
const controller = new DragAndDropController();
|
|
100
100
|
export function useDragSubscription(event, handler) {
|
|
101
|
-
const stableHandler =
|
|
101
|
+
const stableHandler = useStableCallback(handler);
|
|
102
102
|
useEffect(() => controller.on(event, stableHandler), [event, stableHandler]);
|
|
103
103
|
}
|
|
104
104
|
export function useDraggable({ draggableItem, getCollisionRect, }) {
|
package/internal/environment.js
CHANGED
|
@@ -269,8 +269,7 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
|
|
|
269
269
|
focusDragHandle: () => { var _a; return (_a = dragHandleRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
270
270
|
}));
|
|
271
271
|
const isActive = (!!transition && !isHidden) || !!acquired;
|
|
272
|
-
const shouldUsePortal = (
|
|
273
|
-
(transition === null || transition === void 0 ? void 0 : transition.interactionType) === "pointer";
|
|
272
|
+
const shouldUsePortal = (transition === null || transition === void 0 ? void 0 : transition.operation) === "insert" && (transition === null || transition === void 0 ? void 0 : transition.interactionType) === "pointer";
|
|
274
273
|
const childrenRef = useRef(null);
|
|
275
274
|
if (!inTransition || isActive) {
|
|
276
275
|
childrenRef.current = children(!!(transition === null || transition === void 0 ? void 0 : transition.hasDropTarget));
|
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A callback that stays stable between renders even as the dependencies change.
|
|
3
|
-
* Not a recommended React pattern, so it should be used sparingly and only if
|
|
4
|
-
* the callback is an event handler (i.e. not used during rendering) and causing
|
|
5
|
-
* clear performance issues.
|
|
6
|
-
*
|
|
7
|
-
* @see https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
|
|
8
|
-
*/
|
|
9
|
-
export declare function useStableEventHandler<T extends (...args: any[]) => any>(fn: T): T;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
-
// The code is copied from https://github.com/cloudscape-design/components/blob/main/src/internal/hooks/use-stable-event-handler/index.ts
|
|
5
|
-
/**
|
|
6
|
-
* A callback that stays stable between renders even as the dependencies change.
|
|
7
|
-
* Not a recommended React pattern, so it should be used sparingly and only if
|
|
8
|
-
* the callback is an event handler (i.e. not used during rendering) and causing
|
|
9
|
-
* clear performance issues.
|
|
10
|
-
*
|
|
11
|
-
* @see https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
|
|
12
|
-
*/
|
|
13
|
-
export function useStableEventHandler(fn) {
|
|
14
|
-
const ref = useRef();
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
ref.current = fn;
|
|
17
|
-
});
|
|
18
|
-
return useCallback((...args) => { var _a; return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.apply(undefined, args); }, []);
|
|
19
|
-
}
|