@pega/lists-react 9.0.0-build.9.6 → 9.0.0-build.9.8
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/DefaultComponents/EmptyContainer.d.ts +3 -1
- package/lib/Core/Components/DefaultComponents/EmptyContainer.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/EmptyContainer.js +2 -4
- package/lib/Core/Components/DefaultComponents/EmptyContainer.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/index.d.ts +3 -1
- package/lib/Core/Components/DefaultComponents/index.d.ts.map +1 -1
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts +6 -6
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts.map +1 -1
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js +10 -8
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js.map +1 -1
- package/lib/Core/Components/Virtualise/VirtualizeInfinite.js +8 -5
- package/lib/Core/Components/Virtualise/VirtualizeInfinite.js.map +1 -1
- package/lib/Core/Components/Virtualise/index.js +6 -5
- package/lib/Core/Components/Virtualise/index.js.map +1 -1
- package/lib/Core/Localization/defaultTranslations.d.ts +2 -1
- package/lib/Core/Localization/defaultTranslations.d.ts.map +1 -1
- package/lib/Core/Localization/defaultTranslations.js +2 -1
- package/lib/Core/Localization/defaultTranslations.js.map +1 -1
- package/lib/Core/Utils/index.d.ts +11 -0
- package/lib/Core/Utils/index.d.ts.map +1 -1
- package/lib/Core/Utils/index.js +11 -0
- package/lib/Core/Utils/index.js.map +1 -1
- package/lib/Core/Views/Gallery/index.d.ts.map +1 -1
- package/lib/Core/Views/Gallery/index.js +7 -4
- package/lib/Core/Views/Gallery/index.js.map +1 -1
- package/lib/Core/Views/Map/index.d.ts.map +1 -1
- package/lib/Core/Views/Map/index.js +9 -3
- package/lib/Core/Views/Map/index.js.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.d.ts.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.js +12 -5
- package/lib/Core/Views/Table/VirtualizeWrapper.js.map +1 -1
- package/lib/Core/Views/Timeline/index.d.ts.map +1 -1
- package/lib/Core/Views/Timeline/index.js +10 -4
- package/lib/Core/Views/Timeline/index.js.map +1 -1
- package/package.json +7 -7
- package/lib/Core/Components/EmptyContainer.d.ts +0 -5
- package/lib/Core/Components/EmptyContainer.d.ts.map +0 -1
- package/lib/Core/Components/EmptyContainer.js +0 -12
- package/lib/Core/Components/EmptyContainer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Components/DefaultComponents/EmptyContainer.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"EmptyContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Components/DefaultComponents/EmptyContainer.jsx"],"names":[],"mappings":";AAsBA;;4CASC"}
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { defaultThemeProp, EmptyState } from '@pega/cosmos-react-core';
|
|
4
4
|
import TestIdConstants from '../TestIdConstants';
|
|
5
|
-
import useTranslate from '../../Hooks/useTranslate';
|
|
6
5
|
const EmptyContainerStyle = styled.div `
|
|
7
6
|
position: absolute;
|
|
8
7
|
display: flex;
|
|
@@ -17,9 +16,8 @@ const EmptyContainerStyle = styled.div `
|
|
|
17
16
|
overflow: hidden;
|
|
18
17
|
`;
|
|
19
18
|
EmptyContainerStyle.defaultProps = defaultThemeProp;
|
|
20
|
-
const EmptyContainer = () => {
|
|
21
|
-
|
|
22
|
-
return (_jsx(EmptyContainerStyle, { "data-test-id": TestIdConstants.noRecords, "data-testid": TestIdConstants.noRecords, children: _jsx(EmptyState, { message: translate('No records found.') }) }));
|
|
19
|
+
const EmptyContainer = ({ message }) => {
|
|
20
|
+
return (_jsx(EmptyContainerStyle, { "data-test-id": TestIdConstants.noRecords, "data-testid": TestIdConstants.noRecords, children: _jsx(EmptyState, { message: message }) }));
|
|
23
21
|
};
|
|
24
22
|
export default EmptyContainer;
|
|
25
23
|
//# sourceMappingURL=EmptyContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyContainer.js","sourceRoot":"","sources":["../../../../Core/Components/DefaultComponents/EmptyContainer.jsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,eAAe,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"EmptyContainer.js","sourceRoot":"","sources":["../../../../Core/Components/DefaultComponents/EmptyContainer.jsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;gBAUtB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;;CAEtE,CAAC;AAEF,mBAAmB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEpD,MAAM,cAAc,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACrC,OAAO,CACL,KAAC,mBAAmB,oBACJ,eAAe,CAAC,SAAS,iBAC1B,eAAe,CAAC,SAAS,YAEtC,KAAC,UAAU,IAAC,OAAO,EAAE,OAAO,GAAI,GACZ,CACvB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import styled from 'styled-components';\n\nimport { defaultThemeProp, EmptyState } from '@pega/cosmos-react-core';\n\nimport TestIdConstants from '../TestIdConstants';\n\nconst EmptyContainerStyle = styled.div`\n position: absolute;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n top: var(--row-height, 0);\n left: 0;\n right: 0;\n bottom: 0;\n background: ${props => props.theme.base.palette['primary-background']};\n overflow: hidden;\n`;\n\nEmptyContainerStyle.defaultProps = defaultThemeProp;\n\nconst EmptyContainer = ({ message }) => {\n return (\n <EmptyContainerStyle\n data-test-id={TestIdConstants.noRecords}\n data-testid={TestIdConstants.noRecords}\n >\n <EmptyState message={message} />\n </EmptyContainerStyle>\n );\n};\n\nexport default EmptyContainer;\n"]}
|
|
@@ -63,7 +63,9 @@ declare const _default: {
|
|
|
63
63
|
sortRenderer: typeof sort;
|
|
64
64
|
filterRenderer: typeof Filter;
|
|
65
65
|
headerCellRenderer: typeof HeaderCell;
|
|
66
|
-
emptyContainerRenderer: (
|
|
66
|
+
emptyContainerRenderer: ({ message }: {
|
|
67
|
+
message: any;
|
|
68
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
67
69
|
loadingIndicator: typeof LoadingIndicator;
|
|
68
70
|
rowHeightRenderer: typeof RowHeightRenderer;
|
|
69
71
|
personalizationSelectorRenderer: typeof personalizationSelectorRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../Core/Components/DefaultComponents/index.jsx"],"names":[],"mappings":"AA8BA,uGAKC;;;;;;;;;;AAUD,mGASC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../Core/Components/DefaultComponents/index.jsx"],"names":[],"mappings":"AA8BA,uGAKC;;;;;;;;;;AAUD,mGASC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAtDqB,YAAY;iBAEjB,QAAQ;mBACN,UAAU;uBAEN,cAAc;6BAGR,oBAAoB;8BACnB,aAAa;4CAEC,2BAA2B;8CACzB,6BAA6B;8BAC7C,qBAAqB"}
|
package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts
CHANGED
|
@@ -32,11 +32,11 @@ export interface VariableHeightVirtualizerProps {
|
|
|
32
32
|
/** Maximum number of items to render at once. */
|
|
33
33
|
maxItemsToPaint?: number;
|
|
34
34
|
/** Function to render the header. */
|
|
35
|
-
|
|
35
|
+
renderHeader?: (() => ReactNode) | null;
|
|
36
36
|
/** Function to render the footer. */
|
|
37
|
-
|
|
37
|
+
renderFooter?: (() => ReactNode) | null;
|
|
38
38
|
/** Function to render the no-result state. */
|
|
39
|
-
|
|
39
|
+
renderEmptyRecords?: (() => ReactNode) | null;
|
|
40
40
|
/** CSS class for the item container. */
|
|
41
41
|
itemContainerClass?: string;
|
|
42
42
|
/** Maximum height for the view container. */
|
|
@@ -84,9 +84,9 @@ interface VirtualizerRef {
|
|
|
84
84
|
* apiCallback={fetchData}
|
|
85
85
|
* defaultItemHeight={40}
|
|
86
86
|
* buffer={10}
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
* renderHeader={() => <Header />}
|
|
88
|
+
* renderFooter={() => <Footer />}
|
|
89
|
+
* renderEmptyRecords={() => <NoResults />}
|
|
90
90
|
* >
|
|
91
91
|
* {items.map(item => <ListItem key={item.id} {...item} />)}
|
|
92
92
|
* </VariableHeightVirtualizer>
|
package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableHeightVirtualizer.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAC;AAsBrD,MAAM,WAAW,WAAW;IAC1B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD,MAAM,WAAW,8BAA8B;IAC7C,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,QAAQ,EAAE,SAAS,CAAC;IACpB,wCAAwC;IACxC,WAAW,EAAE,CACX,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAC5D,OAAO,EAAE;QAAE,gBAAgB,EAAE,OAAO,CAAA;KAAE,KACnC,IAAI,CAAC;IACV,oDAAoD;IACpD,cAAc,EAAE,OAAO,CAAC;IACxB,4CAA4C;IAC5C,eAAe,EAAE,eAAe,CAAC;IACjC,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,
|
|
1
|
+
{"version":3,"file":"VariableHeightVirtualizer.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAC;AAsBrD,MAAM,WAAW,WAAW;IAC1B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD,MAAM,WAAW,8BAA8B;IAC7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,GAAG,IAAI,CAAC;IAC7C,4CAA4C;IAC5C,kBAAkB,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC7C,4CAA4C;IAC5C,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B;AAaD;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,yBAAyB,2HA6T9B,CAAC;AAIF,eAAe,yBAAyB,CAAC"}
|
package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js
CHANGED
|
@@ -48,15 +48,15 @@ const StyledLoader = Styled.div `
|
|
|
48
48
|
* apiCallback={fetchData}
|
|
49
49
|
* defaultItemHeight={40}
|
|
50
50
|
* buffer={10}
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* renderHeader={() => <Header />}
|
|
52
|
+
* renderFooter={() => <Footer />}
|
|
53
|
+
* renderEmptyRecords={() => <NoResults />}
|
|
54
54
|
* >
|
|
55
55
|
* {items.map(item => <ListItem key={item.id} {...item} />)}
|
|
56
56
|
* </VariableHeightVirtualizer>
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
const VariableHeightVirtualizer = forwardRef(({ id, children, buffer = 15, apiCallback, loadedDataRange = {}, defaultItemHeight = 30, totalItemCount, maxItemsToPaint = 5000,
|
|
59
|
+
const VariableHeightVirtualizer = forwardRef(({ id, children, buffer = 15, apiCallback, loadedDataRange = {}, defaultItemHeight = 30, totalItemCount, maxItemsToPaint = 5000, renderHeader = null, renderFooter = null, renderEmptyRecords = null, itemContainerClass = '', viewMaxHeight = null, minHeight = 'auto', isDataFetching = false, minHeightWhenNoItemsRendered = 'auto' }, ref) => {
|
|
60
60
|
const [startIndex, setStartIndex] = useState(0);
|
|
61
61
|
const [endIndex, setEndIndex] = useState(0);
|
|
62
62
|
const [scrollTop, setScrollTop] = useState(0);
|
|
@@ -200,7 +200,7 @@ const VariableHeightVirtualizer = forwardRef(({ id, children, buffer = 15, apiCa
|
|
|
200
200
|
(!endIndex ||
|
|
201
201
|
(itemContainerRef.current &&
|
|
202
202
|
parentContainerRef.current &&
|
|
203
|
-
isViewNotFilled(virtualizedCount, itemContainerRef.current, parentContainerRef.current, !!
|
|
203
|
+
isViewNotFilled(virtualizedCount, itemContainerRef.current, parentContainerRef.current, !!renderHeader)))) {
|
|
204
204
|
triggerPagination(scrollTop);
|
|
205
205
|
}
|
|
206
206
|
}, [
|
|
@@ -211,7 +211,7 @@ const VariableHeightVirtualizer = forwardRef(({ id, children, buffer = 15, apiCa
|
|
|
211
211
|
triggerPagination,
|
|
212
212
|
parentContainerDimensionChangeTrigger,
|
|
213
213
|
isDataFetching,
|
|
214
|
-
|
|
214
|
+
renderHeader
|
|
215
215
|
]);
|
|
216
216
|
// Resize observer on items to track height changes
|
|
217
217
|
const onItemsHeightUpdate = useCallback(() => {
|
|
@@ -231,7 +231,7 @@ const VariableHeightVirtualizer = forwardRef(({ id, children, buffer = 15, apiCa
|
|
|
231
231
|
overflowY: 'auto',
|
|
232
232
|
position: 'relative',
|
|
233
233
|
width: '100%'
|
|
234
|
-
}, className: 'pContainer variableHeightVirtualizer', "data-total-records": totalItemCount, children: [
|
|
234
|
+
}, className: 'pContainer variableHeightVirtualizer', "data-total-records": totalItemCount, children: [renderHeader && renderHeader(), _jsxs("div", { className: 'bContainer', ref: bufferContainerRef, style: { height: totalBufferHeight, position: 'relative' }, children: [isDataFetching && !isForceRefreshedPagination && (_jsx(StyledLoader, { "$style": {
|
|
235
235
|
top: '--above-loader-top',
|
|
236
236
|
left: '--loader-left'
|
|
237
237
|
}, children: _jsx(Progress, { className: 'above-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) })), _jsx("div", { ref: itemContainerRef, style: {
|
|
@@ -242,7 +242,9 @@ const VariableHeightVirtualizer = forwardRef(({ id, children, buffer = 15, apiCa
|
|
|
242
242
|
}, className: `${itemContainerClass} row-container`, children: children }), isDataFetching && !isForceRefreshedPagination && (_jsx(StyledLoader, { "$style": {
|
|
243
243
|
top: '--below-loader-top',
|
|
244
244
|
left: '--loader-left'
|
|
245
|
-
}, children: _jsx(Progress, { className: 'below-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) }))] }), virtualizedCount === 0 && !isDataFetching &&
|
|
245
|
+
}, children: _jsx(Progress, { className: 'below-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) }))] }), virtualizedCount === 0 && !isDataFetching && renderEmptyRecords
|
|
246
|
+
? renderEmptyRecords()
|
|
247
|
+
: null, renderFooter && renderFooter()] }));
|
|
246
248
|
});
|
|
247
249
|
VariableHeightVirtualizer.displayName = 'VariableHeightVirtualizer';
|
|
248
250
|
export default VariableHeightVirtualizer;
|
package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableHeightVirtualizer.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,SAAS,EACT,QAAQ,EACR,WAAW,EACX,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,OAAO,EACR,MAAM,OAAO,CAAC;AAEf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,YAAY,MAAM,6BAA6B,CAAC;AAEvD,OAAO,+BAA+B,MAAM,mCAAmC,CAAC;AAChF,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,iCAAiC,EACjC,YAAY,E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ACW,CAChB,EAED,cACE,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE;4BACL,QAAQ,EAAE,UAAU;4BACpB,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,MAAM;4BACb,MAAM,EAAE,GAAG,mBAAmB,IAAI;yBACnC,EACD,SAAS,EAAE,GAAG,kBAAkB,gBAAgB,YAE/C,QAAQ,GACL,EAEL,cAAc,IAAI,CAAC,0BAA0B,IAAI,CAChD,KAAC,YAAY,cACH;4BACN,GAAG,EAAE,oBAAoB;4BACzB,IAAI,EAAE,eAAe;yBACtB,YAED,KAAC,QAAQ,IACP,SAAS,EAAC,cAAc,EACxB,SAAS,EAAC,OAAO,EACjB,QAAQ,EAAE,CAAC,gBACC,SAAS,CAAC,sBAAsB,CAAC,GAC7C,GACW,CAChB,IACG,EACL,gBAAgB,KAAK,CAAC,IAAI,CAAC,cAAc,IAAI,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,IAAI,EACzF,cAAc,IAAI,cAAc,EAAE,IAC/B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,yBAAyB,CAAC,WAAW,GAAG,2BAA2B,CAAC;AAEpE,eAAe,yBAAyB,CAAC","sourcesContent":["import {\n useRef,\n useEffect,\n useState,\n useCallback,\n useLayoutEffect,\n forwardRef,\n useImperativeHandle,\n useMemo\n} from 'react';\nimport type { ReactNode, ForwardedRef } from 'react';\nimport Styled from 'styled-components';\n\nimport { Progress } from '@pega/cosmos-react-core';\n\nimport useResizeObserver from '../UseResizeObserver';\nimport useTranslate from '../../../Hooks/useTranslate';\n\nimport useChildrenHeightResizeObserver from './useChildrenHeightResizeObserver';\nimport useLoaderPositioning from './useLoaderPositioning';\nimport usePagination from './usePagination';\nimport useScroll from './useScroll';\nimport useVirtualizerItemCount from './useVirtualizerItemCount';\nimport {\n calculateCumulativeItemSizeChange,\n getMaxHeight,\n isViewNotFilled,\n calculateTotalBufferHeight,\n getChangedItemsHeight,\n updateItemPositionStyles\n} from './utils';\n\nexport interface ItemsHeight {\n [index: number]: number;\n}\n\nexport interface LoadedDataRange {\n startIndex?: number;\n endIndex?: number;\n}\n\ninterface StyledLoaderProps {\n $style: {\n top: string;\n left: string;\n };\n}\n\nexport interface VariableHeightVirtualizerProps {\n /** Unique identifier for the virtualizer instance. */\n id: string;\n /** The React children elements to render inside the virtualizer. */\n children: ReactNode;\n /** Callback to fetch paginated data. */\n apiCallback: (\n params: { startIndex: number; endIndex: number; id: string },\n options: { takeLatestAction: boolean }\n ) => void;\n /** Indicates if data is currently being fetched. */\n isDataFetching: boolean;\n /** Range of data that is already loaded. */\n loadedDataRange: LoadedDataRange;\n /** Default height for items if not measured. */\n defaultItemHeight?: number;\n /** Total number of items in the list. */\n totalItemCount?: number | null;\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 /** Function to render the header. */\n headerRenderer?: (() => ReactNode) | null;\n /** Function to render the footer. */\n footerRenderer?: (() => ReactNode) | null;\n /** Function to render the no-result state. */\n noResultRenderer?: (() => ReactNode) | null;\n /** CSS class for the item container. */\n itemContainerClass?: string;\n /** Maximum height for the view container. */\n viewMaxHeight?: string | number | null;\n /** Minimum height for the view container. */\n minHeight?: string | number;\n /** Minimum height when no items are rendered. */\n minHeightWhenNoItemsRendered?: string;\n}\n\ninterface VirtualizerRef {\n /** Scrolls the parent container to the top. */\n scrollToTop: () => void;\n /** Returns the parent container element. */\n getParentContainer: () => HTMLElement | null;\n /** Returns the buffer container element. */\n getBufferContainer: () => HTMLElement | null;\n /** Triggers a count change notification. */\n notifyCountChange: () => void;\n}\n\nconst StyledLoader = Styled.div<StyledLoaderProps>`\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 width: 100%;\n`;\n\n/**\n * Flow:\n * 1. First load/user scrolls/screen size change/column resize\n * 2. Calculate new pagination range based on scroll position or if view not filled\n * 3. Consumer executes API call to fetch new data\n * 4. New items are prepared and rendered\n * 5. Update cache of item heights\n * 6. Update buffer height\n * 7. Adjust itemContainer top\n * 8. Adjust scrollTop (if needed) to keep the items at same position visually\n */\n\n/**\n * VariableHeightVirtualizer is a React component that efficiently renders large lists with items of variable heights,\n * using virtualization techniques to minimize DOM nodes and improve performance.\n *\n * @param props - {@link VariableHeightVirtualizerProps}\n * @param ref - Forwarded ref exposing imperative APIs: scrollToTop, getParentContainer, getBufferContainer, notifyCountChange.\n *\n * @example\n * ```tsx\n * <VariableHeightVirtualizer\n * id=\"my-list\"\n * totalItemCount={10000}\n * loadedDataRange={{ startIndex: 0, endIndex: 49 }}\n * isDataFetching={isLoading}\n * apiCallback={fetchData}\n * defaultItemHeight={40}\n * buffer={10}\n * headerRenderer={() => <Header />}\n * footerRenderer={() => <Footer />}\n * noResultRenderer={() => <NoResults />}\n * >\n * {items.map(item => <ListItem key={item.id} {...item} />)}\n * </VariableHeightVirtualizer>\n * ```\n */\nconst VariableHeightVirtualizer = forwardRef<VirtualizerRef, VariableHeightVirtualizerProps>(\n (\n {\n id,\n children,\n buffer = 15,\n apiCallback,\n loadedDataRange = {},\n defaultItemHeight = 30,\n totalItemCount,\n maxItemsToPaint = 5000,\n headerRenderer = null,\n footerRenderer = null,\n noResultRenderer = null,\n itemContainerClass = '',\n viewMaxHeight = null,\n minHeight = 'auto',\n isDataFetching = false,\n minHeightWhenNoItemsRendered = 'auto'\n },\n ref: ForwardedRef<VirtualizerRef>\n ) => {\n const [startIndex, setStartIndex] = useState<number>(0);\n const [endIndex, setEndIndex] = useState<number>(0);\n const [scrollTop, setScrollTop] = useState<number>(0);\n const [totalBufferHeight, setTotalBufferHeight] = useState<number>(0);\n const [itemsHeight, setItemsHeight] = useState<ItemsHeight>({});\n const [itemContainerHeight, setItemContainerHeight] = useState<number>(0);\n\n const [countChangeTrigger, setCountChangeTrigger] = useState<number>(0);\n const [itemHeightChangeTrigger, setItemHeightChangeTrigger] = useState<number>(0);\n const [parentContainerDimensionChangeTrigger, setParentContainerDimensionChangeTrigger] =\n useState<number>(0);\n\n const parentContainerRef = useRef<HTMLDivElement>(null);\n const bufferContainerRef = useRef<HTMLDivElement>(null);\n const itemContainerRef = useRef<HTMLDivElement>(null);\n const previousItemsHeightRef = useRef<ItemsHeight>({});\n const previousFirstItemDataIndexRef = useRef<number | null>(null);\n\n const [translate] = useTranslate();\n\n const onParentContainerDimensionUpdate = useCallback(() => {\n const { height: parentContainerHeight, width: parentContainerWidth } =\n parentContainerRef.current?.getBoundingClientRect() ?? {};\n // trigger virtualizer operations only when the container has some height and width\n if (parentContainerHeight && parentContainerWidth) {\n setParentContainerDimensionChangeTrigger(value => value + 1);\n }\n }, []);\n\n const getParentContainer = useCallback(\n (): HTMLDivElement | null => parentContainerRef.current,\n []\n );\n useResizeObserver(getParentContainer, onParentContainerDimensionUpdate);\n\n const { isInfiniteMode, virtualizedCount } = useVirtualizerItemCount({\n totalItemCount,\n startIndex,\n endIndex,\n loadedDataRange,\n isDataFetching,\n itemContainerRef,\n children,\n buffer,\n countResetSignal: countChangeTrigger\n });\n\n const { triggerPagination, isForceRefreshedPagination } = 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 });\n\n // Listens to the scroll events and trigger pagination when more records are needed to enable smooth scrolling\n useScroll({\n parentContainerRef,\n itemContainerRef,\n onThresholdBreach: (sTop: number) => {\n setScrollTop(sTop);\n triggerPagination(sTop);\n },\n delay: 150\n });\n\n // Expose APIs to the consumer\n useImperativeHandle(\n ref,\n (): VirtualizerRef => ({\n scrollToTop: () => {\n if (parentContainerRef.current) {\n parentContainerRef.current.scrollTop = 0;\n setScrollTop(0);\n\n triggerPagination(0, true);\n }\n },\n getParentContainer: () => parentContainerRef.current,\n getBufferContainer: () => itemContainerRef.current,\n notifyCountChange: () => setCountChangeTrigger(value => value + 1)\n })\n );\n\n // Measure height of rendered items and cache the heights\n useLayoutEffect(() => {\n if (!itemContainerRef.current) return;\n\n const newHeights = getChangedItemsHeight(\n itemContainerRef.current,\n itemsHeight,\n defaultItemHeight\n );\n if (Object.keys(newHeights).length > 0) {\n setItemsHeight((prev: ItemsHeight) => ({ ...prev, ...newHeights }));\n }\n }, [\n startIndex,\n itemsHeight,\n children,\n isDataFetching,\n defaultItemHeight,\n itemHeightChangeTrigger\n ]);\n\n // buffer height calculation\n useLayoutEffect(() => {\n const newBufferHeight = calculateTotalBufferHeight(\n virtualizedCount,\n itemsHeight,\n defaultItemHeight\n );\n\n if (newBufferHeight !== totalBufferHeight) {\n setTotalBufferHeight(newBufferHeight);\n }\n }, [itemsHeight, virtualizedCount, defaultItemHeight, totalBufferHeight]);\n\n // itemContainer size and position adjustments\n useLayoutEffect(() => {\n if (!itemContainerRef.current) return;\n\n setItemContainerHeight(\n updateItemPositionStyles(itemContainerRef.current, itemsHeight, defaultItemHeight)\n );\n }, [children, itemsHeight, defaultItemHeight]);\n\n // scroll position adjustment if rendered height is different than estimated height\n useLayoutEffect(() => {\n if (!parentContainerRef.current) return;\n\n const atTop = parentContainerRef.current.scrollTop === 0;\n if (!atTop) {\n const delta = calculateCumulativeItemSizeChange(\n startIndex,\n previousFirstItemDataIndexRef.current,\n itemsHeight,\n previousItemsHeightRef.current,\n defaultItemHeight\n );\n\n if (delta !== 0) {\n parentContainerRef.current.scrollTop += delta;\n }\n }\n\n previousItemsHeightRef.current = { ...itemsHeight };\n }, [startIndex, itemsHeight, defaultItemHeight]);\n\n // Adjust loader positions\n useLoaderPositioning({\n isDataFetching,\n parentContainerRef,\n itemContainerRef,\n children,\n itemsHeight,\n defaultItemHeight\n });\n\n // Initial pagination trigger and subsequent triggers if the view is not completely filled\n useEffect(() => {\n // If consumer already has data for initial items, then no need to trigger pagination. Just hydrate the internal state in sync with existing data.\n if (\n !endIndex &&\n loadedDataRange.startIndex !== undefined &&\n loadedDataRange.startIndex >= 0 &&\n loadedDataRange.endIndex !== undefined &&\n loadedDataRange.endIndex >= 0\n ) {\n setStartIndex(loadedDataRange.startIndex);\n setEndIndex(loadedDataRange.endIndex);\n return;\n }\n\n // If the consumer doesn't have data or view not filled then trigger pagination\n if (\n !isDataFetching &&\n (!endIndex ||\n (itemContainerRef.current &&\n parentContainerRef.current &&\n isViewNotFilled(\n virtualizedCount,\n itemContainerRef.current,\n parentContainerRef.current,\n !!headerRenderer\n )))\n ) {\n triggerPagination(scrollTop);\n }\n }, [\n loadedDataRange,\n scrollTop,\n virtualizedCount,\n endIndex,\n triggerPagination,\n parentContainerDimensionChangeTrigger,\n isDataFetching,\n headerRenderer\n ]);\n\n // Resize observer on items to track height changes\n const onItemsHeightUpdate = useCallback(() => {\n setItemHeightChangeTrigger(value => value + 1);\n }, []);\n useChildrenHeightResizeObserver({\n childrenContainerRef: itemContainerRef,\n children,\n itemsHeight,\n defaultItemHeight,\n onItemsHeightUpdate\n });\n\n const maxHeight = useMemo((): string => getMaxHeight(viewMaxHeight), [viewMaxHeight]);\n\n return (\n <div\n ref={parentContainerRef}\n style={{\n maxHeight,\n minHeight: virtualizedCount === 0 ? minHeightWhenNoItemsRendered : minHeight,\n overflowY: 'auto',\n position: 'relative',\n width: '100%'\n }}\n className='pContainer variableHeightVirtualizer'\n data-total-records={totalItemCount}\n >\n {headerRenderer && headerRenderer()}\n <div\n className='bContainer'\n ref={bufferContainerRef}\n style={{ height: totalBufferHeight, position: 'relative' }}\n >\n {isDataFetching && !isForceRefreshedPagination && (\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\n <div\n ref={itemContainerRef}\n style={{\n position: 'absolute',\n left: 0,\n width: '100%',\n height: `${itemContainerHeight}px`\n }}\n className={`${itemContainerClass} row-container`}\n >\n {children}\n </div>\n\n {isDataFetching && !isForceRefreshedPagination && (\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 {virtualizedCount === 0 && !isDataFetching && noResultRenderer ? noResultRenderer() : null}\n {footerRenderer && footerRenderer()}\n </div>\n );\n }\n);\n\nVariableHeightVirtualizer.displayName = 'VariableHeightVirtualizer';\n\nexport default VariableHeightVirtualizer;\n"]}
|
|
1
|
+
{"version":3,"file":"VariableHeightVirtualizer.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,SAAS,EACT,QAAQ,EACR,WAAW,EACX,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,OAAO,EACR,MAAM,OAAO,CAAC;AAEf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,YAAY,MAAM,6BAA6B,CAAC;AAEvD,OAAO,+BAA+B,MAAM,mCAAmC,CAAC;AAChF,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,iCAAiC,EACjC,YAAY,EACZ,eAAe,EACf,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAmEjB,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAmB;;;;;;UAMxC,KAAK,CAAC,EAAE,CAAC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AAI;yBACnC,EACD,SAAS,EAAE,GAAG,kBAAkB,gBAAgB,YAE/C,QAAQ,GACL,EAEL,cAAc,IAAI,CAAC,0BAA0B,IAAI,CAChD,KAAC,YAAY,cACH;4BACN,GAAG,EAAE,oBAAoB;4BACzB,IAAI,EAAE,eAAe;yBACtB,YAED,KAAC,QAAQ,IACP,SAAS,EAAC,cAAc,EACxB,SAAS,EAAC,OAAO,EACjB,QAAQ,EAAE,CAAC,gBACC,SAAS,CAAC,sBAAsB,CAAC,GAC7C,GACW,CAChB,IACG,EACL,gBAAgB,KAAK,CAAC,IAAI,CAAC,cAAc,IAAI,kBAAkB;gBAC9D,CAAC,CAAC,kBAAkB,EAAE;gBACtB,CAAC,CAAC,IAAI,EACP,YAAY,IAAI,YAAY,EAAE,IAC3B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,yBAAyB,CAAC,WAAW,GAAG,2BAA2B,CAAC;AAEpE,eAAe,yBAAyB,CAAC","sourcesContent":["import {\n useRef,\n useEffect,\n useState,\n useCallback,\n useLayoutEffect,\n forwardRef,\n useImperativeHandle,\n useMemo\n} from 'react';\nimport type { ReactNode, ForwardedRef } from 'react';\nimport Styled from 'styled-components';\n\nimport { Progress } from '@pega/cosmos-react-core';\n\nimport useResizeObserver from '../UseResizeObserver';\nimport useTranslate from '../../../Hooks/useTranslate';\n\nimport useChildrenHeightResizeObserver from './useChildrenHeightResizeObserver';\nimport useLoaderPositioning from './useLoaderPositioning';\nimport usePagination from './usePagination';\nimport useScroll from './useScroll';\nimport useVirtualizerItemCount from './useVirtualizerItemCount';\nimport {\n calculateCumulativeItemSizeChange,\n getMaxHeight,\n isViewNotFilled,\n calculateTotalBufferHeight,\n getChangedItemsHeight,\n updateItemPositionStyles\n} from './utils';\n\nexport interface ItemsHeight {\n [index: number]: number;\n}\n\nexport interface LoadedDataRange {\n startIndex?: number;\n endIndex?: number;\n}\n\ninterface StyledLoaderProps {\n $style: {\n top: string;\n left: string;\n };\n}\n\nexport interface VariableHeightVirtualizerProps {\n /** Unique identifier for the virtualizer instance. */\n id: string;\n /** The React children elements to render inside the virtualizer. */\n children: ReactNode;\n /** Callback to fetch paginated data. */\n apiCallback: (\n params: { startIndex: number; endIndex: number; id: string },\n options: { takeLatestAction: boolean }\n ) => void;\n /** Indicates if data is currently being fetched. */\n isDataFetching: boolean;\n /** Range of data that is already loaded. */\n loadedDataRange: LoadedDataRange;\n /** Default height for items if not measured. */\n defaultItemHeight?: number;\n /** Total number of items in the list. */\n totalItemCount?: number | null;\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 /** Function to render the header. */\n renderHeader?: (() => ReactNode) | null;\n /** Function to render the footer. */\n renderFooter?: (() => ReactNode) | null;\n /** Function to render the no-result state. */\n renderEmptyRecords?: (() => ReactNode) | null;\n /** CSS class for the item container. */\n itemContainerClass?: string;\n /** Maximum height for the view container. */\n viewMaxHeight?: string | number | null;\n /** Minimum height for the view container. */\n minHeight?: string | number;\n /** Minimum height when no items are rendered. */\n minHeightWhenNoItemsRendered?: string;\n}\n\ninterface VirtualizerRef {\n /** Scrolls the parent container to the top. */\n scrollToTop: () => void;\n /** Returns the parent container element. */\n getParentContainer: () => HTMLElement | null;\n /** Returns the buffer container element. */\n getBufferContainer: () => HTMLElement | null;\n /** Triggers a count change notification. */\n notifyCountChange: () => void;\n}\n\nconst StyledLoader = Styled.div<StyledLoaderProps>`\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 width: 100%;\n`;\n\n/**\n * Flow:\n * 1. First load/user scrolls/screen size change/column resize\n * 2. Calculate new pagination range based on scroll position or if view not filled\n * 3. Consumer executes API call to fetch new data\n * 4. New items are prepared and rendered\n * 5. Update cache of item heights\n * 6. Update buffer height\n * 7. Adjust itemContainer top\n * 8. Adjust scrollTop (if needed) to keep the items at same position visually\n */\n\n/**\n * VariableHeightVirtualizer is a React component that efficiently renders large lists with items of variable heights,\n * using virtualization techniques to minimize DOM nodes and improve performance.\n *\n * @param props - {@link VariableHeightVirtualizerProps}\n * @param ref - Forwarded ref exposing imperative APIs: scrollToTop, getParentContainer, getBufferContainer, notifyCountChange.\n *\n * @example\n * ```tsx\n * <VariableHeightVirtualizer\n * id=\"my-list\"\n * totalItemCount={10000}\n * loadedDataRange={{ startIndex: 0, endIndex: 49 }}\n * isDataFetching={isLoading}\n * apiCallback={fetchData}\n * defaultItemHeight={40}\n * buffer={10}\n * renderHeader={() => <Header />}\n * renderFooter={() => <Footer />}\n * renderEmptyRecords={() => <NoResults />}\n * >\n * {items.map(item => <ListItem key={item.id} {...item} />)}\n * </VariableHeightVirtualizer>\n * ```\n */\nconst VariableHeightVirtualizer = forwardRef<VirtualizerRef, VariableHeightVirtualizerProps>(\n (\n {\n id,\n children,\n buffer = 15,\n apiCallback,\n loadedDataRange = {},\n defaultItemHeight = 30,\n totalItemCount,\n maxItemsToPaint = 5000,\n renderHeader = null,\n renderFooter = null,\n renderEmptyRecords = null,\n itemContainerClass = '',\n viewMaxHeight = null,\n minHeight = 'auto',\n isDataFetching = false,\n minHeightWhenNoItemsRendered = 'auto'\n },\n ref: ForwardedRef<VirtualizerRef>\n ) => {\n const [startIndex, setStartIndex] = useState<number>(0);\n const [endIndex, setEndIndex] = useState<number>(0);\n const [scrollTop, setScrollTop] = useState<number>(0);\n const [totalBufferHeight, setTotalBufferHeight] = useState<number>(0);\n const [itemsHeight, setItemsHeight] = useState<ItemsHeight>({});\n const [itemContainerHeight, setItemContainerHeight] = useState<number>(0);\n\n const [countChangeTrigger, setCountChangeTrigger] = useState<number>(0);\n const [itemHeightChangeTrigger, setItemHeightChangeTrigger] = useState<number>(0);\n const [parentContainerDimensionChangeTrigger, setParentContainerDimensionChangeTrigger] =\n useState<number>(0);\n\n const parentContainerRef = useRef<HTMLDivElement>(null);\n const bufferContainerRef = useRef<HTMLDivElement>(null);\n const itemContainerRef = useRef<HTMLDivElement>(null);\n const previousItemsHeightRef = useRef<ItemsHeight>({});\n const previousFirstItemDataIndexRef = useRef<number | null>(null);\n\n const [translate] = useTranslate();\n\n const onParentContainerDimensionUpdate = useCallback(() => {\n const { height: parentContainerHeight, width: parentContainerWidth } =\n parentContainerRef.current?.getBoundingClientRect() ?? {};\n // trigger virtualizer operations only when the container has some height and width\n if (parentContainerHeight && parentContainerWidth) {\n setParentContainerDimensionChangeTrigger(value => value + 1);\n }\n }, []);\n\n const getParentContainer = useCallback(\n (): HTMLDivElement | null => parentContainerRef.current,\n []\n );\n useResizeObserver(getParentContainer, onParentContainerDimensionUpdate);\n\n const { isInfiniteMode, virtualizedCount } = useVirtualizerItemCount({\n totalItemCount,\n startIndex,\n endIndex,\n loadedDataRange,\n isDataFetching,\n itemContainerRef,\n children,\n buffer,\n countResetSignal: countChangeTrigger\n });\n\n const { triggerPagination, isForceRefreshedPagination } = 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 });\n\n // Listens to the scroll events and trigger pagination when more records are needed to enable smooth scrolling\n useScroll({\n parentContainerRef,\n itemContainerRef,\n onThresholdBreach: (sTop: number) => {\n setScrollTop(sTop);\n triggerPagination(sTop);\n },\n delay: 150\n });\n\n // Expose APIs to the consumer\n useImperativeHandle(\n ref,\n (): VirtualizerRef => ({\n scrollToTop: () => {\n if (parentContainerRef.current) {\n parentContainerRef.current.scrollTop = 0;\n setScrollTop(0);\n\n triggerPagination(0, true);\n }\n },\n getParentContainer: () => parentContainerRef.current,\n getBufferContainer: () => itemContainerRef.current,\n notifyCountChange: () => setCountChangeTrigger(value => value + 1)\n })\n );\n\n // Measure height of rendered items and cache the heights\n useLayoutEffect(() => {\n if (!itemContainerRef.current) return;\n\n const newHeights = getChangedItemsHeight(\n itemContainerRef.current,\n itemsHeight,\n defaultItemHeight\n );\n if (Object.keys(newHeights).length > 0) {\n setItemsHeight((prev: ItemsHeight) => ({ ...prev, ...newHeights }));\n }\n }, [\n startIndex,\n itemsHeight,\n children,\n isDataFetching,\n defaultItemHeight,\n itemHeightChangeTrigger\n ]);\n\n // buffer height calculation\n useLayoutEffect(() => {\n const newBufferHeight = calculateTotalBufferHeight(\n virtualizedCount,\n itemsHeight,\n defaultItemHeight\n );\n\n if (newBufferHeight !== totalBufferHeight) {\n setTotalBufferHeight(newBufferHeight);\n }\n }, [itemsHeight, virtualizedCount, defaultItemHeight, totalBufferHeight]);\n\n // itemContainer size and position adjustments\n useLayoutEffect(() => {\n if (!itemContainerRef.current) return;\n\n setItemContainerHeight(\n updateItemPositionStyles(itemContainerRef.current, itemsHeight, defaultItemHeight)\n );\n }, [children, itemsHeight, defaultItemHeight]);\n\n // scroll position adjustment if rendered height is different than estimated height\n useLayoutEffect(() => {\n if (!parentContainerRef.current) return;\n\n const atTop = parentContainerRef.current.scrollTop === 0;\n if (!atTop) {\n const delta = calculateCumulativeItemSizeChange(\n startIndex,\n previousFirstItemDataIndexRef.current,\n itemsHeight,\n previousItemsHeightRef.current,\n defaultItemHeight\n );\n\n if (delta !== 0) {\n parentContainerRef.current.scrollTop += delta;\n }\n }\n\n previousItemsHeightRef.current = { ...itemsHeight };\n }, [startIndex, itemsHeight, defaultItemHeight]);\n\n // Adjust loader positions\n useLoaderPositioning({\n isDataFetching,\n parentContainerRef,\n itemContainerRef,\n children,\n itemsHeight,\n defaultItemHeight\n });\n\n // Initial pagination trigger and subsequent triggers if the view is not completely filled\n useEffect(() => {\n // If consumer already has data for initial items, then no need to trigger pagination. Just hydrate the internal state in sync with existing data.\n if (\n !endIndex &&\n loadedDataRange.startIndex !== undefined &&\n loadedDataRange.startIndex >= 0 &&\n loadedDataRange.endIndex !== undefined &&\n loadedDataRange.endIndex >= 0\n ) {\n setStartIndex(loadedDataRange.startIndex);\n setEndIndex(loadedDataRange.endIndex);\n return;\n }\n\n // If the consumer doesn't have data or view not filled then trigger pagination\n if (\n !isDataFetching &&\n (!endIndex ||\n (itemContainerRef.current &&\n parentContainerRef.current &&\n isViewNotFilled(\n virtualizedCount,\n itemContainerRef.current,\n parentContainerRef.current,\n !!renderHeader\n )))\n ) {\n triggerPagination(scrollTop);\n }\n }, [\n loadedDataRange,\n scrollTop,\n virtualizedCount,\n endIndex,\n triggerPagination,\n parentContainerDimensionChangeTrigger,\n isDataFetching,\n renderHeader\n ]);\n\n // Resize observer on items to track height changes\n const onItemsHeightUpdate = useCallback(() => {\n setItemHeightChangeTrigger(value => value + 1);\n }, []);\n useChildrenHeightResizeObserver({\n childrenContainerRef: itemContainerRef,\n children,\n itemsHeight,\n defaultItemHeight,\n onItemsHeightUpdate\n });\n\n const maxHeight = useMemo((): string => getMaxHeight(viewMaxHeight), [viewMaxHeight]);\n\n return (\n <div\n ref={parentContainerRef}\n style={{\n maxHeight,\n minHeight: virtualizedCount === 0 ? minHeightWhenNoItemsRendered : minHeight,\n overflowY: 'auto',\n position: 'relative',\n width: '100%'\n }}\n className='pContainer variableHeightVirtualizer'\n data-total-records={totalItemCount}\n >\n {renderHeader && renderHeader()}\n <div\n className='bContainer'\n ref={bufferContainerRef}\n style={{ height: totalBufferHeight, position: 'relative' }}\n >\n {isDataFetching && !isForceRefreshedPagination && (\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\n <div\n ref={itemContainerRef}\n style={{\n position: 'absolute',\n left: 0,\n width: '100%',\n height: `${itemContainerHeight}px`\n }}\n className={`${itemContainerClass} row-container`}\n >\n {children}\n </div>\n\n {isDataFetching && !isForceRefreshedPagination && (\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 {virtualizedCount === 0 && !isDataFetching && renderEmptyRecords\n ? renderEmptyRecords()\n : null}\n {renderFooter && renderFooter()}\n </div>\n );\n }\n);\n\nVariableHeightVirtualizer.displayName = 'VariableHeightVirtualizer';\n\nexport default VariableHeightVirtualizer;\n"]}
|
|
@@ -4,7 +4,6 @@ import Styled from 'styled-components';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { defaultThemeProp, Progress } from '@pega/cosmos-react-core';
|
|
6
6
|
import { isEmpty } from 'pega-repeating-structures-core';
|
|
7
|
-
import EmptyContainer from '../DefaultComponents/EmptyContainer';
|
|
8
7
|
import useTranslate from '../../Hooks/useTranslate';
|
|
9
8
|
import { StyledSkeletonRow } from '../../Views/Table/SkeletonRows';
|
|
10
9
|
import getPaginationInfo from './Pagination';
|
|
@@ -43,7 +42,7 @@ const StyledLoader = Styled.div `
|
|
|
43
42
|
top: ${props => props.$style.top};
|
|
44
43
|
bottom: ${props => props.$style.bottom};
|
|
45
44
|
`;
|
|
46
|
-
const VirtualizeInfinite = forwardRef(({ id, viewHeight, viewWidth, itemHeight, callback, rowContainerClass, children, renderHeader, renderFooter, state, bufferMultiplier, viewMaxHeight, showLoadingIndicator, resetCount, countUpdateCallback, isFetching, hasMoreResults }, inputRef) => {
|
|
45
|
+
const VirtualizeInfinite = forwardRef(({ id, viewHeight, viewWidth, itemHeight, callback, rowContainerClass, children, renderHeader, renderFooter, state, bufferMultiplier, viewMaxHeight, showLoadingIndicator, resetCount, countUpdateCallback, isFetching, hasMoreResults, renderEmptyRecords }, inputRef) => {
|
|
47
46
|
const rowBuffer = 5;
|
|
48
47
|
const [rContainerDimensionUpdate, setRContainerDimensionUpdate] = useState();
|
|
49
48
|
const [loadingIndicatorInfo, setLoadingIndicatorInfo] = useState({});
|
|
@@ -261,7 +260,9 @@ const VirtualizeInfinite = forwardRef(({ id, viewHeight, viewWidth, itemHeight,
|
|
|
261
260
|
vi.bContainer = c;
|
|
262
261
|
}, children: _jsxs("div", { className: `${rowContainerClass} row-container`, ref: c => {
|
|
263
262
|
vi.rContainer = c;
|
|
264
|
-
}, role: 'rowgroup', children: [showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingUp && (_jsx(StyledLoader, { "$style": { bottom: '100%' }, children: _jsx(Progress, { className: 'above-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) })), children, showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (_jsx(StyledLoader, { "$style": { top: '100%' }, children: _jsx(Progress, { className: 'below-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) }))] }) }), vi.totalRowsLoaded === 0 && !isFetching
|
|
263
|
+
}, role: 'rowgroup', children: [showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingUp && (_jsx(StyledLoader, { "$style": { bottom: '100%' }, children: _jsx(Progress, { className: 'above-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) })), children, showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (_jsx(StyledLoader, { "$style": { top: '100%' }, children: _jsx(Progress, { className: 'below-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) }))] }) }), vi.totalRowsLoaded === 0 && !isFetching
|
|
264
|
+
? renderEmptyRecords && renderEmptyRecords()
|
|
265
|
+
: null, renderFooter && renderFooter()] }));
|
|
265
266
|
});
|
|
266
267
|
VirtualizeInfinite.propTypes = {
|
|
267
268
|
id: PropTypes.string.isRequired,
|
|
@@ -283,7 +284,8 @@ VirtualizeInfinite.propTypes = {
|
|
|
283
284
|
viewMaxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
284
285
|
showLoadingIndicator: PropTypes.bool,
|
|
285
286
|
resetCount: PropTypes.bool,
|
|
286
|
-
countUpdateCallback: PropTypes.func
|
|
287
|
+
countUpdateCallback: PropTypes.func,
|
|
288
|
+
renderEmptyRecords: PropTypes.func
|
|
287
289
|
};
|
|
288
290
|
VirtualizeInfinite.defaultProps = {
|
|
289
291
|
bufferMultiplier: 2,
|
|
@@ -299,7 +301,8 @@ VirtualizeInfinite.defaultProps = {
|
|
|
299
301
|
viewMaxHeight: undefined,
|
|
300
302
|
showLoadingIndicator: false,
|
|
301
303
|
resetCount: false,
|
|
302
|
-
countUpdateCallback: () => { }
|
|
304
|
+
countUpdateCallback: () => { },
|
|
305
|
+
renderEmptyRecords: null
|
|
303
306
|
};
|
|
304
307
|
VirtualizeInfinite.displayName = 'VirtualizeInfinite';
|
|
305
308
|
export default memo(VirtualizeInfinite);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualizeInfinite.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/VirtualizeInfinite.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,4BAA4B,EAC5B,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,iBAAiB,MAAM,q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U,EAAE,EAAE;IACd,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,SAAS;IAChB,aAAa,EAAE,SAAS;IACxB,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE,KAAK;IACjB,mBAAmB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC9B,CAAC;AAEF,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAC;AAEtD,eAAe,IAAI,CAAC,kBAAkB,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 getRecordCountForLayoutPaint,\n getValueWithUnit,\n getMaxHeight,\n isViewNotFilled,\n setAttributesOnItems,\n updateRowContainerTop\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 border-radius: inherit;\n\n &:has(${StyledSkeletonRow}) {\n overflow: hidden;\n }\n\n .bContainer {\n position: relative;\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 top: ${props => props.$style.top};\n bottom: ${props => props.$style.bottom};\n`;\n\nconst VirtualizeInfinite = forwardRef(\n (\n {\n id,\n viewHeight,\n viewWidth,\n itemHeight,\n callback,\n rowContainerClass,\n children,\n renderHeader,\n renderFooter,\n state,\n bufferMultiplier,\n viewMaxHeight,\n showLoadingIndicator,\n resetCount,\n countUpdateCallback,\n isFetching,\n hasMoreResults\n },\n inputRef\n ) => {\n const rowBuffer = 5;\n\n const [rContainerDimensionUpdate, setRContainerDimensionUpdate] = useState();\n const [loadingIndicatorInfo, setLoadingIndicatorInfo] = useState({});\n const [translate] = useTranslate();\n\n // Create ref to store virtualize related data.\n const vi = useRef({\n itemHeight,\n bufferMultiplier,\n pInfo: {},\n totalRowsLoaded: undefined,\n isInitialized: false\n }).current;\n\n // tracking both state and pInfo.view to identify the initialization as in case of fullscreen, state will be available but pInfo.view won't\n const isInitialized = state && !!Object.keys(vi.pInfo.view ?? {}).length;\n\n const getTotalRowsIncludingBuffer = useCallback(() => {\n if (isEmpty(vi.totalRowsLoaded)) return;\n return hasMoreResults ? vi.totalRowsLoaded + rowBuffer : vi.totalRowsLoaded;\n }, [vi.totalRowsLoaded, hasMoreResults]);\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 (!isInitialized) return;\n getPContainer().scrollTop = 0;\n vi.pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()),\n vi,\n false,\n true\n );\n callback({ ...vi.pInfo.view, id }, { takeLatestAction: true });\n }, [id, vi, getPContainer, callback, isInitialized]);\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 // 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 resting isFetch to false\n // goes to this method when callback is note fired.\n const getPagination = useCallback(\n (isRefresh = false, resetIsFetchingWhenNoNewIndexes = false) => {\n if (!isFetching || resetIsFetchingWhenNoNewIndexes) {\n const pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()),\n vi,\n isRefresh,\n true\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 (\n isRefresh ||\n !state ||\n !(startIndex >= state.startIndex && endIndex <= state.endIndex)\n ) {\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\n callback({ ...vi.pInfo.view, id });\n } else if (resetIsFetchingWhenNoNewIndexes) {\n setLoadingIndicatorInfo({});\n }\n }\n },\n [isFetching, getPContainer, getTotalRowsIncludingBuffer, vi, state, callback, id]\n );\n\n // update average stats for next calculation.\n const updateAvarageInVirtualizeInstance = 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 =\n (getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()) / itemCount) *\n rowContainerHeight;\n return h;\n },\n [getTotalRowsIncludingBuffer]\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 useResizeObserver(getRowContainer, onRowContainerDimensionChange);\n\n const [updateScrollTop] = useScroll(\n getPagination,\n getPContainer,\n vi,\n getTotalRowsIncludingBuffer(),\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 useLayoutEffect(() => {\n if (isFetching || !isInitialized) return;\n\n const rowElements = Array.from(getRowContainer().children || []).filter(a =>\n a.hasAttribute('data-key')\n );\n if (!rowElements.length) {\n vi.totalRowsLoaded = 0;\n return;\n }\n\n const lastRow = rowElements[rowElements.length - 1];\n const lastRowDataIndex = parseInt(lastRow.getAttribute('data-index'), 10);\n const newCount = hasMoreResults ? lastRowDataIndex + 1 + rowBuffer : lastRowDataIndex + 1;\n\n // if user is scrolling up/down within the already encountered records, the record count shouldn't update\n if (newCount < getTotalRowsIncludingBuffer() && !resetCount) return;\n\n vi.totalRowsLoaded = lastRowDataIndex + 1;\n countUpdateCallback(vi.totalRowsLoaded);\n }, [children, isFetching]);\n\n // Get estimate and update buffer height\n useLayoutEffect(() => {\n if (!isInitialized) return;\n\n vi.currentEstimation = getCurrentEstimation(getRowContainer(), true);\n updateAvarageInVirtualizeInstance(vi.currentEstimation);\n const h = getBufferHeight(vi.currentEstimation);\n getBContainer().style.height = `${h}px`;\n }, [\n vi,\n children,\n rContainerDimensionUpdate,\n getBContainer,\n getBufferHeight,\n getRowContainer,\n getTotalRowsIncludingBuffer,\n updateAvarageInVirtualizeInstance\n ]);\n\n useLayoutEffect(() => {\n if (isFetching || !isInitialized) return;\n\n const pContainer = getPContainer();\n const scrollTop = getScrollTop(vi.currentEstimation);\n if (vi.pInfo.view.startIndex !== 0) pContainer.scrollTop = scrollTop;\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(getTotalRowsIncludingBuffer()),\n state,\n pContainer,\n pContainer.scrollTop\n );\n }, [\n vi,\n state,\n isFetching,\n getScrollTop,\n getPContainer,\n updateScrollTop,\n getTotalRowsIncludingBuffer\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 (isFetching) return;\n\n if (!isInitialized) {\n getPagination(true);\n return;\n }\n\n if (\n isViewNotFilled(\n getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()),\n vi,\n getPContainer(),\n renderHeader\n )\n ) {\n getPagination(false, true);\n } else {\n setLoadingIndicatorInfo({});\n }\n }, [\n vi,\n isFetching,\n children,\n viewWidth,\n viewHeight,\n renderHeader,\n rContainerDimensionUpdate,\n getPagination,\n getPContainer,\n getTotalRowsIncludingBuffer\n ]);\n\n return (\n <StyledPContainer\n $style={{\n maxHeight,\n minHeight: vi.totalRowsLoaded === 0 ? '100px' : 'auto',\n renderFooter,\n itemHeight,\n height,\n width\n }}\n data-total-records={vi.totalRowsLoaded}\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 <div\n className={`${rowContainerClass} row-container`}\n ref={c => {\n vi.rContainer = c;\n }}\n role='rowgroup'\n >\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingUp && (\n <StyledLoader $style={{ bottom: '100%' }}>\n <Progress\n className='above-loader'\n placement='block'\n tabIndex={0}\n aria-label={translate('Loading more results')}\n />\n </StyledLoader>\n )}\n {children}\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (\n <StyledLoader $style={{ top: '100%' }}>\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 </div>\n {vi.totalRowsLoaded === 0 && !isFetching ? <EmptyContainer /> : null}\n {renderFooter && renderFooter()}\n </StyledPContainer>\n );\n }\n);\n\nVirtualizeInfinite.propTypes = {\n id: PropTypes.string.isRequired,\n viewHeight: PropTypes.number,\n viewWidth: PropTypes.number,\n itemHeight: PropTypes.number,\n callback: PropTypes.func,\n isFetching: PropTypes.bool,\n hasMoreResults: 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 resetCount: PropTypes.bool,\n countUpdateCallback: PropTypes.func\n};\n\nVirtualizeInfinite.defaultProps = {\n bufferMultiplier: 2,\n callback: () => {},\n isFetching: false,\n hasMoreResults: false,\n rowContainerClass: '',\n viewWidth: 0,\n itemHeight: 40,\n renderHeader: null,\n renderFooter: null,\n state: undefined,\n viewMaxHeight: undefined,\n showLoadingIndicator: false,\n resetCount: false,\n countUpdateCallback: () => {}\n};\n\nVirtualizeInfinite.displayName = 'VirtualizeInfinite';\n\nexport default memo(VirtualizeInfinite);\n"]}
|
|
1
|
+
{"version":3,"file":"VirtualizeInfinite.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/VirtualizeInfinite.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,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,4BAA4B,EAC5B,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,SAAS,sBAAsB,CAAC,KAAK;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AE,CAAC;IACZ,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,SAAS;IAChB,aAAa,EAAE,SAAS;IACxB,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE,KAAK;IACjB,mBAAmB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC7B,kBAAkB,EAAE,IAAI;CACzB,CAAC;AAEF,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAC;AAEtD,eAAe,IAAI,CAAC,kBAAkB,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 useTranslate from '../../Hooks/useTranslate';\nimport { StyledSkeletonRow } from '../../Views/Table/SkeletonRows';\n\nimport getPaginationInfo from './Pagination';\nimport useScroll from './UseScroll';\nimport {\n getCurrentEstimation,\n getRecordCountForLayoutPaint,\n getValueWithUnit,\n getMaxHeight,\n isViewNotFilled,\n setAttributesOnItems,\n updateRowContainerTop\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 border-radius: inherit;\n\n &:has(${StyledSkeletonRow}) {\n overflow: hidden;\n }\n\n .bContainer {\n position: relative;\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 top: ${props => props.$style.top};\n bottom: ${props => props.$style.bottom};\n`;\n\nconst VirtualizeInfinite = forwardRef(\n (\n {\n id,\n viewHeight,\n viewWidth,\n itemHeight,\n callback,\n rowContainerClass,\n children,\n renderHeader,\n renderFooter,\n state,\n bufferMultiplier,\n viewMaxHeight,\n showLoadingIndicator,\n resetCount,\n countUpdateCallback,\n isFetching,\n hasMoreResults,\n renderEmptyRecords\n },\n inputRef\n ) => {\n const rowBuffer = 5;\n\n const [rContainerDimensionUpdate, setRContainerDimensionUpdate] = useState();\n const [loadingIndicatorInfo, setLoadingIndicatorInfo] = useState({});\n const [translate] = useTranslate();\n\n // Create ref to store virtualize related data.\n const vi = useRef({\n itemHeight,\n bufferMultiplier,\n pInfo: {},\n totalRowsLoaded: undefined,\n isInitialized: false\n }).current;\n\n // tracking both state and pInfo.view to identify the initialization as in case of fullscreen, state will be available but pInfo.view won't\n const isInitialized = state && !!Object.keys(vi.pInfo.view ?? {}).length;\n\n const getTotalRowsIncludingBuffer = useCallback(() => {\n if (isEmpty(vi.totalRowsLoaded)) return;\n return hasMoreResults ? vi.totalRowsLoaded + rowBuffer : vi.totalRowsLoaded;\n }, [vi.totalRowsLoaded, hasMoreResults]);\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 (!isInitialized) return;\n getPContainer().scrollTop = 0;\n vi.pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()),\n vi,\n false,\n true\n );\n callback({ ...vi.pInfo.view, id }, { takeLatestAction: true });\n }, [id, vi, getPContainer, callback, isInitialized]);\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 // 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 resting isFetch to false\n // goes to this method when callback is note fired.\n const getPagination = useCallback(\n (isRefresh = false, resetIsFetchingWhenNoNewIndexes = false) => {\n if (!isFetching || resetIsFetchingWhenNoNewIndexes) {\n const pInfo = getPaginationInfo(\n getPContainer(),\n getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()),\n vi,\n isRefresh,\n true\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 (\n isRefresh ||\n !state ||\n !(startIndex >= state.startIndex && endIndex <= state.endIndex)\n ) {\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\n callback({ ...vi.pInfo.view, id });\n } else if (resetIsFetchingWhenNoNewIndexes) {\n setLoadingIndicatorInfo({});\n }\n }\n },\n [isFetching, getPContainer, getTotalRowsIncludingBuffer, vi, state, callback, id]\n );\n\n // update average stats for next calculation.\n const updateAvarageInVirtualizeInstance = 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 =\n (getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()) / itemCount) *\n rowContainerHeight;\n return h;\n },\n [getTotalRowsIncludingBuffer]\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 useResizeObserver(getRowContainer, onRowContainerDimensionChange);\n\n const [updateScrollTop] = useScroll(\n getPagination,\n getPContainer,\n vi,\n getTotalRowsIncludingBuffer(),\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 useLayoutEffect(() => {\n if (isFetching || !isInitialized) return;\n\n const rowElements = Array.from(getRowContainer().children || []).filter(a =>\n a.hasAttribute('data-key')\n );\n if (!rowElements.length) {\n vi.totalRowsLoaded = 0;\n return;\n }\n\n const lastRow = rowElements[rowElements.length - 1];\n const lastRowDataIndex = parseInt(lastRow.getAttribute('data-index'), 10);\n const newCount = hasMoreResults ? lastRowDataIndex + 1 + rowBuffer : lastRowDataIndex + 1;\n\n // if user is scrolling up/down within the already encountered records, the record count shouldn't update\n if (newCount < getTotalRowsIncludingBuffer() && !resetCount) return;\n\n vi.totalRowsLoaded = lastRowDataIndex + 1;\n countUpdateCallback(vi.totalRowsLoaded);\n }, [children, isFetching]);\n\n // Get estimate and update buffer height\n useLayoutEffect(() => {\n if (!isInitialized) return;\n\n vi.currentEstimation = getCurrentEstimation(getRowContainer(), true);\n updateAvarageInVirtualizeInstance(vi.currentEstimation);\n const h = getBufferHeight(vi.currentEstimation);\n getBContainer().style.height = `${h}px`;\n }, [\n vi,\n children,\n rContainerDimensionUpdate,\n getBContainer,\n getBufferHeight,\n getRowContainer,\n getTotalRowsIncludingBuffer,\n updateAvarageInVirtualizeInstance\n ]);\n\n useLayoutEffect(() => {\n if (isFetching || !isInitialized) return;\n\n const pContainer = getPContainer();\n const scrollTop = getScrollTop(vi.currentEstimation);\n if (vi.pInfo.view.startIndex !== 0) pContainer.scrollTop = scrollTop;\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(getTotalRowsIncludingBuffer()),\n state,\n pContainer,\n pContainer.scrollTop\n );\n }, [\n vi,\n state,\n isFetching,\n getScrollTop,\n getPContainer,\n updateScrollTop,\n getTotalRowsIncludingBuffer\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 (isFetching) return;\n\n if (!isInitialized) {\n getPagination(true);\n return;\n }\n\n if (\n isViewNotFilled(\n getRecordCountForLayoutPaint(getTotalRowsIncludingBuffer()),\n vi,\n getPContainer(),\n renderHeader\n )\n ) {\n getPagination(false, true);\n } else {\n setLoadingIndicatorInfo({});\n }\n }, [\n vi,\n isFetching,\n children,\n viewWidth,\n viewHeight,\n renderHeader,\n rContainerDimensionUpdate,\n getPagination,\n getPContainer,\n getTotalRowsIncludingBuffer\n ]);\n\n return (\n <StyledPContainer\n $style={{\n maxHeight,\n minHeight: vi.totalRowsLoaded === 0 ? '100px' : 'auto',\n renderFooter,\n itemHeight,\n height,\n width\n }}\n data-total-records={vi.totalRowsLoaded}\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 <div\n className={`${rowContainerClass} row-container`}\n ref={c => {\n vi.rContainer = c;\n }}\n role='rowgroup'\n >\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingUp && (\n <StyledLoader $style={{ bottom: '100%' }}>\n <Progress\n className='above-loader'\n placement='block'\n tabIndex={0}\n aria-label={translate('Loading more results')}\n />\n </StyledLoader>\n )}\n {children}\n {showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (\n <StyledLoader $style={{ top: '100%' }}>\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 </div>\n {vi.totalRowsLoaded === 0 && !isFetching\n ? renderEmptyRecords && renderEmptyRecords()\n : null}\n {renderFooter && renderFooter()}\n </StyledPContainer>\n );\n }\n);\n\nVirtualizeInfinite.propTypes = {\n id: PropTypes.string.isRequired,\n viewHeight: PropTypes.number,\n viewWidth: PropTypes.number,\n itemHeight: PropTypes.number,\n callback: PropTypes.func,\n isFetching: PropTypes.bool,\n hasMoreResults: 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 resetCount: PropTypes.bool,\n countUpdateCallback: PropTypes.func,\n renderEmptyRecords: PropTypes.func\n};\n\nVirtualizeInfinite.defaultProps = {\n bufferMultiplier: 2,\n callback: () => {},\n isFetching: false,\n hasMoreResults: false,\n rowContainerClass: '',\n viewWidth: 0,\n itemHeight: 40,\n renderHeader: null,\n renderFooter: null,\n state: undefined,\n viewMaxHeight: undefined,\n showLoadingIndicator: false,\n resetCount: false,\n countUpdateCallback: () => {},\n renderEmptyRecords: null\n};\n\nVirtualizeInfinite.displayName = 'VirtualizeInfinite';\n\nexport default memo(VirtualizeInfinite);\n"]}
|
|
@@ -4,7 +4,6 @@ import Styled from 'styled-components';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { defaultThemeProp, Progress } from '@pega/cosmos-react-core';
|
|
6
6
|
import { isEmpty } from 'pega-repeating-structures-core';
|
|
7
|
-
import EmptyContainer from '../DefaultComponents/EmptyContainer';
|
|
8
7
|
import useTranslate from '../../Hooks/useTranslate';
|
|
9
8
|
import { StyledSkeletonRow } from '../../Views/Table/SkeletonRows';
|
|
10
9
|
import getPaginationInfo from './Pagination';
|
|
@@ -49,7 +48,7 @@ const StyledLoader = Styled.div `
|
|
|
49
48
|
left: ${props => `var(${props.$style.left})`};
|
|
50
49
|
top: ${props => `var(${props.$style.top})`};
|
|
51
50
|
`;
|
|
52
|
-
const Virtualize = forwardRef(({ id, viewHeight, viewWidth, totalRecordCount, itemHeight, callback, isFetching, rowContainerClass, children, renderHeader, renderFooter, state, bufferMultiplier, viewMaxHeight, showLoadingIndicator }, inputRef) => {
|
|
51
|
+
const Virtualize = forwardRef(({ id, viewHeight, viewWidth, totalRecordCount, itemHeight, callback, isFetching, rowContainerClass, children, renderHeader, renderFooter, state, bufferMultiplier, viewMaxHeight, showLoadingIndicator, renderEmptyRecords }, inputRef) => {
|
|
53
52
|
const [rContainerDimensionUpdate, setRContainerDimensionUpdate] = useState();
|
|
54
53
|
const [loadingIndicatorInfo, setLoadingIndicatorInfo] = useState({});
|
|
55
54
|
const [translate] = useTranslate();
|
|
@@ -262,7 +261,7 @@ const Virtualize = forwardRef(({ id, viewHeight, viewWidth, totalRecordCount, it
|
|
|
262
261
|
}, role: 'rowgroup', children: children }), showLoadingIndicator && isFetching && loadingIndicatorInfo.isScrollingDown && (_jsx(StyledLoader, { "$style": {
|
|
263
262
|
top: '--below-loader-top',
|
|
264
263
|
left: '--loader-left'
|
|
265
|
-
}, children: _jsx(Progress, { className: 'below-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) }))] }), totalRecordCount === 0 ?
|
|
264
|
+
}, children: _jsx(Progress, { className: 'below-loader', placement: 'block', tabIndex: 0, "aria-label": translate('Loading more results') }) }))] }), totalRecordCount === 0 ? renderEmptyRecords && renderEmptyRecords() : null, renderFooter && renderFooter()] }));
|
|
266
265
|
});
|
|
267
266
|
Virtualize.propTypes = {
|
|
268
267
|
id: PropTypes.string.isRequired,
|
|
@@ -282,7 +281,8 @@ Virtualize.propTypes = {
|
|
|
282
281
|
}),
|
|
283
282
|
bufferMultiplier: PropTypes.number,
|
|
284
283
|
viewMaxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
285
|
-
showLoadingIndicator: PropTypes.bool
|
|
284
|
+
showLoadingIndicator: PropTypes.bool,
|
|
285
|
+
renderEmptyRecords: PropTypes.func
|
|
286
286
|
};
|
|
287
287
|
Virtualize.defaultProps = {
|
|
288
288
|
bufferMultiplier: 2,
|
|
@@ -296,7 +296,8 @@ Virtualize.defaultProps = {
|
|
|
296
296
|
state: undefined,
|
|
297
297
|
totalRecordCount: undefined,
|
|
298
298
|
viewMaxHeight: undefined,
|
|
299
|
-
showLoadingIndicator: false
|
|
299
|
+
showLoadingIndicator: false,
|
|
300
|
+
renderEmptyRecords: null
|
|
300
301
|
};
|
|
301
302
|
Virtualize.displayName = 'Virtualize';
|
|
302
303
|
export default memo(Virtualize);
|