/** * Component for displaying the number of records on a page as a tooltip * * @author: Ilya Brauer * @date: 2019-10-18 */ import * as React from 'react'; import * as styles from './pageSize.m.css'; import {PLACEMENT, TRIGGER} from '../../../constants'; import {joinClassNames, Popover} from '../../../index'; interface IProps { value: string; rowsText: string; pageSizeOptions: number[]; onChangePageSize: (size: number) => void; isDisabled?: boolean; } interface IState { visible: boolean; } export class PageSize extends React.Component { override state = { visible: false }; private onChangePageSize = (size: number) => { return () => { this.props.onChangePageSize(size); this.toggleVisible(false); }; }; private toggleVisible = (visible: boolean) => { this.setState({visible}); }; override render () { if (this.props.isDisabled) { const classes = joinClassNames( styles.value, styles.isDisabled ); return ( {this.props.value} ); } return ( {this.props.value})} > {this.props.pageSizeOptions.map((option, index) => { return (
{option} {this.props.rowsText}
); })}
); } }