UNPKG

react-virtualized-sticky-tree

Version:

A React component for efficiently rendering tree like structures with support for position: sticky

25 lines (24 loc) 1.24 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importDefault(require("react")); const react_measure_1 = __importDefault(require("react-measure")); const StickyTree_js_1 = __importDefault(require("./StickyTree.js")); class AutoSizedStickyTree extends react_1.default.PureComponent { constructor(props) { super(props); this.state = {}; } render() { return (react_1.default.createElement(react_measure_1.default, { bounds: true, onResize: (rect) => { this.setState({ width: rect.bounds.width, height: rect.bounds.height }); if (this.props.onResize !== undefined) { this.props.onResize(rect); } } }, ({ measureRef }) => (react_1.default.createElement("div", { ref: measureRef, className: this.props.className }, react_1.default.createElement(StickyTree_js_1.default, Object.assign({ ref: this.props.treeRef, width: this.state.width, height: this.state.height }, this.props)))))); } } exports.default = AutoSizedStickyTree;