@pega/lists-react 9.0.0-build.21.8 → 9.0.0-build.22.0

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.
Files changed (66) hide show
  1. package/lib/Core/Components/Filters/AdvanceFilter.d.ts.map +1 -1
  2. package/lib/Core/Components/Filters/AdvanceFilter.js +5 -2
  3. package/lib/Core/Components/Filters/AdvanceFilter.js.map +1 -1
  4. package/lib/Core/Components/Filters/SelectFilter.d.ts.map +1 -1
  5. package/lib/Core/Components/Filters/SelectFilter.js +2 -2
  6. package/lib/Core/Components/Filters/SelectFilter.js.map +1 -1
  7. package/lib/Core/Components/HeaderMenu/index.js +2 -2
  8. package/lib/Core/Components/HeaderMenu/index.js.map +1 -1
  9. package/lib/Core/Components/Toolbar/FieldSelector.js +1 -1
  10. package/lib/Core/Components/Toolbar/FieldSelector.js.map +1 -1
  11. package/lib/Core/Components/Toolbar/hooks/useFilter.d.ts.map +1 -1
  12. package/lib/Core/Components/Toolbar/hooks/useFilter.js +4 -1
  13. package/lib/Core/Components/Toolbar/hooks/useFilter.js.map +1 -1
  14. package/lib/Core/Components/Toolbar/utils/utils.d.ts +28 -7
  15. package/lib/Core/Components/Toolbar/utils/utils.d.ts.map +1 -1
  16. package/lib/Core/Components/Toolbar/utils/utils.js +41 -8
  17. package/lib/Core/Components/Toolbar/utils/utils.js.map +1 -1
  18. package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.d.ts +1 -1
  19. package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js +1 -1
  20. package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js.map +1 -1
  21. package/lib/Core/Components/WarningBanner.d.ts +11 -0
  22. package/lib/Core/Components/WarningBanner.d.ts.map +1 -0
  23. package/lib/Core/Components/WarningBanner.js +23 -0
  24. package/lib/Core/Components/WarningBanner.js.map +1 -0
  25. package/lib/Core/Hooks/a11y/useAnnounce.d.ts +3 -4
  26. package/lib/Core/Hooks/a11y/useAnnounce.d.ts.map +1 -1
  27. package/lib/Core/Hooks/a11y/useAnnounce.js +3 -4
  28. package/lib/Core/Hooks/a11y/useAnnounce.js.map +1 -1
  29. package/lib/Core/Hooks/useDragDrop.d.ts +2 -2
  30. package/lib/Core/Hooks/useDragDrop.js +2 -2
  31. package/lib/Core/Hooks/useDragDrop.js.map +1 -1
  32. package/lib/Core/Test/TestUtils.d.ts +0 -1
  33. package/lib/Core/Test/TestUtils.d.ts.map +1 -1
  34. package/lib/Core/Test/TestUtils.js +3 -7
  35. package/lib/Core/Test/TestUtils.js.map +1 -1
  36. package/lib/Core/Views/Gallery/index.d.ts.map +1 -1
  37. package/lib/Core/Views/Gallery/index.js +2 -1
  38. package/lib/Core/Views/Gallery/index.js.map +1 -1
  39. package/lib/Core/Views/Table/StyledTableContainer.js +2 -2
  40. package/lib/Core/Views/Table/StyledTableContainer.js.map +1 -1
  41. package/lib/Core/Views/Table/index.d.ts.map +1 -1
  42. package/lib/Core/Views/Table/index.js +2 -1
  43. package/lib/Core/Views/Table/index.js.map +1 -1
  44. package/lib/Core/Views/Timeline/Timeline.d.ts.map +1 -1
  45. package/lib/Core/Views/Timeline/Timeline.js +11 -16
  46. package/lib/Core/Views/Timeline/Timeline.js.map +1 -1
  47. package/lib/Core/Views/Timeline/Timeline.styles.d.ts +17 -9
  48. package/lib/Core/Views/Timeline/Timeline.styles.d.ts.map +1 -1
  49. package/lib/Core/Views/Timeline/Timeline.styles.js +32 -25
  50. package/lib/Core/Views/Timeline/Timeline.styles.js.map +1 -1
  51. package/lib/Core/Views/Timeline/Timeline.types.d.ts +6 -0
  52. package/lib/Core/Views/Timeline/Timeline.types.d.ts.map +1 -1
  53. package/lib/Core/Views/Timeline/Timeline.types.js.map +1 -1
  54. package/lib/Core/Views/Timeline/TimelineGroup.d.ts +13 -0
  55. package/lib/Core/Views/Timeline/TimelineGroup.d.ts.map +1 -0
  56. package/lib/Core/Views/Timeline/TimelineGroup.js +21 -0
  57. package/lib/Core/Views/Timeline/TimelineGroup.js.map +1 -0
  58. package/lib/Core/Views/Timeline/TimelineItem.d.ts +1 -3
  59. package/lib/Core/Views/Timeline/TimelineItem.d.ts.map +1 -1
  60. package/lib/Core/Views/Timeline/TimelineItem.js +7 -6
  61. package/lib/Core/Views/Timeline/TimelineItem.js.map +1 -1
  62. package/lib/index.d.ts +1 -1
  63. package/lib/index.d.ts.map +1 -1
  64. package/lib/index.js +1 -1
  65. package/lib/index.js.map +1 -1
  66. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA2BrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,KAA4C,EACF,EAAE;IAC5C,MAAM,EACJ,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,cAAc,EACf,GAAG,KAAK,CAAC;IAEV,MAAM,wBAAwB,GAAG,MAAM,GAAG,CAAC,CAAC;IAC5C,IAAI,cAAc,KAAK,CAAC,IAAI,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,KAAK,CAAC,EAAE,CAAC;QAC9E,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAE,CAAC;IAC/D,CAAC;IAED,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;IAE/D,oEAAoE;IACpE,IAAI,uBAAuB,GAAG,CAAC,CAAC;IAChC,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,OACE,iBAAiB,GAAG,cAAc;QAClC,uBAAuB,GAAG,CAAC,WAAW,CAAC,iBAAi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Object } from 'react';\n\nimport { getScrollbarWidth } from 'pega-repeating-structures-core';\nimport { isInstance } from '@pega/cosmos-react-core';\n\nimport type { ItemsHeight } from './VariableHeightVirtualizer';\n\ninterface GetVirtualizedPaginationIndicesParams {\n /** Current vertical scroll offset of the container. */\n scrollTop: number;\n /** Ref to the scrolling container element */\n containerRef: RefObject<HTMLDivElement>;\n /** Ref to the container holding the list items */\n itemContainerRef: RefObject<HTMLDivElement>;\n\n /** Total number of items. */\n totalItemCount: number;\n /** Mapping of item indices and their actual height. */\n itemsHeight: ItemsHeight;\n /** Default height for items if not measured. */\n defaultItemHeight: number;\n\n /** Number of extra items to render above and below the visible viewport for smooth scrolling. */\n buffer: number;\n /** Maximum allowed end index (exclusive). */\n endIndexLimit: number;\n /** If true, allows indices to exceed totalCount for infinite scrolling by including buffer. */\n isInfiniteMode?: boolean;\n}\n\n/**\n * Calculates the start and end indices for virtualized pagination in a variable-height list.\n *\n * @returns {{ startIndex: number, endIndex: number }} Object containing the calculated start and end indices for rendering (inclusive both indices).\n */\nexport const getVirtualizedPaginationIndices = (\n param: GetVirtualizedPaginationIndicesParams\n): { startIndex: number; endIndex: number } => {\n const {\n totalItemCount,\n buffer,\n itemContainerRef,\n scrollTop,\n containerRef,\n itemsHeight,\n defaultItemHeight,\n endIndexLimit,\n isInfiniteMode\n } = param;\n\n const minimumItemsToFetchOnTop = buffer * 4;\n if (totalItemCount === 0 || itemContainerRef.current?.childElementCount === 0) {\n return { startIndex: 0, endIndex: minimumItemsToFetchOnTop };\n }\n\n const viewportHeight = containerRef.current?.clientHeight || 0;\n\n // Find the first visible item index for the current scroll position\n let aboveTheFoldItemsHeight = 0;\n let visibleStartIndex = 0;\n while (\n visibleStartIndex < totalItemCount &&\n aboveTheFoldItemsHeight + (itemsHeight[visibleStartIndex] ?? defaultItemHeight) < scrollTop\n ) {\n aboveTheFoldItemsHeight += itemsHeight[visibleStartIndex] ?? defaultItemHeight;\n visibleStartIndex += 1;\n }\n\n // Find the last visible item index for the current scroll position\n let inViewItemsHeight = 0;\n let visibleEndIndex = visibleStartIndex;\n while (visibleEndIndex < totalItemCount && inViewItemsHeight < viewportHeight) {\n inViewItemsHeight += itemsHeight[visibleEndIndex] ?? defaultItemHeight;\n visibleEndIndex += 1;\n }\n\n const startIndex = Math.max(0, visibleStartIndex - buffer);\n let endIndex = Math.min(visibleEndIndex + buffer, endIndexLimit - 1);\n if (isInfiniteMode) {\n endIndex = Math.max(endIndex, minimumItemsToFetchOnTop);\n } else {\n // In cases where the count is very less due to filters, we would fetch more items to avoid unnecessary API calls if the count after the filter removed is more\n endIndex = Math.max(Math.min(totalItemCount - 1, endIndex), minimumItemsToFetchOnTop);\n }\n return { startIndex, endIndex };\n};\n\n/**\n * Calculates the total buffer height for a list of items, using their individual heights if available,\n * or a default height otherwise.\n *\n * @param totalItemCount - The total number of items in the list.\n * @param itemsHeight - An object or array containing the heights of individual items, indexed by item position.\n * @param defaultItemHeight - The default height to use for items whose height is not specified in `itemsHeight`.\n * @returns The sum of all item heights, using the default height for any missing values.\n */\nexport const calculateTotalBufferHeight = (\n totalItemCount: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let totalBufferHeight = 0;\n for (let i = 0; i < totalItemCount; i += 1) {\n totalBufferHeight += itemsHeight[i] || defaultItemHeight;\n }\n\n return totalBufferHeight;\n};\n\n/**\n * Returns a CSS-compatible max-height value based on the input.\n *\n * @param viewMaxHeight - The maximum height value, which can be a number (pixels), a string (CSS value), or `null`.\n * @returns A string representing the CSS max-height value.\n */\nexport const getMaxHeight = (viewMaxHeight: number | string | null): string => {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n};\n\n/**\n * Calculates the vertical offset for a given item index in a list with variable item heights.\n *\n * @param index - The index of the item for which to calculate the offset.\n * @param itemsHeight - Mapping of item indices and their actual height.\n * @param defaultItemHeight - The default height to use for items not present in the cache.\n * @returns The total offset (in pixels) from the top of the list to the specified index.\n */\nexport const getOffsetForIndex = (\n index: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let offset = 0;\n\n for (let i = 0; i < index; i += 1) {\n offset += itemsHeight[i] ?? defaultItemHeight;\n }\n return offset;\n};\n\n/**\n * Determines whether the viewable area of a virtualized list is not fully filled with rendered items.\n *\n * @param totalItemCount - The total number of items that should be rendered.\n * @param itemContainer - The HTML element containing the rendered items.\n * @param parentContainer - The parent HTML element that contains the items and possibly the header.\n * @param renderHeader - Indicates whether a header is rendered at the top of the parent container.\n * @returns `true` if the view is not filled with all items, `false` otherwise.\n */\nexport const isViewNotFilled = (\n totalItemCount: number,\n itemContainer: HTMLDivElement,\n parentContainer: HTMLDivElement,\n renderHeader: boolean\n): boolean => {\n const parentContainerPosition = parentContainer.getBoundingClientRect();\n let headerHeight = 0;\n if (renderHeader && parentContainer.childElementCount > 1) {\n const firstChild = parentContainer.children[0];\n if (isInstance(firstChild, HTMLDivElement)) {\n headerHeight = firstChild.offsetHeight;\n }\n }\n\n const scrollbarWidth = getScrollbarWidth();\n const items = Array.from(itemContainer.children);\n\n if (!items.length && !totalItemCount) return false;\n if (!items.length && totalItemCount) return true;\n\n return (\n !!totalItemCount &&\n items.length !== totalItemCount &&\n (Math.floor(items[items.length - 1].getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(items[0].getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerHeight) ||\n items.length === 0)\n );\n};\n\n/**\n * Retrieves the numeric data index from the `data-index` attribute of a given Element.\n *\n * @param element - The Element from which to extract the data index.\n * @returns The parsed integer value of the `data-index` attribute, or `null` if the attribute is not present.\n */\nexport const getDataIndex = (element: Element): number | null => {\n const dataIndexStr = element?.getAttribute('data-index');\n if (!dataIndexStr) return null;\n const parsedDataIndex = parseInt(dataIndexStr, 10);\n return Number.isNaN(parsedDataIndex) ? null : parsedDataIndex;\n};\n\n/**\n * Calculates and returns an object containing the heights of items whose heights have changed\n * compared to their previous values.\n *\n * @param itemContainer - The container HTMLElement whose child nodes represent items to measure.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items not present in `itemsHeight`.\n * @returns An object mapping item indices to their new heights for items whose heights have changed.\n */\nexport function getChangedItemsHeight(\n itemContainer: HTMLDivElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): ItemsHeight {\n if (!itemContainer) return {};\n\n const newHeights: ItemsHeight = {};\n const nodes = Array.from(itemContainer.children);\n\n nodes.forEach(node => {\n const itemDataIndex = getDataIndex(node);\n if (itemDataIndex === null) return;\n\n const measuredHeight = node.getBoundingClientRect().height;\n const prevHeight = itemsHeight[itemDataIndex] ?? defaultItemHeight;\n if (measuredHeight !== prevHeight) {\n newHeights[itemDataIndex] = measuredHeight;\n }\n });\n\n return newHeights;\n}\n\n/**\n * Calculates the cumulative change in item heights between two sets of item height data,\n * for a range of items starting from `startIndex` up to (but not including) `previousFirstItemDataIndex`.\n *\n * This function compares the current heights (`itemsHeight`) with the previous heights (`previousItemsHeight`)\n * for each item in the specified range, using `defaultItemHeight` as a fallback if a previous height is missing.\n * The result is the sum of the differences in height for all items in the range.\n *\n * @param startIndex - The index at which to start calculating the cumulative height change.\n * @param previousFirstItemDataIndex - The index up to which to calculate (exclusive). If `null` or less than or equal to 0, returns 0.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param previousItemsHeight - An object mapping item indices of previously rendered items to their heights.\n * @param defaultItemHeight - The default height to use if a previous height is not available.\n * @returns The cumulative change in item heights for the specified range, or 0 if the result is not finite.\n */\nexport const calculateCumulativeItemSizeChange = (\n startIndex: number,\n previousFirstItemDataIndex: number | null,\n itemsHeight: ItemsHeight,\n previousItemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n if (previousFirstItemDataIndex === null || previousFirstItemDataIndex <= 0) {\n return 0;\n }\n\n let delta = 0;\n\n for (let i = startIndex; i < previousFirstItemDataIndex; i += 1) {\n const actualHeight = itemsHeight[i];\n const previousHeight = previousItemsHeight[i] ?? defaultItemHeight;\n\n if (actualHeight !== null && actualHeight !== undefined) {\n delta += actualHeight - previousHeight;\n }\n }\n\n return Number.isFinite(delta) ? delta : 0;\n};\n\n/**\n * Updates the position styles of child items within a container element to enable virtualized rendering.\n * Sets the container's top offset and positions each child absolutely based on their calculated heights.\n *\n * @param itemContainer - The HTML element containing the list items to be positioned.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items without a specified height.\n * @returns The total height of all items within the container, rounded down to the nearest integer.\n */\nexport const updateItemPositionStyles = (\n itemContainer: HTMLDivElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n const items = itemContainer.children;\n if (!items?.length) {\n return 0;\n }\n\n const firstItemDataIndex = getDataIndex(items[0]);\n if (firstItemDataIndex === null) return 0;\n\n const offset = getOffsetForIndex(firstItemDataIndex, itemsHeight, defaultItemHeight);\n itemContainer.style.top = `${offset}px`;\n\n let itemContainerCurrentHeight = 0;\n let currentItemIndex = firstItemDataIndex;\n Array.from(items).forEach(item => {\n if (!isInstance(item, HTMLDivElement)) return;\n\n item.style.position = 'absolute';\n item.style.top = `${itemContainerCurrentHeight}px`;\n itemContainerCurrentHeight += itemsHeight[currentItemIndex] ?? defaultItemHeight;\n currentItemIndex += 1;\n });\n\n return Math.floor(itemContainerCurrentHeight);\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA2BrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,KAA4C,EACF,EAAE;IAC5C,MAAM,EACJ,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,SAAS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,IAAI,0BAA0B,GAAG,CAAC,CAAC;IACnC,IAAI,gBAAgB,GAAG,kBAAkB,CAAC;IAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,cAAc,CAAC;YAAE,OAAO;QAE9C,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,0BAA0B,IAAI,CAAC;QACnD,0BAA0B,IAAI,WAAW,CAAC,gBAAgB,CAAC,IAAI,iBAAiB,CAAC;QACjF,gBAAgB,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import type { RefObject } from 'react';\n\nimport { getScrollbarWidth } from 'pega-repeating-structures-core';\nimport { isInstance } from '@pega/cosmos-react-core';\n\nimport type { ItemsHeight } from './VariableHeightVirtualizer';\n\ninterface GetVirtualizedPaginationIndicesParams {\n /** Current vertical scroll offset of the container. */\n scrollTop: number;\n /** Ref to the scrolling container element */\n containerRef: RefObject<HTMLDivElement>;\n /** Ref to the container holding the list items */\n itemContainerRef: RefObject<HTMLDivElement>;\n\n /** Total number of items. */\n totalItemCount: number;\n /** Mapping of item indices and their actual height. */\n itemsHeight: ItemsHeight;\n /** Default height for items if not measured. */\n defaultItemHeight: number;\n\n /** Number of extra items to render above and below the visible viewport for smooth scrolling. */\n buffer: number;\n /** Maximum allowed end index (exclusive). */\n endIndexLimit: number;\n /** If true, allows indices to exceed totalCount for infinite scrolling by including buffer. */\n isInfiniteMode?: boolean;\n}\n\n/**\n * Calculates the start and end indices for virtualized pagination in a variable-height list.\n *\n * @returns Object containing the calculated start and end indices for rendering (inclusive both indices).\n */\nexport const getVirtualizedPaginationIndices = (\n param: GetVirtualizedPaginationIndicesParams\n): { startIndex: number; endIndex: number } => {\n const {\n totalItemCount,\n buffer,\n itemContainerRef,\n scrollTop,\n containerRef,\n itemsHeight,\n defaultItemHeight,\n endIndexLimit,\n isInfiniteMode\n } = param;\n\n const minimumItemsToFetchOnTop = buffer * 4;\n if (totalItemCount === 0 || itemContainerRef.current?.childElementCount === 0) {\n return { startIndex: 0, endIndex: minimumItemsToFetchOnTop };\n }\n\n const viewportHeight = containerRef.current?.clientHeight || 0;\n\n // Find the first visible item index for the current scroll position\n let aboveTheFoldItemsHeight = 0;\n let visibleStartIndex = 0;\n while (\n visibleStartIndex < totalItemCount &&\n aboveTheFoldItemsHeight + (itemsHeight[visibleStartIndex] ?? defaultItemHeight) < scrollTop\n ) {\n aboveTheFoldItemsHeight += itemsHeight[visibleStartIndex] ?? defaultItemHeight;\n visibleStartIndex += 1;\n }\n\n // Find the last visible item index for the current scroll position\n let inViewItemsHeight = 0;\n let visibleEndIndex = visibleStartIndex;\n while (visibleEndIndex < totalItemCount && inViewItemsHeight < viewportHeight) {\n inViewItemsHeight += itemsHeight[visibleEndIndex] ?? defaultItemHeight;\n visibleEndIndex += 1;\n }\n\n const startIndex = Math.max(0, visibleStartIndex - buffer);\n let endIndex = Math.min(visibleEndIndex + buffer, endIndexLimit - 1);\n if (isInfiniteMode) {\n endIndex = Math.max(endIndex, minimumItemsToFetchOnTop);\n } else {\n // In cases where the count is very less due to filters, we would fetch more items to avoid unnecessary API calls if the count after the filter removed is more\n endIndex = Math.max(Math.min(totalItemCount - 1, endIndex), minimumItemsToFetchOnTop);\n }\n return { startIndex, endIndex };\n};\n\n/**\n * Calculates the total buffer height for a list of items, using their individual heights if available,\n * or a default height otherwise.\n *\n * @param totalItemCount - The total number of items in the list.\n * @param itemsHeight - An object or array containing the heights of individual items, indexed by item position.\n * @param defaultItemHeight - The default height to use for items whose height is not specified in `itemsHeight`.\n * @returns The sum of all item heights, using the default height for any missing values.\n */\nexport const calculateTotalBufferHeight = (\n totalItemCount: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let totalBufferHeight = 0;\n for (let i = 0; i < totalItemCount; i += 1) {\n totalBufferHeight += itemsHeight[i] || defaultItemHeight;\n }\n\n return totalBufferHeight;\n};\n\n/**\n * Returns a CSS-compatible max-height value based on the input.\n *\n * @param viewMaxHeight - The maximum height value, which can be a number (pixels), a string (CSS value), or `null`.\n * @returns A string representing the CSS max-height value.\n */\nexport const getMaxHeight = (viewMaxHeight: number | string | null): string => {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n};\n\n/**\n * Calculates the vertical offset for a given item index in a list with variable item heights.\n *\n * @param index - The index of the item for which to calculate the offset.\n * @param itemsHeight - Mapping of item indices and their actual height.\n * @param defaultItemHeight - The default height to use for items not present in the cache.\n * @returns The total offset (in pixels) from the top of the list to the specified index.\n */\nexport const getOffsetForIndex = (\n index: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let offset = 0;\n\n for (let i = 0; i < index; i += 1) {\n offset += itemsHeight[i] ?? defaultItemHeight;\n }\n return offset;\n};\n\n/**\n * Determines whether the viewable area of a virtualized list is not fully filled with rendered items.\n *\n * @param totalItemCount - The total number of items that should be rendered.\n * @param itemContainer - The HTML element containing the rendered items.\n * @param parentContainer - The parent HTML element that contains the items and possibly the header.\n * @param renderHeader - Indicates whether a header is rendered at the top of the parent container.\n * @returns `true` if the view is not filled with all items, `false` otherwise.\n */\nexport const isViewNotFilled = (\n totalItemCount: number,\n itemContainer: HTMLDivElement,\n parentContainer: HTMLDivElement,\n renderHeader: boolean\n): boolean => {\n const parentContainerPosition = parentContainer.getBoundingClientRect();\n let headerHeight = 0;\n if (renderHeader && parentContainer.childElementCount > 1) {\n const firstChild = parentContainer.children[0];\n if (isInstance(firstChild, HTMLDivElement)) {\n headerHeight = firstChild.offsetHeight;\n }\n }\n\n const scrollbarWidth = getScrollbarWidth();\n const items = Array.from(itemContainer.children);\n\n if (!items.length && !totalItemCount) return false;\n if (!items.length && totalItemCount) return true;\n\n return (\n !!totalItemCount &&\n items.length !== totalItemCount &&\n (Math.floor(items[items.length - 1].getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(items[0].getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerHeight) ||\n items.length === 0)\n );\n};\n\n/**\n * Retrieves the numeric data index from the `data-index` attribute of a given Element.\n *\n * @param element - The Element from which to extract the data index.\n * @returns The parsed integer value of the `data-index` attribute, or `null` if the attribute is not present.\n */\nexport const getDataIndex = (element: Element): number | null => {\n const dataIndexStr = element?.getAttribute('data-index');\n if (!dataIndexStr) return null;\n const parsedDataIndex = parseInt(dataIndexStr, 10);\n return Number.isNaN(parsedDataIndex) ? null : parsedDataIndex;\n};\n\n/**\n * Calculates and returns an object containing the heights of items whose heights have changed\n * compared to their previous values.\n *\n * @param itemContainer - The container HTMLElement whose child nodes represent items to measure.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items not present in `itemsHeight`.\n * @returns An object mapping item indices to their new heights for items whose heights have changed.\n */\nexport function getChangedItemsHeight(\n itemContainer: HTMLDivElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): ItemsHeight {\n if (!itemContainer) return {};\n\n const newHeights: ItemsHeight = {};\n const nodes = Array.from(itemContainer.children);\n\n nodes.forEach(node => {\n const itemDataIndex = getDataIndex(node);\n if (itemDataIndex === null) return;\n\n const measuredHeight = node.getBoundingClientRect().height;\n const prevHeight = itemsHeight[itemDataIndex] ?? defaultItemHeight;\n if (measuredHeight !== prevHeight) {\n newHeights[itemDataIndex] = measuredHeight;\n }\n });\n\n return newHeights;\n}\n\n/**\n * Calculates the cumulative change in item heights between two sets of item height data,\n * for a range of items starting from `startIndex` up to (but not including) `previousFirstItemDataIndex`.\n *\n * This function compares the current heights (`itemsHeight`) with the previous heights (`previousItemsHeight`)\n * for each item in the specified range, using `defaultItemHeight` as a fallback if a previous height is missing.\n * The result is the sum of the differences in height for all items in the range.\n *\n * @param startIndex - The index at which to start calculating the cumulative height change.\n * @param previousFirstItemDataIndex - The index up to which to calculate (exclusive). If `null` or less than or equal to 0, returns 0.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param previousItemsHeight - An object mapping item indices of previously rendered items to their heights.\n * @param defaultItemHeight - The default height to use if a previous height is not available.\n * @returns The cumulative change in item heights for the specified range, or 0 if the result is not finite.\n */\nexport const calculateCumulativeItemSizeChange = (\n startIndex: number,\n previousFirstItemDataIndex: number | null,\n itemsHeight: ItemsHeight,\n previousItemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n if (previousFirstItemDataIndex === null || previousFirstItemDataIndex <= 0) {\n return 0;\n }\n\n let delta = 0;\n\n for (let i = startIndex; i < previousFirstItemDataIndex; i += 1) {\n const actualHeight = itemsHeight[i];\n const previousHeight = previousItemsHeight[i] ?? defaultItemHeight;\n\n if (actualHeight !== null && actualHeight !== undefined) {\n delta += actualHeight - previousHeight;\n }\n }\n\n return Number.isFinite(delta) ? delta : 0;\n};\n\n/**\n * Updates the position styles of child items within a container element to enable virtualized rendering.\n * Sets the container's top offset and positions each child absolutely based on their calculated heights.\n *\n * @param itemContainer - The HTML element containing the list items to be positioned.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items without a specified height.\n * @returns The total height of all items within the container, rounded down to the nearest integer.\n */\nexport const updateItemPositionStyles = (\n itemContainer: HTMLDivElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n const items = itemContainer.children;\n if (!items?.length) {\n return 0;\n }\n\n const firstItemDataIndex = getDataIndex(items[0]);\n if (firstItemDataIndex === null) return 0;\n\n const offset = getOffsetForIndex(firstItemDataIndex, itemsHeight, defaultItemHeight);\n itemContainer.style.top = `${offset}px`;\n\n let itemContainerCurrentHeight = 0;\n let currentItemIndex = firstItemDataIndex;\n Array.from(items).forEach(item => {\n if (!isInstance(item, HTMLDivElement)) return;\n\n item.style.position = 'absolute';\n item.style.top = `${itemContainerCurrentHeight}px`;\n itemContainerCurrentHeight += itemsHeight[currentItemIndex] ?? defaultItemHeight;\n currentItemIndex += 1;\n });\n\n return Math.floor(itemContainerCurrentHeight);\n};\n"]}
@@ -0,0 +1,11 @@
1
+ import type { RsCoreTypes } from 'pega-repeating-structures-core';
2
+ interface WarningBannerProps {
3
+ warningMessages?: RsCoreTypes.WarningDetail[];
4
+ }
5
+ /**
6
+ * WarningBanner displays API warnings at the top of the table.
7
+ * Uses cosmos-core Banner component for consistent styling and accessibility.
8
+ */
9
+ export default function WarningBanner({ warningMessages }: WarningBannerProps): import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
11
+ //# sourceMappingURL=WarningBanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WarningBanner.d.ts","sourceRoot":"","sources":["../../../Core/Components/WarningBanner.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAWlE,UAAU,kBAAkB;IAC1B,eAAe,CAAC,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,eAAe,EAAE,EAAE,kBAAkB,kDAa5E"}
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled, { css } from 'styled-components';
3
+ import { Banner, defaultThemeProp } from '@pega/cosmos-react-core';
4
+ const StyledBanner = styled(Banner)(({ theme }) => {
5
+ return css `
6
+ margin-block-end: calc(${theme.base.spacing} / 2);
7
+ flex-shrink: 0;
8
+ `;
9
+ });
10
+ StyledBanner.defaultProps = defaultThemeProp;
11
+ /**
12
+ * WarningBanner displays API warnings at the top of the table.
13
+ * Uses cosmos-core Banner component for consistent styling and accessibility.
14
+ */
15
+ export default function WarningBanner({ warningMessages }) {
16
+ if (!warningMessages?.length) {
17
+ return null;
18
+ }
19
+ return (_jsx(StyledBanner, { variant: 'warning', messages: warningMessages.map(warning => ({
20
+ label: warning.message || ''
21
+ })) }));
22
+ }
23
+ //# sourceMappingURL=WarningBanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WarningBanner.js","sourceRoot":"","sources":["../../../Core/Components/WarningBanner.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAChD,OAAO,GAAG,CAAA;6BACiB,KAAK,CAAC,IAAI,CAAC,OAAO;;GAE5C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,YAAY,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAM7C;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,eAAe,EAAsB;IAC3E,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,YAAY,IACX,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACxC,KAAK,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;SAC7B,CAAC,CAAC,GACH,CACH,CAAC;AACJ,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { Banner, defaultThemeProp } from '@pega/cosmos-react-core';\nimport type { RsCoreTypes } from 'pega-repeating-structures-core';\n\nconst StyledBanner = styled(Banner)(({ theme }) => {\n return css`\n margin-block-end: calc(${theme.base.spacing} / 2);\n flex-shrink: 0;\n `;\n});\n\nStyledBanner.defaultProps = defaultThemeProp;\n\ninterface WarningBannerProps {\n warningMessages?: RsCoreTypes.WarningDetail[];\n}\n\n/**\n * WarningBanner displays API warnings at the top of the table.\n * Uses cosmos-core Banner component for consistent styling and accessibility.\n */\nexport default function WarningBanner({ warningMessages }: WarningBannerProps) {\n if (!warningMessages?.length) {\n return null;\n }\n\n return (\n <StyledBanner\n variant='warning'\n messages={warningMessages.map(warning => ({\n label: warning.message || ''\n }))}\n />\n );\n}\n"]}
@@ -9,10 +9,9 @@ type Messages = {
9
9
  * considering personalization context. Useful for screen readers to inform users
10
10
  * about dynamic updates in lists or tables.
11
11
  *
12
- * @template T
13
- * @param {T | undefined} currentStateSlice - The current array of items or undefined.
14
- * @param {Messages} messages - Object containing messages for added, modified, and removed states.
15
- * @param {string} [activePersonalization] - Optional key to track personalization context changes.
12
+ * @param currentStateSlice - The current array of items or undefined.
13
+ * @param messages - Object containing messages for added, modified, and removed states.
14
+ * @param activePersonalization - Optional key to track personalization context changes.
16
15
  */
17
16
  export default function useAnnounce<T extends any[] | undefined>(currentStateSlice: T, messages: Messages, activePersonalization?: string): void;
18
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"useAnnounce.d.ts","sourceRoot":"","sources":["../../../../Core/Hooks/a11y/useAnnounce.ts"],"names":[],"mappings":"AAMA,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,SAAS,EAC7D,iBAAiB,EAAE,CAAC,EACpB,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,CAAC,EAAE,MAAM,QAuC/B"}
1
+ {"version":3,"file":"useAnnounce.d.ts","sourceRoot":"","sources":["../../../../Core/Hooks/a11y/useAnnounce.ts"],"names":[],"mappings":"AAMA,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,SAAS,EAC7D,iBAAiB,EAAE,CAAC,EACpB,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,CAAC,EAAE,MAAM,QAuC/B"}
@@ -7,10 +7,9 @@ import { deepEqual } from '../../Utils';
7
7
  * considering personalization context. Useful for screen readers to inform users
8
8
  * about dynamic updates in lists or tables.
9
9
  *
10
- * @template T
11
- * @param {T | undefined} currentStateSlice - The current array of items or undefined.
12
- * @param {Messages} messages - Object containing messages for added, modified, and removed states.
13
- * @param {string} [activePersonalization] - Optional key to track personalization context changes.
10
+ * @param currentStateSlice - The current array of items or undefined.
11
+ * @param messages - Object containing messages for added, modified, and removed states.
12
+ * @param activePersonalization - Optional key to track personalization context changes.
14
13
  */
15
14
  export default function useAnnounce(currentStateSlice, messages, activePersonalization) {
16
15
  const { announcePolite } = useLiveLog();
@@ -1 +1 @@
1
- {"version":3,"file":"useAnnounce.js","sourceRoot":"","sources":["../../../../Core/Hooks/a11y/useAnnounce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,iBAAoB,EACpB,QAAkB,EAClB,qBAA8B;IAE9B,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,EAAE,CAAC;IACxC,MAAM,kBAAkB,GAAG,WAAW,CAAC,i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C;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { useEffect } from 'react';\n\nimport { useLiveLog, usePrevious } from '@pega/cosmos-react-core';\n\nimport { deepEqual } from '../../Utils';\n\ntype Messages = {\n added: string | undefined;\n modified: string | undefined;\n removed: string | undefined;\n};\n\n/**\n * Announces accessibility messages for array changes using a polite live region.\n * Triggers the appropriate message when items are added, modified, or removed,\n * considering personalization context. Useful for screen readers to inform users\n * about dynamic updates in lists or tables.\n *\n * @template T\n * @param {T | undefined} currentStateSlice - The current array of items or undefined.\n * @param {Messages} messages - Object containing messages for added, modified, and removed states.\n * @param {string} [activePersonalization] - Optional key to track personalization context changes.\n */\nexport default function useAnnounce<T extends any[] | undefined>(\n currentStateSlice: T,\n messages: Messages,\n activePersonalization?: string\n) {\n const { announcePolite } = useLiveLog();\n const previousStateSlice = usePrevious(currentStateSlice);\n const previousActivePersonalization = usePrevious(activePersonalization);\n\n useEffect(() => {\n if (!previousStateSlice || !currentStateSlice) return;\n\n const personalizationChanged = activePersonalization !== previousActivePersonalization;\n const previousLen = previousStateSlice.length ?? 0;\n const currentLen = currentStateSlice.length ?? 0;\n const isAdded = (previousLen === 0 || personalizationChanged) && currentLen > 0;\n\n const isModified =\n !personalizationChanged &&\n previousLen > 0 &&\n currentLen > 0 &&\n !deepEqual(previousStateSlice, currentStateSlice);\n\n const isRemoved = !personalizationChanged && previousLen > 0 && currentLen === 0;\n\n let message: string | undefined;\n\n if (isAdded) {\n message = messages.added;\n } else if (isModified) {\n message = messages.modified;\n } else if (isRemoved) {\n message = messages.removed;\n }\n\n if (message) {\n const timeout = setTimeout(() => {\n announcePolite({ message, type: 'info' });\n }, 1000);\n return () => clearTimeout(timeout);\n }\n }, [currentStateSlice, activePersonalization]);\n}\n"]}
1
+ {"version":3,"file":"useAnnounce.js","sourceRoot":"","sources":["../../../../Core/Hooks/a11y/useAnnounce.ts"],"names":[],"mappings":"AA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CAAC;aAAM,IAAI,SAAS,EAAE,CAAC;YACrB,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC7B,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC9B,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5C,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { useEffect } from 'react';\n\nimport { useLiveLog, usePrevious } from '@pega/cosmos-react-core';\n\nimport { deepEqual } from '../../Utils';\n\ntype Messages = {\n added: string | undefined;\n modified: string | undefined;\n removed: string | undefined;\n};\n\n/**\n * Announces accessibility messages for array changes using a polite live region.\n * Triggers the appropriate message when items are added, modified, or removed,\n * considering personalization context. Useful for screen readers to inform users\n * about dynamic updates in lists or tables.\n *\n * @param currentStateSlice - The current array of items or undefined.\n * @param messages - Object containing messages for added, modified, and removed states.\n * @param activePersonalization - Optional key to track personalization context changes.\n */\nexport default function useAnnounce<T extends any[] | undefined>(\n currentStateSlice: T,\n messages: Messages,\n activePersonalization?: string\n) {\n const { announcePolite } = useLiveLog();\n const previousStateSlice = usePrevious(currentStateSlice);\n const previousActivePersonalization = usePrevious(activePersonalization);\n\n useEffect(() => {\n if (!previousStateSlice || !currentStateSlice) return;\n\n const personalizationChanged = activePersonalization !== previousActivePersonalization;\n const previousLen = previousStateSlice.length ?? 0;\n const currentLen = currentStateSlice.length ?? 0;\n const isAdded = (previousLen === 0 || personalizationChanged) && currentLen > 0;\n\n const isModified =\n !personalizationChanged &&\n previousLen > 0 &&\n currentLen > 0 &&\n !deepEqual(previousStateSlice, currentStateSlice);\n\n const isRemoved = !personalizationChanged && previousLen > 0 && currentLen === 0;\n\n let message: string | undefined;\n\n if (isAdded) {\n message = messages.added;\n } else if (isModified) {\n message = messages.modified;\n } else if (isRemoved) {\n message = messages.removed;\n }\n\n if (message) {\n const timeout = setTimeout(() => {\n announcePolite({ message, type: 'info' });\n }, 1000);\n return () => clearTimeout(timeout);\n }\n }, [currentStateSlice, activePersonalization]);\n}\n"]}
@@ -3,9 +3,9 @@ import type { UseDragDropProps, UseDragDropReturn } from './useDragDrop.types';
3
3
  * A custom React hook to handle drag-and-drop functionality with support for animations,
4
4
  * ghost images, and collision detection.
5
5
  *
6
- * @param {UseDragDropProps} params - The parameters for configuring the drag-and-drop behavior.
6
+ * @param params - The parameters for configuring the drag-and-drop behavior.
7
7
  * See {@link UseDragDropProps} for details.
8
- * @returns {UseDragDropReturn} An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.
8
+ * @returns An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.
9
9
  * See {@link UseDragDropReturn} for details.
10
10
  */
11
11
  export default function useDragDrop({ context, onDragStart, onDragEnd, onDragEnter, onDragLeave, onDrop, defaultAnimation, getAnimationSelector, defaultGhostImage, getGhostImageSelector, getDraggedObject }: UseDragDropProps): UseDragDropReturn;
@@ -3,9 +3,9 @@ import { useCallback, useMemo, useRef } from 'react';
3
3
  * A custom React hook to handle drag-and-drop functionality with support for animations,
4
4
  * ghost images, and collision detection.
5
5
  *
6
- * @param {UseDragDropProps} params - The parameters for configuring the drag-and-drop behavior.
6
+ * @param params - The parameters for configuring the drag-and-drop behavior.
7
7
  * See {@link UseDragDropProps} for details.
8
- * @returns {UseDragDropReturn} An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.
8
+ * @returns An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.
9
9
  * See {@link UseDragDropReturn} for details.
10
10
  */
11
11
  export default function useDragDrop({ context, onDragStart = undefined, onDragEnd = undefined, onDragEnter = undefined, onDragLeave = undefined, onDrop, defaultAnimation = true, getAnimationSelector, defaultGhostImage = true, getGhostImageSelector, getDraggedObject }) {
@@ -1 +1 @@
1
- {"version":3,"file":"useDragDrop.js","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIrD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAW,GAAG,SAAS,EACvB,SAAS,GAAG,SAAS,EACrB,WAAW,GAAG,SAAS,EACvB,WAAW,GAAG,SAAS,EACvB,MAAM,EACN,gBAAgB,GAAG,IAAI,EACvB,oBAAoB,EACpB,iBAAiB,GAAG,IAAI,EACxB,qBAAqB,EACrB,gBAAgB,EACC;IACjB,6FAA6F;IAC7F,MAAM,GAAG,GAAG,MAAM,CAAc;QAC9B,UAAU,EAAE,EAAE;QACd,eAAe,EAAE,IAAI;QACrB,UAAU,EAAE,SAAS;KACtB,CAAC,CAAC,OAAO,CAAC;IAEX,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,MAAe,EAAE,EAAE;QAClB,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACvE,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACjB,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EACD,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CACzC,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,MAAe,EAAE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W,CAAC,CAC3B,CAAC;IAEF,OAAO;QACL,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\n\nimport type { DragDropRef, UseDragDropProps, UseDragDropReturn } from './useDragDrop.types';\n\n/**\n * A custom React hook to handle drag-and-drop functionality with support for animations,\n * ghost images, and collision detection.\n *\n * @param {UseDragDropProps} params - The parameters for configuring the drag-and-drop behavior.\n * See {@link UseDragDropProps} for details.\n * @returns {UseDragDropReturn} An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.\n * See {@link UseDragDropReturn} for details.\n */\nexport default function useDragDrop({\n context,\n onDragStart = undefined,\n onDragEnd = undefined,\n onDragEnter = undefined,\n onDragLeave = undefined,\n onDrop,\n defaultAnimation = true,\n getAnimationSelector,\n defaultGhostImage = true,\n getGhostImageSelector,\n getDraggedObject\n}: UseDragDropProps): UseDragDropReturn {\n // A way to fire dragleave when we actually come out of drop target not only a child of that.\n const ref = useRef<DragDropRef>({\n dropTarget: [],\n dropTargetCoord: null,\n dragTarget: undefined\n }).current;\n\n const addDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '0.5';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '1';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const setGhostImage = useCallback(\n (e: React.DragEvent<Element>) => {\n if (defaultGhostImage) {\n const elem = (\n getGhostImageSelector ? getGhostImageSelector(e.currentTarget) : e.currentTarget\n ) as HTMLElement;\n const ghostElement = elem.cloneNode(true) as HTMLElement;\n if (ghostElement) {\n ghostElement.style.height = `${elem.style.height}px`;\n ghostElement.style.width = `${elem.style.width}px`;\n ghostElement.style.position = 'absolute';\n ghostElement.style.top = '-1000000px';\n ghostElement.style.left = '-10000000px';\n ghostElement.style.zIndex = '-1';\n }\n context.current?.appendChild(ghostElement);\n e.dataTransfer?.setDragImage(ghostElement, 0, 0);\n\n setTimeout(() => {\n ghostElement.parentNode?.removeChild(ghostElement);\n }, 1000);\n }\n },\n [getGhostImageSelector, context, defaultGhostImage]\n );\n\n const isColliding = useCallback((x: number, y: number, coord: DOMRect): boolean => {\n const smallBuffer = 2;\n return !(\n x < coord.left - smallBuffer ||\n x > coord.right + smallBuffer ||\n y > coord.bottom + smallBuffer ||\n y < coord.top - smallBuffer\n );\n }, []);\n\n const addDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n // Need to handle this in better way.TODO: need clean up as well.\n elm.style.transition = 'transform 0.25s';\n elm.style.transform = 'translate(20px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.transform = 'translate(0px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const contextDragOverCb = useCallback(\n (e: DragEvent) => {\n e.stopPropagation();\n e.preventDefault();\n if (\n ref.dragLeaveSkipped &&\n ref.dropTarget &&\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTargetCoord &&\n !isColliding(e.clientX, e.clientY, ref.dropTargetCoord)\n ) {\n ref.forcedDragLeave = true;\n ref.dragLeaveSkipped = false;\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n },\n [isColliding, ref]\n );\n\n const contextDropCb = useCallback(\n (ev: DragEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n const elm = ref.dropTarget[ref.dropTarget.length - 1] as HTMLElement;\n if (\n ref.dropTargetCoord &&\n elm !== ref.dragTarget &&\n isColliding(ev.clientX, ev.clientY, ref.dropTargetCoord)\n ) {\n removeDropEffect(elm);\n elm.classList.remove('dragEnter');\n if (onDrop && ref.dragTarget) onDrop(elm, ref.dragTarget);\n ref.dragTarget = undefined;\n ref.dropTargetCoord = null;\n ref.dropTarget = [];\n }\n },\n [ref, isColliding, removeDropEffect, onDrop]\n );\n\n const dragStartCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n document.addEventListener('dragover', contextDragOverCb);\n context.current?.addEventListener('drop', contextDropCb);\n\n // clear the drag operation's data store when drag starts as its the only time when drag data is writable\n if (ev.dataTransfer) ev.dataTransfer.clearData();\n\n // We have to keep event handler in reference so that we can remove right handler when drag ends.\n // Handler might change in between because of deps.\n ref.contextDropCb = contextDropCb;\n ref.contextDragOverCb = contextDragOverCb;\n\n setGhostImage(ev);\n ev.dataTransfer.effectAllowed = 'move';\n // Setting up some dummy data to make drag drop work in firefox. Refer https://medium.com/%40reiberdatschi/common-pitfalls-with-html5-drag-n-drop-api-9f011a09ee6c\n ev.dataTransfer.setData('text/plain', 'RS_Dragged_Item');\n // fail safe reset drag target.\n if (ref.dragTarget) ref.dragTarget = undefined;\n ref.dragTarget = getDraggedObject ? getDraggedObject(ev.currentTarget) : ev.currentTarget;\n ev.currentTarget.classList.add('dragStart');\n addDragEffect(ev.currentTarget);\n if (onDragStart) onDragStart(ev);\n },\n [\n contextDragOverCb,\n context,\n contextDropCb,\n setGhostImage,\n ref,\n getDraggedObject,\n addDragEffect,\n onDragStart\n ]\n );\n\n const dragEndCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n if (ref.contextDragOverCb) document.removeEventListener('dragover', ref.contextDragOverCb);\n if (ref.contextDropCb) context.current?.removeEventListener('drop', ref.contextDropCb);\n ref.dropTarget = [];\n ref.dropTargetCoord = null;\n ref.forcedDragLeave = false;\n ref.dragLeaveSkipped = false;\n ev.currentTarget.classList.remove('dragStart');\n removeDragEffect(ev.currentTarget);\n if (onDragEnd) onDragEnd(ev);\n },\n [onDragEnd, removeDragEffect, context, ref]\n );\n\n const isValidDragEnter = useCallback(\n (e: React.DragEvent<Element>) => {\n let isValid = true;\n if (ref.dragTarget === e.currentTarget) isValid = false;\n else if (ref.dropTarget[ref.dropTarget.length - 1] === e.currentTarget) isValid = false;\n else if (\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTarget[ref.dropTarget.length - 1] !== e.currentTarget\n ) {\n const currentTargetCoord = e.currentTarget.getBoundingClientRect();\n const dropTargetCoord = ref.dropTarget[ref.dropTarget.length - 1].getBoundingClientRect();\n if (\n !isColliding(e.clientX, e.clientY, currentTargetCoord) &&\n isColliding(e.clientX, e.clientY, dropTargetCoord)\n )\n isValid = false;\n }\n return isValid;\n },\n [ref, isColliding]\n );\n\n const dragEnterCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (isValidDragEnter(ev)) {\n ref.dropTarget = ref.dropTarget.length ? [...ref.dropTarget] : [];\n ref.dropTarget.push(ev.currentTarget);\n ev.currentTarget.classList.add('dragEnter');\n ev.dataTransfer.dropEffect = 'move';\n ref.dropTargetCoord = ev.currentTarget.getBoundingClientRect();\n addDropEffect(ev.currentTarget);\n if (onDragEnter) onDragEnter(ev);\n\n if (ref.dropTarget.length > 1) {\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n ref.forcedDragLeave = true;\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n }\n },\n [onDragEnter, addDropEffect, ref, isValidDragEnter]\n );\n\n const dragLeaveCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (ref.forcedDragLeave) {\n ref.forcedDragLeave = false;\n ev.currentTarget.classList.remove('dragEnter');\n removeDropEffect(ev.currentTarget);\n if (onDragLeave) onDragLeave(ev);\n } else if (\n !ev.currentTarget.contains(ev.relatedTarget as Element) &&\n ref.dragTarget !== ev.currentTarget\n ) {\n ref.dragLeaveSkipped = true;\n }\n },\n [ref, removeDropEffect, onDragLeave]\n );\n\n const dragProps = useMemo(\n () => ({\n draggable: true,\n onDragStart: dragStartCb,\n onDragEnd: dragEndCb\n }),\n [dragStartCb, dragEndCb]\n );\n\n const dropProps = useMemo(\n () => ({\n onDragEnter: dragEnterCb,\n onDragLeave: dragLeaveCb,\n 'data-drop': 'dropzone'\n }),\n [dragEnterCb, dragLeaveCb]\n );\n\n return {\n dragProps,\n dropProps\n };\n}\n"]}
1
+ {"version":3,"file":"useDragDrop.js","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIrD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAW,GAAG,SAAS,EACvB,SAAS,GAAG,SAAS,EACrB,WAAW,GAAG,SAAS,EACvB,WAAW,GAAG,SAAS,EACvB,MAAM,EACN,gBAAgB,GAAG,IAAI,EACvB,oBAAoB,EACpB,iBAAiB,GAAG,IAAI,EACxB,qBAAqB,EACrB,gBAAgB,EACC;IACjB,6FAA6F;IAC7F,MAAM,GAAG,GAAG,MAAM,CAAc;QAC9B,UAAU,EAAE,EAAE;QACd,eAAe,EAAE,IAAI;QACrB,UAAU,EAAE,SAAS;KACtB,CAAC,CAAC,OAAO,CAAC;IAEX,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,MAAe,EAAE,EAAE;QAClB,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,C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;QAC9B,CAAC;IACH,CAAC,EACD,CAAC,GAAG,EAAE,gBAAgB,EAAE,WAAW,CAAC,CACrC,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,CAAC;QACL,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,WAAW;QACxB,SAAS,EAAE,SAAS;KACrB,CAAC,EACF,CAAC,WAAW,EAAE,SAAS,CAAC,CACzB,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,UAAU;KACxB,CAAC,EACF,CAAC,WAAW,EAAE,WAAW,CAAC,CAC3B,CAAC;IAEF,OAAO;QACL,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\n\nimport type { DragDropRef, UseDragDropProps, UseDragDropReturn } from './useDragDrop.types';\n\n/**\n * A custom React hook to handle drag-and-drop functionality with support for animations,\n * ghost images, and collision detection.\n *\n * @param params - The parameters for configuring the drag-and-drop behavior.\n * See {@link UseDragDropProps} for details.\n * @returns An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.\n * See {@link UseDragDropReturn} for details.\n */\nexport default function useDragDrop({\n context,\n onDragStart = undefined,\n onDragEnd = undefined,\n onDragEnter = undefined,\n onDragLeave = undefined,\n onDrop,\n defaultAnimation = true,\n getAnimationSelector,\n defaultGhostImage = true,\n getGhostImageSelector,\n getDraggedObject\n}: UseDragDropProps): UseDragDropReturn {\n // A way to fire dragleave when we actually come out of drop target not only a child of that.\n const ref = useRef<DragDropRef>({\n dropTarget: [],\n dropTargetCoord: null,\n dragTarget: undefined\n }).current;\n\n const addDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '0.5';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '1';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const setGhostImage = useCallback(\n (e: React.DragEvent<Element>) => {\n if (defaultGhostImage) {\n const elem = (\n getGhostImageSelector ? getGhostImageSelector(e.currentTarget) : e.currentTarget\n ) as HTMLElement;\n const ghostElement = elem.cloneNode(true) as HTMLElement;\n if (ghostElement) {\n ghostElement.style.height = `${elem.style.height}px`;\n ghostElement.style.width = `${elem.style.width}px`;\n ghostElement.style.position = 'absolute';\n ghostElement.style.top = '-1000000px';\n ghostElement.style.left = '-10000000px';\n ghostElement.style.zIndex = '-1';\n }\n context.current?.appendChild(ghostElement);\n e.dataTransfer?.setDragImage(ghostElement, 0, 0);\n\n setTimeout(() => {\n ghostElement.parentNode?.removeChild(ghostElement);\n }, 1000);\n }\n },\n [getGhostImageSelector, context, defaultGhostImage]\n );\n\n const isColliding = useCallback((x: number, y: number, coord: DOMRect): boolean => {\n const smallBuffer = 2;\n return !(\n x < coord.left - smallBuffer ||\n x > coord.right + smallBuffer ||\n y > coord.bottom + smallBuffer ||\n y < coord.top - smallBuffer\n );\n }, []);\n\n const addDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n // Need to handle this in better way.TODO: need clean up as well.\n elm.style.transition = 'transform 0.25s';\n elm.style.transform = 'translate(20px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.transform = 'translate(0px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const contextDragOverCb = useCallback(\n (e: DragEvent) => {\n e.stopPropagation();\n e.preventDefault();\n if (\n ref.dragLeaveSkipped &&\n ref.dropTarget &&\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTargetCoord &&\n !isColliding(e.clientX, e.clientY, ref.dropTargetCoord)\n ) {\n ref.forcedDragLeave = true;\n ref.dragLeaveSkipped = false;\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n },\n [isColliding, ref]\n );\n\n const contextDropCb = useCallback(\n (ev: DragEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n const elm = ref.dropTarget[ref.dropTarget.length - 1] as HTMLElement;\n if (\n ref.dropTargetCoord &&\n elm !== ref.dragTarget &&\n isColliding(ev.clientX, ev.clientY, ref.dropTargetCoord)\n ) {\n removeDropEffect(elm);\n elm.classList.remove('dragEnter');\n if (onDrop && ref.dragTarget) onDrop(elm, ref.dragTarget);\n ref.dragTarget = undefined;\n ref.dropTargetCoord = null;\n ref.dropTarget = [];\n }\n },\n [ref, isColliding, removeDropEffect, onDrop]\n );\n\n const dragStartCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n document.addEventListener('dragover', contextDragOverCb);\n context.current?.addEventListener('drop', contextDropCb);\n\n // clear the drag operation's data store when drag starts as its the only time when drag data is writable\n if (ev.dataTransfer) ev.dataTransfer.clearData();\n\n // We have to keep event handler in reference so that we can remove right handler when drag ends.\n // Handler might change in between because of deps.\n ref.contextDropCb = contextDropCb;\n ref.contextDragOverCb = contextDragOverCb;\n\n setGhostImage(ev);\n ev.dataTransfer.effectAllowed = 'move';\n // Setting up some dummy data to make drag drop work in firefox. Refer https://medium.com/%40reiberdatschi/common-pitfalls-with-html5-drag-n-drop-api-9f011a09ee6c\n ev.dataTransfer.setData('text/plain', 'RS_Dragged_Item');\n // fail safe reset drag target.\n if (ref.dragTarget) ref.dragTarget = undefined;\n ref.dragTarget = getDraggedObject ? getDraggedObject(ev.currentTarget) : ev.currentTarget;\n ev.currentTarget.classList.add('dragStart');\n addDragEffect(ev.currentTarget);\n if (onDragStart) onDragStart(ev);\n },\n [\n contextDragOverCb,\n context,\n contextDropCb,\n setGhostImage,\n ref,\n getDraggedObject,\n addDragEffect,\n onDragStart\n ]\n );\n\n const dragEndCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n if (ref.contextDragOverCb) document.removeEventListener('dragover', ref.contextDragOverCb);\n if (ref.contextDropCb) context.current?.removeEventListener('drop', ref.contextDropCb);\n ref.dropTarget = [];\n ref.dropTargetCoord = null;\n ref.forcedDragLeave = false;\n ref.dragLeaveSkipped = false;\n ev.currentTarget.classList.remove('dragStart');\n removeDragEffect(ev.currentTarget);\n if (onDragEnd) onDragEnd(ev);\n },\n [onDragEnd, removeDragEffect, context, ref]\n );\n\n const isValidDragEnter = useCallback(\n (e: React.DragEvent<Element>) => {\n let isValid = true;\n if (ref.dragTarget === e.currentTarget) isValid = false;\n else if (ref.dropTarget[ref.dropTarget.length - 1] === e.currentTarget) isValid = false;\n else if (\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTarget[ref.dropTarget.length - 1] !== e.currentTarget\n ) {\n const currentTargetCoord = e.currentTarget.getBoundingClientRect();\n const dropTargetCoord = ref.dropTarget[ref.dropTarget.length - 1].getBoundingClientRect();\n if (\n !isColliding(e.clientX, e.clientY, currentTargetCoord) &&\n isColliding(e.clientX, e.clientY, dropTargetCoord)\n )\n isValid = false;\n }\n return isValid;\n },\n [ref, isColliding]\n );\n\n const dragEnterCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (isValidDragEnter(ev)) {\n ref.dropTarget = ref.dropTarget.length ? [...ref.dropTarget] : [];\n ref.dropTarget.push(ev.currentTarget);\n ev.currentTarget.classList.add('dragEnter');\n ev.dataTransfer.dropEffect = 'move';\n ref.dropTargetCoord = ev.currentTarget.getBoundingClientRect();\n addDropEffect(ev.currentTarget);\n if (onDragEnter) onDragEnter(ev);\n\n if (ref.dropTarget.length > 1) {\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n ref.forcedDragLeave = true;\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n }\n },\n [onDragEnter, addDropEffect, ref, isValidDragEnter]\n );\n\n const dragLeaveCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (ref.forcedDragLeave) {\n ref.forcedDragLeave = false;\n ev.currentTarget.classList.remove('dragEnter');\n removeDropEffect(ev.currentTarget);\n if (onDragLeave) onDragLeave(ev);\n } else if (\n !ev.currentTarget.contains(ev.relatedTarget as Element) &&\n ref.dragTarget !== ev.currentTarget\n ) {\n ref.dragLeaveSkipped = true;\n }\n },\n [ref, removeDropEffect, onDragLeave]\n );\n\n const dragProps = useMemo(\n () => ({\n draggable: true,\n onDragStart: dragStartCb,\n onDragEnd: dragEndCb\n }),\n [dragStartCb, dragEndCb]\n );\n\n const dropProps = useMemo(\n () => ({\n onDragEnter: dragEnterCb,\n onDragLeave: dragLeaveCb,\n 'data-drop': 'dropzone'\n }),\n [dragEnterCb, dragLeaveCb]\n );\n\n return {\n dragProps,\n dropProps\n };\n}\n"]}
@@ -1,4 +1,3 @@
1
- export function wait(amount?: number): Promise<any>;
2
1
  export function updateWrapper(wrapper: any, amount?: number): Promise<void>;
3
2
  export function actWait(amount?: number): Promise<void>;
4
3
  export const cellTextColor: "rgb(166, 2, 13)";
@@ -1 +1 @@
1
- {"version":3,"file":"TestUtils.d.ts","sourceRoot":"","sources":["../../../Core/Test/TestUtils.js"],"names":[],"mappings":"AAGA,oDAGC;AAGD,4EAKC;AAGD,wDAIC;AAED,4BAA6B,iBAAiB,CAAC;AACxC;;EAEL;AACF,kCAAmC,oBAAoB,CAAC"}
1
+ {"version":3,"file":"TestUtils.d.ts","sourceRoot":"","sources":["../../../Core/Test/TestUtils.js"],"names":[],"mappings":"AAKA,4EAKC;AAGD,wDAIC;AAED,4BAA6B,iBAAiB,CAAC;AACxC;;EAEL;AACF,kCAAmC,oBAAoB,CAAC"}
@@ -1,20 +1,16 @@
1
+ import { setTimeout } from 'node:timers/promises';
1
2
  import { act } from '@testing-library/react';
2
- // An explicit wait function
3
- export function wait(amount = 0) {
4
- // eslint-disable-next-line no-promise-executor-return
5
- return new Promise(resolve => setTimeout(resolve, amount));
6
- }
7
3
  // Use this when you want to hold till your query finishes and state gets updated
8
4
  export async function updateWrapper(wrapper, amount = 0) {
9
5
  await act(async () => {
10
- await wait(amount);
6
+ await setTimeout(amount);
11
7
  wrapper.update();
12
8
  });
13
9
  }
14
10
  // Use this when you want your query to get finished
15
11
  export async function actWait(amount = 0) {
16
12
  await act(async () => {
17
- await wait(amount);
13
+ await setTimeout(amount);
18
14
  });
19
15
  }
20
16
  export const cellTextColor = 'rgb(166, 2, 13)';
@@ -1 +1 @@
1
- {"version":3,"file":"TestUtils.js","sourceRoot":"","sources":["../../../Core/Test/TestUtils.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,4BAA4B;AAC5B,MAAM,UAAU,IAAI,CAAC,MAAM,GAAG,CAAC;IAC7B,sDAAsD;IACtD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC;IACrD,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,MAAM,GAAG,CAAC;IACtC,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAAC;IAC9B,eAAe,EAAE,aAAa;CAC/B,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC","sourcesContent":["import { act } from '@testing-library/react';\n\n// An explicit wait function\nexport function wait(amount = 0) {\n // eslint-disable-next-line no-promise-executor-return\n return new Promise(resolve => setTimeout(resolve, amount));\n}\n\n// Use this when you want to hold till your query finishes and state gets updated\nexport async function updateWrapper(wrapper, amount = 0) {\n await act(async () => {\n await wait(amount);\n wrapper.update();\n });\n}\n\n// Use this when you want your query to get finished\nexport async function actWait(amount = 0) {\n await act(async () => {\n await wait(amount);\n });\n}\n\nexport const cellTextColor = 'rgb(166, 2, 13)';\nexport const getStyles = () => ({\n foregroundColor: cellTextColor\n});\nexport const cellBackgroundColor = 'rgb(255, 219, 222)';\n"]}
1
+ {"version":3,"file":"TestUtils.js","sourceRoot":"","sources":["../../../Core/Test/TestUtils.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC;IACrD,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,MAAM,GAAG,CAAC;IACtC,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAAC;IAC9B,eAAe,EAAE,aAAa;CAC/B,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC","sourcesContent":["import { setTimeout } from 'node:timers/promises';\n\nimport { act } from '@testing-library/react';\n\n// Use this when you want to hold till your query finishes and state gets updated\nexport async function updateWrapper(wrapper, amount = 0) {\n await act(async () => {\n await setTimeout(amount);\n wrapper.update();\n });\n}\n\n// Use this when you want your query to get finished\nexport async function actWait(amount = 0) {\n await act(async () => {\n await setTimeout(amount);\n });\n}\n\nexport const cellTextColor = 'rgb(166, 2, 13)';\nexport const getStyles = () => ({\n foregroundColor: cellTextColor\n});\nexport const cellBackgroundColor = 'rgb(255, 219, 222)';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Gallery/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAe7E,iBAAS,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAA;CAAE,2CAsEpD;kBAtEQ,OAAO;;;AA0EhB,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Gallery/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAgB7E,iBAAS,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAA;CAAE,2CAuEpD;kBAvEQ,OAAO;;;AA2EhB,eAAe,OAAO,CAAC"}
@@ -9,6 +9,7 @@ import RenderView from '../../Components/RenderingEngine/RenderView';
9
9
  import { EXTERNAL_FILTERS, SELECTION_MODES } from '../../constants';
10
10
  import RsCardWrapper from '../RsCardWrapper';
11
11
  import LoadingIndicator from '../../Components/LoadingIndicator';
12
+ import WarningBanner from '../../Components/WarningBanner';
12
13
  import GalleryCard from './Components/GalleryCard';
13
14
  import GalleryCheckboxCard from './Components/GalleryCheckboxCard';
14
15
  import GalleryContainer, { StyledVirtualizeContainer } from './GalleryContainer';
@@ -23,7 +24,7 @@ function Gallery({ view }) {
23
24
  cols.sort((colA, colB) => (colA.order ?? 0) - (colB.order ?? 0));
24
25
  return cols;
25
26
  }, [columns]);
26
- return (_jsx(RsCardWrapper, { children: _jsxs(GalleryContainer, { "data-test-id": 'gallery', "data-testid": 'gallery', view: view, isFullscreen: isFullscreen, image: heroImage, children: [_jsx(Toolbar, { view: view }), _jsx(RenderView, { view: view, type: EXTERNAL_FILTERS }), _jsxs(StyledVirtualizeContainer, { className: 'container', children: [_jsx(Virtualiser, { id: 'rootVirtualiser', rowContainerClass: 'grid-container', view: view, bufferMultiplier: 0.8, children: rows?.length
27
+ return (_jsx(RsCardWrapper, { children: _jsxs(GalleryContainer, { "data-test-id": 'gallery', "data-testid": 'gallery', view: view, isFullscreen: isFullscreen, image: heroImage, children: [_jsx(WarningBanner, { warningMessages: view.warningMessages }), _jsx(Toolbar, { view: view }), _jsx(RenderView, { view: view, type: EXTERNAL_FILTERS }), _jsxs(StyledVirtualizeContainer, { className: 'container', children: [_jsx(Virtualiser, { id: 'rootVirtualiser', rowContainerClass: 'grid-container', view: view, bufferMultiplier: 0.8, children: rows?.length
27
28
  ? rows.map(row => selectionMode === SELECTION_MODES.multi && selectionColumn ? (_jsx(GalleryCheckboxCard, { meta: meta, row: row, visibleColumns: visibleColumns, headerColumn: headerColumn, selectionColumn: selectionColumn }, row.reactKey)) : (_jsx(GalleryCard, { meta: meta, row: row, visibleColumns: visibleColumns, headerColumn: headerColumn }, row.reactKey)))
28
29
  : [] }), _jsx(LoadingIndicator, { view: view, show: !rows || !!view.isLoading })] })] }) }));
29
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Core/Views/Gallery/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAoB,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAE5F,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,UAAU,MAAM,6CAA6C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,mCAAmC,CAAC;AAEjE,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,gBAAgB,EAAE,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,SAAS,OAAO,CAAC,EAAE,IAAI,EAA8B;IACnD,MAAM,YAAY,GAAG,CAAC,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAEnD,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAC1C,MAAM,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,E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C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,GAAI,EAClD,MAAC,yBAAyB,IAAC,SAAS,EAAC,WAAW,aAC9C,KAAC,WAAW,IACV,EAAE,EAAC,iBAAiB,EACpB,iBAAiB,EAAC,gBAAgB,EAClC,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,GAAG,YAEpB,IAAI,EAAE,MAAM;gCACX,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CACb,aAAa,KAAK,eAAe,CAAC,KAAK,IAAI,eAAe,CAAC,CAAC,CAAC,CAC3D,KAAC,mBAAmB,IAElB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,IAL3B,GAAG,CAAC,QAAQ,CAMjB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,IAEV,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,IAJrB,GAAG,CAAC,QAAQ,CAKjB,CACH,CACF;gCACH,CAAC,CAAC,EAAE,GACM,EACd,KAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,GAAI,IACvC,IACX,GACL,CACjB,CAAC;AACJ,CAAC;AAED,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;AAEhC,eAAe,OAAO,CAAC","sourcesContent":["import { useMemo } from 'react';\n\nimport { FieldType, type RsCoreTypes } from 'pega-repeating-structures-core';\nimport { useFullscreenContext } from '@pega/cosmos-react-core';\nimport { rowSelectColumnMeta } from 'pega-repeating-structures-core/lib/src/core/constants';\n\nimport Virtualiser from '../Table/VirtualizeWrapper';\nimport Toolbar from '../../Components/Toolbar';\nimport RenderView from '../../Components/RenderingEngine/RenderView';\nimport { EXTERNAL_FILTERS, SELECTION_MODES } from '../../constants';\nimport RsCardWrapper from '../RsCardWrapper';\nimport LoadingIndicator from '../../Components/LoadingIndicator';\n\nimport GalleryCard from './Components/GalleryCard';\nimport GalleryCheckboxCard from './Components/GalleryCheckboxCard';\nimport GalleryContainer, { StyledVirtualizeContainer } from './GalleryContainer';\n\nfunction Gallery({ view }: { view: RsCoreTypes.View }) {\n const isFullscreen = !!useFullscreenContext()?.[0];\n\n const { columns = [], meta, rows } = view;\n const { galleryConfig: { heroImage, header } = {}, selectionMode } = meta;\n\n const headerColumn = useMemo(\n () => (header?.field ? columns.find(col => col.field.id === header.field) : undefined),\n [header, columns]\n );\n\n const selectionColumn = useMemo(\n () => columns.find(col => col.field.id === rowSelectColumnMeta.field.id),\n [columns]\n );\n\n const visibleColumns = useMemo(() => {\n const cols = [...columns].filter(\n col => !col.hidden && col.field.type !== FieldType.ACTION_FIELD_TYPE\n );\n cols.sort((colA, colB) => (colA.order ?? 0) - (colB.order ?? 0));\n return cols;\n }, [columns]);\n\n return (\n <RsCardWrapper>\n <GalleryContainer\n data-test-id='gallery'\n data-testid='gallery'\n view={view}\n isFullscreen={isFullscreen}\n image={heroImage}\n >\n <Toolbar view={view} />\n <RenderView view={view} type={EXTERNAL_FILTERS} />\n <StyledVirtualizeContainer className='container'>\n <Virtualiser\n id='rootVirtualiser'\n rowContainerClass='grid-container'\n view={view}\n bufferMultiplier={0.8}\n >\n {rows?.length\n ? rows.map(row =>\n selectionMode === SELECTION_MODES.multi && selectionColumn ? (\n <GalleryCheckboxCard\n key={row.reactKey}\n meta={meta}\n row={row}\n visibleColumns={visibleColumns}\n headerColumn={headerColumn}\n selectionColumn={selectionColumn}\n />\n ) : (\n <GalleryCard\n key={row.reactKey}\n meta={meta}\n row={row}\n visibleColumns={visibleColumns}\n headerColumn={headerColumn}\n />\n )\n )\n : []}\n </Virtualiser>\n <LoadingIndicator view={view} show={!rows || !!view.isLoading} />\n </StyledVirtualizeContainer>\n </GalleryContainer>\n </RsCardWrapper>\n );\n}\n\nGallery.displayName = 'Gallery';\n\nexport default Gallery;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Core/Views/Gallery/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAoB,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAE5F,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,UAAU,MAAM,6CAA6C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,mCAAmC,CAAC;AACjE,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAE3D,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,gBAAgB,EAAE,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,SAAS,OAAO,CAAC,EAAE,IAAI,EAA8B;IACnD,MAAM,YAAY,GAAG,CAAC,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAEnD,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAC1C,MAAM,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAE1E,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,C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AAS,EAAC,WAAW,aAC9C,KAAC,WAAW,IACV,EAAE,EAAC,iBAAiB,EACpB,iBAAiB,EAAC,gBAAgB,EAClC,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,GAAG,YAEpB,IAAI,EAAE,MAAM;gCACX,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CACb,aAAa,KAAK,eAAe,CAAC,KAAK,IAAI,eAAe,CAAC,CAAC,CAAC,CAC3D,KAAC,mBAAmB,IAElB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,IAL3B,GAAG,CAAC,QAAQ,CAMjB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,IAEV,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,IAJrB,GAAG,CAAC,QAAQ,CAKjB,CACH,CACF;gCACH,CAAC,CAAC,EAAE,GACM,EACd,KAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,GAAI,IACvC,IACX,GACL,CACjB,CAAC;AACJ,CAAC;AAED,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;AAEhC,eAAe,OAAO,CAAC","sourcesContent":["import { useMemo } from 'react';\n\nimport { FieldType, type RsCoreTypes } from 'pega-repeating-structures-core';\nimport { useFullscreenContext } from '@pega/cosmos-react-core';\nimport { rowSelectColumnMeta } from 'pega-repeating-structures-core/lib/src/core/constants';\n\nimport Virtualiser from '../Table/VirtualizeWrapper';\nimport Toolbar from '../../Components/Toolbar';\nimport RenderView from '../../Components/RenderingEngine/RenderView';\nimport { EXTERNAL_FILTERS, SELECTION_MODES } from '../../constants';\nimport RsCardWrapper from '../RsCardWrapper';\nimport LoadingIndicator from '../../Components/LoadingIndicator';\nimport WarningBanner from '../../Components/WarningBanner';\n\nimport GalleryCard from './Components/GalleryCard';\nimport GalleryCheckboxCard from './Components/GalleryCheckboxCard';\nimport GalleryContainer, { StyledVirtualizeContainer } from './GalleryContainer';\n\nfunction Gallery({ view }: { view: RsCoreTypes.View }) {\n const isFullscreen = !!useFullscreenContext()?.[0];\n\n const { columns = [], meta, rows } = view;\n const { galleryConfig: { heroImage, header } = {}, selectionMode } = meta;\n\n const headerColumn = useMemo(\n () => (header?.field ? columns.find(col => col.field.id === header.field) : undefined),\n [header, columns]\n );\n\n const selectionColumn = useMemo(\n () => columns.find(col => col.field.id === rowSelectColumnMeta.field.id),\n [columns]\n );\n\n const visibleColumns = useMemo(() => {\n const cols = [...columns].filter(\n col => !col.hidden && col.field.type !== FieldType.ACTION_FIELD_TYPE\n );\n cols.sort((colA, colB) => (colA.order ?? 0) - (colB.order ?? 0));\n return cols;\n }, [columns]);\n\n return (\n <RsCardWrapper>\n <GalleryContainer\n data-test-id='gallery'\n data-testid='gallery'\n view={view}\n isFullscreen={isFullscreen}\n image={heroImage}\n >\n <WarningBanner warningMessages={view.warningMessages} />\n <Toolbar view={view} />\n <RenderView view={view} type={EXTERNAL_FILTERS} />\n <StyledVirtualizeContainer className='container'>\n <Virtualiser\n id='rootVirtualiser'\n rowContainerClass='grid-container'\n view={view}\n bufferMultiplier={0.8}\n >\n {rows?.length\n ? rows.map(row =>\n selectionMode === SELECTION_MODES.multi && selectionColumn ? (\n <GalleryCheckboxCard\n key={row.reactKey}\n meta={meta}\n row={row}\n visibleColumns={visibleColumns}\n headerColumn={headerColumn}\n selectionColumn={selectionColumn}\n />\n ) : (\n <GalleryCard\n key={row.reactKey}\n meta={meta}\n row={row}\n visibleColumns={visibleColumns}\n headerColumn={headerColumn}\n />\n )\n )\n : []}\n </Virtualiser>\n <LoadingIndicator view={view} show={!rows || !!view.isLoading} />\n </StyledVirtualizeContainer>\n </GalleryContainer>\n </RsCardWrapper>\n );\n}\n\nGallery.displayName = 'Gallery';\n\nexport default Gallery;\n"]}
@@ -816,7 +816,7 @@ const StyledTableContainer = styled(forwardRef((props, ref) => _jsx("div", { ref
816
816
  > .cell {
817
817
  display: inline-grid;
818
818
  align-items: start;
819
- white-space: normal;
819
+ white-space: pre-wrap;
820
820
  word-break: break-all;
821
821
  grid-auto-flow: column;
822
822
 
@@ -855,7 +855,7 @@ const StyledTableContainer = styled(forwardRef((props, ref) => _jsx("div", { ref
855
855
  height: auto;
856
856
  min-height: var(--row-min-height);
857
857
  > .cell {
858
- white-space: normal;
858
+ white-space: pre-wrap;
859
859
 
860
860
  /* -- For BUG-625508 -- */
861
861
  word-break: break-word;