@pega/lists-react 9.0.0-build.6.9 → 9.0.0-build.7.1
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/lib/Core/Components/ContextMenu/ContextMenuContainer.d.ts.map +1 -1
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.js +4 -2
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.js.map +1 -1
- package/lib/Core/Components/Grouping/GroupingMenu.js +1 -1
- package/lib/Core/Components/Grouping/GroupingMenu.js.map +1 -1
- package/lib/Core/Components/Toolbar/AdvanceToolbar.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/AdvanceToolbar.js +3 -16
- package/lib/Core/Components/Toolbar/AdvanceToolbar.js.map +1 -1
- package/lib/Core/Components/Toolbar/SimpleToolbar.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/SimpleToolbar.js +3 -1
- package/lib/Core/Components/Toolbar/SimpleToolbar.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useSort/Row.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useSort/Row.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useWrapAction.d.ts +6 -0
- package/lib/Core/Components/Toolbar/hooks/useWrapAction.d.ts.map +1 -0
- package/lib/Core/Components/Toolbar/hooks/useWrapAction.js +17 -0
- package/lib/Core/Components/Toolbar/hooks/useWrapAction.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts +97 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js +249 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.d.ts +22 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.js +38 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.d.ts +22 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.js +45 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.d.ts +49 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.js +55 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.d.ts +21 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.js +39 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.d.ts +38 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.js +62 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.d.ts +112 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js +213 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js.map +1 -0
- package/lib/Core/Components/Virtualise/index.js +3 -11
- package/lib/Core/Components/Virtualise/index.js.map +1 -1
- package/lib/Core/Components/Virtualise/utility.d.ts +1 -1
- package/lib/Core/Components/Virtualise/utility.d.ts.map +1 -1
- package/lib/Core/Components/Virtualise/utility.js +3 -2
- package/lib/Core/Components/Virtualise/utility.js.map +1 -1
- package/lib/Core/Hooks/useDragDrop.d.ts.map +1 -1
- package/lib/Core/Hooks/useDragDrop.js +2 -0
- package/lib/Core/Hooks/useDragDrop.js.map +1 -1
- package/lib/Core/Views/Gallery/StyledGalleryContainer.d.ts.map +1 -1
- package/lib/Core/Views/Gallery/StyledGalleryContainer.js +1 -0
- package/lib/Core/Views/Gallery/StyledGalleryContainer.js.map +1 -1
- package/lib/Core/Views/Table/Row.d.ts +3 -1
- package/lib/Core/Views/Table/Row.d.ts.map +1 -1
- package/lib/Core/Views/Table/Row.js +5 -3
- package/lib/Core/Views/Table/Row.js.map +1 -1
- package/lib/Core/Views/Table/StyledTableContainer.d.ts.map +1 -1
- package/lib/Core/Views/Table/StyledTableContainer.js +4 -0
- package/lib/Core/Views/Table/StyledTableContainer.js.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.d.ts +3 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.d.ts.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.js +18 -2
- package/lib/Core/Views/Table/VirtualizeWrapper.js.map +1 -1
- package/lib/Core/Views/Table/index.d.ts.map +1 -1
- package/lib/Core/Views/Table/index.js +2 -2
- package/lib/Core/Views/Table/index.js.map +1 -1
- package/lib/Core/Views/Table/useCountChange.d.ts +10 -0
- package/lib/Core/Views/Table/useCountChange.d.ts.map +1 -0
- package/lib/Core/Views/Table/useCountChange.js +39 -0
- package/lib/Core/Views/Table/useCountChange.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +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;AA2BnE;;;;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,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,GAAG,SAAS,EAC3F,CAAC;QACD,uBAAuB,IAAI,WAAW,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CAAC;QAC/E,iBAAiB,IAAI,CAAC,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C,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,aAA0B,EAC1B,WAAwB,EACxB,iBAAyB,EACjB,EAAE;IACV,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC;IACrC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,kBAAkB,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,IAAI,kBAAkB,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAG,iBAAiB,CAAC,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;IACrF,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,MAAM,IAAI,CAAC;IAExC,IAAI,0BAA0B,GAAG,CAAC,CAAC;IACnC,IAAI,gBAAgB,GAAG,kBAAkB,CAAC;IAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAa,EAAE,EAAE;QAC1C,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,CAAC;YAAE,OAAO;QAE3C,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';\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<HTMLElement>;\n /** Ref to the container holding the list items */\n itemContainerRef: RefObject<HTMLElement>;\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: HTMLElement,\n parentContainer: HTMLElement,\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 (firstChild instanceof HTMLElement) {\n headerHeight = firstChild.offsetHeight;\n }\n }\n\n const scrollbarWidth = getScrollbarWidth();\n const items = Array.from(itemContainer.children).filter(\n (el): el is HTMLElement => el instanceof HTMLElement\n );\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: HTMLElement,\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: HTMLElement,\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: Element) => {\n if (!(item instanceof HTMLElement)) 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"]}
|
|
@@ -9,7 +9,7 @@ import useTranslate from '../../Hooks/useTranslate';
|
|
|
9
9
|
import { StyledSkeletonRow } from '../../Views/Table/SkeletonRows';
|
|
10
10
|
import getPaginationInfo from './Pagination';
|
|
11
11
|
import useScroll from './UseScroll';
|
|
12
|
-
import { getCurrentEstimation, updateRowContainerTop, setAttributesOnItems, isViewNotFilled, getRecordCountForLayoutPaint,
|
|
12
|
+
import { getCurrentEstimation, updateRowContainerTop, setAttributesOnItems, isViewNotFilled, getRecordCountForLayoutPaint, getValueWithUnit, getMaxHeight } from './utility';
|
|
13
13
|
import useResizeObserver from './UseResizeObserver';
|
|
14
14
|
function getBContainerMinHeight(props) {
|
|
15
15
|
return props.$style.renderFooter ? `calc(100% - ${2 * props.$style.itemHeight + 1}px) ` : '0';
|
|
@@ -35,7 +35,6 @@ const StyledPContainer = Styled.div `
|
|
|
35
35
|
props.$style.height?.startsWith?.('auto')
|
|
36
36
|
? 'relative'
|
|
37
37
|
: 'sticky'};
|
|
38
|
-
width: 0;
|
|
39
38
|
min-height: ${props => getBContainerMinHeight(props)};
|
|
40
39
|
border-radius: inherit;
|
|
41
40
|
}
|
|
@@ -46,7 +45,7 @@ const StyledLoader = Styled.div `
|
|
|
46
45
|
justify-content: center;
|
|
47
46
|
padding: 0.5rem;
|
|
48
47
|
position: absolute;
|
|
49
|
-
width:
|
|
48
|
+
width: 100%;
|
|
50
49
|
left: ${props => `var(${props.$style.left})`};
|
|
51
50
|
top: ${props => `var(${props.$style.top})`};
|
|
52
51
|
`;
|
|
@@ -216,13 +215,6 @@ const Virtualize = forwardRef(({ id, viewHeight, viewWidth, totalRecordCount, it
|
|
|
216
215
|
getRowContainer,
|
|
217
216
|
getBContainer
|
|
218
217
|
]);
|
|
219
|
-
// setting pContainer's width whenever pContainer dimension updates,
|
|
220
|
-
// because bContainer has 0 width and row-container's width doesn't changes in sync with pContainer
|
|
221
|
-
const onPContainerDimensionUpdate = useCallback(() => {
|
|
222
|
-
getPContainer()?.style.setProperty('--container-width', `${getPContainerClientWidth(getPContainer())}px`);
|
|
223
|
-
}, [getPContainer]);
|
|
224
|
-
// observe on pContainer to adjust the width of row container.
|
|
225
|
-
useResizeObserver(getPContainer, onPContainerDimensionUpdate);
|
|
226
218
|
// On mount that means state is not initialized yet, trigger pagination.
|
|
227
219
|
// or whenever count changes or width /height of view port changes, if view is not filled with data, get indexes again.
|
|
228
220
|
useEffect(() => {
|
|
@@ -267,7 +259,7 @@ const Virtualize = forwardRef(({ id, viewHeight, viewWidth, totalRecordCount, it
|
|
|
267
259
|
left: '--loader-left'
|
|
268
260
|
}, children: _jsx(Progress, { className: 'above-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) })), _jsx("div", { className: `${rowContainerClass} row-container`, ref: c => {
|
|
269
261
|
vi.rContainer = c;
|
|
270
|
-
},
|
|
262
|
+
}, role: 'rowgroup', children: children }), showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (_jsx(StyledLoader, { "$style": {
|
|
271
263
|
top: '--below-loader-top',
|
|
272
264
|
left: '--loader-left'
|
|
273
265
|
}, children: _jsx(Progress, { className: 'below-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) }))] }), totalRecordCount === 0 ? _jsx(EmptyContainer, {}) : null, renderFooter && renderFooter()] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/index.jsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,SAAS,EACT,MAAM,EACN,WAAW,EACX,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,iBAAiB,MAAM,cAAc,CAAC;AAC7C,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,4BAA4B,EAC5B,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACb,MAAM,WAAW,CAAC;AACnB,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,SAAS,sBAAsB,CAAC,KAAK;IAC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AC;IACnB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,UAAU,EAAE,KAAK;IACjB,iBAAiB,EAAE,EAAE;IACrB,SAAS,EAAE,CAAC;IACZ,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,SAAS;IAChB,gBAAgB,EAAE,SAAS;IAC3B,aAAa,EAAE,SAAS;IACxB,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AAEtC,eAAe,IAAI,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import {\n forwardRef,\n memo,\n useEffect,\n useRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useLayoutEffect,\n useState\n} from 'react';\nimport Styled from 'styled-components';\nimport PropTypes from 'prop-types';\n\nimport { defaultThemeProp, Progress } from '@pega/cosmos-react-core';\nimport { isEmpty } from 'pega-repeating-structures-core';\n\nimport EmptyContainer from '../DefaultComponents/EmptyContainer';\nimport useTranslate from '../../Hooks/useTranslate';\nimport { StyledSkeletonRow } from '../../Views/Table/SkeletonRows';\n\nimport getPaginationInfo from './Pagination';\nimport useScroll from './UseScroll';\nimport {\n getCurrentEstimation,\n updateRowContainerTop,\n setAttributesOnItems,\n isViewNotFilled,\n getRecordCountForLayoutPaint,\n getPContainerClientWidth,\n getValueWithUnit,\n getMaxHeight\n} from './utility';\nimport useResizeObserver from './UseResizeObserver';\n\nfunction getBContainerMinHeight(props) {\n return props.$style.renderFooter ? `calc(100% - ${2 * props.$style.itemHeight + 1}px) ` : '0';\n}\n\nconst StyledPContainer = Styled.div`\n position: relative;\n overflow: auto;\n max-height: ${props => props.$style.maxHeight};\n width: ${props => props.$style.width};\n height: ${props => props.$style.height};\n min-height: ${props => props.$style.minHeight};\n\n &:has(${StyledSkeletonRow}) {\n overflow: hidden;\n }\n\n /**\n * When height and maxHeight is auto, virtualization is not going to happen and the scroll jump on row deletion scenario is not going to happen.\n * In such cases, using relative position as sticky was used to fix scroll jump in firefox during virtualization.\n */\n .bContainer {\n position: ${props =>\n props.$style.maxHeight?.startsWith?.('auto') &&\n props.$style.height?.startsWith?.('auto')\n ? 'relative'\n : 'sticky'};\n width: 0;\n min-height: ${props => getBContainerMinHeight(props)};\n border-radius: inherit;\n }\n`;\n\nStyledPContainer.defaultProps = defaultThemeProp;\n\nconst StyledLoader = Styled.div`\n display: flex;\n justify-content: center;\n padding: 0.5rem;\n position: absolute;\n width: var(--container-width);\n left: ${props => `var(${props.$style.left})`};\n top: ${props => `var(${props.$style.top})`};\n`;\n\nconst Virtualize = forwardRef(\n (\n {\n id,\n viewHeight,\n viewWidth,\n totalRecordCount,\n itemHeight,\n callback,\n isFetching,\n rowContainerClass,\n children,\n renderHeader,\n renderFooter,\n state,\n bufferMultiplier,\n viewMaxHeight,\n showLoadingIndicator\n },\n inputRef\n ) => {\n const [rContainerDimensionUpdate, setRContainerDimensionUpdate] = useState();\n const [loadingIndicatorInfo, setLoadingIndicatorInfo] = useState({});\n const [translate] = useTranslate();\n // Create ref to store virtualize related data.\n const vi = useRef({\n itemHeight,\n bufferMultiplier,\n pInfo: {}\n }).current;\n\n const getRowContainer = useCallback(() => vi.rContainer, [vi.rContainer]);\n const getPContainer = useCallback(() => vi.pContainer, [vi.pContainer]);\n const getBContainer = useCallback(() => vi.bContainer, [vi.bContainer]);\n\n // API used when user want to scroll to top programmatically.\n // Though component auto scroll to top if no element is in view.\n // But calling this API upfront might save one extra call to Fetch API.\n const scrollToTop = useCallback(() => {\n if (!state) return;\n getPContainer().scrollTop = 0;\n vi.pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(totalRecordCount),\n vi,\n false,\n true\n );\n callback({ ...vi.pInfo.view, id }, { takeLatestAction: true });\n }, [id, vi, state, getPContainer]);\n\n // expose APIs and properties here to help client to communicate.\n useImperativeHandle(inputRef, () => ({\n getParentContainer: getPContainer,\n scrollToTop,\n vi,\n id\n }));\n\n const { width, height } = useMemo(\n () => ({\n width: getValueWithUnit(viewWidth, '100%'),\n height: getValueWithUnit(viewHeight, 'auto')\n }),\n [viewWidth, viewHeight]\n );\n\n const maxHeight = useMemo(() => getMaxHeight(viewMaxHeight), [viewMaxHeight]);\n\n const minHeight = useMemo(\n () => (totalRecordCount === 0 ? '100px' : 'auto'),\n [totalRecordCount]\n );\n\n // Calculate the pagination indexes and notify callback.\n // resetIsFetchingWhenNoNewIndexes - flag specific for isViewNotFilled\n // If view is not filled, we want to call this but restting isFetch to false\n // goes to this methid when callback is note fired.\n const getPagination = useCallback(\n (isRefresh = false, resetIsFetchingWhenNoNewIndexes = false) => {\n if (resetIsFetchingWhenNoNewIndexes) {\n setLoadingIndicatorInfo({});\n }\n const pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(totalRecordCount),\n vi,\n isRefresh\n );\n const { startIndex, endIndex } = pInfo.view;\n // if new indexes are subset of existing state indexes, no need to update the consumer.\n if (!state || !(startIndex >= state.startIndex && endIndex <= state.endIndex)) {\n vi.pInfo = pInfo;\n if (state) {\n const { startIndex: oldStartIndex, endIndex: oldEndIndex } = state;\n if (startIndex < oldStartIndex) {\n setLoadingIndicatorInfo(info => {\n return { ...info, isScrollingUp: true };\n });\n }\n if (endIndex > oldEndIndex) {\n setLoadingIndicatorInfo(info => {\n return { ...info, isScrollingDown: true };\n });\n }\n }\n callback({ ...vi.pInfo.view, id }, { takeLatestAction: true });\n }\n },\n [vi, totalRecordCount, state, callback, id, getPContainer]\n );\n\n // update average stats for next calculation.\n const updateAverageInVirtualizeInstance = useCallback(\n currentEstimation => {\n const { itemCount, rowContainerHeight, averageNumberOfItemsInARow, averageRowHeight } =\n currentEstimation;\n Object.assign(vi, {\n itemCount: (itemCount + vi.itemCount || itemCount) / 2,\n rowContainerHeight:\n (rowContainerHeight + vi.rowContainerHeight || rowContainerHeight) / 2,\n averageNumberOfItemsInARow:\n (averageNumberOfItemsInARow + vi.averageNumberOfItemsInARow ||\n averageNumberOfItemsInARow) / 2,\n averageRowHeight: (averageRowHeight + vi.averageRowHeight || averageRowHeight) / 2\n });\n },\n [vi]\n );\n\n const getBufferHeight = useCallback(\n currentEstimation => {\n const { itemCount, rowContainerHeight } = currentEstimation;\n let h = 0;\n if (itemCount > 0)\n h = (getRecordCountForLayoutPaint(totalRecordCount) / itemCount) * rowContainerHeight;\n return h;\n },\n [totalRecordCount]\n );\n\n const getScrollTop = useCallback(\n currentEstimation => {\n const { itemCount, rowContainerHeight } = currentEstimation;\n let scrollTop = 0;\n if (itemCount > 0) {\n const scrollNodeTopChange =\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.bufferNewCords?.top - vi.pInfo?.bufferOldCords?.top || 0;\n scrollTop = (vi.pInfo.topRowIndex / itemCount) * rowContainerHeight - scrollNodeTopChange;\n }\n return scrollTop;\n },\n [vi]\n );\n\n const onRowContainerDimensionChange = useCallback(() => {\n const { height: rowContainerHeight, width: rowContainerWidth } =\n getRowContainer()?.getBoundingClientRect() ?? {};\n // trigger virtualizer operations only when row container has some height and width\n if (rowContainerHeight && rowContainerWidth) setRContainerDimensionUpdate({});\n }, [getRowContainer]);\n\n // observe on row container to adjust the buffer container height.\n useResizeObserver(getRowContainer, onRowContainerDimensionChange);\n\n const [updateScrollTop] = useScroll(\n getPagination,\n getPContainer,\n vi,\n totalRecordCount,\n renderHeader,\n isFetching,\n viewHeight\n );\n\n useLayoutEffect(() => {\n const rContainer = getRowContainer();\n if (state && state.startIndex >= 0 && vi && rContainer) {\n setAttributesOnItems(state, rContainer);\n }\n });\n\n // Get estimate and update buffer height\n useLayoutEffect(() => {\n if (state && !isEmpty(totalRecordCount)) {\n vi.currentEstimation = getCurrentEstimation(getRowContainer());\n updateAverageInVirtualizeInstance(vi.currentEstimation);\n const h = Math.floor(getBufferHeight(vi.currentEstimation));\n const previousHeight = getBContainer().offsetHeight;\n\n getBContainer().style.height = `${h}px`;\n vi.bContainerHeight = h;\n\n // if there was no previous height, then keep the scrolltop to 0 by default\n if (h !== previousHeight && previousHeight) {\n const pContainer = getPContainer();\n const scrollTop = getScrollTop(vi.currentEstimation);\n if (scrollTop >= 0) {\n pContainer.scrollTop = scrollTop;\n }\n }\n }\n }, [\n rContainerDimensionUpdate,\n getBContainer,\n getBufferHeight,\n getRowContainer,\n state,\n totalRecordCount,\n updateAverageInVirtualizeInstance,\n vi,\n getPContainer,\n getScrollTop\n ]);\n\n // update parent scroll top and row container top.\n useLayoutEffect(() => {\n if (state && !isEmpty(totalRecordCount)) {\n const pContainer = getPContainer();\n\n // Setting scrollTop from pContainer.scrollTop as getScrollTop can return value with higher decimal accuracy.\n // but scrollTop attribute from HTML element will round it automatically.\n updateScrollTop(pContainer.scrollTop);\n updateRowContainerTop(\n vi,\n getRecordCountForLayoutPaint(totalRecordCount),\n state,\n pContainer,\n pContainer.scrollTop\n );\n\n const topLoaderHeight = 80;\n let top = getRowContainer().style.top;\n if (!top) {\n top = 0;\n }\n getBContainer().style.setProperty(\n '--above-loader-top',\n `${parseInt(top, 10) - topLoaderHeight}px`\n );\n\n getBContainer().style.setProperty(\n '--below-loader-top',\n `${parseInt(top, 10) + getRowContainer().offsetHeight}px`\n );\n }\n }, [\n getPContainer,\n getScrollTop,\n state,\n updateScrollTop,\n vi,\n rContainerDimensionUpdate,\n totalRecordCount,\n getRowContainer,\n getBContainer\n ]);\n\n // setting pContainer's width whenever pContainer dimension updates,\n // because bContainer has 0 width and row-container's width doesn't changes in sync with pContainer\n const onPContainerDimensionUpdate = useCallback(() => {\n getPContainer()?.style.setProperty(\n '--container-width',\n `${getPContainerClientWidth(getPContainer())}px`\n );\n }, [getPContainer]);\n\n // observe on pContainer to adjust the width of row container.\n useResizeObserver(getPContainer, onPContainerDimensionUpdate);\n\n // On mount that means state is not initialized yet, trigger pagination.\n // or whenever count changes or width /height of view port changes, if view is not filled with data, get indexes again.\n useEffect(() => {\n if (state && !isFetching && !isEmpty(totalRecordCount)) {\n if (\n isViewNotFilled(\n getRecordCountForLayoutPaint(totalRecordCount),\n vi,\n getPContainer(),\n renderHeader\n )\n )\n getPagination(false, true);\n else {\n setLoadingIndicatorInfo({});\n }\n } else if (!state || !Object.keys(vi.pInfo).length) getPagination(true);\n }, [\n rContainerDimensionUpdate,\n state,\n vi,\n totalRecordCount,\n viewHeight,\n viewWidth,\n renderHeader,\n getPagination,\n getPContainer\n ]);\n\n useEffect(() => {\n if (!isFetching) return;\n getBContainer().style.setProperty('--loader-left', `${getPContainer().scrollLeft}px`);\n }, [isFetching, getPContainer()?.scrollLeft]);\n\n return (\n <StyledPContainer\n $style={{\n maxHeight,\n minHeight,\n renderFooter,\n itemHeight,\n height,\n width\n }}\n data-total-records={totalRecordCount}\n className='pContainer'\n ref={c => {\n vi.pContainer = c;\n }}\n >\n {renderHeader && renderHeader()}\n <div\n className='bContainer'\n ref={c => {\n vi.bContainer = c;\n }}\n >\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingUp && (\n <StyledLoader\n $style={{\n top: '--above-loader-top',\n left: '--loader-left'\n }}\n >\n <Progress\n className='above-loader'\n placement='block'\n tabIndex={0}\n aria-label={translate('Loading more results')}\n />\n </StyledLoader>\n )}\n <div\n className={`${rowContainerClass} row-container`}\n ref={c => {\n vi.rContainer = c;\n }}\n style={{ width: 'var(--container-width)' }}\n role='rowgroup'\n >\n {/** Do not add any other element in row-container apart from the rows as it will generate incorrect estimations */}\n {children}\n </div>\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (\n <StyledLoader\n $style={{\n top: '--below-loader-top',\n left: '--loader-left'\n }}\n >\n <Progress\n className='below-loader'\n placement='block'\n tabIndex={0}\n aria-label={translate('Loading more results')}\n />\n </StyledLoader>\n )}\n </div>\n {totalRecordCount === 0 ? <EmptyContainer /> : null}\n {renderFooter && renderFooter()}\n </StyledPContainer>\n );\n }\n);\n\nVirtualize.propTypes = {\n id: PropTypes.string.isRequired,\n viewHeight: PropTypes.number,\n viewWidth: PropTypes.number,\n totalRecordCount: PropTypes.number,\n itemHeight: PropTypes.number,\n callback: PropTypes.func,\n isFetching: PropTypes.bool,\n rowContainerClass: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,\n renderHeader: PropTypes.func,\n renderFooter: PropTypes.func,\n state: PropTypes.shape({\n startIndex: PropTypes.number,\n endIndex: PropTypes.number\n }),\n bufferMultiplier: PropTypes.number,\n viewMaxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n showLoadingIndicator: PropTypes.bool\n};\n\nVirtualize.defaultProps = {\n bufferMultiplier: 2,\n callback: () => {},\n isFetching: false,\n rowContainerClass: '',\n viewWidth: 0,\n itemHeight: 40,\n renderHeader: null,\n renderFooter: null,\n state: undefined,\n totalRecordCount: undefined,\n viewMaxHeight: undefined,\n showLoadingIndicator: false\n};\n\nVirtualize.displayName = 'Virtualize';\n\nexport default memo(Virtualize);\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/index.jsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,SAAS,EACT,MAAM,EACN,WAAW,EACX,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,iBAAiB,MAAM,cAAc,CAAC;AAC7C,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,oBAAoB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AI;IAClB,KAAK,EAAE,SAAS;IAChB,gBAAgB,EAAE,SAAS;IAC3B,aAAa,EAAE,SAAS;IACxB,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AAEtC,eAAe,IAAI,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import {\n forwardRef,\n memo,\n useEffect,\n useRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useLayoutEffect,\n useState\n} from 'react';\nimport Styled from 'styled-components';\nimport PropTypes from 'prop-types';\n\nimport { defaultThemeProp, Progress } from '@pega/cosmos-react-core';\nimport { isEmpty } from 'pega-repeating-structures-core';\n\nimport EmptyContainer from '../DefaultComponents/EmptyContainer';\nimport useTranslate from '../../Hooks/useTranslate';\nimport { StyledSkeletonRow } from '../../Views/Table/SkeletonRows';\n\nimport getPaginationInfo from './Pagination';\nimport useScroll from './UseScroll';\nimport {\n getCurrentEstimation,\n updateRowContainerTop,\n setAttributesOnItems,\n isViewNotFilled,\n getRecordCountForLayoutPaint,\n getValueWithUnit,\n getMaxHeight\n} from './utility';\nimport useResizeObserver from './UseResizeObserver';\n\nfunction getBContainerMinHeight(props) {\n return props.$style.renderFooter ? `calc(100% - ${2 * props.$style.itemHeight + 1}px) ` : '0';\n}\n\nconst StyledPContainer = Styled.div`\n position: relative;\n overflow: auto;\n max-height: ${props => props.$style.maxHeight};\n width: ${props => props.$style.width};\n height: ${props => props.$style.height};\n min-height: ${props => props.$style.minHeight};\n\n &:has(${StyledSkeletonRow}) {\n overflow: hidden;\n }\n\n /**\n * When height and maxHeight is auto, virtualization is not going to happen and the scroll jump on row deletion scenario is not going to happen.\n * In such cases, using relative position as sticky was used to fix scroll jump in firefox during virtualization.\n */\n .bContainer {\n position: ${props =>\n props.$style.maxHeight?.startsWith?.('auto') &&\n props.$style.height?.startsWith?.('auto')\n ? 'relative'\n : 'sticky'};\n min-height: ${props => getBContainerMinHeight(props)};\n border-radius: inherit;\n }\n`;\n\nStyledPContainer.defaultProps = defaultThemeProp;\n\nconst StyledLoader = Styled.div`\n display: flex;\n justify-content: center;\n padding: 0.5rem;\n position: absolute;\n width: 100%;\n left: ${props => `var(${props.$style.left})`};\n top: ${props => `var(${props.$style.top})`};\n`;\n\nconst Virtualize = forwardRef(\n (\n {\n id,\n viewHeight,\n viewWidth,\n totalRecordCount,\n itemHeight,\n callback,\n isFetching,\n rowContainerClass,\n children,\n renderHeader,\n renderFooter,\n state,\n bufferMultiplier,\n viewMaxHeight,\n showLoadingIndicator\n },\n inputRef\n ) => {\n const [rContainerDimensionUpdate, setRContainerDimensionUpdate] = useState();\n const [loadingIndicatorInfo, setLoadingIndicatorInfo] = useState({});\n const [translate] = useTranslate();\n // Create ref to store virtualize related data.\n const vi = useRef({\n itemHeight,\n bufferMultiplier,\n pInfo: {}\n }).current;\n\n const getRowContainer = useCallback(() => vi.rContainer, [vi.rContainer]);\n const getPContainer = useCallback(() => vi.pContainer, [vi.pContainer]);\n const getBContainer = useCallback(() => vi.bContainer, [vi.bContainer]);\n\n // API used when user want to scroll to top programmatically.\n // Though component auto scroll to top if no element is in view.\n // But calling this API upfront might save one extra call to Fetch API.\n const scrollToTop = useCallback(() => {\n if (!state) return;\n getPContainer().scrollTop = 0;\n vi.pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(totalRecordCount),\n vi,\n false,\n true\n );\n callback({ ...vi.pInfo.view, id }, { takeLatestAction: true });\n }, [id, vi, state, getPContainer]);\n\n // expose APIs and properties here to help client to communicate.\n useImperativeHandle(inputRef, () => ({\n getParentContainer: getPContainer,\n scrollToTop,\n vi,\n id\n }));\n\n const { width, height } = useMemo(\n () => ({\n width: getValueWithUnit(viewWidth, '100%'),\n height: getValueWithUnit(viewHeight, 'auto')\n }),\n [viewWidth, viewHeight]\n );\n\n const maxHeight = useMemo(() => getMaxHeight(viewMaxHeight), [viewMaxHeight]);\n\n const minHeight = useMemo(\n () => (totalRecordCount === 0 ? '100px' : 'auto'),\n [totalRecordCount]\n );\n\n // Calculate the pagination indexes and notify callback.\n // resetIsFetchingWhenNoNewIndexes - flag specific for isViewNotFilled\n // If view is not filled, we want to call this but restting isFetch to false\n // goes to this methid when callback is note fired.\n const getPagination = useCallback(\n (isRefresh = false, resetIsFetchingWhenNoNewIndexes = false) => {\n if (resetIsFetchingWhenNoNewIndexes) {\n setLoadingIndicatorInfo({});\n }\n const pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(totalRecordCount),\n vi,\n isRefresh\n );\n const { startIndex, endIndex } = pInfo.view;\n // if new indexes are subset of existing state indexes, no need to update the consumer.\n if (!state || !(startIndex >= state.startIndex && endIndex <= state.endIndex)) {\n vi.pInfo = pInfo;\n if (state) {\n const { startIndex: oldStartIndex, endIndex: oldEndIndex } = state;\n if (startIndex < oldStartIndex) {\n setLoadingIndicatorInfo(info => {\n return { ...info, isScrollingUp: true };\n });\n }\n if (endIndex > oldEndIndex) {\n setLoadingIndicatorInfo(info => {\n return { ...info, isScrollingDown: true };\n });\n }\n }\n callback({ ...vi.pInfo.view, id }, { takeLatestAction: true });\n }\n },\n [vi, totalRecordCount, state, callback, id, getPContainer]\n );\n\n // update average stats for next calculation.\n const updateAverageInVirtualizeInstance = useCallback(\n currentEstimation => {\n const { itemCount, rowContainerHeight, averageNumberOfItemsInARow, averageRowHeight } =\n currentEstimation;\n Object.assign(vi, {\n itemCount: (itemCount + vi.itemCount || itemCount) / 2,\n rowContainerHeight:\n (rowContainerHeight + vi.rowContainerHeight || rowContainerHeight) / 2,\n averageNumberOfItemsInARow:\n (averageNumberOfItemsInARow + vi.averageNumberOfItemsInARow ||\n averageNumberOfItemsInARow) / 2,\n averageRowHeight: (averageRowHeight + vi.averageRowHeight || averageRowHeight) / 2\n });\n },\n [vi]\n );\n\n const getBufferHeight = useCallback(\n currentEstimation => {\n const { itemCount, rowContainerHeight } = currentEstimation;\n let h = 0;\n if (itemCount > 0)\n h = (getRecordCountForLayoutPaint(totalRecordCount) / itemCount) * rowContainerHeight;\n return h;\n },\n [totalRecordCount]\n );\n\n const getScrollTop = useCallback(\n currentEstimation => {\n const { itemCount, rowContainerHeight } = currentEstimation;\n let scrollTop = 0;\n if (itemCount > 0) {\n const scrollNodeTopChange =\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.bufferNewCords?.top - vi.pInfo?.bufferOldCords?.top || 0;\n scrollTop = (vi.pInfo.topRowIndex / itemCount) * rowContainerHeight - scrollNodeTopChange;\n }\n return scrollTop;\n },\n [vi]\n );\n\n const onRowContainerDimensionChange = useCallback(() => {\n const { height: rowContainerHeight, width: rowContainerWidth } =\n getRowContainer()?.getBoundingClientRect() ?? {};\n // trigger virtualizer operations only when row container has some height and width\n if (rowContainerHeight && rowContainerWidth) setRContainerDimensionUpdate({});\n }, [getRowContainer]);\n\n // observe on row container to adjust the buffer container height.\n useResizeObserver(getRowContainer, onRowContainerDimensionChange);\n\n const [updateScrollTop] = useScroll(\n getPagination,\n getPContainer,\n vi,\n totalRecordCount,\n renderHeader,\n isFetching,\n viewHeight\n );\n\n useLayoutEffect(() => {\n const rContainer = getRowContainer();\n if (state && state.startIndex >= 0 && vi && rContainer) {\n setAttributesOnItems(state, rContainer);\n }\n });\n\n // Get estimate and update buffer height\n useLayoutEffect(() => {\n if (state && !isEmpty(totalRecordCount)) {\n vi.currentEstimation = getCurrentEstimation(getRowContainer());\n updateAverageInVirtualizeInstance(vi.currentEstimation);\n const h = Math.floor(getBufferHeight(vi.currentEstimation));\n const previousHeight = getBContainer().offsetHeight;\n\n getBContainer().style.height = `${h}px`;\n vi.bContainerHeight = h;\n\n // if there was no previous height, then keep the scrolltop to 0 by default\n if (h !== previousHeight && previousHeight) {\n const pContainer = getPContainer();\n const scrollTop = getScrollTop(vi.currentEstimation);\n if (scrollTop >= 0) {\n pContainer.scrollTop = scrollTop;\n }\n }\n }\n }, [\n rContainerDimensionUpdate,\n getBContainer,\n getBufferHeight,\n getRowContainer,\n state,\n totalRecordCount,\n updateAverageInVirtualizeInstance,\n vi,\n getPContainer,\n getScrollTop\n ]);\n\n // update parent scroll top and row container top.\n useLayoutEffect(() => {\n if (state && !isEmpty(totalRecordCount)) {\n const pContainer = getPContainer();\n\n // Setting scrollTop from pContainer.scrollTop as getScrollTop can return value with higher decimal accuracy.\n // but scrollTop attribute from HTML element will round it automatically.\n updateScrollTop(pContainer.scrollTop);\n updateRowContainerTop(\n vi,\n getRecordCountForLayoutPaint(totalRecordCount),\n state,\n pContainer,\n pContainer.scrollTop\n );\n\n const topLoaderHeight = 80;\n let top = getRowContainer().style.top;\n if (!top) {\n top = 0;\n }\n getBContainer().style.setProperty(\n '--above-loader-top',\n `${parseInt(top, 10) - topLoaderHeight}px`\n );\n\n getBContainer().style.setProperty(\n '--below-loader-top',\n `${parseInt(top, 10) + getRowContainer().offsetHeight}px`\n );\n }\n }, [\n getPContainer,\n getScrollTop,\n state,\n updateScrollTop,\n vi,\n rContainerDimensionUpdate,\n totalRecordCount,\n getRowContainer,\n getBContainer\n ]);\n\n // On mount that means state is not initialized yet, trigger pagination.\n // or whenever count changes or width /height of view port changes, if view is not filled with data, get indexes again.\n useEffect(() => {\n if (state && !isFetching && !isEmpty(totalRecordCount)) {\n if (\n isViewNotFilled(\n getRecordCountForLayoutPaint(totalRecordCount),\n vi,\n getPContainer(),\n renderHeader\n )\n )\n getPagination(false, true);\n else {\n setLoadingIndicatorInfo({});\n }\n } else if (!state || !Object.keys(vi.pInfo).length) getPagination(true);\n }, [\n rContainerDimensionUpdate,\n state,\n vi,\n totalRecordCount,\n viewHeight,\n viewWidth,\n renderHeader,\n getPagination,\n getPContainer\n ]);\n\n useEffect(() => {\n if (!isFetching) return;\n getBContainer().style.setProperty('--loader-left', `${getPContainer().scrollLeft}px`);\n }, [isFetching, getPContainer()?.scrollLeft]);\n\n return (\n <StyledPContainer\n $style={{\n maxHeight,\n minHeight,\n renderFooter,\n itemHeight,\n height,\n width\n }}\n data-total-records={totalRecordCount}\n className='pContainer'\n ref={c => {\n vi.pContainer = c;\n }}\n >\n {renderHeader && renderHeader()}\n <div\n className='bContainer'\n ref={c => {\n vi.bContainer = c;\n }}\n >\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingUp && (\n <StyledLoader\n $style={{\n top: '--above-loader-top',\n left: '--loader-left'\n }}\n >\n <Progress\n className='above-loader'\n placement='block'\n tabIndex={0}\n aria-label={translate('Loading more results')}\n />\n </StyledLoader>\n )}\n <div\n className={`${rowContainerClass} row-container`}\n ref={c => {\n vi.rContainer = c;\n }}\n role='rowgroup'\n >\n {/** Do not add any other element in row-container apart from the rows as it will generate incorrect estimations */}\n {children}\n </div>\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (\n <StyledLoader\n $style={{\n top: '--below-loader-top',\n left: '--loader-left'\n }}\n >\n <Progress\n className='below-loader'\n placement='block'\n tabIndex={0}\n aria-label={translate('Loading more results')}\n />\n </StyledLoader>\n )}\n </div>\n {totalRecordCount === 0 ? <EmptyContainer /> : null}\n {renderFooter && renderFooter()}\n </StyledPContainer>\n );\n }\n);\n\nVirtualize.propTypes = {\n id: PropTypes.string.isRequired,\n viewHeight: PropTypes.number,\n viewWidth: PropTypes.number,\n totalRecordCount: PropTypes.number,\n itemHeight: PropTypes.number,\n callback: PropTypes.func,\n isFetching: PropTypes.bool,\n rowContainerClass: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,\n renderHeader: PropTypes.func,\n renderFooter: PropTypes.func,\n state: PropTypes.shape({\n startIndex: PropTypes.number,\n endIndex: PropTypes.number\n }),\n bufferMultiplier: PropTypes.number,\n viewMaxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n showLoadingIndicator: PropTypes.bool\n};\n\nVirtualize.defaultProps = {\n bufferMultiplier: 2,\n callback: () => {},\n isFetching: false,\n rowContainerClass: '',\n viewWidth: 0,\n itemHeight: 40,\n renderHeader: null,\n renderFooter: null,\n state: undefined,\n totalRecordCount: undefined,\n viewMaxHeight: undefined,\n showLoadingIndicator: false\n};\n\nVirtualize.displayName = 'Virtualize';\n\nexport default memo(Virtualize);\n"]}
|
|
@@ -5,7 +5,7 @@ export declare function isPaginationRequestCompleted(requestedIndexes?: {
|
|
|
5
5
|
}, receivedIndexes?: {
|
|
6
6
|
startIndex: number;
|
|
7
7
|
endIndex: number;
|
|
8
|
-
}): boolean | undefined;
|
|
8
|
+
}): number | boolean | undefined;
|
|
9
9
|
export declare function isViewNotFilled(totalRecordCount: number, vi: {
|
|
10
10
|
rContainer: HTMLDivElement;
|
|
11
11
|
}, pContainer: HTMLDivElement, renderHeader: boolean): boolean | 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/utility.ts"],"names":[],"mappings":"AAOA,wBAAgB,4BAA4B,CAAC,gBAAgB,EAAE,MAAM,UAEpE;AAID,wBAAgB,4BAA4B,CAC1C,gBAAgB,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC3D,eAAe,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/utility.ts"],"names":[],"mappings":"AAOA,wBAAgB,4BAA4B,CAAC,gBAAgB,EAAE,MAAM,UAEpE;AAID,wBAAgB,4BAA4B,CAC1C,gBAAgB,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC3D,eAAe,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,gCAW3D;AAED,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,MAAM,EACxB,EAAE,EAAE;IAAE,U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AAE,WAAW,sBAU/D;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,YAAY,EAAE,MAAM,GAAG,MAAM,GAC5B,MAAM,GAAG,MAAM,CAMjB;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAG/E"}
|
|
@@ -12,8 +12,9 @@ export function isPaginationRequestCompleted(requestedIndexes, receivedIndexes)
|
|
|
12
12
|
// about updated index though pagination is really not required.
|
|
13
13
|
return (receivedIndexes &&
|
|
14
14
|
requestedIndexes &&
|
|
15
|
-
receivedIndexes.startIndex === requestedIndexes.startIndex &&
|
|
16
|
-
|
|
15
|
+
((receivedIndexes.startIndex === requestedIndexes.startIndex &&
|
|
16
|
+
receivedIndexes.endIndex === requestedIndexes.endIndex) ||
|
|
17
|
+
(Object.keys(requestedIndexes).length === 0 && receivedIndexes.endIndex)));
|
|
17
18
|
}
|
|
18
19
|
export function isViewNotFilled(totalRecordCount, vi, pContainer, renderHeader) {
|
|
19
20
|
const parentContainerPosition = pContainer.getBoundingClientRect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,2CAA2C;AAC3C,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,UAAU,4BAA4B,CAAC,gBAAwB;IACnE,OAAO,gBAAgB,GAAG,wBAAwB,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,gBAAgB,CAAC;AACnG,CAAC;AAED,0DAA0D;AAC1D,+CAA+C;AAC/C,MAAM,UAAU,4BAA4B,CAC1C,gBAA2D,EAC3D,eAA0D;IAE1D,8FAA8F;I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AE,OAAO;IAExB,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;IAEtE,IAAI,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACxD,IAAI,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QACpD,qBAAqB,IAAI,iBAAiB,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,KAAkC,EAClC,YAA6B;IAE7B,IAAI,CAAC,KAAK;QAAE,OAAO,YAAY,CAAC;IAChC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,aAA0C;IACrE,IAAI,CAAC,aAAa;QAAE,OAAO,MAAM,CAAC;IAClC,OAAO,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC;AAClF,CAAC","sourcesContent":["import { getScrollbarWidth } from 'pega-repeating-structures-core';\n\nimport { StickyGroupHeader } from './Pagination';\n\n// TODO: in future, take this count in meta\nconst MAX_SCROLLABLE_ROW_COUNT = 5000;\n\nexport function getRecordCountForLayoutPaint(totalRecordCount: number) {\n return totalRecordCount > MAX_SCROLLABLE_ROW_COUNT ? MAX_SCROLLABLE_ROW_COUNT : totalRecordCount;\n}\n\n// State should be communicated back from consumer to know\n// if pagination last request completed or not.\nexport function isPaginationRequestCompleted(\n requestedIndexes?: { startIndex: number; endIndex: number },\n receivedIndexes?: { startIndex: number; endIndex: number }\n) {\n // this is required when there is a pagination request which is raised just to update consumer\n // about updated index though pagination is really not required.\n return (\n receivedIndexes &&\n requestedIndexes &&\n receivedIndexes.startIndex === requestedIndexes.startIndex &&\n receivedIndexes.endIndex === requestedIndexes.endIndex\n );\n}\n\nexport function isViewNotFilled(\n totalRecordCount: number,\n vi: { rContainer: HTMLDivElement },\n pContainer: HTMLDivElement,\n renderHeader: boolean\n) {\n const parentContainerPosition = pContainer.getBoundingClientRect();\n // This is required to accommodate header height.\n // TODO: Need to find a better solution to pull out header out of this.\n const headerRowHeight =\n renderHeader && pContainer.childElementCount > 1\n ? (pContainer.childNodes[0] as HTMLElement).offsetHeight\n : 0;\n const scrollbarWidth = getScrollbarWidth();\n return (\n totalRecordCount &&\n vi.rContainer.childElementCount !== totalRecordCount &&\n (Math.floor(vi.rContainer.getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(vi.rContainer.getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerRowHeight) ||\n vi.rContainer.childElementCount === 0)\n );\n}\n\nfunction getItemCountPerRow(rows: Element[]) {\n const itemsCountPerRow: {\n [key: string]: { count: number; height: number; isStickyGroupHeader: boolean };\n } = {};\n rows.forEach(item => {\n const itemBoundary = item.getBoundingClientRect();\n // isStickyGroupHeader flag helps in including the overlapped sticky-group-header for getting correct averages\n const isStickyGroupHeader = item.classList.contains(StickyGroupHeader);\n if (itemsCountPerRow[itemBoundary.top]) {\n itemsCountPerRow[itemBoundary.top].count += 1;\n if (itemsCountPerRow[itemBoundary.top].height < itemBoundary.height) {\n itemsCountPerRow[itemBoundary.top].height = itemBoundary.height;\n }\n } else {\n itemsCountPerRow[itemBoundary.top] = {\n count: 1,\n height: itemBoundary.height,\n isStickyGroupHeader\n };\n }\n });\n return itemsCountPerRow;\n}\n\n// Based on row container size, get estimated count,\n// average height and no of items in a row.\nexport function getCurrentEstimation(rContainer: HTMLDivElement, includeRowsOnly = false) {\n const rContainerChildren = Array.from(rContainer.children || []);\n const filteredRowsContainer = includeRowsOnly\n ? rContainerChildren.filter(r => r.hasAttribute('data-key'))\n : rContainerChildren;\n\n const itemsCountPerRow = getItemCountPerRow(filteredRowsContainer);\n const itemCount = filteredRowsContainer.length || 0;\n // TODO FIXME: #virtualizer Remove dependency on sticky-group-header class and try to make the key of ItemsCountPerRow unique which will work for overlapping scenarios\n // BUG-740809 handling the rowCount in case of overlapped sticky-group-header\n // If we have sticky-group-headers, add overlapped sticky-group-headers to rowCount.\n // So, that averageNumberOfItemsInARow will be 1 for grid. That's why adding the complete count.\n const rowCount = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.count;\n }\n return acc + 1;\n },\n 0\n );\n const averageNumberOfItemsInARow = rowCount > 0 ? itemCount / rowCount : 0;\n const height = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; height: number; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.height * o.count;\n }\n return acc + o.height;\n },\n 0\n );\n const averageRowHeight = rowCount > 0 ? height / rowCount : 0;\n const rowContainerHeight = rContainer.offsetHeight || 0;\n return { itemCount, rowContainerHeight, averageNumberOfItemsInARow, averageRowHeight };\n}\n\n// Calculate top which needs to set on row container when component rerender.\n// component can rerender many times though pagination is in progress.\nfunction calculateTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo?: {\n view?: { startIndex: number; endIndex: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n scrollTop: number\n) {\n let top = 0;\n if (vi.pInfo && vi.pInfo?.view?.startIndex !== 0) {\n // slide row container for current view based on previous estimated value.\n const estimatedNoOfItemsPushedUp =\n scrollTop * (vi.currentEstimation.itemCount / vi.currentEstimation.rowContainerHeight);\n // estimated start view index of current view based on scroll top.\n\n const estimatedStartIndexInView = estimatedNoOfItemsPushedUp + 1;\n // estimated number of buffer records.\n\n const noOfBufferRecords = estimatedStartIndexInView - (vi.pInfo?.view?.startIndex ?? 0);\n const noOfBufferRecordsHeight =\n (noOfBufferRecords / vi.currentEstimation.averageNumberOfItemsInARow) *\n vi.currentEstimation.averageRowHeight;\n // calculated top of row container.\n top = scrollTop - noOfBufferRecordsHeight;\n if (top < 0) top = 0;\n }\n return top;\n}\n\nfunction adjustTopRowContainerToAvoidDrift(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n existingTop: number\n) {\n // Adjust top if element was viewable when user stop scrolling and pagination trigger.\n // existing item should be viewable are at time of calculation\n // as we allow user to scroll even pagination request triggered.\n let effectiveTop = existingTop;\n const { existingItemBoundingBox, currentRowIndex } = vi.pInfo;\n // As safari does elastic scroll, we need this check to avoid any space on top.\n const safariIsFirstItem = currentRowIndex === 0;\n if (existingItemBoundingBox && !safariIsFirstItem) {\n const currentRowIndexItem = vi.rContainer.querySelector(\n `[data-index='${vi.pInfo.currentRowIndex}']`\n );\n if (currentRowIndexItem) {\n // scrollNodeTopChange - change in scroll while pagination is in progress.\n const scrollNodeTopChange = vi.pInfo.bufferNewCords.top - vi.pInfo.bufferOldCords.top;\n const newItemBoundingBox = currentRowIndexItem.getBoundingClientRect();\n const top = newItemBoundingBox.y - existingItemBoundingBox.y - scrollNodeTopChange;\n effectiveTop = existingTop - top;\n }\n }\n // As of now, we are making top to zero if it goes in negative, which is not right way.\n // -ve is possible value for it as scroll top is just approximation. Check when\n // gallery view gives you 0 to index result after some scroll.\n // scroll top is 0 as it is top row index based.\n // TODO: can go negative as bottom to top paint strategy is pending.\n // This check and expression is not required after that. This will be handled in next release.\n // Gallery issue wil also be handled in that. As of for first attempt we have to either scroll more.\n // or make buffer size more in that to avoid 0 to index number in next repaint.\n if (effectiveTop < 0 && vi.pInfo.view.startIndex === 0) effectiveTop = 0;\n if (effectiveTop !== existingTop) vi.rContainer.style.top = `${effectiveTop}px`;\n}\n\nexport function updateRowContainerTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n totalRecordCount: number,\n state: { [key: string]: any },\n pContainer: HTMLDivElement,\n scrollTop: number\n) {\n // if you get last record , put row container to bottom always to Avoid\n // any space left because of estimation otherwise calculate top.\n // if next rerender you get less records,\n if (\n (vi.pInfo?.view?.startIndex === 0 && vi.pInfo?.view?.endIndex < totalRecordCount) ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 > totalRecordCount ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex - vi.pInfo?.view?.startIndex >= totalRecordCount\n ) {\n // This is a case when you scroll to top or say after filter your items count reduce to such level\n // it doesn't fit in current start and end index and put container top and fill view\n // will consider if empty.\n vi.rContainer.style.removeProperty('bottom');\n vi.rContainer.style.top = '0px';\n // Any action which makes indexes out of range to total record count,\n // scroll to top as a default behavior.\n if (vi.pInfo.view.startIndex + 1 > totalRecordCount) pContainer.scrollTop = 0;\n\n // commenting below line as it can cause white space on top sometime.\n // Commenting this line might cause a small flicker only when you reach at top.\n // We will solve this in 8.6 release.\n // else if (vi.pInfo?.topRowIndex > 0) adjustTopRowContainerToAvoidDrift(vi, 0);\n } else if (\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex + 1 >= totalRecordCount &&\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 <= totalRecordCount\n ) {\n vi.rContainer.style.removeProperty('top');\n vi.rContainer.style.bottom = '0px';\n } else {\n vi.rContainer.style.removeProperty('bottom');\n const top = calculateTop(vi, scrollTop);\n vi.rContainer.style.top = `${top}px`;\n adjustTopRowContainerToAvoidDrift(vi, top);\n }\n}\n\n// index attrs required to estimate next set.\nexport function setAttributesOnItems(\n state: { startIndex: number; endIndex: number },\n rContainer: HTMLElement\n) {\n rContainer.childNodes.forEach((r, index) => {\n (r as HTMLElement).setAttribute('data-index', `${state.startIndex + index}`);\n });\n}\n\nexport function getPContainerClientWidth(pContainer: HTMLElement) {\n if (!pContainer) return;\n\n const { width: pContainerWidth } = pContainer.getBoundingClientRect();\n\n let pContainerClientWidth = Math.floor(pContainerWidth);\n if (pContainer.offsetWidth > pContainer.clientWidth) {\n pContainerClientWidth -= getScrollbarWidth();\n }\n return pContainerClientWidth;\n}\n\nexport function getValueWithUnit(\n value: string | number | undefined,\n defaultValue: string | number\n): string | number {\n if (!value) return defaultValue;\n if (!value.toString().includes('px') && !value.toString().includes('%')) {\n return `${value}px`;\n }\n return `${value}`;\n}\n\nexport function getMaxHeight(viewMaxHeight: number | string | undefined): string {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,2CAA2C;AAC3C,MAAM,wBAAw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CAAC,CAAC,CAAC,aAAa,CAAC;AAClF,CAAC","sourcesContent":["import { getScrollbarWidth } from 'pega-repeating-structures-core';\n\nimport { StickyGroupHeader } from './Pagination';\n\n// TODO: in future, take this count in meta\nconst MAX_SCROLLABLE_ROW_COUNT = 5000;\n\nexport function getRecordCountForLayoutPaint(totalRecordCount: number) {\n return totalRecordCount > MAX_SCROLLABLE_ROW_COUNT ? MAX_SCROLLABLE_ROW_COUNT : totalRecordCount;\n}\n\n// State should be communicated back from consumer to know\n// if pagination last request completed or not.\nexport function isPaginationRequestCompleted(\n requestedIndexes?: { startIndex: number; endIndex: number },\n receivedIndexes?: { startIndex: number; endIndex: number }\n) {\n // this is required when there is a pagination request which is raised just to update consumer\n // about updated index though pagination is really not required.\n return (\n receivedIndexes &&\n requestedIndexes &&\n ((receivedIndexes.startIndex === requestedIndexes.startIndex &&\n receivedIndexes.endIndex === requestedIndexes.endIndex) ||\n (Object.keys(requestedIndexes).length === 0 && receivedIndexes.endIndex))\n );\n}\n\nexport function isViewNotFilled(\n totalRecordCount: number,\n vi: { rContainer: HTMLDivElement },\n pContainer: HTMLDivElement,\n renderHeader: boolean\n) {\n const parentContainerPosition = pContainer.getBoundingClientRect();\n // This is required to accommodate header height.\n // TODO: Need to find a better solution to pull out header out of this.\n const headerRowHeight =\n renderHeader && pContainer.childElementCount > 1\n ? (pContainer.childNodes[0] as HTMLElement).offsetHeight\n : 0;\n const scrollbarWidth = getScrollbarWidth();\n return (\n totalRecordCount &&\n vi.rContainer.childElementCount !== totalRecordCount &&\n (Math.floor(vi.rContainer.getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(vi.rContainer.getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerRowHeight) ||\n vi.rContainer.childElementCount === 0)\n );\n}\n\nfunction getItemCountPerRow(rows: Element[]) {\n const itemsCountPerRow: {\n [key: string]: { count: number; height: number; isStickyGroupHeader: boolean };\n } = {};\n rows.forEach(item => {\n const itemBoundary = item.getBoundingClientRect();\n // isStickyGroupHeader flag helps in including the overlapped sticky-group-header for getting correct averages\n const isStickyGroupHeader = item.classList.contains(StickyGroupHeader);\n if (itemsCountPerRow[itemBoundary.top]) {\n itemsCountPerRow[itemBoundary.top].count += 1;\n if (itemsCountPerRow[itemBoundary.top].height < itemBoundary.height) {\n itemsCountPerRow[itemBoundary.top].height = itemBoundary.height;\n }\n } else {\n itemsCountPerRow[itemBoundary.top] = {\n count: 1,\n height: itemBoundary.height,\n isStickyGroupHeader\n };\n }\n });\n return itemsCountPerRow;\n}\n\n// Based on row container size, get estimated count,\n// average height and no of items in a row.\nexport function getCurrentEstimation(rContainer: HTMLDivElement, includeRowsOnly = false) {\n const rContainerChildren = Array.from(rContainer.children || []);\n const filteredRowsContainer = includeRowsOnly\n ? rContainerChildren.filter(r => r.hasAttribute('data-key'))\n : rContainerChildren;\n\n const itemsCountPerRow = getItemCountPerRow(filteredRowsContainer);\n const itemCount = filteredRowsContainer.length || 0;\n // TODO FIXME: #virtualizer Remove dependency on sticky-group-header class and try to make the key of ItemsCountPerRow unique which will work for overlapping scenarios\n // BUG-740809 handling the rowCount in case of overlapped sticky-group-header\n // If we have sticky-group-headers, add overlapped sticky-group-headers to rowCount.\n // So, that averageNumberOfItemsInARow will be 1 for grid. That's why adding the complete count.\n const rowCount = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.count;\n }\n return acc + 1;\n },\n 0\n );\n const averageNumberOfItemsInARow = rowCount > 0 ? itemCount / rowCount : 0;\n const height = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; height: number; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.height * o.count;\n }\n return acc + o.height;\n },\n 0\n );\n const averageRowHeight = rowCount > 0 ? height / rowCount : 0;\n const rowContainerHeight = rContainer.offsetHeight || 0;\n return { itemCount, rowContainerHeight, averageNumberOfItemsInARow, averageRowHeight };\n}\n\n// Calculate top which needs to set on row container when component rerender.\n// component can rerender many times though pagination is in progress.\nfunction calculateTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo?: {\n view?: { startIndex: number; endIndex: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n scrollTop: number\n) {\n let top = 0;\n if (vi.pInfo && vi.pInfo?.view?.startIndex !== 0) {\n // slide row container for current view based on previous estimated value.\n const estimatedNoOfItemsPushedUp =\n scrollTop * (vi.currentEstimation.itemCount / vi.currentEstimation.rowContainerHeight);\n // estimated start view index of current view based on scroll top.\n\n const estimatedStartIndexInView = estimatedNoOfItemsPushedUp + 1;\n // estimated number of buffer records.\n\n const noOfBufferRecords = estimatedStartIndexInView - (vi.pInfo?.view?.startIndex ?? 0);\n const noOfBufferRecordsHeight =\n (noOfBufferRecords / vi.currentEstimation.averageNumberOfItemsInARow) *\n vi.currentEstimation.averageRowHeight;\n // calculated top of row container.\n top = scrollTop - noOfBufferRecordsHeight;\n if (top < 0) top = 0;\n }\n return top;\n}\n\nfunction adjustTopRowContainerToAvoidDrift(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n existingTop: number\n) {\n // Adjust top if element was viewable when user stop scrolling and pagination trigger.\n // existing item should be viewable are at time of calculation\n // as we allow user to scroll even pagination request triggered.\n let effectiveTop = existingTop;\n const { existingItemBoundingBox, currentRowIndex } = vi.pInfo;\n // As safari does elastic scroll, we need this check to avoid any space on top.\n const safariIsFirstItem = currentRowIndex === 0;\n if (existingItemBoundingBox && !safariIsFirstItem) {\n const currentRowIndexItem = vi.rContainer.querySelector(\n `[data-index='${vi.pInfo.currentRowIndex}']`\n );\n if (currentRowIndexItem) {\n // scrollNodeTopChange - change in scroll while pagination is in progress.\n const scrollNodeTopChange = vi.pInfo.bufferNewCords.top - vi.pInfo.bufferOldCords.top;\n const newItemBoundingBox = currentRowIndexItem.getBoundingClientRect();\n const top = newItemBoundingBox.y - existingItemBoundingBox.y - scrollNodeTopChange;\n effectiveTop = existingTop - top;\n }\n }\n // As of now, we are making top to zero if it goes in negative, which is not right way.\n // -ve is possible value for it as scroll top is just approximation. Check when\n // gallery view gives you 0 to index result after some scroll.\n // scroll top is 0 as it is top row index based.\n // TODO: can go negative as bottom to top paint strategy is pending.\n // This check and expression is not required after that. This will be handled in next release.\n // Gallery issue wil also be handled in that. As of for first attempt we have to either scroll more.\n // or make buffer size more in that to avoid 0 to index number in next repaint.\n if (effectiveTop < 0 && vi.pInfo.view.startIndex === 0) effectiveTop = 0;\n if (effectiveTop !== existingTop) vi.rContainer.style.top = `${effectiveTop}px`;\n}\n\nexport function updateRowContainerTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n totalRecordCount: number,\n state: { [key: string]: any },\n pContainer: HTMLDivElement,\n scrollTop: number\n) {\n // if you get last record , put row container to bottom always to Avoid\n // any space left because of estimation otherwise calculate top.\n // if next rerender you get less records,\n if (\n (vi.pInfo?.view?.startIndex === 0 && vi.pInfo?.view?.endIndex < totalRecordCount) ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 > totalRecordCount ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex - vi.pInfo?.view?.startIndex >= totalRecordCount\n ) {\n // This is a case when you scroll to top or say after filter your items count reduce to such level\n // it doesn't fit in current start and end index and put container top and fill view\n // will consider if empty.\n vi.rContainer.style.removeProperty('bottom');\n vi.rContainer.style.top = '0px';\n // Any action which makes indexes out of range to total record count,\n // scroll to top as a default behavior.\n if (vi.pInfo.view.startIndex + 1 > totalRecordCount) pContainer.scrollTop = 0;\n\n // commenting below line as it can cause white space on top sometime.\n // Commenting this line might cause a small flicker only when you reach at top.\n // We will solve this in 8.6 release.\n // else if (vi.pInfo?.topRowIndex > 0) adjustTopRowContainerToAvoidDrift(vi, 0);\n } else if (\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex + 1 >= totalRecordCount &&\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 <= totalRecordCount\n ) {\n vi.rContainer.style.removeProperty('top');\n vi.rContainer.style.bottom = '0px';\n } else {\n vi.rContainer.style.removeProperty('bottom');\n const top = calculateTop(vi, scrollTop);\n vi.rContainer.style.top = `${top}px`;\n adjustTopRowContainerToAvoidDrift(vi, top);\n }\n}\n\n// index attrs required to estimate next set.\nexport function setAttributesOnItems(\n state: { startIndex: number; endIndex: number },\n rContainer: HTMLElement\n) {\n rContainer.childNodes.forEach((r, index) => {\n (r as HTMLElement).setAttribute('data-index', `${state.startIndex + index}`);\n });\n}\n\nexport function getPContainerClientWidth(pContainer: HTMLElement) {\n if (!pContainer) return;\n\n const { width: pContainerWidth } = pContainer.getBoundingClientRect();\n\n let pContainerClientWidth = Math.floor(pContainerWidth);\n if (pContainer.offsetWidth > pContainer.clientWidth) {\n pContainerClientWidth -= getScrollbarWidth();\n }\n return pContainerClientWidth;\n}\n\nexport function getValueWithUnit(\n value: string | number | undefined,\n defaultValue: string | number\n): string | number {\n if (!value) return defaultValue;\n if (!value.toString().includes('px') && !value.toString().includes('%')) {\n return `${value}px`;\n }\n return `${value}`;\n}\n\nexport function getMaxHeight(viewMaxHeight: number | string | undefined): string {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDragDrop.d.ts","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5F;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAuB,EACvB,SAAqB,EACrB,WAAuB,EACvB,WAAuB,EACvB,MAAM,EACN,gBAAuB,EACvB,oBAAoB,EACpB,iBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EACjB,EAAE,gBAAgB,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useDragDrop.d.ts","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5F;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAuB,EACvB,SAAqB,EACrB,WAAuB,EACvB,WAAuB,EACvB,MAAM,EACN,gBAAuB,EACvB,oBAAoB,EACpB,iBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EACjB,EAAE,gBAAgB,GAAG,iBAAiB,CAgStC"}
|
|
@@ -126,6 +126,8 @@ export default function useDragDrop({ context, onDragStart = undefined, onDragEn
|
|
|
126
126
|
ref.contextDragOverCb = contextDragOverCb;
|
|
127
127
|
setGhostImage(ev);
|
|
128
128
|
ev.dataTransfer.effectAllowed = 'move';
|
|
129
|
+
// 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
|
|
130
|
+
ev.dataTransfer.setData('text/plain', 'RS_Dragged_Item');
|
|
129
131
|
// fail safe reset drag target.
|
|
130
132
|
if (ref.dragTarget)
|
|
131
133
|
ref.dragTarget = undefined;
|
|
@@ -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,C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AG,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 {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 // 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,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I,CAAC;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 {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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledGalleryContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Gallery/StyledGalleryContainer.jsx"],"names":[],"mappings":";AAKA,
|
|
1
|
+
{"version":3,"file":"StyledGalleryContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Gallery/StyledGalleryContainer.jsx"],"names":[],"mappings":";AAKA,sNA8CE"}
|
|
@@ -11,6 +11,7 @@ const StyledGalleryContainer = styled(forwardRef((props, ref) => _jsx("div", { r
|
|
|
11
11
|
/* stylelint-disable-next-line unit-allowed-list */
|
|
12
12
|
grid-gap: 10px;
|
|
13
13
|
grid-template-columns: repeat(auto-fit, minmax(18.75rem, 1fr));
|
|
14
|
+
width: 100%;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
.flex-container {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledGalleryContainer.js","sourceRoot":"","sources":["../../../../Core/Views/Gallery/StyledGalleryContainer.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,sBAAsB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,cAAK,GAAG,EAAE,GAAG,KAAM,KAAK,GAAI,CAAC,CAAC,CAC7F,GAAG,EAAE;IACH,OAAO,GAAG,CAAA;QACN,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"StyledGalleryContainer.js","sourceRoot":"","sources":["../../../../Core/Views/Gallery/StyledGalleryContainer.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,sBAAsB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,cAAK,GAAG,EAAE,GAAG,KAAM,KAAK,GAAI,CAAC,CAAC,CAC7F,GAAG,EAAE;IACH,OAAO,GAAG,CAAA;QACN,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyC7E,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { generateRSHeightStyles } from '../../Utils/styles';\n\nconst StyledGalleryContainer = styled(forwardRef((props, ref) => <div ref={ref} {...props} />))(\n () => {\n return css`\n ${({ view, isFullscreen }) => generateRSHeightStyles({ view, isFullscreen })}\n\n .card-item-grid-container {\n display: grid;\n /* stylelint-disable-next-line unit-allowed-list */\n grid-gap: 10px;\n grid-template-columns: repeat(auto-fit, minmax(18.75rem, 1fr));\n width: 100%;\n }\n\n .flex-container {\n display: flex;\n flex-wrap: wrap;\n /* stylelint-disable-next-line unit-allowed-list */\n gap: 10px;\n }\n\n /* Gallery view CSS START */\n .icon-ph > button {\n cursor: pointer;\n margin-right: 0.437rem;\n }\n .icon-ph {\n margin: 0.625rem 0;\n }\n .field-value > li {\n padding-bottom: 0.25rem;\n }\n\n .row-container {\n position: absolute;\n justify-content: space-evenly;\n }\n\n &.animate {\n .row-container > span {\n transition: transform 0.5s cubic-bezier(0.4, 0.6, 0.1, 1);\n }\n }\n\n /* Gallery view CSS END */\n `;\n }\n);\n\nexport default StyledGalleryContainer;\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare const _default: import("react").MemoExoticComponent<typeof Row>;
|
|
2
2
|
export default _default;
|
|
3
|
-
declare function Row({ row, columns, level }: {
|
|
3
|
+
declare function Row({ row, columns, level, dataIndex }: {
|
|
4
4
|
row: any;
|
|
5
5
|
columns: any;
|
|
6
6
|
level?: number | undefined;
|
|
7
|
+
dataIndex: any;
|
|
7
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
declare namespace Row {
|
|
9
10
|
namespace propTypes {
|
|
@@ -12,6 +13,7 @@ declare namespace Row {
|
|
|
12
13
|
[x: string]: any;
|
|
13
14
|
}>;
|
|
14
15
|
let level: PropTypes.Requireable<number>;
|
|
16
|
+
let dataIndex: PropTypes.Requireable<number>;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
import PropTypes from 'prop-types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Table/Row.jsx"],"names":[],"mappings":";;AAKA
|
|
1
|
+
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Table/Row.jsx"],"names":[],"mappings":";;AAKA;;;;;4CAcC;;;;;;;;;;;sBAnBqB,YAAY"}
|
|
@@ -2,8 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
import CellWrapper from './CellWrapper';
|
|
5
|
-
function Row({ row, columns, level = 0 }) {
|
|
6
|
-
|
|
5
|
+
function Row({ row, columns, level = 0, dataIndex }) {
|
|
6
|
+
const uiProps = { ...row.getUIProps(), ...(dataIndex >= 0 ? { 'data-index': dataIndex } : {}) };
|
|
7
|
+
return (_jsx("div", { ...uiProps, children: [...columns]
|
|
7
8
|
.sort((colA, colB) => colA.order - colB.order)
|
|
8
9
|
.map(column => {
|
|
9
10
|
column.setExecutionContext(row);
|
|
@@ -15,7 +16,8 @@ function Row({ row, columns, level = 0 }) {
|
|
|
15
16
|
Row.propTypes = {
|
|
16
17
|
columns: PropTypes.arrayOf(PropTypes.any),
|
|
17
18
|
row: PropTypes.objectOf(PropTypes.any),
|
|
18
|
-
level: PropTypes.number
|
|
19
|
+
level: PropTypes.number,
|
|
20
|
+
dataIndex: PropTypes.number
|
|
19
21
|
};
|
|
20
22
|
export default memo(Row);
|
|
21
23
|
//# sourceMappingURL=Row.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../../Core/Views/Table/Row.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,SAAS,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../../Core/Views/Table/Row.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,SAAS,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE;IACjD,MAAM,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAEhG,OAAO,CACL,iBAAS,OAAO,YACb,CAAC,GAAG,OAAO,CAAC;aACV,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;aAC7C,GAAG,CAAC,MAAM,CAAC,EAAE;YACZ,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,MAAM,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAC;YAC/B,OAAO,KAAC,WAAW,IAAuB,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAvD,MAAM,CAAC,KAAK,CAAC,EAAE,CAA4C,CAAC;QACvF,CAAC,CAAC,GACA,CACP,CAAC;AACJ,CAAC;AAED,GAAG,CAAC,SAAS,GAAG;IACd,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC;IACzC,GAAG,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;IACtC,KAAK,EAAE,SAAS,CAAC,MAAM;IACvB,SAAS,EAAE,SAAS,CAAC,MAAM;CAC5B,CAAC;AAEF,eAAe,IAAI,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport { memo } from 'react';\n\nimport CellWrapper from './CellWrapper';\n\nfunction Row({ row, columns, level = 0, dataIndex }) {\n const uiProps = { ...row.getUIProps(), ...(dataIndex >= 0 ? { 'data-index': dataIndex } : {}) };\n\n return (\n <div {...uiProps}>\n {[...columns]\n .sort((colA, colB) => colA.order - colB.order)\n .map(column => {\n column.setExecutionContext(row);\n if (column.hidden) return null;\n return <CellWrapper key={column.field.id} row={row} column={column} level={level} />;\n })}\n </div>\n );\n}\n\nRow.propTypes = {\n columns: PropTypes.arrayOf(PropTypes.any),\n row: PropTypes.objectOf(PropTypes.any),\n level: PropTypes.number,\n dataIndex: PropTypes.number\n};\n\nexport default memo(Row);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledTableContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Table/StyledTableContainer.jsx"],"names":[],"mappings":";AAkBA,
|
|
1
|
+
{"version":3,"file":"StyledTableContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Views/Table/StyledTableContainer.jsx"],"names":[],"mappings":";AAkBA,oNAs5BG"}
|
|
@@ -622,6 +622,10 @@ const StyledTableContainer = styled(forwardRef((props, ref) => _jsx("div", { ref
|
|
|
622
622
|
&:not(.wrap-content-height) > .row:not(.group-header-row) {
|
|
623
623
|
height: var(--data-row-height);
|
|
624
624
|
}
|
|
625
|
+
|
|
626
|
+
& > .row:not(.group-header-row) {
|
|
627
|
+
min-width: 100%;
|
|
628
|
+
}
|
|
625
629
|
border-end-start-radius: inherit;
|
|
626
630
|
border-end-end-radius: inherit;
|
|
627
631
|
|