-
Notifications
You must be signed in to change notification settings - Fork 457
/
textbox.js
93 lines (86 loc) · 3.15 KB
/
textbox.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
81
82
83
84
85
86
87
88
89
90
91
92
93
var React = require("react");
var { View, Text, TextInput } = require("react-native");
function textbox(locals) {
if (locals.hidden) {
return null;
}
var stylesheet = locals.stylesheet;
var formGroupStyle = stylesheet.formGroup.normal;
var controlLabelStyle = stylesheet.controlLabel.normal;
var textboxStyle = stylesheet.textbox.normal;
var textboxViewStyle = stylesheet.textboxView.normal;
var helpBlockStyle = stylesheet.helpBlock.normal;
var errorBlockStyle = stylesheet.errorBlock;
if (locals.hasError) {
formGroupStyle = stylesheet.formGroup.error;
controlLabelStyle = stylesheet.controlLabel.error;
textboxStyle = stylesheet.textbox.error;
textboxViewStyle = stylesheet.textboxView.error;
helpBlockStyle = stylesheet.helpBlock.error;
}
if (locals.editable === false) {
textboxStyle = stylesheet.textbox.notEditable;
textboxViewStyle = stylesheet.textboxView.notEditable;
}
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;
return (
<View style={formGroupStyle}>
{label}
<View style={textboxViewStyle}>
<TextInput
accessibilityLabel={locals.label}
ref="input"
allowFontScaling={locals.allowFontScaling}
autoCapitalize={locals.autoCapitalize}
autoCorrect={locals.autoCorrect}
autoFocus={locals.autoFocus}
blurOnSubmit={locals.blurOnSubmit}
editable={locals.editable}
keyboardType={locals.keyboardType}
maxLength={locals.maxLength}
multiline={locals.multiline}
onBlur={locals.onBlur}
onEndEditing={locals.onEndEditing}
onFocus={locals.onFocus}
onLayout={locals.onLayout}
onSelectionChange={locals.onSelectionChange}
onSubmitEditing={locals.onSubmitEditing}
onContentSizeChange={locals.onContentSizeChange}
placeholderTextColor={locals.placeholderTextColor}
secureTextEntry={locals.secureTextEntry}
selectTextOnFocus={locals.selectTextOnFocus}
selectionColor={locals.selectionColor}
numberOfLines={locals.numberOfLines}
clearButtonMode={locals.clearButtonMode}
clearTextOnFocus={locals.clearTextOnFocus}
enablesReturnKeyAutomatically={locals.enablesReturnKeyAutomatically}
keyboardAppearance={locals.keyboardAppearance}
onKeyPress={locals.onKeyPress}
returnKeyType={locals.returnKeyType}
selectionState={locals.selectionState}
onChangeText={value => locals.onChange(value)}
onChange={locals.onChangeNative}
placeholder={locals.placeholder}
style={textboxStyle}
value={locals.value}
testID={locals.testID}
textContentType={locals.textContentType}
/>
</View>
{help}
{error}
</View>
);
}
module.exports = textbox;