@cloudscape-design/board-components 3.0.8 → 3.0.10
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-item/styles.css.js +10 -10
- package/board-item/styles.scoped.css +10 -10
- package/board-item/styles.selectors.js +10 -10
- package/internal/drag-handle/index.js +2 -2
- package/internal/environment.js +1 -1
- package/internal/item-container/index.js +16 -15
- package/internal/manifest.json +1 -1
- package/internal/resize-handle/index.js +4 -2
- package/internal/utils/throttle.js +3 -1
- package/package.json +1 -1
- package/internal/drag-handle/icon.d.ts +0 -4
- package/internal/drag-handle/icon.js +0 -12
- package/internal/resize-handle/icon.d.ts +0 -4
- package/internal/resize-handle/icon.js +0 -12
- package/internal/utils/use-throttled-event-handler.d.ts +0 -1
- package/internal/utils/use-throttled-event-handler.js +0 -11
package/board-item/styles.css.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"root": "
|
|
5
|
-
"container-override": "awsui_container-
|
|
6
|
-
"active": "
|
|
7
|
-
"header": "
|
|
8
|
-
"flexible": "
|
|
9
|
-
"handle": "
|
|
10
|
-
"header-content": "awsui_header-
|
|
11
|
-
"settings": "
|
|
12
|
-
"fixed": "
|
|
13
|
-
"resizer": "
|
|
4
|
+
"root": "awsui_root_9ckv7_o6rfp_1",
|
|
5
|
+
"container-override": "awsui_container-override_9ckv7_o6rfp_6",
|
|
6
|
+
"active": "awsui_active_9ckv7_o6rfp_6",
|
|
7
|
+
"header": "awsui_header_9ckv7_o6rfp_10",
|
|
8
|
+
"flexible": "awsui_flexible_9ckv7_o6rfp_16",
|
|
9
|
+
"handle": "awsui_handle_9ckv7_o6rfp_20",
|
|
10
|
+
"header-content": "awsui_header-content_9ckv7_o6rfp_24",
|
|
11
|
+
"settings": "awsui_settings_9ckv7_o6rfp_28",
|
|
12
|
+
"fixed": "awsui_fixed_9ckv7_o6rfp_33",
|
|
13
|
+
"resizer": "awsui_resizer_9ckv7_o6rfp_37"
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
.
|
|
1
|
+
.awsui_root_9ckv7_o6rfp_1:not(#\9) {
|
|
2
2
|
display: contents;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
/* TODO: use container API instead of styles override */
|
|
6
|
-
.awsui_container-
|
|
6
|
+
.awsui_container-override_9ckv7_o6rfp_6.awsui_active_9ckv7_o6rfp_6:not(#\9) {
|
|
7
7
|
box-shadow: var(--shadow-container-active-l4kuxc, 0px 1px 1px 1px #e9ebed, 0px 6px 36px rgba(0, 7, 22, 0.1019607843));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.
|
|
10
|
+
.awsui_header_9ckv7_o6rfp_10:not(#\9) {
|
|
11
11
|
display: flex;
|
|
12
12
|
justify-items: center;
|
|
13
13
|
padding: var(--space-scaled-s-cu1hzn, 12px) calc(var(--space-container-horizontal-tlw03i, 20px) - var(--space-scaled-xs-6859qs, 8px));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.
|
|
16
|
+
.awsui_flexible_9ckv7_o6rfp_16:not(#\9) {
|
|
17
17
|
flex: 1 1 min-content;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
.
|
|
20
|
+
.awsui_handle_9ckv7_o6rfp_20:not(#\9) {
|
|
21
21
|
margin-top: calc(var(--space-scaled-xxs-95dhkm, 4px) + 1px);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.awsui_header-
|
|
24
|
+
.awsui_header-content_9ckv7_o6rfp_24:not(#\9) {
|
|
25
25
|
margin-left: var(--space-scaled-xxs-95dhkm, 4px);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.
|
|
29
|
-
margin-top: calc(var(--space-scaled-xxxs-
|
|
28
|
+
.awsui_settings_9ckv7_o6rfp_28:not(#\9) {
|
|
29
|
+
margin-top: calc(var(--space-scaled-xxxs-lo883m, 2px) + 1px);
|
|
30
30
|
margin-left: var(--space-static-xs-9adq92, 8px);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.
|
|
33
|
+
.awsui_fixed_9ckv7_o6rfp_33:not(#\9) {
|
|
34
34
|
flex: 0 0 auto;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
.
|
|
37
|
+
.awsui_resizer_9ckv7_o6rfp_37:not(#\9) {
|
|
38
38
|
position: absolute;
|
|
39
39
|
bottom: calc(var(--space-static-xs-9adq92, 8px) - var(--space-static-xxxs-k3qmdh, 2px));
|
|
40
40
|
right: calc(var(--space-static-xs-9adq92, 8px) - var(--space-static-xxxs-k3qmdh, 2px));
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"container-override": "awsui_container-
|
|
7
|
-
"active": "
|
|
8
|
-
"header": "
|
|
9
|
-
"flexible": "
|
|
10
|
-
"handle": "
|
|
11
|
-
"header-content": "awsui_header-
|
|
12
|
-
"settings": "
|
|
13
|
-
"fixed": "
|
|
14
|
-
"resizer": "
|
|
5
|
+
"root": "awsui_root_9ckv7_o6rfp_1",
|
|
6
|
+
"container-override": "awsui_container-override_9ckv7_o6rfp_6",
|
|
7
|
+
"active": "awsui_active_9ckv7_o6rfp_6",
|
|
8
|
+
"header": "awsui_header_9ckv7_o6rfp_10",
|
|
9
|
+
"flexible": "awsui_flexible_9ckv7_o6rfp_16",
|
|
10
|
+
"handle": "awsui_handle_9ckv7_o6rfp_20",
|
|
11
|
+
"header-content": "awsui_header-content_9ckv7_o6rfp_24",
|
|
12
|
+
"settings": "awsui_settings_9ckv7_o6rfp_28",
|
|
13
|
+
"fixed": "awsui_fixed_9ckv7_o6rfp_33",
|
|
14
|
+
"resizer": "awsui_resizer_9ckv7_o6rfp_37"
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import { Icon } from "@cloudscape-design/components";
|
|
4
5
|
import { forwardRef } from "react";
|
|
5
6
|
import Handle from "../handle";
|
|
6
|
-
import DragHandleIcon from "./icon";
|
|
7
7
|
import styles from "./styles.css.js";
|
|
8
8
|
function DragHandle({ ariaLabelledBy, ariaDescribedBy, onPointerDown, onKeyDown }, ref) {
|
|
9
|
-
return (_jsx(Handle, { ref: ref, className: styles.handle, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onPointerDown: onPointerDown, onKeyDown: onKeyDown, children: _jsx(
|
|
9
|
+
return (_jsx(Handle, { ref: ref, className: styles.handle, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onPointerDown: onPointerDown, onKeyDown: onKeyDown, children: _jsx(Icon, { name: "drag-indicator" }) }));
|
|
10
10
|
}
|
|
11
11
|
export default forwardRef(DragHandle);
|
package/internal/environment.js
CHANGED
|
@@ -7,8 +7,7 @@ import { createContext, forwardRef, useContext, useEffect, useImperativeHandle,
|
|
|
7
7
|
import { useDragSubscription, useDraggable, } from "../dnd-controller/controller";
|
|
8
8
|
import { Coordinates } from "../utils/coordinates";
|
|
9
9
|
import { getNormalizedElementRect } from "../utils/screen";
|
|
10
|
-
import {
|
|
11
|
-
import { useThrottledEventHandler } from "../utils/use-throttled-event-handler";
|
|
10
|
+
import { throttle } from "../utils/throttle";
|
|
12
11
|
import { getCollisionRect } from "./get-collision-rect";
|
|
13
12
|
import { getNextDroppable } from "./get-next-droppable";
|
|
14
13
|
import styles from "./styles.css.js";
|
|
@@ -35,18 +34,6 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
|
|
|
35
34
|
return getCollisionRect(operation, itemRef.current, coordinates, sizeOverride);
|
|
36
35
|
},
|
|
37
36
|
});
|
|
38
|
-
const onPointerMove = useThrottledEventHandler((event) => {
|
|
39
|
-
var _a, _b, _c, _d;
|
|
40
|
-
const coordinates = Coordinates.fromEvent(event);
|
|
41
|
-
draggableApi.updateTransition(new Coordinates({
|
|
42
|
-
x: Math.max(coordinates.x, (_b = (_a = pointerBoundariesRef.current) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : Number.NEGATIVE_INFINITY),
|
|
43
|
-
y: Math.max(coordinates.y, (_d = (_c = pointerBoundariesRef.current) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : Number.NEGATIVE_INFINITY),
|
|
44
|
-
}));
|
|
45
|
-
}, 10);
|
|
46
|
-
const onPointerUp = useStableEventHandler(() => {
|
|
47
|
-
onPointerMove.cancel();
|
|
48
|
-
draggableApi.submitTransition();
|
|
49
|
-
});
|
|
50
37
|
function updateTransition({ operation, interactionType, draggableItem, collisionRect, coordinates, dropTarget, }) {
|
|
51
38
|
if (item.id === draggableItem.id) {
|
|
52
39
|
const [width, height] = [collisionRect.right - collisionRect.left, collisionRect.bottom - collisionRect.top];
|
|
@@ -89,6 +76,18 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
|
|
|
89
76
|
const transitionInteractionType = (_a = transition === null || transition === void 0 ? void 0 : transition.interactionType) !== null && _a !== void 0 ? _a : null;
|
|
90
77
|
const transitionItemId = (_b = transition === null || transition === void 0 ? void 0 : transition.itemId) !== null && _b !== void 0 ? _b : null;
|
|
91
78
|
useEffect(() => {
|
|
79
|
+
const onPointerMove = throttle((event) => {
|
|
80
|
+
var _a, _b, _c, _d;
|
|
81
|
+
const coordinates = Coordinates.fromEvent(event);
|
|
82
|
+
draggableApi.updateTransition(new Coordinates({
|
|
83
|
+
x: Math.max(coordinates.x, (_b = (_a = pointerBoundariesRef.current) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : Number.NEGATIVE_INFINITY),
|
|
84
|
+
y: Math.max(coordinates.y, (_d = (_c = pointerBoundariesRef.current) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : Number.NEGATIVE_INFINITY),
|
|
85
|
+
}));
|
|
86
|
+
}, 10);
|
|
87
|
+
const onPointerUp = () => {
|
|
88
|
+
onPointerMove.cancel();
|
|
89
|
+
draggableApi.submitTransition();
|
|
90
|
+
};
|
|
92
91
|
if (transitionInteractionType === "pointer" && transitionItemId === item.id) {
|
|
93
92
|
window.addEventListener("pointermove", onPointerMove);
|
|
94
93
|
window.addEventListener("pointerup", onPointerUp);
|
|
@@ -97,7 +96,9 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
|
|
|
97
96
|
window.removeEventListener("pointermove", onPointerMove);
|
|
98
97
|
window.removeEventListener("pointerup", onPointerUp);
|
|
99
98
|
};
|
|
100
|
-
|
|
99
|
+
// draggableApi is not expected to change
|
|
100
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
+
}, [item.id, transitionInteractionType, transitionItemId]);
|
|
101
102
|
function onKeyboardTransitionToggle(operation) {
|
|
102
103
|
// The acquired item is a copy and does not have the transition state.
|
|
103
104
|
// However, pressing "Space" or "Enter" on the acquired item must submit the active transition.
|
package/internal/manifest.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import { Icon } from "@cloudscape-design/components";
|
|
2
5
|
import Handle from "../handle";
|
|
3
|
-
import { ResizeHandleIcon } from "./icon";
|
|
4
6
|
import styles from "./styles.css.js";
|
|
5
7
|
export default function ResizeHandle({ ariaLabelledBy, ariaDescribedBy, onPointerDown, onKeyDown }) {
|
|
6
|
-
return (_jsx(Handle, { className: styles.handle, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onPointerDown: onPointerDown, onKeyDown: onKeyDown, children: _jsx(
|
|
8
|
+
return (_jsx(Handle, { className: styles.handle, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onPointerDown: onPointerDown, onKeyDown: onKeyDown, children: _jsx(Icon, { name: "resize-area" }) }));
|
|
7
9
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
export function throttle(func, delay) {
|
|
4
|
+
let cancelled = false;
|
|
4
5
|
let pending = null;
|
|
5
6
|
let lastInvokeTime = null;
|
|
6
7
|
let timerId = null;
|
|
7
8
|
// Runs on every animation frame until timer stopped.
|
|
8
9
|
function pendingFunc() {
|
|
9
|
-
if (pending === null || lastInvokeTime === null) {
|
|
10
|
+
if (cancelled === true || pending === null || lastInvokeTime === null) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
const invokeTime = Date.now();
|
|
@@ -46,6 +47,7 @@ export function throttle(func, delay) {
|
|
|
46
47
|
pending = null;
|
|
47
48
|
lastInvokeTime = null;
|
|
48
49
|
timerId = null;
|
|
50
|
+
cancelled = true;
|
|
49
51
|
};
|
|
50
52
|
return throttled;
|
|
51
53
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import Icon from "@cloudscape-design/components/icon";
|
|
5
|
-
import { memo } from "react";
|
|
6
|
-
function DragHandleIcon() {
|
|
7
|
-
return _jsx(Icon, { svg: _jsx(SVG, {}) });
|
|
8
|
-
}
|
|
9
|
-
function SVG() {
|
|
10
|
-
return (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("circle", { cx: "5.5", cy: "2.5", r: "0.5", className: "filled", strokeWidth: "2" }), _jsx("circle", { cx: "5.5", cy: "13.5", r: "0.5", className: "filled", strokeWidth: "2" }), _jsx("circle", { cx: "5.5", cy: "8", r: "0.5", className: "filled", strokeWidth: "2" }), _jsx("circle", { cx: "10.5", cy: "2.5", r: "0.5", className: "filled", strokeWidth: "2" }), _jsx("circle", { cx: "10.5", cy: "13.5", r: "0.5", className: "filled", strokeWidth: "2" }), _jsx("circle", { cx: "10.5", cy: "8", r: "0.5", className: "filled", strokeWidth: "2" })] }));
|
|
11
|
-
}
|
|
12
|
-
export default memo(DragHandleIcon);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import Icon from "@cloudscape-design/components/icon";
|
|
5
|
-
import { memo } from "react";
|
|
6
|
-
export function ResizeHandleIcon() {
|
|
7
|
-
return _jsx(Icon, { svg: _jsx(SVG, {}) });
|
|
8
|
-
}
|
|
9
|
-
function SVG() {
|
|
10
|
-
return (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M9.5 14.5L14.5 9.5", strokeWidth: "2" }), _jsx("path", { d: "M4 14.5L14.5 4", strokeWidth: "2" })] }));
|
|
11
|
-
}
|
|
12
|
-
export default memo(ResizeHandleIcon);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useThrottledEventHandler<T extends (...args: any[]) => void>(callback: T, delay: number): import("./throttle").ThrottledFunction<T>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { useCallback } from "react";
|
|
4
|
-
import { throttle } from "./throttle";
|
|
5
|
-
import { useStableEventHandler } from "./use-stable-event-handler";
|
|
6
|
-
export function useThrottledEventHandler(callback, delay) {
|
|
7
|
-
const stableCallback = useStableEventHandler(callback);
|
|
8
|
-
// ESLint rule requires an inline function which we cannot provide here
|
|
9
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10
|
-
return useCallback(throttle(((...args) => stableCallback(...args)), delay), []);
|
|
11
|
-
}
|