UNPKG

apeman-react-select

Version:
61 lines (52 loc) 1.22 kB
/** * Label component * @class ApSelectLabel */ 'use strict' import React, { Component, PropTypes as types } from 'react' import { withTouch } from 'apeman-react-touchable' import classnames from 'classnames' import { ApIcon } from 'apeman-react-icon' /** @lends ApSelectLabel */ class ApSelectLabel extends Component { render () { const s = this let { props } = s let hasVal = !!props.value let className = classnames('ap-select-label-value', { 'ap-select-label-placeholder': !hasVal }) return ( <a className='ap-select-label'> <span className={ className }>{ hasVal ? props.value : props.placeholder }</span> <ApIcon className={ props.icon }/> </a> ) } } Object.assign(ApSelectLabel, { // -------------------- // Specs // -------------------- propTypes: { value: types.oneOfType([ types.string, types.element ]), placeholder: types.string, icon: types.string }, defaultProps: { value: null } }) export { ApSelectLabel } export default withTouch(ApSelectLabel, { getTouchData () { const s = this let { props } = s return props.data } })