forked from regentmarkets-repo-archive/binary-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectGroup.js
More file actions
41 lines (36 loc) · 926 Bytes
/
SelectGroup.js
File metadata and controls
41 lines (36 loc) · 926 Bytes
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
import React, { PureComponent } from 'react';
import Label from '../i18n/Label';
type Option = {
text: string,
value: string,
disabled: boolean,
}
export default class SelectGroup extends PureComponent {
props: {
hint: string,
id: string,
className: string,
label: string,
options: Option[],
disabled: boolean,
value: string,
onChange: (e: SyntheticEvent) => void,
};
static defaultProps = {
options: [],
};
render() {
const { className, id, label, hint, value, options, disabled, onChange } = this.props;
return (
<fieldset className={className}>
{label && <Label htmlFor={id} text={label} />}
<select id={id} disabled={disabled} onChange={onChange} value={value}>
{options.map((o: Option) => (
<option key={o.value} value={o.value} disabled={o.disabled}>{o.text}</option>
))}
</select>
{hint && <p className="hint">{hint}</p>}
</fieldset>
);
}
}