react-native-nitro-input 0.3.2 → 0.3.4
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 +129 -0
- package/README.md +45 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +25 -4
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +211 -3
- package/android/src/main/java/com/margelo/nitro/nitroinput/UnmountHandoffs.kt +57 -0
- package/ios/HybridNitroInputView.swift +19 -4
- package/ios/NitroInputCommands.mm +10 -0
- package/ios/NitroInputView.swift +585 -14
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +2 -0
- package/lib/commonjs/src/NitroInput.js +103 -15
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +2 -0
- package/lib/module/src/NitroInput.js +104 -16
- package/lib/typescript/src/NitroInput.d.ts +16 -0
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +22 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +22 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +5 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +16 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +18 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +3 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +33 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +5 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +5 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +2 -0
- package/package.json +1 -1
- package/src/NitroInput.tsx +117 -11
- package/src/specs/NitroInput.nitro.ts +22 -0
|
@@ -157,6 +157,8 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
157
157
|
var showSoftInputOnFocus: Bool = true { didSet { markConfigDirty() } }
|
|
158
158
|
var selectTextOnFocus: Bool = false { didSet { markConfigDirty() } }
|
|
159
159
|
var clearTextOnFocus: Bool = false { didSet { markConfigDirty() } }
|
|
160
|
+
var keyboardHandoffMs: Double = 0 { didSet { markConfigDirty() } }
|
|
161
|
+
var returnKeyBar: Bool = true { didSet { markConfigDirty() } }
|
|
160
162
|
var contextMenuHidden: Bool = false { didSet { markConfigDirty() } }
|
|
161
163
|
var spellCheck: Bool = true { didSet { markConfigDirty() } }
|
|
162
164
|
var selectionStart: Double = -1 { didSet { markSelectionDirty() } }
|
|
@@ -195,6 +197,10 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
195
197
|
onMain { self.inputView.blur() }
|
|
196
198
|
}
|
|
197
199
|
|
|
200
|
+
func prepareForUnmount() throws {
|
|
201
|
+
onMain { self.inputView.handOffKeyboardIfFocused() }
|
|
202
|
+
}
|
|
203
|
+
|
|
198
204
|
func clear() throws {
|
|
199
205
|
onMain {
|
|
200
206
|
self.flushConfigIfNeeded()
|
|
@@ -364,6 +370,8 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
364
370
|
showSoftInputOnFocus = true
|
|
365
371
|
selectTextOnFocus = false
|
|
366
372
|
clearTextOnFocus = false
|
|
373
|
+
keyboardHandoffMs = 0
|
|
374
|
+
returnKeyBar = true
|
|
367
375
|
contextMenuHidden = false
|
|
368
376
|
spellCheck = true
|
|
369
377
|
selectionStart = -1
|
|
@@ -436,17 +444,22 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
436
444
|
inputView.setSelection(start: start, end: end)
|
|
437
445
|
}
|
|
438
446
|
|
|
439
|
-
/// The `text` prop handshake:
|
|
440
|
-
///
|
|
441
|
-
///
|
|
447
|
+
/// The `text` prop handshake: once JS has seen every native edit
|
|
448
|
+
/// (`mostRecentEventCount` caught up with the native count), the field shows
|
|
449
|
+
/// `text`, like React Native's own `TextInput`. Compared with what the field
|
|
450
|
+
/// shows, not just the last value applied: a controlled parent that keeps
|
|
451
|
+
/// its value while the user types (a rejected edit) puts its text back.
|
|
452
|
+
/// `setText` leaves the field (and the caret) alone when the formatted
|
|
453
|
+
/// value is already what it shows. An uncontrolled field sends a count of 0,
|
|
454
|
+
/// so its initial text is never re-applied over what the user typed.
|
|
442
455
|
private func applyTextIfNeeded() {
|
|
443
456
|
guard textDirty else { return }
|
|
444
457
|
textDirty = false
|
|
445
|
-
guard text != lastAppliedText else { return }
|
|
446
458
|
snapshotLock.lock()
|
|
447
459
|
let nativeCount = snapshot.eventCount
|
|
448
460
|
snapshotLock.unlock()
|
|
449
461
|
guard mostRecentEventCount.isFinite, Int(mostRecentEventCount) >= nativeCount else { return }
|
|
462
|
+
guard text != lastAppliedText || text != inputView.text else { return }
|
|
450
463
|
lastAppliedText = text
|
|
451
464
|
inputView.setText(text, reason: .prop)
|
|
452
465
|
}
|
|
@@ -583,6 +596,8 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
583
596
|
traits.showSoftInputOnFocus = showSoftInputOnFocus
|
|
584
597
|
traits.selectTextOnFocus = selectTextOnFocus
|
|
585
598
|
traits.clearTextOnFocus = clearTextOnFocus
|
|
599
|
+
traits.keyboardHandoffMs = keyboardHandoffMs.isFinite ? max(0, keyboardHandoffMs) : 0
|
|
600
|
+
traits.returnKeyBar = returnKeyBar
|
|
586
601
|
traits.contextMenuHidden = contextMenuHidden
|
|
587
602
|
traits.spellCheck = spellCheck && autoCorrect
|
|
588
603
|
|
|
@@ -50,6 +50,16 @@ static BOOL NitroInputEditorIsEditable(UIView *editor)
|
|
|
50
50
|
|
|
51
51
|
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
52
52
|
{
|
|
53
|
+
// The field's own focus()/blur(): they retry a declined focus, hold a focus
|
|
54
|
+
// asked for while the view has no window, and let a held keyboard go.
|
|
55
|
+
UIView *host = self.contentView;
|
|
56
|
+
SEL own = [(NSString *)commandName isEqualToString:@"focus"] ? NSSelectorFromString(@"nitroFocus")
|
|
57
|
+
: [(NSString *)commandName isEqualToString:@"blur"] ? NSSelectorFromString(@"nitroBlur")
|
|
58
|
+
: nil;
|
|
59
|
+
if (own != nil && [host respondsToSelector:own]) {
|
|
60
|
+
((void (*)(id, SEL))[host methodForSelector:own])(host, own);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
53
63
|
UIView *editor = NitroInputFindEditor(self.contentView);
|
|
54
64
|
if (editor == nil) {
|
|
55
65
|
return;
|