@pega/lists-react 9.0.0-build.9.8 → 9.0.0-build.9.9

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.
@@ -22,9 +22,9 @@ interface PaginationParams {
22
22
  /** Default height for items if not measured. */
23
23
  defaultItemHeight: number;
24
24
  /** Ref to the parent scrollable container element. */
25
- parentContainerRef: RefObject<HTMLElement>;
25
+ parentContainerRef: RefObject<HTMLDivElement>;
26
26
  /** Ref to the container holding the rendered items. */
27
- itemContainerRef: RefObject<HTMLElement>;
27
+ itemContainerRef: RefObject<HTMLDivElement>;
28
28
  /** Setter for the start index. */
29
29
  setStartIndex: (v: number) => void;
30
30
  /** Setter for the end index. */
@@ -1 +1 @@
1
- {"version":3,"file":"usePagination.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAG/F,UAAU,gBAAgB;IACxB,wCAAwC;IACxC,WAAW,EAAE,8BAA8B,CAAC,aAAa,CAAC,CAAC;IAC3D,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,eAAe,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,gBAAgB,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,gDAAgD;IAChD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,kBAAkB,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,uDAAuD;IACvD,gBAAgB,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,kCAAkC;IAClC,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,gCAAgC;IAChC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,yDAAyD;IACzD,6BAA6B,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAChE;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,WAAW,EACX,EAAE,EACF,MAAM,EACN,eAAe,EACf,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,6BAA6B,EAC9B,EAAE,gBAAgB;0CAII,MAAM,iBAAiB,OAAO;;EAgDpD"}
1
+ {"version":3,"file":"usePagination.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAG/F,UAAU,gBAAgB;IACxB,wCAAwC;IACxC,WAAW,EAAE,8BAA8B,CAAC,aAAa,CAAC,CAAC;IAC3D,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,eAAe,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,gBAAgB,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,gDAAgD;IAChD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,kBAAkB,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAC9C,uDAAuD;IACvD,gBAAgB,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5C,kCAAkC;IAClC,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,gCAAgC;IAChC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,yDAAyD;IACzD,6BAA6B,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAChE;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,WAAW,EACX,EAAE,EACF,MAAM,EACN,eAAe,EACf,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,6BAA6B,EAC9B,EAAE,gBAAgB;0CAII,MAAM,iBAAiB,OAAO;;EAgDpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePagination.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI9C,OAAO,EAAE,YAAY,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAmCxE;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,WAAW,EACX,EAAE,EACF,MAAM,EACN,eAAe,EACf,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,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gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC;IACJ,CAAC,EACD;QACE,gBAAgB;QAChB,cAAc;QACd,MAAM;QACN,eAAe;QACf,UAAU;QACV,QAAQ;QACR,WAAW;QACX,EAAE;QACF,WAAW;QACX,iBAAiB;KAClB,CACF,CAAC;IAEF,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\n\nimport type { ItemsHeight, VariableHeightVirtualizerProps } from './VariableHeightVirtualizer';\nimport { getDataIndex, getVirtualizedPaginationIndices } from './utils';\n\ninterface PaginationParams {\n /** Callback to fetch paginated data. */\n apiCallback: VariableHeightVirtualizerProps['apiCallback'];\n /** Unique identifier for the virtualizer instance. */\n id: string;\n /** Number of items to buffer before/after the visible range. */\n buffer: number;\n /** Maximum number of items to render at once. */\n maxItemsToPaint: number;\n /** Current start index of the visible items. */\n startIndex: number;\n /** Current end index of the visible items. */\n endIndex: number;\n /** Total number of items in the virtualized list. */\n virtualizedCount: number;\n /** Whether infinite scrolling mode is enabled. */\n isInfiniteMode: boolean;\n /** Mapping of item indices and their actual height. */\n itemsHeight: ItemsHeight;\n /** Default height for items if not measured. */\n defaultItemHeight: number;\n /** Ref to the parent scrollable container element. */\n parentContainerRef: RefObject<HTMLElement>;\n /** Ref to the container holding the rendered items. */\n itemContainerRef: RefObject<HTMLElement>;\n /** Setter for the start index. */\n setStartIndex: (v: number) => void;\n /** Setter for the end index. */\n setEndIndex: (v: number) => void;\n /** Ref to track the previous first item's data index. */\n previousFirstItemDataIndexRef: MutableRefObject<number | null>;\n}\n\n/**\n * Calculates the indices of items to render based on the current scroll position,\n * buffer, and virtualization settings. It triggers data fetching via the provided `apiCallback`\n * when pagination boundaries change or a force refresh is requested.\n *\n * @returns An object containing:\n * - `triggerPagination`: Function to recalculate pagination indices and trigger data fetching.\n * - `isForceRefreshedPagination`: Boolean indicating if the last pagination was force-refreshed.\n */\nexport default function usePagination({\n apiCallback,\n id,\n buffer,\n maxItemsToPaint,\n startIndex,\n endIndex,\n virtualizedCount,\n isInfiniteMode,\n itemsHeight,\n defaultItemHeight,\n parentContainerRef,\n itemContainerRef,\n setStartIndex,\n setEndIndex,\n previousFirstItemDataIndexRef\n}: PaginationParams) {\n const [isForceRefreshedPagination, setIsForceRefreshedPagination] = useState<boolean>(false);\n\n const triggerPagination = useCallback(\n (currentScrollTop: number, forceRefresh?: boolean) => {\n setIsForceRefreshedPagination(!!forceRefresh);\n const { startIndex: newStartIndex, endIndex: newEndIndex } = getVirtualizedPaginationIndices({\n scrollTop: currentScrollTop,\n containerRef: parentContainerRef,\n itemContainerRef,\n totalItemCount: virtualizedCount,\n itemsHeight,\n defaultItemHeight,\n buffer,\n endIndexLimit: maxItemsToPaint,\n isInfiniteMode\n });\n\n // Prevent redundant fetch\n if (!forceRefresh && endIndex > 0 && newStartIndex >= startIndex && newEndIndex <= endIndex) {\n return;\n }\n\n if (virtualizedCount === 0) {\n previousFirstItemDataIndexRef.current = 0;\n } else if (itemContainerRef.current?.children[0]) {\n const firstItemDataIndex = getDataIndex(itemContainerRef.current.children[0]);\n previousFirstItemDataIndexRef.current = firstItemDataIndex ?? 0;\n }\n\n setStartIndex(newStartIndex);\n setEndIndex(newEndIndex);\n apiCallback(\n { startIndex: newStartIndex, endIndex: newEndIndex, id },\n { takeLatestAction: true }\n );\n },\n [\n virtualizedCount,\n isInfiniteMode,\n buffer,\n maxItemsToPaint,\n startIndex,\n endIndex,\n apiCallback,\n id,\n itemsHeight,\n defaultItemHeight\n ]\n );\n\n return { triggerPagination, isForceRefreshedPagination };\n}\n"]}
1
+ {"version":3,"file":"usePagination.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI9C,OAAO,EAAE,YAAY,E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AAO,GAAG,kBAAkB,IAAI,CAAC,CAAC;QAClE,CAAC;QAED,aAAa,CAAC,aAAa,CAAC,CAAC;QAC7B,WAAW,CAAC,WAAW,CAAC,CAAC;QACzB,WAAW,CACT,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,EACxD,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC;IACJ,CAAC,EACD;QACE,gBAAgB;QAChB,cAAc;QACd,MAAM;QACN,eAAe;QACf,UAAU;QACV,QAAQ;QACR,WAAW;QACX,EAAE;QACF,WAAW;QACX,iBAAiB;KAClB,CACF,CAAC;IAEF,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\n\nimport type { ItemsHeight, VariableHeightVirtualizerProps } from './VariableHeightVirtualizer';\nimport { getDataIndex, getVirtualizedPaginationIndices } from './utils';\n\ninterface PaginationParams {\n /** Callback to fetch paginated data. */\n apiCallback: VariableHeightVirtualizerProps['apiCallback'];\n /** Unique identifier for the virtualizer instance. */\n id: string;\n /** Number of items to buffer before/after the visible range. */\n buffer: number;\n /** Maximum number of items to render at once. */\n maxItemsToPaint: number;\n /** Current start index of the visible items. */\n startIndex: number;\n /** Current end index of the visible items. */\n endIndex: number;\n /** Total number of items in the virtualized list. */\n virtualizedCount: number;\n /** Whether infinite scrolling mode is enabled. */\n isInfiniteMode: boolean;\n /** Mapping of item indices and their actual height. */\n itemsHeight: ItemsHeight;\n /** Default height for items if not measured. */\n defaultItemHeight: number;\n /** Ref to the parent scrollable container element. */\n parentContainerRef: RefObject<HTMLDivElement>;\n /** Ref to the container holding the rendered items. */\n itemContainerRef: RefObject<HTMLDivElement>;\n /** Setter for the start index. */\n setStartIndex: (v: number) => void;\n /** Setter for the end index. */\n setEndIndex: (v: number) => void;\n /** Ref to track the previous first item's data index. */\n previousFirstItemDataIndexRef: MutableRefObject<number | null>;\n}\n\n/**\n * Calculates the indices of items to render based on the current scroll position,\n * buffer, and virtualization settings. It triggers data fetching via the provided `apiCallback`\n * when pagination boundaries change or a force refresh is requested.\n *\n * @returns An object containing:\n * - `triggerPagination`: Function to recalculate pagination indices and trigger data fetching.\n * - `isForceRefreshedPagination`: Boolean indicating if the last pagination was force-refreshed.\n */\nexport default function usePagination({\n apiCallback,\n id,\n buffer,\n maxItemsToPaint,\n startIndex,\n endIndex,\n virtualizedCount,\n isInfiniteMode,\n itemsHeight,\n defaultItemHeight,\n parentContainerRef,\n itemContainerRef,\n setStartIndex,\n setEndIndex,\n previousFirstItemDataIndexRef\n}: PaginationParams) {\n const [isForceRefreshedPagination, setIsForceRefreshedPagination] = useState<boolean>(false);\n\n const triggerPagination = useCallback(\n (currentScrollTop: number, forceRefresh?: boolean) => {\n setIsForceRefreshedPagination(!!forceRefresh);\n const { startIndex: newStartIndex, endIndex: newEndIndex } = getVirtualizedPaginationIndices({\n scrollTop: currentScrollTop,\n containerRef: parentContainerRef,\n itemContainerRef,\n totalItemCount: virtualizedCount,\n itemsHeight,\n defaultItemHeight,\n buffer,\n endIndexLimit: maxItemsToPaint,\n isInfiniteMode\n });\n\n // Prevent redundant fetch\n if (!forceRefresh && endIndex > 0 && newStartIndex >= startIndex && newEndIndex <= endIndex) {\n return;\n }\n\n if (virtualizedCount === 0) {\n previousFirstItemDataIndexRef.current = 0;\n } else if (itemContainerRef.current?.children[0]) {\n const firstItemDataIndex = getDataIndex(itemContainerRef.current.children[0]);\n previousFirstItemDataIndexRef.current = firstItemDataIndex ?? 0;\n }\n\n setStartIndex(newStartIndex);\n setEndIndex(newEndIndex);\n apiCallback(\n { startIndex: newStartIndex, endIndex: newEndIndex, id },\n { takeLatestAction: true }\n );\n },\n [\n virtualizedCount,\n isInfiniteMode,\n buffer,\n maxItemsToPaint,\n startIndex,\n endIndex,\n apiCallback,\n id,\n itemsHeight,\n defaultItemHeight\n ]\n );\n\n return { triggerPagination, isForceRefreshedPagination };\n}\n"]}
@@ -4,9 +4,9 @@ interface GetVirtualizedPaginationIndicesParams {
4
4
  /** Current vertical scroll offset of the container. */
5
5
  scrollTop: number;
6
6
  /** Ref to the scrolling container element */
7
- containerRef: RefObject<HTMLElement>;
7
+ containerRef: RefObject<HTMLDivElement>;
8
8
  /** Ref to the container holding the list items */
9
- itemContainerRef: RefObject<HTMLElement>;
9
+ itemContainerRef: RefObject<HTMLDivElement>;
10
10
  /** Total number of items. */
11
11
  totalItemCount: number;
12
12
  /** Mapping of item indices and their actual height. */
@@ -64,7 +64,7 @@ export declare const getOffsetForIndex: (index: number, itemsHeight: ItemsHeight
64
64
  * @param renderHeader - Indicates whether a header is rendered at the top of the parent container.
65
65
  * @returns `true` if the view is not filled with all items, `false` otherwise.
66
66
  */
67
- export declare const isViewNotFilled: (totalItemCount: number, itemContainer: HTMLElement, parentContainer: HTMLElement, renderHeader: boolean) => boolean;
67
+ export declare const isViewNotFilled: (totalItemCount: number, itemContainer: HTMLDivElement, parentContainer: HTMLDivElement, renderHeader: boolean) => boolean;
68
68
  /**
69
69
  * Retrieves the numeric data index from the `data-index` attribute of a given Element.
70
70
  *
@@ -81,7 +81,7 @@ export declare const getDataIndex: (element: Element) => number | null;
81
81
  * @param defaultItemHeight - The default height to use for items not present in `itemsHeight`.
82
82
  * @returns An object mapping item indices to their new heights for items whose heights have changed.
83
83
  */
84
- export declare function getChangedItemsHeight(itemContainer: HTMLElement, itemsHeight: ItemsHeight, defaultItemHeight: number): ItemsHeight;
84
+ export declare function getChangedItemsHeight(itemContainer: HTMLDivElement, itemsHeight: ItemsHeight, defaultItemHeight: number): ItemsHeight;
85
85
  /**
86
86
  * Calculates the cumulative change in item heights between two sets of item height data,
87
87
  * for a range of items starting from `startIndex` up to (but not including) `previousFirstItemDataIndex`.
@@ -107,6 +107,6 @@ export declare const calculateCumulativeItemSizeChange: (startIndex: number, pre
107
107
  * @param defaultItemHeight - The default height to use for items without a specified height.
108
108
  * @returns The total height of all items within the container, rounded down to the nearest integer.
109
109
  */
110
- export declare const updateItemPositionStyles: (itemContainer: HTMLElement, itemsHeight: ItemsHeight, defaultItemHeight: number) => number;
110
+ export declare const updateItemPositionStyles: (itemContainer: HTMLDivElement, itemsHeight: ItemsHeight, defaultItemHeight: number) => number;
111
111
  export {};
112
112
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,UAAU,qCAAqC;IAC7C,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,YAAY,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACrC,kDAAkD;IAClD,gBAAgB,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,6BAA6B;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,gDAAgD;IAChD,iBAAiB,EAAE,MAAM,CAAC;IAE1B,iGAAiG;IACjG,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,+FAA+F;IAC/F,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAC1C,OAAO,qCAAqC,KAC3C;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAgDxC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GACrC,gBAAgB,MAAM,EACtB,aAAa,WAAW,EACxB,mBAAmB,MAAM,KACxB,MAOF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,eAAe,MAAM,GAAG,MAAM,GAAG,IAAI,KAAG,MAGpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,MAAM,EACb,aAAa,WAAW,EACxB,mBAAmB,MAAM,KACxB,MAOF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,MAAM,EACtB,eAAe,WAAW,EAC1B,iBAAiB,WAAW,EAC5B,cAAc,OAAO,KACpB,OA2BF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,KAAG,MAAM,GAAG,IAKxD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,WAAW,EAC1B,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,MAAM,GACxB,WAAW,CAkBb;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAC5C,YAAY,MAAM,EAClB,4BAA4B,MAAM,GAAG,IAAI,EACzC,aAAa,WAAW,EACxB,qBAAqB,WAAW,EAChC,mBAAmB,MAAM,KACxB,MAiBF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,eAAe,WAAW,EAC1B,aAAa,WAAW,EACxB,mBAAmB,MAAM,KACxB,MAwBF,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,UAAU,qCAAqC;IAC7C,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,kDAA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AO,MAAM,iCAAiC,GAC5C,YAAY,MAAM,EAClB,4BAA4B,MAAM,GAAG,IAAI,EACzC,aAAa,WAAW,EACxB,qBAAqB,WAAW,EAChC,mBAAmB,MAAM,KACxB,MAiBF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,eAAe,cAAc,EAC7B,aAAa,WAAW,EACxB,mBAAmB,MAAM,KACxB,MAwBF,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { getScrollbarWidth } from 'pega-repeating-structures-core';
2
+ import { isInstance } from '@pega/cosmos-react-core';
2
3
  /**
3
4
  * Calculates the start and end indices for virtualized pagination in a variable-height list.
4
5
  *
@@ -93,12 +94,12 @@ export const isViewNotFilled = (totalItemCount, itemContainer, parentContainer,
93
94
  let headerHeight = 0;
94
95
  if (renderHeader && parentContainer.childElementCount > 1) {
95
96
  const firstChild = parentContainer.children[0];
96
- if (firstChild instanceof HTMLElement) {
97
+ if (isInstance(firstChild, HTMLDivElement)) {
97
98
  headerHeight = firstChild.offsetHeight;
98
99
  }
99
100
  }
100
101
  const scrollbarWidth = getScrollbarWidth();
101
- const items = Array.from(itemContainer.children).filter((el) => el instanceof HTMLElement);
102
+ const items = Array.from(itemContainer.children);
102
103
  if (!items.length && !totalItemCount)
103
104
  return false;
104
105
  if (!items.length && totalItemCount)
@@ -200,8 +201,8 @@ export const updateItemPositionStyles = (itemContainer, itemsHeight, defaultItem
200
201
  itemContainer.style.top = `${offset}px`;
201
202
  let itemContainerCurrentHeight = 0;
202
203
  let currentItemIndex = firstItemDataIndex;
203
- Array.from(items).forEach((item) => {
204
- if (!(item instanceof HTMLElement))
204
+ Array.from(items).forEach(item => {
205
+ if (!isInstance(item, HTMLDivElement))
205
206
  return;
206
207
  item.style.position = 'absolute';
207
208
  item.style.top = `${itemContainerCurrentHeight}px`;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/utils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AG,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"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA2BrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,KAA4C,EACF,EAAE;IAC5C,MAAM,EACJ,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,cAAc,EACf,GAAG,KAAK,CAAC;IAEV,MAAM,wBAAwB,GAAG,MAAM,GAAG,CAAC,CAAC;IAC5C,IAAI,cAAc,KAAK,CAAC,IAAI,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,KAAK,CAAC,EAAE,CAAC;QAC9E,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAE,CAAC;IAC/D,CAAC;IAED,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;IAE/D,oEAAoE;IACpE,IAAI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F,gBAAgB,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import type { RefObject } from 'react';\n\nimport { getScrollbarWidth } from 'pega-repeating-structures-core';\nimport { isInstance } from '@pega/cosmos-react-core';\n\nimport type { ItemsHeight } from './VariableHeightVirtualizer';\n\ninterface GetVirtualizedPaginationIndicesParams {\n /** Current vertical scroll offset of the container. */\n scrollTop: number;\n /** Ref to the scrolling container element */\n containerRef: RefObject<HTMLDivElement>;\n /** Ref to the container holding the list items */\n itemContainerRef: RefObject<HTMLDivElement>;\n\n /** Total number of items. */\n totalItemCount: number;\n /** Mapping of item indices and their actual height. */\n itemsHeight: ItemsHeight;\n /** Default height for items if not measured. */\n defaultItemHeight: number;\n\n /** Number of extra items to render above and below the visible viewport for smooth scrolling. */\n buffer: number;\n /** Maximum allowed end index (exclusive). */\n endIndexLimit: number;\n /** If true, allows indices to exceed totalCount for infinite scrolling by including buffer. */\n isInfiniteMode?: boolean;\n}\n\n/**\n * Calculates the start and end indices for virtualized pagination in a variable-height list.\n *\n * @returns {{ startIndex: number, endIndex: number }} Object containing the calculated start and end indices for rendering (inclusive both indices).\n */\nexport const getVirtualizedPaginationIndices = (\n param: GetVirtualizedPaginationIndicesParams\n): { startIndex: number; endIndex: number } => {\n const {\n totalItemCount,\n buffer,\n itemContainerRef,\n scrollTop,\n containerRef,\n itemsHeight,\n defaultItemHeight,\n endIndexLimit,\n isInfiniteMode\n } = param;\n\n const minimumItemsToFetchOnTop = buffer * 4;\n if (totalItemCount === 0 || itemContainerRef.current?.childElementCount === 0) {\n return { startIndex: 0, endIndex: minimumItemsToFetchOnTop };\n }\n\n const viewportHeight = containerRef.current?.clientHeight || 0;\n\n // Find the first visible item index for the current scroll position\n let aboveTheFoldItemsHeight = 0;\n let visibleStartIndex = 0;\n while (\n visibleStartIndex < totalItemCount &&\n aboveTheFoldItemsHeight + (itemsHeight[visibleStartIndex] ?? defaultItemHeight) < scrollTop\n ) {\n aboveTheFoldItemsHeight += itemsHeight[visibleStartIndex] ?? defaultItemHeight;\n visibleStartIndex += 1;\n }\n\n // Find the last visible item index for the current scroll position\n let inViewItemsHeight = 0;\n let visibleEndIndex = visibleStartIndex;\n while (visibleEndIndex < totalItemCount && inViewItemsHeight < viewportHeight) {\n inViewItemsHeight += itemsHeight[visibleEndIndex] ?? defaultItemHeight;\n visibleEndIndex += 1;\n }\n\n const startIndex = Math.max(0, visibleStartIndex - buffer);\n let endIndex = Math.min(visibleEndIndex + buffer, endIndexLimit - 1);\n if (isInfiniteMode) {\n endIndex = Math.max(endIndex, minimumItemsToFetchOnTop);\n } else {\n // In cases where the count is very less due to filters, we would fetch more items to avoid unnecessary API calls if the count after the filter removed is more\n endIndex = Math.max(Math.min(totalItemCount - 1, endIndex), minimumItemsToFetchOnTop);\n }\n return { startIndex, endIndex };\n};\n\n/**\n * Calculates the total buffer height for a list of items, using their individual heights if available,\n * or a default height otherwise.\n *\n * @param totalItemCount - The total number of items in the list.\n * @param itemsHeight - An object or array containing the heights of individual items, indexed by item position.\n * @param defaultItemHeight - The default height to use for items whose height is not specified in `itemsHeight`.\n * @returns The sum of all item heights, using the default height for any missing values.\n */\nexport const calculateTotalBufferHeight = (\n totalItemCount: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let totalBufferHeight = 0;\n for (let i = 0; i < totalItemCount; i += 1) {\n totalBufferHeight += itemsHeight[i] || defaultItemHeight;\n }\n\n return totalBufferHeight;\n};\n\n/**\n * Returns a CSS-compatible max-height value based on the input.\n *\n * @param viewMaxHeight - The maximum height value, which can be a number (pixels), a string (CSS value), or `null`.\n * @returns A string representing the CSS max-height value.\n */\nexport const getMaxHeight = (viewMaxHeight: number | string | null): string => {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n};\n\n/**\n * Calculates the vertical offset for a given item index in a list with variable item heights.\n *\n * @param index - The index of the item for which to calculate the offset.\n * @param itemsHeight - Mapping of item indices and their actual height.\n * @param defaultItemHeight - The default height to use for items not present in the cache.\n * @returns The total offset (in pixels) from the top of the list to the specified index.\n */\nexport const getOffsetForIndex = (\n index: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let offset = 0;\n\n for (let i = 0; i < index; i += 1) {\n offset += itemsHeight[i] ?? defaultItemHeight;\n }\n return offset;\n};\n\n/**\n * Determines whether the viewable area of a virtualized list is not fully filled with rendered items.\n *\n * @param totalItemCount - The total number of items that should be rendered.\n * @param itemContainer - The HTML element containing the rendered items.\n * @param parentContainer - The parent HTML element that contains the items and possibly the header.\n * @param renderHeader - Indicates whether a header is rendered at the top of the parent container.\n * @returns `true` if the view is not filled with all items, `false` otherwise.\n */\nexport const isViewNotFilled = (\n totalItemCount: number,\n itemContainer: HTMLDivElement,\n parentContainer: HTMLDivElement,\n renderHeader: boolean\n): boolean => {\n const parentContainerPosition = parentContainer.getBoundingClientRect();\n let headerHeight = 0;\n if (renderHeader && parentContainer.childElementCount > 1) {\n const firstChild = parentContainer.children[0];\n if (isInstance(firstChild, HTMLDivElement)) {\n headerHeight = firstChild.offsetHeight;\n }\n }\n\n const scrollbarWidth = getScrollbarWidth();\n const items = Array.from(itemContainer.children);\n\n if (!items.length && !totalItemCount) return false;\n if (!items.length && totalItemCount) return true;\n\n return (\n !!totalItemCount &&\n items.length !== totalItemCount &&\n (Math.floor(items[items.length - 1].getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(items[0].getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerHeight) ||\n items.length === 0)\n );\n};\n\n/**\n * Retrieves the numeric data index from the `data-index` attribute of a given Element.\n *\n * @param element - The Element from which to extract the data index.\n * @returns The parsed integer value of the `data-index` attribute, or `null` if the attribute is not present.\n */\nexport const getDataIndex = (element: Element): number | null => {\n const dataIndexStr = element?.getAttribute('data-index');\n if (!dataIndexStr) return null;\n const parsedDataIndex = parseInt(dataIndexStr, 10);\n return Number.isNaN(parsedDataIndex) ? null : parsedDataIndex;\n};\n\n/**\n * Calculates and returns an object containing the heights of items whose heights have changed\n * compared to their previous values.\n *\n * @param itemContainer - The container HTMLElement whose child nodes represent items to measure.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items not present in `itemsHeight`.\n * @returns An object mapping item indices to their new heights for items whose heights have changed.\n */\nexport function getChangedItemsHeight(\n itemContainer: HTMLDivElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): ItemsHeight {\n if (!itemContainer) return {};\n\n const newHeights: ItemsHeight = {};\n const nodes = Array.from(itemContainer.children);\n\n nodes.forEach(node => {\n const itemDataIndex = getDataIndex(node);\n if (itemDataIndex === null) return;\n\n const measuredHeight = node.getBoundingClientRect().height;\n const prevHeight = itemsHeight[itemDataIndex] ?? defaultItemHeight;\n if (measuredHeight !== prevHeight) {\n newHeights[itemDataIndex] = measuredHeight;\n }\n });\n\n return newHeights;\n}\n\n/**\n * Calculates the cumulative change in item heights between two sets of item height data,\n * for a range of items starting from `startIndex` up to (but not including) `previousFirstItemDataIndex`.\n *\n * This function compares the current heights (`itemsHeight`) with the previous heights (`previousItemsHeight`)\n * for each item in the specified range, using `defaultItemHeight` as a fallback if a previous height is missing.\n * The result is the sum of the differences in height for all items in the range.\n *\n * @param startIndex - The index at which to start calculating the cumulative height change.\n * @param previousFirstItemDataIndex - The index up to which to calculate (exclusive). If `null` or less than or equal to 0, returns 0.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param previousItemsHeight - An object mapping item indices of previously rendered items to their heights.\n * @param defaultItemHeight - The default height to use if a previous height is not available.\n * @returns The cumulative change in item heights for the specified range, or 0 if the result is not finite.\n */\nexport const calculateCumulativeItemSizeChange = (\n startIndex: number,\n previousFirstItemDataIndex: number | null,\n itemsHeight: ItemsHeight,\n previousItemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n if (previousFirstItemDataIndex === null || previousFirstItemDataIndex <= 0) {\n return 0;\n }\n\n let delta = 0;\n\n for (let i = startIndex; i < previousFirstItemDataIndex; i += 1) {\n const actualHeight = itemsHeight[i];\n const previousHeight = previousItemsHeight[i] ?? defaultItemHeight;\n\n if (actualHeight !== null && actualHeight !== undefined) {\n delta += actualHeight - previousHeight;\n }\n }\n\n return Number.isFinite(delta) ? delta : 0;\n};\n\n/**\n * Updates the position styles of child items within a container element to enable virtualized rendering.\n * Sets the container's top offset and positions each child absolutely based on their calculated heights.\n *\n * @param itemContainer - The HTML element containing the list items to be positioned.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items without a specified height.\n * @returns The total height of all items within the container, rounded down to the nearest integer.\n */\nexport const updateItemPositionStyles = (\n itemContainer: HTMLDivElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n const items = itemContainer.children;\n if (!items?.length) {\n return 0;\n }\n\n const firstItemDataIndex = getDataIndex(items[0]);\n if (firstItemDataIndex === null) return 0;\n\n const offset = getOffsetForIndex(firstItemDataIndex, itemsHeight, defaultItemHeight);\n itemContainer.style.top = `${offset}px`;\n\n let itemContainerCurrentHeight = 0;\n let currentItemIndex = firstItemDataIndex;\n Array.from(items).forEach(item => {\n if (!isInstance(item, HTMLDivElement)) return;\n\n item.style.position = 'absolute';\n item.style.top = `${itemContainerCurrentHeight}px`;\n itemContainerCurrentHeight += itemsHeight[currentItemIndex] ?? defaultItemHeight;\n currentItemIndex += 1;\n });\n\n return Math.floor(itemContainerCurrentHeight);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/lists-react",
3
- "version": "9.0.0-build.9.8",
3
+ "version": "9.0.0-build.9.9",
4
4
  "description": "Repeating view structures such as Table, Gallery(Repeating layouts), Kanban etc.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Pegasystems",
@@ -14,9 +14,9 @@
14
14
  "build": "tsc -b tsconfig.build.json"
15
15
  },
16
16
  "dependencies": {
17
- "@pega/cosmos-react-condition-builder": "9.0.0-build.9.8",
18
- "@pega/cosmos-react-core": "9.0.0-build.9.8",
19
- "@pega/cosmos-react-rte": "9.0.0-build.9.8",
17
+ "@pega/cosmos-react-condition-builder": "9.0.0-build.9.9",
18
+ "@pega/cosmos-react-core": "9.0.0-build.9.9",
19
+ "@pega/cosmos-react-rte": "9.0.0-build.9.9",
20
20
  "@types/lodash.get": "^4.4.9",
21
21
  "@types/react": "^17.0.62 || ^18.3.3",
22
22
  "@types/react-dom": "^17.0.20 || ^18.3.0",
@@ -24,8 +24,8 @@
24
24
  "dayjs": "^1.11.13",
25
25
  "fast-deep-equal": "^3.1.3",
26
26
  "lodash.get": "^4.4.2",
27
- "pega-repeating-structures-core": "npm:@pega/lists-core@9.0.0-build.9.8",
28
- "pega-ui-list-data-apis": "npm:@pega/lists-core-utils@9.0.0-build.9.8",
27
+ "pega-repeating-structures-core": "npm:@pega/lists-core@9.0.0-build.9.9",
28
+ "pega-ui-list-data-apis": "npm:@pega/lists-core-utils@9.0.0-build.9.9",
29
29
  "polished": "^4.1.0",
30
30
  "prop-types": "^15.8.1",
31
31
  "react": "^17.0.0 || ^18.0.0",
@@ -44,7 +44,7 @@
44
44
  "@testing-library/react": "^16.0.0",
45
45
  "@testing-library/user-event": "^14.6.1",
46
46
  "jest-axe": "^8.0.0",
47
- "srs-utils": "9.0.0-build.9.8",
47
+ "srs-utils": "9.0.0-build.9.9",
48
48
  "typescript": "~5.8.3"
49
49
  }
50
50
  }