Debian Codegraph @

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

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