@expo/ui 55.0.10 → 55.0.11

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 (75) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +11 -7
  4. package/android/src/main/java/expo/modules/ui/TextFieldView.kt +326 -0
  5. package/build/jetpack-compose/SlotView.d.ts +7 -0
  6. package/build/jetpack-compose/SlotView.d.ts.map +1 -0
  7. package/build/jetpack-compose/TextField/index.d.ts +177 -0
  8. package/build/jetpack-compose/TextField/index.d.ts.map +1 -0
  9. package/build/jetpack-compose/index.d.ts +1 -1
  10. package/build/swift-ui/SecureField/index.d.ts +9 -20
  11. package/build/swift-ui/SecureField/index.d.ts.map +1 -1
  12. package/build/swift-ui/TextField/index.d.ts +17 -63
  13. package/build/swift-ui/TextField/index.d.ts.map +1 -1
  14. package/build/swift-ui/modifiers/index.d.ts +35 -4
  15. package/build/swift-ui/modifiers/index.d.ts.map +1 -1
  16. package/expo-module.config.json +1 -1
  17. package/ios/Modifiers/KeyboardTypeModifier.swift +68 -0
  18. package/ios/Modifiers/LineLimitModifier.swift +29 -0
  19. package/ios/Modifiers/OnSubmitModifier.swift +21 -0
  20. package/ios/Modifiers/ViewModifierRegistry.swift +12 -8
  21. package/ios/SecureFieldView.swift +5 -12
  22. package/ios/TextFieldView.swift +26 -94
  23. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.10/expo.modules.ui-55.0.10-sources.jar → 55.0.11/expo.modules.ui-55.0.11-sources.jar} +0 -0
  24. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11-sources.jar.md5 +1 -0
  25. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11-sources.jar.sha1 +1 -0
  26. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11-sources.jar.sha256 +1 -0
  27. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11-sources.jar.sha512 +1 -0
  28. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.aar +0 -0
  29. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.aar.md5 +1 -0
  30. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.aar.sha1 +1 -0
  31. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.aar.sha256 +1 -0
  32. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.aar.sha512 +1 -0
  33. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.10/expo.modules.ui-55.0.10.module → 55.0.11/expo.modules.ui-55.0.11.module} +22 -22
  34. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.module.md5 +1 -0
  35. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.module.sha1 +1 -0
  36. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.module.sha256 +1 -0
  37. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.module.sha512 +1 -0
  38. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.10/expo.modules.ui-55.0.10.pom → 55.0.11/expo.modules.ui-55.0.11.pom} +1 -1
  39. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.pom.md5 +1 -0
  40. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.pom.sha1 +1 -0
  41. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.pom.sha256 +1 -0
  42. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.11/expo.modules.ui-55.0.11.pom.sha512 +1 -0
  43. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
  44. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
  45. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
  46. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
  47. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
  48. package/package.json +2 -2
  49. package/src/jetpack-compose/SlotView.tsx +15 -0
  50. package/src/jetpack-compose/TextField/index.tsx +276 -0
  51. package/src/jetpack-compose/index.ts +1 -1
  52. package/src/swift-ui/SecureField/index.tsx +18 -36
  53. package/src/swift-ui/TextField/index.tsx +30 -91
  54. package/src/swift-ui/modifiers/index.ts +63 -3
  55. package/android/src/main/java/expo/modules/ui/TextInputView.kt +0 -124
  56. package/build/jetpack-compose/TextInput/index.d.ts +0 -105
  57. package/build/jetpack-compose/TextInput/index.d.ts.map +0 -1
  58. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10-sources.jar.md5 +0 -1
  59. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10-sources.jar.sha1 +0 -1
  60. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10-sources.jar.sha256 +0 -1
  61. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10-sources.jar.sha512 +0 -1
  62. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.aar +0 -0
  63. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.aar.md5 +0 -1
  64. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.aar.sha1 +0 -1
  65. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.aar.sha256 +0 -1
  66. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.aar.sha512 +0 -1
  67. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.module.md5 +0 -1
  68. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.module.sha1 +0 -1
  69. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.module.sha256 +0 -1
  70. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.module.sha512 +0 -1
  71. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.pom.md5 +0 -1
  72. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.pom.sha1 +0 -1
  73. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.pom.sha256 +0 -1
  74. package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.10/expo.modules.ui-55.0.10.pom.sha512 +0 -1
  75. package/src/jetpack-compose/TextInput/index.tsx +0 -157
@@ -1,124 +0,0 @@
1
- package expo.modules.ui
2
-
3
- import android.annotation.SuppressLint
4
- import android.content.Context
5
- import androidx.compose.foundation.text.KeyboardOptions
6
- import androidx.compose.material3.OutlinedTextField
7
- import androidx.compose.material3.Text
8
- import androidx.compose.material3.TextField
9
- import androidx.compose.runtime.Composable
10
- import androidx.compose.runtime.MutableState
11
- import androidx.compose.runtime.mutableStateOf
12
- import androidx.compose.ui.text.input.KeyboardCapitalization
13
- import androidx.compose.ui.text.input.KeyboardType
14
- import expo.modules.kotlin.AppContext
15
- import expo.modules.kotlin.types.Enumerable
16
- import expo.modules.kotlin.viewevent.EventDispatcher
17
- import expo.modules.kotlin.views.ComposableScope
18
- import expo.modules.kotlin.views.ComposeProps
19
- import expo.modules.kotlin.views.ExpoComposeView
20
-
21
- enum class TextInputViewVariant(val value: String) : Enumerable {
22
- FILLED("filled"),
23
- OUTLINED("outlined"),
24
- }
25
-
26
- data class TextInputProps(
27
- val defaultValue: MutableState<String> = mutableStateOf(""),
28
- val placeholder: MutableState<String> = mutableStateOf(""),
29
- val variant: MutableState<TextInputViewVariant> = mutableStateOf(TextInputViewVariant.FILLED),
30
- val multiline: MutableState<Boolean> = mutableStateOf(false),
31
- val numberOfLines: MutableState<Int?> = mutableStateOf(null),
32
- val keyboardType: MutableState<String> = mutableStateOf("default"),
33
- val autocorrection: MutableState<Boolean> = mutableStateOf(true),
34
- val autoCapitalize: MutableState<String> = mutableStateOf("none"),
35
- val modifiers: MutableState<ModifierList> = mutableStateOf(emptyList()),
36
- ) : ComposeProps
37
-
38
- private fun String.keyboardType(): KeyboardType {
39
- return when (this) {
40
- "default" -> KeyboardType.Text
41
- "numeric" -> KeyboardType.Number
42
- "email-address" -> KeyboardType.Email
43
- "phone-pad" -> KeyboardType.Phone
44
- "decimal-pad" -> KeyboardType.Decimal
45
- "password" -> KeyboardType.Password
46
- "ascii-capable" -> KeyboardType.Ascii
47
- "url" -> KeyboardType.Uri
48
- "number-password" -> KeyboardType.NumberPassword
49
- else -> KeyboardType.Text
50
- }
51
- }
52
-
53
- private fun String.autoCapitalize(): KeyboardCapitalization {
54
- return when (this) {
55
- "characters" -> KeyboardCapitalization.Characters
56
- "none" -> KeyboardCapitalization.None
57
- "sentences" -> KeyboardCapitalization.Sentences
58
- "unspecified" -> KeyboardCapitalization.Unspecified
59
- "words" -> KeyboardCapitalization.Words
60
- else -> KeyboardCapitalization.None
61
- }
62
- }
63
-
64
- @SuppressLint("ViewConstructor")
65
- class TextInputView(context: Context, appContext: AppContext) :
66
- ExpoComposeView<TextInputProps>(context, appContext) {
67
- override val props = TextInputProps()
68
- private val onValueChanged by EventDispatcher()
69
-
70
- private val textState = mutableStateOf<String?>(null)
71
-
72
- var text: String?
73
- get() = textState.value
74
- set(value) {
75
- textState.value = value
76
- onValueChanged(mapOf("value" to (value ?: "")))
77
- }
78
-
79
- @Composable
80
- override fun ComposableScope.Content() {
81
- val value = textState.value ?: props.defaultValue.value
82
- val onValueChange: (String) -> Unit = {
83
- textState.value = it
84
- onValueChanged(mapOf("value" to it))
85
- }
86
- val placeholder: @Composable () -> Unit = { Text(props.placeholder.value) }
87
- val maxLines = if (props.multiline.value) props.numberOfLines.value ?: Int.MAX_VALUE else 1
88
- val singleLine = !props.multiline.value
89
- val keyboardOptions = KeyboardOptions.Default.copy(
90
- keyboardType = props.keyboardType.value.keyboardType(),
91
- autoCorrectEnabled = props.autocorrection.value,
92
- capitalization = props.autoCapitalize.value.autoCapitalize()
93
- )
94
- val labelSlotView = findChildSlotView(this@TextInputView, "label")
95
- val label: (@Composable () -> Unit)? = labelSlotView?.let {
96
- { with(ComposableScope()) { with(it) { Content() } } }
97
- }
98
- val modifier = ModifierRegistry.applyModifiers(props.modifiers.value, appContext, this@Content, globalEventDispatcher)
99
-
100
- if (props.variant.value == TextInputViewVariant.OUTLINED) {
101
- OutlinedTextField(
102
- value = value,
103
- onValueChange = onValueChange,
104
- placeholder = placeholder,
105
- maxLines = maxLines,
106
- singleLine = singleLine,
107
- keyboardOptions = keyboardOptions,
108
- label = label,
109
- modifier = modifier
110
- )
111
- } else {
112
- TextField(
113
- value = value,
114
- onValueChange = onValueChange,
115
- placeholder = placeholder,
116
- maxLines = maxLines,
117
- singleLine = singleLine,
118
- keyboardOptions = keyboardOptions,
119
- label = label,
120
- modifier = modifier
121
- )
122
- }
123
- }
124
- }
@@ -1,105 +0,0 @@
1
- import { Ref } from 'react';
2
- import { ExpoModifier, ViewEvent } from '../../types';
3
- /**
4
- * @hidden Not used anywhere yet.
5
- */
6
- export type TextInputRole = 'default' | 'cancel' | 'destructive';
7
- export type TextInputRef = {
8
- setText: (newText: string) => Promise<void>;
9
- };
10
- export type TextInputVariant = 'filled' | 'outlined';
11
- export type TextInputProps = {
12
- /**
13
- * Can be used for imperatively setting text on the TextInput component.
14
- */
15
- ref?: Ref<TextInputRef>;
16
- /**
17
- * Initial value that the TextInput displays when being mounted. As the TextInput is an uncontrolled component, change the key prop if you need to change the text value.
18
- */
19
- defaultValue?: string;
20
- /**
21
- * The visual style of the text input field.
22
- * - `filled` - A text field with a filled background (default).
23
- * - `outlined` - A text field with a transparent background and a border outline.
24
- * @default filled
25
- * @platform android
26
- */
27
- variant?: TextInputVariant;
28
- /**
29
- * A callback triggered when user types in text into the TextInput.
30
- */
31
- onChangeText: (value: string) => void;
32
- /**
33
- * If true, the text input can be multiple lines.
34
- * While the content will wrap, there's no keyboard button to insert a new line.
35
- */
36
- multiline?: boolean;
37
- /**
38
- * The number of lines to display when `multiline` is set to true.
39
- * If the number of lines in the view is above this number, the view scrolls.
40
- * @default undefined, which means unlimited lines.
41
- */
42
- numberOfLines?: number;
43
- /**
44
- * Determines which keyboard to open. For example, `'numeric'`.
45
- *
46
- * Available options:
47
- * - default
48
- * - numeric
49
- * - email-address
50
- * - phone-pad
51
- * - decimal-pad
52
- * - ascii-capable
53
- * - url
54
- * - password
55
- * - password-numeric
56
- *
57
- * @default default
58
- */
59
- keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'ascii-capable' | 'url' | 'decimal-pad';
60
- /**
61
- * If true, autocorrection is enabled.
62
- * @default true
63
- */
64
- autocorrection?: boolean;
65
- /**
66
- * Options to request software keyboard to capitalize the text. Applies to languages which has upper-case and lower-case letters.
67
- *
68
- * Available options:
69
- * - `characters`: Capitalize all characters.
70
- * - `none`: Do not auto-capitalize text.
71
- * - `sentences`: Capitalize the first character of each sentence.
72
- * - `unspecified`: Capitalization behavior is not specified.
73
- * - `words`: Capitalize the first character of every word.
74
- * @default none
75
- * @platform android
76
- */
77
- autoCapitalize?: 'characters' | 'none' | 'sentences' | 'unspecified' | 'words';
78
- /**
79
- * Placeholder text shown inside the field when empty and focused.
80
- *
81
- */
82
- placeholder?: string;
83
- /** Modifiers for the component */
84
- modifiers?: ExpoModifier[];
85
- /**
86
- * Slot children (e.g. `TextInput.Label`).
87
- */
88
- children?: React.ReactNode;
89
- };
90
- export type NativeTextInputProps = Omit<TextInputProps, 'onChangeText' | 'children'> & {
91
- children?: React.ReactNode;
92
- } & ViewEvent<'onValueChanged', {
93
- value: string;
94
- }>;
95
- /**
96
- * Renders a `TextInput` component.
97
- */
98
- declare function TextInputComponent(props: TextInputProps): import("react").JSX.Element;
99
- declare namespace TextInputComponent {
100
- var Label: (props: {
101
- children: React.ReactNode;
102
- }) => import("react").JSX.Element;
103
- }
104
- export { TextInputComponent as TextInput };
105
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jetpack-compose/TextInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAatD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EACT,SAAS,GACT,eAAe,GACf,SAAS,GACT,WAAW,GACX,eAAe,GACf,KAAK,GACL,aAAa,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,aAAa,GAAG,OAAO,CAAC;IAC/E;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,EAAE,cAAc,GAAG,UAAU,CAAC,GAAG;IACrF,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,GAAG,SAAS,CAAC,gBAAgB,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AA+BnD;;GAEG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAAE,cAAc,+BAEhD;kBAFQ,kBAAkB;uBAPL;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;AAanD,OAAO,EAAE,kBAAkB,IAAI,SAAS,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- 0fb41718cf502bf1bd5bfeefef2497a791ec4067
@@ -1 +0,0 @@
1
- 6f17f489b1f61bda39b7219a16731839a2436678e8e1258f862b6f126229a160
@@ -1 +0,0 @@
1
- d9c690394b14a26e66a9e2520000d48ab9d98163b4495ff3acf0be27d3c285e3f3c11a4e9843c124d9bbf1d8da51064956af5f3fd7f11e4775ef5d6d32a2487b
@@ -1 +0,0 @@
1
- 47a9ad9a4255f9c8a380708a52ffe51ccba93762
@@ -1 +0,0 @@
1
- 0cc100bb063457e6e0be298e51fd87edbe497d86fcf01f7f4e32b83ba71ee443
@@ -1 +0,0 @@
1
- 6eabbcc0f2c5ca30426dc5325e8d02ee5cd43c5c2d3660996b29d5344b609532e4cc79251162be6974dcc54c5722c50b54d59ce0ea8b422db6c1efb5a460c830
@@ -1 +0,0 @@
1
- 6d6684e1477f090289e93eeb36134bef87067815
@@ -1 +0,0 @@
1
- a4367d937fc3d4c24a47dd610db00620480a3ef4788c4c11c42dcc3b318182cd
@@ -1 +0,0 @@
1
- 61e1749ec59eb2f5b91bfd897c2f782fd94351c84c089d9539796d3dd4ff4dccba64432c5c750f378f23c75c0f478bccdeaea13101a91bc69e42bf3273c34331
@@ -1 +0,0 @@
1
- 3f56e5cc5f3650a11784c84f714595c023a99daf
@@ -1 +0,0 @@
1
- 889146699fd5faafc6fc87e3468a2ca4d5d22de6969ea2117a4615dd94f882a7
@@ -1 +0,0 @@
1
- e2ec38ff5380b28bf629f0a1d1c103e7bec3e5985250a2b9a947028d49d515e644f5f44cda6d67002e2b0cf0cc80d57b1d65968dac3c67a7cd1f0d2bd636d4e4
@@ -1,157 +0,0 @@
1
- import { requireNativeView } from 'expo';
2
- import { Ref } from 'react';
3
-
4
- import { ExpoModifier, ViewEvent } from '../../types';
5
- import { createViewModifierEventListener } from '../modifiers/utils';
6
-
7
- type SlotNativeViewProps = {
8
- slotName: string;
9
- children: React.ReactNode;
10
- };
11
-
12
- const SlotNativeView: React.ComponentType<SlotNativeViewProps> = requireNativeView(
13
- 'ExpoUI',
14
- 'SlotView'
15
- );
16
-
17
- /**
18
- * @hidden Not used anywhere yet.
19
- */
20
- export type TextInputRole = 'default' | 'cancel' | 'destructive';
21
-
22
- export type TextInputRef = {
23
- setText: (newText: string) => Promise<void>;
24
- };
25
-
26
- export type TextInputVariant = 'filled' | 'outlined';
27
-
28
- export type TextInputProps = {
29
- /**
30
- * Can be used for imperatively setting text on the TextInput component.
31
- */
32
- ref?: Ref<TextInputRef>;
33
- /**
34
- * Initial value that the TextInput displays when being mounted. As the TextInput is an uncontrolled component, change the key prop if you need to change the text value.
35
- */
36
- defaultValue?: string;
37
- /**
38
- * The visual style of the text input field.
39
- * - `filled` - A text field with a filled background (default).
40
- * - `outlined` - A text field with a transparent background and a border outline.
41
- * @default filled
42
- * @platform android
43
- */
44
- variant?: TextInputVariant;
45
- /**
46
- * A callback triggered when user types in text into the TextInput.
47
- */
48
- onChangeText: (value: string) => void;
49
- /**
50
- * If true, the text input can be multiple lines.
51
- * While the content will wrap, there's no keyboard button to insert a new line.
52
- */
53
- multiline?: boolean;
54
- /**
55
- * The number of lines to display when `multiline` is set to true.
56
- * If the number of lines in the view is above this number, the view scrolls.
57
- * @default undefined, which means unlimited lines.
58
- */
59
- numberOfLines?: number;
60
- /**
61
- * Determines which keyboard to open. For example, `'numeric'`.
62
- *
63
- * Available options:
64
- * - default
65
- * - numeric
66
- * - email-address
67
- * - phone-pad
68
- * - decimal-pad
69
- * - ascii-capable
70
- * - url
71
- * - password
72
- * - password-numeric
73
- *
74
- * @default default
75
- */
76
- keyboardType?:
77
- | 'default'
78
- | 'email-address'
79
- | 'numeric'
80
- | 'phone-pad'
81
- | 'ascii-capable'
82
- | 'url'
83
- | 'decimal-pad';
84
- /**
85
- * If true, autocorrection is enabled.
86
- * @default true
87
- */
88
- autocorrection?: boolean;
89
- /**
90
- * Options to request software keyboard to capitalize the text. Applies to languages which has upper-case and lower-case letters.
91
- *
92
- * Available options:
93
- * - `characters`: Capitalize all characters.
94
- * - `none`: Do not auto-capitalize text.
95
- * - `sentences`: Capitalize the first character of each sentence.
96
- * - `unspecified`: Capitalization behavior is not specified.
97
- * - `words`: Capitalize the first character of every word.
98
- * @default none
99
- * @platform android
100
- */
101
- autoCapitalize?: 'characters' | 'none' | 'sentences' | 'unspecified' | 'words';
102
- /**
103
- * Placeholder text shown inside the field when empty and focused.
104
- *
105
- */
106
- placeholder?: string;
107
- /** Modifiers for the component */
108
- modifiers?: ExpoModifier[];
109
- /**
110
- * Slot children (e.g. `TextInput.Label`).
111
- */
112
- children?: React.ReactNode;
113
- };
114
-
115
- export type NativeTextInputProps = Omit<TextInputProps, 'onChangeText' | 'children'> & {
116
- children?: React.ReactNode;
117
- } & ViewEvent<'onValueChanged', { value: string }>;
118
-
119
- // We have to work around the `role` and `onPress` props being reserved by React Native.
120
- const TextInputNativeView: React.ComponentType<NativeTextInputProps> = requireNativeView(
121
- 'ExpoUI',
122
- 'TextInputView'
123
- );
124
-
125
- function transformTextInputProps(props: TextInputProps): NativeTextInputProps {
126
- const { modifiers, children, ...restProps } = props;
127
- return {
128
- modifiers,
129
- ...(modifiers ? createViewModifierEventListener(modifiers) : undefined),
130
- ...restProps,
131
- children,
132
- onValueChanged: (event) => {
133
- props.onChangeText?.(event.nativeEvent.value);
134
- },
135
- };
136
- }
137
-
138
- /**
139
- * A label slot for `TextInput`.
140
- * The label floats above the text field when focused or filled.
141
- *
142
- * @platform android
143
- */
144
- function Label(props: { children: React.ReactNode }) {
145
- return <SlotNativeView slotName="label">{props.children}</SlotNativeView>;
146
- }
147
-
148
- /**
149
- * Renders a `TextInput` component.
150
- */
151
- function TextInputComponent(props: TextInputProps) {
152
- return <TextInputNativeView {...transformTextInputProps(props)} />;
153
- }
154
-
155
- TextInputComponent.Label = Label;
156
-
157
- export { TextInputComponent as TextInput };