You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,16 @@
2
2
3
3
TextInput component that allows transforming text synchronously with a worklet.
4
4
5
+
## Motivation
6
+
7
+
Transforming input as users type is common—phone numbers, credit cards, usernames. Existing approaches have trade-offs:
8
+
9
+
**Pattern-based masking** (e.g., [react-native-advanced-input-mask](https://github.com/IvanIhnatsiuk/react-native-advanced-input-mask)) uses declarative patterns like `+1 ([000]) [000]-[0000]`. This works well for fixed formats, but patterns can't express conditional logic, variable-length formats, or transformations that depend on context.
10
+
11
+
**Controlled inputs** (`value` + `onChangeText` + state) give you full JS flexibility, but create a native → JS → re-render → native round-trip. This causes visible lag and cursor flicker—the input feels sluggish because keystrokes are corrected asynchronously.
12
+
13
+
**This library** combines JS flexibility with synchronous execution. Your transform runs as a worklet on the UI thread—no bridge delay, no flicker. Write any logic you need with the responsiveness of a native input.
14
+
5
15
## Installation
6
16
```sh
7
17
npm install react-native-transformer-text-input
@@ -98,6 +108,29 @@ Default behavior when no `selection` is returned:
98
108
99
109
The library includes ready-to-use transformers for common use cases.
100
110
111
+
### PatternTransformer
112
+
113
+
Formats input using a pattern string with placeholder characters.
-`showTrailingLiterals`: Show literal characters after the last input (default: `false`).
133
+
101
134
### PhoneNumberTransformer
102
135
103
136
Formats phone numbers as the user types.
@@ -123,7 +156,7 @@ Code in this repository is thought through and mostly written by humans, with AI
123
156
124
157
## Acknowledgments
125
158
126
-
-[react-native-live-markdown](https://github.com/Expensify/react-native-live-markdown)for an example of how to extend TextInput.
159
+
-[react-native-live-markdown](https://github.com/Expensify/react-native-live-markdown)and [react-native-advanced-input-mask](https://github.com/IvanIhnatsiuk/react-native-advanced-input-mask) for examples of how to extend TextInput.
127
160
-[react-native-worklets](https://github.com/software-mansion/react-native-reanimated/tree/main/packages/react-native-worklets) for the worklet runtime powering UI-thread execution.
0 commit comments