@cloudscape-design/board-components 3.0.119 → 3.0.121
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/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 +5 -5
package/board/internal.js
CHANGED
|
@@ -128,10 +128,8 @@ export function InternalBoard({ items, renderItem, onItemsChange, empty, i18nStr
|
|
|
128
128
|
useDragSubscription("submit", () => {
|
|
129
129
|
dispatch({ type: "submit" });
|
|
130
130
|
autoScrollHandlers.stop();
|
|
131
|
-
if (!transition
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
if (!transition.layoutShift ||
|
|
131
|
+
if (!transition ||
|
|
132
|
+
!transition.layoutShift ||
|
|
135
133
|
transition.layoutShift.conflicts.length > 0 ||
|
|
136
134
|
transition.layoutShift.moves.length === 0) {
|
|
137
135
|
return null;
|
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,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE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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 { ReactNode, useEffect, useRef } from \"react\";\nimport { usePrevious } from \"@dnd-kit/utilities\";\nimport clsx from \"clsx\";\n\nimport { getIsRtl, useMergeRefs } from \"@cloudscape-design/component-toolkit/internal\";\n\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 { BoardProps } from \"./interfaces\";\nimport Placeholder from \"./placeholder\";\nimport { selectTransitionRows, useTransition } from \"./transition\";\nimport { announcementToString } from \"./utils/announcements\";\nimport { createTransforms } from \"./utils/create-transforms\";\nimport { createItemsChangeEvent } from \"./utils/events\";\n\nimport styles from \"./styles.css.js\";\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 focusNextRenderIdRef = useRef<null | ItemId>(null);\n useEffect(() => {\n const focusTarget = focusNextRenderIdRef.current;\n if (focusTarget) {\n itemContainerRef.current[focusTarget].focusDragHandle();\n }\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 const newItems = createItemsChangeEvent(items, removeTransition.layoutShift);\n const itemIdToFocus = newItems.detail.items[nextIndexToFocus]?.id;\n\n if (itemIdToFocus) {\n itemContainerRef.current[itemIdToFocus].focusDragHandle();\n }\n onItemsChange(newItems);\n }, TRANSITION_DURATION_MS);\n\n return () => clearTimeout(timeoutId);\n }, [removeTransition, items, onItemsChange]);\n\n // When item is inserting with the keyboard it keeps rendering by the palette and upon submission\n // it starts rendering by the board. This transitions might lead to the focus being lost from the item's drag handle.\n // The below code refocuses the drag handle when detecting the acquired item is no longer used.\n const acquiredItemId = usePrevious(acquiredItem?.id);\n const previousAcquiredItemElement = usePrevious(acquiredItemElement);\n useEffect(() => {\n if (acquiredItemId && previousAcquiredItemElement && !acquiredItemElement) {\n itemContainerRef.current[acquiredItemId]?.focusDragHandle();\n }\n }, [acquiredItemId, previousAcquiredItemElement, acquiredItemElement]);\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.run();\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.stop();\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.stop();\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 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"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/board/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAEvF,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,CA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AW,EAAE,GAAG,EAAE,CAAC,CAAC;oCAClB,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;oCAC3C,QAAQ,EAAE,WAAW,CAAC,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 { ReactNode, useEffect, useRef } from \"react\";\nimport { usePrevious } from \"@dnd-kit/utilities\";\nimport clsx from \"clsx\";\n\nimport { getIsRtl, useMergeRefs } from \"@cloudscape-design/component-toolkit/internal\";\n\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 { BoardProps } from \"./interfaces\";\nimport Placeholder from \"./placeholder\";\nimport { selectTransitionRows, useTransition } from \"./transition\";\nimport { announcementToString } from \"./utils/announcements\";\nimport { createTransforms } from \"./utils/create-transforms\";\nimport { createItemsChangeEvent } from \"./utils/events\";\n\nimport styles from \"./styles.css.js\";\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 focusNextRenderIdRef = useRef<null | ItemId>(null);\n useEffect(() => {\n const focusTarget = focusNextRenderIdRef.current;\n if (focusTarget) {\n itemContainerRef.current[focusTarget].focusDragHandle();\n }\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 const newItems = createItemsChangeEvent(items, removeTransition.layoutShift);\n const itemIdToFocus = newItems.detail.items[nextIndexToFocus]?.id;\n\n if (itemIdToFocus) {\n itemContainerRef.current[itemIdToFocus].focusDragHandle();\n }\n onItemsChange(newItems);\n }, TRANSITION_DURATION_MS);\n\n return () => clearTimeout(timeoutId);\n }, [removeTransition, items, onItemsChange]);\n\n // When item is inserting with the keyboard it keeps rendering by the palette and upon submission\n // it starts rendering by the board. This transitions might lead to the focus being lost from the item's drag handle.\n // The below code refocuses the drag handle when detecting the acquired item is no longer used.\n const acquiredItemId = usePrevious(acquiredItem?.id);\n const previousAcquiredItemElement = usePrevious(acquiredItemElement);\n useEffect(() => {\n if (acquiredItemId && previousAcquiredItemElement && !acquiredItemElement) {\n itemContainerRef.current[acquiredItemId]?.focusDragHandle();\n }\n }, [acquiredItemId, previousAcquiredItemElement, acquiredItemElement]);\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.run();\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.stop();\n\n if (\n !transition ||\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.stop();\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 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"]}
|
package/board/transition.js
CHANGED
|
@@ -92,7 +92,7 @@ function submitTransition(state) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
if (!transition) {
|
|
95
|
-
|
|
95
|
+
return { transition: null, removeTransition: null, announcement: null };
|
|
96
96
|
}
|
|
97
97
|
const { operation, itemsLayout, draggableItem: item, acquiredItem } = transition;
|
|
98
98
|
const itemBelongsToBoard = item.id === (acquiredItem === null || acquiredItem === void 0 ? void 0 : acquiredItem.id) || itemsLayout.items.some((it) => it.id === item.id);
|
|
@@ -111,10 +111,10 @@ function submitTransition(state) {
|
|
|
111
111
|
function discardTransition(state) {
|
|
112
112
|
const { transition, removeTransition } = state;
|
|
113
113
|
if (removeTransition) {
|
|
114
|
-
throw new Error("
|
|
114
|
+
throw new Error("Invariant violation: can't discard remove transition.");
|
|
115
115
|
}
|
|
116
116
|
if (!transition) {
|
|
117
|
-
|
|
117
|
+
return { transition: null, removeTransition: null, announcement: null };
|
|
118
118
|
}
|
|
119
119
|
const { operation, itemsLayout, draggableItem: item, acquiredItem } = transition;
|
|
120
120
|
const itemBelongsToBoard = item.id === (acquiredItem === null || acquiredItem === void 0 ? void 0 : acquiredItem.id) || itemsLayout.items.some((it) => it.id === item.id);
|
|
@@ -128,7 +128,7 @@ function updateTransitionWithPointerEvent(state, { collisionIds, positionOffset,
|
|
|
128
128
|
var _a, _b, _c;
|
|
129
129
|
const { transition } = state;
|
|
130
130
|
if (!transition) {
|
|
131
|
-
|
|
131
|
+
return { transition: null, removeTransition: null, announcement: null };
|
|
132
132
|
}
|
|
133
133
|
const layout = (_b = (_a = transition.layoutShift) === null || _a === void 0 ? void 0 : _a.next) !== null && _b !== void 0 ? _b : transition.itemsLayout;
|
|
134
134
|
const layoutItem = layout.items.find((it) => it.id === transition.draggableItem.id);
|
|
@@ -171,7 +171,7 @@ function updateTransitionWithPointerEvent(state, { collisionIds, positionOffset,
|
|
|
171
171
|
function updateTransitionWithKeyboardEvent(state, { direction }, { isRtl }) {
|
|
172
172
|
const { transition } = state;
|
|
173
173
|
if (!transition) {
|
|
174
|
-
|
|
174
|
+
return { transition: null, removeTransition: null, announcement: null };
|
|
175
175
|
}
|
|
176
176
|
const updateManualItemTransition = (transition, direction) => {
|
|
177
177
|
var _a, _b;
|
|
@@ -218,7 +218,7 @@ function updateTransitionWithKeyboardEvent(state, { direction }, { isRtl }) {
|
|
|
218
218
|
function acquireTransitionItem(state, { position, layoutElement, acquiredItemElement }) {
|
|
219
219
|
const { transition } = state;
|
|
220
220
|
if (!transition) {
|
|
221
|
-
|
|
221
|
+
return { transition: null, removeTransition: null, announcement: null };
|
|
222
222
|
}
|
|
223
223
|
const { columns } = transition.itemsLayout;
|
|
224
224
|
const layoutRect = getLogicalBoundingClientRect(layoutElement);
|
package/board/transition.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition.js","sourceRoot":"","sources":["../../../src/board/transition.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAuB,UAAU,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAI7F,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7G,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAuDhE,MAAM,UAAU,aAAa,CAAI,EAAE,KAAK,EAA4B;IAClE,OAAO,UAAU,CAAC,uBAAuB,CAAI,EAAE,KAA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":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Dispatch, ReactNode, useReducer } from \"react\";\n\nimport { getLogicalBoundingClientRect } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { InteractionType, Operation } from \"../internal/dnd-controller/controller\";\nimport { BoardItemDefinitionBase, Direction, GridLayout, ItemId, Rect } from \"../internal/interfaces\";\nimport { LayoutEngine } from \"../internal/layout-engine/engine\";\nimport { Coordinates } from \"../internal/utils/coordinates\";\nimport { getDefaultColumnSpan, getDefaultRowSpan, getMinColumnSpan, getMinRowSpan } from \"../internal/utils/layout\";\nimport { Position } from \"../internal/utils/position\";\nimport { BoardProps, RemoveTransition, Transition, TransitionAnnouncement } from \"./interfaces\";\nimport { createOperationAnnouncement } from \"./utils/announcements\";\nimport { getHoveredRect } from \"./utils/get-hovered-rect\";\nimport { getInsertionDirection, getLayoutPlaceholders, getLayoutRows, getLayoutShift } from \"./utils/layout\";\nimport { appendMovePath, appendResizePath } from \"./utils/path\";\n\nexport interface TransitionState<D> {\n transition: null | Transition<D>;\n removeTransition: null | RemoveTransition<D>;\n announcement: null | TransitionAnnouncement;\n}\n\nexport type Action<D> =\n | InitAction<D>\n | InitRemoveAction<D>\n | SubmitAction\n | DiscardAction\n | UpdateWithPointerAction\n | UpdateWithKeyboardAction\n | AcquireItemAction;\n\ninterface InitAction<D> {\n type: \"init\";\n operation: Operation;\n interactionType: InteractionType;\n itemsLayout: GridLayout;\n draggableItem: BoardItemDefinitionBase<D>;\n draggableRect: Rect;\n collisionIds: readonly ItemId[];\n}\ninterface InitRemoveAction<D> {\n type: \"init-remove\";\n items: readonly BoardProps.Item<D>[];\n removedItem: BoardItemDefinitionBase<D>;\n itemsLayout: GridLayout;\n}\ninterface SubmitAction {\n type: \"submit\";\n}\ninterface DiscardAction {\n type: \"discard\";\n}\ninterface UpdateWithPointerAction {\n type: \"update-with-pointer\";\n collisionIds: readonly ItemId[];\n positionOffset: Coordinates;\n draggableRect: Rect;\n}\ninterface UpdateWithKeyboardAction {\n type: \"update-with-keyboard\";\n direction: Direction;\n}\ninterface AcquireItemAction {\n type: \"acquire-item\";\n position: Position;\n layoutElement: HTMLElement;\n acquiredItemElement?: ReactNode;\n}\n\nexport function useTransition<D>({ isRtl }: { isRtl: () => boolean }): [TransitionState<D>, Dispatch<Action<D>>] {\n return useReducer(createTransitionReducer<D>({ isRtl }), {\n transition: null,\n removeTransition: null,\n announcement: null,\n });\n}\n\nexport function selectTransitionRows<D>(state: TransitionState<D>) {\n return state.transition ? getLayoutRows(state.transition) : 0;\n}\n\nfunction createTransitionReducer<D>({ isRtl }: { isRtl: () => boolean }) {\n return function transitionReducer(state: TransitionState<D>, action: Action<D>): TransitionState<D> {\n switch (action.type) {\n case \"init\":\n return initTransition(action);\n case \"init-remove\":\n return initRemoveTransition(action);\n case \"submit\":\n return submitTransition(state);\n case \"discard\":\n return discardTransition(state);\n case \"update-with-pointer\":\n return updateTransitionWithPointerEvent(state, action);\n case \"update-with-keyboard\":\n return updateTransitionWithKeyboardEvent(state, action, { isRtl });\n case \"acquire-item\":\n return acquireTransitionItem(state, action);\n }\n };\n}\n\nfunction initTransition<D>({\n operation,\n interactionType,\n itemsLayout,\n draggableItem,\n draggableRect,\n collisionIds,\n}: InitAction<D>): TransitionState<D> {\n const transition: Transition<D> = {\n operation,\n interactionType,\n itemsLayout,\n layoutEngine: new LayoutEngine(itemsLayout),\n insertionDirection: null,\n draggableItem,\n draggableRect,\n acquiredItem: null,\n collisionIds: new Set(),\n layoutShift: null,\n path: [],\n };\n\n const placeholdersLayout = getLayoutPlaceholders(transition);\n\n const layoutItem = itemsLayout.items.find((it) => it.id === draggableItem.id);\n\n let path: Position[] = [];\n if (interactionType === \"pointer\" || operation === \"insert\") {\n const collisionRect = getHoveredRect(collisionIds, placeholdersLayout.items);\n const appendPath = operation === \"resize\" ? appendResizePath : appendMovePath;\n path = layoutItem ? appendPath([], collisionRect) : [];\n } else if (layoutItem) {\n path =\n operation === \"resize\"\n ? [new Position({ x: layoutItem.x + layoutItem.width, y: layoutItem.y + layoutItem.height })]\n : [new Position({ x: layoutItem.x, y: layoutItem.y })];\n }\n\n return {\n transition: { ...transition, path },\n removeTransition: null,\n announcement: layoutItem ? { type: \"dnd-started\", item: draggableItem, operation } : null,\n };\n}\n\nfunction initRemoveTransition<D>({ items, removedItem, itemsLayout }: InitRemoveAction<D>): TransitionState<D> {\n const layoutShift = new LayoutEngine(itemsLayout).remove(removedItem.id);\n const removeTransition: RemoveTransition<D> = { items, removedItem, layoutShift };\n return { transition: null, removeTransition, announcement: null };\n}\n\nfunction submitTransition<D>(state: TransitionState<D>): TransitionState<D> {\n const { transition, removeTransition } = state;\n\n if (removeTransition) {\n const disturbed = new Set(removeTransition.layoutShift.moves.map((move) => move.itemId));\n disturbed.delete(removeTransition.removedItem.id);\n return {\n transition: null,\n removeTransition: null,\n announcement: { type: \"item-removed\", item: removeTransition.removedItem, disturbed },\n };\n }\n\n if (!transition) {\n throw new Error(\"Invariant violation: no transition.\");\n }\n\n const { operation, itemsLayout, draggableItem: item, acquiredItem } = transition;\n const itemBelongsToBoard = item.id === acquiredItem?.id || itemsLayout.items.some((it) => it.id === item.id);\n\n return transition.layoutShift?.conflicts.length === 0\n ? {\n transition: null,\n removeTransition: null,\n announcement: itemBelongsToBoard ? { type: \"dnd-committed\", item, operation } : null,\n }\n : {\n transition: null,\n removeTransition: null,\n announcement: itemBelongsToBoard ? { type: \"dnd-discarded\", item, operation } : null,\n };\n}\n\nfunction discardTransition<D>(state: TransitionState<D>): TransitionState<D> {\n const { transition, removeTransition } = state;\n\n if (removeTransition) {\n throw new Error(\"Can't discard remove transition.\");\n }\n\n if (!transition) {\n throw new Error(\"Invariant violation: no transition.\");\n }\n\n const { operation, itemsLayout, draggableItem: item, acquiredItem } = transition;\n const itemBelongsToBoard = item.id === acquiredItem?.id || itemsLayout.items.some((it) => it.id === item.id);\n\n return {\n transition: null,\n removeTransition: null,\n announcement: itemBelongsToBoard ? { type: \"dnd-discarded\", item, operation } : null,\n };\n}\n\nfunction updateTransitionWithPointerEvent<D>(\n state: TransitionState<D>,\n { collisionIds, positionOffset, draggableRect }: UpdateWithPointerAction,\n): TransitionState<D> {\n const { transition } = state;\n\n if (!transition) {\n throw new Error(\"Invariant violation: no transition.\");\n }\n\n const layout = transition.layoutShift?.next ?? transition.itemsLayout;\n const layoutItem = layout.items.find((it) => it.id === transition.draggableItem.id);\n const itemWidth = layoutItem ? layoutItem.width : getDefaultColumnSpan(transition.draggableItem, layout.columns);\n const itemHeight = layoutItem ? layoutItem.height : getDefaultRowSpan(transition.draggableItem);\n const itemSize = itemWidth * itemHeight;\n\n const isOutOfBoundaries =\n transition.operation !== \"resize\" ? collisionIds.length < itemSize : collisionIds.length === 0;\n\n if (isOutOfBoundaries) {\n return {\n transition: {\n ...transition,\n draggableRect,\n collisionIds: new Set(),\n layoutShift: null,\n insertionDirection: null,\n },\n removeTransition: null,\n announcement: null,\n };\n }\n\n const placeholdersLayout = getLayoutPlaceholders(transition);\n const collisionRect = getHoveredRect(collisionIds, placeholdersLayout.items);\n const appendPath = transition.operation === \"resize\" ? appendResizePath : appendMovePath;\n const path = appendPath(transition.path, collisionRect);\n\n const insertionDirection = transition.insertionDirection ?? getInsertionDirection(positionOffset);\n const layoutShift = getLayoutShift(transition, path, insertionDirection);\n\n return {\n transition: {\n ...transition,\n draggableRect,\n collisionIds: new Set(collisionIds),\n layoutShift,\n path,\n insertionDirection,\n },\n removeTransition: null,\n announcement: null,\n };\n}\n\nfunction updateTransitionWithKeyboardEvent<D>(\n state: TransitionState<D>,\n { direction }: UpdateWithKeyboardAction,\n { isRtl }: { isRtl: () => boolean },\n): TransitionState<D> {\n const { transition } = state;\n\n if (!transition) {\n throw new Error(\"Invariant violation: no transition.\");\n }\n\n const updateManualItemTransition = (transition: Transition<D>, direction: Direction): TransitionState<D> => {\n const xDelta = direction === \"left\" ? -1 : direction === \"right\" ? 1 : 0;\n const yDelta = direction === \"up\" ? -1 : direction === \"down\" ? 1 : 0;\n const lastPosition = transition.path[transition.path.length - 1];\n const nextPosition = new Position({ x: lastPosition.x + xDelta, y: lastPosition.y + yDelta });\n const nextPath = [...transition.path, nextPosition];\n\n // Check resizing below min size.\n const layout = transition.layoutShift?.next ?? transition.itemsLayout;\n const layoutItem = layout.items.find((it) => it.id === transition.draggableItem.id);\n const minWidth = getMinColumnSpan(transition.draggableItem, transition.itemsLayout.columns);\n const minHeight = getMinRowSpan(transition.draggableItem);\n if (\n transition.operation === \"resize\" &&\n layoutItem &&\n (layoutItem.width + xDelta < minWidth || layoutItem.height + yDelta < minHeight)\n ) {\n return state;\n }\n\n try {\n const layoutShift = getLayoutShift(transition, nextPath);\n const nextTransition = { ...transition, layoutShift, path: nextPath };\n return {\n transition: nextTransition,\n removeTransition: null,\n announcement: createOperationAnnouncement(nextTransition, direction),\n };\n } catch (e) {\n // Can't create next layout because the next path is out of bounds.\n return state;\n }\n };\n\n switch (direction) {\n case \"left\":\n return updateManualItemTransition(transition, !isRtl() ? \"left\" : \"right\");\n case \"right\":\n return updateManualItemTransition(transition, !isRtl() ? \"right\" : \"left\");\n case \"up\":\n return updateManualItemTransition(transition, \"up\");\n case \"down\":\n return updateManualItemTransition(transition, \"down\");\n }\n}\n\nfunction acquireTransitionItem<D>(\n state: TransitionState<D>,\n { position, layoutElement, acquiredItemElement }: AcquireItemAction,\n): TransitionState<D> {\n const { transition } = state;\n\n if (!transition) {\n throw new Error(\"Invariant violation: no transition.\");\n }\n\n const { columns } = transition.itemsLayout;\n\n const layoutRect = getLogicalBoundingClientRect(layoutElement);\n const itemRect = transition.draggableRect;\n const coordinatesX = itemRect.left - layoutRect.insetInlineStart;\n const offset = new Coordinates({ x: coordinatesX, y: itemRect.top - layoutRect.insetBlockStart });\n const insertionDirection = getInsertionDirection(offset);\n\n // Update original insertion position if the item can't fit into the layout by width.\n const width = getDefaultColumnSpan(transition.draggableItem, columns);\n position = new Position({ x: Math.min(columns - width, position.x), y: position.y });\n\n const path = [...transition.path, position];\n\n const layoutShift = getLayoutShift(transition, path, insertionDirection);\n\n // The columnOffset, columnSpan and rowSpan are of no use as of being overridden by the layout shift.\n const acquiredItem = { ...transition.draggableItem, columnOffset: 0, columnSpan: 1, rowSpan: 1 };\n\n const nextTransition: Transition<D> = {\n ...transition,\n collisionIds: new Set(),\n layoutShift,\n path,\n acquiredItem,\n acquiredItemElement,\n };\n return {\n transition: nextTransition,\n removeTransition: null,\n announcement: createOperationAnnouncement(nextTransition, null),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transition.js","sourceRoot":"","sources":["../../../src/board/transition.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAuB,UAAU,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAI7F,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7G,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAuDhE,MAAM,UAAU,aAAa,CAAI,EAAE,KAAK,EAA4B;IAClE,OAAO,UAAU,CAAC,uBAAuB,CAAI,EAAE,KAAK,EAAE,CAAC,EAAE;QACvD,UAAU,EAAE,IAAI;QAChB,gBAAgB,EAAE,IA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ACZ,mBAAmB;KACpB,CAAC;IACF,OAAO;QACL,UAAU,EAAE,cAAc;QAC1B,gBAAgB,EAAE,IAAI;QACtB,YAAY,EAAE,2BAA2B,CAAC,cAAc,EAAE,IAAI,CAAC;KAChE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Dispatch, ReactNode, useReducer } from \"react\";\n\nimport { getLogicalBoundingClientRect } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { InteractionType, Operation } from \"../internal/dnd-controller/controller\";\nimport { BoardItemDefinitionBase, Direction, GridLayout, ItemId, Rect } from \"../internal/interfaces\";\nimport { LayoutEngine } from \"../internal/layout-engine/engine\";\nimport { Coordinates } from \"../internal/utils/coordinates\";\nimport { getDefaultColumnSpan, getDefaultRowSpan, getMinColumnSpan, getMinRowSpan } from \"../internal/utils/layout\";\nimport { Position } from \"../internal/utils/position\";\nimport { BoardProps, RemoveTransition, Transition, TransitionAnnouncement } from \"./interfaces\";\nimport { createOperationAnnouncement } from \"./utils/announcements\";\nimport { getHoveredRect } from \"./utils/get-hovered-rect\";\nimport { getInsertionDirection, getLayoutPlaceholders, getLayoutRows, getLayoutShift } from \"./utils/layout\";\nimport { appendMovePath, appendResizePath } from \"./utils/path\";\n\nexport interface TransitionState<D> {\n transition: null | Transition<D>;\n removeTransition: null | RemoveTransition<D>;\n announcement: null | TransitionAnnouncement;\n}\n\nexport type Action<D> =\n | InitAction<D>\n | InitRemoveAction<D>\n | SubmitAction\n | DiscardAction\n | UpdateWithPointerAction\n | UpdateWithKeyboardAction\n | AcquireItemAction;\n\ninterface InitAction<D> {\n type: \"init\";\n operation: Operation;\n interactionType: InteractionType;\n itemsLayout: GridLayout;\n draggableItem: BoardItemDefinitionBase<D>;\n draggableRect: Rect;\n collisionIds: readonly ItemId[];\n}\ninterface InitRemoveAction<D> {\n type: \"init-remove\";\n items: readonly BoardProps.Item<D>[];\n removedItem: BoardItemDefinitionBase<D>;\n itemsLayout: GridLayout;\n}\ninterface SubmitAction {\n type: \"submit\";\n}\ninterface DiscardAction {\n type: \"discard\";\n}\ninterface UpdateWithPointerAction {\n type: \"update-with-pointer\";\n collisionIds: readonly ItemId[];\n positionOffset: Coordinates;\n draggableRect: Rect;\n}\ninterface UpdateWithKeyboardAction {\n type: \"update-with-keyboard\";\n direction: Direction;\n}\ninterface AcquireItemAction {\n type: \"acquire-item\";\n position: Position;\n layoutElement: HTMLElement;\n acquiredItemElement?: ReactNode;\n}\n\nexport function useTransition<D>({ isRtl }: { isRtl: () => boolean }): [TransitionState<D>, Dispatch<Action<D>>] {\n return useReducer(createTransitionReducer<D>({ isRtl }), {\n transition: null,\n removeTransition: null,\n announcement: null,\n });\n}\n\nexport function selectTransitionRows<D>(state: TransitionState<D>) {\n return state.transition ? getLayoutRows(state.transition) : 0;\n}\n\nfunction createTransitionReducer<D>({ isRtl }: { isRtl: () => boolean }) {\n return function transitionReducer(state: TransitionState<D>, action: Action<D>): TransitionState<D> {\n switch (action.type) {\n case \"init\":\n return initTransition(action);\n case \"init-remove\":\n return initRemoveTransition(action);\n case \"submit\":\n return submitTransition(state);\n case \"discard\":\n return discardTransition(state);\n case \"update-with-pointer\":\n return updateTransitionWithPointerEvent(state, action);\n case \"update-with-keyboard\":\n return updateTransitionWithKeyboardEvent(state, action, { isRtl });\n case \"acquire-item\":\n return acquireTransitionItem(state, action);\n }\n };\n}\n\nfunction initTransition<D>({\n operation,\n interactionType,\n itemsLayout,\n draggableItem,\n draggableRect,\n collisionIds,\n}: InitAction<D>): TransitionState<D> {\n const transition: Transition<D> = {\n operation,\n interactionType,\n itemsLayout,\n layoutEngine: new LayoutEngine(itemsLayout),\n insertionDirection: null,\n draggableItem,\n draggableRect,\n acquiredItem: null,\n collisionIds: new Set(),\n layoutShift: null,\n path: [],\n };\n\n const placeholdersLayout = getLayoutPlaceholders(transition);\n\n const layoutItem = itemsLayout.items.find((it) => it.id === draggableItem.id);\n\n let path: Position[] = [];\n if (interactionType === \"pointer\" || operation === \"insert\") {\n const collisionRect = getHoveredRect(collisionIds, placeholdersLayout.items);\n const appendPath = operation === \"resize\" ? appendResizePath : appendMovePath;\n path = layoutItem ? appendPath([], collisionRect) : [];\n } else if (layoutItem) {\n path =\n operation === \"resize\"\n ? [new Position({ x: layoutItem.x + layoutItem.width, y: layoutItem.y + layoutItem.height })]\n : [new Position({ x: layoutItem.x, y: layoutItem.y })];\n }\n\n return {\n transition: { ...transition, path },\n removeTransition: null,\n announcement: layoutItem ? { type: \"dnd-started\", item: draggableItem, operation } : null,\n };\n}\n\nfunction initRemoveTransition<D>({ items, removedItem, itemsLayout }: InitRemoveAction<D>): TransitionState<D> {\n const layoutShift = new LayoutEngine(itemsLayout).remove(removedItem.id);\n const removeTransition: RemoveTransition<D> = { items, removedItem, layoutShift };\n return { transition: null, removeTransition, announcement: null };\n}\n\nfunction submitTransition<D>(state: TransitionState<D>): TransitionState<D> {\n const { transition, removeTransition } = state;\n\n if (removeTransition) {\n const disturbed = new Set(removeTransition.layoutShift.moves.map((move) => move.itemId));\n disturbed.delete(removeTransition.removedItem.id);\n return {\n transition: null,\n removeTransition: null,\n announcement: { type: \"item-removed\", item: removeTransition.removedItem, disturbed },\n };\n }\n\n if (!transition) {\n return { transition: null, removeTransition: null, announcement: null };\n }\n\n const { operation, itemsLayout, draggableItem: item, acquiredItem } = transition;\n const itemBelongsToBoard = item.id === acquiredItem?.id || itemsLayout.items.some((it) => it.id === item.id);\n return transition.layoutShift?.conflicts.length === 0\n ? {\n transition: null,\n removeTransition: null,\n announcement: itemBelongsToBoard ? { type: \"dnd-committed\", item, operation } : null,\n }\n : {\n transition: null,\n removeTransition: null,\n announcement: itemBelongsToBoard ? { type: \"dnd-discarded\", item, operation } : null,\n };\n}\n\nfunction discardTransition<D>(state: TransitionState<D>): TransitionState<D> {\n const { transition, removeTransition } = state;\n\n if (removeTransition) {\n throw new Error(\"Invariant violation: can't discard remove transition.\");\n }\n\n if (!transition) {\n return { transition: null, removeTransition: null, announcement: null };\n }\n\n const { operation, itemsLayout, draggableItem: item, acquiredItem } = transition;\n const itemBelongsToBoard = item.id === acquiredItem?.id || itemsLayout.items.some((it) => it.id === item.id);\n return {\n transition: null,\n removeTransition: null,\n announcement: itemBelongsToBoard ? { type: \"dnd-discarded\", item, operation } : null,\n };\n}\n\nfunction updateTransitionWithPointerEvent<D>(\n state: TransitionState<D>,\n { collisionIds, positionOffset, draggableRect }: UpdateWithPointerAction,\n): TransitionState<D> {\n const { transition } = state;\n\n if (!transition) {\n return { transition: null, removeTransition: null, announcement: null };\n }\n\n const layout = transition.layoutShift?.next ?? transition.itemsLayout;\n const layoutItem = layout.items.find((it) => it.id === transition.draggableItem.id);\n const itemWidth = layoutItem ? layoutItem.width : getDefaultColumnSpan(transition.draggableItem, layout.columns);\n const itemHeight = layoutItem ? layoutItem.height : getDefaultRowSpan(transition.draggableItem);\n const itemSize = itemWidth * itemHeight;\n\n const isOutOfBoundaries =\n transition.operation !== \"resize\" ? collisionIds.length < itemSize : collisionIds.length === 0;\n\n if (isOutOfBoundaries) {\n return {\n transition: {\n ...transition,\n draggableRect,\n collisionIds: new Set(),\n layoutShift: null,\n insertionDirection: null,\n },\n removeTransition: null,\n announcement: null,\n };\n }\n\n const placeholdersLayout = getLayoutPlaceholders(transition);\n const collisionRect = getHoveredRect(collisionIds, placeholdersLayout.items);\n const appendPath = transition.operation === \"resize\" ? appendResizePath : appendMovePath;\n const path = appendPath(transition.path, collisionRect);\n\n const insertionDirection = transition.insertionDirection ?? getInsertionDirection(positionOffset);\n const layoutShift = getLayoutShift(transition, path, insertionDirection);\n\n return {\n transition: {\n ...transition,\n draggableRect,\n collisionIds: new Set(collisionIds),\n layoutShift,\n path,\n insertionDirection,\n },\n removeTransition: null,\n announcement: null,\n };\n}\n\nfunction updateTransitionWithKeyboardEvent<D>(\n state: TransitionState<D>,\n { direction }: UpdateWithKeyboardAction,\n { isRtl }: { isRtl: () => boolean },\n): TransitionState<D> {\n const { transition } = state;\n\n if (!transition) {\n return { transition: null, removeTransition: null, announcement: null };\n }\n\n const updateManualItemTransition = (transition: Transition<D>, direction: Direction): TransitionState<D> => {\n const xDelta = direction === \"left\" ? -1 : direction === \"right\" ? 1 : 0;\n const yDelta = direction === \"up\" ? -1 : direction === \"down\" ? 1 : 0;\n const lastPosition = transition.path[transition.path.length - 1];\n const nextPosition = new Position({ x: lastPosition.x + xDelta, y: lastPosition.y + yDelta });\n const nextPath = [...transition.path, nextPosition];\n\n // Check resizing below min size.\n const layout = transition.layoutShift?.next ?? transition.itemsLayout;\n const layoutItem = layout.items.find((it) => it.id === transition.draggableItem.id);\n const minWidth = getMinColumnSpan(transition.draggableItem, transition.itemsLayout.columns);\n const minHeight = getMinRowSpan(transition.draggableItem);\n if (\n transition.operation === \"resize\" &&\n layoutItem &&\n (layoutItem.width + xDelta < minWidth || layoutItem.height + yDelta < minHeight)\n ) {\n return state;\n }\n\n try {\n const layoutShift = getLayoutShift(transition, nextPath);\n const nextTransition = { ...transition, layoutShift, path: nextPath };\n return {\n transition: nextTransition,\n removeTransition: null,\n announcement: createOperationAnnouncement(nextTransition, direction),\n };\n } catch (e) {\n // Can't create next layout because the next path is out of bounds.\n return state;\n }\n };\n\n switch (direction) {\n case \"left\":\n return updateManualItemTransition(transition, !isRtl() ? \"left\" : \"right\");\n case \"right\":\n return updateManualItemTransition(transition, !isRtl() ? \"right\" : \"left\");\n case \"up\":\n return updateManualItemTransition(transition, \"up\");\n case \"down\":\n return updateManualItemTransition(transition, \"down\");\n }\n}\n\nfunction acquireTransitionItem<D>(\n state: TransitionState<D>,\n { position, layoutElement, acquiredItemElement }: AcquireItemAction,\n): TransitionState<D> {\n const { transition } = state;\n\n if (!transition) {\n return { transition: null, removeTransition: null, announcement: null };\n }\n\n const { columns } = transition.itemsLayout;\n\n const layoutRect = getLogicalBoundingClientRect(layoutElement);\n const itemRect = transition.draggableRect;\n const coordinatesX = itemRect.left - layoutRect.insetInlineStart;\n const offset = new Coordinates({ x: coordinatesX, y: itemRect.top - layoutRect.insetBlockStart });\n const insertionDirection = getInsertionDirection(offset);\n\n // Update original insertion position if the item can't fit into the layout by width.\n const width = getDefaultColumnSpan(transition.draggableItem, columns);\n position = new Position({ x: Math.min(columns - width, position.x), y: position.y });\n\n const path = [...transition.path, position];\n\n const layoutShift = getLayoutShift(transition, path, insertionDirection);\n\n // The columnOffset, columnSpan and rowSpan are of no use as of being overridden by the layout shift.\n const acquiredItem = { ...transition.draggableItem, columnOffset: 0, columnSpan: 1, rowSpan: 1 };\n\n const nextTransition: Transition<D> = {\n ...transition,\n collisionIds: new Set(),\n layoutShift,\n path,\n acquiredItem,\n acquiredItemElement,\n };\n return {\n transition: nextTransition,\n removeTransition: null,\n announcement: createOperationAnnouncement(nextTransition, null),\n };\n}\n"]}
|
package/board/utils/path.js
CHANGED
|
@@ -59,7 +59,7 @@ function appendPath(prevPath, nextPosition) {
|
|
|
59
59
|
let safetyCounter = 0;
|
|
60
60
|
while (x !== nextPosition.x || y !== nextPosition.y) {
|
|
61
61
|
if (++safetyCounter === 100) {
|
|
62
|
-
throw new Error("
|
|
62
|
+
throw new Error("Invariant violation: infinite loop in appendPath.");
|
|
63
63
|
}
|
|
64
64
|
if (x !== nextPosition.x) {
|
|
65
65
|
x += vx;
|
package/board/utils/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../src/board/utils/path.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAyB,EACzB,kBAA6B,EAC7B,OAAe,EACf,IAAY;IAEZ,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACp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AM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAEtD,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,YAAY,CAAC;IAC5B,IAAI,aAAa,GAAG,CAAC,CAAC;IAEtB,OAAO,CAAC,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC,EAAE;QACnD,IAAI,EAAE,aAAa,KAAK,GAAG,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACtE;QACD,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC,EAAE;YACxB,CAAC,IAAI,EAAE,CAAC;SACT;aAAM;YACL,CAAC,IAAI,EAAE,CAAC;SACT;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KACnC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Direction } from \"../../internal/interfaces\";\nimport { Rect } from \"../../internal/interfaces\";\nimport { Position } from \"../../internal/utils/position\";\n\n/**\n * The insertion operation is similar to reorder yet the first path entry is treated differently.\n * The normalization removes leading path entries if on the same edge to optimize UX.\n */\nexport function normalizeInsertionPath(\n path: readonly Position[],\n insertionDirection: Direction,\n columns: number,\n rows: number,\n): Position[] {\n let edgeIndex = -1;\n for (let i = 0; i < path.length; i++) {\n switch (insertionDirection) {\n case \"left\": {\n if (path[i].x === 0) {\n edgeIndex = i;\n }\n break;\n }\n case \"right\": {\n if (path[i].x === columns - 1) {\n edgeIndex = i;\n }\n break;\n }\n case \"up\": {\n if (path[i].y === 0) {\n edgeIndex = i;\n }\n break;\n }\n case \"down\": {\n if (path[i].y === rows - 1) {\n edgeIndex = i;\n }\n break;\n }\n }\n }\n return path.slice(edgeIndex);\n}\n\nexport function appendMovePath(prevPath: readonly Position[], collisionRect: Rect): Position[] {\n return appendPath(prevPath, new Position({ x: collisionRect.left, y: collisionRect.top }));\n}\n\nexport function appendResizePath(prevPath: readonly Position[], collisionRect: Rect): Position[] {\n return appendPath(prevPath, new Position({ x: collisionRect.right, y: collisionRect.bottom }));\n}\n\n/**\n * The operation path must be strictly incremental (each dx + dy == 1). However, the actual collisions\n * data can have gaps due to pointer events throttling or other factors.\n *\n * The function produces next path from previous path and the target position by incrementally adding steps.\n */\nfunction appendPath(prevPath: readonly Position[], nextPosition: Position): Position[] {\n const path: Array<Position> = [...prevPath];\n const lastPosition = prevPath[prevPath.length - 1];\n\n if (!lastPosition) {\n return [nextPosition];\n }\n\n const vx = Math.sign(nextPosition.x - lastPosition.x);\n const vy = Math.sign(nextPosition.y - lastPosition.y);\n\n let { x, y } = lastPosition;\n let safetyCounter = 0;\n\n while (x !== nextPosition.x || y !== nextPosition.y) {\n if (++safetyCounter === 100) {\n throw new Error(\"Invariant violation: infinite loop in appendPath.\");\n }\n if (x !== nextPosition.x) {\n x += vx;\n } else {\n y += vy;\n }\n path.push(new Position({ x, y }));\n }\n\n return path;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Parameter {
|
|
2
2
|
name: string;
|
|
3
|
-
typeName
|
|
3
|
+
typeName: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
flags: {
|
|
6
6
|
isOptional?: boolean;
|
|
@@ -13,7 +13,7 @@ interface TypeArgument {
|
|
|
13
13
|
export interface TestUtilMethod {
|
|
14
14
|
name: string;
|
|
15
15
|
description?: string;
|
|
16
|
-
returnType
|
|
16
|
+
returnType: {
|
|
17
17
|
name: string;
|
|
18
18
|
isNullable: boolean;
|
|
19
19
|
typeArguments?: Array<TypeArgument>;
|
|
@@ -18,13 +18,15 @@ class DragAndDropController extends EventEmitter {
|
|
|
18
18
|
*/
|
|
19
19
|
start(transition) {
|
|
20
20
|
this.transition = { ...transition };
|
|
21
|
-
this.emit("start", this.getDragAndDropData(transition.startCoordinates));
|
|
21
|
+
this.emit("start", this.getDragAndDropData(transition, transition.startCoordinates));
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Updates current transition with given coordinates and issues an "update" event.
|
|
25
25
|
*/
|
|
26
26
|
update(coordinates) {
|
|
27
|
-
|
|
27
|
+
if (this.transition) {
|
|
28
|
+
this.emit("update", this.getDragAndDropData(this.transition, coordinates));
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Removes transition and issues a "submit" event.
|
|
@@ -44,10 +46,9 @@ class DragAndDropController extends EventEmitter {
|
|
|
44
46
|
* Issues an "acquire" event to notify the current transition draggable is acquired by the given droppable.
|
|
45
47
|
*/
|
|
46
48
|
acquire(droppableId, renderAcquiredItem) {
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
+
if (this.transition) {
|
|
50
|
+
this.emit("acquire", { droppableId, draggableItem: this.transition.draggableItem, renderAcquiredItem });
|
|
49
51
|
}
|
|
50
|
-
this.emit("acquire", { droppableId, draggableItem: this.transition.draggableItem, renderAcquiredItem });
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
54
|
* Registers a droppable used for collisions check, acquire, and dropTarget provision.
|
|
@@ -67,14 +68,11 @@ class DragAndDropController extends EventEmitter {
|
|
|
67
68
|
getDroppables() {
|
|
68
69
|
return [...this.droppables.entries()];
|
|
69
70
|
}
|
|
70
|
-
getDragAndDropData(coordinates) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
const positionOffset = Coordinates.cursorOffset(coordinates, this.transition.startCoordinates);
|
|
75
|
-
const collisionRect = this.getCollisionRect(this.transition, coordinates);
|
|
71
|
+
getDragAndDropData(transition, coordinates) {
|
|
72
|
+
const positionOffset = Coordinates.cursorOffset(coordinates, transition.startCoordinates);
|
|
73
|
+
const collisionRect = this.getCollisionRect(transition, coordinates);
|
|
76
74
|
const { collisionIds, dropTarget } = this.getCollisions(collisionRect);
|
|
77
|
-
return { ...
|
|
75
|
+
return { ...transition, positionOffset, coordinates, collisionRect, collisionIds, dropTarget };
|
|
78
76
|
}
|
|
79
77
|
getCollisionRect(transition, coordinates) {
|
|
80
78
|
const originalCollisionRect = transition.getCollisionRect(transition.operation, coordinates, null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/internal/dnd-controller/controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAwDhE,MAAM,qBAAsB,SAAQ,YAA+B;IAAnE;;QACU,eAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC1C,eAAU,GAAsB,IAAI,CAAC;IAgG/C,CAAC;IA9FC;;;;OAIG;IACI,KAAK,CAAC,UAAsB;QACjC,IAAI,CAAC,UAAU,GAAG,EAAE,GAAG,UAAU,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,WAAwB;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACI,MAAM;Q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,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ReactNode, useEffect } from \"react\";\n\nimport { useStableCallback } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { BoardItemDefinitionBase, ItemId, Rect } from \"../interfaces\";\nimport { Coordinates } from \"../utils/coordinates\";\nimport { EventEmitter } from \"./event-emitter\";\nimport { getHoveredDroppables } from \"./get-hovered-droppables\";\n\ntype Item = BoardItemDefinitionBase<unknown>;\n\nexport type Operation = \"reorder\" | \"resize\" | \"insert\";\n\nexport type InteractionType = \"pointer\" | \"keyboard\";\n\n/**\n * Represents the relations between droppables and draggables.\n *\n * The `scale` function transforms draggable's width/height in relative units\n * to the absolute width/height in pixels the droppable expects.\n */\nexport interface DropTargetContext {\n scale: (item: Item, size?: { width: number; height: number }) => { width: number; height: number };\n}\n\nexport interface DragAndDropData {\n operation: Operation;\n interactionType: InteractionType;\n draggableItem: Item;\n collisionRect: Rect;\n positionOffset: Coordinates;\n coordinates: Coordinates;\n collisionIds: ItemId[];\n dropTarget: null | DropTargetContext;\n}\n\nexport interface Droppable {\n element: HTMLElement;\n context: DropTargetContext;\n}\n\nexport interface AcquireData {\n droppableId: ItemId;\n draggableItem: Item;\n renderAcquiredItem: () => ReactNode;\n}\n\nexport interface DragAndDropEvents {\n start: (data: DragAndDropData) => void;\n update: (data: DragAndDropData) => void;\n submit: () => void;\n discard: () => void;\n acquire: (data: AcquireData) => void;\n}\n\ninterface Transition {\n operation: Operation;\n interactionType: InteractionType;\n draggableItem: Item;\n getCollisionRect: (operation: Operation, coordinates: Coordinates, dropTarget: null | DropTargetContext) => Rect;\n startCoordinates: Coordinates;\n}\n\nclass DragAndDropController extends EventEmitter<DragAndDropEvents> {\n private droppables = new Map<ItemId, Droppable>();\n private transition: null | Transition = null;\n\n /**\n * Inits a drag transition and issues a \"start\" event.\n *\n * The method overrides the previous transition if exists (w/o a cancellation event)!\n */\n public start(transition: Transition) {\n this.transition = { ...transition };\n this.emit(\"start\", this.getDragAndDropData(transition.startCoordinates));\n }\n\n /**\n * Updates current transition with given coordinates and issues an \"update\" event.\n */\n public update(coordinates: Coordinates) {\n this.emit(\"update\", this.getDragAndDropData(coordinates));\n }\n\n /**\n * Removes transition and issues a \"submit\" event.\n */\n public submit() {\n this.emit(\"submit\");\n this.transition = null;\n }\n\n /**\n * Removes transition and issues a \"discard\" event.\n */\n public discard() {\n this.emit(\"discard\");\n this.transition = null;\n }\n\n /**\n * Issues an \"acquire\" event to notify the current transition draggable is acquired by the given droppable.\n */\n public acquire(droppableId: ItemId, renderAcquiredItem: () => ReactNode) {\n if (!this.transition) {\n throw new Error(\"Invariant violation: no transition present for acquire.\");\n }\n this.emit(\"acquire\", { droppableId, draggableItem: this.transition.draggableItem, renderAcquiredItem });\n }\n\n /**\n * Registers a droppable used for collisions check, acquire, and dropTarget provision.\n */\n public addDroppable(id: ItemId, context: DropTargetContext, element: HTMLElement) {\n this.droppables.set(id, { element, context });\n }\n\n /**\n * Un-registers the droppable - use it when component unmounts.\n */\n public removeDroppable(id: ItemId) {\n this.droppables.delete(id);\n }\n\n /**\n * Retrieves all registered droppables to run a manual match against.\n */\n public getDroppables() {\n return [...this.droppables.entries()];\n }\n\n private getDragAndDropData(coordinates: Coordinates): DragAndDropData {\n if (!this.transition) {\n throw new Error(\"Invariant violation: no transition present for interaction.\");\n }\n const positionOffset = Coordinates.cursorOffset(coordinates, this.transition.startCoordinates);\n const collisionRect = this.getCollisionRect(this.transition, coordinates);\n const { collisionIds, dropTarget } = this.getCollisions(collisionRect);\n return { ...this.transition, positionOffset, coordinates, collisionRect, collisionIds, dropTarget };\n }\n\n private getCollisionRect(transition: Transition, coordinates: Coordinates) {\n const originalCollisionRect = transition.getCollisionRect(transition.operation, coordinates, null);\n const { dropTarget } = this.getCollisions(originalCollisionRect);\n return transition.getCollisionRect(transition.operation, coordinates, dropTarget);\n }\n\n private getCollisions(collisionRect: Rect) {\n const droppableEntries = [...this.droppables.entries()];\n const droppableElements: [ItemId, HTMLElement][] = droppableEntries.map(([id, entry]) => [id, entry.element]);\n const collisionIds = getHoveredDroppables(collisionRect, droppableElements);\n if (collisionIds.length === 0) {\n return { collisionIds, dropTarget: null };\n }\n\n const matchedDroppable = droppableEntries.find(([id]) => id === collisionIds[0]);\n if (!matchedDroppable) {\n throw new Error(\"Invariant violation: no droppable matches collision.\");\n }\n return { collisionIds, dropTarget: matchedDroppable[1].context };\n }\n}\n\n// Controller is a singleton and is shared between all d&d elements.\nconst controller = new DragAndDropController();\n\nexport function useDragSubscription<K extends keyof DragAndDropEvents>(event: K, handler: DragAndDropEvents[K]) {\n const stableHandler = useStableCallback(handler);\n useEffect(() => controller.on(event, stableHandler), [event, stableHandler]);\n}\n\nexport function useDraggable({\n draggableItem,\n getCollisionRect,\n}: {\n draggableItem: Item;\n getCollisionRect: (operation: Operation, coordinates: Coordinates, dropTarget: null | DropTargetContext) => Rect;\n}) {\n return {\n start(operation: Operation, interactionType: InteractionType, startCoordinates: Coordinates) {\n controller.start({ operation, interactionType, draggableItem, getCollisionRect, startCoordinates });\n },\n updateTransition(coordinates: Coordinates) {\n controller.update(coordinates);\n },\n submitTransition() {\n controller.submit();\n },\n discardTransition() {\n controller.discard();\n },\n acquire(droppableId: ItemId, renderAcquiredItem: () => ReactNode) {\n controller.acquire(droppableId, renderAcquiredItem);\n },\n getDroppables() {\n return controller.getDroppables();\n },\n };\n}\n\nexport function useDroppable({\n itemId,\n context,\n getElement,\n}: {\n itemId: ItemId;\n context: DropTargetContext;\n getElement: () => HTMLElement;\n}) {\n useEffect(() => {\n controller.addDroppable(itemId, context, getElement());\n return () => controller.removeDroppable(itemId);\n }, [itemId, context, getElement]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/internal/dnd-controller/controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAwDhE,MAAM,qBAAsB,SAAQ,YAA+B;IAAnE;;QACU,eAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC1C,eAAU,GAAsB,IAAI,CAAC;IA6F/C,CAAC;IA3FC;;;;OAIG;IACI,KAAK,CAAC,UAAsB;QACjC,IAAI,CAAC,UAAU,GAAG,EAAE,GAAG,UAAU,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvF,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,WAAwB;QACpC,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;SAC5E;IACH,CAAC;IAED;;OAEG;IACI,MAAM;QACX,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,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AE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAC3B,aAAa,EACb,gBAAgB,GAIjB;IACC,OAAO;QACL,KAAK,CAAC,SAAoB,EAAE,eAAgC,EAAE,gBAA6B;YACzF,UAAU,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACtG,CAAC;QACD,gBAAgB,CAAC,WAAwB;YACvC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACjC,CAAC;QACD,gBAAgB;YACd,UAAU,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;QACD,iBAAiB;YACf,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,CAAC,WAAmB,EAAE,kBAAmC;YAC9D,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtD,CAAC;QACD,aAAa;YACX,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAC3B,MAAM,EACN,OAAO,EACP,UAAU,GAKX;IACC,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ReactNode, useEffect } from \"react\";\n\nimport { useStableCallback } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { BoardItemDefinitionBase, ItemId, Rect } from \"../interfaces\";\nimport { Coordinates } from \"../utils/coordinates\";\nimport { EventEmitter } from \"./event-emitter\";\nimport { getHoveredDroppables } from \"./get-hovered-droppables\";\n\ntype Item = BoardItemDefinitionBase<unknown>;\n\nexport type Operation = \"reorder\" | \"resize\" | \"insert\";\n\nexport type InteractionType = \"pointer\" | \"keyboard\";\n\n/**\n * Represents the relations between droppables and draggables.\n *\n * The `scale` function transforms draggable's width/height in relative units\n * to the absolute width/height in pixels the droppable expects.\n */\nexport interface DropTargetContext {\n scale: (item: Item, size?: { width: number; height: number }) => { width: number; height: number };\n}\n\nexport interface DragAndDropData {\n operation: Operation;\n interactionType: InteractionType;\n draggableItem: Item;\n collisionRect: Rect;\n positionOffset: Coordinates;\n coordinates: Coordinates;\n collisionIds: ItemId[];\n dropTarget: null | DropTargetContext;\n}\n\nexport interface Droppable {\n element: HTMLElement;\n context: DropTargetContext;\n}\n\nexport interface AcquireData {\n droppableId: ItemId;\n draggableItem: Item;\n renderAcquiredItem: () => ReactNode;\n}\n\nexport interface DragAndDropEvents {\n start: (data: DragAndDropData) => void;\n update: (data: DragAndDropData) => void;\n submit: () => void;\n discard: () => void;\n acquire: (data: AcquireData) => void;\n}\n\ninterface Transition {\n operation: Operation;\n interactionType: InteractionType;\n draggableItem: Item;\n getCollisionRect: (operation: Operation, coordinates: Coordinates, dropTarget: null | DropTargetContext) => Rect;\n startCoordinates: Coordinates;\n}\n\nclass DragAndDropController extends EventEmitter<DragAndDropEvents> {\n private droppables = new Map<ItemId, Droppable>();\n private transition: null | Transition = null;\n\n /**\n * Inits a drag transition and issues a \"start\" event.\n *\n * The method overrides the previous transition if exists (w/o a cancellation event)!\n */\n public start(transition: Transition) {\n this.transition = { ...transition };\n this.emit(\"start\", this.getDragAndDropData(transition, transition.startCoordinates));\n }\n\n /**\n * Updates current transition with given coordinates and issues an \"update\" event.\n */\n public update(coordinates: Coordinates) {\n if (this.transition) {\n this.emit(\"update\", this.getDragAndDropData(this.transition, coordinates));\n }\n }\n\n /**\n * Removes transition and issues a \"submit\" event.\n */\n public submit() {\n this.emit(\"submit\");\n this.transition = null;\n }\n\n /**\n * Removes transition and issues a \"discard\" event.\n */\n public discard() {\n this.emit(\"discard\");\n this.transition = null;\n }\n\n /**\n * Issues an \"acquire\" event to notify the current transition draggable is acquired by the given droppable.\n */\n public acquire(droppableId: ItemId, renderAcquiredItem: () => ReactNode) {\n if (this.transition) {\n this.emit(\"acquire\", { droppableId, draggableItem: this.transition.draggableItem, renderAcquiredItem });\n }\n }\n\n /**\n * Registers a droppable used for collisions check, acquire, and dropTarget provision.\n */\n public addDroppable(id: ItemId, context: DropTargetContext, element: HTMLElement) {\n this.droppables.set(id, { element, context });\n }\n\n /**\n * Un-registers the droppable - use it when component unmounts.\n */\n public removeDroppable(id: ItemId) {\n this.droppables.delete(id);\n }\n\n /**\n * Retrieves all registered droppables to run a manual match against.\n */\n public getDroppables() {\n return [...this.droppables.entries()];\n }\n\n private getDragAndDropData(transition: Transition, coordinates: Coordinates): DragAndDropData {\n const positionOffset = Coordinates.cursorOffset(coordinates, transition.startCoordinates);\n const collisionRect = this.getCollisionRect(transition, coordinates);\n const { collisionIds, dropTarget } = this.getCollisions(collisionRect);\n return { ...transition, positionOffset, coordinates, collisionRect, collisionIds, dropTarget };\n }\n\n private getCollisionRect(transition: Transition, coordinates: Coordinates) {\n const originalCollisionRect = transition.getCollisionRect(transition.operation, coordinates, null);\n const { dropTarget } = this.getCollisions(originalCollisionRect);\n return transition.getCollisionRect(transition.operation, coordinates, dropTarget);\n }\n\n private getCollisions(collisionRect: Rect) {\n const droppableEntries = [...this.droppables.entries()];\n const droppableElements: [ItemId, HTMLElement][] = droppableEntries.map(([id, entry]) => [id, entry.element]);\n const collisionIds = getHoveredDroppables(collisionRect, droppableElements);\n if (collisionIds.length === 0) {\n return { collisionIds, dropTarget: null };\n }\n const matchedDroppable = droppableEntries.find(([id]) => id === collisionIds[0]);\n if (!matchedDroppable) {\n throw new Error(\"Invariant violation: no droppable matches collision.\");\n }\n return { collisionIds, dropTarget: matchedDroppable[1].context };\n }\n}\n\n// Controller is a singleton and is shared between all d&d elements.\nconst controller = new DragAndDropController();\n\nexport function useDragSubscription<K extends keyof DragAndDropEvents>(event: K, handler: DragAndDropEvents[K]) {\n const stableHandler = useStableCallback(handler);\n useEffect(() => controller.on(event, stableHandler), [event, stableHandler]);\n}\n\nexport function useDraggable({\n draggableItem,\n getCollisionRect,\n}: {\n draggableItem: Item;\n getCollisionRect: (operation: Operation, coordinates: Coordinates, dropTarget: null | DropTargetContext) => Rect;\n}) {\n return {\n start(operation: Operation, interactionType: InteractionType, startCoordinates: Coordinates) {\n controller.start({ operation, interactionType, draggableItem, getCollisionRect, startCoordinates });\n },\n updateTransition(coordinates: Coordinates) {\n controller.update(coordinates);\n },\n submitTransition() {\n controller.submit();\n },\n discardTransition() {\n controller.discard();\n },\n acquire(droppableId: ItemId, renderAcquiredItem: () => ReactNode) {\n controller.acquire(droppableId, renderAcquiredItem);\n },\n getDroppables() {\n return controller.getDroppables();\n },\n };\n}\n\nexport function useDroppable({\n itemId,\n context,\n getElement,\n}: {\n itemId: ItemId;\n context: DropTargetContext;\n getElement: () => HTMLElement;\n}) {\n useEffect(() => {\n controller.addDroppable(itemId, context, getElement());\n return () => controller.removeDroppable(itemId);\n }, [itemId, context, getElement]);\n}\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "board-components";
|
|
2
|
-
export var PACKAGE_VERSION = "3.0.0 (
|
|
2
|
+
export var PACKAGE_VERSION = "3.0.0 (0ce808bb)";
|
|
3
3
|
export var THEME = "open-source-visual-refresh";
|
|
4
4
|
export var ALWAYS_VISUAL_REFRESH = true;
|
|
5
5
|
export var SYSTEM = "console";
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useDragSubscription } from "../dnd-controller/controller";
|
|
4
4
|
import styles from "./styles.css.js";
|
|
5
|
-
function assertNever(value) {
|
|
6
|
-
throw new Error("Unexpected value: " + value);
|
|
7
|
-
}
|
|
8
5
|
function setup({ operation, interactionType }) {
|
|
9
6
|
const isPointerInteraction = interactionType === "pointer";
|
|
10
7
|
switch (operation) {
|
|
@@ -20,8 +17,7 @@ function setup({ operation, interactionType }) {
|
|
|
20
17
|
}
|
|
21
18
|
break;
|
|
22
19
|
default:
|
|
23
|
-
|
|
24
|
-
assertNever(operation);
|
|
20
|
+
throw new Error("Invariant violation: unexpected operation type.");
|
|
25
21
|
}
|
|
26
22
|
if (isPointerInteraction) {
|
|
27
23
|
document.body.classList.add(styles["disable-selection"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/global-drag-state-styles/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAmB,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/global-drag-state-styles/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAmB,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,eAAe,EAAmB;IAC5D,MAAM,oBAAoB,GAAG,eAAe,KAAK,SAAS,CAAC;IAC3D,QAAQ,SAAS,EAAE;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,IAAI,oBAAoB,EAAE;gBACxB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;aACzD;YACD,MAAM;QACR,KAAK,QAAQ;YACX,IAAI,oBAAoB,EAAE;gBACxB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;aAC3D;YACD,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACtE;IAED,IAAI,oBAAoB,EAAE;QACxB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;KAC1D;AACH,CAAC;AAED,SAAS,QAAQ;IACf,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;AACxH,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACzC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { DragAndDropData, useDragSubscription } from \"../dnd-controller/controller\";\n\nimport styles from \"./styles.css.js\";\n\nfunction setup({ operation, interactionType }: DragAndDropData) {\n const isPointerInteraction = interactionType === \"pointer\";\n switch (operation) {\n case \"insert\":\n case \"reorder\":\n if (isPointerInteraction) {\n document.body.classList.add(styles[\"show-grab-cursor\"]);\n }\n break;\n case \"resize\":\n if (isPointerInteraction) {\n document.body.classList.add(styles[\"show-resize-cursor\"]);\n }\n break;\n default:\n throw new Error(\"Invariant violation: unexpected operation type.\");\n }\n\n if (isPointerInteraction) {\n document.body.classList.add(styles[\"disable-selection\"]);\n }\n}\n\nfunction teardown() {\n document.body.classList.remove(styles[\"show-grab-cursor\"], styles[\"show-resize-cursor\"], styles[\"disable-selection\"]);\n}\n\nexport function useGlobalDragStateStyles() {\n useDragSubscription(\"start\", setup);\n useDragSubscription(\"discard\", teardown);\n useDragSubscription(\"submit\", teardown);\n}\n"]}
|
|
@@ -19,7 +19,7 @@ export const ItemContext = createContext(null);
|
|
|
19
19
|
export function useItemContext() {
|
|
20
20
|
const ctx = useContext(ItemContext);
|
|
21
21
|
if (!ctx) {
|
|
22
|
-
throw new Error("
|
|
22
|
+
throw new Error("Invariant violation: no board item context.");
|
|
23
23
|
}
|
|
24
24
|
return ctx;
|
|
25
25
|
}
|
|
@@ -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,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;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,mB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KAAK,CAAC;oBACnE,WAAW,EAAE,0BAA0B,CAAC;wBACtC,cAAc,EAAE,QAAQ;wBACxB,iBAAiB,EAAE,UAAU;wBAC7B,oBAAoB,EAAE,mBAAmB,CAAC,WAAW,CAAC,KAAK;wBAC3D,eAAe,EAAE,SAAS;qBAC3B,CAAC;oBACF,gBAAgB,EAAE,yBAAyB;oBAC3C,kBAAkB,EAChB,mBAAmB,CAAC,WAAW,CAAC,KAAK,KAAK,kBAAkB,IAAI,CAAC,YAAY,IAAI,QAAQ,CAAC;iBAC7F;gBACD,YAAY,EAAE,MAAM;oBAClB,CAAC,CAAC;wBACE,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,QAAQ,CAAC;wBACtD,SAAS,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC;wBACrE,WAAW,EAAE,0BAA0B,CAAC;4BACtC,cAAc,EAAE,QAAQ;4BACxB,iBAAiB,EAAE,UAAU;4BAC7B,oBAAoB,EAAE,qBAAqB,CAAC,WAAW,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;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,8BAA8B,GAC/B,MAAM,SAAS,CAAC;AAEjB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AA+ErC,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAyB,IAAI,CAAC,CAAC;AAEvE,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;KAChE;IACD,OAAO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;iBAC7F;gBACD,YAAY,EAAE,MAAM;oBAClB,CAAC,CAAC;wBACE,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,QAAQ,CAAC;wBACtD,SAAS,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC;wBACrE,WAAW,EAAE,0BAA0B,CAAC;4BACtC,cAAc,EAAE,QAAQ;4BACxB,iBAAiB,EAAE,UAAU;4BAC7B,oBAAoB,EAAE,qBAAqB,CAAC,WAAW,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(\"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
|
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,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,cAA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,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 };
|
|
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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,kDAAkD,CAAC,CAAC;6BACrE;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 { 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudscape-design/board-components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.121",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/cloudscape-design/board-components.git"
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@types/react-dom": "^18.0.10",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
46
46
|
"@typescript-eslint/parser": "^5.48.0",
|
|
47
|
-
"@vitejs/plugin-react": "^4.
|
|
48
|
-
"@vitest/coverage-v8": "^3.
|
|
47
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
48
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
49
49
|
"chokidar-cli": "^3.0.0",
|
|
50
50
|
"deep-freeze-es6": "^1.4.1",
|
|
51
51
|
"eslint": "^8.57.0",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"stylelint-config-recommended-scss": "^14.1.0",
|
|
77
77
|
"stylelint-prettier": "^5.0.2",
|
|
78
78
|
"typescript": "^4.9.4",
|
|
79
|
-
"vite": "^6.3.
|
|
80
|
-
"vitest": "^3.
|
|
79
|
+
"vite": "^6.3.6",
|
|
80
|
+
"vitest": "^3.2.4"
|
|
81
81
|
},
|
|
82
82
|
"//": "ensure that typedoc uses latest typescript. It prints a warning, but works",
|
|
83
83
|
"overrides": {
|