@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.
Files changed (168) hide show
  1. package/dist/cjs/Input.cjs +78 -162
  2. package/dist/cjs/Input.native.cjs +209 -0
  3. package/dist/cjs/Input.native.js +186 -282
  4. package/dist/cjs/Input.native.js.map +1 -1
  5. package/dist/cjs/InputNativeProps.cjs +10 -11
  6. package/dist/cjs/InputNativeProps.native.cjs +19 -0
  7. package/dist/cjs/InputNativeProps.native.js +10 -10
  8. package/dist/cjs/InputNativeProps.native.js.map +1 -1
  9. package/dist/cjs/TextArea.cjs +25 -38
  10. package/dist/cjs/TextArea.native.cjs +41 -0
  11. package/dist/cjs/TextArea.native.js +25 -37
  12. package/dist/cjs/TextArea.native.js.map +1 -1
  13. package/dist/cjs/index.cjs +16 -17
  14. package/dist/cjs/index.native.cjs +33 -0
  15. package/dist/cjs/index.native.js +16 -16
  16. package/dist/cjs/index.native.js.map +1 -1
  17. package/dist/cjs/shared.cjs +115 -122
  18. package/dist/cjs/shared.native.cjs +144 -0
  19. package/dist/cjs/shared.native.js +120 -126
  20. package/dist/cjs/shared.native.js.map +1 -1
  21. package/dist/cjs/types.cjs +10 -11
  22. package/dist/cjs/types.native.cjs +19 -0
  23. package/dist/cjs/types.native.js +10 -10
  24. package/dist/cjs/types.native.js.map +1 -1
  25. package/dist/esm/Input.mjs +63 -137
  26. package/dist/esm/Input.mjs.map +1 -1
  27. package/dist/esm/Input.native.js +172 -259
  28. package/dist/esm/Input.native.js.map +1 -1
  29. package/dist/esm/InputNativeProps.mjs +0 -2
  30. package/dist/esm/InputNativeProps.native.js +0 -2
  31. package/dist/esm/TextArea.mjs +12 -20
  32. package/dist/esm/TextArea.mjs.map +1 -1
  33. package/dist/esm/TextArea.native.js +12 -20
  34. package/dist/esm/TextArea.native.js.map +1 -1
  35. package/dist/esm/index.js +6 -4
  36. package/dist/esm/index.mjs +6 -4
  37. package/dist/esm/index.native.js +6 -4
  38. package/dist/esm/shared.mjs +99 -104
  39. package/dist/esm/shared.mjs.map +1 -1
  40. package/dist/esm/shared.native.js +104 -109
  41. package/dist/esm/shared.native.js.map +1 -1
  42. package/dist/esm/types.mjs +0 -2
  43. package/dist/esm/types.native.js +0 -2
  44. package/dist/jsx/Input.mjs +63 -137
  45. package/dist/jsx/Input.mjs.map +1 -1
  46. package/dist/jsx/Input.native.cjs +209 -0
  47. package/dist/jsx/Input.native.js +186 -282
  48. package/dist/jsx/Input.native.js.map +1 -1
  49. package/dist/jsx/InputNativeProps.mjs +0 -2
  50. package/dist/jsx/InputNativeProps.native.cjs +19 -0
  51. package/dist/jsx/InputNativeProps.native.js +10 -10
  52. package/dist/jsx/InputNativeProps.native.js.map +1 -1
  53. package/dist/jsx/TextArea.mjs +12 -20
  54. package/dist/jsx/TextArea.mjs.map +1 -1
  55. package/dist/jsx/TextArea.native.cjs +41 -0
  56. package/dist/jsx/TextArea.native.js +25 -37
  57. package/dist/jsx/TextArea.native.js.map +1 -1
  58. package/dist/jsx/index.js +6 -4
  59. package/dist/jsx/index.mjs +6 -4
  60. package/dist/jsx/index.native.cjs +33 -0
  61. package/dist/jsx/index.native.js +16 -16
  62. package/dist/jsx/index.native.js.map +1 -1
  63. package/dist/jsx/shared.mjs +99 -104
  64. package/dist/jsx/shared.mjs.map +1 -1
  65. package/dist/jsx/shared.native.cjs +144 -0
  66. package/dist/jsx/shared.native.js +120 -126
  67. package/dist/jsx/shared.native.js.map +1 -1
  68. package/dist/jsx/types.mjs +0 -2
  69. package/dist/jsx/types.native.cjs +19 -0
  70. package/dist/jsx/types.native.js +10 -10
  71. package/dist/jsx/types.native.js.map +1 -1
  72. package/package.json +13 -15
  73. package/src/Input.native.tsx +263 -240
  74. package/src/Input.tsx +162 -152
  75. package/src/TextArea.tsx +6 -14
  76. package/src/shared.tsx +65 -70
  77. package/src/types.ts +1 -1
  78. package/types/Input.d.ts +57 -41
  79. package/types/Input.d.ts.map +1 -1
  80. package/types/Input.native.d.ts +57 -41
  81. package/types/Input.native.d.ts.map +1 -1
  82. package/types/TextArea.d.ts +172 -24
  83. package/types/TextArea.d.ts.map +1 -1
  84. package/types/shared.d.ts +14 -99
  85. package/types/shared.d.ts.map +1 -1
  86. package/types/types.d.ts +1 -1
  87. package/dist/cjs/inputTypes.test-d.cjs +0 -128
  88. package/dist/cjs/inputTypes.test-d.native.js +0 -131
  89. package/dist/cjs/inputTypes.test-d.native.js.map +0 -1
  90. package/dist/cjs/v1/Input.cjs +0 -200
  91. package/dist/cjs/v1/Input.native.js +0 -183
  92. package/dist/cjs/v1/Input.native.js.map +0 -1
  93. package/dist/cjs/v1/TextArea.cjs +0 -52
  94. package/dist/cjs/v1/TextArea.native.js +0 -55
  95. package/dist/cjs/v1/TextArea.native.js.map +0 -1
  96. package/dist/cjs/v1/index.cjs +0 -21
  97. package/dist/cjs/v1/index.native.js +0 -24
  98. package/dist/cjs/v1/index.native.js.map +0 -1
  99. package/dist/cjs/v1/types.cjs +0 -18
  100. package/dist/cjs/v1/types.native.js +0 -21
  101. package/dist/cjs/v1/types.native.js.map +0 -1
  102. package/dist/esm/InputNativeProps.mjs.map +0 -1
  103. package/dist/esm/InputNativeProps.native.js.map +0 -1
  104. package/dist/esm/index.js.map +0 -1
  105. package/dist/esm/index.mjs.map +0 -1
  106. package/dist/esm/index.native.js.map +0 -1
  107. package/dist/esm/inputTypes.test-d.mjs +0 -129
  108. package/dist/esm/inputTypes.test-d.mjs.map +0 -1
  109. package/dist/esm/inputTypes.test-d.native.js +0 -129
  110. package/dist/esm/inputTypes.test-d.native.js.map +0 -1
  111. package/dist/esm/types.mjs.map +0 -1
  112. package/dist/esm/types.native.js.map +0 -1
  113. package/dist/esm/v1/Input.mjs +0 -164
  114. package/dist/esm/v1/Input.mjs.map +0 -1
  115. package/dist/esm/v1/Input.native.js +0 -144
  116. package/dist/esm/v1/Input.native.js.map +0 -1
  117. package/dist/esm/v1/TextArea.mjs +0 -27
  118. package/dist/esm/v1/TextArea.mjs.map +0 -1
  119. package/dist/esm/v1/TextArea.native.js +0 -27
  120. package/dist/esm/v1/TextArea.native.js.map +0 -1
  121. package/dist/esm/v1/index.mjs +0 -3
  122. package/dist/esm/v1/index.mjs.map +0 -1
  123. package/dist/esm/v1/index.native.js +0 -3
  124. package/dist/esm/v1/index.native.js.map +0 -1
  125. package/dist/esm/v1/types.mjs +0 -2
  126. package/dist/esm/v1/types.mjs.map +0 -1
  127. package/dist/esm/v1/types.native.js +0 -2
  128. package/dist/esm/v1/types.native.js.map +0 -1
  129. package/dist/jsx/InputNativeProps.mjs.map +0 -1
  130. package/dist/jsx/index.js.map +0 -1
  131. package/dist/jsx/index.mjs.map +0 -1
  132. package/dist/jsx/inputTypes.test-d.mjs +0 -129
  133. package/dist/jsx/inputTypes.test-d.mjs.map +0 -1
  134. package/dist/jsx/inputTypes.test-d.native.js +0 -131
  135. package/dist/jsx/inputTypes.test-d.native.js.map +0 -1
  136. package/dist/jsx/types.mjs.map +0 -1
  137. package/dist/jsx/v1/Input.mjs +0 -164
  138. package/dist/jsx/v1/Input.mjs.map +0 -1
  139. package/dist/jsx/v1/Input.native.js +0 -183
  140. package/dist/jsx/v1/Input.native.js.map +0 -1
  141. package/dist/jsx/v1/TextArea.mjs +0 -27
  142. package/dist/jsx/v1/TextArea.mjs.map +0 -1
  143. package/dist/jsx/v1/TextArea.native.js +0 -55
  144. package/dist/jsx/v1/TextArea.native.js.map +0 -1
  145. package/dist/jsx/v1/index.mjs +0 -3
  146. package/dist/jsx/v1/index.mjs.map +0 -1
  147. package/dist/jsx/v1/index.native.js +0 -24
  148. package/dist/jsx/v1/index.native.js.map +0 -1
  149. package/dist/jsx/v1/types.mjs +0 -2
  150. package/dist/jsx/v1/types.mjs.map +0 -1
  151. package/dist/jsx/v1/types.native.js +0 -21
  152. package/dist/jsx/v1/types.native.js.map +0 -1
  153. package/src/inputTypes.test-d.ts +0 -245
  154. package/src/v1/Input.native.tsx +0 -153
  155. package/src/v1/Input.tsx +0 -190
  156. package/src/v1/TextArea.tsx +0 -35
  157. package/src/v1/index.ts +0 -3
  158. package/src/v1/types.ts +0 -65
  159. package/types/v1/Input.d.ts +0 -64
  160. package/types/v1/Input.d.ts.map +0 -1
  161. package/types/v1/Input.native.d.ts +0 -63
  162. package/types/v1/Input.native.d.ts.map +0 -1
  163. package/types/v1/TextArea.d.ts +0 -41
  164. package/types/v1/TextArea.d.ts.map +0 -1
  165. package/types/v1/index.d.ts +0 -4
  166. package/types/v1/index.d.ts.map +0 -1
  167. package/types/v1/types.d.ts +0 -39
  168. package/types/v1/types.d.ts.map +0 -1
@@ -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 = StyledInput.styleable<InputExtraProps>((props, forwardedRef) => {
16
- const {
17
- // Web props we need to convert
18
- type,
19
- disabled,
20
- readOnly,
21
- id,
22
- rows,
23
- autoComplete,
24
- enterKeyHint,
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
- // Callbacks
27
- onChange,
28
- onInput,
29
- onKeyDown,
30
- onChangeText,
31
- onSubmitEditing,
32
- onSelectionChange,
33
- onEndEditing,
34
- onContentSizeChange,
35
- onScroll,
36
- onKeyPress: onKeyPressProp,
37
- selection,
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
- // Native-only props (pass through directly)
40
- keyboardAppearance,
41
- returnKeyType: returnKeyTypeProp,
42
- submitBehavior,
43
- blurOnSubmit,
44
- caretHidden,
45
- contextMenuHidden,
46
- selectTextOnFocus,
47
- secureTextEntry: secureTextEntryProp,
48
- maxFontSizeMultiplier,
49
- allowFontScaling,
50
- multiline: multilineProp,
51
- keyboardType: keyboardTypeProp,
52
- inputMode: inputModeProp,
53
- autoCapitalize: autoCapitalizeProp,
54
- autoCorrect: autoCorrectProp,
55
- autoFocusNative,
56
- textContentType,
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
- // iOS-only props
59
- clearButtonMode,
60
- clearTextOnFocus,
61
- enablesReturnKeyAutomatically,
62
- dataDetectorTypes,
63
- scrollEnabled,
64
- passwordRules,
65
- rejectResponderTermination,
66
- spellCheck,
67
- lineBreakStrategyIOS,
68
- lineBreakModeIOS,
69
- smartInsertDelete,
70
- inputAccessoryViewID,
71
- inputAccessoryViewButtonLabel,
72
- disableKeyboardShortcuts,
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
- // Android-only props
75
- importantForAutofill,
76
- disableFullscreenUI,
77
- inlineImageLeft,
78
- inlineImagePadding,
79
- returnKeyLabel,
80
- textBreakStrategy,
81
- textAlignVertical,
82
- verticalAlign,
83
- showSoftInputOnFocus,
84
- numberOfLines: numberOfLinesProp,
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
- // Web-only props to filter out
87
- // @ts-ignore
88
- dirname,
89
- min,
90
- max,
91
- minLength,
92
- multiple,
93
- name,
94
- pattern,
95
- required,
96
- step,
97
- render,
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
- ...rest
100
- } = props
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
- const { ref, composedRef } = useNativeInputRef(forwardedRef)
112
+ ...rest
113
+ } = props
103
114
 
104
- // Convert web type to native props (if not explicitly overridden)
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
- // only derive from type if native props weren't explicitly set
110
- if (!secureTextEntryProp && !keyboardTypeProp && !inputModeProp) {
111
- switch (type) {
112
- case 'password':
113
- secureTextEntry = true
114
- break
115
- case 'email':
116
- keyboardType = 'email-address'
117
- inputMode = 'email'
118
- break
119
- case 'tel':
120
- keyboardType = 'phone-pad'
121
- inputMode = 'tel'
122
- break
123
- case 'number':
124
- keyboardType = 'numeric'
125
- inputMode = 'numeric'
126
- break
127
- case 'url':
128
- keyboardType = 'url'
129
- inputMode = 'url'
130
- break
131
- case 'search':
132
- inputMode = 'search'
133
- break
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
- // Use explicit returnKeyType if provided, otherwise convert enterKeyHint
138
- let returnKeyType: RNTextInputProps['returnKeyType'] = returnKeyTypeProp
139
- if (!returnKeyType && enterKeyHint) {
140
- switch (enterKeyHint) {
141
- case 'done':
142
- returnKeyType = 'done'
143
- break
144
- case 'go':
145
- returnKeyType = 'go'
146
- break
147
- case 'next':
148
- returnKeyType = 'next'
149
- break
150
- case 'search':
151
- returnKeyType = 'search'
152
- break
153
- case 'send':
154
- returnKeyType = 'send'
155
- break
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
- // Determine multiline
160
- const multiline = multilineProp ?? (render === 'textarea' || (rows && rows > 1))
161
- const numberOfLines = numberOfLinesProp ?? rows
172
+ // Determine multiline
173
+ const multiline = multilineProp ?? (render === 'textarea' || (rows && rows > 1))
174
+ const numberOfLines = numberOfLinesProp ?? rows
162
175
 
163
- // convert web-style autoCorrect string to native boolean
164
- const autoCorrect =
165
- autoCorrectProp === 'on' ? true : autoCorrectProp === 'off' ? false : autoCorrectProp
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
- // convert web-style autoCapitalize to native values
168
- const autoCapitalize =
169
- autoCapitalizeProp === 'on'
170
- ? 'sentences'
171
- : autoCapitalizeProp === 'off'
172
- ? 'none'
173
- : autoCapitalizeProp
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
- // Register focusable
176
- React.useEffect(() => {
177
- if (!id || disabled) return
178
- return registerFocusable(id, {
179
- focusAndSelect: () => ref.current?.focus(),
180
- focus: () => ref.current?.focus(),
181
- })
182
- }, [id, disabled])
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
- // Handle web onChange/onInput -> native onChangeText
185
- const handleChangeText = (text: string) => {
186
- onChangeText?.(text)
187
- if (onChange) {
188
- onChange({ target: { value: text }, type: 'change' } as any)
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
- if (onInput) {
191
- onInput({ target: { value: text }, type: 'input' } as any)
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
- // Handle onKeyDown via onKeyPress + onSubmitEditing
196
- const handleKeyPress = (e: any) => {
197
- // call user's onKeyPress first
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
- const handleSubmitEditing = (e: any) => {
209
- if (onKeyDown) {
210
- onKeyDown({ key: 'Enter', type: 'keydown' } as any)
232
+ // Handle selection change
233
+ const handleSelectionChange = (e: any) => {
234
+ onSelectionChange?.(e)
211
235
  }
212
- onSubmitEditing?.(e)
213
- }
214
236
 
215
- // Handle selection change
216
- const handleSelectionChange = (e: any) => {
217
- onSelectionChange?.(e)
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
- const finalProps: any = {
221
- ...rest,
222
- editable: !disabled && !readOnly,
223
- secureTextEntry,
224
- keyboardType,
225
- keyboardAppearance,
226
- inputMode,
227
- returnKeyType,
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
- // callbacks
235
- onChangeText: handleChangeText,
236
- onKeyPress: onKeyPressProp || onKeyDown ? handleKeyPress : undefined,
237
- onSubmitEditing: onKeyDown || onSubmitEditing ? handleSubmitEditing : undefined,
238
- onSelectionChange: onSelectionChange ? handleSelectionChange : undefined,
239
- onEndEditing,
240
- onContentSizeChange,
241
- onScroll,
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
- // cross-platform native props
244
- submitBehavior,
245
- blurOnSubmit,
246
- caretHidden,
247
- contextMenuHidden,
248
- selectTextOnFocus,
249
- maxFontSizeMultiplier,
250
- allowFontScaling,
251
- autoCapitalize,
252
- autoCorrect,
253
- textContentType,
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
- // iOS-only props
256
- clearButtonMode,
257
- clearTextOnFocus,
258
- enablesReturnKeyAutomatically,
259
- dataDetectorTypes,
260
- scrollEnabled,
261
- passwordRules,
262
- rejectResponderTermination,
263
- spellCheck,
264
- lineBreakStrategyIOS,
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
- // Android-only props
272
- importantForAutofill,
273
- disableFullscreenUI,
274
- inlineImageLeft,
275
- inlineImagePadding,
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
- return <StyledInput ref={composedRef} {...finalProps} />
284
- })
305
+ return <StyledInput ref={composedRef} {...finalProps} />
306
+ }
307
+ )