-
Notifications
You must be signed in to change notification settings - Fork 457
/
Copy pathselect.android.js
67 lines (60 loc) · 1.71 KB
/
select.android.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
var React = require("react");
var { View, Text, Picker } = require("react-native");
function select(locals) {
if (locals.hidden) {
return null;
}
var stylesheet = locals.stylesheet;
var formGroupStyle = stylesheet.formGroup.normal;
var controlLabelStyle = stylesheet.controlLabel.normal;
var selectStyle = Object.assign(
{},
stylesheet.select.normal,
stylesheet.pickerContainer.normal
);
var helpBlockStyle = stylesheet.helpBlock.normal;
var errorBlockStyle = stylesheet.errorBlock;
if (locals.hasError) {
formGroupStyle = stylesheet.formGroup.error;
controlLabelStyle = stylesheet.controlLabel.error;
selectStyle = stylesheet.select.error;
helpBlockStyle = stylesheet.helpBlock.error;
}
var label = locals.label ? (
<Text style={controlLabelStyle}>{locals.label}</Text>
) : null;
var help = locals.help ? (
<Text style={helpBlockStyle}>{locals.help}</Text>
) : null;
var error =
locals.hasError && locals.error ? (
<Text accessibilityLiveRegion="polite" style={errorBlockStyle}>
{locals.error}
</Text>
) : null;
var options = locals.options.map(({ value, text }) => (
<Picker.Item key={value} value={value} label={text} />
));
return (
<View style={formGroupStyle}>
{label}
<Picker
accessibilityLabel={locals.label}
ref="input"
style={selectStyle}
selectedValue={locals.value}
onValueChange={locals.onChange}
help={locals.help}
enabled={!locals.disabled}
mode={locals.mode}
prompt={locals.prompt}
itemStyle={locals.itemStyle}
>
{options}
</Picker>
{help}
{error}
</View>
);
}
module.exports = select;