nuke-input
Advanced tools
Comparing version 0.3.5 to 0.3.6
# Changelog | ||
## 0.3.6 / 2017-04-27 | ||
* [[52d026f](http://gitlab.alibaba-inc.com/nuke/input/commit/52d026f8e118004c94efc1aa6c37273e0f478299)] - `fix` fix defaultValue bug, add e.target.value for weex | ||
## 0.3.5 / 2017-04-19 | ||
@@ -5,0 +9,0 @@ |
@@ -88,3 +88,3 @@ /** @jsx createElement */ | ||
_this.changeHandler = _this.changeHandler.bind(_this); | ||
// this.inputHandler = this.inputHandler.bind(this); | ||
_this.inputHandler = _this.inputHandler.bind(_this); | ||
_this.focusHandler = _this.focusHandler.bind(_this); | ||
@@ -97,3 +97,3 @@ _this.blurHandler = _this.blurHandler.bind(_this); | ||
focus: false, | ||
value: props.value || '' | ||
value: _this.getPropValue(props, 'value') | ||
}; | ||
@@ -137,2 +137,3 @@ return _this; | ||
onFocus = _props.onFocus, | ||
onInput = _props.onInput, | ||
onBlur = _props.onBlur, | ||
@@ -153,3 +154,3 @@ readOnly = _props.readOnly, | ||
type = _props$type === undefined ? 'enclosed' : _props$type, | ||
others = _objectWithoutProperties(_props, ['hasFeedback', 'hasClear', 'prefix', 'ref', 'className', 'state', 'defaultValue', 'value', 'onChange', 'onFocus', 'onBlur', 'readOnly', 'size', 'disabled', 'style', 'addonBefore', 'addonAfter', 'multiple', 'inputStyle', 'autoFocus', 'type']); | ||
others = _objectWithoutProperties(_props, ['hasFeedback', 'hasClear', 'prefix', 'ref', 'className', 'state', 'defaultValue', 'value', 'onChange', 'onFocus', 'onInput', 'onBlur', 'readOnly', 'size', 'disabled', 'style', 'addonBefore', 'addonAfter', 'multiple', 'inputStyle', 'autoFocus', 'type']); | ||
@@ -171,2 +172,3 @@ // style.textAlign = this.getValueFromContextAndProp('align') || 'left'; | ||
onChange: this.changeHandler, | ||
onInput: this.inputHandler, | ||
onFocus: this.focusHandler, | ||
@@ -250,7 +252,7 @@ onBlur: this.blurHandler, | ||
key: 'getPropValue', | ||
value: function getPropValue(key) { | ||
value: function getPropValue(props, key) { | ||
var capitalKey = key.charAt(0).toUpperCase() + key.slice(1); | ||
var name = this.props[key] !== undefined ? key : 'default' + capitalKey; | ||
return this.props[name]; | ||
var name = props[key] !== undefined ? key : 'default' + capitalKey; | ||
return props[name]; | ||
} | ||
@@ -384,2 +386,3 @@ }, { | ||
value = e.value; | ||
e.target['value'] = value; | ||
} | ||
@@ -392,25 +395,13 @@ var maxLength = this.props.maxLength; | ||
// 不管有没有到达maxLength | ||
// !!!必须优先确保trigger onChange,让state与value同步 | ||
// 解决中文输入时由于value不同步被打断的问题 | ||
if (maxLength && value.length > maxLength) return; | ||
} | ||
// inputHandler(e){ | ||
// let value ,event; | ||
// if(isWeb){ | ||
// value = e.target.value; | ||
// }else{ | ||
// value = e.value; | ||
// } | ||
// const { maxLength } = this.props; | ||
}, { | ||
key: 'inputHandler', | ||
value: function inputHandler(e) { | ||
if (_nukeEnv.isWeex) { | ||
e.target['value'] = e.value; | ||
} | ||
// this.trigger('onInput', value, e); | ||
// this.setUnControlledState('value', value); | ||
// // 不管有没有到达maxLength | ||
// // !!!必须优先确保trigger onChange,让state与value同步 | ||
// // 解决中文输入时由于value不同步被打断的问题 | ||
// if(maxLength && value.length > maxLength) return; | ||
// } | ||
this.trigger('onInput', e); | ||
} | ||
}, { | ||
@@ -417,0 +408,0 @@ key: 'updateStateFromProps', |
{ | ||
"name": "nuke-input", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "输入框", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
@@ -8,2 +8,3 @@ /** @jsx createElement */ | ||
let App = class NukeDemoIndex extends Component { | ||
@@ -15,2 +16,3 @@ constructor() { | ||
} | ||
} | ||
@@ -27,3 +29,3 @@ change = (value, e)=>{ | ||
<View style={styles.lineWithMargin}> | ||
<Input ref="myinput" onChange={this.change} onInput={(e)=>{console.log('input==>',e)}}/> | ||
<Input ref="myinput" defaultValue="春装 连衣裙" onChange={this.change} onInput={(e)=>{console.log('input==>',e.target.value)}}/> | ||
</View> | ||
@@ -37,3 +39,3 @@ <View style={[styles.lineWithMargin,styles.textLine]}> | ||
<BizPage.Intro main="多行"></BizPage.Intro> | ||
<View style={styles.lineWithMargin}><Input style={{height:'300rem',marginBottom:'20rem'}} autoFocus={true} multiple={true} placeholder="介绍一下" onFocus={(e) => console.log('onFocus',e)} onBlur={(e) => console.log('onBlur',e)}/></View> | ||
<View style={styles.lineWithMargin}><Input style={{height:'300rem',marginBottom:'20rem'}} multiple={true} placeholder="介绍一下" onFocus={(e) => console.log('onFocus',e)} onBlur={(e) => console.log('onBlur',e)}/></View> | ||
<BizPage.Intro main="自定义样式"></BizPage.Intro> | ||
@@ -40,0 +42,0 @@ <View style={styles.lineWithMargin}> |
75006
971