@tamagui/input 2.7.7 → 3.0.0-beta.643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Input.cjs +78 -162
- package/dist/cjs/Input.native.cjs +209 -0
- package/dist/cjs/Input.native.js +186 -282
- package/dist/cjs/Input.native.js.map +1 -1
- package/dist/cjs/InputNativeProps.cjs +10 -11
- package/dist/cjs/InputNativeProps.native.cjs +19 -0
- package/dist/cjs/InputNativeProps.native.js +10 -10
- package/dist/cjs/InputNativeProps.native.js.map +1 -1
- package/dist/cjs/TextArea.cjs +25 -38
- package/dist/cjs/TextArea.native.cjs +41 -0
- package/dist/cjs/TextArea.native.js +25 -37
- package/dist/cjs/TextArea.native.js.map +1 -1
- package/dist/cjs/index.cjs +16 -17
- package/dist/cjs/index.native.cjs +33 -0
- package/dist/cjs/index.native.js +16 -16
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/shared.cjs +115 -122
- package/dist/cjs/shared.native.cjs +144 -0
- package/dist/cjs/shared.native.js +120 -126
- package/dist/cjs/shared.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Input.mjs +63 -137
- package/dist/esm/Input.mjs.map +1 -1
- package/dist/esm/Input.native.js +172 -259
- package/dist/esm/Input.native.js.map +1 -1
- package/dist/esm/InputNativeProps.mjs +0 -2
- package/dist/esm/InputNativeProps.native.js +0 -2
- package/dist/esm/TextArea.mjs +12 -20
- package/dist/esm/TextArea.mjs.map +1 -1
- package/dist/esm/TextArea.native.js +12 -20
- package/dist/esm/TextArea.native.js.map +1 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.native.js +6 -4
- package/dist/esm/shared.mjs +99 -104
- package/dist/esm/shared.mjs.map +1 -1
- package/dist/esm/shared.native.js +104 -109
- package/dist/esm/shared.native.js.map +1 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/jsx/Input.mjs +63 -137
- package/dist/jsx/Input.mjs.map +1 -1
- package/dist/jsx/Input.native.cjs +209 -0
- package/dist/jsx/Input.native.js +186 -282
- package/dist/jsx/Input.native.js.map +1 -1
- package/dist/jsx/InputNativeProps.mjs +0 -2
- package/dist/jsx/InputNativeProps.native.cjs +19 -0
- package/dist/jsx/InputNativeProps.native.js +10 -10
- package/dist/jsx/InputNativeProps.native.js.map +1 -1
- package/dist/jsx/TextArea.mjs +12 -20
- package/dist/jsx/TextArea.mjs.map +1 -1
- package/dist/jsx/TextArea.native.cjs +41 -0
- package/dist/jsx/TextArea.native.js +25 -37
- package/dist/jsx/TextArea.native.js.map +1 -1
- package/dist/jsx/index.js +6 -4
- package/dist/jsx/index.mjs +6 -4
- package/dist/jsx/index.native.cjs +33 -0
- package/dist/jsx/index.native.js +16 -16
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/shared.mjs +99 -104
- package/dist/jsx/shared.mjs.map +1 -1
- package/dist/jsx/shared.native.cjs +144 -0
- package/dist/jsx/shared.native.js +120 -126
- package/dist/jsx/shared.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +19 -0
- package/dist/jsx/types.native.js +10 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +13 -15
- package/src/Input.native.tsx +263 -240
- package/src/Input.tsx +162 -152
- package/src/TextArea.tsx +6 -14
- package/src/shared.tsx +65 -70
- package/src/types.ts +1 -1
- package/types/Input.d.ts +57 -41
- package/types/Input.d.ts.map +1 -1
- package/types/Input.native.d.ts +57 -41
- package/types/Input.native.d.ts.map +1 -1
- package/types/TextArea.d.ts +172 -24
- package/types/TextArea.d.ts.map +1 -1
- package/types/shared.d.ts +14 -99
- package/types/shared.d.ts.map +1 -1
- package/types/types.d.ts +1 -1
- package/dist/cjs/inputTypes.test-d.cjs +0 -128
- package/dist/cjs/inputTypes.test-d.native.js +0 -131
- package/dist/cjs/inputTypes.test-d.native.js.map +0 -1
- package/dist/cjs/v1/Input.cjs +0 -200
- package/dist/cjs/v1/Input.native.js +0 -183
- package/dist/cjs/v1/Input.native.js.map +0 -1
- package/dist/cjs/v1/TextArea.cjs +0 -52
- package/dist/cjs/v1/TextArea.native.js +0 -55
- package/dist/cjs/v1/TextArea.native.js.map +0 -1
- package/dist/cjs/v1/index.cjs +0 -21
- package/dist/cjs/v1/index.native.js +0 -24
- package/dist/cjs/v1/index.native.js.map +0 -1
- package/dist/cjs/v1/types.cjs +0 -18
- package/dist/cjs/v1/types.native.js +0 -21
- package/dist/cjs/v1/types.native.js.map +0 -1
- package/dist/esm/InputNativeProps.mjs.map +0 -1
- package/dist/esm/InputNativeProps.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/inputTypes.test-d.mjs +0 -129
- package/dist/esm/inputTypes.test-d.mjs.map +0 -1
- package/dist/esm/inputTypes.test-d.native.js +0 -129
- package/dist/esm/inputTypes.test-d.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/esm/v1/Input.mjs +0 -164
- package/dist/esm/v1/Input.mjs.map +0 -1
- package/dist/esm/v1/Input.native.js +0 -144
- package/dist/esm/v1/Input.native.js.map +0 -1
- package/dist/esm/v1/TextArea.mjs +0 -27
- package/dist/esm/v1/TextArea.mjs.map +0 -1
- package/dist/esm/v1/TextArea.native.js +0 -27
- package/dist/esm/v1/TextArea.native.js.map +0 -1
- package/dist/esm/v1/index.mjs +0 -3
- package/dist/esm/v1/index.mjs.map +0 -1
- package/dist/esm/v1/index.native.js +0 -3
- package/dist/esm/v1/index.native.js.map +0 -1
- package/dist/esm/v1/types.mjs +0 -2
- package/dist/esm/v1/types.mjs.map +0 -1
- package/dist/esm/v1/types.native.js +0 -2
- package/dist/esm/v1/types.native.js.map +0 -1
- package/dist/jsx/InputNativeProps.mjs.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/inputTypes.test-d.mjs +0 -129
- package/dist/jsx/inputTypes.test-d.mjs.map +0 -1
- package/dist/jsx/inputTypes.test-d.native.js +0 -131
- package/dist/jsx/inputTypes.test-d.native.js.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
- package/dist/jsx/v1/Input.mjs +0 -164
- package/dist/jsx/v1/Input.mjs.map +0 -1
- package/dist/jsx/v1/Input.native.js +0 -183
- package/dist/jsx/v1/Input.native.js.map +0 -1
- package/dist/jsx/v1/TextArea.mjs +0 -27
- package/dist/jsx/v1/TextArea.mjs.map +0 -1
- package/dist/jsx/v1/TextArea.native.js +0 -55
- package/dist/jsx/v1/TextArea.native.js.map +0 -1
- package/dist/jsx/v1/index.mjs +0 -3
- package/dist/jsx/v1/index.mjs.map +0 -1
- package/dist/jsx/v1/index.native.js +0 -24
- package/dist/jsx/v1/index.native.js.map +0 -1
- package/dist/jsx/v1/types.mjs +0 -2
- package/dist/jsx/v1/types.mjs.map +0 -1
- package/dist/jsx/v1/types.native.js +0 -21
- package/dist/jsx/v1/types.native.js.map +0 -1
- package/src/inputTypes.test-d.ts +0 -245
- package/src/v1/Input.native.tsx +0 -153
- package/src/v1/Input.tsx +0 -190
- package/src/v1/TextArea.tsx +0 -35
- package/src/v1/index.ts +0 -3
- package/src/v1/types.ts +0 -65
- package/types/v1/Input.d.ts +0 -64
- package/types/v1/Input.d.ts.map +0 -1
- package/types/v1/Input.native.d.ts +0 -63
- package/types/v1/Input.native.d.ts.map +0 -1
- package/types/v1/TextArea.d.ts +0 -41
- package/types/v1/TextArea.d.ts.map +0 -1
- package/types/v1/index.d.ts +0 -4
- package/types/v1/index.d.ts.map +0 -1
- package/types/v1/types.d.ts +0 -39
- package/types/v1/types.d.ts.map +0 -1
package/src/Input.native.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { TextInput, type TextInputProps as RNTextInputProps } from 'react-native'
|
|
3
|
-
import { styled } from '@tamagui/core'
|
|
3
|
+
import { createStyledHOC, type GetProps, styled } from '@tamagui/core'
|
|
4
4
|
import { registerFocusable } from '@tamagui/focusable'
|
|
5
5
|
import { useNativeInputRef } from '@tamagui/element'
|
|
6
6
|
import { styledBody } from './shared'
|
|
@@ -12,273 +12,296 @@ const StyledInput = styled(TextInput, styledBody[0], styledBody[1])
|
|
|
12
12
|
* A web-aligned input component for React Native.
|
|
13
13
|
* @see — Docs https://tamagui.dev/ui/inputs#input
|
|
14
14
|
*/
|
|
15
|
-
export const Input =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
export const Input = createStyledHOC(
|
|
16
|
+
StyledInput,
|
|
17
|
+
(
|
|
18
|
+
props: Omit<GetProps<typeof StyledInput>, keyof InputExtraProps> & InputExtraProps,
|
|
19
|
+
forwardedRef
|
|
20
|
+
) => {
|
|
21
|
+
const {
|
|
22
|
+
// Web props we need to convert
|
|
23
|
+
type,
|
|
24
|
+
disabled,
|
|
25
|
+
readOnly,
|
|
26
|
+
id,
|
|
27
|
+
rows,
|
|
28
|
+
autoComplete,
|
|
29
|
+
enterKeyHint,
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
// Callbacks
|
|
32
|
+
onChange,
|
|
33
|
+
onInput,
|
|
34
|
+
onKeyDown,
|
|
35
|
+
onChangeText,
|
|
36
|
+
onSubmitEditing,
|
|
37
|
+
onSelectionChange,
|
|
38
|
+
onEndEditing,
|
|
39
|
+
onContentSizeChange,
|
|
40
|
+
onScroll,
|
|
41
|
+
onKeyPress: onKeyPressProp,
|
|
42
|
+
selection,
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
// Native-only props (pass through directly)
|
|
45
|
+
keyboardAppearance,
|
|
46
|
+
returnKeyType: returnKeyTypeProp,
|
|
47
|
+
submitBehavior,
|
|
48
|
+
blurOnSubmit,
|
|
49
|
+
caretHidden,
|
|
50
|
+
contextMenuHidden,
|
|
51
|
+
selectTextOnFocus,
|
|
52
|
+
secureTextEntry: secureTextEntryProp,
|
|
53
|
+
maxFontSizeMultiplier,
|
|
54
|
+
allowFontScaling,
|
|
55
|
+
multiline: multilineProp,
|
|
56
|
+
keyboardType: keyboardTypeProp,
|
|
57
|
+
inputMode: inputModeProp,
|
|
58
|
+
autoCapitalize: autoCapitalizeProp,
|
|
59
|
+
autoCorrect: autoCorrectProp,
|
|
60
|
+
autoFocusNative,
|
|
61
|
+
textContentType,
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
// iOS-only props
|
|
64
|
+
clearButtonMode,
|
|
65
|
+
clearTextOnFocus,
|
|
66
|
+
enablesReturnKeyAutomatically,
|
|
67
|
+
dataDetectorTypes,
|
|
68
|
+
scrollEnabled,
|
|
69
|
+
passwordRules,
|
|
70
|
+
rejectResponderTermination,
|
|
71
|
+
spellCheck,
|
|
72
|
+
lineBreakStrategyIOS,
|
|
73
|
+
lineBreakModeIOS,
|
|
74
|
+
smartInsertDelete,
|
|
75
|
+
inputAccessoryViewID,
|
|
76
|
+
inputAccessoryViewButtonLabel,
|
|
77
|
+
disableKeyboardShortcuts,
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
// Android-only props
|
|
80
|
+
importantForAutofill,
|
|
81
|
+
disableFullscreenUI,
|
|
82
|
+
inlineImageLeft,
|
|
83
|
+
inlineImagePadding,
|
|
84
|
+
returnKeyLabel,
|
|
85
|
+
textBreakStrategy,
|
|
86
|
+
textAlignVertical,
|
|
87
|
+
verticalAlign,
|
|
88
|
+
showSoftInputOnFocus,
|
|
89
|
+
numberOfLines: numberOfLinesProp,
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
// Web-only props to filter out
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
dirname,
|
|
94
|
+
min,
|
|
95
|
+
max,
|
|
96
|
+
minLength,
|
|
97
|
+
multiple,
|
|
98
|
+
name,
|
|
99
|
+
pattern,
|
|
100
|
+
required,
|
|
101
|
+
step,
|
|
102
|
+
render,
|
|
98
103
|
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
// caretColor is web-only as a CSS prop; on native forward to
|
|
105
|
+
// cursorColor (Android) + selectionColor (iOS+Android caret) unless
|
|
106
|
+
// those are explicitly set.
|
|
107
|
+
// @ts-ignore - caretColor is typed as web-only in core
|
|
108
|
+
caretColor,
|
|
109
|
+
cursorColor: cursorColorProp,
|
|
110
|
+
selectionColor: selectionColorProp,
|
|
101
111
|
|
|
102
|
-
|
|
112
|
+
...rest
|
|
113
|
+
} = props
|
|
103
114
|
|
|
104
|
-
|
|
105
|
-
let secureTextEntry = secureTextEntryProp ?? false
|
|
106
|
-
let keyboardType: RNTextInputProps['keyboardType'] = keyboardTypeProp ?? 'default'
|
|
107
|
-
let inputMode: RNTextInputProps['inputMode'] = inputModeProp
|
|
115
|
+
const { ref, composedRef } = useNativeInputRef(forwardedRef)
|
|
108
116
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
117
|
+
// Convert web type to native props (if not explicitly overridden)
|
|
118
|
+
let secureTextEntry = secureTextEntryProp ?? false
|
|
119
|
+
let keyboardType: RNTextInputProps['keyboardType'] = keyboardTypeProp ?? 'default'
|
|
120
|
+
let inputMode: RNTextInputProps['inputMode'] = inputModeProp
|
|
121
|
+
|
|
122
|
+
// only derive from type if native props weren't explicitly set
|
|
123
|
+
if (!secureTextEntryProp && !keyboardTypeProp && !inputModeProp) {
|
|
124
|
+
switch (type) {
|
|
125
|
+
case 'password':
|
|
126
|
+
secureTextEntry = true
|
|
127
|
+
break
|
|
128
|
+
case 'email':
|
|
129
|
+
keyboardType = 'email-address'
|
|
130
|
+
inputMode = 'email'
|
|
131
|
+
break
|
|
132
|
+
case 'tel':
|
|
133
|
+
keyboardType = 'phone-pad'
|
|
134
|
+
inputMode = 'tel'
|
|
135
|
+
break
|
|
136
|
+
case 'number':
|
|
137
|
+
keyboardType = 'numeric'
|
|
138
|
+
inputMode = 'numeric'
|
|
139
|
+
break
|
|
140
|
+
case 'url':
|
|
141
|
+
keyboardType = 'url'
|
|
142
|
+
inputMode = 'url'
|
|
143
|
+
break
|
|
144
|
+
case 'search':
|
|
145
|
+
inputMode = 'search'
|
|
146
|
+
break
|
|
147
|
+
}
|
|
134
148
|
}
|
|
135
|
-
}
|
|
136
149
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
// Use explicit returnKeyType if provided, otherwise convert enterKeyHint
|
|
151
|
+
let returnKeyType: RNTextInputProps['returnKeyType'] = returnKeyTypeProp
|
|
152
|
+
if (!returnKeyType && enterKeyHint) {
|
|
153
|
+
switch (enterKeyHint) {
|
|
154
|
+
case 'done':
|
|
155
|
+
returnKeyType = 'done'
|
|
156
|
+
break
|
|
157
|
+
case 'go':
|
|
158
|
+
returnKeyType = 'go'
|
|
159
|
+
break
|
|
160
|
+
case 'next':
|
|
161
|
+
returnKeyType = 'next'
|
|
162
|
+
break
|
|
163
|
+
case 'search':
|
|
164
|
+
returnKeyType = 'search'
|
|
165
|
+
break
|
|
166
|
+
case 'send':
|
|
167
|
+
returnKeyType = 'send'
|
|
168
|
+
break
|
|
169
|
+
}
|
|
156
170
|
}
|
|
157
|
-
}
|
|
158
171
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
// Determine multiline
|
|
173
|
+
const multiline = multilineProp ?? (render === 'textarea' || (rows && rows > 1))
|
|
174
|
+
const numberOfLines = numberOfLinesProp ?? rows
|
|
162
175
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
// convert web-style autoCorrect string to native boolean
|
|
177
|
+
const autoCorrect =
|
|
178
|
+
autoCorrectProp === 'on'
|
|
179
|
+
? true
|
|
180
|
+
: autoCorrectProp === 'off'
|
|
181
|
+
? false
|
|
182
|
+
: autoCorrectProp
|
|
166
183
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
184
|
+
// convert web-style autoCapitalize to native values
|
|
185
|
+
const autoCapitalize =
|
|
186
|
+
autoCapitalizeProp === 'on'
|
|
187
|
+
? 'sentences'
|
|
188
|
+
: autoCapitalizeProp === 'off'
|
|
189
|
+
? 'none'
|
|
190
|
+
: autoCapitalizeProp
|
|
174
191
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
192
|
+
// Register focusable
|
|
193
|
+
React.useEffect(() => {
|
|
194
|
+
if (!id || disabled) return
|
|
195
|
+
return registerFocusable(id, {
|
|
196
|
+
focusAndSelect: () => ref.current?.focus(),
|
|
197
|
+
focus: () => ref.current?.focus(),
|
|
198
|
+
})
|
|
199
|
+
}, [id, disabled])
|
|
183
200
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
201
|
+
// Handle web onChange/onInput -> native onChangeText
|
|
202
|
+
const handleChangeText = (text: string) => {
|
|
203
|
+
onChangeText?.(text)
|
|
204
|
+
if (onChange) {
|
|
205
|
+
onChange({ target: { value: text }, type: 'change' } as any)
|
|
206
|
+
}
|
|
207
|
+
if (onInput) {
|
|
208
|
+
onInput({ target: { value: text }, type: 'input' } as any)
|
|
209
|
+
}
|
|
189
210
|
}
|
|
190
|
-
|
|
191
|
-
|
|
211
|
+
|
|
212
|
+
// Handle onKeyDown via onKeyPress + onSubmitEditing
|
|
213
|
+
const handleKeyPress = (e: any) => {
|
|
214
|
+
// call user's onKeyPress first
|
|
215
|
+
onKeyPressProp?.(e)
|
|
216
|
+
// then handle web onKeyDown compat
|
|
217
|
+
if (onKeyDown) {
|
|
218
|
+
const { key } = e.nativeEvent
|
|
219
|
+
if (key === 'Backspace' || key === 'Enter' || key.length === 1) {
|
|
220
|
+
onKeyDown({ key, type: 'keydown' } as any)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
192
223
|
}
|
|
193
|
-
}
|
|
194
224
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
onKeyPressProp?.(e)
|
|
199
|
-
// then handle web onKeyDown compat
|
|
200
|
-
if (onKeyDown) {
|
|
201
|
-
const { key } = e.nativeEvent
|
|
202
|
-
if (key === 'Backspace' || key === 'Enter' || key.length === 1) {
|
|
203
|
-
onKeyDown({ key, type: 'keydown' } as any)
|
|
225
|
+
const handleSubmitEditing = (e: any) => {
|
|
226
|
+
if (onKeyDown) {
|
|
227
|
+
onKeyDown({ key: 'Enter', type: 'keydown' } as any)
|
|
204
228
|
}
|
|
229
|
+
onSubmitEditing?.(e)
|
|
205
230
|
}
|
|
206
|
-
}
|
|
207
231
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
232
|
+
// Handle selection change
|
|
233
|
+
const handleSelectionChange = (e: any) => {
|
|
234
|
+
onSelectionChange?.(e)
|
|
211
235
|
}
|
|
212
|
-
onSubmitEditing?.(e)
|
|
213
|
-
}
|
|
214
236
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
237
|
+
const finalProps: any = {
|
|
238
|
+
...rest,
|
|
239
|
+
editable: !disabled && !readOnly,
|
|
240
|
+
secureTextEntry,
|
|
241
|
+
keyboardType,
|
|
242
|
+
keyboardAppearance,
|
|
243
|
+
inputMode,
|
|
244
|
+
returnKeyType,
|
|
245
|
+
multiline,
|
|
246
|
+
numberOfLines,
|
|
247
|
+
selection,
|
|
248
|
+
autoComplete: autoComplete as any,
|
|
249
|
+
autoFocus: autoFocusNative,
|
|
219
250
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
multiline,
|
|
229
|
-
numberOfLines,
|
|
230
|
-
selection,
|
|
231
|
-
autoComplete: autoComplete as any,
|
|
232
|
-
autoFocus: autoFocusNative,
|
|
251
|
+
// callbacks
|
|
252
|
+
onChangeText: handleChangeText,
|
|
253
|
+
onKeyPress: onKeyPressProp || onKeyDown ? handleKeyPress : undefined,
|
|
254
|
+
onSubmitEditing: onKeyDown || onSubmitEditing ? handleSubmitEditing : undefined,
|
|
255
|
+
onSelectionChange: onSelectionChange ? handleSelectionChange : undefined,
|
|
256
|
+
onEndEditing,
|
|
257
|
+
onContentSizeChange,
|
|
258
|
+
onScroll,
|
|
233
259
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
260
|
+
// cross-platform native props
|
|
261
|
+
submitBehavior,
|
|
262
|
+
blurOnSubmit,
|
|
263
|
+
caretHidden,
|
|
264
|
+
contextMenuHidden,
|
|
265
|
+
selectTextOnFocus,
|
|
266
|
+
maxFontSizeMultiplier,
|
|
267
|
+
allowFontScaling,
|
|
268
|
+
autoCapitalize,
|
|
269
|
+
autoCorrect,
|
|
270
|
+
textContentType,
|
|
242
271
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
272
|
+
// iOS-only props
|
|
273
|
+
clearButtonMode,
|
|
274
|
+
clearTextOnFocus,
|
|
275
|
+
enablesReturnKeyAutomatically,
|
|
276
|
+
dataDetectorTypes,
|
|
277
|
+
scrollEnabled,
|
|
278
|
+
passwordRules,
|
|
279
|
+
rejectResponderTermination,
|
|
280
|
+
spellCheck,
|
|
281
|
+
lineBreakStrategyIOS,
|
|
282
|
+
lineBreakModeIOS,
|
|
283
|
+
smartInsertDelete,
|
|
284
|
+
inputAccessoryViewID,
|
|
285
|
+
inputAccessoryViewButtonLabel,
|
|
286
|
+
disableKeyboardShortcuts,
|
|
254
287
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
lineBreakModeIOS,
|
|
266
|
-
smartInsertDelete,
|
|
267
|
-
inputAccessoryViewID,
|
|
268
|
-
inputAccessoryViewButtonLabel,
|
|
269
|
-
disableKeyboardShortcuts,
|
|
288
|
+
// Android-only props
|
|
289
|
+
importantForAutofill,
|
|
290
|
+
disableFullscreenUI,
|
|
291
|
+
inlineImageLeft,
|
|
292
|
+
inlineImagePadding,
|
|
293
|
+
returnKeyLabel,
|
|
294
|
+
textBreakStrategy,
|
|
295
|
+
textAlignVertical,
|
|
296
|
+
verticalAlign,
|
|
297
|
+
showSoftInputOnFocus,
|
|
270
298
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
returnKeyLabel,
|
|
277
|
-
textBreakStrategy,
|
|
278
|
-
textAlignVertical,
|
|
279
|
-
verticalAlign,
|
|
280
|
-
showSoftInputOnFocus,
|
|
281
|
-
}
|
|
299
|
+
// caretColor → cursorColor (Android) + selectionColor (iOS+Android),
|
|
300
|
+
// unless the caller passed those explicitly.
|
|
301
|
+
cursorColor: cursorColorProp ?? caretColor,
|
|
302
|
+
selectionColor: selectionColorProp ?? caretColor,
|
|
303
|
+
}
|
|
282
304
|
|
|
283
|
-
|
|
284
|
-
}
|
|
305
|
+
return <StyledInput ref={composedRef} {...finalProps} />
|
|
306
|
+
}
|
|
307
|
+
)
|