nuke-input
Advanced tools
Comparing version 1.0.47 to 1.0.48
@@ -0,1 +1,103 @@ | ||
# Input Demo | ||
* order: 4 | ||
* hide:true | ||
weex-format | ||
--- | ||
```js | ||
/** @jsx createElement */ | ||
import { createElement, Component, render } from 'rax'; | ||
import View from 'nuke-view'; | ||
import Text from 'nuke-text'; | ||
import Input from 'nuke-input'; | ||
import Page from 'nuke-page'; | ||
import Button from 'nuke-button'; | ||
import { isWeb, isWeex, appInfo } from 'nuke-env'; | ||
import { StyleProvider } from 'nuke-theme-provider'; | ||
const isAndroid = true; | ||
let md = { | ||
Core: { | ||
'color-brand1-1': '#00BBD3', | ||
'color-brand1-6': '#1A9CB7', | ||
'color-brand1-9': '#0096A6', | ||
'color-error-3': '#D50000', | ||
'color-line1-1': '#DADADA', | ||
'color-line1-2': '#E0E0E0', | ||
'color-text1-1': '#9E9E9E', | ||
['font-size-title']: 40, | ||
['font-size-subhead']: 32, | ||
['font-size-body-3']: 28, | ||
['font-size-body-2']: 28, | ||
['font-size-body-1']: 28, | ||
['font-size-caption']: 24, | ||
['font-size-footnote']: 20 | ||
}, | ||
Input: { | ||
'md-placeholder-height': 50, | ||
'md-help-margin-top': 16, | ||
'md-input-height': 50, | ||
'md-placeholder-font-size': 28, | ||
'md-input-margin-bottom': 0 | ||
} | ||
}; | ||
let App = class NukeDemoIndex extends Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
cardNumber: '432' | ||
}; | ||
this.input = this.input.bind(this); | ||
this.change = this.change.bind(this); | ||
} | ||
componentDidMount() { | ||
if (isWeex) { | ||
this.refs.input.wrappedInstance.setNativeFormatRule({ | ||
formatRule: '/(\\d{4})(?!$)/g', | ||
formatReplace: '$1 ', | ||
recoverRule: '/(\\s*)/g', | ||
recoverReplace: '' | ||
}); | ||
} | ||
} | ||
input(e) { | ||
console.log('onInput ==>', e.value); | ||
} | ||
change(value, e) { | ||
console.log('onChange ==>', value); | ||
} | ||
render() { | ||
return ( | ||
<StyleProvider style={md} androidConfigs={{ materialDesign: true }}> | ||
<Page title="single md"> | ||
<Page.Intro main="cardnumber" /> | ||
<View style={styles.demoBlock}> | ||
<Input | ||
maxLength={19} | ||
type="text" | ||
defaultValue={this.state.cardNumber} | ||
ref="input" | ||
onInput={this.input} | ||
onChange={this.change} | ||
placeholder="Format" | ||
/> | ||
</View> | ||
</Page> | ||
</StyleProvider> | ||
); | ||
} | ||
}; | ||
const styles = { | ||
demoBlock: { | ||
marginLeft: 40, | ||
marginRight: 40 | ||
} | ||
}; | ||
render(<App />); | ||
``` |
@@ -64,3 +64,4 @@ # Input Demo | ||
status3: 'error', | ||
value: '111' | ||
value: '111', | ||
disabled: true | ||
}; | ||
@@ -112,3 +113,3 @@ this.checkLength = this.checkLength.bind(this); | ||
<Input | ||
disabled={true} | ||
disabled={this.state.disabled} | ||
maxLength={10} | ||
@@ -119,2 +120,10 @@ type="text" | ||
</View> | ||
<Button | ||
onPress={() => { | ||
this.setState({ disabled: false }); | ||
}} | ||
type="primary" | ||
> | ||
switch | ||
</Button> | ||
<Page.Intro main="error" /> | ||
@@ -121,0 +130,0 @@ <View style={styles.demoBlock}> |
# Changelog | ||
## 1.0.48 / 2018-02-06 | ||
* [[a18ce46](http://gitlab.alibaba-inc.com/nuke/input/commit/a18ce46d27033ccc2c1584191045dd792043e0dd)] - `fix` fix input not update when value is null | ||
## 1.0.47 / 2018-02-02 | ||
@@ -5,0 +9,0 @@ |
@@ -50,2 +50,3 @@ 'use strict'; | ||
_this.getValue = _this.getValue.bind(_this); | ||
_this.setNativeFormatRule = _this.setNativeFormatRule.bind(_this); | ||
@@ -85,2 +86,7 @@ _this.materialDesign = context.androidConfigs && context.androidConfigs.materialDesign; | ||
}, { | ||
key: 'setNativeFormatRule', | ||
value: function setNativeFormatRule(rules) { | ||
return this.refs.baseinput.setNativeFormatRule(rules); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -87,0 +93,0 @@ value: function render() { |
@@ -48,2 +48,3 @@ 'use strict'; | ||
_this.getRef = _this.getRef.bind(_this); | ||
_this.setNativeFormatRule = _this.setNativeFormatRule.bind(_this); | ||
_this.inputHandler = _this.inputHandler.bind(_this); | ||
@@ -60,5 +61,10 @@ _this.returnHandler = _this.returnHandler.bind(_this); | ||
} | ||
return false; | ||
return nextProps.readOnly !== this.props.readOnly || nextProps.disabled !== this.props.disabled; | ||
} | ||
}, { | ||
key: 'setNativeFormatRule', | ||
value: function setNativeFormatRule(rules) { | ||
this.refs.input.setTextFormatter(rules); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
@@ -65,0 +71,0 @@ value: function componentWillReceiveProps(nextProps) { |
@@ -106,2 +106,3 @@ 'use strict'; | ||
_this.clear = _this.clear.bind(_this); | ||
_this.setNativeFormatRule = _this.setNativeFormatRule.bind(_this); | ||
return _this; | ||
@@ -243,2 +244,7 @@ } | ||
}, { | ||
key: 'setNativeFormatRule', | ||
value: function setNativeFormatRule(rules) { | ||
return this.refs.baseinput.setNativeFormatRule(rules); | ||
} | ||
}, { | ||
key: 'clear', | ||
@@ -245,0 +251,0 @@ value: function clear() { |
{ | ||
"name": "nuke-input", | ||
"version": "1.0.47", | ||
"version": "1.0.48", | ||
"description": "输入框", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
179896
2303