-
Notifications
You must be signed in to change notification settings - Fork 93
/
GroupedOptionsField.js
80 lines (74 loc) · 1.36 KB
/
GroupedOptionsField.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import Select from 'react-select-plus';
var ops = [{
label: 'Black',
value: 'black',
}, {
label: 'Primary Colors',
options: [{
label: 'Yellow',
value: 'yellow'
}, {
label: 'Red',
value: 'red'
}, {
label: 'Blue',
value: 'blue'
}]
}, {
label: 'Secondary Colors',
options: [{
label: 'Orange',
value: 'orange'
}, {
label: 'Purple',
options: [{
label: 'Light Purple',
value: 'light_purple'
}, {
label: 'Medium Purple',
value: 'medium_purple'
}, {
label: 'Dark Purple',
value: 'dark_purple'
}]
}, {
label: 'Green',
value: 'green'
}]
}, {
label: 'White',
value: 'white',
}];
var GroupedOptionsField = createClass({
displayName: 'GroupedOptionsField',
propTypes: {
delimiter: PropTypes.string,
label: PropTypes.string,
multi: PropTypes.bool,
},
getInitialState () {
return {
value: null,
};
},
onChange(value) {
this.setState({ value });
console.log('Option Groups Select value changed to', value);
},
render () {
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select
onChange={this.onChange}
options={ops}
placeholder="Select a color"
value={this.state.value} />
</div>
);
}
});
module.exports = GroupedOptionsField;