import React, { Component } from 'react'; import classnames from 'classnames'; import './styles.module.scss'; const Card: React.FC = ({type, style, className, children}) => { return
{children}
; } export default Card; export const CardBody: React.FC = ({children, className}) => { return
{children}
; } export const CardHeader: React.FC = ({children, size, className, onClick}) => { return
{children}
; } export const CardWell: React.FC = ({children, type, className}) => { return
{children}
; } export const CardWellHighlight: React.FC = ({children, className}) => { return {children} ; } export const CardLoading: React.FC = ({indeterminate, percent, className}) => { return
} export class CardTable extends Component { constructor(props) { super(props); this.state = { showLeftArrow: false, showRightArrow: false, }; this.onScroll = this.onScroll.bind(this); } onScroll() { const container = (this as any).container.getBoundingClientRect(); const table = (this as any).table.getBoundingClientRect(); let showLeftArrow = table.width > container.width && table.left < container.left; let showRightArrow = table.width > container.width && table.right > container.right; if (showLeftArrow !== this.state.showLeftArrow || showRightArrow !== this.state.showRightArrow) { this.setState({showLeftArrow, showRightArrow}); } } componentDidMount() { window.addEventListener('resize', this.onScroll); (this as any).container.addEventListener('scroll', this.onScroll); this.onScroll(); } componentWillUnmount() { window.removeEventListener('resize', this.onScroll); (this as any).container.removeEventListener('scroll', this.onScroll); } render() { const { headings, data, mapDataItemToRow } = this.props; return (
{ (this as any).container = r; }}> { (this as any).table = r; }}> {headings.map(heading => )} {data.map(row => ( {mapDataItemToRow(row).map((item, index) => )} ))}
{heading}
{item}
); } } Card.displayName = 'Card'; CardBody.displayName = 'CardBody'; CardHeader.displayName = 'CardHeader'; CardLoading.displayName = 'CardLoading'; CardWell.displayName = 'CardWell'; CardWellHighlight.displayName = 'CardWellHighlight';