react-native-nitro-input 0.2.0 → 0.3.1

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 (222) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +132 -2
  3. package/android/CMakeLists.txt +4 -0
  4. package/android/gradle.properties +1 -1
  5. package/android/src/main/cpp/JReflowEngine.cpp +32 -0
  6. package/android/src/main/cpp/JReflowEngine.hpp +13 -0
  7. package/android/src/main/cpp/JRollingEngine.cpp +43 -2
  8. package/android/src/main/cpp/JRollingEngine.hpp +9 -1
  9. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +20 -0
  10. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform.kt +284 -0
  11. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +113 -0
  12. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextMeasure.kt +25 -0
  13. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +140 -0
  14. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputPackage.kt +2 -1
  15. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +69 -10
  16. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +522 -130
  17. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroTextView.kt +868 -0
  18. package/android/src/main/java/com/margelo/nitro/nitroinput/ReflowEngine.kt +21 -0
  19. package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +14 -2
  20. package/cpp/RollingEngine.cpp +102 -8
  21. package/cpp/RollingEngine.hpp +44 -3
  22. package/cpp/numberformat/HybridNitroNumberFormat.cpp +498 -0
  23. package/cpp/numberformat/HybridNitroNumberFormat.hpp +74 -0
  24. package/cpp/numberformat/HybridNitroNumberFormatFactory.hpp +11 -0
  25. package/cpp/numberformat/NumberFormatCore.cpp +629 -0
  26. package/cpp/numberformat/NumberFormatCore.hpp +154 -0
  27. package/cpp/numberformat/NumberFormatProbe.cpp +354 -0
  28. package/cpp/numberformat/NumberFormatProbe.hpp +63 -0
  29. package/ios/HybridNitroInputView.swift +15 -0
  30. package/ios/HybridNitroNumberFormatPlatform.swift +426 -0
  31. package/ios/HybridNitroNumberView.swift +101 -1
  32. package/ios/HybridNitroTextView.swift +134 -0
  33. package/ios/NitroInputView.swift +79 -19
  34. package/ios/NitroNumberView.swift +520 -147
  35. package/ios/NitroTextView.swift +583 -0
  36. package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
  37. package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
  38. package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
  39. package/lib/commonjs/src/NitroInput.js +8 -6
  40. package/lib/commonjs/src/NitroNumber.js +54 -3
  41. package/lib/commonjs/src/NitroText.js +138 -0
  42. package/lib/commonjs/src/NitroTime.js +65 -0
  43. package/lib/commonjs/src/NumberFormat.js +525 -0
  44. package/lib/commonjs/src/formatProps.js +108 -0
  45. package/lib/commonjs/src/index.js +8 -1
  46. package/lib/commonjs/src/specs/NitroText.nitro.js +2 -0
  47. package/lib/commonjs/src/specs/NumberFormat.nitro.js +2 -0
  48. package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
  49. package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
  50. package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
  51. package/lib/module/src/NitroInput.js +8 -6
  52. package/lib/module/src/NitroNumber.js +54 -3
  53. package/lib/module/src/NitroText.js +98 -0
  54. package/lib/module/src/NitroTime.js +29 -0
  55. package/lib/module/src/NumberFormat.js +521 -0
  56. package/lib/module/src/formatProps.js +104 -0
  57. package/lib/module/src/index.js +3 -0
  58. package/lib/module/src/specs/NitroText.nitro.js +1 -0
  59. package/lib/module/src/specs/NumberFormat.nitro.js +1 -0
  60. package/lib/typescript/src/NitroInput.d.ts +22 -0
  61. package/lib/typescript/src/NitroNumber.d.ts +115 -2
  62. package/lib/typescript/src/NitroText.d.ts +67 -0
  63. package/lib/typescript/src/NitroTime.d.ts +19 -0
  64. package/lib/typescript/src/NumberFormat.d.ts +47 -0
  65. package/lib/typescript/src/formatProps.d.ts +47 -0
  66. package/lib/typescript/src/index.d.ts +6 -1
  67. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +10 -0
  68. package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +80 -1
  69. package/lib/typescript/src/specs/NitroText.nitro.d.ts +60 -0
  70. package/lib/typescript/src/specs/NumberFormat.nitro.d.ts +139 -0
  71. package/nitro.json +36 -0
  72. package/nitrogen/generated/android/NitroInput+autolinking.cmake +12 -0
  73. package/nitrogen/generated/android/NitroInputOnLoad.cpp +62 -0
  74. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +45 -0
  75. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +10 -0
  76. package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp +118 -0
  77. package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.hpp +64 -0
  78. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +297 -0
  79. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +52 -0
  80. package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp +65 -0
  81. package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.hpp +64 -0
  82. package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.cpp +58 -0
  83. package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.hpp +64 -0
  84. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +253 -0
  85. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +104 -0
  86. package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +3 -0
  87. package/nitrogen/generated/android/c++/JNitroNumberShimmerDirection.hpp +61 -0
  88. package/nitrogen/generated/android/c++/JNitroNumberSignDisplay.hpp +67 -0
  89. package/nitrogen/generated/android/c++/JNumberFormatCompactDisplay.hpp +58 -0
  90. package/nitrogen/generated/android/c++/JNumberFormatCurrencyDisplay.hpp +64 -0
  91. package/nitrogen/generated/android/c++/JNumberFormatCurrencySign.hpp +58 -0
  92. package/nitrogen/generated/android/c++/JNumberFormatNotation.hpp +64 -0
  93. package/nitrogen/generated/android/c++/JNumberFormatPlatformOptions.hpp +161 -0
  94. package/nitrogen/generated/android/c++/JNumberFormatPlatformSymbols.hpp +89 -0
  95. package/nitrogen/generated/android/c++/JNumberFormatRoundingMode.hpp +79 -0
  96. package/nitrogen/generated/android/c++/JNumberFormatSignDisplay.hpp +67 -0
  97. package/nitrogen/generated/android/c++/JNumberFormatStyle.hpp +64 -0
  98. package/nitrogen/generated/android/c++/JNumberFormatUnitDisplay.hpp +61 -0
  99. package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +25 -0
  100. package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +130 -0
  101. package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +174 -0
  102. package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.hpp +54 -0
  103. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +30 -0
  104. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatformSpec.kt +60 -0
  105. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +172 -0
  106. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroPlatformNumberFormatterSpec.kt +62 -0
  107. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextMeasureSpec.kt +60 -0
  108. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +179 -0
  109. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +2 -1
  110. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberShimmerDirection.kt +24 -0
  111. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberSignDisplay.kt +26 -0
  112. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCompactDisplay.kt +23 -0
  113. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencyDisplay.kt +25 -0
  114. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencySign.kt +23 -0
  115. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatNotation.kt +25 -0
  116. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformOptions.kt +136 -0
  117. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformSymbols.kt +91 -0
  118. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatRoundingMode.kt +30 -0
  119. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatSignDisplay.kt +26 -0
  120. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatStyle.kt +25 -0
  121. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatUnitDisplay.kt +24 -0
  122. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroTextViewManager.kt +96 -0
  123. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroTextViewStateUpdater.kt +23 -0
  124. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +68 -0
  125. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +184 -0
  126. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +56 -0
  127. package/nitrogen/generated/ios/NitroInputAutolinking.mm +34 -0
  128. package/nitrogen/generated/ios/NitroInputAutolinking.swift +36 -0
  129. package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +30 -0
  130. package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.cpp +11 -0
  131. package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.hpp +122 -0
  132. package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +188 -0
  133. package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.cpp +11 -0
  134. package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.hpp +94 -0
  135. package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.cpp +11 -0
  136. package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.hpp +90 -0
  137. package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.cpp +11 -0
  138. package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +233 -0
  139. package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +30 -0
  140. package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +156 -0
  141. package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +264 -0
  142. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +5 -0
  143. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +55 -0
  144. package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec.swift +56 -0
  145. package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec_cxx.swift +159 -0
  146. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +26 -0
  147. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +658 -21
  148. package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec.swift +56 -0
  149. package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec_cxx.swift +155 -0
  150. package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec.swift +56 -0
  151. package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec_cxx.swift +150 -0
  152. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +75 -0
  153. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +608 -0
  154. package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +4 -0
  155. package/nitrogen/generated/ios/swift/NitroNumberShimmerDirection.swift +44 -0
  156. package/nitrogen/generated/ios/swift/NitroNumberSignDisplay.swift +52 -0
  157. package/nitrogen/generated/ios/swift/NumberFormatCompactDisplay.swift +40 -0
  158. package/nitrogen/generated/ios/swift/NumberFormatCurrencyDisplay.swift +48 -0
  159. package/nitrogen/generated/ios/swift/NumberFormatCurrencySign.swift +40 -0
  160. package/nitrogen/generated/ios/swift/NumberFormatNotation.swift +48 -0
  161. package/nitrogen/generated/ios/swift/NumberFormatPlatformOptions.swift +159 -0
  162. package/nitrogen/generated/ios/swift/NumberFormatPlatformSymbols.swift +69 -0
  163. package/nitrogen/generated/ios/swift/NumberFormatRoundingMode.swift +68 -0
  164. package/nitrogen/generated/ios/swift/NumberFormatSignDisplay.swift +52 -0
  165. package/nitrogen/generated/ios/swift/NumberFormatStyle.swift +48 -0
  166. package/nitrogen/generated/ios/swift/NumberFormatUnitDisplay.swift +44 -0
  167. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +10 -0
  168. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +10 -0
  169. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp +22 -0
  170. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.hpp +70 -0
  171. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp +22 -0
  172. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.hpp +70 -0
  173. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp +23 -0
  174. package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.hpp +71 -0
  175. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +52 -0
  176. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +58 -0
  177. package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp +23 -0
  178. package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.hpp +65 -0
  179. package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.cpp +22 -0
  180. package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.hpp +63 -0
  181. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +62 -0
  182. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +115 -0
  183. package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +4 -0
  184. package/nitrogen/generated/shared/c++/NitroNumberShimmerDirection.hpp +80 -0
  185. package/nitrogen/generated/shared/c++/NitroNumberSignDisplay.hpp +88 -0
  186. package/nitrogen/generated/shared/c++/NumberFormatCompactDisplay.hpp +76 -0
  187. package/nitrogen/generated/shared/c++/NumberFormatCurrencyDisplay.hpp +84 -0
  188. package/nitrogen/generated/shared/c++/NumberFormatCurrencySign.hpp +76 -0
  189. package/nitrogen/generated/shared/c++/NumberFormatGrouping.hpp +80 -0
  190. package/nitrogen/generated/shared/c++/NumberFormatNotation.hpp +84 -0
  191. package/nitrogen/generated/shared/c++/NumberFormatOptions.hpp +193 -0
  192. package/nitrogen/generated/shared/c++/NumberFormatPart.hpp +87 -0
  193. package/nitrogen/generated/shared/c++/NumberFormatPlatformOptions.hpp +176 -0
  194. package/nitrogen/generated/shared/c++/NumberFormatPlatformSymbols.hpp +115 -0
  195. package/nitrogen/generated/shared/c++/NumberFormatRoundingMode.hpp +104 -0
  196. package/nitrogen/generated/shared/c++/NumberFormatRoundingPriority.hpp +80 -0
  197. package/nitrogen/generated/shared/c++/NumberFormatSignDisplay.hpp +88 -0
  198. package/nitrogen/generated/shared/c++/NumberFormatStyle.hpp +84 -0
  199. package/nitrogen/generated/shared/c++/NumberFormatTrailingZeroDisplay.hpp +76 -0
  200. package/nitrogen/generated/shared/c++/NumberFormatUnitDisplay.hpp +80 -0
  201. package/nitrogen/generated/shared/c++/ResolvedNumberFormatOptions.hpp +197 -0
  202. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +10 -0
  203. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +15 -0
  204. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +52 -0
  205. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +80 -0
  206. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +74 -0
  207. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +149 -0
  208. package/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
  209. package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
  210. package/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
  211. package/package.json +2 -2
  212. package/src/NitroInput.tsx +42 -7
  213. package/src/NitroNumber.tsx +236 -12
  214. package/src/NitroText.tsx +166 -0
  215. package/src/NitroTime.tsx +68 -0
  216. package/src/NumberFormat.ts +563 -0
  217. package/src/formatProps.ts +149 -0
  218. package/src/index.ts +23 -0
  219. package/src/specs/NitroInput.nitro.ts +10 -0
  220. package/src/specs/NitroNumber.nitro.ts +82 -1
  221. package/src/specs/NitroText.nitro.ts +65 -0
  222. package/src/specs/NumberFormat.nitro.ts +145 -0
@@ -43,6 +43,7 @@ const react_native_nitro_modules_1 = require("react-native-nitro-modules");
43
43
  const NitroInputViewConfig_json_1 = __importDefault(require("../nitrogen/generated/shared/json/NitroInputViewConfig.json"));
44
44
  const worklets_1 = require("./worklets");
45
45
  const styleHelpers_1 = require("./styleHelpers");
46
+ const formatProps_1 = require("./formatProps");
46
47
  const textInputRegistry = (() => {
47
48
  try {
48
49
  // The registry has no public surface: `TextInput.State` exposes the focus
@@ -175,7 +176,7 @@ function warnIncompatible(what) {
175
176
  * Like a `TextInput`, it takes its width from its parent; `autoWidth` sizes
176
177
  * it to its content instead, and is on by default when the text reflows.
177
178
  */
178
- exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaultValue, mode, fractionDigits, maxIntegerDigits, groupingSeparator, decimalSeparator, prefix, suffix, prefixFontSize, suffixFontSize, affixAlign, signPlacement, prefixAlign, suffixAlign, 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, returnKeyType, autoCapitalize, autoCorrect, editable, multiline, numberOfLines, rows, textAlignVertical, scrollEnabled, autoFocus, transition, autoWidth: autoWidthProp, submitBehavior, blurOnSubmit, secureTextEntry, keyboardAppearance, textContentType, autoComplete, enablesReturnKeyAutomatically, showSoftInputOnFocus, selectTextOnFocus, clearTextOnFocus, contextMenuHidden, spellCheck, readOnly, selection, onEndEditing, onSelectionChange, onKeyPress, maxLength, transform, onChangeText, onChange, onChangeValue, onChangeMask, onFocus, onBlur, onSubmitEditing, onNativeRef, style, ...viewProps }, ref) {
179
+ 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, returnKeyType, autoCapitalize, autoCorrect, editable, multiline, numberOfLines, rows, textAlignVertical, scrollEnabled, autoFocus, transition, autoWidth: autoWidthProp, submitBehavior, blurOnSubmit, secureTextEntry, keyboardAppearance, textContentType, autoComplete, enablesReturnKeyAutomatically, showSoftInputOnFocus, selectTextOnFocus, clearTextOnFocus, contextMenuHidden, spellCheck, readOnly, selection, onEndEditing, onSelectionChange, onKeyPress, maxLength, transform, onChangeText, onChange, onChangeValue, onChangeMask, onFocus, onBlur, onSubmitEditing, onNativeRef, style, ...viewProps }, ref) {
179
180
  const nativeRef = (0, react_1.useRef)(null);
180
181
  // What React Native's registry stores for this field. The React host
181
182
  // instance when there is one (iOS), otherwise a stable per-instance token:
@@ -467,13 +468,14 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
467
468
  if (suffix)
468
469
  warnIncompatible('suffix');
469
470
  }
470
- const resolvedMode = isMultiline ? 'text' : (mode ?? 'text');
471
+ const derived = format ? (0, formatProps_1.formatProps)(format) : undefined;
472
+ const resolvedMode = isMultiline ? 'text' : (mode ?? (derived ? 'number' : 'text'));
471
473
  const reflows = !isMultiline && transition === 'reflow';
472
474
  // The affixes are accessory views beside one line of text; a wrapping text
473
475
  // view has no slot for them, so they go with the mode rather than being
474
476
  // half-drawn on one platform and not the other.
475
- const resolvedPrefix = isMultiline ? '' : (prefix ?? '');
476
- const resolvedSuffix = isMultiline ? '' : (suffix ?? '');
477
+ const resolvedPrefix = isMultiline ? '' : (prefix ?? derived?.prefix ?? '');
478
+ const resolvedSuffix = isMultiline ? '' : (suffix ?? derived?.suffix ?? '');
477
479
  // A new `maskNotations` literal each render must not re-set the native
478
480
  // prop, so it is keyed on its contents. Always an array (empty = none):
479
481
  // removing the prop would reach native as `null`, which Nitro's array
@@ -482,7 +484,7 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
482
484
  const stableNotations = (0, react_1.useMemo)(() => (notationsKey !== '' && maskNotations ? [...maskNotations] : EMPTY_NOTATIONS),
483
485
  // eslint-disable-next-line react-hooks/exhaustive-deps
484
486
  [notationsKey]);
485
- const resolvedFractionDigits = fractionDigits ?? 2;
487
+ const resolvedFractionDigits = fractionDigits ?? derived?.fractionDigits ?? 2;
486
488
  const resolvedKeyboardType = keyboardType ??
487
489
  (inputMode != null
488
490
  ? INPUT_MODE_TO_KEYBOARD[inputMode]
@@ -544,7 +546,7 @@ exports.NitroInput = (0, react_1.forwardRef)(function NitroInput({ value, defaul
544
546
  ? { width: size.width, height: size.height }
545
547
  : { height: size.height }
546
548
  : { height: resolvedFontSize * 1.25 }, [size, resolvedFontSize, autoWidth]);
547
- return (react_1.default.createElement(exports.NativeNitroInputView, { ...hostViewProps, ref: hostRef, style: [autoSize, style], hybridRef: hybridRef, text: value ?? initialText, mostRecentEventCount: eventCountRef.current, mode: resolvedMode, plain: !reflows, fractionDigits: resolvedFractionDigits, maxIntegerDigits: maxIntegerDigits ?? 15, groupingSeparator: groupingSeparator ?? ',', decimalSeparator: decimalSeparator ?? '.', prefix: resolvedPrefix, suffix: resolvedSuffix, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, signPlacement: signPlacement ?? 'beforeAffix', prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, 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, 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 ??
549
+ return (react_1.default.createElement(exports.NativeNitroInputView, { ...hostViewProps, ref: hostRef, style: [autoSize, style], hybridRef: hybridRef, text: value ?? initialText, mostRecentEventCount: eventCountRef.current, 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, 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 ??
548
550
  // As `TextInput` resolves the legacy `blurOnSubmit`: a multiline
549
551
  // field's return key inserts a line break unless told to blur.
550
552
  (multiline
@@ -42,11 +42,14 @@ const react_native_1 = require("react-native");
42
42
  const react_native_nitro_modules_1 = require("react-native-nitro-modules");
43
43
  const NitroNumberViewConfig_json_1 = __importDefault(require("../nitrogen/generated/shared/json/NitroNumberViewConfig.json"));
44
44
  const styleHelpers_1 = require("./styleHelpers");
45
+ const formatProps_1 = require("./formatProps");
45
46
  /**
46
47
  * The raw Nitro host component. Prefer {@link NitroNumber}, which adds
47
48
  * auto-sizing, color/weight conversion and a convenient handle.
48
49
  */
49
50
  exports.NativeNitroNumberView = (0, react_native_nitro_modules_1.getHostComponent)('NitroNumberView', () => NitroNumberViewConfig_json_1.default);
51
+ const EMPTY = [];
52
+ const EMPTY_STRINGS = [];
50
53
  /** Each transition's own timing, used when the props leave it unsaid. */
51
54
  const TRANSITION_DEFAULTS = {
52
55
  roll: { duration: 500, easing: 'easeInOut', stagger: 0 },
@@ -63,7 +66,7 @@ const TRANSITION_DEFAULTS = {
63
66
  * The view sizes itself to its content unless you pass an explicit `width` /
64
67
  * `height` in `style`.
65
68
  */
66
- exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, fractionDigits, minimumIntegerDigits, groupingSeparator, decimalSeparator, prefix, suffix, transition, flashUpColor, flashDownColor, flashDuration, popOnChange, duration, easing, bounce, stagger, direction, reveal, revealStyle, revealDuration, revealBounce, revealGrow, revealStagger, revealMilestones, revealMilestoneHold, onRevealEnd, onRevealMilestone, loading, shimmerColor, shimmerDuration, fontSize, prefixFontSize, suffixFontSize, affixAlign, prefixAlign, suffixAlign, adjustsFontSizeToFit, minimumFontScale, allowFontScaling, maxFontSizeMultiplier, fontWeight, fontFamily, color, textAlign, onNativeRef, style, ...viewProps }, ref) {
69
+ exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, fractionDigits, minimumIntegerDigits, groupingSeparator, decimalSeparator, prefix, suffix, transition, flashUpColor, flashDownColor, flashDuration, popOnChange, duration, easing, bounce, stagger, direction, reveal, revealStyle, revealDuration, revealBounce, revealGrow, revealStagger, revealMilestones, revealMilestoneHold, onRevealEnd, onRevealMilestone, loading, shimmerColor, shimmerDuration, shimmerAngle, shimmerWidth, shimmerBaseColor, shimmerDirection, shimmerDelay, fontSize, prefixFontSize, suffixFontSize, affixAlign, prefixAlign, suffixAlign, letterSpacing, prefixSpacing, suffixSpacing, prefixOffset, suffixOffset, tabularNums, format, adjustsFontSizeToFit, minimumFontScale, allowFontScaling, maxFontSizeMultiplier, fontWeight, fontFamily, color, textAlign, signDisplay, plusSign, minusSign, prefixColor, suffixColor, fractionColor, fractionFontSize, fractionAlign, digitGlyphs, groupingSizes, digits, continuous, animated, respectReduceMotion, onAnimationStart, onAnimationEnd, onNativeRef, style, ...viewProps }, ref) {
67
70
  const nativeRef = (0, react_1.useRef)(null);
68
71
  const latestOnNativeRef = (0, react_1.useRef)(onNativeRef);
69
72
  latestOnNativeRef.current = onNativeRef;
@@ -73,6 +76,10 @@ exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, frac
73
76
  latestOnRevealMilestone.current = onRevealMilestone;
74
77
  const latestValue = (0, react_1.useRef)(value);
75
78
  latestValue.current = value;
79
+ const latestOnAnimationStart = (0, react_1.useRef)(onAnimationStart);
80
+ latestOnAnimationStart.current = onAnimationStart;
81
+ const latestOnAnimationEnd = (0, react_1.useRef)(onAnimationEnd);
82
+ latestOnAnimationEnd.current = onAnimationEnd;
76
83
  const [size, setSize] = (0, react_1.useState)(null);
77
84
  // Nitro callbacks must be wrapped with `callback()` and the wrapper object
78
85
  // has to be referentially stable, otherwise every render re-sets the prop.
@@ -95,6 +102,13 @@ exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, frac
95
102
  const onRevealMilestoneCallback = (0, react_1.useMemo)(() => (0, react_native_nitro_modules_1.callback)((index, milestone) => {
96
103
  latestOnRevealMilestone.current?.(index, milestone);
97
104
  }), []);
105
+ const onAnimationStartCallback = (0, react_1.useMemo)(() => (0, react_native_nitro_modules_1.callback)(() => {
106
+ latestOnAnimationStart.current?.();
107
+ }), []);
108
+ // The figure a compact format rolls is not the value (1.2 for 1,234): report the value.
109
+ const onAnimationEndCallback = (0, react_1.useMemo)(() => (0, react_native_nitro_modules_1.callback)((shown) => {
110
+ latestOnAnimationEnd.current?.(compactRef.current ? latestValue.current : shown);
111
+ }), []);
98
112
  // A new array literal each render must not re-set the native prop. Always an
99
113
  // array (empty = no tiers): removing the prop would reach native as `null`,
100
114
  // which Nitro's array parser rejects ("Value is null, expected an Object").
@@ -108,7 +122,7 @@ exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, frac
108
122
  jumpTo: (next) => nativeRef.current?.jumpTo(next),
109
123
  animateTo: (next) => nativeRef.current?.animateTo(next),
110
124
  revealTo: (next) => nativeRef.current?.revealTo(next),
111
- getValue: () => nativeRef.current?.value ?? latestValue.current,
125
+ getValue: () => (compactRef.current ? latestValue.current : nativeRef.current?.value ?? latestValue.current),
112
126
  get native() {
113
127
  return nativeRef.current;
114
128
  },
@@ -122,11 +136,48 @@ exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, frac
122
136
  // render and had the whole configuration re-applied on every value change.
123
137
  const processedColor = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(color) ?? Infinity, [color]);
124
138
  const processedShimmerColor = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(shimmerColor) ?? Infinity, [shimmerColor]);
139
+ const processedShimmerBase = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(shimmerBaseColor) ?? Infinity, [shimmerBaseColor]);
125
140
  const processedFlashUp = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(flashUpColor) ?? Infinity, [flashUpColor]);
126
141
  const processedFlashDown = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(flashDownColor) ?? Infinity, [flashDownColor]);
127
142
  const numericWeight = (0, styleHelpers_1.toNumericWeight)(fontWeight) ?? 400;
128
143
  const resolvedFontSize = fontSize ?? 32;
129
144
  const resolvedAffixAlign = affixAlign ?? 'baseline';
145
+ const derived = format ? (0, formatProps_1.formatProps)(format) : undefined;
146
+ // Compact notation: "1.2K" rolls the figure 1.2 and swaps the suffix.
147
+ const compact = format && derived?.compact ? (0, formatProps_1.compactParts)(format, value) : undefined;
148
+ const compactRef = (0, react_1.useRef)(false);
149
+ compactRef.current = compact !== undefined;
150
+ // Which way the value moved, for a compact figure that fell while the value grew (999 → 1K).
151
+ const previousValue = (0, react_1.useRef)(value);
152
+ const compactDirection = compact && direction === undefined ? (value >= previousValue.current ? 'up' : 'down') : undefined;
153
+ previousValue.current = value;
154
+ const processedPrefixColor = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(prefixColor) ?? Infinity, [prefixColor]);
155
+ const processedSuffixColor = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(suffixColor) ?? Infinity, [suffixColor]);
156
+ const processedFractionColor = (0, react_1.useMemo)(() => (0, styleHelpers_1.toProcessedColor)(fractionColor) ?? Infinity, [fractionColor]);
157
+ // Arrays reach native only when their contents change.
158
+ const digitMaxKey = digits ? JSON.stringify(digits) : '';
159
+ const digitMax = (0, react_1.useMemo)(() => {
160
+ if (!digits)
161
+ return EMPTY;
162
+ const out = [];
163
+ for (const [position, spec] of Object.entries(digits)) {
164
+ const index = Number(position);
165
+ if (!Number.isInteger(index) || index < 0 || index >= 20)
166
+ continue;
167
+ while (out.length <= index)
168
+ out.push(9);
169
+ out[index] = spec.max;
170
+ }
171
+ return out;
172
+ // eslint-disable-next-line react-hooks/exhaustive-deps
173
+ }, [digitMaxKey]);
174
+ const glyphs = digitGlyphs ?? derived?.digitGlyphs ?? EMPTY_STRINGS;
175
+ const glyphsKey = glyphs.join('|');
176
+ const stableGlyphs = (0, react_1.useMemo)(() => glyphs, [glyphsKey]); // eslint-disable-line react-hooks/exhaustive-deps
177
+ const groups = groupingSizes ?? derived?.groupingSizes ?? EMPTY;
178
+ const groupsKey = groups.join(',');
179
+ const stableGroups = (0, react_1.useMemo)(() => groups, [groupsKey]); // eslint-disable-line react-hooks/exhaustive-deps
180
+ const still = animated === false;
130
181
  const autoSize = (0, react_1.useMemo)(() => size !== null
131
182
  ? { width: size.width, height: size.height }
132
183
  : { height: (fontSize ?? 32) * 1.25 }, [size, fontSize]);
@@ -135,5 +186,5 @@ exports.NitroNumber = (0, react_1.forwardRef)(function NitroNumber({ value, frac
135
186
  // does not hand a Hybrid View its resolved direction, so native is told.
136
187
  const layoutDirection = (0, react_1.useMemo)(() => react_native_1.StyleSheet.flatten(style)?.direction, [style]);
137
188
  const rightToLeft = layoutDirection === 'rtl' || (layoutDirection !== 'ltr' && react_native_1.I18nManager.isRTL);
138
- return (react_1.default.createElement(exports.NativeNitroNumberView, { ...viewProps, style: [autoSize, style], hybridRef: hybridRef, value: value, fractionDigits: fractionDigits ?? 0, minimumIntegerDigits: minimumIntegerDigits ?? 1, groupingSeparator: groupingSeparator ?? '', decimalSeparator: decimalSeparator ?? '.', prefix: prefix ?? '', suffix: suffix ?? '', transition: transition ?? 'roll', flashUpColor: processedFlashUp, flashDownColor: processedFlashDown, flashDuration: flashDuration ?? 600, popOnChange: popOnChange ?? 0, duration: 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 ?? 'auto', revealState: reveal === undefined ? 0 : reveal ? 2 : 1, revealStyle: revealStyle ?? 'count', revealDuration: revealDuration ?? 2200, revealBounce: revealBounce ?? 0.12, revealGrow: revealGrow ?? 0.2, revealStagger: revealStagger ?? 200, revealMilestones: stableMilestones, revealMilestoneHold: revealMilestoneHold ?? 0, onRevealEnd: onRevealEndCallback, onRevealMilestone: onRevealMilestoneCallback, loading: loading ?? false, shimmerColor: processedShimmerColor, shimmerDuration: shimmerDuration ?? 950, fontSize: resolvedFontSize, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, affixAlign: resolvedAffixAlign, prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, 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 }));
189
+ return (react_1.default.createElement(exports.NativeNitroNumberView, { ...viewProps, style: [autoSize, style], hybridRef: hybridRef, value: compact ? compact.value : value, fractionDigits: fractionDigits ?? compact?.fractionDigits ?? derived?.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 }));
139
190
  });
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.NativeNitroTextView = void 0;
40
+ exports.NitroText = NitroText;
41
+ const react_1 = __importStar(require("react"));
42
+ const react_native_1 = require("react-native");
43
+ const react_native_nitro_modules_1 = require("react-native-nitro-modules");
44
+ const NitroTextViewConfig_json_1 = __importDefault(require("../nitrogen/generated/shared/json/NitroTextViewConfig.json"));
45
+ const styleHelpers_1 = require("./styleHelpers");
46
+ /** The raw Nitro host component behind {@link NitroText}. */
47
+ exports.NativeNitroTextView = (0, react_native_nitro_modules_1.getHostComponent)('NitroTextView', () => NitroTextViewConfig_json_1.default);
48
+ let measurer = null;
49
+ function measure() {
50
+ measurer ??= react_native_nitro_modules_1.NitroModules.createHybridObject('NitroTextMeasure');
51
+ return measurer;
52
+ }
53
+ const lineHeights = new Map();
54
+ /**
55
+ * A single line of text that morphs to the next, natively, as Torph does on
56
+ * the web: the characters the two share glide to their new places, digits
57
+ * matched by place ("$1,204" → "$1,318" rolls the hundreds and tens), and the
58
+ * rest fade out and in ("Sign in" → "Signing in…"). At rest it is one line
59
+ * drawn in one pass, like a label: no text field, no layer per character.
60
+ * It sizes itself to its text in the render that mounts it (a native
61
+ * measurement, synchronously); a `width` in `style` overrides it.
62
+ *
63
+ * Only the props that were set go to the native view, as
64
+ * react-native-plain-text does: every prop that crosses is converted and
65
+ * stored per view in the commit, and the native side holds the defaults.
66
+ */
67
+ function NitroText({ children, fontSize, fontWeight, fontFamily, color, letterSpacing, textAlign, allowFontScaling, maxFontSizeMultiplier, duration, easing, bounce, effect, respectReduceMotion, loading, shimmerColor, shimmerDuration, shimmerAngle, shimmerWidth, shimmerBaseColor, shimmerDirection, shimmerDelay, style, ...viewProps }) {
68
+ const text = typeof children === 'string' ? children : String(children);
69
+ const scale = allowFontScaling
70
+ ? maxFontSizeMultiplier && maxFontSizeMultiplier > 0
71
+ ? Math.min(react_native_1.PixelRatio.getFontScale(), maxFontSizeMultiplier)
72
+ : react_native_1.PixelRatio.getFontScale()
73
+ : 1;
74
+ const size = (fontSize ?? 17) * scale;
75
+ const weight = fontWeight === undefined ? 400 : (0, styleHelpers_1.toNumericWeight)(fontWeight) ?? 400;
76
+ const family = fontFamily ?? '';
77
+ const spacing = letterSpacing ?? 0;
78
+ const width = (0, react_1.useMemo)(() => measure().measure(text, size, weight, family, spacing), [text, size, weight, family, spacing]);
79
+ const fontKey = `${size}|${weight}|${family}`;
80
+ let height = lineHeights.get(fontKey);
81
+ if (height === undefined) {
82
+ height = measure().lineHeight(size, weight, family);
83
+ lineHeights.set(fontKey, height);
84
+ }
85
+ const native = viewProps;
86
+ native.text = text;
87
+ native.style = style == null ? { width: Math.ceil(width), height } : [{ width: Math.ceil(width), height }, style];
88
+ if (size !== 17)
89
+ native.fontSize = size;
90
+ if (weight !== 400)
91
+ native.fontWeight = weight;
92
+ if (family !== '')
93
+ native.fontFamily = family;
94
+ if (spacing !== 0)
95
+ native.letterSpacing = spacing;
96
+ const processedColor = (0, styleHelpers_1.toProcessedColor)(color);
97
+ if (processedColor !== undefined)
98
+ native.color = processedColor;
99
+ if (textAlign !== undefined)
100
+ native.textAlign = textAlign;
101
+ if (duration !== undefined)
102
+ native.duration = duration;
103
+ if (easing !== undefined)
104
+ native.easing = easing;
105
+ if (bounce !== undefined)
106
+ native.bounce = bounce;
107
+ if (effect !== undefined)
108
+ native.effect = effect;
109
+ if (respectReduceMotion !== undefined)
110
+ native.respectReduceMotion = respectReduceMotion;
111
+ if (loading !== undefined)
112
+ native.loading = loading;
113
+ const processedShimmerColor = (0, styleHelpers_1.toProcessedColor)(shimmerColor);
114
+ if (processedShimmerColor !== undefined)
115
+ native.shimmerColor = processedShimmerColor;
116
+ if (shimmerDuration !== undefined)
117
+ native.shimmerDuration = shimmerDuration;
118
+ if (shimmerAngle !== undefined)
119
+ native.shimmerAngle = shimmerAngle;
120
+ if (shimmerWidth !== undefined)
121
+ native.shimmerWidth = shimmerWidth;
122
+ const processedShimmerBaseColor = (0, styleHelpers_1.toProcessedColor)(shimmerBaseColor);
123
+ if (processedShimmerBaseColor !== undefined)
124
+ native.shimmerBaseColor = processedShimmerBaseColor;
125
+ if (shimmerDirection !== undefined)
126
+ native.shimmerDirection = shimmerDirection;
127
+ if (shimmerDelay !== undefined)
128
+ native.shimmerDelay = shimmerDelay;
129
+ // The start edge follows the layout direction, the app's unless the style sets one.
130
+ const direction = style == null ? undefined : react_native_1.StyleSheet.flatten(style).direction;
131
+ if (direction === 'rtl' || (direction !== 'ltr' && react_native_1.I18nManager.isRTL))
132
+ native.rightToLeft = true;
133
+ // The native view is the accessibility element, labelled with its text and
134
+ // announced as text. A label from outside takes over, on this view.
135
+ if (native.accessibilityLabel != null && native.accessible === undefined)
136
+ native.accessible = true;
137
+ return react_1.default.createElement(exports.NativeNitroTextView, { ...native });
138
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NitroTime = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const NitroNumber_1 = require("./NitroNumber");
39
+ const LAYOUT = {
40
+ 'm:ss': { hours: false, digits: 3 },
41
+ 'mm:ss': { hours: false, digits: 4 },
42
+ 'h:mm:ss': { hours: true, digits: 5 },
43
+ 'hh:mm:ss': { hours: true, digits: 6 },
44
+ };
45
+ // The tens of seconds, and of minutes when hours are shown, wrap after 5.
46
+ const SECONDS = { 1: { max: 5 } };
47
+ const MINUTES_AND_SECONDS = { 1: { max: 5 }, 3: { max: 5 } };
48
+ // One separator before the seconds: 125:00 is 125 minutes, not 1:25:00.
49
+ const MINUTES_ONLY = [2, 0];
50
+ const PAIRS = [2];
51
+ /**
52
+ * A clock, a timer or a countdown: `NitroNumber` with the time as its figure
53
+ * (12:34:56 is 123456), grouped in pairs, and the tens of seconds and minutes
54
+ * wrapping after 5, so 0:59 → 1:00 turns them one step, as a clock's wheels
55
+ * do, instead of rolling back through 4, 3, 2, 1.
56
+ */
57
+ exports.NitroTime = (0, react_1.forwardRef)(function NitroTime({ seconds, timeFormat = 'm:ss', separator = ':', ...props }, ref) {
58
+ const layout = LAYOUT[timeFormat];
59
+ const total = Math.max(0, Math.floor(Number.isFinite(seconds) ? seconds : 0));
60
+ const s = total % 60;
61
+ const value = layout.hours
62
+ ? Math.floor(total / 3600) * 10000 + (Math.floor(total / 60) % 60) * 100 + s
63
+ : Math.floor(total / 60) * 100 + s;
64
+ return (react_1.default.createElement(NitroNumber_1.NitroNumber, { ref: ref, value: value, minimumIntegerDigits: layout.digits, groupingSeparator: separator, groupingSizes: layout.hours ? PAIRS : MINUTES_ONLY, digits: layout.hours ? MINUTES_AND_SECONDS : SECONDS, ...props }));
65
+ });