react-native-nitro-input 0.3.5 → 0.3.6
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
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.6
|
|
4
|
+
|
|
5
|
+
- **A controlled `selection` rendered before the latest keystrokes is
|
|
6
|
+
dropped**, as `value` already was and as React Native's `TextInput` does.
|
|
7
|
+
Typed faster than JS renders (a slow Android phone, a busy JS thread), a
|
|
8
|
+
caret computed for an earlier text landed in a field that already had more
|
|
9
|
+
in it, and the next characters went in behind the first ones: a code field
|
|
10
|
+
driven by `selection` took "123456" as "156234". Uncontrolled fields are
|
|
11
|
+
unchanged.
|
|
12
|
+
|
|
3
13
|
## 0.3.5
|
|
4
14
|
|
|
5
15
|
- **`focusedValue`**: pass a shared value (Reanimated's `useSharedValue(false)`)
|
|
@@ -532,12 +532,18 @@ class HybridNitroInputView(private val context: ThemedReactContext) : HybridNitr
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
/// A controlled `selection`; -1 on either end means "leave the caret alone".
|
|
535
|
+
/// Like `text`, dropped when it was rendered before JS saw the latest native
|
|
536
|
+
/// edits (React Native's `TextInput` does the same): typed faster than JS
|
|
537
|
+
/// renders, a caret computed for "1" landed in a field already showing
|
|
538
|
+
/// "1234", and the next digits went in behind the first one. An uncontrolled
|
|
539
|
+
/// field sends a count of 0 and is applied as before.
|
|
535
540
|
private fun flushSelectionIfNeeded() {
|
|
536
541
|
if (!selectionDirty) return
|
|
537
542
|
selectionDirty = false
|
|
538
543
|
val start = clampInt(selectionStart, -1, Int.MAX_VALUE, -1)
|
|
539
544
|
val end = clampInt(selectionEnd, -1, Int.MAX_VALUE, -1)
|
|
540
545
|
if (start < 0 || end < 0) return
|
|
546
|
+
if (mostRecentEventCount > 0 && mostRecentEventCount < eventCount) return
|
|
541
547
|
inputView.setSelection(start, end)
|
|
542
548
|
}
|
|
543
549
|
|
|
@@ -434,13 +434,21 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
/// A controlled `selection`: `-1` on either end means "leave the caret alone",
|
|
437
|
-
/// which is what an uncontrolled field sends on every render.
|
|
437
|
+
/// which is what an uncontrolled field sends on every render. Like `text`,
|
|
438
|
+
/// dropped when it was rendered before JS saw the latest native edits (React
|
|
439
|
+
/// Native's `TextInput` does the same): typed faster than JS renders, a caret
|
|
440
|
+
/// computed for "1" landed in a field already showing "1234". An
|
|
441
|
+
/// uncontrolled field sends a count of 0 and is applied as before.
|
|
438
442
|
private func applySelectionIfNeeded() {
|
|
439
443
|
guard selectionDirty else { return }
|
|
440
444
|
selectionDirty = false
|
|
441
445
|
let start = Self.clampInt(selectionStart, -1, Int(Int32.max), fallback: -1)
|
|
442
446
|
let end = Self.clampInt(selectionEnd, -1, Int(Int32.max), fallback: -1)
|
|
443
447
|
guard start >= 0, end >= 0 else { return }
|
|
448
|
+
snapshotLock.lock()
|
|
449
|
+
let nativeCount = snapshot.eventCount
|
|
450
|
+
snapshotLock.unlock()
|
|
451
|
+
if mostRecentEventCount.isFinite, mostRecentEventCount > 0, Int(mostRecentEventCount) < nativeCount { return }
|
|
444
452
|
inputView.setSelection(start: start, end: end)
|
|
445
453
|
}
|
|
446
454
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-input",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Native text for React Native, built with Nitro: a text and amount input with native formatting, masks and a Torph-style reflow, and an animated number (odometer, SwiftUI-style numeric text, ticker) whose digits roll or swap natively, with currency layouts and animated currency switches, shrink-to-fit, a loading shimmer and a jackpot reveal.",
|
|
5
5
|
"main": "lib/commonjs/src/index.js",
|
|
6
6
|
"module": "lib/module/src/index.js",
|