UNPKG

@hbsis.uikit/react

Version:
42 lines (32 loc) 880 B
import React from 'react' import Col from './col' class ConfigItem { constructor (config) { this.config = config this.visible = ('visible' in config) ? config.visible : true } isVisible = () => { return this.visible } getValue = (data) => { const { attribute, renderCol } = this.config return renderCol ? renderCol(data) : data[attribute] } renderHeaderCol = () => { const { width, labelHeader, attribute, bordered } = this.config return ( <Col key={attribute} width={width} bordered={bordered}> {labelHeader} </Col> ) } renderDataCol = (data) => { const { width, attribute, bordered } = this.config return ( <Col key={attribute} width={width} bordered={bordered}> {this.getValue(data)} </Col> ) } } export default ConfigItem