UNPKG

weex-nuke

Version:

基于 Rax 、Weex 的高性能组件体系 ~~

55 lines (51 loc) 1.42 kB
'use strict'; /** @jsx createElement */ import { createElement, Component, PropTypes } from 'rax'; import { connectStyle } from 'nuke-theme-provider'; import stylesProvider from './styles'; import MDInput from './view/material'; import NormalInput from './view/normal'; class Input extends Component { constructor(props, context) { super(props); this.focus = this.focus.bind(this); this.blur = this.blur.bind(this); this.clear = this.blur.bind(this); this.getRef = this.getRef.bind(this); this.getValue = this.getValue.bind(this); this.materialDesign = context.androidConfigs && context.androidConfigs.materialDesign; if ('materialDesign' in props) { this.materialDesign = props.materialDesign; } } focus() { this.refs.baseinput.focus(); } blur() { this.refs.baseinput.blur(); } clear() { this.refs.baseinput.clear(); } getValue() { return this.refs.baseinput.getValue(); } getRef() { return this.refs.baseinput.getRef(); } render() { return this.materialDesign ? ( <MDInput ref="baseinput" {...this.props} /> ) : ( <NormalInput ref="baseinput" {...this.props} /> ); } } Input.contextTypes = { androidConfigs: PropTypes.any, commonConfigs: PropTypes.any, }; Input.displayName = 'Input'; const StyledInput = connectStyle(stylesProvider, { withRef: true })(Input); export default StyledInput;