-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
32 lines (27 loc) · 766 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { createElement as h } from 'react';
import createReactClass from 'create-react-class';
import { v1 as uuidv1 } from 'uuid';
const IdControl = createReactClass({
componentDidMount: function () {
const value = this.props.value ? this.props.value : uuidv1();
this.props.onChange(value)
},
handleChange: function(e) {
this.props.onChange(e.target.value.trim());
},
render: function() {
return h('input', {
type: 'text',
disabled: 'disabled',
value: this.props.value,
onChange: this.handleChange,
className: this.props.classNameWrapper
});
}
});
const IdPreview = createReactClass({
render: function() {
return h('p', {}, this.props.value);
}
});
export default { IdControl, IdPreview };