@cloudscape-design/board-components 3.0.10 → 3.0.11
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.d.ts +1 -1
- package/board/internal.js +3 -2
- package/board-item/internal.d.ts +1 -1
- package/board-item/internal.js +3 -2
- package/internal/base-component/get-data-attributes.d.ts +1 -0
- package/internal/base-component/get-data-attributes.js +11 -0
- package/internal/environment.js +1 -1
- package/internal/item-container/index.d.ts +4 -2
- package/internal/item-container/index.js +3 -3
- package/internal/manifest.json +1 -1
- package/internal/utils/layout.js +1 -7
- package/items-palette/internal.d.ts +1 -1
- package/items-palette/internal.js +3 -2
- package/package.json +1 -1
package/board/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InternalBaseComponentProps } from "../internal/base-component/use-base-component";
|
|
3
3
|
import { BoardProps } from "./interfaces";
|
|
4
|
-
export declare function InternalBoard<D>({ items, renderItem, onItemsChange, empty, i18nStrings, __internalRootRef, }: BoardProps<D> & InternalBaseComponentProps): JSX.Element;
|
|
4
|
+
export declare function InternalBoard<D>({ items, renderItem, onItemsChange, empty, i18nStrings, __internalRootRef, ...rest }: BoardProps<D> & InternalBaseComponentProps): JSX.Element;
|
package/board/internal.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
|
+
import { getDataAttributes } from "../internal/base-component/get-data-attributes";
|
|
6
7
|
import { useContainerColumns } from "../internal/breakpoints";
|
|
7
8
|
import { TRANSITION_DURATION_MS } from "../internal/constants";
|
|
8
9
|
import { useDragSubscription } from "../internal/dnd-controller/controller";
|
|
@@ -21,7 +22,7 @@ import { selectTransitionRows, useTransition } from "./transition";
|
|
|
21
22
|
import { announcementToString } from "./utils/announcements";
|
|
22
23
|
import { createTransforms } from "./utils/create-transforms";
|
|
23
24
|
import { createItemsChangeEvent } from "./utils/events";
|
|
24
|
-
export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStrings, __internalRootRef, }) {
|
|
25
|
+
export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStrings, __internalRootRef, ...rest }) {
|
|
25
26
|
var _a, _b;
|
|
26
27
|
const containerAccessRef = useRef(null);
|
|
27
28
|
const [columns, containerQueryRef] = useContainerColumns();
|
|
@@ -156,7 +157,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
|
|
|
156
157
|
const announcement = transitionAnnouncement
|
|
157
158
|
? announcementToString(transitionAnnouncement, items, i18nStrings, columns)
|
|
158
159
|
: "";
|
|
159
|
-
return (_jsxs("div", { ref: __internalRootRef, children: [_jsx(ScreenReaderGridNavigation, { items: items, itemsLayout: itemsLayout, ariaLabel: i18nStrings.navigationAriaLabel, ariaDescription: i18nStrings.navigationAriaDescription, itemAriaLabel: i18nStrings.navigationItemAriaLabel, onActivateItem: focusItem }), _jsx("div", { ref: containerRef, className: clsx(styles.root, { [styles.empty]: rows === 0 }), children: rows > 0 ? (_jsx(Grid, { columns: columns, layout: [...placeholdersLayout.items, ...itemsLayout.items], children: (gridContext) => {
|
|
160
|
+
return (_jsxs("div", { ref: __internalRootRef, ...getDataAttributes(rest), children: [_jsx(ScreenReaderGridNavigation, { items: items, itemsLayout: itemsLayout, ariaLabel: i18nStrings.navigationAriaLabel, ariaDescription: i18nStrings.navigationAriaDescription, itemAriaLabel: i18nStrings.navigationItemAriaLabel, onActivateItem: focusItem }), _jsx("div", { ref: containerRef, className: clsx(styles.root, { [styles.empty]: rows === 0 }), children: rows > 0 ? (_jsx(Grid, { columns: columns, layout: [...placeholdersLayout.items, ...itemsLayout.items], children: (gridContext) => {
|
|
160
161
|
var _a;
|
|
161
162
|
const layoutShift = (_a = transition === null || transition === void 0 ? void 0 : transition.layoutShift) !== null && _a !== void 0 ? _a : removeTransition === null || removeTransition === void 0 ? void 0 : removeTransition.layoutShift;
|
|
162
163
|
const transforms = layoutShift ? createTransforms(itemsLayout, layoutShift.moves, gridContext) : {};
|
package/board-item/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InternalBaseComponentProps } from "../internal/base-component/use-base-component";
|
|
3
3
|
import type { BoardItemProps } from "./interfaces";
|
|
4
|
-
export declare function InternalBoardItem({ children, header, settings, disableContentPaddings, footer, i18nStrings, __internalRootRef, }: BoardItemProps & InternalBaseComponentProps): JSX.Element;
|
|
4
|
+
export declare function InternalBoardItem({ children, header, settings, disableContentPaddings, footer, i18nStrings, __internalRootRef, ...rest }: BoardItemProps & InternalBaseComponentProps): JSX.Element;
|
package/board-item/internal.js
CHANGED
|
@@ -4,17 +4,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import Container from "@cloudscape-design/components/container";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { useId } from "react";
|
|
7
|
+
import { getDataAttributes } from "../internal/base-component/get-data-attributes";
|
|
7
8
|
import DragHandle from "../internal/drag-handle";
|
|
8
9
|
import { useItemContext } from "../internal/item-container";
|
|
9
10
|
import ResizeHandle from "../internal/resize-handle";
|
|
10
11
|
import ScreenreaderOnly from "../internal/screenreader-only";
|
|
11
12
|
import WidgetContainerHeader from "./header";
|
|
12
13
|
import styles from "./styles.css.js";
|
|
13
|
-
export function InternalBoardItem({ children, header, settings, disableContentPaddings, footer, i18nStrings, __internalRootRef, }) {
|
|
14
|
+
export function InternalBoardItem({ children, header, settings, disableContentPaddings, footer, i18nStrings, __internalRootRef, ...rest }) {
|
|
14
15
|
const { dragHandle, resizeHandle, isActive } = useItemContext();
|
|
15
16
|
const dragHandleAriaLabelledBy = useId();
|
|
16
17
|
const dragHandleAriaDescribedBy = useId();
|
|
17
18
|
const resizeHandleAriaLabelledBy = useId();
|
|
18
19
|
const resizeHandleAriaDescribedBy = useId();
|
|
19
|
-
return (_jsxs("div", { ref: __internalRootRef, className: styles.root, children: [_jsx(Container, { fitHeight: true, disableHeaderPaddings: true, header: _jsx(WidgetContainerHeader, { handle: _jsx(DragHandle, { ref: dragHandle.ref, ariaLabelledBy: dragHandleAriaLabelledBy, ariaDescribedBy: dragHandleAriaDescribedBy, onPointerDown: dragHandle.onPointerDown, onKeyDown: dragHandle.onKeyDown }), settings: settings, children: header }), footer: footer, disableContentPaddings: disableContentPaddings, className: clsx(styles["container-override"], isActive && styles.active), children: children }), resizeHandle && (_jsx("div", { className: styles.resizer, children: _jsx(ResizeHandle, { ariaLabelledBy: resizeHandleAriaLabelledBy, ariaDescribedBy: resizeHandleAriaDescribedBy, onPointerDown: resizeHandle.onPointerDown, onKeyDown: resizeHandle.onKeyDown }) })), _jsx(ScreenreaderOnly, { id: dragHandleAriaLabelledBy, children: i18nStrings.dragHandleAriaLabel }), _jsx(ScreenreaderOnly, { id: dragHandleAriaDescribedBy, children: i18nStrings.dragHandleAriaDescription }), _jsx(ScreenreaderOnly, { id: resizeHandleAriaLabelledBy, children: i18nStrings.resizeHandleAriaLabel }), _jsx(ScreenreaderOnly, { id: resizeHandleAriaDescribedBy, children: i18nStrings.resizeHandleAriaDescription })] }));
|
|
20
|
+
return (_jsxs("div", { ref: __internalRootRef, className: styles.root, ...getDataAttributes(rest), children: [_jsx(Container, { fitHeight: true, disableHeaderPaddings: true, header: _jsx(WidgetContainerHeader, { handle: _jsx(DragHandle, { ref: dragHandle.ref, ariaLabelledBy: dragHandleAriaLabelledBy, ariaDescribedBy: dragHandleAriaDescribedBy, onPointerDown: dragHandle.onPointerDown, onKeyDown: dragHandle.onKeyDown }), settings: settings, children: header }), footer: footer, disableContentPaddings: disableContentPaddings, className: clsx(styles["container-override"], isActive && styles.active), children: children }), resizeHandle && (_jsx("div", { className: styles.resizer, children: _jsx(ResizeHandle, { ariaLabelledBy: resizeHandleAriaLabelledBy, ariaDescribedBy: resizeHandleAriaDescribedBy, onPointerDown: resizeHandle.onPointerDown, onKeyDown: resizeHandle.onKeyDown }) })), _jsx(ScreenreaderOnly, { id: dragHandleAriaLabelledBy, children: i18nStrings.dragHandleAriaLabel }), _jsx(ScreenreaderOnly, { id: dragHandleAriaDescribedBy, children: i18nStrings.dragHandleAriaDescription }), _jsx(ScreenreaderOnly, { id: resizeHandleAriaLabelledBy, children: i18nStrings.resizeHandleAriaLabel }), _jsx(ScreenreaderOnly, { id: resizeHandleAriaDescribedBy, children: i18nStrings.resizeHandleAriaDescription })] }));
|
|
20
21
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDataAttributes(props: Record<string, string>): Record<string, any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export function getDataAttributes(props) {
|
|
4
|
+
const result = {};
|
|
5
|
+
Object.keys(props).forEach((prop) => {
|
|
6
|
+
if (prop.startsWith("data-")) {
|
|
7
|
+
result[prop] = props[prop];
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
return result;
|
|
11
|
+
}
|
package/internal/environment.js
CHANGED
|
@@ -4,7 +4,7 @@ import { BoardItemDefinitionBase, Direction, Transform } from "../interfaces";
|
|
|
4
4
|
export interface ItemContainerRef {
|
|
5
5
|
focusDragHandle(): void;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface ItemContextType {
|
|
8
8
|
isActive: boolean;
|
|
9
9
|
dragHandle: {
|
|
10
10
|
ref: RefObject<HTMLButtonElement>;
|
|
@@ -16,7 +16,8 @@ export interface ItemContext {
|
|
|
16
16
|
onKeyDown(event: KeyboardEvent): void;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
export declare
|
|
19
|
+
export declare const ItemContext: import("react").Context<ItemContextType | null>;
|
|
20
|
+
export declare function useItemContext(): ItemContextType;
|
|
20
21
|
/**
|
|
21
22
|
* Defines item's parameters and its relation with the layout.
|
|
22
23
|
*
|
|
@@ -46,3 +47,4 @@ export interface ItemContainerProps {
|
|
|
46
47
|
children: ReactNode;
|
|
47
48
|
}
|
|
48
49
|
export declare const ItemContainer: import("react").ForwardRefExoticComponent<ItemContainerProps & import("react").RefAttributes<ItemContainerRef>>;
|
|
50
|
+
export {};
|
|
@@ -11,9 +11,9 @@ import { throttle } from "../utils/throttle";
|
|
|
11
11
|
import { getCollisionRect } from "./get-collision-rect";
|
|
12
12
|
import { getNextDroppable } from "./get-next-droppable";
|
|
13
13
|
import styles from "./styles.css.js";
|
|
14
|
-
const
|
|
14
|
+
export const ItemContext = createContext(null);
|
|
15
15
|
export function useItemContext() {
|
|
16
|
-
const ctx = useContext(
|
|
16
|
+
const ctx = useContext(ItemContext);
|
|
17
17
|
if (!ctx) {
|
|
18
18
|
throw new Error("Unable to find BoardItem context.");
|
|
19
19
|
}
|
|
@@ -253,7 +253,7 @@ function ItemContainerComponent({ item, placed, acquired, inTransition, transfor
|
|
|
253
253
|
useImperativeHandle(ref, () => ({
|
|
254
254
|
focusDragHandle: () => { var _a; return (_a = dragHandleRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
255
255
|
}));
|
|
256
|
-
return (_jsx("div", { ref: itemRef, className: clsx(styles.root, ...itemTransitionClassNames), style: itemTransitionStyle, "data-item-id": item.id, onBlur: onBlur, children: _jsx(
|
|
256
|
+
return (_jsx("div", { ref: itemRef, className: clsx(styles.root, ...itemTransitionClassNames), style: itemTransitionStyle, "data-item-id": item.id, onBlur: onBlur, children: _jsx(ItemContext.Provider, { value: {
|
|
257
257
|
isActive: (!!transition && !transition.isBorrowed) || !!acquired,
|
|
258
258
|
dragHandle: {
|
|
259
259
|
ref: dragHandleRef,
|
package/internal/manifest.json
CHANGED
package/internal/utils/layout.js
CHANGED
|
@@ -78,19 +78,13 @@ export function transformItems(sourceItems, gridLayout, resizeTarget) {
|
|
|
78
78
|
const items = [];
|
|
79
79
|
let changeFromIndex = sortedLayout.findIndex(({ id }, index) => id !== sourceItems[index].id || id === resizeTarget);
|
|
80
80
|
changeFromIndex = changeFromIndex !== -1 ? changeFromIndex : sortedLayout.length;
|
|
81
|
-
function setColumnOffset(item, layout, value) {
|
|
82
|
-
if (!item.columnOffset) {
|
|
83
|
-
item.columnOffset = {};
|
|
84
|
-
}
|
|
85
|
-
item.columnOffset[layout] = value;
|
|
86
|
-
}
|
|
87
81
|
for (let index = 0; index < sortedLayout.length; index++) {
|
|
88
82
|
const { id, x, width, height } = sortedLayout[index];
|
|
89
83
|
const item = { ...getItem(id) };
|
|
90
84
|
if (index >= changeFromIndex) {
|
|
91
85
|
item.columnOffset = undefined;
|
|
92
86
|
}
|
|
93
|
-
|
|
87
|
+
item.columnOffset = { ...item.columnOffset, [gridLayout.columns]: x };
|
|
94
88
|
if (item.id === resizeTarget) {
|
|
95
89
|
item.columnSpan = width;
|
|
96
90
|
item.rowSpan = height;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InternalBaseComponentProps } from "../internal/base-component/use-base-component";
|
|
3
3
|
import { ItemsPaletteProps } from "./interfaces";
|
|
4
|
-
export declare function InternalItemsPalette<D>({ items, renderItem, i18nStrings, __internalRootRef, }: ItemsPaletteProps<D> & InternalBaseComponentProps): JSX.Element;
|
|
4
|
+
export declare function InternalItemsPalette<D>({ items, renderItem, i18nStrings, __internalRootRef, ...rest }: ItemsPaletteProps<D> & InternalBaseComponentProps): JSX.Element;
|
|
@@ -3,12 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import SpaceBetween from "@cloudscape-design/components/space-between";
|
|
5
5
|
import { useRef, useState } from "react";
|
|
6
|
+
import { getDataAttributes } from "../internal/base-component/get-data-attributes";
|
|
6
7
|
import { useDragSubscription } from "../internal/dnd-controller/controller";
|
|
7
8
|
import { ItemContainer } from "../internal/item-container";
|
|
8
9
|
import LiveRegion from "../internal/live-region";
|
|
9
10
|
import { ScreenReaderGridNavigation } from "../internal/screenreader-grid-navigation";
|
|
10
11
|
import styles from "./styles.css.js";
|
|
11
|
-
export function InternalItemsPalette({ items, renderItem, i18nStrings, __internalRootRef, }) {
|
|
12
|
+
export function InternalItemsPalette({ items, renderItem, i18nStrings, __internalRootRef, ...rest }) {
|
|
12
13
|
const paletteRef = useRef(null);
|
|
13
14
|
const itemContainerRef = useRef({});
|
|
14
15
|
const [dropState, setDropState] = useState();
|
|
@@ -54,7 +55,7 @@ export function InternalItemsPalette({ items, renderItem, i18nStrings, __interna
|
|
|
54
55
|
columns: 1,
|
|
55
56
|
rows: items.length,
|
|
56
57
|
};
|
|
57
|
-
return (_jsxs("div", { ref: __internalRootRef, children: [_jsx(ScreenReaderGridNavigation, { items: items, itemsLayout: itemsLayout, ariaLabel: i18nStrings.navigationAriaLabel, ariaDescription: i18nStrings.navigationAriaDescription, itemAriaLabel: (item) => i18nStrings.navigationItemAriaLabel(item), onActivateItem: focusItem }), _jsx("div", { ref: paletteRef, className: styles.root, children: _jsx(SpaceBetween, { size: "l", children: items.map((item) => (_jsx(ItemContainer, { ref: (elem) => {
|
|
58
|
+
return (_jsxs("div", { ref: __internalRootRef, ...getDataAttributes(rest), children: [_jsx(ScreenReaderGridNavigation, { items: items, itemsLayout: itemsLayout, ariaLabel: i18nStrings.navigationAriaLabel, ariaDescription: i18nStrings.navigationAriaDescription, itemAriaLabel: (item) => i18nStrings.navigationItemAriaLabel(item), onActivateItem: focusItem }), _jsx("div", { ref: paletteRef, className: styles.root, children: _jsx(SpaceBetween, { size: "l", children: items.map((item) => (_jsx(ItemContainer, { ref: (elem) => {
|
|
58
59
|
if (elem) {
|
|
59
60
|
itemContainerRef.current[item.id] = elem;
|
|
60
61
|
}
|