@cloudscape-design/board-components 3.0.67 → 3.0.68
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/interfaces.d.ts +3 -5
- package/board/interfaces.js.map +1 -1
- package/board/internal.js +1 -5
- package/board/internal.js.map +1 -1
- package/internal/api-docs/components/board.js +1 -1
- package/internal/api-docs/components/items-palette.js +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/items-palette/interfaces.d.ts +3 -5
- package/items-palette/interfaces.js.map +1 -1
- package/items-palette/internal.js +1 -10
- package/items-palette/internal.js.map +1 -1
- package/package.json +1 -1
- package/internal/screenreader-grid-navigation/index.d.ts +0 -22
- package/internal/screenreader-grid-navigation/index.js +0 -43
- package/internal/screenreader-grid-navigation/index.js.map +0 -1
- package/internal/screenreader-grid-navigation/styles.css.js +0 -7
- package/internal/screenreader-grid-navigation/styles.scoped.css +0 -13
- package/internal/screenreader-grid-navigation/styles.selectors.js +0 -8
package/board/interfaces.d.ts
CHANGED
|
@@ -40,11 +40,6 @@ export interface BoardProps<D = DataFallbackType> {
|
|
|
40
40
|
* * `liveAnnouncementDndDiscarded(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate commit of DnD ("reorder", "resize" or "insert").
|
|
41
41
|
* * `liveAnnouncementDndCommitted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate discard of DnD ("reorder", "resize" or "insert").
|
|
42
42
|
* * `liveAnnouncementItemRemoved(BoardProps.OperationStateRemove<D>): string` - the function to create a live announcement string to indicate when item is removed.
|
|
43
|
-
*
|
|
44
|
-
* Navigation labels:
|
|
45
|
-
* * `navigationAriaLabel` (string) - the ARIA label for the accessible board navigation element.
|
|
46
|
-
* * `navigationAriaDescription` (string, optional) - the ARIA description for the accessible board navigation element.
|
|
47
|
-
* * `navigationItemAriaLabel(null | BoardProps.Item<D>): string` - the function to create the ARIA label for a navigation board item or an empty slot.
|
|
48
43
|
*/
|
|
49
44
|
i18nStrings: BoardProps.I18nStrings<D>;
|
|
50
45
|
/**
|
|
@@ -86,8 +81,11 @@ export declare namespace BoardProps {
|
|
|
86
81
|
liveAnnouncementDndCommitted: (operationType: DndOperationType) => string;
|
|
87
82
|
liveAnnouncementDndDiscarded: (operationType: DndOperationType) => string;
|
|
88
83
|
liveAnnouncementItemRemoved: (operation: ItemRemovedState<D>) => string;
|
|
84
|
+
/** @deprecated Has no effect. */
|
|
89
85
|
navigationAriaLabel: string;
|
|
86
|
+
/** @deprecated Has no effect. */
|
|
90
87
|
navigationAriaDescription?: string;
|
|
88
|
+
/** @deprecated Has no effect. */
|
|
91
89
|
navigationItemAriaLabel: (item: null | BoardProps.Item<D>) => string;
|
|
92
90
|
}
|
|
93
91
|
type DndOperationType = "reorder" | "resize" | "insert";
|
package/board/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/board/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ReactNode } from \"react\";\nimport { InteractionType, Operation } from \"../internal/dnd-controller/controller\";\nimport {\n BoardItemDefinition,\n BoardItemDefinitionBase,\n DataFallbackType,\n Direction,\n GridLayout,\n GridLayoutItem,\n ItemId,\n Rect,\n} from \"../internal/interfaces\";\nimport { LayoutEngine } from \"../internal/layout-engine/engine\";\nimport { LayoutShift } from \"../internal/layout-engine/interfaces\";\nimport { NonCancelableEventHandler } from \"../internal/utils/events\";\nimport { Position } from \"../internal/utils/position\";\n\n/*\n Note:\n The component does not provide handling of items state (loading, error, loaded).\n It is the responsibility of the client to control it and provide the necessary\n ARIA-live announcements.\n*/\n\nexport interface BoardProps<D = DataFallbackType> {\n /**\n * Specifies the items displayed in the board. Each item includes its position on the board and\n * optional data. The content of an item is controlled by the `renderItem` property.\n *\n * The BoardProps.Item includes:\n * * `id` (string) - the unique item identifier. The IDs of any two items in a page must be different.\n * * `definition.minRowSpan` (number, optional) - the minimal number of rows the item is allowed to take. It can't be less than two. Defaults to two.\n * * `definition.minColumnSpan` (number, optional) - the minimal number of columns the item is allowed to take. It can't be less than one. Defaults to one.\n * * `definition.defaultRowSpan` (number, optional) - the number or rows the item will take when inserted to the board. It can't be less than `definition.minRowSpan`.\n * * `definition.defaultColumnSpan` (number, optional) - the number or columns the item will take when inserted in the board. It can't be less than `definition.minColumnSpan`.\n * * `columnOffset` (mapping, optional) - the item's offset from the first column (per layout) starting from zero. The value is updated by `onItemsChange` after an update is committed.\n * * `rowSpan` (number, optional) - the item's vertical size starting from two. The value is updated by `onItemsChange` after an update is committed.\n * * `columnSpan` (number, optional) - the item's horizontal size starting from one. The value is updated by `onItemsChange` after an update is committed.\n * * `data` (D) - optional item data which can include the specific configurations of an item, such as its title.\n */\n items: ReadonlyArray<BoardProps.Item<D>>;\n\n /**\n * Specifies a function to render content for board items. The return value must include board item component.\n *\n * The function takes the item and its associated actions (BoardProps.ItemActions) that include:\n * * `removeItem(): void` - the callback to issue the item's removal. Once issued, the `onItemsChange` will fire to update the state.\n */\n renderItem: (item: BoardProps.Item<D>, actions: BoardProps.ItemActions) => JSX.Element;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n *\n * Live announcements:\n * * `liveAnnouncementDndStarted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate start of DnD (\"reorder\", \"resize\" or \"insert\").\n * * `liveAnnouncementDndItemReordered(BoardProps.DndReorderState<D>): string` - the function to create a live announcement string to indicate when DnD reorder is performed.\n * * `liveAnnouncementDndItemResized(BoardProps.DndResizeState<D>): string` - the function to create a live announcement string to indicate when DnD resize is performed.\n * * `liveAnnouncementDndItemInserted(BoardProps.DndInsertState<D>): string` - the function to create a live announcement string to indicate when DnD insert is performed.\n * * `liveAnnouncementDndDiscarded(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate commit of DnD (\"reorder\", \"resize\" or \"insert\").\n * * `liveAnnouncementDndCommitted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate discard of DnD (\"reorder\", \"resize\" or \"insert\").\n * * `liveAnnouncementItemRemoved(BoardProps.OperationStateRemove<D>): string` - the function to create a live announcement string to indicate when item is removed.\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/board/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ReactNode } from \"react\";\nimport { InteractionType, Operation } from \"../internal/dnd-controller/controller\";\nimport {\n BoardItemDefinition,\n BoardItemDefinitionBase,\n DataFallbackType,\n Direction,\n GridLayout,\n GridLayoutItem,\n ItemId,\n Rect,\n} from \"../internal/interfaces\";\nimport { LayoutEngine } from \"../internal/layout-engine/engine\";\nimport { LayoutShift } from \"../internal/layout-engine/interfaces\";\nimport { NonCancelableEventHandler } from \"../internal/utils/events\";\nimport { Position } from \"../internal/utils/position\";\n\n/*\n Note:\n The component does not provide handling of items state (loading, error, loaded).\n It is the responsibility of the client to control it and provide the necessary\n ARIA-live announcements.\n*/\n\nexport interface BoardProps<D = DataFallbackType> {\n /**\n * Specifies the items displayed in the board. Each item includes its position on the board and\n * optional data. The content of an item is controlled by the `renderItem` property.\n *\n * The BoardProps.Item includes:\n * * `id` (string) - the unique item identifier. The IDs of any two items in a page must be different.\n * * `definition.minRowSpan` (number, optional) - the minimal number of rows the item is allowed to take. It can't be less than two. Defaults to two.\n * * `definition.minColumnSpan` (number, optional) - the minimal number of columns the item is allowed to take. It can't be less than one. Defaults to one.\n * * `definition.defaultRowSpan` (number, optional) - the number or rows the item will take when inserted to the board. It can't be less than `definition.minRowSpan`.\n * * `definition.defaultColumnSpan` (number, optional) - the number or columns the item will take when inserted in the board. It can't be less than `definition.minColumnSpan`.\n * * `columnOffset` (mapping, optional) - the item's offset from the first column (per layout) starting from zero. The value is updated by `onItemsChange` after an update is committed.\n * * `rowSpan` (number, optional) - the item's vertical size starting from two. The value is updated by `onItemsChange` after an update is committed.\n * * `columnSpan` (number, optional) - the item's horizontal size starting from one. The value is updated by `onItemsChange` after an update is committed.\n * * `data` (D) - optional item data which can include the specific configurations of an item, such as its title.\n */\n items: ReadonlyArray<BoardProps.Item<D>>;\n\n /**\n * Specifies a function to render content for board items. The return value must include board item component.\n *\n * The function takes the item and its associated actions (BoardProps.ItemActions) that include:\n * * `removeItem(): void` - the callback to issue the item's removal. Once issued, the `onItemsChange` will fire to update the state.\n */\n renderItem: (item: BoardProps.Item<D>, actions: BoardProps.ItemActions) => JSX.Element;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n *\n * Live announcements:\n * * `liveAnnouncementDndStarted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate start of DnD (\"reorder\", \"resize\" or \"insert\").\n * * `liveAnnouncementDndItemReordered(BoardProps.DndReorderState<D>): string` - the function to create a live announcement string to indicate when DnD reorder is performed.\n * * `liveAnnouncementDndItemResized(BoardProps.DndResizeState<D>): string` - the function to create a live announcement string to indicate when DnD resize is performed.\n * * `liveAnnouncementDndItemInserted(BoardProps.DndInsertState<D>): string` - the function to create a live announcement string to indicate when DnD insert is performed.\n * * `liveAnnouncementDndDiscarded(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate commit of DnD (\"reorder\", \"resize\" or \"insert\").\n * * `liveAnnouncementDndCommitted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate discard of DnD (\"reorder\", \"resize\" or \"insert\").\n * * `liveAnnouncementItemRemoved(BoardProps.OperationStateRemove<D>): string` - the function to create a live announcement string to indicate when item is removed.\n */\n i18nStrings: BoardProps.I18nStrings<D>;\n\n /**\n * Called when a user modifies the size or position of board items.\n *\n * The change detail has the following properties:\n *\n * * `items`: (readonly Item<D>[]) - the updated items array.\n * * `addedItem`: (Item<D>, optional) - the item that was added as part of the update, if applicable.\n * * `removedItem`: (Item<D>, optional) - the item that was removed as part of the update, if applicable.\n * * `resizedItem`: (Item<D>, optional) - the item that was resized as part of the update, if applicable.\n * * `movedItem`: (Item<D>, optional) - the item that was moved as part of the update, if applicable.\n */\n onItemsChange: NonCancelableEventHandler<BoardProps.ItemsChangeDetail<D>>;\n\n /**\n * Rendered when the `items` array is empty.\n *\n * When items are loading the slot can be used to render the loading indicator.\n */\n empty: ReactNode;\n}\n\nexport namespace BoardProps {\n export type Item<D = DataFallbackType> = BoardItemDefinition<D>;\n\n export interface ItemActions {\n removeItem(): void;\n }\n\n export interface ItemsChangeDetail<D = DataFallbackType> {\n items: ReadonlyArray<Item<D>>;\n movedItem?: Item<D>;\n resizedItem?: Item<D>;\n addedItem?: Item<D>;\n removedItem?: Item<D>;\n }\n\n export interface I18nStrings<D> {\n liveAnnouncementDndStarted: (operationType: DndOperationType) => string;\n liveAnnouncementDndItemReordered: (operation: DndReorderState<D>) => string;\n liveAnnouncementDndItemResized: (operation: DndResizeState<D>) => string;\n liveAnnouncementDndItemInserted: (operation: DndInsertState<D>) => string;\n liveAnnouncementDndCommitted: (operationType: DndOperationType) => string;\n liveAnnouncementDndDiscarded: (operationType: DndOperationType) => string;\n liveAnnouncementItemRemoved: (operation: ItemRemovedState<D>) => string;\n\n /** @deprecated Has no effect. */\n navigationAriaLabel: string;\n /** @deprecated Has no effect. */\n navigationAriaDescription?: string;\n /** @deprecated Has no effect. */\n navigationItemAriaLabel: (item: null | BoardProps.Item<D>) => string;\n }\n\n export type DndOperationType = \"reorder\" | \"resize\" | \"insert\";\n\n export interface ItemPlacement {\n x: number;\n y: number;\n width: number;\n height: number;\n }\n\n export interface DndReorderState<D> {\n item: Item<D>;\n placement: ItemPlacement;\n direction: \"horizontal\" | \"vertical\";\n conflicts: readonly Item<D>[];\n disturbed: readonly Item<D>[];\n }\n\n export interface DndInsertState<D> {\n item: Item<D>;\n placement: ItemPlacement;\n conflicts: readonly Item<D>[];\n disturbed: readonly Item<D>[];\n }\n\n export interface DndResizeState<D> {\n item: Item<D>;\n placement: ItemPlacement;\n direction: \"horizontal\" | \"vertical\";\n isMinimalColumnsReached: boolean;\n isMinimalRowsReached: boolean;\n conflicts: readonly Item<D>[];\n disturbed: readonly Item<D>[];\n }\n\n export interface ItemRemovedState<D> {\n item: Item<D>;\n disturbed: readonly Item<D>[];\n }\n}\n\nexport interface Transition<D> {\n operation: Operation;\n interactionType: InteractionType;\n itemsLayout: GridLayout;\n layoutEngine: LayoutEngine;\n insertionDirection: null | Direction;\n draggableItem: BoardItemDefinitionBase<D>;\n draggableRect: Rect;\n acquiredItem: null | BoardItemDefinitionBase<D>;\n collisionIds: Set<ItemId>;\n layoutShift: null | LayoutShift;\n path: readonly Position[];\n acquiredItemElement?: ReactNode;\n}\n\nexport interface RemoveTransition<D> {\n items: readonly BoardProps.Item<D>[];\n removedItem: BoardItemDefinitionBase<D>;\n layoutShift: LayoutShift;\n}\n\nexport type TransitionAnnouncement =\n | DndStartedAnnouncement\n | DndActionAnnouncement\n | DndCommittedAnnouncement\n | DndDiscardedAnnouncement\n | ItemRemovedAnnouncement;\n\nexport interface DndStartedAnnouncement {\n type: \"dnd-started\";\n item: BoardItemDefinitionBase<unknown>;\n operation: Operation;\n}\nexport interface DndActionAnnouncement {\n type: \"dnd-action\";\n item: BoardItemDefinitionBase<unknown>;\n operation: Operation;\n placement: Omit<GridLayoutItem, \"id\">;\n direction: null | Direction;\n conflicts: Set<ItemId>;\n disturbed: Set<ItemId>;\n}\nexport interface DndCommittedAnnouncement {\n type: \"dnd-committed\";\n item: BoardItemDefinitionBase<unknown>;\n operation: Operation;\n}\nexport interface DndDiscardedAnnouncement {\n type: \"dnd-discarded\";\n item: BoardItemDefinitionBase<unknown>;\n operation: Operation;\n}\nexport interface ItemRemovedAnnouncement {\n type: \"item-removed\";\n item: BoardItemDefinitionBase<unknown>;\n disturbed: Set<ItemId>;\n}\n"]}
|
package/board/internal.js
CHANGED
|
@@ -12,7 +12,6 @@ import { useGlobalDragStateStyles } from "../internal/global-drag-state-styles";
|
|
|
12
12
|
import Grid from "../internal/grid";
|
|
13
13
|
import { ItemContainer } from "../internal/item-container";
|
|
14
14
|
import LiveRegion from "../internal/live-region";
|
|
15
|
-
import { ScreenReaderGridNavigation } from "../internal/screenreader-grid-navigation";
|
|
16
15
|
import { createPlaceholdersLayout, getDefaultColumnSpan, getDefaultRowSpan, getMinColumnSpan, getMinRowSpan, interpretItems, } from "../internal/utils/layout";
|
|
17
16
|
import { Position } from "../internal/utils/position";
|
|
18
17
|
import { useAutoScroll } from "../internal/utils/use-auto-scroll";
|
|
@@ -154,9 +153,6 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
|
|
|
154
153
|
const removeItemAction = (removedItem) => {
|
|
155
154
|
dispatch({ type: "init-remove", items, itemsLayout, removedItem });
|
|
156
155
|
};
|
|
157
|
-
function focusItem(itemId) {
|
|
158
|
-
itemContainerRef.current[itemId].focusDragHandle();
|
|
159
|
-
}
|
|
160
156
|
function onItemMove(direction) {
|
|
161
157
|
if (transition) {
|
|
162
158
|
dispatch({ type: "update-with-keyboard", direction });
|
|
@@ -166,7 +162,7 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
|
|
|
166
162
|
const announcement = transitionAnnouncement
|
|
167
163
|
? announcementToString(transitionAnnouncement, items, i18nStrings, itemsLayout.columns)
|
|
168
164
|
: "";
|
|
169
|
-
return (_jsxs("div", { ref: __internalRootRef, ...getDataAttributes(rest), children: [_jsx(
|
|
165
|
+
return (_jsxs("div", { ref: __internalRootRef, ...getDataAttributes(rest), children: [_jsx("div", { ref: containerRef, className: clsx(styles.root, { [styles.empty]: rows === 0 }), children: rows > 0 ? (_jsx(Grid, { isRtl: isRtl, columns: itemsLayout.columns, layout: [...placeholdersLayout.items, ...itemsLayout.items], children: (gridContext) => {
|
|
170
166
|
var _a;
|
|
171
167
|
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;
|
|
172
168
|
const transforms = layoutShift ? createTransforms(itemsLayout, layoutShift.moves, gridContext) : {};
|
package/board/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/board/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAoB,MAAM,4BAA4B,CAAC;AAC7E,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE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AAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;oCACrD,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;iCACrD,CAAC,EACF,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,KAAK,YAEX,IAAI,CAAC,EAAE,MAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,EAAE,CAAA,IAAI,mBAAmB;oCAClD,CAAC,CAAC,GAAG,EAAE,CAAC,mBAAmB;oCAC3B,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,IA1BnE,IAAI,CAAC,EAAE,CA2BE,CACjB,CAAC;wBACJ,CAAC,CAAC,CAAC;wBAEH,OAAO,QAAQ,CAAC;oBAClB,CAAC,GACI,CACR,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GACG,EAEN,KAAC,UAAU,cAAE,YAAY,GAAc,IACnC,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getIsRtl } from \"@cloudscape-design/component-toolkit/internal\";\nimport clsx from \"clsx\";\nimport { ReactNode, useEffect, useRef } from \"react\";\nimport { getDataAttributes } from \"../internal/base-component/get-data-attributes\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { useContainerColumns } from \"../internal/breakpoints\";\nimport { TRANSITION_DURATION_MS } from \"../internal/constants\";\nimport { useDragSubscription } from \"../internal/dnd-controller/controller\";\nimport { useGlobalDragStateStyles } from \"../internal/global-drag-state-styles\";\nimport Grid from \"../internal/grid\";\nimport { BoardItemDefinition, BoardItemDefinitionBase, Direction, ItemId, Rect } from \"../internal/interfaces\";\nimport { ItemContainer, ItemContainerRef } from \"../internal/item-container\";\nimport LiveRegion from \"../internal/live-region\";\nimport { ScreenReaderGridNavigation } from \"../internal/screenreader-grid-navigation\";\nimport {\n createPlaceholdersLayout,\n getDefaultColumnSpan,\n getDefaultRowSpan,\n getMinColumnSpan,\n getMinRowSpan,\n interpretItems,\n} from \"../internal/utils/layout\";\nimport { Position } from \"../internal/utils/position\";\nimport { useAutoScroll } from \"../internal/utils/use-auto-scroll\";\nimport { useMergeRefs } from \"../internal/utils/use-merge-refs\";\n\nimport { BoardProps } from \"./interfaces\";\nimport Placeholder from \"./placeholder\";\nimport styles from \"./styles.css.js\";\nimport { selectTransitionRows, useTransition } from \"./transition\";\nimport { announcementToString } from \"./utils/announcements\";\nimport { createTransforms } from \"./utils/create-transforms\";\nimport { createItemsChangeEvent } from \"./utils/events\";\n\nexport function InternalBoard<D>({\n items,\n renderItem,\n onItemsChange,\n empty,\n i18nStrings,\n __internalRootRef,\n ...rest\n}: BoardProps<D> & InternalBaseComponentProps) {\n const containerAccessRef = useRef<HTMLDivElement>(null);\n const [currentColumns, containerQueryRef] = useContainerColumns();\n const containerRef = useMergeRefs(containerAccessRef, containerQueryRef);\n const itemContainerRef = useRef<{ [id: ItemId]: ItemContainerRef }>({});\n\n const isRtl = () => getIsRtl(containerAccessRef.current);\n\n useGlobalDragStateStyles();\n\n const autoScrollHandlers = useAutoScroll();\n\n const [transitionState, dispatch] = useTransition<D>({ isRtl });\n const transition = transitionState.transition;\n const removeTransition = transitionState.removeTransition;\n const transitionAnnouncement = transitionState.announcement;\n const acquiredItem = transition?.acquiredItem ?? null;\n const acquiredItemElement = transition?.acquiredItemElement;\n\n // Using cached columns from transition to ensure no unexpected changes in the process.\n const columns = transition ? transition.itemsLayout.columns : currentColumns;\n\n // Use previous items while remove transition is in progress.\n items = removeTransition?.items ?? items;\n\n // The acquired item is the one being inserting at the moment but not submitted yet.\n // It needs to be included to the layout to be a part of layout shifts and rendering.\n items = acquiredItem ? [...items, acquiredItem] : items;\n const itemsLayout = interpretItems(items, columns);\n\n const layoutItemById = new Map(itemsLayout.items.map((item) => [item.id, item]));\n const layoutItemIndexById = new Map(itemsLayout.items.map((item, index) => [item.id, index]));\n\n // Items and layout items must maintain the same order visually, in the DOM and in the data\n // to ensure on-change events and tab order work as expected.\n items = [...items].sort((a, b) => (layoutItemIndexById.get(a.id) ?? -1) - (layoutItemIndexById.get(b.id) ?? -1));\n\n // When an item gets acquired or removed the focus needs to be dispatched on the next render.\n const focusNextRenderIndexRef = useRef<null | number>(null);\n const focusNextRenderIdRef = useRef<null | ItemId>(null);\n useEffect(() => {\n const focusTarget = focusNextRenderIdRef.current ?? items[focusNextRenderIndexRef.current ?? -1]?.id;\n if (focusTarget) {\n itemContainerRef.current[focusTarget].focusDragHandle();\n }\n focusNextRenderIndexRef.current = null;\n focusNextRenderIdRef.current = null;\n });\n\n // Submit scheduled removal after a delay to let animations play.\n useEffect(() => {\n if (!removeTransition) {\n return;\n }\n\n const timeoutId = setTimeout(() => {\n dispatch({ type: \"submit\" });\n\n const removedItemIndex = items.findIndex((it) => it.id === removeTransition.removedItem.id);\n const nextIndexToFocus = removedItemIndex !== items.length - 1 ? removedItemIndex : items.length - 2;\n focusNextRenderIndexRef.current = nextIndexToFocus;\n onItemsChange(createItemsChangeEvent(items, removeTransition.layoutShift));\n }, TRANSITION_DURATION_MS);\n\n return () => clearTimeout(timeoutId);\n }, [removeTransition, items, onItemsChange]);\n\n const rows = selectTransitionRows(transitionState) || itemsLayout.rows;\n const placeholdersLayout = createPlaceholdersLayout(rows, itemsLayout.columns);\n\n function isElementOverBoard(rect: Rect) {\n const board = containerAccessRef.current!;\n const boardContains = (target: null | Element) => board === target || board.contains(target);\n const left = !isRtl() ? rect.left : document.documentElement.clientWidth - rect.left;\n const right = !isRtl() ? rect.right : document.documentElement.clientWidth - rect.right;\n const { top, bottom } = rect;\n return (\n boardContains(document.elementFromPoint(left, top)) ||\n boardContains(document.elementFromPoint(right, top)) ||\n boardContains(document.elementFromPoint(right, bottom)) ||\n boardContains(document.elementFromPoint(left, bottom))\n );\n }\n\n useDragSubscription(\"start\", ({ operation, interactionType, draggableItem, collisionRect, collisionIds }) => {\n dispatch({\n type: \"init\",\n operation,\n interactionType,\n itemsLayout,\n // TODO: resolve any\n // The code only works assuming the board can take any draggable.\n // If draggables can be of different types a check of some sort is required here.\n draggableItem: draggableItem as BoardItemDefinitionBase<any>,\n draggableRect: collisionRect,\n collisionIds: interactionType === \"pointer\" && isElementOverBoard(collisionRect) ? collisionIds : [],\n });\n\n autoScrollHandlers.addPointerEventHandlers();\n });\n\n useDragSubscription(\"update\", ({ interactionType, collisionIds, positionOffset, collisionRect }) => {\n dispatch({\n type: \"update-with-pointer\",\n collisionIds: interactionType === \"pointer\" && isElementOverBoard(collisionRect) ? collisionIds : [],\n positionOffset,\n draggableRect: collisionRect,\n });\n });\n\n useDragSubscription(\"submit\", () => {\n dispatch({ type: \"submit\" });\n\n autoScrollHandlers.removePointerEventHandlers();\n\n if (!transition) {\n throw new Error(\"Invariant violation: no transition.\");\n }\n if (\n !transition.layoutShift ||\n transition.layoutShift.conflicts.length > 0 ||\n transition.layoutShift.moves.length === 0\n ) {\n return null;\n }\n\n // Commit new layout for insert case.\n if (transition.operation === \"insert\") {\n onItemsChange(createItemsChangeEvent([...items, transition.draggableItem], transition.layoutShift));\n }\n // Commit new layout for reorder/resize case.\n else {\n onItemsChange(createItemsChangeEvent(items, transition.layoutShift));\n }\n });\n\n useDragSubscription(\"discard\", () => {\n dispatch({ type: \"discard\" });\n\n autoScrollHandlers.removePointerEventHandlers();\n });\n\n useDragSubscription(\"acquire\", ({ droppableId, draggableItem, renderAcquiredItem }) => {\n const placeholder = placeholdersLayout.items.find((it) => it.id === droppableId);\n\n // If missing then it does not belong to this board.\n if (!placeholder) {\n return;\n }\n\n dispatch({\n type: \"acquire-item\",\n position: new Position({ x: placeholder.x, y: placeholder.y }),\n layoutElement: containerAccessRef.current!,\n acquiredItemElement: renderAcquiredItem(),\n });\n\n focusNextRenderIdRef.current = draggableItem.id;\n });\n\n const removeItemAction = (removedItem: BoardItemDefinition<D>) => {\n dispatch({ type: \"init-remove\", items, itemsLayout, removedItem });\n };\n\n function focusItem(itemId: ItemId) {\n itemContainerRef.current[itemId].focusDragHandle();\n }\n\n function onItemMove(direction: Direction) {\n if (transition) {\n dispatch({ type: \"update-with-keyboard\", direction });\n autoScrollHandlers.scheduleActiveElementScrollIntoView(TRANSITION_DURATION_MS);\n }\n }\n\n const announcement = transitionAnnouncement\n ? announcementToString(transitionAnnouncement, items, i18nStrings, itemsLayout.columns)\n : \"\";\n\n return (\n <div ref={__internalRootRef} {...getDataAttributes(rest)}>\n <ScreenReaderGridNavigation\n items={items}\n itemsLayout={itemsLayout}\n ariaLabel={i18nStrings.navigationAriaLabel}\n ariaDescription={i18nStrings.navigationAriaDescription}\n itemAriaLabel={i18nStrings.navigationItemAriaLabel}\n onActivateItem={focusItem}\n />\n\n <div ref={containerRef} className={clsx(styles.root, { [styles.empty]: rows === 0 })}>\n {rows > 0 ? (\n <Grid\n isRtl={isRtl}\n columns={itemsLayout.columns}\n layout={[...placeholdersLayout.items, ...itemsLayout.items]}\n >\n {(gridContext) => {\n const layoutShift = transition?.layoutShift ?? removeTransition?.layoutShift;\n const transforms = layoutShift ? createTransforms(itemsLayout, layoutShift.moves, gridContext) : {};\n\n // Exclude drag target from transforms.\n if (transition && transition.interactionType === \"pointer\") {\n delete transforms[transition.draggableItem.id];\n }\n\n const children: ReactNode[] = [];\n\n /* Placeholders are rendered even when there is no transition to support the first collisions check. */\n placeholdersLayout.items.forEach((placeholder) =>\n children.push(\n <Placeholder\n key={placeholder.id}\n id={placeholder.id}\n state={transition ? (transition.collisionIds?.has(placeholder.id) ? \"hover\" : \"active\") : \"default\"}\n gridContext={gridContext}\n columns={itemsLayout.columns}\n />,\n ),\n );\n\n items.forEach((item) => {\n const layoutItem = layoutItemById.get(item.id);\n const isResizing = transition?.operation === \"resize\" && transition?.draggableItem.id === item.id;\n\n const itemSize = layoutItem ?? {\n width: getDefaultColumnSpan(item, itemsLayout.columns),\n height: getDefaultRowSpan(item),\n };\n\n const itemMaxSize =\n isResizing && layoutItem ? { width: itemsLayout.columns - layoutItem.x, height: 999 } : itemSize;\n\n children.push(\n <ItemContainer\n key={item.id}\n ref={(elem) => {\n if (elem) {\n itemContainerRef.current[item.id] = elem;\n } else {\n delete itemContainerRef.current[item.id];\n }\n }}\n item={item}\n transform={transforms[item.id]}\n inTransition={!!transition || !!removeTransition}\n placed={item.id !== acquiredItem?.id}\n acquired={item.id === acquiredItem?.id}\n getItemSize={() => ({\n width: gridContext.getWidth(itemSize.width),\n minWidth: gridContext.getWidth(getMinColumnSpan(item, itemsLayout.columns)),\n maxWidth: gridContext.getWidth(itemMaxSize.width),\n height: gridContext.getHeight(itemSize.height),\n minHeight: gridContext.getHeight(getMinRowSpan(item)),\n maxHeight: gridContext.getHeight(itemMaxSize.height),\n })}\n onKeyMove={onItemMove}\n isRtl={isRtl}\n >\n {item.id === acquiredItem?.id && acquiredItemElement\n ? () => acquiredItemElement\n : () => renderItem(item, { removeItem: () => removeItemAction(item) })}\n </ItemContainer>,\n );\n });\n\n return children;\n }}\n </Grid>\n ) : (\n empty\n )}\n </div>\n\n <LiveRegion>{announcement}</LiveRegion>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/board/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;A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AC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;oCAC3E,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC;oCACjD,MAAM,EAAE,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;oCAC9C,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;oCACrD,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;iCACrD,CAAC,EACF,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,KAAK,YAEX,IAAI,CAAC,EAAE,MAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,EAAE,CAAA,IAAI,mBAAmB;oCAClD,CAAC,CAAC,GAAG,EAAE,CAAC,mBAAmB;oCAC3B,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,IA1BnE,IAAI,CAAC,EAAE,CA2BE,CACjB,CAAC;wBACJ,CAAC,CAAC,CAAC;wBAEH,OAAO,QAAQ,CAAC;oBAClB,CAAC,GACI,CACR,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GACG,EAEN,KAAC,UAAU,cAAE,YAAY,GAAc,IACnC,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getIsRtl } from \"@cloudscape-design/component-toolkit/internal\";\nimport clsx from \"clsx\";\nimport { ReactNode, useEffect, useRef } from \"react\";\nimport { getDataAttributes } from \"../internal/base-component/get-data-attributes\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { useContainerColumns } from \"../internal/breakpoints\";\nimport { TRANSITION_DURATION_MS } from \"../internal/constants\";\nimport { useDragSubscription } from \"../internal/dnd-controller/controller\";\nimport { useGlobalDragStateStyles } from \"../internal/global-drag-state-styles\";\nimport Grid from \"../internal/grid\";\nimport { BoardItemDefinition, BoardItemDefinitionBase, Direction, ItemId, Rect } from \"../internal/interfaces\";\nimport { ItemContainer, ItemContainerRef } from \"../internal/item-container\";\nimport LiveRegion from \"../internal/live-region\";\nimport {\n createPlaceholdersLayout,\n getDefaultColumnSpan,\n getDefaultRowSpan,\n getMinColumnSpan,\n getMinRowSpan,\n interpretItems,\n} from \"../internal/utils/layout\";\nimport { Position } from \"../internal/utils/position\";\nimport { useAutoScroll } from \"../internal/utils/use-auto-scroll\";\nimport { useMergeRefs } from \"../internal/utils/use-merge-refs\";\n\nimport { BoardProps } from \"./interfaces\";\nimport Placeholder from \"./placeholder\";\nimport styles from \"./styles.css.js\";\nimport { selectTransitionRows, useTransition } from \"./transition\";\nimport { announcementToString } from \"./utils/announcements\";\nimport { createTransforms } from \"./utils/create-transforms\";\nimport { createItemsChangeEvent } from \"./utils/events\";\n\nexport function InternalBoard<D>({\n items,\n renderItem,\n onItemsChange,\n empty,\n i18nStrings,\n __internalRootRef,\n ...rest\n}: BoardProps<D> & InternalBaseComponentProps) {\n const containerAccessRef = useRef<HTMLDivElement>(null);\n const [currentColumns, containerQueryRef] = useContainerColumns();\n const containerRef = useMergeRefs(containerAccessRef, containerQueryRef);\n const itemContainerRef = useRef<{ [id: ItemId]: ItemContainerRef }>({});\n\n const isRtl = () => getIsRtl(containerAccessRef.current);\n\n useGlobalDragStateStyles();\n\n const autoScrollHandlers = useAutoScroll();\n\n const [transitionState, dispatch] = useTransition<D>({ isRtl });\n const transition = transitionState.transition;\n const removeTransition = transitionState.removeTransition;\n const transitionAnnouncement = transitionState.announcement;\n const acquiredItem = transition?.acquiredItem ?? null;\n const acquiredItemElement = transition?.acquiredItemElement;\n\n // Using cached columns from transition to ensure no unexpected changes in the process.\n const columns = transition ? transition.itemsLayout.columns : currentColumns;\n\n // Use previous items while remove transition is in progress.\n items = removeTransition?.items ?? items;\n\n // The acquired item is the one being inserting at the moment but not submitted yet.\n // It needs to be included to the layout to be a part of layout shifts and rendering.\n items = acquiredItem ? [...items, acquiredItem] : items;\n const itemsLayout = interpretItems(items, columns);\n\n const layoutItemById = new Map(itemsLayout.items.map((item) => [item.id, item]));\n const layoutItemIndexById = new Map(itemsLayout.items.map((item, index) => [item.id, index]));\n\n // Items and layout items must maintain the same order visually, in the DOM and in the data\n // to ensure on-change events and tab order work as expected.\n items = [...items].sort((a, b) => (layoutItemIndexById.get(a.id) ?? -1) - (layoutItemIndexById.get(b.id) ?? -1));\n\n // When an item gets acquired or removed the focus needs to be dispatched on the next render.\n const focusNextRenderIndexRef = useRef<null | number>(null);\n const focusNextRenderIdRef = useRef<null | ItemId>(null);\n useEffect(() => {\n const focusTarget = focusNextRenderIdRef.current ?? items[focusNextRenderIndexRef.current ?? -1]?.id;\n if (focusTarget) {\n itemContainerRef.current[focusTarget].focusDragHandle();\n }\n focusNextRenderIndexRef.current = null;\n focusNextRenderIdRef.current = null;\n });\n\n // Submit scheduled removal after a delay to let animations play.\n useEffect(() => {\n if (!removeTransition) {\n return;\n }\n\n const timeoutId = setTimeout(() => {\n dispatch({ type: \"submit\" });\n\n const removedItemIndex = items.findIndex((it) => it.id === removeTransition.removedItem.id);\n const nextIndexToFocus = removedItemIndex !== items.length - 1 ? removedItemIndex : items.length - 2;\n focusNextRenderIndexRef.current = nextIndexToFocus;\n onItemsChange(createItemsChangeEvent(items, removeTransition.layoutShift));\n }, TRANSITION_DURATION_MS);\n\n return () => clearTimeout(timeoutId);\n }, [removeTransition, items, onItemsChange]);\n\n const rows = selectTransitionRows(transitionState) || itemsLayout.rows;\n const placeholdersLayout = createPlaceholdersLayout(rows, itemsLayout.columns);\n\n function isElementOverBoard(rect: Rect) {\n const board = containerAccessRef.current!;\n const boardContains = (target: null | Element) => board === target || board.contains(target);\n const left = !isRtl() ? rect.left : document.documentElement.clientWidth - rect.left;\n const right = !isRtl() ? rect.right : document.documentElement.clientWidth - rect.right;\n const { top, bottom } = rect;\n return (\n boardContains(document.elementFromPoint(left, top)) ||\n boardContains(document.elementFromPoint(right, top)) ||\n boardContains(document.elementFromPoint(right, bottom)) ||\n boardContains(document.elementFromPoint(left, bottom))\n );\n }\n\n useDragSubscription(\"start\", ({ operation, interactionType, draggableItem, collisionRect, collisionIds }) => {\n dispatch({\n type: \"init\",\n operation,\n interactionType,\n itemsLayout,\n // TODO: resolve any\n // The code only works assuming the board can take any draggable.\n // If draggables can be of different types a check of some sort is required here.\n draggableItem: draggableItem as BoardItemDefinitionBase<any>,\n draggableRect: collisionRect,\n collisionIds: interactionType === \"pointer\" && isElementOverBoard(collisionRect) ? collisionIds : [],\n });\n\n autoScrollHandlers.addPointerEventHandlers();\n });\n\n useDragSubscription(\"update\", ({ interactionType, collisionIds, positionOffset, collisionRect }) => {\n dispatch({\n type: \"update-with-pointer\",\n collisionIds: interactionType === \"pointer\" && isElementOverBoard(collisionRect) ? collisionIds : [],\n positionOffset,\n draggableRect: collisionRect,\n });\n });\n\n useDragSubscription(\"submit\", () => {\n dispatch({ type: \"submit\" });\n\n autoScrollHandlers.removePointerEventHandlers();\n\n if (!transition) {\n throw new Error(\"Invariant violation: no transition.\");\n }\n if (\n !transition.layoutShift ||\n transition.layoutShift.conflicts.length > 0 ||\n transition.layoutShift.moves.length === 0\n ) {\n return null;\n }\n\n // Commit new layout for insert case.\n if (transition.operation === \"insert\") {\n onItemsChange(createItemsChangeEvent([...items, transition.draggableItem], transition.layoutShift));\n }\n // Commit new layout for reorder/resize case.\n else {\n onItemsChange(createItemsChangeEvent(items, transition.layoutShift));\n }\n });\n\n useDragSubscription(\"discard\", () => {\n dispatch({ type: \"discard\" });\n\n autoScrollHandlers.removePointerEventHandlers();\n });\n\n useDragSubscription(\"acquire\", ({ droppableId, draggableItem, renderAcquiredItem }) => {\n const placeholder = placeholdersLayout.items.find((it) => it.id === droppableId);\n\n // If missing then it does not belong to this board.\n if (!placeholder) {\n return;\n }\n\n dispatch({\n type: \"acquire-item\",\n position: new Position({ x: placeholder.x, y: placeholder.y }),\n layoutElement: containerAccessRef.current!,\n acquiredItemElement: renderAcquiredItem(),\n });\n\n focusNextRenderIdRef.current = draggableItem.id;\n });\n\n const removeItemAction = (removedItem: BoardItemDefinition<D>) => {\n dispatch({ type: \"init-remove\", items, itemsLayout, removedItem });\n };\n\n function onItemMove(direction: Direction) {\n if (transition) {\n dispatch({ type: \"update-with-keyboard\", direction });\n autoScrollHandlers.scheduleActiveElementScrollIntoView(TRANSITION_DURATION_MS);\n }\n }\n\n const announcement = transitionAnnouncement\n ? announcementToString(transitionAnnouncement, items, i18nStrings, itemsLayout.columns)\n : \"\";\n\n return (\n <div ref={__internalRootRef} {...getDataAttributes(rest)}>\n <div ref={containerRef} className={clsx(styles.root, { [styles.empty]: rows === 0 })}>\n {rows > 0 ? (\n <Grid\n isRtl={isRtl}\n columns={itemsLayout.columns}\n layout={[...placeholdersLayout.items, ...itemsLayout.items]}\n >\n {(gridContext) => {\n const layoutShift = transition?.layoutShift ?? removeTransition?.layoutShift;\n const transforms = layoutShift ? createTransforms(itemsLayout, layoutShift.moves, gridContext) : {};\n\n // Exclude drag target from transforms.\n if (transition && transition.interactionType === \"pointer\") {\n delete transforms[transition.draggableItem.id];\n }\n\n const children: ReactNode[] = [];\n\n /* Placeholders are rendered even when there is no transition to support the first collisions check. */\n placeholdersLayout.items.forEach((placeholder) =>\n children.push(\n <Placeholder\n key={placeholder.id}\n id={placeholder.id}\n state={transition ? (transition.collisionIds?.has(placeholder.id) ? \"hover\" : \"active\") : \"default\"}\n gridContext={gridContext}\n columns={itemsLayout.columns}\n />,\n ),\n );\n\n items.forEach((item) => {\n const layoutItem = layoutItemById.get(item.id);\n const isResizing = transition?.operation === \"resize\" && transition?.draggableItem.id === item.id;\n\n const itemSize = layoutItem ?? {\n width: getDefaultColumnSpan(item, itemsLayout.columns),\n height: getDefaultRowSpan(item),\n };\n\n const itemMaxSize =\n isResizing && layoutItem ? { width: itemsLayout.columns - layoutItem.x, height: 999 } : itemSize;\n\n children.push(\n <ItemContainer\n key={item.id}\n ref={(elem) => {\n if (elem) {\n itemContainerRef.current[item.id] = elem;\n } else {\n delete itemContainerRef.current[item.id];\n }\n }}\n item={item}\n transform={transforms[item.id]}\n inTransition={!!transition || !!removeTransition}\n placed={item.id !== acquiredItem?.id}\n acquired={item.id === acquiredItem?.id}\n getItemSize={() => ({\n width: gridContext.getWidth(itemSize.width),\n minWidth: gridContext.getWidth(getMinColumnSpan(item, itemsLayout.columns)),\n maxWidth: gridContext.getWidth(itemMaxSize.width),\n height: gridContext.getHeight(itemSize.height),\n minHeight: gridContext.getHeight(getMinRowSpan(item)),\n maxHeight: gridContext.getHeight(itemMaxSize.height),\n })}\n onKeyMove={onItemMove}\n isRtl={isRtl}\n >\n {item.id === acquiredItem?.id && acquiredItemElement\n ? () => acquiredItemElement\n : () => renderItem(item, { removeItem: () => removeItemAction(item) })}\n </ItemContainer>,\n );\n });\n\n return children;\n }}\n </Grid>\n ) : (\n empty\n )}\n </div>\n\n <LiveRegion>{announcement}</LiveRegion>\n </div>\n );\n}\n"]}
|
|
@@ -70,7 +70,7 @@ module.exports = {
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"optional": false,
|
|
73
|
-
"description": "An object containing all the necessary localized strings required by the component.\nLive announcements:\n* `liveAnnouncementDndStarted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate start of DnD (\"reorder\", \"resize\" or \"insert\").\n* `liveAnnouncementDndItemReordered(BoardProps.DndReorderState<D>): string` - the function to create a live announcement string to indicate when DnD reorder is performed.\n* `liveAnnouncementDndItemResized(BoardProps.DndResizeState<D>): string` - the function to create a live announcement string to indicate when DnD resize is performed.\n* `liveAnnouncementDndItemInserted(BoardProps.DndInsertState<D>): string` - the function to create a live announcement string to indicate when DnD insert is performed.\n* `liveAnnouncementDndDiscarded(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate commit of DnD (\"reorder\", \"resize\" or \"insert\").\n* `liveAnnouncementDndCommitted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate discard of DnD (\"reorder\", \"resize\" or \"insert\").\n* `liveAnnouncementItemRemoved(BoardProps.OperationStateRemove<D>): string` - the function to create a live announcement string to indicate when item is removed.\n
|
|
73
|
+
"description": "An object containing all the necessary localized strings required by the component.\nLive announcements:\n* `liveAnnouncementDndStarted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate start of DnD (\"reorder\", \"resize\" or \"insert\").\n* `liveAnnouncementDndItemReordered(BoardProps.DndReorderState<D>): string` - the function to create a live announcement string to indicate when DnD reorder is performed.\n* `liveAnnouncementDndItemResized(BoardProps.DndResizeState<D>): string` - the function to create a live announcement string to indicate when DnD resize is performed.\n* `liveAnnouncementDndItemInserted(BoardProps.DndInsertState<D>): string` - the function to create a live announcement string to indicate when DnD insert is performed.\n* `liveAnnouncementDndDiscarded(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate commit of DnD (\"reorder\", \"resize\" or \"insert\").\n* `liveAnnouncementDndCommitted(BoardProps.DndOperationType): string` - the function to create a live announcement string to indicate discard of DnD (\"reorder\", \"resize\" or \"insert\").\n* `liveAnnouncementItemRemoved(BoardProps.OperationStateRemove<D>): string` - the function to create a live announcement string to indicate when item is removed.\n"
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"name": "items",
|
|
@@ -39,7 +39,7 @@ module.exports = {
|
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
41
|
"optional": false,
|
|
42
|
-
"description": "An object containing all the necessary localized strings required by the component.\nLive announcements:\n* `liveAnnouncementDndStarted` (string) - live announcement string to indicate start of DnD.\n* `liveAnnouncementDndDiscarded` (string) - live announcement string to indicate discard of DnD.\n
|
|
42
|
+
"description": "An object containing all the necessary localized strings required by the component.\nLive announcements:\n* `liveAnnouncementDndStarted` (string) - live announcement string to indicate start of DnD.\n* `liveAnnouncementDndDiscarded` (string) - live announcement string to indicate discard of DnD.\n"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"name": "items",
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
|
@@ -26,11 +26,6 @@ export interface ItemsPaletteProps<D = DataFallbackType> {
|
|
|
26
26
|
* Live announcements:
|
|
27
27
|
* * `liveAnnouncementDndStarted` (string) - live announcement string to indicate start of DnD.
|
|
28
28
|
* * `liveAnnouncementDndDiscarded` (string) - live announcement string to indicate discard of DnD.
|
|
29
|
-
*
|
|
30
|
-
* Navigation labels:
|
|
31
|
-
* * `navigationAriaLabel` (string) - the ARIA label for the accessible board navigation element.
|
|
32
|
-
* * `navigationAriaDescription` (string, optional) - the ARIA description for the accessible board navigation element.
|
|
33
|
-
* * `navigationItemAriaLabel(null | BoardProps.Item<D>): string` - the function to create the ARIA label for a navigation board item.
|
|
34
29
|
*/
|
|
35
30
|
i18nStrings: ItemsPaletteProps.I18nStrings<D>;
|
|
36
31
|
}
|
|
@@ -42,8 +37,11 @@ export declare namespace ItemsPaletteProps {
|
|
|
42
37
|
interface I18nStrings<D> {
|
|
43
38
|
liveAnnouncementDndStarted: string;
|
|
44
39
|
liveAnnouncementDndDiscarded: string;
|
|
40
|
+
/** @deprecated Has no effect. */
|
|
45
41
|
navigationAriaLabel: string;
|
|
42
|
+
/** @deprecated Has no effect. */
|
|
46
43
|
navigationAriaDescription?: string;
|
|
44
|
+
/** @deprecated Has no effect. */
|
|
47
45
|
navigationItemAriaLabel: (item: ItemsPaletteProps.Item<D>) => string;
|
|
48
46
|
}
|
|
49
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/items-palette/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BoardItemDefinitionBase, DataFallbackType } from \"../internal/interfaces\";\n\n/*\n Note:\n The component does not provide handling of items state (loading, error, loaded).\n It is the responsibility of the client to control it and provide the necessary\n ARIA-live announcements.\n*/\n\nexport interface ItemsPaletteProps<D = DataFallbackType> {\n /**\n * Specifies the items displayed in the palette. The content of each item is controlled by the `renderItem` property.\n *\n * The ItemsPaletteProps.Item includes:\n * * `id` (string) - the unique item identifier. The IDs of any two items in a page must be different.\n * * `definition.minRowSpan` (number, optional) - the minimal number of rows the item is allowed to take. It can't be less than two. Defaults to two.\n * * `definition.minColumnSpan` (number, optional) - the minimal number of columns the item is allowed to take (in a 4 column layout). It can't be less than one. Defaults to one.\n * * `definition.defaultRowSpan` (number) - the number or rows the item will take when inserted to the board. It can't be less than `definition.minRowSpan`.\n * * `definition.defaultColumnSpan` (number) - the number or columns the item will take (in a 4 column layout) when inserted to the board. It can't be less than `definition.minColumnSpan`.\n * * `data` (D) - optional item data which can include the specific configurations of an item, such as its title.\n */\n items: ReadonlyArray<ItemsPaletteProps.Item<D>>;\n\n /**\n * Specifies a function to render content for a palette item. The return value must include board item component.\n *\n * The function takes the item and its associated context (ItemsPaletteProps.ItemContext) that include:\n * * `showPreview` (boolean) - a flag that indicates if the item's content needs to be rendered in preview mode.\n */\n renderItem: (item: ItemsPaletteProps.Item<D>, context: ItemsPaletteProps.ItemContext) => JSX.Element;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n *\n * Live announcements:\n * * `liveAnnouncementDndStarted` (string) - live announcement string to indicate start of DnD.\n * * `liveAnnouncementDndDiscarded` (string) - live announcement string to indicate discard of DnD.\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/items-palette/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BoardItemDefinitionBase, DataFallbackType } from \"../internal/interfaces\";\n\n/*\n Note:\n The component does not provide handling of items state (loading, error, loaded).\n It is the responsibility of the client to control it and provide the necessary\n ARIA-live announcements.\n*/\n\nexport interface ItemsPaletteProps<D = DataFallbackType> {\n /**\n * Specifies the items displayed in the palette. The content of each item is controlled by the `renderItem` property.\n *\n * The ItemsPaletteProps.Item includes:\n * * `id` (string) - the unique item identifier. The IDs of any two items in a page must be different.\n * * `definition.minRowSpan` (number, optional) - the minimal number of rows the item is allowed to take. It can't be less than two. Defaults to two.\n * * `definition.minColumnSpan` (number, optional) - the minimal number of columns the item is allowed to take (in a 4 column layout). It can't be less than one. Defaults to one.\n * * `definition.defaultRowSpan` (number) - the number or rows the item will take when inserted to the board. It can't be less than `definition.minRowSpan`.\n * * `definition.defaultColumnSpan` (number) - the number or columns the item will take (in a 4 column layout) when inserted to the board. It can't be less than `definition.minColumnSpan`.\n * * `data` (D) - optional item data which can include the specific configurations of an item, such as its title.\n */\n items: ReadonlyArray<ItemsPaletteProps.Item<D>>;\n\n /**\n * Specifies a function to render content for a palette item. The return value must include board item component.\n *\n * The function takes the item and its associated context (ItemsPaletteProps.ItemContext) that include:\n * * `showPreview` (boolean) - a flag that indicates if the item's content needs to be rendered in preview mode.\n */\n renderItem: (item: ItemsPaletteProps.Item<D>, context: ItemsPaletteProps.ItemContext) => JSX.Element;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n *\n * Live announcements:\n * * `liveAnnouncementDndStarted` (string) - live announcement string to indicate start of DnD.\n * * `liveAnnouncementDndDiscarded` (string) - live announcement string to indicate discard of DnD.\n */\n i18nStrings: ItemsPaletteProps.I18nStrings<D>;\n}\n\nexport namespace ItemsPaletteProps {\n export type Item<D = DataFallbackType> = BoardItemDefinitionBase<D>;\n\n export interface ItemContext {\n showPreview: boolean;\n }\n\n export interface I18nStrings<D> {\n liveAnnouncementDndStarted: string;\n liveAnnouncementDndDiscarded: string;\n /** @deprecated Has no effect. */\n navigationAriaLabel: string;\n /** @deprecated Has no effect. */\n navigationAriaDescription?: string;\n /** @deprecated Has no effect. */\n navigationItemAriaLabel: (item: ItemsPaletteProps.Item<D>) => string;\n }\n}\n"]}
|
|
@@ -8,7 +8,6 @@ import { getDataAttributes } from "../internal/base-component/get-data-attribute
|
|
|
8
8
|
import { useDragSubscription } from "../internal/dnd-controller/controller";
|
|
9
9
|
import { ItemContainer } from "../internal/item-container";
|
|
10
10
|
import LiveRegion from "../internal/live-region";
|
|
11
|
-
import { ScreenReaderGridNavigation } from "../internal/screenreader-grid-navigation";
|
|
12
11
|
import styles from "./styles.css.js";
|
|
13
12
|
export function InternalItemsPalette({ items, renderItem, i18nStrings, __internalRootRef, ...rest }) {
|
|
14
13
|
const paletteRef = useRef(null);
|
|
@@ -16,9 +15,6 @@ export function InternalItemsPalette({ items, renderItem, i18nStrings, __interna
|
|
|
16
15
|
const [dropState, setDropState] = useState();
|
|
17
16
|
const [announcement, setAnnouncement] = useState("");
|
|
18
17
|
const isRtl = () => getIsRtl(paletteRef.current);
|
|
19
|
-
function focusItem(itemId) {
|
|
20
|
-
itemContainerRef.current[itemId].focusDragHandle();
|
|
21
|
-
}
|
|
22
18
|
useDragSubscription("start", ({ draggableItem: { id } }) => {
|
|
23
19
|
setDropState({ id });
|
|
24
20
|
// Announce only if the target item belongs to the palette.
|
|
@@ -52,12 +48,7 @@ export function InternalItemsPalette({ items, renderItem, i18nStrings, __interna
|
|
|
52
48
|
setDropState(undefined);
|
|
53
49
|
}
|
|
54
50
|
});
|
|
55
|
-
|
|
56
|
-
items: items.map((it, index) => ({ id: it.id, x: 0, y: index, width: 1, height: 1 })),
|
|
57
|
-
columns: 1,
|
|
58
|
-
rows: items.length,
|
|
59
|
-
};
|
|
60
|
-
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) => {
|
|
51
|
+
return (_jsxs("div", { ref: __internalRootRef, ...getDataAttributes(rest), children: [_jsx("div", { ref: paletteRef, className: styles.root, children: _jsx(SpaceBetween, { size: "l", children: items.map((item) => (_jsx(ItemContainer, { ref: (elem) => {
|
|
61
52
|
if (elem) {
|
|
62
53
|
itemContainerRef.current[item.id] = elem;
|
|
63
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/items-palette/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,YAAY,MAAM,6CAA6C,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAoB,MAAM,4BAA4B,CAAC;AAC7E,OAAO,UAAU,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/items-palette/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,YAAY,MAAM,6CAA6C,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAoB,MAAM,4BAA4B,CAAC;AAC7E,OA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AAE,CAAC,CAAC;6BAC1C;wBACH,CAAC,EAED,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,KAAK,EACf,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,KAAK,EACnB,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE;4BAC3B,IAAI,CAAC,WAAW,EAAE;gCAChB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;6BAC9F;4BACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;4BAClD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;wBACnG,CAAC,EACD,KAAK,EAAE,KAAK,YAEX,CAAC,aAAa,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,IAf/D,IAAI,CAAC,EAAE,CAgBE,CACjB,CAAC,GACW,GACX,EAEN,KAAC,UAAU,cAAE,YAAY,GAAc,IACnC,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getIsRtl } from \"@cloudscape-design/component-toolkit/internal\";\nimport SpaceBetween from \"@cloudscape-design/components/space-between\";\nimport { useRef, useState } from \"react\";\nimport { getDataAttributes } from \"../internal/base-component/get-data-attributes\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { useDragSubscription } from \"../internal/dnd-controller/controller\";\nimport { ItemId } from \"../internal/interfaces\";\nimport { ItemContainer, ItemContainerRef } from \"../internal/item-container\";\nimport LiveRegion from \"../internal/live-region\";\nimport { ItemsPaletteProps } from \"./interfaces\";\nimport styles from \"./styles.css.js\";\n\nexport function InternalItemsPalette<D>({\n items,\n renderItem,\n i18nStrings,\n __internalRootRef,\n ...rest\n}: ItemsPaletteProps<D> & InternalBaseComponentProps) {\n const paletteRef = useRef<HTMLDivElement>(null);\n const itemContainerRef = useRef<{ [id: ItemId]: ItemContainerRef }>({});\n const [dropState, setDropState] = useState<{ id: string }>();\n const [announcement, setAnnouncement] = useState(\"\");\n\n const isRtl = () => getIsRtl(paletteRef.current);\n\n useDragSubscription(\"start\", ({ draggableItem: { id } }) => {\n setDropState({ id });\n\n // Announce only if the target item belongs to the palette.\n if (items.some((it) => it.id === id)) {\n setAnnouncement(i18nStrings.liveAnnouncementDndStarted);\n } else {\n setAnnouncement(\"\");\n }\n });\n\n useDragSubscription(\"update\", ({ draggableItem: { id } }) => {\n setDropState({ id });\n });\n\n useDragSubscription(\"submit\", () => {\n setDropState(undefined);\n\n // Announce only if the target item belongs to the palette.\n if (dropState && items.some((it) => it.id === dropState.id)) {\n setAnnouncement(i18nStrings.liveAnnouncementDndDiscarded);\n }\n });\n\n useDragSubscription(\"discard\", () => {\n setDropState(undefined);\n\n // Announce only if the target item belongs to the palette.\n if (items.some((it) => it.id === dropState?.id)) {\n setAnnouncement(i18nStrings.liveAnnouncementDndDiscarded);\n }\n });\n\n useDragSubscription(\"acquire\", ({ draggableItem }) => {\n // \"Disconnect\" target item from the palette if borrowed.\n if (items.some((it) => it.id === draggableItem.id)) {\n setDropState(undefined);\n }\n });\n\n return (\n <div ref={__internalRootRef} {...getDataAttributes(rest)}>\n <div ref={paletteRef} className={styles.root}>\n <SpaceBetween size=\"l\">\n {items.map((item) => (\n <ItemContainer\n ref={(elem) => {\n if (elem) {\n itemContainerRef.current[item.id] = elem;\n } else {\n delete itemContainerRef.current[item.id];\n }\n }}\n key={item.id}\n item={item}\n placed={false}\n acquired={false}\n transform={undefined}\n inTransition={false}\n getItemSize={(dropContext) => {\n if (!dropContext) {\n throw new Error(\"Invariant violation: cannot query palette item size with no drop context.\");\n }\n const { width, height } = dropContext.scale(item);\n return { width, minWidth: width, maxWidth: width, height, minHeight: height, maxHeight: height };\n }}\n isRtl={isRtl}\n >\n {(hasDropTarget) => renderItem(item, { showPreview: hasDropTarget })}\n </ItemContainer>\n ))}\n </SpaceBetween>\n </div>\n\n <LiveRegion>{announcement}</LiveRegion>\n </div>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { GridLayout, ItemId } from "../interfaces";
|
|
3
|
-
export interface ScreenReaderGridNavigationProps<Item> {
|
|
4
|
-
items: readonly Item[];
|
|
5
|
-
itemsLayout: GridLayout;
|
|
6
|
-
ariaLabel: string;
|
|
7
|
-
ariaDescription?: string;
|
|
8
|
-
itemAriaLabel: (item: null | Item) => string;
|
|
9
|
-
onActivateItem: (itemId: ItemId) => void;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* The component provides a native screen-reader grid navigation for board items.
|
|
13
|
-
* A separate navigation component is used because the navigation requires a table or table-like
|
|
14
|
-
* DOM structure while the board uses CSS grid.
|
|
15
|
-
*
|
|
16
|
-
* The screen-reader navigation component is hidden and don't have a tab stop, however, it can be focused
|
|
17
|
-
* programmatically or with a screen-reader. When focused with a screen-reader the component becomes visible
|
|
18
|
-
* so that it can be clicked (e.g. the VO can imitate clicks on the elements under VO cursor with VO+Space).
|
|
19
|
-
*/
|
|
20
|
-
export declare function ScreenReaderGridNavigation<Item extends {
|
|
21
|
-
id: string;
|
|
22
|
-
}>({ items, itemsLayout, ariaLabel, ariaDescription, itemAriaLabel, onActivateItem, }: ScreenReaderGridNavigationProps<Item>): JSX.Element;
|
|
@@ -1,43 +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 { useId, useMemo, useState } from "react";
|
|
5
|
-
import ScreenreaderOnly from "../screenreader-only";
|
|
6
|
-
import styles from "./styles.css.js";
|
|
7
|
-
/**
|
|
8
|
-
* The component provides a native screen-reader grid navigation for board items.
|
|
9
|
-
* A separate navigation component is used because the navigation requires a table or table-like
|
|
10
|
-
* DOM structure while the board uses CSS grid.
|
|
11
|
-
*
|
|
12
|
-
* The screen-reader navigation component is hidden and don't have a tab stop, however, it can be focused
|
|
13
|
-
* programmatically or with a screen-reader. When focused with a screen-reader the component becomes visible
|
|
14
|
-
* so that it can be clicked (e.g. the VO can imitate clicks on the elements under VO cursor with VO+Space).
|
|
15
|
-
*/
|
|
16
|
-
export function ScreenReaderGridNavigation({ items, itemsLayout, ariaLabel, ariaDescription, itemAriaLabel, onActivateItem, }) {
|
|
17
|
-
const [isNavigationFocused, setIsNavigationFocused] = useState(false);
|
|
18
|
-
const className = isNavigationFocused
|
|
19
|
-
? styles["screen-reader-navigation-visible"]
|
|
20
|
-
: styles["screen-reader-navigation-hidden"];
|
|
21
|
-
const tableId = useId();
|
|
22
|
-
const navigationDescriptionId = useId();
|
|
23
|
-
const getItem = useMemo(() => {
|
|
24
|
-
const itemById = new Map(items.map((it) => [it.id, it]));
|
|
25
|
-
return (id) => { var _a; return (id ? (_a = itemById.get(id)) !== null && _a !== void 0 ? _a : null : null); };
|
|
26
|
-
}, [items]);
|
|
27
|
-
const layout = [];
|
|
28
|
-
function makeNewRow() {
|
|
29
|
-
layout.push([...Array(itemsLayout.columns)].map(() => null));
|
|
30
|
-
}
|
|
31
|
-
for (const item of itemsLayout.items) {
|
|
32
|
-
for (let y = item.y; y < item.y + item.height; y++) {
|
|
33
|
-
while (layout.length <= y) {
|
|
34
|
-
makeNewRow();
|
|
35
|
-
}
|
|
36
|
-
for (let x = item.x; x < item.x + item.width; x++) {
|
|
37
|
-
layout[y][x] = item.id;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return (_jsxs("div", { role: "navigation", "aria-labelledby": tableId, "aria-describedby": ariaDescription ? navigationDescriptionId : undefined, className: className, children: [_jsx("table", { id: tableId, role: "grid", "aria-label": ariaLabel, "aria-describedby": ariaDescription ? navigationDescriptionId : undefined, children: _jsx("tbody", { children: layout.map((row, rowIndex) => (_jsx("tr", { role: "row", children: row.map((itemId, cellIndex) => (_jsx("td", { role: "gridcell", children: itemId ? (_jsx("button", { tabIndex: -1, onClick: () => itemId && onActivateItem(itemId), onFocus: () => setIsNavigationFocused(true), onBlur: () => setIsNavigationFocused(false), children: itemAriaLabel(getItem(itemId)) })) : (itemAriaLabel(getItem(itemId))) }, cellIndex))) }, rowIndex))) }) }), ariaDescription && _jsx(ScreenreaderOnly, { id: navigationDescriptionId, children: ariaDescription })] }));
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/screenreader-grid-navigation/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AAEpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAWrC;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAA8B,EACtE,KAAK,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,aAAa,EACb,cAAc,GACwB;IACtC,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,mBAAmB;QACnC,CAAC,CAAC,MAAM,CAAC,kCAAkC,CAAC;QAC5C,CAAC,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC;IAE9C,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,MAAM,uBAAuB,GAAG,KAAK,EAAE,CAAC;IAExC,MAAM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C,CAAC,SAAS,EACvE,SAAS,EAAE,SAAS,aAEpB,gBACE,EAAE,EAAE,OAAO,EACX,IAAI,EAAC,MAAM,gBACC,SAAS,sBACH,eAAe,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,YAEvE,0BACG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAC7B,aAAI,IAAI,EAAC,KAAK,YACX,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,CAC9B,aAAI,IAAI,EAAC,UAAU,YAChB,MAAM,CAAC,CAAC,CAAC,CACR,iBACE,QAAQ,EAAE,CAAC,CAAC,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,EAC/C,OAAO,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAC3C,MAAM,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAAC,YAE1C,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GACxB,CACV,CAAC,CAAC,CAAC,CACF,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAC/B,IAZsB,SAAS,CAa7B,CACN,CAAC,IAhBgB,QAAQ,CAiBvB,CACN,CAAC,GACI,GACF,EAEP,eAAe,IAAI,KAAC,gBAAgB,IAAC,EAAE,EAAE,uBAAuB,YAAG,eAAe,GAAoB,IACnG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useId, useMemo, useState } from \"react\";\nimport { GridLayout, ItemId } from \"../interfaces\";\nimport ScreenreaderOnly from \"../screenreader-only\";\n\nimport styles from \"./styles.css.js\";\n\nexport interface ScreenReaderGridNavigationProps<Item> {\n items: readonly Item[];\n itemsLayout: GridLayout;\n ariaLabel: string;\n ariaDescription?: string;\n itemAriaLabel: (item: null | Item) => string;\n onActivateItem: (itemId: ItemId) => void;\n}\n\n/**\n * The component provides a native screen-reader grid navigation for board items.\n * A separate navigation component is used because the navigation requires a table or table-like\n * DOM structure while the board uses CSS grid.\n *\n * The screen-reader navigation component is hidden and don't have a tab stop, however, it can be focused\n * programmatically or with a screen-reader. When focused with a screen-reader the component becomes visible\n * so that it can be clicked (e.g. the VO can imitate clicks on the elements under VO cursor with VO+Space).\n */\nexport function ScreenReaderGridNavigation<Item extends { id: string }>({\n items,\n itemsLayout,\n ariaLabel,\n ariaDescription,\n itemAriaLabel,\n onActivateItem,\n}: ScreenReaderGridNavigationProps<Item>) {\n const [isNavigationFocused, setIsNavigationFocused] = useState(false);\n const className = isNavigationFocused\n ? styles[\"screen-reader-navigation-visible\"]\n : styles[\"screen-reader-navigation-hidden\"];\n\n const tableId = useId();\n const navigationDescriptionId = useId();\n\n const getItem = useMemo(() => {\n const itemById = new Map(items.map((it) => [it.id, it]));\n return (id: null | ItemId) => (id ? itemById.get(id) ?? null : null);\n }, [items]);\n\n const layout: (null | ItemId)[][] = [];\n\n function makeNewRow() {\n layout.push([...Array(itemsLayout.columns)].map(() => null));\n }\n\n for (const item of itemsLayout.items) {\n for (let y = item.y; y < item.y + item.height; y++) {\n while (layout.length <= y) {\n makeNewRow();\n }\n for (let x = item.x; x < item.x + item.width; x++) {\n layout[y][x] = item.id;\n }\n }\n }\n\n return (\n <div\n role=\"navigation\"\n aria-labelledby={tableId}\n aria-describedby={ariaDescription ? navigationDescriptionId : undefined}\n className={className}\n >\n <table\n id={tableId}\n role=\"grid\"\n aria-label={ariaLabel}\n aria-describedby={ariaDescription ? navigationDescriptionId : undefined}\n >\n <tbody>\n {layout.map((row, rowIndex) => (\n <tr role=\"row\" key={rowIndex}>\n {row.map((itemId, cellIndex) => (\n <td role=\"gridcell\" key={cellIndex}>\n {itemId ? (\n <button\n tabIndex={-1}\n onClick={() => itemId && onActivateItem(itemId)}\n onFocus={() => setIsNavigationFocused(true)}\n onBlur={() => setIsNavigationFocused(false)}\n >\n {itemAriaLabel(getItem(itemId))}\n </button>\n ) : (\n itemAriaLabel(getItem(itemId))\n )}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n\n {ariaDescription && <ScreenreaderOnly id={navigationDescriptionId}>{ariaDescription}</ScreenreaderOnly>}\n </div>\n );\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
.awsui_screen-reader-navigation-hidden_1wuib_1u63w_1:not(#\9) {
|
|
2
|
-
position: absolute !important;
|
|
3
|
-
clip-path: circle(0);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.awsui_screen-reader-navigation-visible_1wuib_1u63w_6:not(#\9) {
|
|
7
|
-
position: fixed;
|
|
8
|
-
background: white;
|
|
9
|
-
padding-block: 8px;
|
|
10
|
-
padding-inline: 8px;
|
|
11
|
-
border: 1px solid black;
|
|
12
|
-
z-index: 10001;
|
|
13
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// es-module interop with Babel and Typescript
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
module.exports.default = {
|
|
5
|
-
"screen-reader-navigation-hidden": "awsui_screen-reader-navigation-hidden_1wuib_1u63w_1",
|
|
6
|
-
"screen-reader-navigation-visible": "awsui_screen-reader-navigation-visible_1wuib_1u63w_6"
|
|
7
|
-
};
|
|
8
|
-
|