Debian Codegraph @

node/@patternfly/react-table/dist/js/components/Table/RowWrapper.js

raw
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.RowWrapper = void 0;
4 const tslib_1 = require("tslib");
5 const jsx_runtime_1 = require("react/jsx-runtime");
6 const react_1 = require("react");
7 const util_1 = require('@patternfly/react-core/dist/js/helpers/util');
8 const Tr_1 = require("./Tr");
9 class RowWrapper extends react_1.Component {
10 constructor(props) {
11 super(props);
12 this.handleScroll = (event) => {
13 if (!this._unmounted) {
14 this.props.onScroll(event);
15 }
16 };
17 this.handleResize = (event) => {
18 if (!this._unmounted) {
19 this.props.onResize(event);
20 }
21 };
22 if (props.onScroll) {
23 this.handleScroll = (0, util_1.debounce)(this.handleScroll, 100);
24 }
25 if (props.onResize) {
26 this.handleResize = (0, util_1.debounce)(this.handleResize, 100);
27 }
28 }
29 componentDidMount() {
30 this._unmounted = false;
31 if (util_1.canUseDOM) {
32 if (this.props.onScroll) {
33 window.addEventListener('scroll', this.handleScroll);
34 }
35 if (this.props.onResize) {
36 window.addEventListener('resize', this.handleResize);
37 }
38 }
39 }
40 componentWillUnmount() {
41 this._unmounted = true;
42 if (util_1.canUseDOM) {
43 if (this.props.onScroll) {
44 window.removeEventListener('scroll', this.handleScroll);
45 }
46 if (this.props.onResize) {
47 window.removeEventListener('resize', this.handleResize);
48 }
49 }
50 }
51 render() {
52 const _a = this.props, {
53 /* eslint-disable @typescript-eslint/no-unused-vars */
54 onScroll, onResize, row: { isExpanded, isEditable, isClickable, isRowSelected }, rowProps,
55 /* eslint-enable @typescript-eslint/no-unused-vars */
56 trRef, className, ouiaId } = _a, props = tslib_1.__rest(_a, ["onScroll", "onResize", "row", "rowProps", "trRef", "className", "ouiaId"]);
57 return ((0, jsx_runtime_1.jsx)(Tr_1.Tr, Object.assign({}, props, { ref: trRef, isExpanded: isExpanded, isEditable: isEditable, className: className, ouiaId: ouiaId, isClickable: isClickable, isRowSelected: isRowSelected })));
58 }
59 }
60 exports.RowWrapper = RowWrapper;
61 RowWrapper.displayName = 'RowWrapper';
62 RowWrapper.defaultProps = {
63 className: '',
64 row: {
65 isOpen: undefined,
66 isExpanded: undefined,
67 isHeightAuto: undefined,
68 isEditable: undefined
69 },
70 rowProps: null
71 };
72 //# sourceMappingURL=RowWrapper.js.map