react-native-nitro-input 0.1.0
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/CHANGELOG.md +63 -0
- package/LICENSE +21 -0
- package/NitroInput.podspec +54 -0
- package/README.md +524 -0
- package/android/CMakeLists.txt +52 -0
- package/android/build.gradle +158 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/JAmountFormatter.cpp +70 -0
- package/android/src/main/cpp/JAmountFormatter.hpp +45 -0
- package/android/src/main/cpp/JMaskEngine.cpp +81 -0
- package/android/src/main/cpp/JMaskEngine.hpp +52 -0
- package/android/src/main/cpp/JMorphEngine.cpp +132 -0
- package/android/src/main/cpp/JMorphEngine.hpp +54 -0
- package/android/src/main/cpp/JNitroInputWorklets.cpp +83 -0
- package/android/src/main/cpp/JNitroInputWorklets.hpp +40 -0
- package/android/src/main/cpp/JOutlineGeometry.cpp +58 -0
- package/android/src/main/cpp/JOutlineGeometry.hpp +55 -0
- package/android/src/main/cpp/cpp-adapter.cpp +19 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/AmountFormatter.kt +35 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +730 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/MaskEngine.kt +50 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/MorphEngine.kt +47 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputPackage.kt +24 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +2176 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputWorklets.kt +34 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/OutlineGeometry.kt +71 -0
- package/cpp/AmountFormatter.cpp +346 -0
- package/cpp/AmountFormatter.hpp +88 -0
- package/cpp/MaskEngine.cpp +596 -0
- package/cpp/MaskEngine.hpp +136 -0
- package/cpp/MorphEngine.cpp +904 -0
- package/cpp/MorphEngine.hpp +213 -0
- package/cpp/OutlineGeometry.cpp +159 -0
- package/cpp/OutlineGeometry.hpp +107 -0
- package/cpp/worklets/HybridNitroInputWorklets.cpp +30 -0
- package/cpp/worklets/HybridNitroInputWorklets.hpp +30 -0
- package/cpp/worklets/NitroInputWorkletsBridge.cpp +203 -0
- package/cpp/worklets/NitroInputWorkletsBridge.hpp +52 -0
- package/cpp/worklets/NitroInputWorkletsBridgeJSI.hpp +23 -0
- package/ios/HybridMorphInputView.swift +710 -0
- package/ios/NitroInputCommands.mm +66 -0
- package/ios/NitroInputView.swift +2600 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +101 -0
- package/lib/commonjs/src/MorphInput.js +42 -0
- package/lib/commonjs/src/NitroInput.js +623 -0
- package/lib/commonjs/src/index.js +12 -0
- package/lib/commonjs/src/specs/NitroInput.nitro.js +2 -0
- package/lib/commonjs/src/specs/NitroInputWorklets.nitro.js +2 -0
- package/lib/commonjs/src/useNitroInputState.js +58 -0
- package/lib/commonjs/src/worklets.js +226 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +101 -0
- package/lib/module/package.json +1 -0
- package/lib/module/src/MorphInput.js +6 -0
- package/lib/module/src/NitroInput.js +584 -0
- package/lib/module/src/index.js +4 -0
- package/lib/module/src/specs/NitroInput.nitro.js +1 -0
- package/lib/module/src/specs/NitroInputWorklets.nitro.js +1 -0
- package/lib/module/src/useNitroInputState.js +55 -0
- package/lib/module/src/worklets.js +214 -0
- package/lib/typescript/src/MorphInput.d.ts +18 -0
- package/lib/typescript/src/NitroInput.d.ts +411 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +390 -0
- package/lib/typescript/src/specs/NitroInputWorklets.nitro.d.ts +15 -0
- package/lib/typescript/src/useNitroInputState.d.ts +55 -0
- package/lib/typescript/src/worklets.d.ts +117 -0
- package/nitro.json +37 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +84 -0
- package/nitrogen/generated/android/NitroInput+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +78 -0
- package/nitrogen/generated/android/NitroInputOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_double.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__string_std__string_bool.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +1073 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +254 -0
- package/nitrogen/generated/android/c++/JNitroInputAffixAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroInputAutoCapitalize.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroInputEasing.hpp +67 -0
- package/nitrogen/generated/android/c++/JNitroInputEffect.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputKeyboardAppearance.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputKeyboardType.hpp +79 -0
- package/nitrogen/generated/android/c++/JNitroInputLabelBehavior.hpp +58 -0
- package/nitrogen/generated/android/c++/JNitroInputMode.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputNotation.hpp +65 -0
- package/nitrogen/generated/android/c++/JNitroInputReturnKeyType.hpp +70 -0
- package/nitrogen/generated/android/c++/JNitroInputSignPlacement.hpp +58 -0
- package/nitrogen/generated/android/c++/JNitroInputSubmitBehavior.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputTextAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroInputTextAlignVertical.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroInputVariant.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +529 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_bool.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_double_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_std__string.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_std__string_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_std__string_std__string_std__string_bool.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +711 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputAffixAlign.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputAutoCapitalize.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputEasing.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputEffect.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputKeyboardAppearance.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputKeyboardType.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputLabelBehavior.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputMode.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputNotation.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputReturnKeyType.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSignPlacement.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSubmitBehavior.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputTextAlign.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputTextAlignVertical.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputVariant.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroInputViewManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroInputViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroInput+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +81 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +348 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +92 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +43 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +769 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +690 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_std__string_std__string_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +154 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +1454 -0
- package/nitrogen/generated/ios/swift/NitroInputAffixAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroInputAutoCapitalize.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroInputEasing.swift +52 -0
- package/nitrogen/generated/ios/swift/NitroInputEffect.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroInputKeyboardAppearance.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroInputKeyboardType.swift +68 -0
- package/nitrogen/generated/ios/swift/NitroInputLabelBehavior.swift +40 -0
- package/nitrogen/generated/ios/swift/NitroInputMode.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroInputNotation.swift +39 -0
- package/nitrogen/generated/ios/swift/NitroInputReturnKeyType.swift +56 -0
- package/nitrogen/generated/ios/swift/NitroInputSignPlacement.swift +40 -0
- package/nitrogen/generated/ios/swift/NitroInputSubmitBehavior.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroInputTextAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroInputTextAlignVertical.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroInputVariant.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +213 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +300 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputWorkletsSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputWorkletsSpec.hpp +62 -0
- package/nitrogen/generated/shared/c++/NitroInputAffixAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroInputAutoCapitalize.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroInputEasing.hpp +88 -0
- package/nitrogen/generated/shared/c++/NitroInputEffect.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroInputKeyboardAppearance.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroInputKeyboardType.hpp +104 -0
- package/nitrogen/generated/shared/c++/NitroInputLabelBehavior.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroInputMode.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroInputNotation.hpp +91 -0
- package/nitrogen/generated/shared/c++/NitroInputReturnKeyType.hpp +92 -0
- package/nitrogen/generated/shared/c++/NitroInputSignPlacement.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroInputSubmitBehavior.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroInputTextAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroInputTextAlignVertical.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroInputVariant.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +216 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +374 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +101 -0
- package/package.json +141 -0
- package/react-native.config.js +16 -0
- package/src/MorphInput.tsx +30 -0
- package/src/NitroInput.tsx +1364 -0
- package/src/index.ts +55 -0
- package/src/specs/NitroInput.nitro.ts +436 -0
- package/src/specs/NitroInputWorklets.nitro.ts +13 -0
- package/src/useNitroInputState.ts +101 -0
- package/src/worklets.ts +300 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
- Memory: a dropped field is freed when Fabric drops it. The Nitro hybrid
|
|
6
|
+
behind a view is kept alive by its C++ part until the JS handle from
|
|
7
|
+
`hybridRef` is garbage-collected, and Hermes collects a handle it takes for
|
|
8
|
+
an empty object only when the JS heap fills up. On Android the hybrid held
|
|
9
|
+
the platform view, so in a mount/unmount loop on a Galaxy A22 every dropped
|
|
10
|
+
field stayed allocated (about 60 live `View`s more per cycle, linear). Now
|
|
11
|
+
the Android hybrid lets go of its view on drop (unless Fabric is recycling
|
|
12
|
+
it); iOS pools and reuses the component view. The hybrid reports its
|
|
13
|
+
`memorySize` to Nitro so the handle is collected in time, and `dispose()`
|
|
14
|
+
on the ref stops the animation eagerly, as a drop does.
|
|
15
|
+
- An unset colour is sent as `Infinity`, not `NaN`: Nitro only calls a native
|
|
16
|
+
setter when a prop's value changed, and NaN never equals itself, so every
|
|
17
|
+
render of a controlled field (every keystroke) re-set the colours and had
|
|
18
|
+
the whole configuration applied again. Native already read a non-finite
|
|
19
|
+
colour as the platform default.
|
|
20
|
+
|
|
21
|
+
- Initial release: native single-line text / amount input (iOS + Android) with Torph-style text morphing, built with Nitro Modules.
|
|
22
|
+
- One shared C++ engine (`cpp/MorphEngine`): caret matching for edits (grouping separators paired from the units end), place matching for programmatic sets, longest-common-subsequence for text; digits slide through the line box, separators from below, text fades and scales; entering and leaving characters ride with their nearest persisting neighbour; `expo` / `easeOut` / `easeInOut` / `linear` / `spring` timing; Reduce Motion snaps.
|
|
23
|
+
- `mode="number"`: every edit is formatted natively before a frame is drawn (`cpp/AmountFormatter`): grouping, one decimal, `fractionDigits` / `maxIntegerDigits` limits that reject the keystroke, backspace over a separator removes the digit before it, a decimal typed in the integer part moves the decimal point, `prefix` / `suffix` with their own sizes and alignment.
|
|
24
|
+
- Controlled `value` with the `text` + `mostRecentEventCount` handshake (a stale value never fights the user); `onChangeText`, `onChangeValue`, `onFocus` / `onBlur`, `onSubmitEditing`; `focus` / `blur` / `clear` / `setText` / `setValue` / `getText` / `getValue` / `isFocused`.
|
|
25
|
+
- Worklets (optional, with `react-native-worklets`): a `transform` worklet and `'worklet'`-marked `onChangeText` / `onChangeValue` run synchronously on the UI thread inside the native edit, via a `NitroInputWorklets` bridge that holds the worklets UI runtime; no-ops when the package is not installed.
|
|
26
|
+
- `mode="mask"`: a fixed pattern applied natively as you type, from one shared compiled state machine (`cpp/MaskEngine`) — `[…]` editable blocks, `{…}` inserted literals, built-in `0 9 A a _ …` slots plus caller-defined ones via `maskNotations`; `maskAutocomplete` / `maskAutoSkip`; `onChangeMask` reports formatted text, extracted value, the remaining tail and completeness. Autocompletion only runs with the caret at the end, so editing mid-value does not fight you.
|
|
27
|
+
- Outlined and filled frames: `variant`, `label`, `labelBehavior`, `labelColor` / `labelFocusedColor` / `labelFontSize`, `strokeColor` / `focusedStrokeColor`, `strokeWidth`, `cornerRadius`, `fillColor`. The outlined notch is a real hole in the stroked path (shared `cpp/OutlineGeometry`, replayed identically on both platforms), so the background shows through it — no Skia. Timings follow Material's: 200 ms label on the standard decelerate curve, notch staggered 50 ms behind opening and 50 ms flat closing, driven entirely inside the view with no React state and nothing crossing into JS per frame. `label` also becomes the field's accessible name when nothing else supplies one.
|
|
28
|
+
- `setSelection(start, end)` on the ref (code point offsets).
|
|
29
|
+
- `NitroInput` is now the component, and `MorphInput` the thin wrapper over it — the general-purpose field was being defined as a special case of the specific one, which is why its props had to subtract the morph API back out. Both public APIs are unchanged. The `plain` prop is gone, replaced by its inverse `morph` (off by default), because `plain` only meant "no glyph engine" as an accident of the morph case being built first.
|
|
30
|
+
- `autoWidth` takes `'auto'` as well as a boolean. `NitroInput` defaults to `false`, so flexbox stretches it to its parent the way a `TextInput` is stretched; `MorphInput` uses `'auto'`, so an amount still grows as digits arrive.
|
|
31
|
+
- Fixed: in a plain field (no `morph`) a tap landed the caret at the start of the text wherever it fell, so a filled field tapped to refocus it came up with the caret before its first character. Tap-to-caret went through the morph engine's glyph boundaries on both platforms, which a plain field never feeds; it now defers to the system field's own mapping there.
|
|
32
|
+
- Fixed: `autoWidth` on a plain field (no `morph`) collapsed it to a couple of points. The reported width was the morph engine's, which a plain field never feeds; it now measures the text (or the placeholder) and the affixes with the fonts the field draws them in, on both platforms. Covered by an on-device Harness test.
|
|
33
|
+
- Fixed: negative amounts lost their sign; number formatting followed `LC_NUMERIC`, so a comma-decimal locale broke parsing; the worklets bridge held the UI runtime by `shared_ptr`.
|
|
34
|
+
- Fixed: the frame props were originally `outline*`, which collide with the CSS outline properties React Native 0.76 added to every view — a Hybrid View's props derive from `ViewProps`, so both parsers ran and RN drew a second square outline. A test now fails the build if any declared prop name collides with one React Native parses.
|
|
35
|
+
- `TextInput` parity, checked side by side in `src/__tests__/TextInputParity.test.tsx` against React Native's real component and its own `TextInput.d.ts`: every `TextInput` prop is either supported, inherited from `ViewProps`, or listed with a reason. Added `submitBehavior` (with the `blurOnSubmit` alias), `secureTextEntry`, `keyboardAppearance`, `textContentType` / `autoComplete`, `enablesReturnKeyAutomatically`, `showSoftInputOnFocus`, `selectTextOnFocus`, `clearTextOnFocus`, `contextMenuHidden`, `spellCheck`, `readOnly`, `selection`, the HTML-style aliases `inputMode` / `enterKeyHint` / `id` / `aria-label` / `rows` (resolved with React Native's own tables and precedence, since a Nitro view is handed the raw props), and the callbacks `onChange`, `onEndEditing`, `onSelectionChange` and `onKeyPress`.
|
|
36
|
+
- The field registers in React Native's text-input registry and routes the registry's `focusTextInput` / `blurTextInput` to its own native focus and blur, so `Keyboard.dismiss()`, `TextInput.State.currentlyFocusedInput()`, a ScrollView's `keyboardShouldPersistTaps` and `react-native-keyboard-controller` treat it as the text input it is. `testID` and `accessibilityLabel` are forwarded to the system field (the element VoiceOver, TalkBack and e2e tools interact with), and the `placeholder` is its accessibility value while it is empty. `TextInput.State.focusTextInput` / `blurTextInput` copy their references when `TextInput.js` loads and so bypass the routing: iOS answers the view command they dispatch, Android drops it.
|
|
37
|
+
- Every event is a superset of `TextInput`'s: `nativeEvent` carries React Native's fields under React Native's names, so a handler written against a `TextInput` works unchanged, and the same fields are repeated at the top level (`onSubmitEditing={({ text }) => …}`). `onFocus` / `onBlur` carry `text`, `eventCount` and `target`.
|
|
38
|
+
- `multiline`, with `numberOfLines` / `rows`, `textAlignVertical` and `scrollEnabled`. A wrapping field is drawn by the system view (on iOS a `UITextView` built the first time it is asked for), grows with its content unless given a line count, and is always `mode="text"`: `morph`, a non-text `mode` and the `prefix` / `suffix` affixes are ignored alongside it, with one warning each in development. Its return key inserts a line break by default (`submitBehavior="newline"`), as a `TextInput`'s does. `lineHeight` on both platforms, with the CSS meaning (the total height a line occupies), honoured tighter than the font too — the case React Native's own correction skips.
|
|
39
|
+
- Every event callback can be a worklet: mark `onChangeText`, `onChangeValue`, `onFocus`, `onBlur`, `onSelectionChange`, `onSubmitEditing`, `onEndEditing` or `onKeyPress` with `'worklet'` and it runs on the UI runtime inside the native edit, and is not also called on the JS thread. `useNitroInputState(useSharedValue)` builds on that: the field's `text`, `value`, `focused` and `selection` as shared values, plus the handlers that keep them current.
|
|
40
|
+
- `signPlacement`: where a negative amount's sign sits relative to the `prefix`, `'beforeAffix'` (`-$1,234.56`, the default) or `'afterAffix'` (`$-1,234.56`). Only the morph honours it; a plain field's affixes are accessory views outside the text, so it always reads `$-1,234.56`. Fixed: the morph drew `$-1,234.56` unconditionally.
|
|
41
|
+
- Right-to-left. `textAlign` gains `'auto'` and **defaults to it** (it was `'left'`): the start edge of the layout direction, as `TextInput` with no `textAlign`. `'left'` and `'right'` are absolute on both platforms (Android used to resolve `'left'` as start). The direction is resolved on the JS side, from `style.direction` else `I18nManager.isRTL`, and handed to native, because Fabric does not give a Hybrid View its layout direction. A `prefix` sits at the start edge and a `suffix` at the end, plain or morphed, with the digits still reading left to right; the frame's label and its notch sit at the start edge.
|
|
42
|
+
- Fixed: from React Native 0.86 a Hybrid View on Android received none of its base view props (`backgroundColor`, `border*`, `transform`, `opacity`, `testID`, accessibility): `react-native-nitro-modules` 0.37.1's `cloneProps` never fills `Props::rawProps`. The monorepo patches it (`patches/react-native-nitro-modules@0.37.1.patch`, filed as margelo/nitro#1656) and `src/__tests__/NitroViewProps.test.tsx` fails if the patch stops being applied.
|
|
43
|
+
- Fixed: a framed multiline field grew taller with its `cornerRadius` (the label's side inset was being reused as vertical padding); its label rested at the box's centre rather than on the first line; on Android the frame's padding was computed and then left out of the reported height.
|
|
44
|
+
- An uncontrolled or worklet-driven field no longer re-renders on every keystroke: the native edit count is kept in a ref, and only a controlled field (`value` given) takes the state update that forces a render, which is the one case native needs the count for. A field made controlled later still sends the fresh count.
|
|
45
|
+
- `submitBehavior` gains `'newline'`, and the defaults are resolved the way `TextInput` resolves them: `'blurAndSubmit'` on a single-line field, `'newline'` on a multiline one; `blurOnSubmit={false}` means `'submit'` on one line, and `blurOnSubmit` means `'blurAndSubmit'` on many.
|
|
46
|
+
- `maskNotations` is keyed on its contents, so an inline array literal no longer re-sets the native prop every render; the frame and caret colours, the flattened `style` and the imperative handle are memoised, and the handle is one object for the field's lifetime.
|
|
47
|
+
- Exported types: `NitroInputSignPlacement`, `NitroInputTextAlignVertical`, `InputMode` and `EnterKeyHint`; `textAlignVertical` is typed by the spec's `NitroInputTextAlignVertical`, and `NitroInputSelection` is declared once.
|
|
48
|
+
- Packaging: a dual build (`lib/module` for `import`, `lib/commonjs` for `require`, `lib/typescript` for the types) with matching `exports`; `react-native-worklets` is declared as an optional peer dependency, since it is loaded at runtime when present.
|
|
49
|
+
- Fixed on Android: the `onChangeValue`, `onFocus` / `onBlur`, `onSelectionChange`, `onSubmitEditing` and `onEndEditing` worklets kept running a stale handler after the callback changed (their ids never reached the view).
|
|
50
|
+
- `submitBehavior` is honoured natively on a multiline field on both platforms: `'newline'` inserts a line break, `'submit'` fires `onSubmitEditing` and keeps focus, `'blurAndSubmit'` fires it and dismisses the keyboard; on a single-line field `'newline'` does nothing, as with `TextInput`. A wrapping field that submits shows the IME's action key on Android.
|
|
51
|
+
- The field follows a light/dark switch without a remount: iOS re-rasterizes its glyphs and re-resolves the frame, label and caret colours on a trait change (and on a move to a display with another scale; the pixel density now comes from the view's traits instead of the deprecated `UIScreen.main`, which visionOS lacks), Android re-reads its theme colours on a configuration change.
|
|
52
|
+
- iOS: `focus()` / `blur()`, `Keyboard.dismiss()` and a ScrollView's auto-blur now reach a multiline field (the Fabric command only looked for a `UITextField`). `maxIntegerDigits` accepts up to 30, as on Android. Turning `morph` back on after plain mode no longer leaves the field blank until the next edit.
|
|
53
|
+
- Android: toggling `secureTextEntry` at runtime re-feeds the glyphs (the real characters used to stay on screen until the next edit); `maxLength` no longer clips a mask's own punctuation (it applies to `mode="text"` only, as on iOS); `focus()` and `autoFocus` respect `showSoftInputOnFocus={false}`; a `lineHeight` removed at runtime resets the spacing; tabular figures in text mode too, matching iOS.
|
|
54
|
+
- Less work per frame and per keystroke: iOS keeps one layer entry per glyph and re-uses it (no per-glyph allocation per frame), positions the caret once per step and caches the right-to-left caret blocks when a frame is published; Android resolves its theme colours once instead of per draw, reads the animator duration scale once (refreshed by a settings observer) instead of querying the settings provider per keystroke below API 33, and the outlined frame's geometry is written into a reused buffer instead of two vectors per draw.
|
|
55
|
+
- Removed dead code: `MaskEngine::format` / `totalTextLength` / `totalValueLength` / `placeholder`, the worklets bridge's `uninstallRuntime` and `isReady`, `MorphEngine::rightToLeft`, the unused JNI bindings behind them, and an unreachable pre-iOS-15 branch.
|
|
56
|
+
- Android build: the Android Gradle plugin is only pinned when the library builds on its own, Java 17 source/target, an unused `kotlinVersion` property removed, `cmake_minimum_required` before `project()`.
|
|
57
|
+
- Fixed: in a plain (text-mode) field with `morph` on, the decimal point of a number typed by hand dipped and rose again on every keystroke after it, although it never moved. The engine took a lone `.` or `,` for a grouping separator and re-paired it from the units end on each edit; it is the decimal point now, part of the typed sequence like the digits. Repeated punctuation (`192.168.0.1`, `21.09.2026`) is still structure.
|
|
58
|
+
- `onChangeMask` reports the same way on both platforms: whenever the text changes, from a keystroke, `setText` / `clear` or the `value` prop. iOS used to report the untouched empty text once at mount, and Android never reported a prop change. Found by the new on-device suite.
|
|
59
|
+
- A masked field that is emptied stays empty: `clear()`, `setText('')` and an empty `value` prop used to leave the mask's leading literals (`+1 (`) behind, while deleting everything by hand did not, and Android showed those literals in an untouched field at mount. Found by the new on-device suite.
|
|
60
|
+
- Android: a wrapping field grows with text set through `setText` / `defaultValue` / `value`, not only with typing. Found by the new on-device suite.
|
|
61
|
+
- The handle queues `focus()`, `blur()`, `clear()`, `setText()`, `setValue()` and `setSelection()` sent before the native view has attached and replays them the moment it does, as React Native queues a `TextInput`'s view commands; `useEffect(() => ref.current?.focus(), [])` and a `focus()` in a ref callback used to be silent no-ops. Found by the on-device suite that mirrors React Native's own `TextInput` tests.
|
|
62
|
+
- `aria-busy`, `aria-checked`, `aria-disabled`, `aria-expanded` and `aria-selected` fold into `accessibilityState`, `aria-hidden` hides the element, and `aria-labelledby` reaches the host, the way `TextInput` resolves them (a Nitro view is handed the raw props, which the native parser drops). `NitroInput` and `MorphInput` carry a `displayName`.
|
|
63
|
+
- Docs page with a live demo running the same engine and formatter compiled to WebAssembly.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ronald Goedeke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "NitroInput"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
|
|
14
|
+
s.source = { :git => "https://github.com/ronickg/react-native-nitro-rolling-number.git", :tag => "nitro-input-v#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = [
|
|
17
|
+
# Implementation (Swift)
|
|
18
|
+
"ios/**/*.{swift}",
|
|
19
|
+
# Autolinking/Registration (Objective-C++)
|
|
20
|
+
"ios/**/*.{m,mm}",
|
|
21
|
+
# Implementation (C++ objects)
|
|
22
|
+
"cpp/**/*.{hpp,cpp}",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
# The shared C++ engine and formatter are public headers so the pod's Swift
|
|
26
|
+
# sources can call them directly through Swift/C++ interop (enabled by Nitro below).
|
|
27
|
+
s.public_header_files = ["cpp/**/*.hpp"]
|
|
28
|
+
# The engine's unit tests build as a host executable (`bun run test:cpp`).
|
|
29
|
+
s.exclude_files = ["cpp/__tests__/**"]
|
|
30
|
+
|
|
31
|
+
# Worklets are optional: with react-native-worklets in the app, `transform`
|
|
32
|
+
# and worklet callbacks run synchronously on the UI thread.
|
|
33
|
+
worklets_package = begin
|
|
34
|
+
`cd "#{Pod::Config.instance.installation_root}" && node --print "require.resolve('react-native-worklets/package.json')" 2>/dev/null`.strip
|
|
35
|
+
rescue StandardError
|
|
36
|
+
""
|
|
37
|
+
end
|
|
38
|
+
has_worklets = !worklets_package.empty? && File.exist?(worklets_package)
|
|
39
|
+
if has_worklets
|
|
40
|
+
Pod::UI.puts "[NitroInput] react-native-worklets found, worklet support enabled"
|
|
41
|
+
s.dependency 'RNWorklets'
|
|
42
|
+
s.pod_target_xcconfig = {
|
|
43
|
+
"GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) MORPH_INPUT_WORKLETS=1",
|
|
44
|
+
"HEADER_SEARCH_PATHS" => "$(inherited) \"$(PODS_ROOT)/Headers/Public/RNWorklets\"",
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
load 'nitrogen/generated/ios/NitroInput+autolinking.rb'
|
|
49
|
+
add_nitrogen_files(s)
|
|
50
|
+
|
|
51
|
+
s.dependency 'React-jsi'
|
|
52
|
+
s.dependency 'React-callinvoker'
|
|
53
|
+
install_modules_dependencies(s)
|
|
54
|
+
end
|