@cloudscape-design/board-components 3.0.118 → 3.0.120
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.js +2 -4
- package/board/internal.js.map +1 -1
- package/board/transition.js +6 -6
- package/board/transition.js.map +1 -1
- package/board/utils/path.js +1 -1
- package/board/utils/path.js.map +1 -1
- package/internal/api-docs/test-utils-doc/interfaces.d.ts +2 -2
- package/internal/dnd-controller/controller.js +10 -12
- package/internal/dnd-controller/controller.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/generated/styles/tokens.d.ts +1 -0
- package/internal/generated/styles/tokens.js +1 -0
- package/internal/generated/theming/index.cjs +47 -14
- package/internal/generated/theming/index.cjs.d.ts +9 -0
- package/internal/generated/theming/index.d.ts +9 -0
- package/internal/generated/theming/index.js +47 -14
- package/internal/global-drag-state-styles/index.js +1 -5
- package/internal/global-drag-state-styles/index.js.map +1 -1
- package/internal/item-container/index.js +1 -1
- package/internal/item-container/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/internal/utils/layout.js +1 -1
- package/internal/utils/layout.js.map +1 -1
- package/items-palette/internal.js +1 -1
- package/items-palette/internal.js.map +1 -1
- package/package.json +1 -1
- package/test-utils/dom/index.js +16 -4
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/selectors/index.js +16 -4
- package/test-utils/selectors/index.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/item-container/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EACL,aAAa,EAEb,UAAU,EAMV,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,oBAAoB,C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,CAAC,KAAK;4BAC7D,eAAe,EAAE,QAAQ;yBAC1B,CAAC;wBACF,gBAAgB,EAAE,yBAAyB;qBAC5C;oBACH,CAAC,CAAC,IAAI;aACT,YAEA,WAAW,CAAC,OAAO,GACC,GACnB,CACP,CAAC;IAEF,OAAO,eAAe,CAAC,CAAC,CAAC,wBAAM,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AACvF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport {\n createContext,\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n Ref,\n RefObject,\n useContext,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { CSS as CSSUtil } from \"@dnd-kit/utilities\";\nimport clsx from \"clsx\";\n\nimport { createSingletonHandler, getLogicalBoundingClientRect } from \"@cloudscape-design/component-toolkit/internal\";\nimport {\n useInternalDragHandleInteractionState,\n UseInternalDragHandleInteractionStateProps,\n} from \"@cloudscape-design/components/internal/do-not-use/drag-handle\";\n\nimport {\n DragAndDropData,\n DropTargetContext,\n InteractionType,\n Operation,\n useDraggable,\n useDragSubscription,\n} from \"../dnd-controller/controller\";\nimport { BoardItemDefinitionBase, Direction, ItemId, Transform } from \"../interfaces\";\nimport { Coordinates } from \"../utils/coordinates\";\nimport { getNormalizedElementRect } from \"../utils/screen\";\nimport { throttle } from \"../utils/throttle\";\nimport { getCollisionRect } from \"./get-collision-rect\";\nimport { getNextDroppable } from \"./get-next-droppable\";\nimport {\n calculateInitialPointerData,\n determineHandleActiveState,\n getDndOperationType,\n hasPointerMovedBeyondThreshold,\n} from \"./utils\";\n\nimport styles from \"./styles.css.js\";\n\nexport interface ItemContainerRef {\n focusDragHandle(): void;\n}\n\nexport type HandleActiveState = null | \"pointer\" | \"uap\";\n\ninterface ItemContextType {\n /**\n * Flag indicating if a drag or resize interaction is currently active.\n */\n isActive: boolean;\n /**\n * Flag indicating if the item is currently hidden.\n * (When a board item is moved from the palette to the board and the transition is not submitted)\n */\n isHidden: boolean;\n dragHandle: {\n /**\n * Ref to the drag button. Used to focus the drag handle when moving an item\n * from the palette to the board via keyboard or UAP actions.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * Listen to pointerDown events on the drag handle.\n * Used to start a transition and attach global event handlers.\n */\n onPointerDown(event: ReactPointerEvent): void;\n /**\n * Listen to keyDown events on the drag handle.\n */\n onKeyDown(event: KeyboardEvent): void;\n /**\n * Indicating if drag handle is active.\n */\n activeState: HandleActiveState;\n /**\n * Listen to UAP direction button clicks.\n */\n onDirectionClick(direction: KeyboardEvent[\"key\"], operation: HandleOperation): void;\n /**\n * Flag indicating if the UAP buttons should be shown. E.g. when a item is moved from\n * the palette via keyboard or UAP to the board.\n */\n initialShowButtons?: boolean;\n };\n resizeHandle: null | {\n /**\n * Listen to pointerDown events on the drag handle.\n * Used to start a transition and attach global event handlers.\n */\n onPointerDown(event: ReactPointerEvent): void;\n /**\n * Listen to keyDown events on the drag handle.\n */\n onKeyDown(event: KeyboardEvent): void;\n /**\n * Indicating if resize handle is active.\n */\n activeState: HandleActiveState;\n /**\n * Listen to UAP direction button clicks.\n */\n onDirectionClick(direction: KeyboardEvent[\"key\"], operation: HandleOperation): void;\n };\n}\n\nexport interface Transition {\n itemId: ItemId;\n operation: Operation;\n interactionType: InteractionType;\n sizeTransform: null | { width: number; height: number };\n positionTransform: null | { x: number; y: number };\n hasDropTarget?: boolean;\n}\n\nexport type HandleOperation = \"drag\" | \"resize\";\n\nexport const ItemContext = createContext<ItemContextType | null>(null);\n\nexport function useItemContext() {\n const ctx = useContext(ItemContext);\n if (!ctx) {\n throw new Error(\"Unable to find BoardItem context.\");\n }\n return ctx;\n}\n\n/**\n * Defines item's parameters and its relation with the layout.\n *\n * `item` - the unique board item base object to be used in d&d context.\n * `placed` - specifies if the item already belongs to the board.\n * `acquired` - specifies if the item is essentially a copy temporarily acquired by a droppable but not submitted yet.\n * `inTransition` - specifies if the item is currently being moved.\n * `transform` - specifies if the item's position needs to be altered.\n * `getItemSize` - item size getter that takes droppable context as argument.\n * `onKeyMove` - a callback that fires when arrow keys are pressed in drag- or resize handle.\n */\nexport interface ItemContainerProps {\n item: BoardItemDefinitionBase<unknown>;\n placed: boolean;\n acquired: boolean;\n inTransition: boolean;\n transform: Transform | undefined;\n getItemSize: (context: null | DropTargetContext) => {\n width: number;\n minWidth: number;\n maxWidth: number;\n height: number;\n minHeight: number;\n maxHeight: number;\n };\n\n onKeyMove?(direction: Direction): void;\n\n children: (hasDropTarget: boolean) => ReactNode;\n isRtl: () => boolean;\n}\n\nexport const ItemContainer = forwardRef(ItemContainerComponent);\n\n// The amount of distance after pointer down that the cursor is allowed to\n// jitter for a subsequent mouseup to still register as a \"press\" instead of\n// a drag. A little allowance is needed for usability reasons, but this number\n// isn't set in stone.\nexport const CLICK_DRAG_THRESHOLD = 3;\n\n// We use singleton helper to avoid creating event listeners per each board item.\nconst usePointerEventListeners = createSingletonHandler<\n { type: \"move\"; event: PointerEvent } | { type: \"up\"; event: PointerEvent }\n>((setEvent) => {\n const handleGlobalPointerMove = (event: PointerEvent) => setEvent({ type: \"move\", event });\n const handleGlobalPointerUp = (event: PointerEvent) => setEvent({ type: \"up\", event });\n const controller = new AbortController();\n window.addEventListener(\"pointermove\", handleGlobalPointerMove, { signal: controller.signal });\n window.addEventListener(\"pointerup\", handleGlobalPointerUp, { signal: controller.signal });\n return () => controller.abort();\n});\n\nfunction ItemContainerComponent(\n { item, placed, acquired, inTransition, transform, getItemSize, onKeyMove, children, isRtl }: ItemContainerProps,\n ref: Ref<ItemContainerRef>,\n) {\n const originalSizeRef = useRef({ width: 0, height: 0 });\n const pointerOffsetRef = useRef(new Coordinates({ x: 0, y: 0 }));\n const pointerBoundariesRef = useRef<null | Coordinates>(null);\n const [transition, setTransition] = useState<null | Transition>(null);\n const [isHidden, setIsHidden] = useState(false);\n const muteEventsRef = useRef(false);\n const itemRef = useRef<HTMLDivElement>(null);\n // Keeps the starting position of active pointer-based d&d transition.\n // If undefined - it means the pointer-based d&d is not engaged.\n const initialPointerDownPosition = useRef<{ x: number; y: number } | undefined>();\n const draggableApi = useDraggable({\n draggableItem: item,\n getCollisionRect: (operation, coordinates, dropTarget) => {\n const sizeOverride = operation === \"insert\" && dropTarget ? getItemSize(dropTarget) : null;\n return getCollisionRect(operation, itemRef.current!, coordinates, sizeOverride);\n },\n });\n\n function updateTransition({\n operation,\n interactionType,\n draggableItem,\n collisionRect,\n coordinates,\n dropTarget,\n }: DragAndDropData) {\n if (item.id === draggableItem.id) {\n const [width, height] = [collisionRect.right - collisionRect.left, collisionRect.bottom - collisionRect.top];\n const pointerOffset = pointerOffsetRef.current;\n\n if (operation === \"resize\") {\n setTransition({\n operation,\n interactionType,\n itemId: draggableItem.id,\n sizeTransform: {\n width: Math.max(getItemSize(null).minWidth, Math.min(getItemSize(null).maxWidth, width - pointerOffset.x)),\n height: Math.max(getItemSize(null).minHeight, height - pointerOffset.y),\n },\n positionTransform: null,\n });\n } else if (operation === \"insert\" || operation === \"reorder\") {\n setTransition({\n operation,\n interactionType,\n itemId: draggableItem.id,\n sizeTransform: dropTarget ? getItemSize(dropTarget) : originalSizeRef.current,\n positionTransform: { x: coordinates.x - pointerOffset.x, y: coordinates.y - pointerOffset.y },\n hasDropTarget: !!dropTarget,\n });\n }\n }\n }\n\n useDragSubscription(\"start\", (detail) => updateTransition(detail));\n useDragSubscription(\"update\", (detail) => updateTransition(detail));\n useDragSubscription(\"submit\", () => {\n setTransition(null);\n setIsHidden(false);\n muteEventsRef.current = false;\n });\n useDragSubscription(\"discard\", () => {\n setTransition(null);\n setIsHidden(false);\n muteEventsRef.current = false;\n });\n\n // Handles incremental transition logic shared between different keyboard and UAP interactions.\n function handleIncrementalTransition(operation: HandleOperation, submitExisting = false) {\n // The acquired item is a copy and does not have the transition state.\n // However, pressing \"Space\" or \"Enter\" on the acquired item must submit the active transition.\n if (acquired) {\n return draggableApi.submitTransition();\n }\n\n // Submit existing transition if requested and one exists\n if (submitExisting && transition) {\n return draggableApi.submitTransition();\n }\n\n const rect = getNormalizedElementRect(itemRef.current!);\n const coordinates = new Coordinates({\n x: operation === \"drag\" ? rect.left : rect.right,\n y: operation === \"drag\" ? rect.top : rect.bottom,\n });\n\n if (operation === \"drag\" && !placed) {\n draggableApi.start(\"insert\", \"keyboard\", coordinates);\n } else if (operation === \"drag\") {\n draggableApi.start(\"reorder\", \"keyboard\", coordinates);\n } else {\n draggableApi.start(\"resize\", \"keyboard\", coordinates);\n }\n }\n\n function handleInsert(direction: Direction) {\n // Find the closest droppable (in the direction) to the item.\n const droppables = draggableApi.getDroppables();\n const nextDroppable = getNextDroppable({\n draggableElement: itemRef.current!,\n droppables,\n direction,\n isRtl: isRtl(),\n });\n\n if (!nextDroppable) {\n // TODO: add announcement\n // Context: the keyboard insertion only works when there is some droppable area in the specified direction.\n // That means that only some arrow keys might work which is confusing for a screen-reader user.\n // Alternatively, we can consider a multi-step insertion where the user would first explicitly select the desired board.\n return;\n }\n\n // Notify the respective droppable of the intention to insert the item in it.\n draggableApi.acquire(nextDroppable, () => children(true));\n setIsHidden(true);\n muteEventsRef.current = true;\n }\n\n function handleDirectionalMovement(direction: Direction, operation: HandleOperation) {\n const canInsert = transition && operation === \"drag\" && !placed;\n const canNavigate = transition || operation === \"drag\";\n if (canInsert) {\n handleInsert(direction);\n } else if (canNavigate) {\n onKeyMove?.(direction);\n }\n }\n\n function onHandleKeyDown(operation: HandleOperation, event: KeyboardEvent) {\n // We do not expect keyboard input when pointer-based d&d is performed.\n // Upon receiving any, we discard the current transition immediately.\n if (transition && initialPointerDownPosition.current) {\n initialPointerDownPosition.current = undefined;\n draggableApi.discardTransition();\n return;\n }\n\n const discard = () => {\n if (transition || acquired) {\n draggableApi.discardTransition();\n }\n };\n switch (event.key) {\n case \"ArrowUp\":\n return handleDirectionalMovement(\"up\", operation);\n case \"ArrowDown\":\n return handleDirectionalMovement(\"down\", operation);\n case \"ArrowLeft\":\n return handleDirectionalMovement(\"left\", operation);\n case \"ArrowRight\":\n return handleDirectionalMovement(\"right\", operation);\n case \" \":\n case \"Enter\":\n return handleIncrementalTransition(operation, true);\n case \"Escape\":\n return discard();\n }\n }\n\n function onBlur() {\n // When drag- or resize handle on palette or board item loses focus the transition must be submitted with two exceptions:\n // 1. If the last interaction is not \"keyboard\" (the user clicked on another handle issuing a new transition);\n // 2. If the item is acquired by the board (in that case the focus moves to the board item which is expected, palette item is hidden and all events handlers must be muted).\n selectedHook.current.processBlur();\n\n if (acquired || (transition && transition.interactionType === \"keyboard\" && !muteEventsRef.current)) {\n initialPointerDownPosition.current = undefined;\n draggableApi.submitTransition();\n }\n }\n\n // Pointer-down handler, added to each drag- and resize handle.\n function onHandlePointerDown(event: ReactPointerEvent, operation: HandleOperation) {\n // Prevent UI issues when right-clicking: in such a case the OS context menu will be shown and\n // the board while the board-item is active. Because of the context menu under the pointer,\n // onPointerUp is not called anymore. In such a case the board item would stuck in onPointerUp.\n if (event.button !== 0) {\n return;\n }\n initialPointerDownPosition.current = { x: event.clientX, y: event.clientY };\n\n if (operation === \"drag\") {\n selectedHook.current = dragInteractionHook;\n } else {\n selectedHook.current = resizeInteractionHook;\n }\n selectedHook.current.processPointerDown(event.nativeEvent);\n }\n // Global pointer-move and pointer-up handlers.\n usePointerEventListeners(({ type, event }) => {\n switch (type) {\n case \"move\": {\n if (hasPointerMovedBeyondThreshold(event, initialPointerDownPosition.current)) {\n selectedHook.current.processPointerMove(event);\n }\n break;\n }\n case \"up\": {\n if (initialPointerDownPosition.current) {\n selectedHook.current.processPointerUp(event);\n }\n initialPointerDownPosition.current = undefined;\n break;\n }\n }\n });\n\n function handlePointerInteractionStart(event: PointerEvent, operation: \"drag\" | \"resize\") {\n const currentItemElement = itemRef.current;\n if (!currentItemElement) {\n console.warn(\"ItemContainer: itemRef.current is not available on interaction start.\");\n return;\n }\n\n const rect = getLogicalBoundingClientRect(currentItemElement);\n originalSizeRef.current = { width: rect.inlineSize, height: rect.blockSize };\n\n const { pointerOffset, pointerBoundaries } = calculateInitialPointerData({\n event,\n operation,\n rect,\n getMinSize: () => getItemSize(null),\n isRtl: isRtl(),\n });\n pointerOffsetRef.current = pointerOffset;\n pointerBoundariesRef.current = pointerBoundaries;\n\n const dndOperation = getDndOperationType(operation, placed);\n const startCoordinates = Coordinates.fromEvent(event, { isRtl: isRtl() });\n draggableApi.start(dndOperation, \"pointer\", startCoordinates);\n }\n\n const onHandleDndTransitionActive = throttle((event: PointerEvent) => {\n const coordinates = Coordinates.fromEvent(event, { isRtl: isRtl() });\n draggableApi.updateTransition(\n new Coordinates({\n x: Math.max(coordinates.x, pointerBoundariesRef.current?.x ?? Number.NEGATIVE_INFINITY),\n y: Math.max(coordinates.y, pointerBoundariesRef.current?.y ?? Number.NEGATIVE_INFINITY),\n }),\n );\n }, 10) as (event: PointerEvent) => void;\n\n const itemTransitionStyle: CSSProperties = {};\n const itemTransitionClassNames: string[] = [];\n\n if (inTransition) {\n itemTransitionClassNames.push(styles.inTransition);\n }\n\n if (transition && transition.interactionType === \"pointer\") {\n // Adjust the dragged/resized item to the pointer's location.\n itemTransitionClassNames.push(transition.operation === \"resize\" ? styles.resized : styles.dragged);\n itemTransitionStyle.insetInlineStart = transition.positionTransform?.x;\n itemTransitionStyle.insetBlockStart = transition.positionTransform?.y;\n itemTransitionStyle.inlineSize = transition.sizeTransform?.width;\n itemTransitionStyle.blockSize = transition.sizeTransform?.height;\n itemTransitionStyle.pointerEvents = \"none\";\n }\n\n if (isHidden) {\n itemTransitionClassNames.push(styles.hidden);\n }\n\n if (transform) {\n // The moved items positions are altered with CSS transform.\n if (transform.type === \"move\") {\n itemTransitionClassNames.push(styles.transformed);\n itemTransitionStyle.transform = CSSUtil.Transform.toString({\n x: transform.x,\n y: transform.y,\n scaleX: 1,\n scaleY: 1,\n });\n itemTransitionStyle.width = transform.width + \"px\";\n itemTransitionStyle.height = transform.height + \"px\";\n }\n // The item is removed from the DOM after animations play.\n // During the animations the removed item is hidden with styles.\n if (transform.type === \"remove\") {\n itemTransitionClassNames.push(styles.removed);\n }\n }\n\n const dragHandleRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => ({\n focusDragHandle: () => {\n return dragHandleRef.current?.focus();\n },\n }));\n\n const dragHookProps: UseInternalDragHandleInteractionStateProps = {\n onDndStartAction: (event) => handlePointerInteractionStart(event, \"drag\"),\n onDndActiveAction: onHandleDndTransitionActive,\n onDndEndAction: () => transition && draggableApi.submitTransition(),\n onUapActionStartAction: () => handleIncrementalTransition(\"drag\"),\n };\n const resizeHookProps: UseInternalDragHandleInteractionStateProps = {\n onDndStartAction: (event) => handlePointerInteractionStart(event, \"resize\"),\n onDndActiveAction: onHandleDndTransitionActive,\n onDndEndAction: () => transition && draggableApi.submitTransition(),\n onUapActionStartAction: () => handleIncrementalTransition(\"resize\"),\n };\n\n // When d&d is active, either drag- or resize hook should be used.\n // We determine the correct one in the onHandlePointerDown handler, and store it to the selectedHook ref.\n const dragInteractionHook = useInternalDragHandleInteractionState(dragHookProps);\n const resizeInteractionHook = useInternalDragHandleInteractionState(resizeHookProps);\n const selectedHook = useRef(dragInteractionHook);\n\n const isActive = (!!transition && !isHidden) || !!acquired;\n const shouldUsePortal =\n transition?.operation === \"insert\" &&\n transition?.interactionType === \"pointer\" &&\n selectedHook.current.interaction.value === \"dnd-active\";\n const childrenRef = useRef<ReactNode>(null);\n if (!inTransition || isActive) {\n childrenRef.current = children(!!transition?.hasDropTarget);\n }\n\n const content = (\n <div\n ref={itemRef}\n className={clsx(styles.root, ...itemTransitionClassNames)}\n style={itemTransitionStyle}\n data-item-id={item.id}\n onBlur={onBlur}\n >\n <ItemContext.Provider\n value={{\n isActive,\n isHidden,\n dragHandle: {\n ref: dragHandleRef,\n onPointerDown: (e) => onHandlePointerDown(e, \"drag\"),\n onKeyDown: (event: KeyboardEvent) => onHandleKeyDown(\"drag\", event),\n activeState: determineHandleActiveState({\n isHandleActive: isActive,\n currentTransition: transition,\n interactionHookValue: dragInteractionHook.interaction.value,\n targetOperation: \"reorder\",\n }),\n onDirectionClick: handleDirectionalMovement,\n initialShowButtons:\n dragInteractionHook.interaction.value === \"uap-action-start\" || (inTransition && acquired),\n },\n resizeHandle: placed\n ? {\n onPointerDown: (e) => onHandlePointerDown(e, \"resize\"),\n onKeyDown: (event: KeyboardEvent) => onHandleKeyDown(\"resize\", event),\n activeState: determineHandleActiveState({\n isHandleActive: isActive,\n currentTransition: transition,\n interactionHookValue: resizeInteractionHook.interaction.value,\n targetOperation: \"resize\",\n }),\n onDirectionClick: handleDirectionalMovement,\n }\n : null,\n }}\n >\n {childrenRef.current}\n </ItemContext.Provider>\n </div>\n );\n\n return shouldUsePortal ? <div>{createPortal(content, document.body)}</div> : content;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/item-container/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EACL,aAAa,EAEb,UAAU,EAMV,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AACrH,OAAO,EACL,qCAAqC,GAEtC,MAAM,+DAA+D,CAAC;AAEvE,OAAO,EAKL,YAAY,EACZ,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC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, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport {\n createContext,\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n Ref,\n RefObject,\n useContext,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { CSS as CSSUtil } from \"@dnd-kit/utilities\";\nimport clsx from \"clsx\";\n\nimport { createSingletonHandler, getLogicalBoundingClientRect } from \"@cloudscape-design/component-toolkit/internal\";\nimport {\n useInternalDragHandleInteractionState,\n UseInternalDragHandleInteractionStateProps,\n} from \"@cloudscape-design/components/internal/do-not-use/drag-handle\";\n\nimport {\n DragAndDropData,\n DropTargetContext,\n InteractionType,\n Operation,\n useDraggable,\n useDragSubscription,\n} from \"../dnd-controller/controller\";\nimport { BoardItemDefinitionBase, Direction, ItemId, Transform } from \"../interfaces\";\nimport { Coordinates } from \"../utils/coordinates\";\nimport { getNormalizedElementRect } from \"../utils/screen\";\nimport { throttle } from \"../utils/throttle\";\nimport { getCollisionRect } from \"./get-collision-rect\";\nimport { getNextDroppable } from \"./get-next-droppable\";\nimport {\n calculateInitialPointerData,\n determineHandleActiveState,\n getDndOperationType,\n hasPointerMovedBeyondThreshold,\n} from \"./utils\";\n\nimport styles from \"./styles.css.js\";\n\nexport interface ItemContainerRef {\n focusDragHandle(): void;\n}\n\nexport type HandleActiveState = null | \"pointer\" | \"uap\";\n\ninterface ItemContextType {\n /**\n * Flag indicating if a drag or resize interaction is currently active.\n */\n isActive: boolean;\n /**\n * Flag indicating if the item is currently hidden.\n * (When a board item is moved from the palette to the board and the transition is not submitted)\n */\n isHidden: boolean;\n dragHandle: {\n /**\n * Ref to the drag button. Used to focus the drag handle when moving an item\n * from the palette to the board via keyboard or UAP actions.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * Listen to pointerDown events on the drag handle.\n * Used to start a transition and attach global event handlers.\n */\n onPointerDown(event: ReactPointerEvent): void;\n /**\n * Listen to keyDown events on the drag handle.\n */\n onKeyDown(event: KeyboardEvent): void;\n /**\n * Indicating if drag handle is active.\n */\n activeState: HandleActiveState;\n /**\n * Listen to UAP direction button clicks.\n */\n onDirectionClick(direction: KeyboardEvent[\"key\"], operation: HandleOperation): void;\n /**\n * Flag indicating if the UAP buttons should be shown. E.g. when a item is moved from\n * the palette via keyboard or UAP to the board.\n */\n initialShowButtons?: boolean;\n };\n resizeHandle: null | {\n /**\n * Listen to pointerDown events on the drag handle.\n * Used to start a transition and attach global event handlers.\n */\n onPointerDown(event: ReactPointerEvent): void;\n /**\n * Listen to keyDown events on the drag handle.\n */\n onKeyDown(event: KeyboardEvent): void;\n /**\n * Indicating if resize handle is active.\n */\n activeState: HandleActiveState;\n /**\n * Listen to UAP direction button clicks.\n */\n onDirectionClick(direction: KeyboardEvent[\"key\"], operation: HandleOperation): void;\n };\n}\n\nexport interface Transition {\n itemId: ItemId;\n operation: Operation;\n interactionType: InteractionType;\n sizeTransform: null | { width: number; height: number };\n positionTransform: null | { x: number; y: number };\n hasDropTarget?: boolean;\n}\n\nexport type HandleOperation = \"drag\" | \"resize\";\n\nexport const ItemContext = createContext<ItemContextType | null>(null);\n\nexport function useItemContext() {\n const ctx = useContext(ItemContext);\n if (!ctx) {\n throw new Error(\"Invariant violation: no board item context.\");\n }\n return ctx;\n}\n\n/**\n * Defines item's parameters and its relation with the layout.\n *\n * `item` - the unique board item base object to be used in d&d context.\n * `placed` - specifies if the item already belongs to the board.\n * `acquired` - specifies if the item is essentially a copy temporarily acquired by a droppable but not submitted yet.\n * `inTransition` - specifies if the item is currently being moved.\n * `transform` - specifies if the item's position needs to be altered.\n * `getItemSize` - item size getter that takes droppable context as argument.\n * `onKeyMove` - a callback that fires when arrow keys are pressed in drag- or resize handle.\n */\nexport interface ItemContainerProps {\n item: BoardItemDefinitionBase<unknown>;\n placed: boolean;\n acquired: boolean;\n inTransition: boolean;\n transform: Transform | undefined;\n getItemSize: (context: null | DropTargetContext) => {\n width: number;\n minWidth: number;\n maxWidth: number;\n height: number;\n minHeight: number;\n maxHeight: number;\n };\n\n onKeyMove?(direction: Direction): void;\n\n children: (hasDropTarget: boolean) => ReactNode;\n isRtl: () => boolean;\n}\n\nexport const ItemContainer = forwardRef(ItemContainerComponent);\n\n// The amount of distance after pointer down that the cursor is allowed to\n// jitter for a subsequent mouseup to still register as a \"press\" instead of\n// a drag. A little allowance is needed for usability reasons, but this number\n// isn't set in stone.\nexport const CLICK_DRAG_THRESHOLD = 3;\n\n// We use singleton helper to avoid creating event listeners per each board item.\nconst usePointerEventListeners = createSingletonHandler<\n { type: \"move\"; event: PointerEvent } | { type: \"up\"; event: PointerEvent }\n>((setEvent) => {\n const handleGlobalPointerMove = (event: PointerEvent) => setEvent({ type: \"move\", event });\n const handleGlobalPointerUp = (event: PointerEvent) => setEvent({ type: \"up\", event });\n const controller = new AbortController();\n window.addEventListener(\"pointermove\", handleGlobalPointerMove, { signal: controller.signal });\n window.addEventListener(\"pointerup\", handleGlobalPointerUp, { signal: controller.signal });\n return () => controller.abort();\n});\n\nfunction ItemContainerComponent(\n { item, placed, acquired, inTransition, transform, getItemSize, onKeyMove, children, isRtl }: ItemContainerProps,\n ref: Ref<ItemContainerRef>,\n) {\n const originalSizeRef = useRef({ width: 0, height: 0 });\n const pointerOffsetRef = useRef(new Coordinates({ x: 0, y: 0 }));\n const pointerBoundariesRef = useRef<null | Coordinates>(null);\n const [transition, setTransition] = useState<null | Transition>(null);\n const [isHidden, setIsHidden] = useState(false);\n const muteEventsRef = useRef(false);\n const itemRef = useRef<HTMLDivElement>(null);\n // Keeps the starting position of active pointer-based d&d transition.\n // If undefined - it means the pointer-based d&d is not engaged.\n const initialPointerDownPosition = useRef<{ x: number; y: number } | undefined>();\n const draggableApi = useDraggable({\n draggableItem: item,\n getCollisionRect: (operation, coordinates, dropTarget) => {\n const sizeOverride = operation === \"insert\" && dropTarget ? getItemSize(dropTarget) : null;\n return getCollisionRect(operation, itemRef.current!, coordinates, sizeOverride);\n },\n });\n\n function updateTransition({\n operation,\n interactionType,\n draggableItem,\n collisionRect,\n coordinates,\n dropTarget,\n }: DragAndDropData) {\n if (item.id === draggableItem.id) {\n const [width, height] = [collisionRect.right - collisionRect.left, collisionRect.bottom - collisionRect.top];\n const pointerOffset = pointerOffsetRef.current;\n\n if (operation === \"resize\") {\n setTransition({\n operation,\n interactionType,\n itemId: draggableItem.id,\n sizeTransform: {\n width: Math.max(getItemSize(null).minWidth, Math.min(getItemSize(null).maxWidth, width - pointerOffset.x)),\n height: Math.max(getItemSize(null).minHeight, height - pointerOffset.y),\n },\n positionTransform: null,\n });\n } else if (operation === \"insert\" || operation === \"reorder\") {\n setTransition({\n operation,\n interactionType,\n itemId: draggableItem.id,\n sizeTransform: dropTarget ? getItemSize(dropTarget) : originalSizeRef.current,\n positionTransform: { x: coordinates.x - pointerOffset.x, y: coordinates.y - pointerOffset.y },\n hasDropTarget: !!dropTarget,\n });\n }\n }\n }\n\n useDragSubscription(\"start\", (detail) => updateTransition(detail));\n useDragSubscription(\"update\", (detail) => updateTransition(detail));\n useDragSubscription(\"submit\", () => {\n setTransition(null);\n setIsHidden(false);\n muteEventsRef.current = false;\n });\n useDragSubscription(\"discard\", () => {\n setTransition(null);\n setIsHidden(false);\n muteEventsRef.current = false;\n });\n\n // Handles incremental transition logic shared between different keyboard and UAP interactions.\n function handleIncrementalTransition(operation: HandleOperation, submitExisting = false) {\n // The acquired item is a copy and does not have the transition state.\n // However, pressing \"Space\" or \"Enter\" on the acquired item must submit the active transition.\n if (acquired) {\n return draggableApi.submitTransition();\n }\n\n // Submit existing transition if requested and one exists\n if (submitExisting && transition) {\n return draggableApi.submitTransition();\n }\n\n const rect = getNormalizedElementRect(itemRef.current!);\n const coordinates = new Coordinates({\n x: operation === \"drag\" ? rect.left : rect.right,\n y: operation === \"drag\" ? rect.top : rect.bottom,\n });\n\n if (operation === \"drag\" && !placed) {\n draggableApi.start(\"insert\", \"keyboard\", coordinates);\n } else if (operation === \"drag\") {\n draggableApi.start(\"reorder\", \"keyboard\", coordinates);\n } else {\n draggableApi.start(\"resize\", \"keyboard\", coordinates);\n }\n }\n\n function handleInsert(direction: Direction) {\n // Find the closest droppable (in the direction) to the item.\n const droppables = draggableApi.getDroppables();\n const nextDroppable = getNextDroppable({\n draggableElement: itemRef.current!,\n droppables,\n direction,\n isRtl: isRtl(),\n });\n\n if (!nextDroppable) {\n // TODO: add announcement\n // Context: the keyboard insertion only works when there is some droppable area in the specified direction.\n // That means that only some arrow keys might work which is confusing for a screen-reader user.\n // Alternatively, we can consider a multi-step insertion where the user would first explicitly select the desired board.\n return;\n }\n\n // Notify the respective droppable of the intention to insert the item in it.\n draggableApi.acquire(nextDroppable, () => children(true));\n setIsHidden(true);\n muteEventsRef.current = true;\n }\n\n function handleDirectionalMovement(direction: Direction, operation: HandleOperation) {\n const canInsert = transition && operation === \"drag\" && !placed;\n const canNavigate = transition || operation === \"drag\";\n if (canInsert) {\n handleInsert(direction);\n } else if (canNavigate) {\n onKeyMove?.(direction);\n }\n }\n\n function onHandleKeyDown(operation: HandleOperation, event: KeyboardEvent) {\n // We do not expect keyboard input when pointer-based d&d is performed.\n // Upon receiving any, we discard the current transition immediately.\n if (transition && initialPointerDownPosition.current) {\n initialPointerDownPosition.current = undefined;\n draggableApi.discardTransition();\n return;\n }\n\n const discard = () => {\n if (transition || acquired) {\n draggableApi.discardTransition();\n }\n };\n switch (event.key) {\n case \"ArrowUp\":\n return handleDirectionalMovement(\"up\", operation);\n case \"ArrowDown\":\n return handleDirectionalMovement(\"down\", operation);\n case \"ArrowLeft\":\n return handleDirectionalMovement(\"left\", operation);\n case \"ArrowRight\":\n return handleDirectionalMovement(\"right\", operation);\n case \" \":\n case \"Enter\":\n return handleIncrementalTransition(operation, true);\n case \"Escape\":\n return discard();\n }\n }\n\n function onBlur() {\n // When drag- or resize handle on palette or board item loses focus the transition must be submitted with two exceptions:\n // 1. If the last interaction is not \"keyboard\" (the user clicked on another handle issuing a new transition);\n // 2. If the item is acquired by the board (in that case the focus moves to the board item which is expected, palette item is hidden and all events handlers must be muted).\n selectedHook.current.processBlur();\n\n if (acquired || (transition && transition.interactionType === \"keyboard\" && !muteEventsRef.current)) {\n initialPointerDownPosition.current = undefined;\n draggableApi.submitTransition();\n }\n }\n\n // Pointer-down handler, added to each drag- and resize handle.\n function onHandlePointerDown(event: ReactPointerEvent, operation: HandleOperation) {\n // Prevent UI issues when right-clicking: in such a case the OS context menu will be shown and\n // the board while the board-item is active. Because of the context menu under the pointer,\n // onPointerUp is not called anymore. In such a case the board item would stuck in onPointerUp.\n if (event.button !== 0) {\n return;\n }\n initialPointerDownPosition.current = { x: event.clientX, y: event.clientY };\n\n if (operation === \"drag\") {\n selectedHook.current = dragInteractionHook;\n } else {\n selectedHook.current = resizeInteractionHook;\n }\n selectedHook.current.processPointerDown(event.nativeEvent);\n }\n // Global pointer-move and pointer-up handlers.\n usePointerEventListeners(({ type, event }) => {\n switch (type) {\n case \"move\": {\n if (hasPointerMovedBeyondThreshold(event, initialPointerDownPosition.current)) {\n selectedHook.current.processPointerMove(event);\n }\n break;\n }\n case \"up\": {\n if (initialPointerDownPosition.current) {\n selectedHook.current.processPointerUp(event);\n }\n initialPointerDownPosition.current = undefined;\n break;\n }\n }\n });\n\n function handlePointerInteractionStart(event: PointerEvent, operation: \"drag\" | \"resize\") {\n const currentItemElement = itemRef.current;\n if (!currentItemElement) {\n console.warn(\"ItemContainer: itemRef.current is not available on interaction start.\");\n return;\n }\n\n const rect = getLogicalBoundingClientRect(currentItemElement);\n originalSizeRef.current = { width: rect.inlineSize, height: rect.blockSize };\n\n const { pointerOffset, pointerBoundaries } = calculateInitialPointerData({\n event,\n operation,\n rect,\n getMinSize: () => getItemSize(null),\n isRtl: isRtl(),\n });\n pointerOffsetRef.current = pointerOffset;\n pointerBoundariesRef.current = pointerBoundaries;\n\n const dndOperation = getDndOperationType(operation, placed);\n const startCoordinates = Coordinates.fromEvent(event, { isRtl: isRtl() });\n draggableApi.start(dndOperation, \"pointer\", startCoordinates);\n }\n\n const onHandleDndTransitionActive = throttle((event: PointerEvent) => {\n const coordinates = Coordinates.fromEvent(event, { isRtl: isRtl() });\n draggableApi.updateTransition(\n new Coordinates({\n x: Math.max(coordinates.x, pointerBoundariesRef.current?.x ?? Number.NEGATIVE_INFINITY),\n y: Math.max(coordinates.y, pointerBoundariesRef.current?.y ?? Number.NEGATIVE_INFINITY),\n }),\n );\n }, 10) as (event: PointerEvent) => void;\n\n const itemTransitionStyle: CSSProperties = {};\n const itemTransitionClassNames: string[] = [];\n\n if (inTransition) {\n itemTransitionClassNames.push(styles.inTransition);\n }\n\n if (transition && transition.interactionType === \"pointer\") {\n // Adjust the dragged/resized item to the pointer's location.\n itemTransitionClassNames.push(transition.operation === \"resize\" ? styles.resized : styles.dragged);\n itemTransitionStyle.insetInlineStart = transition.positionTransform?.x;\n itemTransitionStyle.insetBlockStart = transition.positionTransform?.y;\n itemTransitionStyle.inlineSize = transition.sizeTransform?.width;\n itemTransitionStyle.blockSize = transition.sizeTransform?.height;\n itemTransitionStyle.pointerEvents = \"none\";\n }\n\n if (isHidden) {\n itemTransitionClassNames.push(styles.hidden);\n }\n\n if (transform) {\n // The moved items positions are altered with CSS transform.\n if (transform.type === \"move\") {\n itemTransitionClassNames.push(styles.transformed);\n itemTransitionStyle.transform = CSSUtil.Transform.toString({\n x: transform.x,\n y: transform.y,\n scaleX: 1,\n scaleY: 1,\n });\n itemTransitionStyle.width = transform.width + \"px\";\n itemTransitionStyle.height = transform.height + \"px\";\n }\n // The item is removed from the DOM after animations play.\n // During the animations the removed item is hidden with styles.\n if (transform.type === \"remove\") {\n itemTransitionClassNames.push(styles.removed);\n }\n }\n\n const dragHandleRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => ({\n focusDragHandle: () => {\n return dragHandleRef.current?.focus();\n },\n }));\n\n const dragHookProps: UseInternalDragHandleInteractionStateProps = {\n onDndStartAction: (event) => handlePointerInteractionStart(event, \"drag\"),\n onDndActiveAction: onHandleDndTransitionActive,\n onDndEndAction: () => transition && draggableApi.submitTransition(),\n onUapActionStartAction: () => handleIncrementalTransition(\"drag\"),\n };\n const resizeHookProps: UseInternalDragHandleInteractionStateProps = {\n onDndStartAction: (event) => handlePointerInteractionStart(event, \"resize\"),\n onDndActiveAction: onHandleDndTransitionActive,\n onDndEndAction: () => transition && draggableApi.submitTransition(),\n onUapActionStartAction: () => handleIncrementalTransition(\"resize\"),\n };\n\n // When d&d is active, either drag- or resize hook should be used.\n // We determine the correct one in the onHandlePointerDown handler, and store it to the selectedHook ref.\n const dragInteractionHook = useInternalDragHandleInteractionState(dragHookProps);\n const resizeInteractionHook = useInternalDragHandleInteractionState(resizeHookProps);\n const selectedHook = useRef(dragInteractionHook);\n\n const isActive = (!!transition && !isHidden) || !!acquired;\n const shouldUsePortal =\n transition?.operation === \"insert\" &&\n transition?.interactionType === \"pointer\" &&\n selectedHook.current.interaction.value === \"dnd-active\";\n const childrenRef = useRef<ReactNode>(null);\n if (!inTransition || isActive) {\n childrenRef.current = children(!!transition?.hasDropTarget);\n }\n\n const content = (\n <div\n ref={itemRef}\n className={clsx(styles.root, ...itemTransitionClassNames)}\n style={itemTransitionStyle}\n data-item-id={item.id}\n onBlur={onBlur}\n >\n <ItemContext.Provider\n value={{\n isActive,\n isHidden,\n dragHandle: {\n ref: dragHandleRef,\n onPointerDown: (e) => onHandlePointerDown(e, \"drag\"),\n onKeyDown: (event: KeyboardEvent) => onHandleKeyDown(\"drag\", event),\n activeState: determineHandleActiveState({\n isHandleActive: isActive,\n currentTransition: transition,\n interactionHookValue: dragInteractionHook.interaction.value,\n targetOperation: \"reorder\",\n }),\n onDirectionClick: handleDirectionalMovement,\n initialShowButtons:\n dragInteractionHook.interaction.value === \"uap-action-start\" || (inTransition && acquired),\n },\n resizeHandle: placed\n ? {\n onPointerDown: (e) => onHandlePointerDown(e, \"resize\"),\n onKeyDown: (event: KeyboardEvent) => onHandleKeyDown(\"resize\", event),\n activeState: determineHandleActiveState({\n isHandleActive: isActive,\n currentTransition: transition,\n interactionHookValue: resizeInteractionHook.interaction.value,\n targetOperation: \"resize\",\n }),\n onDirectionClick: handleDirectionalMovement,\n }\n : null,\n }}\n >\n {childrenRef.current}\n </ItemContext.Provider>\n </div>\n );\n\n return shouldUsePortal ? <div>{createPortal(content, document.body)}</div> : content;\n}\n"]}
|
package/internal/manifest.json
CHANGED
package/internal/utils/layout.js
CHANGED
|
@@ -70,7 +70,7 @@ export function transformItems(sourceItems, gridLayout, resizeTarget) {
|
|
|
70
70
|
const getItem = (itemId) => {
|
|
71
71
|
const item = itemById.get(itemId);
|
|
72
72
|
if (!item) {
|
|
73
|
-
throw new Error("Invariant violation: no
|
|
73
|
+
throw new Error("Invariant violation: no layout item matches given id.");
|
|
74
74
|
}
|
|
75
75
|
return item;
|
|
76
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../../src/internal/utils/layout.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK1D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAsB,EAAE,OAAe;IACpE,MAAM,WAAW,GAAqB,EAAE,CAAC;IACzC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7C,SAAS,aAAa,CAAC,IAAU;;QAC/B,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,UAAU,mCAAI,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CA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I,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAU,EAAE,OAAe;;IAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,iBAAiB,mCAAI,CAAC,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAU;;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,UAAU,mCAAI,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAU;;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,cAAc,mCAAI,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,cAAc,CAAC,CAAiB,EAAE,CAAiB;IAC1D,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACf,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3B;IACD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MIN_COL_SPAN, MIN_ROW_SPAN } from \"../constants\";\nimport { BoardItemDefinition, GridLayout, GridLayoutItem, ItemId } from \"../interfaces\";\n\ntype Item<D = unknown> = BoardItemDefinition<D>;\n\n/**\n * The function produces grid layout from board items and given number of columns.\n * The positional data is taken from the items when available or the default placement is used otherwise.\n */\nexport function interpretItems(items: readonly Item[], columns: number): GridLayout {\n const layoutItems: GridLayoutItem[] = [];\n const columnHeights = Array(columns).fill(0);\n\n function getColumnSpan(item: Item): number {\n const minColumnSpan = getMinColumnSpan(item, columns);\n const columnSpan = item.columnSpan ?? getDefaultColumnSpan(item, columns);\n return Math.min(columns, Math.max(minColumnSpan, columnSpan));\n }\n\n function getRowSpan(item: Item): number {\n const minRowSpan = getMinRowSpan(item);\n const rowSpan = item.rowSpan ?? getDefaultRowSpan(item);\n return Math.max(minRowSpan, rowSpan);\n }\n\n function getColumnOffset(item: Item, currentOffset: number): number {\n const columnSpan = getColumnSpan(item);\n const rowSpan = getRowSpan(item);\n const columnOffset = item.columnOffset?.[columns] ?? findOptimalColumnOffset(currentOffset, columnSpan, rowSpan);\n return columnOffset + columnSpan <= columns ? columnOffset : 0;\n }\n\n function findOptimalColumnOffset(currentColumnOffset: number, columnSpan: number, rowSpan: number): number {\n for (let colOffset = currentColumnOffset; colOffset + columnSpan <= columns; colOffset++) {\n if (getRowOffset(colOffset, columnSpan) + rowSpan <= getRowOffset(0, columns)) {\n return colOffset;\n }\n }\n for (let colOffset = 0; colOffset + columnSpan <= columns; colOffset++) {\n if (getRowOffset(colOffset, columnSpan) + rowSpan <= getRowOffset(0, columns)) {\n return colOffset;\n }\n }\n return currentColumnOffset;\n }\n\n function getRowOffset(columnOffset: number, columnSpan: number) {\n let rowOffset = 0;\n for (let col = columnOffset; col < columnOffset + columnSpan; col++) {\n rowOffset = Math.max(rowOffset, columnHeights[col]);\n }\n return rowOffset;\n }\n\n for (let index = 0, columnOffset = 0, rowOffset = 0; index < items.length; index++, rowOffset = 0) {\n const columnSpan = getColumnSpan(items[index]);\n const rowSpan = getRowSpan(items[index]);\n columnOffset = getColumnOffset(items[index], columnOffset);\n rowOffset = getRowOffset(columnOffset, columnSpan);\n\n layoutItems.push({ id: items[index].id, width: columnSpan, height: rowSpan, x: columnOffset, y: rowOffset });\n\n for (let col = columnOffset; col < columnOffset + columnSpan; col++) {\n columnHeights[col] = rowOffset + rowSpan;\n }\n\n columnOffset += columnSpan;\n }\n\n layoutItems.sort(itemComparator);\n\n return { items: layoutItems, columns, rows: getRowOffset(0, columns) };\n}\n\n/**\n * The function produces new items from the current state and updated grid layout.\n * The positional data for the given number of columns is preserved as is while the other layouts are partially invalidated.\n */\nexport function transformItems<D>(\n sourceItems: readonly BoardItemDefinition<D>[],\n gridLayout: GridLayout,\n resizeTarget: null | ItemId,\n): readonly BoardItemDefinition<D>[] {\n const itemById = new Map(sourceItems.map((item) => [item.id, item]));\n const getItem = (itemId: ItemId) => {\n const item = itemById.get(itemId);\n if (!item) {\n throw new Error(\"Invariant violation: no matching source item found.\");\n }\n return item;\n };\n\n const sortedLayout = gridLayout.items.slice().sort(itemComparator);\n\n const items: BoardItemDefinition<D>[] = [];\n\n let changeFromIndex = sortedLayout.findIndex(({ id }, index) => id !== sourceItems[index].id || id === resizeTarget);\n changeFromIndex = changeFromIndex !== -1 ? changeFromIndex : sortedLayout.length;\n\n for (let index = 0; index < sortedLayout.length; index++) {\n const { id, x, width, height } = sortedLayout[index];\n\n const item = { ...getItem(id) };\n\n if (index >= changeFromIndex) {\n item.columnOffset = undefined;\n }\n item.columnOffset = { ...item.columnOffset, [gridLayout.columns]: x };\n\n if (item.id === resizeTarget) {\n item.columnSpan = width;\n item.rowSpan = height;\n }\n\n items.push(item);\n }\n\n return items;\n}\n\nexport function createPlaceholdersLayout(rows: number, columns: number): GridLayout {\n const layoutItems: GridLayoutItem[] = [];\n\n for (let row = 0; row < rows; row++) {\n for (let col = 0; col < columns; col++) {\n layoutItems.push({ id: `awsui-placeholder-${row}-${col}`, x: col, y: row, width: 1, height: 1 });\n }\n }\n\n return { items: layoutItems, columns, rows };\n}\n\nexport function getMinColumnSpan(item: Item, columns: number) {\n return Math.min(columns, Math.max(MIN_COL_SPAN, item.definition?.minColumnSpan ?? 0));\n}\n\nexport function getDefaultColumnSpan(item: Item, columns: number) {\n return Math.min(columns, Math.max(getMinColumnSpan(item, columns), item.definition?.defaultColumnSpan ?? 0));\n}\n\nexport function getMinRowSpan(item: Item) {\n return Math.max(MIN_ROW_SPAN, item.definition?.minRowSpan ?? 0);\n}\n\nexport function getDefaultRowSpan(item: Item) {\n return Math.max(getMinRowSpan(item), item.definition?.defaultRowSpan ?? 0);\n}\n\nfunction itemComparator(a: GridLayoutItem, b: GridLayoutItem) {\n if (a.y !== b.y) {\n return a.y > b.y ? 1 : -1;\n }\n return a.x > b.x ? 1 : -1;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../../src/internal/utils/layout.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK1D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAsB,EAAE,OAAe;IACpE,MAAM,WAAW,GAAqB,EAAE,CAAC;IACzC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7C,SAAS,aAAa,CAAC,IAAU;;QAC/B,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,UAAU,mCAAI,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,SAAS,UAAU,CAAC,IAAU;;QAC5B,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,mCAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC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E,OAAO,CAAC,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,iBAAiB,mCAAI,CAAC,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAU;;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,UAAU,mCAAI,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAU;;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,cAAc,mCAAI,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,cAAc,CAAC,CAAiB,EAAE,CAAiB;IAC1D,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACf,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3B;IACD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MIN_COL_SPAN, MIN_ROW_SPAN } from \"../constants\";\nimport { BoardItemDefinition, GridLayout, GridLayoutItem, ItemId } from \"../interfaces\";\n\ntype Item<D = unknown> = BoardItemDefinition<D>;\n\n/**\n * The function produces grid layout from board items and given number of columns.\n * The positional data is taken from the items when available or the default placement is used otherwise.\n */\nexport function interpretItems(items: readonly Item[], columns: number): GridLayout {\n const layoutItems: GridLayoutItem[] = [];\n const columnHeights = Array(columns).fill(0);\n\n function getColumnSpan(item: Item): number {\n const minColumnSpan = getMinColumnSpan(item, columns);\n const columnSpan = item.columnSpan ?? getDefaultColumnSpan(item, columns);\n return Math.min(columns, Math.max(minColumnSpan, columnSpan));\n }\n\n function getRowSpan(item: Item): number {\n const minRowSpan = getMinRowSpan(item);\n const rowSpan = item.rowSpan ?? getDefaultRowSpan(item);\n return Math.max(minRowSpan, rowSpan);\n }\n\n function getColumnOffset(item: Item, currentOffset: number): number {\n const columnSpan = getColumnSpan(item);\n const rowSpan = getRowSpan(item);\n const columnOffset = item.columnOffset?.[columns] ?? findOptimalColumnOffset(currentOffset, columnSpan, rowSpan);\n return columnOffset + columnSpan <= columns ? columnOffset : 0;\n }\n\n function findOptimalColumnOffset(currentColumnOffset: number, columnSpan: number, rowSpan: number): number {\n for (let colOffset = currentColumnOffset; colOffset + columnSpan <= columns; colOffset++) {\n if (getRowOffset(colOffset, columnSpan) + rowSpan <= getRowOffset(0, columns)) {\n return colOffset;\n }\n }\n for (let colOffset = 0; colOffset + columnSpan <= columns; colOffset++) {\n if (getRowOffset(colOffset, columnSpan) + rowSpan <= getRowOffset(0, columns)) {\n return colOffset;\n }\n }\n return currentColumnOffset;\n }\n\n function getRowOffset(columnOffset: number, columnSpan: number) {\n let rowOffset = 0;\n for (let col = columnOffset; col < columnOffset + columnSpan; col++) {\n rowOffset = Math.max(rowOffset, columnHeights[col]);\n }\n return rowOffset;\n }\n\n for (let index = 0, columnOffset = 0, rowOffset = 0; index < items.length; index++, rowOffset = 0) {\n const columnSpan = getColumnSpan(items[index]);\n const rowSpan = getRowSpan(items[index]);\n columnOffset = getColumnOffset(items[index], columnOffset);\n rowOffset = getRowOffset(columnOffset, columnSpan);\n\n layoutItems.push({ id: items[index].id, width: columnSpan, height: rowSpan, x: columnOffset, y: rowOffset });\n\n for (let col = columnOffset; col < columnOffset + columnSpan; col++) {\n columnHeights[col] = rowOffset + rowSpan;\n }\n\n columnOffset += columnSpan;\n }\n\n layoutItems.sort(itemComparator);\n\n return { items: layoutItems, columns, rows: getRowOffset(0, columns) };\n}\n\n/**\n * The function produces new items from the current state and updated grid layout.\n * The positional data for the given number of columns is preserved as is while the other layouts are partially invalidated.\n */\nexport function transformItems<D>(\n sourceItems: readonly BoardItemDefinition<D>[],\n gridLayout: GridLayout,\n resizeTarget: null | ItemId,\n): readonly BoardItemDefinition<D>[] {\n const itemById = new Map(sourceItems.map((item) => [item.id, item]));\n const getItem = (itemId: ItemId) => {\n const item = itemById.get(itemId);\n if (!item) {\n throw new Error(\"Invariant violation: no layout item matches given id.\");\n }\n return item;\n };\n\n const sortedLayout = gridLayout.items.slice().sort(itemComparator);\n\n const items: BoardItemDefinition<D>[] = [];\n\n let changeFromIndex = sortedLayout.findIndex(({ id }, index) => id !== sourceItems[index].id || id === resizeTarget);\n changeFromIndex = changeFromIndex !== -1 ? changeFromIndex : sortedLayout.length;\n\n for (let index = 0; index < sortedLayout.length; index++) {\n const { id, x, width, height } = sortedLayout[index];\n\n const item = { ...getItem(id) };\n\n if (index >= changeFromIndex) {\n item.columnOffset = undefined;\n }\n item.columnOffset = { ...item.columnOffset, [gridLayout.columns]: x };\n\n if (item.id === resizeTarget) {\n item.columnSpan = width;\n item.rowSpan = height;\n }\n\n items.push(item);\n }\n\n return items;\n}\n\nexport function createPlaceholdersLayout(rows: number, columns: number): GridLayout {\n const layoutItems: GridLayoutItem[] = [];\n\n for (let row = 0; row < rows; row++) {\n for (let col = 0; col < columns; col++) {\n layoutItems.push({ id: `awsui-placeholder-${row}-${col}`, x: col, y: row, width: 1, height: 1 });\n }\n }\n\n return { items: layoutItems, columns, rows };\n}\n\nexport function getMinColumnSpan(item: Item, columns: number) {\n return Math.min(columns, Math.max(MIN_COL_SPAN, item.definition?.minColumnSpan ?? 0));\n}\n\nexport function getDefaultColumnSpan(item: Item, columns: number) {\n return Math.min(columns, Math.max(getMinColumnSpan(item, columns), item.definition?.defaultColumnSpan ?? 0));\n}\n\nexport function getMinRowSpan(item: Item) {\n return Math.max(MIN_ROW_SPAN, item.definition?.minRowSpan ?? 0);\n}\n\nexport function getDefaultRowSpan(item: Item) {\n return Math.max(getMinRowSpan(item), item.definition?.defaultRowSpan ?? 0);\n}\n\nfunction itemComparator(a: GridLayoutItem, b: GridLayoutItem) {\n if (a.y !== b.y) {\n return a.y > b.y ? 1 : -1;\n }\n return a.x > b.x ? 1 : -1;\n}\n"]}
|
|
@@ -57,7 +57,7 @@ export function InternalItemsPalette({ items, renderItem, i18nStrings, __interna
|
|
|
57
57
|
}
|
|
58
58
|
}, item: item, placed: false, acquired: false, transform: undefined, inTransition: false, getItemSize: (dropContext) => {
|
|
59
59
|
if (!dropContext) {
|
|
60
|
-
throw new Error("Invariant violation:
|
|
60
|
+
throw new Error("Invariant violation: no drop context in palette.");
|
|
61
61
|
}
|
|
62
62
|
const { width, height } = dropContext.scale(item);
|
|
63
63
|
return { width, minWidth: width, maxWidth: width, height, minHeight: height, maxHeight: height };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/items-palette/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,YAAY,MAAM,6CAA6C,CAAC;AAEvE,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;AAGjD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,UAAU,oBAAoB,CAAI,EACtC,KAAK,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,GAAG,IAAI,EAC2C;IAClD,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAA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sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useRef, useState } from \"react\";\n\nimport { getIsRtl } from \"@cloudscape-design/component-toolkit/internal\";\nimport ColumnLayout from \"@cloudscape-design/components/column-layout\";\n\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\";\n\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 <ColumnLayout columns={3}>\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: no drop context in palette.\");\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 </ColumnLayout>\n </div>\n\n <LiveRegion>{announcement}</LiveRegion>\n </div>\n );\n}\n"]}
|
package/package.json
CHANGED
package/test-utils/dom/index.js
CHANGED
|
@@ -15,7 +15,10 @@ exports.ItemsPaletteWrapper = items_palette_1.default;
|
|
|
15
15
|
const palette_item_1 = require("./palette-item");
|
|
16
16
|
exports.PaletteItemWrapper = palette_item_1.default;
|
|
17
17
|
dom_1.ElementWrapper.prototype.findBoard = function (selector) {
|
|
18
|
-
|
|
18
|
+
let rootSelector = `.${board_1.default.rootSelector}`;
|
|
19
|
+
if ("legacyRootSelector" in board_1.default && board_1.default.legacyRootSelector) {
|
|
20
|
+
rootSelector = `:is(.${board_1.default.rootSelector}, .${board_1.default.legacyRootSelector})`;
|
|
21
|
+
}
|
|
19
22
|
// casting to 'any' is needed to avoid this issue with generics
|
|
20
23
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
21
24
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, board_1.default);
|
|
@@ -24,7 +27,10 @@ dom_1.ElementWrapper.prototype.findAllBoards = function (selector) {
|
|
|
24
27
|
return this.findAllComponents(board_1.default, selector);
|
|
25
28
|
};
|
|
26
29
|
dom_1.ElementWrapper.prototype.findBoardItem = function (selector) {
|
|
27
|
-
|
|
30
|
+
let rootSelector = `.${board_item_1.default.rootSelector}`;
|
|
31
|
+
if ("legacyRootSelector" in board_item_1.default && board_item_1.default.legacyRootSelector) {
|
|
32
|
+
rootSelector = `:is(.${board_item_1.default.rootSelector}, .${board_item_1.default.legacyRootSelector})`;
|
|
33
|
+
}
|
|
28
34
|
// casting to 'any' is needed to avoid this issue with generics
|
|
29
35
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
30
36
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, board_item_1.default);
|
|
@@ -33,7 +39,10 @@ dom_1.ElementWrapper.prototype.findAllBoardItems = function (selector) {
|
|
|
33
39
|
return this.findAllComponents(board_item_1.default, selector);
|
|
34
40
|
};
|
|
35
41
|
dom_1.ElementWrapper.prototype.findItemsPalette = function (selector) {
|
|
36
|
-
|
|
42
|
+
let rootSelector = `.${items_palette_1.default.rootSelector}`;
|
|
43
|
+
if ("legacyRootSelector" in items_palette_1.default && items_palette_1.default.legacyRootSelector) {
|
|
44
|
+
rootSelector = `:is(.${items_palette_1.default.rootSelector}, .${items_palette_1.default.legacyRootSelector})`;
|
|
45
|
+
}
|
|
37
46
|
// casting to 'any' is needed to avoid this issue with generics
|
|
38
47
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
39
48
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, items_palette_1.default);
|
|
@@ -42,7 +51,10 @@ dom_1.ElementWrapper.prototype.findAllItemsPalettes = function (selector) {
|
|
|
42
51
|
return this.findAllComponents(items_palette_1.default, selector);
|
|
43
52
|
};
|
|
44
53
|
dom_1.ElementWrapper.prototype.findPaletteItem = function (selector) {
|
|
45
|
-
|
|
54
|
+
let rootSelector = `.${palette_item_1.default.rootSelector}`;
|
|
55
|
+
if ("legacyRootSelector" in palette_item_1.default && palette_item_1.default.legacyRootSelector) {
|
|
56
|
+
rootSelector = `:is(.${palette_item_1.default.rootSelector}, .${palette_item_1.default.legacyRootSelector})`;
|
|
57
|
+
}
|
|
46
58
|
// casting to 'any' is needed to avoid this issue with generics
|
|
47
59
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
48
60
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, palette_item_1.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/test-utils/dom/index.ts"],"names":[],"mappings":";;;AACA,qEAAqE;AACrE,sCAAsC;AACtC,gEAAwE;AAG/D,+FAHA,oBAAc,OAGA;AAFvB,oEAA0E;AAI1E,mCAAmC;AAM1B,uBANF,eAAY,CAME;AALrB,6CAA4C;AAMnC,2BANF,oBAAgB,CAME;AALzB,mDAAkD;AAMzC,8BANF,uBAAmB,CAME;AAL5B,iDAAgD;AAMvC,6BANF,sBAAkB,CAME;AAqF3B,oBAAc,CAAC,SAAS,CAAC,SAAS,GAAG,UAAS,QAAQ;IACpD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/test-utils/dom/index.ts"],"names":[],"mappings":";;;AACA,qEAAqE;AACrE,sCAAsC;AACtC,gEAAwE;AAG/D,+FAHA,oBAAc,OAGA;AAFvB,oEAA0E;AAI1E,mCAAmC;AAM1B,uBANF,eAAY,CAME;AALrB,6CAA4C;AAMnC,2BANF,oBAAgB,CAME;AALzB,mDAAkD;AAMzC,8BANF,uBAAmB,CAME;AAL5B,iDAAgD;AAMvC,6BANF,sBAAkB,CAME;AAqF3B,oBAAc,CAAC,SAAS,CAAC,SAAS,GAAG,UAAS,QAAQ;IACpD,IAAI,YAAY,GAAG,IAAI,eAAY,CAAC,YAAY,EAAE,CAAC;IACnD,IAAG,oBAAoB,I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AQ,IAAI,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAC9D,OAAO,CAAC,IAAI,CAAC,2GAA2G,CAAC,CAAA;KAC1H;IAAA,CAAC;IACF,OAAO,IAAI,oBAAc,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AALD,0BAKC","sourcesContent":["\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ElementWrapper } from '@cloudscape-design/test-utils-core/dom';\nimport { appendSelector } from '@cloudscape-design/test-utils-core/utils';\n\nexport { ElementWrapper };\n\nimport BoardWrapper from './board';\nimport BoardItemWrapper from './board-item';\nimport ItemsPaletteWrapper from './items-palette';\nimport PaletteItemWrapper from './palette-item';\n\n\nexport { BoardWrapper };\nexport { BoardItemWrapper };\nexport { ItemsPaletteWrapper };\nexport { PaletteItemWrapper };\n\ndeclare module '@cloudscape-design/test-utils-core/dist/dom' {\n interface ElementWrapper {\n \n/**\n * Returns the wrapper of the first Board that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first Board.\n * If no matching Board is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {BoardWrapper | null}\n */\nfindBoard(selector?: string): BoardWrapper | null;\n\n/**\n * Returns an array of Board wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the Boards inside the current wrapper.\n * If no matching Board is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<BoardWrapper>}\n */\nfindAllBoards(selector?: string): Array<BoardWrapper>;\n/**\n * Returns the wrapper of the first BoardItem that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first BoardItem.\n * If no matching BoardItem is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {BoardItemWrapper | null}\n */\nfindBoardItem(selector?: string): BoardItemWrapper | null;\n\n/**\n * Returns an array of BoardItem wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the BoardItems inside the current wrapper.\n * If no matching BoardItem is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<BoardItemWrapper>}\n */\nfindAllBoardItems(selector?: string): Array<BoardItemWrapper>;\n/**\n * Returns the wrapper of the first ItemsPalette that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first ItemsPalette.\n * If no matching ItemsPalette is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {ItemsPaletteWrapper | null}\n */\nfindItemsPalette(selector?: string): ItemsPaletteWrapper | null;\n\n/**\n * Returns an array of ItemsPalette wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the ItemsPalettes inside the current wrapper.\n * If no matching ItemsPalette is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<ItemsPaletteWrapper>}\n */\nfindAllItemsPalettes(selector?: string): Array<ItemsPaletteWrapper>;\n/**\n * Returns the wrapper of the first PaletteItem that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first PaletteItem.\n * If no matching PaletteItem is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {PaletteItemWrapper | null}\n */\nfindPaletteItem(selector?: string): PaletteItemWrapper | null;\n\n/**\n * Returns an array of PaletteItem wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the PaletteItems inside the current wrapper.\n * If no matching PaletteItem is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<PaletteItemWrapper>}\n */\nfindAllPaletteItems(selector?: string): Array<PaletteItemWrapper>;\n }\n}\n\n\nElementWrapper.prototype.findBoard = function(selector) {\n let rootSelector = `.${BoardWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in BoardWrapper && BoardWrapper.legacyRootSelector){\n rootSelector = `:is(.${BoardWrapper.rootSelector}, .${BoardWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, BoardWrapper);\n};\n\nElementWrapper.prototype.findAllBoards = function(selector) {\n return this.findAllComponents(BoardWrapper, selector);\n};\nElementWrapper.prototype.findBoardItem = function(selector) {\n let rootSelector = `.${BoardItemWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in BoardItemWrapper && BoardItemWrapper.legacyRootSelector){\n rootSelector = `:is(.${BoardItemWrapper.rootSelector}, .${BoardItemWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, BoardItemWrapper);\n};\n\nElementWrapper.prototype.findAllBoardItems = function(selector) {\n return this.findAllComponents(BoardItemWrapper, selector);\n};\nElementWrapper.prototype.findItemsPalette = function(selector) {\n let rootSelector = `.${ItemsPaletteWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in ItemsPaletteWrapper && ItemsPaletteWrapper.legacyRootSelector){\n rootSelector = `:is(.${ItemsPaletteWrapper.rootSelector}, .${ItemsPaletteWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ItemsPaletteWrapper);\n};\n\nElementWrapper.prototype.findAllItemsPalettes = function(selector) {\n return this.findAllComponents(ItemsPaletteWrapper, selector);\n};\nElementWrapper.prototype.findPaletteItem = function(selector) {\n let rootSelector = `.${PaletteItemWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in PaletteItemWrapper && PaletteItemWrapper.legacyRootSelector){\n rootSelector = `:is(.${PaletteItemWrapper.rootSelector}, .${PaletteItemWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, PaletteItemWrapper);\n};\n\nElementWrapper.prototype.findAllPaletteItems = function(selector) {\n return this.findAllComponents(PaletteItemWrapper, selector);\n};\n\n\nexport default function wrapper(root: Element = document.body) {\n if (document && document.body && !document.body.contains(root)) {\n console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly')\n };\n return new ElementWrapper(root);\n}\n"]}
|
|
@@ -15,7 +15,10 @@ exports.ItemsPaletteWrapper = items_palette_1.default;
|
|
|
15
15
|
const palette_item_1 = require("./palette-item");
|
|
16
16
|
exports.PaletteItemWrapper = palette_item_1.default;
|
|
17
17
|
selectors_1.ElementWrapper.prototype.findBoard = function (selector) {
|
|
18
|
-
|
|
18
|
+
let rootSelector = `.${board_1.default.rootSelector}`;
|
|
19
|
+
if ("legacyRootSelector" in board_1.default && board_1.default.legacyRootSelector) {
|
|
20
|
+
rootSelector = `:is(.${board_1.default.rootSelector}, .${board_1.default.legacyRootSelector})`;
|
|
21
|
+
}
|
|
19
22
|
// casting to 'any' is needed to avoid this issue with generics
|
|
20
23
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
21
24
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, board_1.default);
|
|
@@ -24,7 +27,10 @@ selectors_1.ElementWrapper.prototype.findAllBoards = function (selector) {
|
|
|
24
27
|
return this.findAllComponents(board_1.default, selector);
|
|
25
28
|
};
|
|
26
29
|
selectors_1.ElementWrapper.prototype.findBoardItem = function (selector) {
|
|
27
|
-
|
|
30
|
+
let rootSelector = `.${board_item_1.default.rootSelector}`;
|
|
31
|
+
if ("legacyRootSelector" in board_item_1.default && board_item_1.default.legacyRootSelector) {
|
|
32
|
+
rootSelector = `:is(.${board_item_1.default.rootSelector}, .${board_item_1.default.legacyRootSelector})`;
|
|
33
|
+
}
|
|
28
34
|
// casting to 'any' is needed to avoid this issue with generics
|
|
29
35
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
30
36
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, board_item_1.default);
|
|
@@ -33,7 +39,10 @@ selectors_1.ElementWrapper.prototype.findAllBoardItems = function (selector) {
|
|
|
33
39
|
return this.findAllComponents(board_item_1.default, selector);
|
|
34
40
|
};
|
|
35
41
|
selectors_1.ElementWrapper.prototype.findItemsPalette = function (selector) {
|
|
36
|
-
|
|
42
|
+
let rootSelector = `.${items_palette_1.default.rootSelector}`;
|
|
43
|
+
if ("legacyRootSelector" in items_palette_1.default && items_palette_1.default.legacyRootSelector) {
|
|
44
|
+
rootSelector = `:is(.${items_palette_1.default.rootSelector}, .${items_palette_1.default.legacyRootSelector})`;
|
|
45
|
+
}
|
|
37
46
|
// casting to 'any' is needed to avoid this issue with generics
|
|
38
47
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
39
48
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, items_palette_1.default);
|
|
@@ -42,7 +51,10 @@ selectors_1.ElementWrapper.prototype.findAllItemsPalettes = function (selector)
|
|
|
42
51
|
return this.findAllComponents(items_palette_1.default, selector);
|
|
43
52
|
};
|
|
44
53
|
selectors_1.ElementWrapper.prototype.findPaletteItem = function (selector) {
|
|
45
|
-
|
|
54
|
+
let rootSelector = `.${palette_item_1.default.rootSelector}`;
|
|
55
|
+
if ("legacyRootSelector" in palette_item_1.default && palette_item_1.default.legacyRootSelector) {
|
|
56
|
+
rootSelector = `:is(.${palette_item_1.default.rootSelector}, .${palette_item_1.default.legacyRootSelector})`;
|
|
57
|
+
}
|
|
46
58
|
// casting to 'any' is needed to avoid this issue with generics
|
|
47
59
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
48
60
|
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, palette_item_1.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/test-utils/selectors/index.ts"],"names":[],"mappings":";;;AACA,qEAAqE;AAC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,iBAAiB,CAAC,uBAAmB,EAAE,QAAQ,CAAC,CAAC;AAC/D,CAAC,CAAC;AACF,0BAAc,CAAC,SAAS,CAAC,eAAe,GAAG,UAAS,QAAQ;IAC1D,IAAI,YAAY,GAAG,IAAI,sBAAkB,CAAC,YAAY,EAAE,CAAC;IACzD,IAAG,oBAAoB,IAAI,sBAAkB,IAAI,sBAAkB,CAAC,kBAAkB,EAAC;QACrF,YAAY,GAAG,QAAQ,sBAAkB,CAAC,YAAY,MAAM,sBAAkB,CAAC,kBAAkB,GAAG,CAAC;KACtG;IACD,+DAA+D;IAC/D,uDAAuD;IACvD,OAAQ,IAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,sBAAkB,CAAC,CAAC;AAC3H,CAAC,CAAC;AAEF,0BAAc,CAAC,SAAS,CAAC,mBAAmB,GAAG,UAAS,QAAQ;IAC9D,OAAO,IAAI,CAAC,iBAAiB,CAAC,sBAAkB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC,CAAC;AAGF,SAAwB,OAAO,CAAC,OAAe,MAAM;IACnD,OAAO,IAAI,0BAAc,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAFD,0BAEC","sourcesContent":["\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ElementWrapper } from '@cloudscape-design/test-utils-core/selectors';\nimport { appendSelector } from '@cloudscape-design/test-utils-core/utils';\n\nexport { ElementWrapper };\n\nimport BoardWrapper from './board';\nimport BoardItemWrapper from './board-item';\nimport ItemsPaletteWrapper from './items-palette';\nimport PaletteItemWrapper from './palette-item';\n\n\nexport { BoardWrapper };\nexport { BoardItemWrapper };\nexport { ItemsPaletteWrapper };\nexport { PaletteItemWrapper };\n\ndeclare module '@cloudscape-design/test-utils-core/dist/selectors' {\n interface ElementWrapper {\n \n/**\n * Returns a wrapper that matches the Boards with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches Boards.\n *\n * @param {string} [selector] CSS Selector\n * @returns {BoardWrapper}\n */\nfindBoard(selector?: string): BoardWrapper;\n\n/**\n * Returns a multi-element wrapper that matches Boards with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches Boards.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<BoardWrapper>}\n */\nfindAllBoards(selector?: string): MultiElementWrapper<BoardWrapper>;\n/**\n * Returns a wrapper that matches the BoardItems with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches BoardItems.\n *\n * @param {string} [selector] CSS Selector\n * @returns {BoardItemWrapper}\n */\nfindBoardItem(selector?: string): BoardItemWrapper;\n\n/**\n * Returns a multi-element wrapper that matches BoardItems with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches BoardItems.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<BoardItemWrapper>}\n */\nfindAllBoardItems(selector?: string): MultiElementWrapper<BoardItemWrapper>;\n/**\n * Returns a wrapper that matches the ItemsPalettes with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches ItemsPalettes.\n *\n * @param {string} [selector] CSS Selector\n * @returns {ItemsPaletteWrapper}\n */\nfindItemsPalette(selector?: string): ItemsPaletteWrapper;\n\n/**\n * Returns a multi-element wrapper that matches ItemsPalettes with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches ItemsPalettes.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<ItemsPaletteWrapper>}\n */\nfindAllItemsPalettes(selector?: string): MultiElementWrapper<ItemsPaletteWrapper>;\n/**\n * Returns a wrapper that matches the PaletteItems with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches PaletteItems.\n *\n * @param {string} [selector] CSS Selector\n * @returns {PaletteItemWrapper}\n */\nfindPaletteItem(selector?: string): PaletteItemWrapper;\n\n/**\n * Returns a multi-element wrapper that matches PaletteItems with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches PaletteItems.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<PaletteItemWrapper>}\n */\nfindAllPaletteItems(selector?: string): MultiElementWrapper<PaletteItemWrapper>;\n }\n}\n\n\nElementWrapper.prototype.findBoard = function(selector) {\n let rootSelector = `.${BoardWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in BoardWrapper && BoardWrapper.legacyRootSelector){\n rootSelector = `:is(.${BoardWrapper.rootSelector}, .${BoardWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, BoardWrapper);\n};\n\nElementWrapper.prototype.findAllBoards = function(selector) {\n return this.findAllComponents(BoardWrapper, selector);\n};\nElementWrapper.prototype.findBoardItem = function(selector) {\n let rootSelector = `.${BoardItemWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in BoardItemWrapper && BoardItemWrapper.legacyRootSelector){\n rootSelector = `:is(.${BoardItemWrapper.rootSelector}, .${BoardItemWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, BoardItemWrapper);\n};\n\nElementWrapper.prototype.findAllBoardItems = function(selector) {\n return this.findAllComponents(BoardItemWrapper, selector);\n};\nElementWrapper.prototype.findItemsPalette = function(selector) {\n let rootSelector = `.${ItemsPaletteWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in ItemsPaletteWrapper && ItemsPaletteWrapper.legacyRootSelector){\n rootSelector = `:is(.${ItemsPaletteWrapper.rootSelector}, .${ItemsPaletteWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ItemsPaletteWrapper);\n};\n\nElementWrapper.prototype.findAllItemsPalettes = function(selector) {\n return this.findAllComponents(ItemsPaletteWrapper, selector);\n};\nElementWrapper.prototype.findPaletteItem = function(selector) {\n let rootSelector = `.${PaletteItemWrapper.rootSelector}`;\n if(\"legacyRootSelector\" in PaletteItemWrapper && PaletteItemWrapper.legacyRootSelector){\n rootSelector = `:is(.${PaletteItemWrapper.rootSelector}, .${PaletteItemWrapper.legacyRootSelector})`;\n }\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, PaletteItemWrapper);\n};\n\nElementWrapper.prototype.findAllPaletteItems = function(selector) {\n return this.findAllComponents(PaletteItemWrapper, selector);\n};\n\n\nexport default function wrapper(root: string = 'body') {\n return new ElementWrapper(root);\n}\n"]}
|