mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
Backport labels & placeholders for Editable text from Vector
This commit is contained in:
parent
6cca5f4c05
commit
25ab56106a
@ -21,7 +21,9 @@ var React = require('react');
|
||||
module.exports = {
|
||||
propTypes: {
|
||||
onValueChanged: React.PropTypes.func,
|
||||
initalValue: React.PropTypes.string,
|
||||
initialValue: React.PropTypes.string,
|
||||
label: React.PropTypes.string,
|
||||
placeHolder: React.PropTypes.string,
|
||||
},
|
||||
|
||||
Phases: {
|
||||
@ -32,37 +34,55 @@ module.exports = {
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
onValueChanged: function() {},
|
||||
initalValue: '',
|
||||
initialValue: '',
|
||||
label: 'Click to set',
|
||||
placeholder: '',
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
value: this.props.initalValue,
|
||||
value: this.props.initialValue,
|
||||
phase: this.Phases.Display,
|
||||
}
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
this.setState({
|
||||
value: nextProps.initialValue
|
||||
});
|
||||
},
|
||||
|
||||
getValue: function() {
|
||||
return this.state.value;
|
||||
},
|
||||
|
||||
setValue: function(val) {
|
||||
setValue: function(val, shouldSubmit, suppressListener) {
|
||||
var self = this;
|
||||
this.setState({
|
||||
value: val,
|
||||
phase: this.Phases.Display,
|
||||
}, function() {
|
||||
if (!suppressListener) {
|
||||
self.onValueChanged(shouldSubmit);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
this.onValueChanged();
|
||||
edit: function() {
|
||||
this.setState({
|
||||
phase: this.Phases.Edit,
|
||||
});
|
||||
},
|
||||
|
||||
cancelEdit: function() {
|
||||
this.setState({
|
||||
phase: this.Phases.Display,
|
||||
});
|
||||
this.onValueChanged(false);
|
||||
},
|
||||
|
||||
onValueChanged: function() {
|
||||
this.props.onValueChanged(this.state.value);
|
||||
onValueChanged: function(shouldSubmit) {
|
||||
this.props.onValueChanged(this.state.value, shouldSubmit);
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user