import * as React from 'react'; import * as classNames from 'classnames'; import {ReactNode, SFC, Ref} from 'react'; import {Scrollbars} from './../'; import {range} from './utils/array'; export interface DatagridTableViewProps { children?: ReactNode; loading?: boolean; properties: any[]; showPlaceholderCells?: boolean; } export const DatagridTableView: SFC = (props: DatagridTableViewProps) => { const childrenArray = React.Children.toArray(props.children); return (
{!!childrenArray.length &&
{props.children}
} {(!childrenArray.length || childrenArray.length < 20) && renderPlaceholder(props)}
); }; DatagridTableView.displayName = 'DatagridTableView'; DatagridTableView.defaultProps = { loading: false, showPlaceholderCells: false, }; const renderPlaceholder = (props: DatagridTableViewProps) => { const {showPlaceholderCells, properties, loading} = props; const dummyArray = range(100); return (
{dummyArray.map((item, index) => (
{properties.map((property: any, index) => (
))}
))}
); };