UNPKG

@sap-ux/ui-components

Version:
71 lines 2.29 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.UIVirtualList = exports.defaultCellRangeRenderer = exports.CellMeasurerCache = void 0; const react_1 = __importDefault(require("react")); const react_virtualized_1 = require("react-virtualized"); var react_virtualized_2 = require("react-virtualized"); Object.defineProperty(exports, "CellMeasurerCache", { enumerable: true, get: function () { return react_virtualized_2.CellMeasurerCache; } }); Object.defineProperty(exports, "defaultCellRangeRenderer", { enumerable: true, get: function () { return react_virtualized_2.defaultCellRangeRenderer; } }); /** * UIVirtualList component. * based on https://github.com/bvaughn/react-virtualized/tree/master/source/List. * * @exports * @class UIVirtualList * @extends {React.Component<ListProps, {}>} */ class UIVirtualList extends react_1.default.Component { /** * Initializes component properties. * * @param {CellMeasurerProps} props */ constructor(props) { super(props); this.listRef = react_1.default.createRef(); } forceListUpdate() { if (this.listRef.current) { this.listRef.current.forceUpdate(); } } /** * Scrolls to the row based on index. * * @param index */ scrollToRow(index) { if (this.listRef.current) { this.listRef.current.scrollToRow(index); } } /** * Method to compute row height. * * @param {number} index */ recomputeRowHeights(index) { if (this.listRef.current) { this.listRef.current.recomputeRowHeights(index); } } /** * Method returns state of component isScrolling. * * @returns {boolean} */ isScrolling() { return !!this.listRef.current?.Grid?.state.isScrolling; } /** * @returns {JSX.Element} */ render() { return (react_1.default.createElement(react_virtualized_1.List, { ref: this.listRef, ...this.props }, this.props.children)); } } exports.UIVirtualList = UIVirtualList; //# sourceMappingURL=UIVirtualList.js.map