react-native-nitro-input 0.3.8 → 0.4.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +5 -1
  3. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputMeasure.kt +52 -0
  4. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +74 -80
  5. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +18 -18
  6. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +14 -14
  7. package/android/src/main/java/com/margelo/nitro/nitroinput/InputFonts.kt +199 -0
  8. package/android/src/main/java/com/margelo/nitro/nitroinput/InputSizing.kt +398 -0
  9. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +112 -333
  10. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +178 -30
  11. package/ios/HybridNitroInputView.swift +69 -75
  12. package/ios/HybridNitroNumberView.swift +18 -18
  13. package/ios/HybridNitroTextView.swift +14 -14
  14. package/ios/InputSizing.swift +534 -0
  15. package/ios/NitroInputView.swift +102 -198
  16. package/ios/NitroNumberView.swift +98 -23
  17. package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  18. package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  19. package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  20. package/lib/commonjs/src/NitroInput.js +164 -23
  21. package/lib/commonjs/src/NitroNumber.js +1 -1
  22. package/lib/commonjs/src/NitroText.js +6 -6
  23. package/lib/commonjs/src/specs/NitroInputMeasure.nitro.js +2 -0
  24. package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  25. package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  26. package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  27. package/lib/module/src/NitroInput.js +165 -24
  28. package/lib/module/src/NitroNumber.js +1 -1
  29. package/lib/module/src/NitroText.js +6 -6
  30. package/lib/module/src/specs/NitroInputMeasure.nitro.js +1 -0
  31. package/lib/typescript/src/NitroInput.d.ts +9 -16
  32. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +17 -8
  33. package/lib/typescript/src/specs/NitroInputMeasure.nitro.d.ts +67 -0
  34. package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +6 -6
  35. package/lib/typescript/src/specs/NitroText.nitro.d.ts +6 -6
  36. package/nitro.json +10 -0
  37. package/nitrogen/generated/android/NitroInput+autolinking.cmake +2 -0
  38. package/nitrogen/generated/android/NitroInputOnLoad.cpp +16 -0
  39. package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.cpp +93 -0
  40. package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.hpp +63 -0
  41. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +76 -40
  42. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +24 -16
  43. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +30 -30
  44. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +12 -12
  45. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +30 -30
  46. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +12 -12
  47. package/nitrogen/generated/android/c++/JNitroInputSize.hpp +61 -0
  48. package/nitrogen/generated/android/c++/JNitroInputSizing.hpp +284 -0
  49. package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +44 -24
  50. package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +18 -18
  51. package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +18 -18
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputMeasureSpec.kt +56 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +32 -8
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +6 -6
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +6 -6
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSize.kt +56 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSizing.kt +246 -0
  58. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +17 -0
  59. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +29 -0
  60. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +11 -0
  61. package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
  62. package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
  63. package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.cpp +11 -0
  64. package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.hpp +112 -0
  65. package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +56 -32
  66. package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +24 -24
  67. package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +24 -24
  68. package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +56 -32
  69. package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +24 -24
  70. package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +24 -24
  71. package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec.swift +55 -0
  72. package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec_cxx.swift +138 -0
  73. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +12 -8
  74. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +68 -24
  75. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +6 -6
  76. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +18 -18
  77. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +6 -6
  78. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +18 -18
  79. package/nitrogen/generated/ios/swift/NitroInputSize.swift +34 -0
  80. package/nitrogen/generated/ios/swift/NitroInputSizing.swift +242 -0
  81. package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.cpp +21 -0
  82. package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.hpp +66 -0
  83. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +24 -16
  84. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +24 -16
  85. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +12 -12
  86. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +12 -12
  87. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +12 -12
  88. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +12 -12
  89. package/nitrogen/generated/shared/c++/NitroInputSize.hpp +87 -0
  90. package/nitrogen/generated/shared/c++/NitroInputSizing.hpp +263 -0
  91. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +24 -16
  92. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +36 -24
  93. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +12 -12
  94. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +18 -18
  95. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +12 -12
  96. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +18 -18
  97. package/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  98. package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  99. package/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  100. package/package.json +4 -2
  101. package/src/NitroInput.tsx +201 -64
  102. package/src/NitroNumber.tsx +6 -6
  103. package/src/NitroText.tsx +6 -6
  104. package/src/specs/NitroInput.nitro.ts +17 -8
  105. package/src/specs/NitroInputMeasure.nitro.ts +76 -0
  106. package/src/specs/NitroNumber.nitro.ts +6 -6
  107. package/src/specs/NitroText.nitro.ts +6 -6
@@ -320,6 +320,7 @@ final class NitroNumberView: UIView {
320
320
  /// passes a second on a trading screen). Past `budget` bytes, what has gone
321
321
  /// unused for `idle` seconds is dropped, oldest first; what is still in use
322
322
  /// stays unless the cache passes `limit`. A memory warning empties it.
323
+ /// Thread-safe: the glyphs are blurred off the main thread and drawn on it.
323
324
  private final class RecentImageCache<Key: Hashable> {
324
325
  private struct Entry {
325
326
  let image: UIImage
@@ -332,6 +333,7 @@ final class NitroNumberView: UIView {
332
333
  private let limit: Int
333
334
  private let idle: CFTimeInterval
334
335
  private var observer: NSObjectProtocol?
336
+ private let lock = NSLock()
335
337
 
336
338
  init(budget: Int = 8 << 20, limit: Int = 64 << 20, idle: CFTimeInterval = 2) {
337
339
  self.budget = budget
@@ -340,14 +342,23 @@ final class NitroNumberView: UIView {
340
342
  observer = NotificationCenter.default.addObserver(
341
343
  forName: UIApplication.didReceiveMemoryWarningNotification, object: nil, queue: .main
342
344
  ) { [weak self] _ in
343
- self?.entries.removeAll()
344
- self?.bytes = 0
345
+ guard let self else { return }
346
+ self.lock.lock()
347
+ defer { self.lock.unlock() }
348
+ self.entries.removeAll()
349
+ self.bytes = 0
345
350
  }
346
351
  }
347
352
 
348
- var count: Int { entries.count }
353
+ var count: Int {
354
+ lock.lock()
355
+ defer { lock.unlock() }
356
+ return entries.count
357
+ }
349
358
 
350
359
  subscript(key: Key) -> UIImage? {
360
+ lock.lock()
361
+ defer { lock.unlock() }
351
362
  guard var entry = entries[key] else { return nil }
352
363
  entry.used = CACurrentMediaTime()
353
364
  entries[key] = entry
@@ -356,6 +367,8 @@ final class NitroNumberView: UIView {
356
367
 
357
368
  func insert(_ image: UIImage, for key: Key) {
358
369
  let cost = image.cgImage.map { $0.bytesPerRow * $0.height } ?? 0
370
+ lock.lock()
371
+ defer { lock.unlock() }
359
372
  let now = CACurrentMediaTime()
360
373
  if let old = entries.updateValue(Entry(image: image, bytes: cost, used: now), forKey: key) { bytes -= old.bytes }
361
374
  bytes += cost
@@ -439,6 +452,10 @@ final class NitroNumberView: UIView {
439
452
  let top: CGFloat
440
453
  let glyphs: String
441
454
  }
455
+ /// `sharedImages` and `sharedTinted` are read and written off the main
456
+ /// thread too (the warm-up, a requested blur): only under this lock, and
457
+ /// never held while an image renders.
458
+ private static let imagesLock = NSLock()
442
459
  private static var sharedImages: [ImageKey: UIImage] = [:]
443
460
  /// Blurred glyphs, the digit's own colour (tint 0) and the flash's alike.
444
461
  private static let sharedBlurred = RecentImageCache<TintKey>()
@@ -567,8 +584,12 @@ final class NitroNumberView: UIView {
567
584
  /// per-glyph `NSAttributedString.draw` dominating the main thread.
568
585
  func image(_ text: String, role: GlyphRole) -> UIImage? {
569
586
  let key = ImageKey(font: fontTag(role), color: colorKey(for: role), scale: renderScale, text: text, role: role)
570
- if let cached = Self.sharedImages[key] { return cached }
571
- let string = attributed(text, role: role)
587
+ Self.imagesLock.lock()
588
+ let cached = Self.sharedImages[key]
589
+ Self.imagesLock.unlock()
590
+ if let cached { return cached }
591
+ // Not `attributed(_:role:)`: its cache is the main thread's, and this runs off it too.
592
+ let string = NSAttributedString(string: text, attributes: [.font: font(for: role), .foregroundColor: color(for: role)])
572
593
  let size = string.size()
573
594
  guard size.width > 0, size.height > 0 else { return nil }
574
595
  let format = UIGraphicsImageRendererFormat()
@@ -578,8 +599,10 @@ final class NitroNumberView: UIView {
578
599
  let image = UIGraphicsImageRenderer(size: bounds, format: format).image { _ in
579
600
  string.draw(at: .zero)
580
601
  }
602
+ Self.imagesLock.lock()
581
603
  if Self.sharedImages.count >= Self.sharedCapacity { Self.sharedImages.removeAll(keepingCapacity: true) }
582
604
  Self.sharedImages[key] = image
605
+ Self.imagesLock.unlock()
583
606
  return image
584
607
  }
585
608
 
@@ -618,6 +641,45 @@ final class NitroNumberView: UIView {
618
641
  return blurredImage(text, role: role, level: level)
619
642
  }
620
643
 
644
+ /// `swapImage` for the main thread, which never blurs: the blurred image if
645
+ /// it is made already, or nil, and it is made on `glyphQueue` for a frame
646
+ /// to come (the caller draws the sharp glyph meanwhile). Opening a screen
647
+ /// of numeric figures blurred and rasterized every digit at every level on
648
+ /// the main thread, ~1 s of it in blocks of up to 180 ms.
649
+ func readySwapImage(_ text: String, role: GlyphRole = .digit, level: Int, tint: UIColor?) -> UIImage? {
650
+ if level <= 0 || numericBlur <= 0 { return swapImage(text, role: role, level: 0, tint: tint) }
651
+ let key = TintKey(image: ImageKey(font: fontTag(role), color: colorKey(for: role), scale: renderScale, text: text, role: role), tint: tint.map { Self.key(of: $0) } ?? 0, level: level, blur: blurKey)
652
+ if let cached = Self.sharedBlurred[key] { return cached }
653
+ let now = CACurrentMediaTime()
654
+ Self.pendingLock.lock()
655
+ // One that could not be made is not asked for again every frame.
656
+ let recentlyFailed = Self.failed[key].map { now - $0 < Self.retryInterval } ?? false
657
+ let first = !recentlyFailed && Self.pending.insert(key).inserted
658
+ Self.pendingLock.unlock()
659
+ if first {
660
+ Self.glyphQueue.async {
661
+ let made = self.swapImage(text, role: role, level: level, tint: tint) != nil
662
+ Self.pendingLock.lock()
663
+ Self.pending.remove(key)
664
+ if made { Self.failed[key] = nil } else { Self.failed[key] = CACurrentMediaTime() }
665
+ Self.pendingLock.unlock()
666
+ }
667
+ }
668
+ return nil
669
+ }
670
+
671
+ /// Where a glyph the screen is waiting on is blurred: ahead of the warm-up's queue.
672
+ private static let glyphQueue = DispatchQueue(label: "NitroNumber.glyphs", qos: .userInitiated)
673
+ /// Where every digit is blurred ahead of a numeric transition (`warmSwapImages`).
674
+ static let warmQueue = DispatchQueue(label: "NitroNumber.warm", qos: .utility)
675
+ /// Blurs asked for and not made yet, so a glyph asked for every frame is made once.
676
+ private static var pending = Set<TintKey>()
677
+ /// When a blur last could not be made (vImage or the renderer failed), by key.
678
+ private static var failed: [TintKey: CFTimeInterval] = [:]
679
+ private static let retryInterval: CFTimeInterval = 2
680
+ /// Guards `pending` and `failed`.
681
+ private static let pendingLock = NSLock()
682
+
621
683
  private var blurKey: Int { Int((numericBlur * 1000).rounded()) }
622
684
 
623
685
  /// `sharp` blurred by `level / numericBlurLevels` of `numericBlur` line
@@ -680,7 +742,10 @@ final class NitroNumberView: UIView {
680
742
  /// opacity. Made once per font, density and tint.
681
743
  func tintedImage(_ text: String, role: GlyphRole = .digit, tint: UIColor) -> UIImage? {
682
744
  let key = TintKey(image: ImageKey(font: fontTag(role), color: colorKey(for: role), scale: renderScale, text: text, role: role), tint: Self.key(of: tint))
683
- if let cached = Self.sharedTinted[key] { return cached }
745
+ Self.imagesLock.lock()
746
+ let cached = Self.sharedTinted[key]
747
+ Self.imagesLock.unlock()
748
+ if let cached { return cached }
684
749
  let string = NSAttributedString(string: text, attributes: [.font: font(for: role), .foregroundColor: tint])
685
750
  let size = string.size()
686
751
  guard size.width > 0, size.height > 0 else { return nil }
@@ -690,8 +755,10 @@ final class NitroNumberView: UIView {
690
755
  let image = UIGraphicsImageRenderer(size: CGSize(width: ceil(size.width), height: ceil(size.height)), format: format).image { _ in
691
756
  string.draw(at: .zero)
692
757
  }
758
+ Self.imagesLock.lock()
693
759
  if Self.sharedTinted.count >= 128 { Self.sharedTinted.removeAll(keepingCapacity: true) }
694
760
  Self.sharedTinted[key] = image
761
+ Self.imagesLock.unlock()
695
762
  return image
696
763
  }
697
764
 
@@ -1263,22 +1330,27 @@ final class NitroNumberView: UIView {
1263
1330
  }
1264
1331
 
1265
1332
  /// Renders the ten digits' sharp and blurred images ahead of the first
1266
- /// numeric swap, on the next turn of the main queue so the mount itself
1267
- /// pays nothing. Rendered on demand instead, the first change of a session
1268
- /// spent its opening frames drawing glyphs, and the spring had landed by
1269
- /// the time the second frame was on screen.
1333
+ /// numeric swap, off the main thread. The fonts, colours and tints are read
1334
+ /// on the next turn of the main queue, once the props of this update have
1335
+ /// all landed. Rendered on demand instead, the first change of a session
1336
+ /// spent its opening frames drawing glyphs; rendered on the main queue, a
1337
+ /// screen of numeric figures opened with ~1 s of it, in blocks of up to
1338
+ /// 180 ms (a dropped frame at the first block).
1270
1339
  private func warmSwapImages() {
1271
1340
  guard timing.transition == .numeric else { return }
1272
1341
  DispatchQueue.main.async { [weak self] in
1273
1342
  guard let self, self.timing.transition == .numeric else { return }
1343
+ let fonts = self.fonts
1274
1344
  let tints = [self.flash.upColor, self.flash.downColor].compactMap { $0 }
1275
1345
  let roles: [GlyphRole] = self.format.fractionDigits > 0 ? [.digit, .fraction] : [.digit]
1276
- for role in roles {
1277
- for digit in self.fonts.glyphs {
1278
- for level in 0...Self.numericBlurLevels {
1279
- _ = self.fonts.blurredImage(digit, role: role, level: level)
1280
- for tint in tints {
1281
- _ = self.fonts.tintedBlurredImage(digit, role: role, tint: tint, level: level)
1346
+ FontSet.warmQueue.async {
1347
+ for role in roles {
1348
+ for digit in fonts.glyphs {
1349
+ for level in 0...Self.numericBlurLevels {
1350
+ _ = fonts.blurredImage(digit, role: role, level: level)
1351
+ for tint in tints {
1352
+ _ = fonts.tintedBlurredImage(digit, role: role, tint: tint, level: level)
1353
+ }
1282
1354
  }
1283
1355
  }
1284
1356
  }
@@ -1968,12 +2040,13 @@ final class NitroNumberView: UIView {
1968
2040
  if layer.isHidden != hidden { layer.isHidden = hidden }
1969
2041
  if hidden { return }
1970
2042
  if slot.text != text || slot.level != level {
1971
- if let image = fonts.blurredImage(text, role: role, level: level) {
1972
- layer.contents = image.cgImage
1973
- layer.bounds = CGRect(origin: .zero, size: image.size)
1974
- }
2043
+ // A blur not made yet draws sharp, and the slot asks again next frame.
2044
+ let ready = fonts.readySwapImage(text, role: role, level: level, tint: nil)
2045
+ let image = ready ?? sharp
2046
+ layer.contents = image.cgImage
2047
+ layer.bounds = CGRect(origin: .zero, size: image.size)
1975
2048
  slot.text = text
1976
- slot.level = level
2049
+ slot.level = ready != nil ? level : -1
1977
2050
  }
1978
2051
  layer.position = center
1979
2052
  layer.opacity = Float(layerAlpha)
@@ -2014,12 +2087,14 @@ final class NitroNumberView: UIView {
2014
2087
  if layer.isHidden != hidden { layer.isHidden = hidden }
2015
2088
  if hidden { return }
2016
2089
  if slot.glyph != glyph || slot.level != level || slot.tint != tintKey {
2017
- if let image = fonts.swapImage(text, role: role, level: level, tint: tint) {
2090
+ // A blur not made yet draws sharp, and the slot asks again next frame.
2091
+ let ready = fonts.readySwapImage(text, role: role, level: level, tint: tint)
2092
+ if let image = ready ?? fonts.swapImage(text, role: role, level: 0, tint: tint) {
2018
2093
  layer.contents = image.cgImage
2019
2094
  layer.bounds = CGRect(origin: .zero, size: image.size)
2020
2095
  }
2021
2096
  slot.glyph = glyph
2022
- slot.level = level
2097
+ slot.level = ready != nil ? level : -1
2023
2098
  slot.tint = tintKey
2024
2099
  }
2025
2100
  layer.position = center
@@ -40,7 +40,7 @@
40
40
  "signPlacement": true,
41
41
  "prefixAlign": true,
42
42
  "suffixAlign": true,
43
- "letterSpacing": true,
43
+ "textLetterSpacing": true,
44
44
  "prefixSpacing": true,
45
45
  "suffixSpacing": true,
46
46
  "prefixOffset": true,
@@ -51,12 +51,12 @@
51
51
  "easing": true,
52
52
  "bounce": true,
53
53
  "effect": true,
54
- "fontSize": true,
55
- "lineHeight": true,
56
- "fontWeight": true,
57
- "fontFamily": true,
58
- "color": true,
59
- "textAlign": true,
54
+ "textSize": true,
55
+ "textLineHeight": true,
56
+ "textWeight": true,
57
+ "textFamily": true,
58
+ "textColor": true,
59
+ "textAlignment": true,
60
60
  "rightToLeft": true,
61
61
  "caretColor": true,
62
62
  "selectionColor": true,
@@ -72,7 +72,11 @@
72
72
  "editable": true,
73
73
  "multiline": true,
74
74
  "numberOfLines": true,
75
- "textAlignVertical": true,
75
+ "textVerticalAlignment": true,
76
+ "textInsetLeft": true,
77
+ "textInsetTop": true,
78
+ "textInsetRight": true,
79
+ "textInsetBottom": true,
76
80
  "scrollEnabled": true,
77
81
  "autoFocus": true,
78
82
  "fieldTestID": true,
@@ -37,13 +37,13 @@
37
37
  "shimmerBaseColor": true,
38
38
  "shimmerDirection": true,
39
39
  "shimmerDelay": true,
40
- "fontSize": true,
40
+ "textSize": true,
41
41
  "prefixFontSize": true,
42
42
  "suffixFontSize": true,
43
43
  "affixAlign": true,
44
44
  "prefixAlign": true,
45
45
  "suffixAlign": true,
46
- "letterSpacing": true,
46
+ "textLetterSpacing": true,
47
47
  "prefixSpacing": true,
48
48
  "suffixSpacing": true,
49
49
  "prefixOffset": true,
@@ -66,10 +66,10 @@
66
66
  "minimumFontScale": true,
67
67
  "allowFontScaling": true,
68
68
  "maxFontSizeMultiplier": true,
69
- "fontWeight": true,
70
- "fontFamily": true,
71
- "color": true,
72
- "textAlign": true,
69
+ "textWeight": true,
70
+ "textFamily": true,
71
+ "textColor": true,
72
+ "textAlignment": true,
73
73
  "rightToLeft": true,
74
74
  "onSizeChange": true,
75
75
  "onRevealEnd": true,
@@ -5,12 +5,12 @@
5
5
  "directEventTypes": {},
6
6
  "validAttributes": {
7
7
  "text": true,
8
- "fontSize": true,
9
- "fontWeight": true,
10
- "fontFamily": true,
11
- "color": true,
12
- "letterSpacing": true,
13
- "textAlign": true,
8
+ "textSize": true,
9
+ "textWeight": true,
10
+ "textFamily": true,
11
+ "textColor": true,
12
+ "textLetterSpacing": true,
13
+ "textAlignment": true,
14
14
  "rightToLeft": true,
15
15
  "duration": true,
16
16
  "easing": true,
@@ -184,21 +184,75 @@ function warnIncompatible(what) {
184
184
  'field is drawn by the system view, and an amount, a mask and their ' +
185
185
  'affixes are single-line. Drop one of the two.');
186
186
  }
187
+ const NO_INSETS = { left: 0, top: 0, right: 0, bottom: 0 };
187
188
  /**
188
- * A native text input: a system field (`UITextField` / `EditText`) that owns
189
- * the keyboard, editing, selection, paste and accessibility, with native
190
- * formatting (`mode="number"`), native masking (`mode="mask"`), an outlined
191
- * or filled frame with a floating label, and optionally the glyph engine
192
- * (`transition="reflow"`), under which characters that stay glide to their new place, new
193
- * ones slide or fade in and removed ones leave alongside their neighbours.
194
- * In `'number'` mode every edit is formatted on the native side before a
195
- * frame is drawn, with the caret kept in place, so there is never an
196
- * unformatted frame and never a round trip through JS.
197
- *
198
- * Like a `TextInput`, it takes its width from its parent; `autoWidth` sizes
199
- * it to its content instead, and is on by default when the text reflows.
189
+ * The style's padding plus border per edge, resolved the way Yoga does: a
190
+ * start / end edge before left / right, then horizontal / vertical, then all.
191
+ * A size measured for the text gets them added, as `TextInput`'s is, so a
192
+ * padded field grows rather than squeezing its text. Percentages are not
193
+ * resolved here (they need the parent's size) and count as 0.
200
194
  */
201
- exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaultValue, mode, fractionDigits, maxIntegerDigits, groupingSeparator, decimalSeparator, prefix, suffix, prefixFontSize, suffixFontSize, affixAlign, signPlacement, prefixAlign, suffixAlign, letterSpacing, prefixSpacing, suffixSpacing, prefixOffset, suffixOffset, format, placeholder, placeholderTextColor, duration, easing, bounce, effect, fontSize, lineHeight, fontWeight, fontFamily, color, textAlign, cursorColor, selectionColor, caretHidden, adjustsFontSizeToFit, minimumFontScale, allowFontScaling, maxFontSizeMultiplier, variant, label, labelBehavior, labelColor, labelFocusedColor, labelFontSize, strokeColor, focusedStrokeColor, strokeWidth, cornerRadius, fillColor, keyboardType, inputMode, enterKeyHint, mask, maskNotations, maskAutocomplete, maskAutoSkip, maskAffinityFormats, maskAffinityStrategy, maskTextCase, maskCharacterMap, maskSlotPlaceholder, keepPlaceholder, returnKeyType, autoCapitalize, autoCorrect, editable, multiline, numberOfLines, rows, textAlignVertical, scrollEnabled, autoFocus, transition, autoWidth: autoWidthProp, submitBehavior, blurOnSubmit, secureTextEntry, keyboardAppearance, textContentType, autoComplete, enablesReturnKeyAutomatically, showSoftInputOnFocus, selectTextOnFocus, clearTextOnFocus, keyboardHandoffMs, returnKeyBar, contextMenuHidden, spellCheck, readOnly, selection, onEndEditing, onSelectionChange, onKeyPress, maxLength, transform, onChangeText, onChange, onChangeValue, onChangeMask, onFocus, onBlur, focusedValue, onSubmitEditing, onNativeRef, style, ...viewProps }, ref) {
195
+ function styleInsets(flat, rightToLeft) {
196
+ if (flat == null)
197
+ return NO_INSETS;
198
+ const n = (key) => {
199
+ const value = flat[key];
200
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
201
+ };
202
+ const start = rightToLeft ? 'End' : 'Start';
203
+ const end = rightToLeft ? 'Start' : 'End';
204
+ const insets = {
205
+ left: (n(`padding${start}`) ?? n('paddingLeft') ?? n('paddingHorizontal') ?? n('padding') ?? 0) +
206
+ (n(`border${start}Width`) ?? n('borderLeftWidth') ?? n('borderWidth') ?? 0),
207
+ right: (n(`padding${end}`) ?? n('paddingRight') ?? n('paddingHorizontal') ?? n('padding') ?? 0) +
208
+ (n(`border${end}Width`) ?? n('borderRightWidth') ?? n('borderWidth') ?? 0),
209
+ top: (n('paddingTop') ?? n('paddingVertical') ?? n('padding') ?? 0) + (n('borderTopWidth') ?? n('borderWidth') ?? 0),
210
+ bottom: (n('paddingBottom') ?? n('paddingVertical') ?? n('padding') ?? 0) +
211
+ (n('borderBottomWidth') ?? n('borderWidth') ?? 0),
212
+ };
213
+ return insets.left === 0 && insets.right === 0 && insets.top === 0 && insets.bottom === 0 ? NO_INSETS : insets;
214
+ }
215
+ function styleTextAlign(value, rightToLeft) {
216
+ switch (value) {
217
+ case undefined:
218
+ return undefined;
219
+ // `justify` has no meaning on one line: the start edge, as on a TextInput.
220
+ case 'start':
221
+ case 'justify':
222
+ return 'auto';
223
+ case 'end':
224
+ return rightToLeft ? 'left' : 'right';
225
+ default:
226
+ return value;
227
+ }
228
+ }
229
+ function styleTextAlignVertical(value) {
230
+ return value ?? undefined;
231
+ }
232
+ // One per app, made on first use. `null` when the native side has none (an
233
+ // app built against an older version, or a test without native modules): the
234
+ // field then takes its size from the view's first report, as it used to.
235
+ let measurer;
236
+ function measureSizing(sizing) {
237
+ if (measurer === undefined) {
238
+ try {
239
+ const made = react_native_nitro_modules_1.NitroModules.createHybridObject('NitroInputMeasure');
240
+ measurer = typeof made?.measure === 'function' ? made : null;
241
+ }
242
+ catch {
243
+ measurer = null;
244
+ }
245
+ }
246
+ if (measurer === null)
247
+ return null;
248
+ try {
249
+ return measurer.measure(sizing);
250
+ }
251
+ catch {
252
+ return null;
253
+ }
254
+ }
255
+ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaultValue, mode, fractionDigits, maxIntegerDigits, groupingSeparator, decimalSeparator, prefix, suffix, prefixFontSize, suffixFontSize, affixAlign, signPlacement, prefixAlign, suffixAlign, letterSpacing: letterSpacingProp, prefixSpacing, suffixSpacing, prefixOffset, suffixOffset, format, placeholder, placeholderTextColor, duration, easing, bounce, effect, fontSize: fontSizeProp, lineHeight: lineHeightProp, fontWeight: fontWeightProp, fontFamily: fontFamilyProp, color: colorProp, textAlign: textAlignProp, cursorColor, selectionColor, caretHidden, adjustsFontSizeToFit, minimumFontScale, allowFontScaling, maxFontSizeMultiplier, variant, label, labelBehavior, labelColor, labelFocusedColor, labelFontSize, strokeColor, focusedStrokeColor, strokeWidth, cornerRadius, fillColor, keyboardType, inputMode, enterKeyHint, mask, maskNotations, maskAutocomplete, maskAutoSkip, maskAffinityFormats, maskAffinityStrategy, maskTextCase, maskCharacterMap, maskSlotPlaceholder, keepPlaceholder, returnKeyType, autoCapitalize, autoCorrect, editable, multiline, numberOfLines, rows, textAlignVertical: textAlignVerticalProp, scrollEnabled, autoFocus, transition, autoWidth: autoWidthProp, submitBehavior, blurOnSubmit, secureTextEntry, keyboardAppearance, textContentType, autoComplete, enablesReturnKeyAutomatically, showSoftInputOnFocus, selectTextOnFocus, clearTextOnFocus, keyboardHandoffMs, returnKeyBar, contextMenuHidden, spellCheck, readOnly, selection, onEndEditing, onSelectionChange, onKeyPress, maxLength, transform, onChangeText, onChange, onChangeValue, onChangeMask, onFocus, onBlur, focusedValue, onSubmitEditing, onNativeRef, style, ...viewProps }, ref) {
202
256
  const nativeRef = (0, react_1.useRef)(null);
203
257
  // `keyboardHandoffMs`: hand the keyboard off while this field still has it.
204
258
  // A layout-effect cleanup runs in React's commit, so the native call is
@@ -261,6 +315,11 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
261
315
  if (value != null)
262
316
  textRef.current = value;
263
317
  const [size, setSize] = (0, react_1.useState)(null);
318
+ // The size measured before the view existed (see `measureSizing`), and
319
+ // whether the view has reported its own since.
320
+ const seedRef = (0, react_1.useRef)(null);
321
+ const seedKeyRef = (0, react_1.useRef)('');
322
+ const reportedRef = (0, react_1.useRef)(false);
264
323
  // Worklets are registered on the UI runtime and referenced by id; a
265
324
  // handler marked 'worklet' runs there instead of on the JS thread.
266
325
  const transformId = useWorkletId(transform, worklets_1.registerTransform);
@@ -366,11 +425,24 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
366
425
  // A field with a width of its own (the usual case) never needs a React
367
426
  // commit per keystroke: only the height (font-dependent) is taken from native.
368
427
  const flat = (0, react_1.useMemo)(() => react_native_1.StyleSheet.flatten(style), [style]);
428
+ // `TextInput` takes its typography from `style`; so does this, under the
429
+ // props of the same name, which win. (Fabric hands a view its style's keys
430
+ // as props too; the view's own are named so that none can be one of them -
431
+ // see PropNameCollisions.test.)
432
+ const fontSize = fontSizeProp ?? flat?.fontSize;
433
+ const lineHeight = lineHeightProp ?? flat?.lineHeight;
434
+ const fontWeight = fontWeightProp ?? flat?.fontWeight;
435
+ const fontFamily = fontFamilyProp ?? flat?.fontFamily;
436
+ const color = colorProp ?? flat?.color;
437
+ const letterSpacing = letterSpacingProp ?? flat?.letterSpacing;
438
+ const textAlignVertical = textAlignVerticalProp ?? styleTextAlignVertical(flat?.textAlignVertical);
369
439
  // The layout direction, resolved the way React Native resolves it for its
370
440
  // own views: the field's `style.direction` if it says, else the app's.
371
441
  // Fabric does not hand a Hybrid View its resolved direction, so native is
372
442
  // told outright.
373
443
  const rightToLeft = flat?.direction === 'rtl' || (flat?.direction !== 'ltr' && react_native_1.I18nManager.isRTL);
444
+ const textAlign = textAlignProp ?? styleTextAlign(flat?.textAlign, rightToLeft);
445
+ const insets = (0, react_1.useMemo)(() => styleInsets(flat, rightToLeft), [flat, rightToLeft]);
374
446
  // `TextInput` stretches to its parent; sizing to content is this
375
447
  // component's own behaviour, and it is what stops it being a drop-in.
376
448
  // `NitroInput` turns it off so flexbox gives it the parent's width, the
@@ -388,13 +460,17 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
388
460
  const measuredRef = (0, react_1.useRef)(measured);
389
461
  measuredRef.current = measured;
390
462
  const onSizeChange = (0, react_1.useMemo)(() => (0, react_native_nitro_modules_1.callback)((width, height) => {
463
+ reportedRef.current = true;
391
464
  if (!measuredRef.current)
392
465
  return;
393
466
  setSize((previous) => {
467
+ // Until the first report the field shows the seed; a report that
468
+ // matches it leaves `size` as it is, and costs no commit.
469
+ const shown = previous ?? seedRef.current;
394
470
  if (!autoWidthRef.current) {
395
- return previous !== null && previous.height === height ? previous : { width: previous?.width ?? width, height };
471
+ return shown !== null && shown.height === height ? previous : { width: shown?.width ?? width, height };
396
472
  }
397
- return previous !== null && previous.width === width && previous.height === height
473
+ return shown !== null && shown.width === width && shown.height === height
398
474
  ? previous
399
475
  : { width, height };
400
476
  });
@@ -639,15 +715,80 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
639
715
  hostViewProps.importantForAccessibility = resolvedImportance;
640
716
  if (resolvedLabelledBy != null)
641
717
  hostViewProps.accessibilityLabelledBy = resolvedLabelledBy;
642
- const autoSize = (0, react_1.useMemo)(() => size !== null
643
- ? autoWidth
644
- ? { width: size.width, height: size.height }
645
- : { height: size.height }
646
- : { height: resolvedFontSize * 1.25 }, [size, resolvedFontSize, autoWidth]);
647
- return (react_1.default.createElement(exports.NativeNitroInputView, { ...hostViewProps, ref: hostRef, style: [autoSize, style], hybridRef: hybridRef, text: value ?? uncontrolledText,
718
+ // What the field's size follows. Sent to the view as props and, before
719
+ // the view exists, to `measureSizing`, so the two see the same values.
720
+ const sizing = {
721
+ text: value ?? uncontrolledText,
722
+ mode: resolvedMode,
723
+ plain: !reflows,
724
+ multiline: isMultiline,
725
+ secureTextEntry: secureTextEntry ?? false,
726
+ maxLength: maxLength ?? 0,
727
+ fractionDigits: resolvedFractionDigits,
728
+ maxIntegerDigits: maxIntegerDigits ?? 15,
729
+ groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? ',',
730
+ decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.',
731
+ prefix: resolvedPrefix,
732
+ suffix: resolvedSuffix,
733
+ signPlacement: signPlacement ?? derived?.signPlacement ?? 'beforeAffix',
734
+ placeholder: placeholder ?? '',
735
+ mask: resolvedMode === 'mask' ? (mask ?? '') : '',
736
+ maskNotations: stableNotations,
737
+ maskAutocomplete: maskAutocomplete ?? true,
738
+ maskAutoSkip: maskAutoSkip ?? false,
739
+ maskAffinityFormats: stableAffinityFormats,
740
+ maskAffinityStrategy: maskAffinityStrategy ?? 'wholeString',
741
+ maskTextCase: maskTextCase ?? 'none',
742
+ maskCharacterMap: stableCharacterMap,
743
+ maskSlotPlaceholder: maskSlotPlaceholder ?? (keepPlaceholder ? '_' : ''),
744
+ keepPlaceholder: keepPlaceholder ?? false,
745
+ textSize: resolvedFontSize,
746
+ textLineHeight: Math.max(0, lineHeight ?? 0),
747
+ prefixFontSize: prefixFontSize ?? resolvedFontSize,
748
+ suffixFontSize: suffixFontSize ?? resolvedFontSize,
749
+ textWeight: numericWeight,
750
+ textFamily: fontFamily ?? '',
751
+ textLetterSpacing: letterSpacing ?? 0,
752
+ prefixSpacing: prefixSpacing ?? Infinity,
753
+ suffixSpacing: suffixSpacing ?? Infinity,
754
+ allowFontScaling: allowFontScaling ?? false,
755
+ maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0,
756
+ variant: variant ?? 'none',
757
+ label: label ?? '',
758
+ labelBehavior: labelBehavior ?? 'float',
759
+ labelFontSize: labelFontSize ?? 0,
760
+ cornerRadius: cornerRadius ?? 8,
761
+ };
762
+ // Until the view reports its size, the field lays out at the size it will
763
+ // report, measured now with the view's own code - as `TextInput` measures
764
+ // in its shadow node - rather than at its parent's width for the commit
765
+ // the report takes. Not for a wrapping field (its height needs the width
766
+ // it will get), a `transform` (a worklet, run on the UI thread) or a
767
+ // style that sets both dimensions. Measured again only when what it
768
+ // follows changes.
769
+ if (!reportedRef.current) {
770
+ const seedKey = measured && !isMultiline && transformId === 0 ? JSON.stringify(sizing) : '';
771
+ if (seedKey !== seedKeyRef.current) {
772
+ seedKeyRef.current = seedKey;
773
+ seedRef.current = seedKey === '' ? null : measureSizing(sizing);
774
+ }
775
+ }
776
+ const shownSize = size ?? seedRef.current;
777
+ // The size measured for the text, plus the style's padding and border
778
+ // (Yoga's box includes them; `TextInput`'s measured size gets them too).
779
+ const autoSize = (0, react_1.useMemo)(() => {
780
+ const extraWidth = insets.left + insets.right;
781
+ const extraHeight = insets.top + insets.bottom;
782
+ return shownSize !== null
783
+ ? autoWidth
784
+ ? { width: shownSize.width + extraWidth, height: shownSize.height + extraHeight }
785
+ : { height: shownSize.height + extraHeight }
786
+ : { height: resolvedFontSize * 1.25 + extraHeight };
787
+ }, [shownSize, resolvedFontSize, autoWidth, insets]);
788
+ return (react_1.default.createElement(exports.NativeNitroInputView, { ...hostViewProps, ...sizing, ref: hostRef, style: [autoSize, style], hybridRef: hybridRef,
648
789
  // An uncontrolled field's `text` is its initial text: a count of 0 is
649
790
  // never caught up after the first edit, so native never puts it back.
650
- mostRecentEventCount: value != null ? eventCountRef.current : 0, mode: resolvedMode, plain: !reflows, fractionDigits: resolvedFractionDigits, maxIntegerDigits: maxIntegerDigits ?? 15, groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? ',', decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.', prefix: resolvedPrefix, suffix: resolvedSuffix, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, signPlacement: signPlacement ?? derived?.signPlacement ?? 'beforeAffix', prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, letterSpacing: letterSpacing ?? 0, prefixSpacing: prefixSpacing ?? Infinity, suffixSpacing: suffixSpacing ?? Infinity, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, placeholder: placeholder ?? '', placeholderColor: processedPlaceholderColor, duration: duration ?? 400, easing: easing ?? 'expo', bounce: bounce ?? 0.15, effect: effect ?? 'auto', fontSize: resolvedFontSize, lineHeight: Math.max(0, lineHeight ?? 0), fontWeight: numericWeight, fontFamily: fontFamily ?? '', color: processedColor, textAlign: textAlign ?? 'auto', rightToLeft: rightToLeft, caretColor: processedCursorColor, selectionColor: processedSelectionColor, caretHidden: caretHidden ?? false, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, allowFontScaling: allowFontScaling ?? false, maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0, variant: variant ?? 'none', label: label ?? '', labelBehavior: labelBehavior ?? 'float', labelColor: processedLabelColor, labelFocusedColor: processedLabelFocusedColor, labelFontSize: labelFontSize ?? 0, strokeColor: processedStrokeColor, focusedStrokeColor: processedFocusedStrokeColor, strokeWidth: strokeWidth ?? 1, cornerRadius: cornerRadius ?? 8, fillColor: processedFillColor, mask: resolvedMode === 'mask' ? (mask ?? '') : '', maskNotations: stableNotations, maskAutocomplete: maskAutocomplete ?? true, maskAutoSkip: maskAutoSkip ?? false, maskAffinityFormats: stableAffinityFormats, maskAffinityStrategy: maskAffinityStrategy ?? 'wholeString', maskTextCase: maskTextCase ?? 'none', maskCharacterMap: stableCharacterMap, maskSlotPlaceholder: maskSlotPlaceholder ?? (keepPlaceholder ? '_' : ''), keepPlaceholder: keepPlaceholder ?? false, onChangeMask: onChangeMaskCallback, keyboardType: resolvedKeyboardType, returnKeyType: resolvedReturnKeyType, autoCapitalize: autoCapitalize ?? 'sentences', autoCorrect: autoCorrect ?? true, editable: (editable ?? true) && !(readOnly ?? false), multiline: isMultiline, numberOfLines: Math.max(0, Math.trunc(numberOfLines ?? rows ?? 0)), textAlignVertical: textAlignVertical ?? 'auto', scrollEnabled: scrollEnabled ?? true, autoFocus: autoFocus ?? false, fieldTestID: viewProps.testID ?? '', fieldAccessibilityLabel: resolvedAccessibilityLabel ?? '', submitBehavior: submitBehavior ??
791
+ mostRecentEventCount: value != null ? eventCountRef.current : 0, prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, placeholderColor: processedPlaceholderColor, duration: duration ?? 400, easing: easing ?? 'expo', bounce: bounce ?? 0.15, effect: effect ?? 'auto', textColor: processedColor, textAlignment: textAlign ?? 'auto', rightToLeft: rightToLeft, caretColor: processedCursorColor, selectionColor: processedSelectionColor, caretHidden: caretHidden ?? false, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, labelColor: processedLabelColor, labelFocusedColor: processedLabelFocusedColor, strokeColor: processedStrokeColor, focusedStrokeColor: processedFocusedStrokeColor, strokeWidth: strokeWidth ?? 1, fillColor: processedFillColor, onChangeMask: onChangeMaskCallback, keyboardType: resolvedKeyboardType, returnKeyType: resolvedReturnKeyType, autoCapitalize: autoCapitalize ?? 'sentences', autoCorrect: autoCorrect ?? true, editable: (editable ?? true) && !(readOnly ?? false), numberOfLines: Math.max(0, Math.trunc(numberOfLines ?? rows ?? 0)), textVerticalAlignment: textAlignVertical ?? 'auto', textInsetLeft: insets.left, textInsetTop: insets.top, textInsetRight: insets.right, textInsetBottom: insets.bottom, scrollEnabled: scrollEnabled ?? true, autoFocus: autoFocus ?? false, fieldTestID: viewProps.testID ?? '', fieldAccessibilityLabel: resolvedAccessibilityLabel ?? '', submitBehavior: submitBehavior ??
651
792
  // As `TextInput` resolves the legacy `blurOnSubmit`: a multiline
652
793
  // field's return key inserts a line break unless told to blur.
653
794
  (multiline
@@ -656,7 +797,7 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
656
797
  : 'newline'
657
798
  : blurOnSubmit === false
658
799
  ? 'submit'
659
- : 'blurAndSubmit'), secureTextEntry: secureTextEntry ?? false, keyboardAppearance: keyboardAppearance ?? 'default', textContentType: textContentType ?? autoComplete ?? '', enablesReturnKeyAutomatically: enablesReturnKeyAutomatically ?? false, showSoftInputOnFocus: resolvedShowSoftInput, selectTextOnFocus: selectTextOnFocus ?? false, clearTextOnFocus: clearTextOnFocus ?? false, keyboardHandoffMs: keyboardHandoffMs ?? 0, returnKeyBar: returnKeyBar ?? true, contextMenuHidden: contextMenuHidden ?? false, spellCheck: spellCheck ?? autoCorrect ?? true, selectionStart: selection?.start ?? -1, selectionEnd: selection?.end ?? selection?.start ?? -1, maxLength: maxLength ?? 0, transformWorklet: transformId, onChangeTextWorklet: onChangeTextId, onChangeValueWorklet: onChangeValueId, onFocusChangeWorklet: onFocusId, onSelectionChangeWorklet: onSelectionChangeId, onSubmitEditingWorklet: onSubmitEditingId, onEndEditingWorklet: onEndEditingId, onKeyPressWorklet: onKeyPressId, onChangeText: onChangeTextCallback, onChangeValue: onChangeValueCallback, onFocusChange: onFocusChangeCallback, onSubmitEditing: onSubmitEditingCallback, onEndEditing: onEndEditingCallback, onSelectionChange: onSelectionChangeCallback, onKeyPress: onKeyPressCallback, onSizeChange: onSizeChange }));
800
+ : 'blurAndSubmit'), keyboardAppearance: keyboardAppearance ?? 'default', textContentType: textContentType ?? autoComplete ?? '', enablesReturnKeyAutomatically: enablesReturnKeyAutomatically ?? false, showSoftInputOnFocus: resolvedShowSoftInput, selectTextOnFocus: selectTextOnFocus ?? false, clearTextOnFocus: clearTextOnFocus ?? false, keyboardHandoffMs: keyboardHandoffMs ?? 0, returnKeyBar: returnKeyBar ?? true, contextMenuHidden: contextMenuHidden ?? false, spellCheck: spellCheck ?? autoCorrect ?? true, selectionStart: selection?.start ?? -1, selectionEnd: selection?.end ?? selection?.start ?? -1, transformWorklet: transformId, onChangeTextWorklet: onChangeTextId, onChangeValueWorklet: onChangeValueId, onFocusChangeWorklet: onFocusId, onSelectionChangeWorklet: onSelectionChangeId, onSubmitEditingWorklet: onSubmitEditingId, onEndEditingWorklet: onEndEditingId, onKeyPressWorklet: onKeyPressId, onChangeText: onChangeTextCallback, onChangeValue: onChangeValueCallback, onFocusChange: onFocusChangeCallback, onSubmitEditing: onSubmitEditingCallback, onEndEditing: onEndEditingCallback, onSelectionChange: onSelectionChangeCallback, onKeyPress: onKeyPressCallback, onSizeChange: onSizeChange }));
660
801
  });
661
802
  // The name DevTools and error stacks show, as `TextInput` names itself.
662
803
  exports.NitroInput.displayName = 'NitroInput';
@@ -194,5 +194,5 @@ exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, mino
194
194
  // does not hand a Hybrid View its resolved direction, so native is told.
195
195
  const layoutDirection = (0, react_1.useMemo)(() => react_native_1.StyleSheet.flatten(style)?.direction, [style]);
196
196
  const rightToLeft = layoutDirection === 'rtl' || (layoutDirection !== 'ltr' && react_native_1.I18nManager.isRTL);
197
- return (react_1.default.createElement(exports.NativeNitroNumberView, { ...viewProps, style: [autoSize, style], hybridRef: hybridRef, value: shownValue, fractionDigits: fractionDigits ?? figure?.fractionDigits ?? 0, minimumIntegerDigits: minimumIntegerDigits ?? derived?.minimumIntegerDigits ?? 1, groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? '', decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.', prefix: prefix ?? compact?.prefix ?? derived?.prefix ?? '', suffix: suffix ?? compact?.suffix ?? derived?.suffix ?? '', transition: transition ?? 'roll', flashUpColor: processedFlashUp, flashDownColor: processedFlashDown, flashDuration: flashDuration ?? 600, popOnChange: popOnChange ?? 0, duration: still ? 0 : duration ?? TRANSITION_DEFAULTS[transition ?? 'roll'].duration, easing: easing ?? TRANSITION_DEFAULTS[transition ?? 'roll'].easing, bounce: bounce ?? 0.15, stagger: stagger ?? TRANSITION_DEFAULTS[transition ?? 'roll'].stagger, rollDirection: direction ?? compactDirection ?? 'auto', revealState: reveal === undefined ? 0 : reveal ? 2 : 1, revealStyle: revealStyle ?? 'count', revealDuration: still ? 0 : revealDuration ?? 2200, revealBounce: revealBounce ?? 0.12, revealGrow: revealGrow ?? 0.2, revealStagger: revealStagger ?? 200, revealMilestones: stableMilestones, revealMilestoneHold: revealMilestoneHold ?? 0, onRevealEnd: onRevealEndCallback, onRevealMilestone: onRevealMilestoneCallback, onAnimationStart: onAnimationStartCallback, onAnimationEnd: onAnimationEndCallback, loading: loading ?? false, shimmerColor: processedShimmerColor, shimmerDuration: shimmerDuration ?? 950, shimmerAngle: shimmerAngle ?? 31, shimmerWidth: shimmerWidth ?? 1, shimmerBaseColor: processedShimmerBase, shimmerDirection: shimmerDirection ?? 'auto', shimmerDelay: shimmerDelay ?? 0, fontSize: resolvedFontSize, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, affixAlign: resolvedAffixAlign, prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, letterSpacing: letterSpacing ?? 0, prefixSpacing: prefixSpacing ?? Infinity, suffixSpacing: suffixSpacing ?? Infinity, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, tabularNums: tabularNums ?? true, signDisplay: signDisplay ?? derived?.signDisplay ?? 'auto', plusSign: plusSign ?? derived?.plusSign ?? '+', minusSign: minusSign ?? derived?.minusSign ?? '-', digitGlyphs: stableGlyphs, groupingSizes: stableGroups, digitMax: digitMax, continuous: continuous ?? false, prefixColor: processedPrefixColor, suffixColor: processedSuffixColor, fractionColor: processedFractionColor, fractionFontSize: fractionFontSize ?? Infinity, fractionAlign: fractionAlign ?? 'baseline', respectReduceMotion: respectReduceMotion ?? true, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, allowFontScaling: allowFontScaling ?? false, maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0, fontWeight: numericWeight, fontFamily: fontFamily ?? '', color: processedColor, textAlign: textAlign ?? 'auto', rightToLeft: rightToLeft, onSizeChange: onSizeChange }));
197
+ return (react_1.default.createElement(exports.NativeNitroNumberView, { ...viewProps, style: [autoSize, style], hybridRef: hybridRef, value: shownValue, fractionDigits: fractionDigits ?? figure?.fractionDigits ?? 0, minimumIntegerDigits: minimumIntegerDigits ?? derived?.minimumIntegerDigits ?? 1, groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? '', decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.', prefix: prefix ?? compact?.prefix ?? derived?.prefix ?? '', suffix: suffix ?? compact?.suffix ?? derived?.suffix ?? '', transition: transition ?? 'roll', flashUpColor: processedFlashUp, flashDownColor: processedFlashDown, flashDuration: flashDuration ?? 600, popOnChange: popOnChange ?? 0, duration: still ? 0 : duration ?? TRANSITION_DEFAULTS[transition ?? 'roll'].duration, easing: easing ?? TRANSITION_DEFAULTS[transition ?? 'roll'].easing, bounce: bounce ?? 0.15, stagger: stagger ?? TRANSITION_DEFAULTS[transition ?? 'roll'].stagger, rollDirection: direction ?? compactDirection ?? 'auto', revealState: reveal === undefined ? 0 : reveal ? 2 : 1, revealStyle: revealStyle ?? 'count', revealDuration: still ? 0 : revealDuration ?? 2200, revealBounce: revealBounce ?? 0.12, revealGrow: revealGrow ?? 0.2, revealStagger: revealStagger ?? 200, revealMilestones: stableMilestones, revealMilestoneHold: revealMilestoneHold ?? 0, onRevealEnd: onRevealEndCallback, onRevealMilestone: onRevealMilestoneCallback, onAnimationStart: onAnimationStartCallback, onAnimationEnd: onAnimationEndCallback, loading: loading ?? false, shimmerColor: processedShimmerColor, shimmerDuration: shimmerDuration ?? 950, shimmerAngle: shimmerAngle ?? 31, shimmerWidth: shimmerWidth ?? 1, shimmerBaseColor: processedShimmerBase, shimmerDirection: shimmerDirection ?? 'auto', shimmerDelay: shimmerDelay ?? 0, textSize: resolvedFontSize, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, affixAlign: resolvedAffixAlign, prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, textLetterSpacing: letterSpacing ?? 0, prefixSpacing: prefixSpacing ?? Infinity, suffixSpacing: suffixSpacing ?? Infinity, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, tabularNums: tabularNums ?? true, signDisplay: signDisplay ?? derived?.signDisplay ?? 'auto', plusSign: plusSign ?? derived?.plusSign ?? '+', minusSign: minusSign ?? derived?.minusSign ?? '-', digitGlyphs: stableGlyphs, groupingSizes: stableGroups, digitMax: digitMax, continuous: continuous ?? false, prefixColor: processedPrefixColor, suffixColor: processedSuffixColor, fractionColor: processedFractionColor, fractionFontSize: fractionFontSize ?? Infinity, fractionAlign: fractionAlign ?? 'baseline', respectReduceMotion: respectReduceMotion ?? true, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, allowFontScaling: allowFontScaling ?? false, maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0, textWeight: numericWeight, textFamily: fontFamily ?? '', textColor: processedColor, textAlignment: textAlign ?? 'auto', rightToLeft: rightToLeft, onSizeChange: onSizeChange }));
198
198
  });
@@ -86,18 +86,18 @@ function NitroText({ children, fontSize, fontWeight, fontFamily, color, letterSp
86
86
  native.text = text;
87
87
  native.style = style == null ? { width: Math.ceil(width), height } : [{ width: Math.ceil(width), height }, style];
88
88
  if (size !== 17)
89
- native.fontSize = size;
89
+ native.textSize = size;
90
90
  if (weight !== 400)
91
- native.fontWeight = weight;
91
+ native.textWeight = weight;
92
92
  if (family !== '')
93
- native.fontFamily = family;
93
+ native.textFamily = family;
94
94
  if (spacing !== 0)
95
- native.letterSpacing = spacing;
95
+ native.textLetterSpacing = spacing;
96
96
  const processedColor = (0, styleHelpers_1.toProcessedColor)(color);
97
97
  if (processedColor !== undefined)
98
- native.color = processedColor;
98
+ native.textColor = processedColor;
99
99
  if (textAlign !== undefined)
100
- native.textAlign = textAlign;
100
+ native.textAlignment = textAlign;
101
101
  if (duration !== undefined)
102
102
  native.duration = duration;
103
103
  if (easing !== undefined)
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });