react-native-nitro-input 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +343 -3
- package/NitroInput.podspec +4 -4
- package/README.md +420 -53
- package/android/CMakeLists.txt +9 -3
- package/android/gradle.properties +1 -1
- package/android/src/main/cpp/JOutlineGeometry.hpp +1 -1
- package/android/src/main/cpp/JReflowEngine.cpp +132 -0
- package/android/src/main/cpp/{JMorphEngine.hpp → JReflowEngine.hpp} +7 -7
- package/android/src/main/cpp/JRollingEngine.cpp +223 -0
- package/android/src/main/cpp/JRollingEngine.hpp +68 -0
- package/android/src/main/cpp/cpp-adapter.cpp +4 -2
- package/android/src/main/java/com/margelo/nitro/nitroinput/AmountFormatter.kt +1 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +21 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform.kt +209 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +496 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputPackage.kt +2 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +107 -26
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +1881 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/{MorphEngine.kt → ReflowEngine.kt} +2 -2
- package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +60 -0
- package/cpp/AmountFormatter.cpp +5 -0
- package/cpp/AmountFormatter.hpp +10 -2
- package/cpp/{MorphEngine.cpp → ReflowEngine.cpp} +52 -47
- package/cpp/{MorphEngine.hpp → ReflowEngine.hpp} +12 -4
- package/cpp/RollingEngine.cpp +1234 -0
- package/cpp/RollingEngine.hpp +475 -0
- package/cpp/SwiftNonCopyable.hpp +22 -0
- package/cpp/numberformat/HybridNitroNumberFormat.cpp +498 -0
- package/cpp/numberformat/HybridNitroNumberFormat.hpp +74 -0
- package/cpp/numberformat/HybridNitroNumberFormatFactory.hpp +11 -0
- package/cpp/numberformat/NumberFormatCore.cpp +629 -0
- package/cpp/numberformat/NumberFormatCore.hpp +154 -0
- package/cpp/numberformat/NumberFormatProbe.cpp +354 -0
- package/cpp/numberformat/NumberFormatProbe.hpp +63 -0
- package/cpp/worklets/NitroInputWorkletsBridge.cpp +3 -3
- package/cpp/worklets/NitroInputWorkletsBridge.hpp +1 -1
- package/ios/{HybridMorphInputView.swift → HybridNitroInputView.swift} +16 -1
- package/ios/HybridNitroNumberFormatPlatform.swift +348 -0
- package/ios/HybridNitroNumberView.swift +458 -0
- package/ios/NitroInputView.swift +148 -64
- package/ios/NitroNumberView.swift +2074 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +61 -0
- package/lib/commonjs/src/NitroInput.js +27 -56
- package/lib/commonjs/src/NitroNumber.js +141 -0
- package/lib/commonjs/src/NumberFormat.js +525 -0
- package/lib/commonjs/src/formatProps.js +48 -0
- package/lib/commonjs/src/index.js +6 -3
- package/lib/commonjs/src/specs/NitroNumber.nitro.js +2 -0
- package/lib/commonjs/src/specs/NumberFormat.nitro.js +2 -0
- package/lib/commonjs/src/styleHelpers.js +36 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +61 -0
- package/lib/module/src/NitroInput.js +18 -47
- package/lib/module/src/NitroNumber.js +102 -0
- package/lib/module/src/NumberFormat.js +521 -0
- package/lib/module/src/formatProps.js +45 -0
- package/lib/module/src/index.js +2 -1
- package/lib/module/src/specs/NitroNumber.nitro.js +1 -0
- package/lib/module/src/specs/NumberFormat.nitro.js +1 -0
- package/lib/module/src/styleHelpers.js +32 -0
- package/lib/typescript/src/NitroInput.d.ts +50 -21
- package/lib/typescript/src/NitroNumber.d.ts +246 -0
- package/lib/typescript/src/NumberFormat.d.ts +47 -0
- package/lib/typescript/src/formatProps.d.ts +21 -0
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +19 -9
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +250 -0
- package/lib/typescript/src/specs/NumberFormat.nitro.d.ts +139 -0
- package/lib/typescript/src/styleHelpers.d.ts +3 -0
- package/nitro.json +26 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +10 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +48 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +10 -10
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp +118 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +590 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +168 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberAffixAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberEasing.hpp +67 -0
- package/nitrogen/generated/android/c++/JNitroNumberRevealStyle.hpp +58 -0
- package/nitrogen/generated/android/c++/JNitroNumberTextAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberTransition.hpp +61 -0
- package/nitrogen/generated/android/c++/JNumberFormatCompactDisplay.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencyDisplay.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencySign.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatNotation.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformOptions.hpp +161 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformSymbols.hpp +89 -0
- package/nitrogen/generated/android/c++/JNumberFormatRoundingMode.hpp +79 -0
- package/nitrogen/generated/android/c++/JNumberFormatSignDisplay.hpp +67 -0
- package/nitrogen/generated/android/c++/JNumberFormatStyle.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatUnitDisplay.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +25 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +329 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/Func_void_double_double.kt +9 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatformSpec.kt +60 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +399 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroPlatformNumberFormatterSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberAffixAlign.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberEasing.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberRevealStyle.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberTextAlign.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberTransition.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCompactDisplay.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencyDisplay.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencySign.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatNotation.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformOptions.kt +136 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformSymbols.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatRoundingMode.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatSignDisplay.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatStyle.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatUnitDisplay.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroNumberViewManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroNumberViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +59 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +311 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +63 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +26 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +24 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +30 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.hpp +122 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +474 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.hpp +94 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +30 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +450 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +5 -5
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +5 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec_cxx.swift +159 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +108 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +1387 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/NitroNumberAffixAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberEasing.swift +52 -0
- package/nitrogen/generated/ios/swift/NitroNumberRevealStyle.swift +40 -0
- package/nitrogen/generated/ios/swift/NitroNumberTextAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberTransition.swift +44 -0
- package/nitrogen/generated/ios/swift/NumberFormatCompactDisplay.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencyDisplay.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencySign.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatNotation.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformOptions.swift +159 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformSymbols.swift +69 -0
- package/nitrogen/generated/ios/swift/NumberFormatRoundingMode.swift +68 -0
- package/nitrogen/generated/ios/swift/NumberFormatSignDisplay.swift +52 -0
- package/nitrogen/generated/ios/swift/NumberFormatStyle.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatUnitDisplay.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +127 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +187 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/NitroNumberAffixAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberEasing.hpp +88 -0
- package/nitrogen/generated/shared/c++/NitroNumberRevealStyle.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroNumberTextAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberTransition.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatCompactDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencyDisplay.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencySign.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatGrouping.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatNotation.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatOptions.hpp +193 -0
- package/nitrogen/generated/shared/c++/NumberFormatPart.hpp +87 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformOptions.hpp +176 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformSymbols.hpp +115 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingMode.hpp +104 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingPriority.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatSignDisplay.hpp +88 -0
- package/nitrogen/generated/shared/c++/NumberFormatStyle.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatTrailingZeroDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatUnitDisplay.hpp +80 -0
- package/nitrogen/generated/shared/c++/ResolvedNumberFormatOptions.hpp +197 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +10 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +15 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +136 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +245 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +61 -0
- package/package.json +15 -7
- package/src/NitroInput.tsx +79 -67
- package/src/NitroNumber.tsx +531 -0
- package/src/NumberFormat.ts +563 -0
- package/src/formatProps.ts +59 -0
- package/src/index.ts +38 -6
- package/src/specs/NitroInput.nitro.ts +19 -9
- package/src/specs/NitroNumber.nitro.ts +271 -0
- package/src/specs/NumberFormat.nitro.ts +145 -0
- package/src/styleHelpers.ts +32 -0
- package/android/src/main/cpp/JMorphEngine.cpp +0 -132
- package/lib/commonjs/src/MorphInput.js +0 -42
- package/lib/module/src/MorphInput.js +0 -6
- package/lib/typescript/src/MorphInput.d.ts +0 -18
- package/src/MorphInput.tsx +0 -30
|
@@ -3,6 +3,7 @@ import { type ColorValue, type TextStyle, type ViewProps } from 'react-native';
|
|
|
3
3
|
import { type HybridRef } from 'react-native-nitro-modules';
|
|
4
4
|
import type { NitroInputAffixAlign, NitroInputAutoCapitalize, NitroInputEasing, NitroInputEffect, NitroInputKeyboardAppearance, NitroInputKeyboardType, NitroInputLabelBehavior, NitroInputMethods, NitroInputMode, NitroInputProps as NativeNitroInputProps, NitroInputReturnKeyType, NitroInputSubmitBehavior, NitroInputTextAlign, NitroInputTextAlignVertical, NitroInputSignPlacement, NitroInputVariant, NitroInputNotation } from './specs/NitroInput.nitro';
|
|
5
5
|
import { type NitroInputSelection, type NitroInputTransform } from './worklets';
|
|
6
|
+
import type { NumberFormat } from './NumberFormat';
|
|
6
7
|
/** React Native's `inputMode`, the HTML-aligned alias for `keyboardType`. */
|
|
7
8
|
export type InputMode = 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
8
9
|
/** React Native's `enterKeyHint`, the HTML-aligned alias for `returnKeyType`. */
|
|
@@ -168,7 +169,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
168
169
|
* Where a negative amount's sign sits relative to `prefix`. `'beforeAffix'`
|
|
169
170
|
* (the default) reads `-$1,234.56`; `'afterAffix'` reads `$-1,234.56`, which
|
|
170
171
|
* suits a symbol styled as an ornament rather than read as part of the
|
|
171
|
-
* number. Only the
|
|
172
|
+
* number. Only the reflow honours it - a plain field's affixes are accessory
|
|
172
173
|
* views outside the text, so it is always `'afterAffix'`.
|
|
173
174
|
*/
|
|
174
175
|
signPlacement?: NitroInputSignPlacement;
|
|
@@ -176,13 +177,34 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
176
177
|
prefixAlign?: NitroInputAffixAlign;
|
|
177
178
|
/** Alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
178
179
|
suffixAlign?: NitroInputAffixAlign;
|
|
179
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* Points added after every glyph, like `Text`'s `letterSpacing` (negative
|
|
182
|
+
* tightens). A smaller prefix or suffix gets it in proportion to its size.
|
|
183
|
+
* Default: `0`.
|
|
184
|
+
*/
|
|
185
|
+
letterSpacing?: number;
|
|
186
|
+
/** Points between the prefix and the text, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
187
|
+
prefixSpacing?: number;
|
|
188
|
+
/** Points between the text and the suffix, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
189
|
+
suffixSpacing?: number;
|
|
190
|
+
/** Points the prefix is moved down after `prefixAlign` places it (negative: up). Default: `0`. */
|
|
191
|
+
prefixOffset?: number;
|
|
192
|
+
/** Points the suffix is moved down after `suffixAlign` places it (negative: up). Default: `0`. */
|
|
193
|
+
suffixOffset?: number;
|
|
194
|
+
/**
|
|
195
|
+
* A `NumberFormat` the amount follows: its prefix and suffix (the currency
|
|
196
|
+
* where the locale puts it), grouping and decimal separators, fraction
|
|
197
|
+
* digits and where the sign goes. Sets `mode` to `'number'` unless it is
|
|
198
|
+
* given. The individual props override what it says.
|
|
199
|
+
*/
|
|
200
|
+
format?: NumberFormat;
|
|
201
|
+
/** Shown while the field is empty and reflowed away by the first character. In `'number'` mode `'0'` reads well. */
|
|
180
202
|
placeholder?: string;
|
|
181
203
|
/** Color of the placeholder. Defaults to the platform placeholder color. */
|
|
182
204
|
placeholderTextColor?: ColorValue;
|
|
183
|
-
/** Duration in ms of the
|
|
205
|
+
/** Duration in ms of the reflow played on every change. `0` snaps. Default: `400`. */
|
|
184
206
|
duration?: number;
|
|
185
|
-
/** Timing curve of the
|
|
207
|
+
/** Timing curve of the reflow. Default: `'expo'` (Torph's `cubic-bezier(0.19, 1, 0.22, 1)`). */
|
|
186
208
|
easing?: NitroInputEasing;
|
|
187
209
|
/** Overshoot of the `'spring'` easing, `0`–`1`. Default: `0.15`. */
|
|
188
210
|
bounce?: number;
|
|
@@ -199,7 +221,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
199
221
|
* line occupies rather than extra leading. Omit to use the font's own.
|
|
200
222
|
*
|
|
201
223
|
* Unlike `TextInput`, a line height *tighter* than the font is centred
|
|
202
|
-
* correctly too, and it applies to single-line and
|
|
224
|
+
* correctly too, and it applies to single-line and reflowing fields, not only
|
|
203
225
|
* wrapped ones.
|
|
204
226
|
*/
|
|
205
227
|
lineHeight?: number;
|
|
@@ -247,8 +269,8 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
247
269
|
*
|
|
248
270
|
* A multiline field is always drawn by the system view and is always
|
|
249
271
|
* `'text'` mode: the glyph engine lays one run out on one baseline, so it
|
|
250
|
-
* cannot
|
|
251
|
-
* `
|
|
272
|
+
* cannot reflow wrapped text, and an amount or a mask is a single-line idea.
|
|
273
|
+
* `transition="reflow"`, `mode="number"`, `mode="mask"` and the `prefix` / `suffix`
|
|
252
274
|
* affixes are ignored alongside it, with one warning each in development.
|
|
253
275
|
* The return key inserts a line break unless `submitBehavior` says otherwise.
|
|
254
276
|
*/
|
|
@@ -306,20 +328,22 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
306
328
|
end?: number;
|
|
307
329
|
};
|
|
308
330
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
331
|
+
* How the text changes. `'none'` (the default) draws it the instant it
|
|
332
|
+
* changes: this is a text field first, and a `TextInput` does not animate
|
|
333
|
+
* its characters. `'reflow'` runs the glyph engine, so characters that stay
|
|
334
|
+
* glide to their new place, new ones slide or fade in and removed ones leave
|
|
335
|
+
* alongside their neighbours, which is what an amount field wants. A
|
|
336
|
+
* multiline field is always `'none'`.
|
|
313
337
|
*/
|
|
314
|
-
|
|
338
|
+
transition?: NitroInputTransition;
|
|
315
339
|
/**
|
|
316
340
|
* Whether the field sizes itself to its content.
|
|
317
341
|
*
|
|
318
|
-
* `false`
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
342
|
+
* `false` takes no width of its own, so flexbox stretches it to its parent
|
|
343
|
+
* the way a `TextInput` is stretched — that is what makes this a drop-in.
|
|
344
|
+
* `true` always sizes to content. `'auto'` infers it: on unless `style`
|
|
345
|
+
* gives a `width` or `flex`, which is what lets an amount grow as digits
|
|
346
|
+
* arrive. Default: `'auto'` with `transition="reflow"`, else `false`.
|
|
323
347
|
*/
|
|
324
348
|
autoWidth?: boolean | 'auto';
|
|
325
349
|
/** `'text'` mode: most characters accepted. Default: unlimited. */
|
|
@@ -378,7 +402,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
378
402
|
export interface NitroInputHandle {
|
|
379
403
|
focus(): void;
|
|
380
404
|
blur(): void;
|
|
381
|
-
/** Empties the field,
|
|
405
|
+
/** Empties the field, reflowing the characters away. */
|
|
382
406
|
clear(): void;
|
|
383
407
|
/** Replaces the text (formatted in `'number'` mode), caret at the end. */
|
|
384
408
|
setText(text: string): void;
|
|
@@ -394,18 +418,23 @@ export interface NitroInputHandle {
|
|
|
394
418
|
/** The native Nitro object, or `null` before mount. */
|
|
395
419
|
readonly native: NitroInputRef | null;
|
|
396
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* How a `NitroInput`'s text changes: drawn at once (`'none'`), or reflowed by
|
|
423
|
+
* the glyph engine (`'reflow'`).
|
|
424
|
+
*/
|
|
425
|
+
export type NitroInputTransition = 'none' | 'reflow';
|
|
397
426
|
/**
|
|
398
427
|
* A native text input: a system field (`UITextField` / `EditText`) that owns
|
|
399
428
|
* the keyboard, editing, selection, paste and accessibility, with native
|
|
400
429
|
* formatting (`mode="number"`), native masking (`mode="mask"`), an outlined
|
|
401
430
|
* or filled frame with a floating label, and optionally the glyph engine
|
|
402
|
-
* (`
|
|
431
|
+
* (`transition="reflow"`), under which characters that stay glide to their new place, new
|
|
403
432
|
* ones slide or fade in and removed ones leave alongside their neighbours.
|
|
404
433
|
* In `'number'` mode every edit is formatted on the native side before a
|
|
405
434
|
* frame is drawn, with the caret kept in place, so there is never an
|
|
406
435
|
* unformatted frame and never a round trip through JS.
|
|
407
436
|
*
|
|
408
|
-
* Like a `TextInput`, it takes its width from its parent; `autoWidth`
|
|
409
|
-
*
|
|
437
|
+
* Like a `TextInput`, it takes its width from its parent; `autoWidth` sizes
|
|
438
|
+
* it to its content instead, and is on by default when the text reflows.
|
|
410
439
|
*/
|
|
411
440
|
export declare const NitroInput: React.ForwardRefExoticComponent<NitroInputProps & React.RefAttributes<NitroInputHandle>>;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ColorValue, type TextStyle, type ViewProps } from 'react-native';
|
|
3
|
+
import { type HybridRef } from 'react-native-nitro-modules';
|
|
4
|
+
import type { NitroNumberAffixAlign, NitroNumberDirection, NitroNumberTransition, NitroNumberEasing, NitroNumberMethods, NitroNumberProps as NativeNitroNumberProps, NitroNumberRevealStyle, NitroNumberTextAlign } from './specs/NitroNumber.nitro';
|
|
5
|
+
import type { NumberFormat } from './NumberFormat';
|
|
6
|
+
/**
|
|
7
|
+
* The raw Nitro host component. Prefer {@link NitroNumber}, which adds
|
|
8
|
+
* auto-sizing, color/weight conversion and a convenient handle.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NativeNitroNumberView: import("react-native-nitro-modules").ReactNativeView<NativeNitroNumberProps, NitroNumberMethods>;
|
|
11
|
+
/** The native Nitro `HybridObject` behind a mounted {@link NitroNumber}. */
|
|
12
|
+
export type NitroNumberRef = HybridRef<NativeNitroNumberProps, NitroNumberMethods>;
|
|
13
|
+
export interface NitroNumberProps extends Omit<ViewProps, 'children'> {
|
|
14
|
+
/**
|
|
15
|
+
* The number to display. Every change rolls each digit natively to its new
|
|
16
|
+
* glyph, in the direction of the change. The first value is shown instantly.
|
|
17
|
+
* At most 18 digits are shown: `|value| × 10^fractionDigits` is clamped at
|
|
18
|
+
* 10^17, and a JS number carries exact integers only up to 2^53.
|
|
19
|
+
*/
|
|
20
|
+
value: number;
|
|
21
|
+
/** Digits shown after the decimal separator. Default: `0`. */
|
|
22
|
+
fractionDigits?: number;
|
|
23
|
+
/** Zero-pads the integer part to at least this many digits. Default: `1`. */
|
|
24
|
+
minimumIntegerDigits?: number;
|
|
25
|
+
/** Inserted between every three integer digits (e.g. `','`). Default: none. */
|
|
26
|
+
groupingSeparator?: string;
|
|
27
|
+
/** Placed between integer and fraction digits. Default: `'.'`. */
|
|
28
|
+
decimalSeparator?: string;
|
|
29
|
+
/** Static text drawn before the number, e.g. `'$'`. */
|
|
30
|
+
prefix?: string;
|
|
31
|
+
/** Static text drawn after the number, e.g. `'%'`. */
|
|
32
|
+
suffix?: string;
|
|
33
|
+
/**
|
|
34
|
+
* How a value change plays. `'roll'` (default) is the odometer: every
|
|
35
|
+
* changed digit rolls through the digits between its old and new glyph, in
|
|
36
|
+
* the direction of the change. `'numeric'` is the numeric transition, the
|
|
37
|
+
* effect of SwiftUI's `.contentTransition(.numericText())`: each changed
|
|
38
|
+
* glyph swaps in place, the old one softening, shrinking and sliding out
|
|
39
|
+
* while the new one slides in from the other side and comes into focus, the
|
|
40
|
+
* digits cascading from the left; unchanged digits stay put. `'scramble'`
|
|
41
|
+
* shows a different random digit every few frames until each changed digit
|
|
42
|
+
* locks on its target, from the left.
|
|
43
|
+
*
|
|
44
|
+
* Each swap style has its own defaults for `duration`, `easing` and
|
|
45
|
+
* `stagger`: numeric 480 / (its own clocks) / 150, scramble 500 / `'linear'` / 60.
|
|
46
|
+
*/
|
|
47
|
+
transition?: NitroNumberTransition;
|
|
48
|
+
/**
|
|
49
|
+
* The change flash: every digit whose glyph changes lights up in this
|
|
50
|
+
* colour when the value grew (e.g. a green), stays lit while it moves,
|
|
51
|
+
* and fades back over `flashDuration` once it has landed. Unset: no flash.
|
|
52
|
+
*/
|
|
53
|
+
flashUpColor?: ColorValue;
|
|
54
|
+
/** The change flash's colour when the value shrank (e.g. a red). Unset: no flash. */
|
|
55
|
+
flashDownColor?: ColorValue;
|
|
56
|
+
/** Milliseconds a change flash takes to fade, once the digit has landed. Default: `600`. */
|
|
57
|
+
flashDuration?: number;
|
|
58
|
+
/**
|
|
59
|
+
* A punch of the whole figure on every value change, its peak overshoot
|
|
60
|
+
* as a fraction of the size, `0` (none, the default) to `1`; rung out like
|
|
61
|
+
* the reveal's landing pop. `0.08` is a nudge, `0.2` a slam.
|
|
62
|
+
*/
|
|
63
|
+
popOnChange?: number;
|
|
64
|
+
/** Duration in ms of the roll played when `value` changes. `0` snaps. Default: `500` (each swap transition has its own, see `transition`). */
|
|
65
|
+
duration?: number;
|
|
66
|
+
/** Timing curve of the roll. Default: `'easeInOut'` (the scramble has its own, see `transition`; the numeric transition keeps SwiftUI's own clocks and ignores it). */
|
|
67
|
+
easing?: NitroNumberEasing;
|
|
68
|
+
/** Overshoot of the `'spring'` easing, `0`–`1`. Default: `0.15` (the numeric transition has its own, fixed). */
|
|
69
|
+
bounce?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Delay in ms between the start of each digit's roll, least significant
|
|
72
|
+
* digit first, so a change cascades like a mechanical carry. In the numeric
|
|
73
|
+
* transition it is the span of the whole cascade instead: the digits that
|
|
74
|
+
* change start spread evenly over it from the leftmost to the rightmost,
|
|
75
|
+
* however many there are, the way the effect cascades on iOS. Default: `0`
|
|
76
|
+
* (`150` for the numeric transition).
|
|
77
|
+
*/
|
|
78
|
+
stagger?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Which way the digits roll. `'auto'` follows the sign of the change;
|
|
81
|
+
* `'up'` / `'down'` force one; `'shortest'` rolls each digit its own
|
|
82
|
+
* shorter way round (1 → 2 is one step up even when the value falls, where
|
|
83
|
+
* `'auto'` rolls nine steps down), which is calmer on big jumps. The numeric transition and the reveal ignore it. Default: `'auto'`.
|
|
84
|
+
*/
|
|
85
|
+
direction?: NitroNumberDirection;
|
|
86
|
+
/**
|
|
87
|
+
* Jackpot reveal, the casino "you won" presentation. While `false` the view
|
|
88
|
+
* holds the opening frame of `value` ("$0.00": its layout, every digit blank
|
|
89
|
+
* except the mandatory ones); when it turns `true` the figure plays its
|
|
90
|
+
* `revealStyle` to `value` and lands with a pop. Pair it with
|
|
91
|
+
* `textAlign="center"` for a centred hero figure. Leave it `undefined` for
|
|
92
|
+
* a normal NitroNumber. To let the user skip the reveal, call `jumpTo(value)`.
|
|
93
|
+
*/
|
|
94
|
+
reveal?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* `'count'` (default) is the win-meter rollup: the figure tallies up from 0
|
|
97
|
+
* like a slot's win counter, taking off at once, running at a constant
|
|
98
|
+
* rate and braking into the total (and into each tier with
|
|
99
|
+
* `revealMilestones`), swelling slightly as it climbs, digits swapping in
|
|
100
|
+
* place and leading digits appearing as the count reaches them. `'spin'`
|
|
101
|
+
* is the jackpot reels: every digit spins like a slot reel, then the reels
|
|
102
|
+
* brake and lock one at a time from the left, each with a mechanical bounce.
|
|
103
|
+
*/
|
|
104
|
+
revealStyle?: NitroNumberRevealStyle;
|
|
105
|
+
/** Duration of the reveal in ms (the count, or the time until the last reel locks). Default: `2200`. */
|
|
106
|
+
revealDuration?: number;
|
|
107
|
+
/** Peak overshoot of the reveal's landing pop, `0` (none) to `1`. Default: `0.12`. */
|
|
108
|
+
revealBounce?: number;
|
|
109
|
+
/**
|
|
110
|
+
* `'count'` style: how much smaller the figure opens, as a fraction of its
|
|
111
|
+
* size, growing to full size over the count, the way a big win's meter is
|
|
112
|
+
* enlarged as it climbs. `0` = no growth. Default: `0.2`.
|
|
113
|
+
*/
|
|
114
|
+
revealGrow?: number;
|
|
115
|
+
/** `'spin'` style: ms between one reel locking and the next, shortened to fit `revealDuration`. Default: `200`. */
|
|
116
|
+
revealStagger?: number;
|
|
117
|
+
/**
|
|
118
|
+
* `'count'` style: the win tiers of a casino rollup ("Big win" → "Mega win"
|
|
119
|
+
* → "Epic win"), in the figure's units. When the count reaches one, the
|
|
120
|
+
* figure punches, pauses on it for `revealMilestoneHold` and
|
|
121
|
+
* `onRevealMilestone` fires, so the app can slam its banner in, fire the
|
|
122
|
+
* confetti and play the sting on that beat. Values at or above `value` are ignored.
|
|
123
|
+
*/
|
|
124
|
+
revealMilestones?: number[];
|
|
125
|
+
/** `'count'` style: ms the count pauses on each milestone (the banner's moment). Default: `0`. */
|
|
126
|
+
revealMilestoneHold?: number;
|
|
127
|
+
/** Called once a reveal has landed (count finished or last reel locked, and the pop rung out). */
|
|
128
|
+
onRevealEnd?: () => void;
|
|
129
|
+
/** Called when the count reaches a milestone: its index among the usable milestones and its value. */
|
|
130
|
+
onRevealMilestone?: (index: number, value: number) => void;
|
|
131
|
+
/**
|
|
132
|
+
* Loading glint: the ink keeps its color while a slanted, text-wide band of
|
|
133
|
+
* `shimmerColor` sweeps through the glyphs (a "shine" skeleton). Toggling
|
|
134
|
+
* cross-fades; the number keeps its size so nothing jumps when the value
|
|
135
|
+
* arrives. Default: `false`.
|
|
136
|
+
*/
|
|
137
|
+
loading?: boolean;
|
|
138
|
+
/** Color of the glint's core, e.g. your theme's lightest neutral. Defaults to `#D6D9E1` (`#2B2E37` in dark mode). */
|
|
139
|
+
shimmerColor?: ColorValue;
|
|
140
|
+
/** Duration of one sweep in ms (linear, repeating). Default: `950`. */
|
|
141
|
+
shimmerDuration?: number;
|
|
142
|
+
/** Font size of the digits in points. Default: `32`. */
|
|
143
|
+
fontSize?: number;
|
|
144
|
+
/** Font size of `prefix`, e.g. a smaller currency symbol. Defaults to `fontSize`. */
|
|
145
|
+
prefixFontSize?: number;
|
|
146
|
+
/** Font size of `suffix`, e.g. a smaller currency code. Defaults to `fontSize`. */
|
|
147
|
+
suffixFontSize?: number;
|
|
148
|
+
/**
|
|
149
|
+
* How prefix and suffix line up with the digits: `'top'` pins glyph tops,
|
|
150
|
+
* `'bottom'` pins the bottom of the line boxes, `'baseline'` shares the
|
|
151
|
+
* digits' baseline, `'center'` centres. Default: `'baseline'`.
|
|
152
|
+
*/
|
|
153
|
+
affixAlign?: NitroNumberAffixAlign;
|
|
154
|
+
/** Alignment of `prefix` only. Defaults to `affixAlign`. */
|
|
155
|
+
prefixAlign?: NitroNumberAffixAlign;
|
|
156
|
+
/** Alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
157
|
+
suffixAlign?: NitroNumberAffixAlign;
|
|
158
|
+
/**
|
|
159
|
+
* Points added after every glyph, like `Text`'s `letterSpacing` (negative
|
|
160
|
+
* tightens). A smaller prefix or suffix gets it in proportion to its size.
|
|
161
|
+
* Default: `0`.
|
|
162
|
+
*/
|
|
163
|
+
letterSpacing?: number;
|
|
164
|
+
/** Points between the prefix and the digits, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
165
|
+
prefixSpacing?: number;
|
|
166
|
+
/** Points between the digits and the suffix, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
167
|
+
suffixSpacing?: number;
|
|
168
|
+
/** Points the prefix is moved down after `prefixAlign` places it (negative: up). Default: `0`. */
|
|
169
|
+
prefixOffset?: number;
|
|
170
|
+
/** Points the suffix is moved down after `suffixAlign` places it (negative: up). Default: `0`. */
|
|
171
|
+
suffixOffset?: number;
|
|
172
|
+
/**
|
|
173
|
+
* `true` (the default): every digit as wide as the widest, so columns never
|
|
174
|
+
* move, what a ticker or a price wants. `false`: each digit at its own
|
|
175
|
+
* width, the font's proportional figures, for a face whose "1" is narrow
|
|
176
|
+
* (or that has no tabular figures at all); a changing column's width
|
|
177
|
+
* then eases once from the old digit's to the new one's.
|
|
178
|
+
*/
|
|
179
|
+
tabularNums?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* A `NumberFormat` the number follows: its prefix and suffix (the currency
|
|
182
|
+
* where the locale puts it), grouping and decimal separators, fraction
|
|
183
|
+
* digits and minimum integer digits. The individual props override what it
|
|
184
|
+
* says.
|
|
185
|
+
*/
|
|
186
|
+
format?: NumberFormat;
|
|
187
|
+
/**
|
|
188
|
+
* Scale the number down when the view is narrower than its content, and back
|
|
189
|
+
* up (never above `fontSize`) when it fits again. Give the view a fixed
|
|
190
|
+
* `width` in `style`; the view keeps its full-size height so the box around
|
|
191
|
+
* it never moves, only the amount scales. Like `Text`'s prop. Default: `false`.
|
|
192
|
+
*/
|
|
193
|
+
adjustsFontSizeToFit?: boolean;
|
|
194
|
+
/** Smallest scale `adjustsFontSizeToFit` may apply, `0`–`1`. Default: `0.5`. */
|
|
195
|
+
minimumFontScale?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Scale the fonts with the system text size (Dynamic Type / Android font
|
|
198
|
+
* scale) like `Text` does. Off by default so amounts keep their design size.
|
|
199
|
+
*/
|
|
200
|
+
allowFontScaling?: boolean;
|
|
201
|
+
/** Upper bound for `allowFontScaling`, e.g. `1.3`. `0` means no cap. Default: `0`. */
|
|
202
|
+
maxFontSizeMultiplier?: number;
|
|
203
|
+
/** Font weight, like `Text`'s `fontWeight`. Default: `'normal'`. */
|
|
204
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
205
|
+
/** Font family name, like `Text`'s `fontFamily`. Defaults to the system font. */
|
|
206
|
+
fontFamily?: string;
|
|
207
|
+
/** Text color. Defaults to the platform's primary label color. */
|
|
208
|
+
color?: ColorValue;
|
|
209
|
+
/**
|
|
210
|
+
* Where the number sits when the view is wider than its content, e.g. when
|
|
211
|
+
* you give it a fixed `width` so it doesn't reflow as digits appear.
|
|
212
|
+
* Default: `'auto'`: the start edge of the layout direction, as `Text`.
|
|
213
|
+
* `'left'` and `'right'` are absolute.
|
|
214
|
+
*/
|
|
215
|
+
textAlign?: NitroNumberTextAlign;
|
|
216
|
+
/** Receives the native Nitro object once the view is mounted. */
|
|
217
|
+
onNativeRef?: (ref: NitroNumberRef) => void;
|
|
218
|
+
}
|
|
219
|
+
/** Imperative handle exposed through `ref`. Methods are no-ops before mount. */
|
|
220
|
+
export interface NitroNumberHandle {
|
|
221
|
+
/**
|
|
222
|
+
* Shows `value` immediately with continuously positioned digits (odometer
|
|
223
|
+
* style, `12.5` shows the last digit half way between `2` and `3`). No roll
|
|
224
|
+
* is played. Useful for scrubbing, e.g. from a scroll or drag handler.
|
|
225
|
+
*/
|
|
226
|
+
jumpTo(value: number): void;
|
|
227
|
+
/** Rolls to `value` natively, exactly like changing the `value` prop. */
|
|
228
|
+
animateTo(value: number): void;
|
|
229
|
+
/** Plays a jackpot reveal to `value` (counts up from 0), whatever the `reveal` prop says. */
|
|
230
|
+
revealTo(value: number): void;
|
|
231
|
+
/** The value currently shown or being rolled towards. */
|
|
232
|
+
getValue(): number;
|
|
233
|
+
/** The native Nitro object, or `null` before mount. */
|
|
234
|
+
readonly native: NitroNumberRef | null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A number that animates its changes natively: an odometer roll, SwiftUI's
|
|
238
|
+
* numeric transition or a scramble.
|
|
239
|
+
*
|
|
240
|
+
* Change `value` and every digit rolls to its new glyph on the native side.
|
|
241
|
+
* Use the ref's `animateTo` / `jumpTo` for imperative updates.
|
|
242
|
+
*
|
|
243
|
+
* The view sizes itself to its content unless you pass an explicit `width` /
|
|
244
|
+
* `height` in `style`.
|
|
245
|
+
*/
|
|
246
|
+
export declare const NitroNumber: React.ForwardRefExoticComponent<NitroNumberProps & React.RefAttributes<NitroNumberHandle>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { NumberFormatOptions, NumberFormatPart, ResolvedNumberFormatOptions } from './specs/NumberFormat.nitro';
|
|
2
|
+
/**
|
|
3
|
+
* A number formatter with the API of `Intl.NumberFormat`, formatted natively.
|
|
4
|
+
*
|
|
5
|
+
* The locale's format is learned once from the platform (Foundation on iOS,
|
|
6
|
+
* ICU on Android, the same data Hermes' `Intl` uses) and every number after
|
|
7
|
+
* that is formatted in C++, without calling into the platform. Building a
|
|
8
|
+
* formatter with locales and options seen before reuses the native one, so
|
|
9
|
+
* there is no need to memoize them.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const php = new NumberFormat('en-PH', { style: 'currency', currency: 'PHP' })
|
|
13
|
+
* php.format(1234.5) // "₱1,234.50"
|
|
14
|
+
* php.formatToParts(-12) // works on iOS too
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* It behaves as ECMA-402 specifies `Intl.NumberFormat` (options are read,
|
|
18
|
+
* coerced and checked in the specified order, `format` is a bound getter,
|
|
19
|
+
* `NumberFormat()` works without `new`), and is checked against test262.
|
|
20
|
+
*/
|
|
21
|
+
export interface NumberFormat {
|
|
22
|
+
/** Formats a number, a bigint, or a decimal string (exactly, without going through a double). A bound function: `values.map(nf.format)` works. */
|
|
23
|
+
readonly format: (value: number | bigint | string) => string;
|
|
24
|
+
formatToParts(value: number | bigint | string): NumberFormatPart[];
|
|
25
|
+
formatRange(start: number | bigint | string, end: number | bigint | string): string;
|
|
26
|
+
formatRangeToParts(start: number | bigint | string, end: number | bigint | string): NumberFormatRangePart[];
|
|
27
|
+
resolvedOptions(): ResolvedNumberFormatOptions;
|
|
28
|
+
}
|
|
29
|
+
export interface NumberFormatRangePart extends NumberFormatPart {
|
|
30
|
+
source: 'startRange' | 'endRange' | 'shared';
|
|
31
|
+
}
|
|
32
|
+
export interface NumberFormatConstructor {
|
|
33
|
+
new (locales?: string | readonly string[], options?: NumberFormatOptions): NumberFormat;
|
|
34
|
+
(locales?: string | readonly string[], options?: NumberFormatOptions): NumberFormat;
|
|
35
|
+
readonly prototype: NumberFormat;
|
|
36
|
+
/** The given locales that have number data, as `Intl.NumberFormat.supportedLocalesOf` returns them. */
|
|
37
|
+
supportedLocalesOf(locales: string | readonly string[], options?: {
|
|
38
|
+
localeMatcher?: 'lookup' | 'best fit';
|
|
39
|
+
}): string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The native formatter behind a `NumberFormat`, which every instance with the
|
|
43
|
+
* same locales and options shares: a key for caching what is derived from one.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export declare function sharedFormatterOf(value: unknown): object | undefined;
|
|
47
|
+
export declare const NumberFormat: NumberFormatConstructor;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type NumberFormat } from './NumberFormat';
|
|
2
|
+
/** What `NitroNumber` and `NitroInput` take from a `NumberFormat` through their `format` prop. */
|
|
3
|
+
export interface FormatProps {
|
|
4
|
+
prefix: string;
|
|
5
|
+
suffix: string;
|
|
6
|
+
groupingSeparator: string;
|
|
7
|
+
decimalSeparator: string;
|
|
8
|
+
/** The digits after the decimal separator: the format's maximum. */
|
|
9
|
+
fractionDigits: number;
|
|
10
|
+
minimumIntegerDigits: number;
|
|
11
|
+
/** Whether a negative amount's sign comes before the prefix ("-$5") or after it ("$-5"). */
|
|
12
|
+
signPlacement: 'beforeAffix' | 'afterAffix';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The prefix, suffix, separators and digit counts of `format`, read off its
|
|
16
|
+
* parts once and cached per formatter. The components keep their own model
|
|
17
|
+
* (a sign, a prefix, digits grouped in threes, a suffix), so a format outside
|
|
18
|
+
* it (Indian grouping, native digits, accounting parentheses) is followed as
|
|
19
|
+
* far as that model goes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatProps(format: NumberFormat): FormatProps;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export { NitroInput, NativeNitroInputView, type NitroInputProps, type NitroInputHandle, type NitroInputRef, type NitroInputTextEvent, type NitroInputFocusEvent, type NitroInputSelectionEvent, type NitroInputKeyPressEvent, type InputMode, type EnterKeyHint, } from './NitroInput';
|
|
2
|
-
export { MorphInput, type MorphInputProps, type MorphInputHandle, type MorphInputRef, } from './MorphInput';
|
|
1
|
+
export { NitroInput, NativeNitroInputView, type NitroInputProps, type NitroInputHandle, type NitroInputRef, type NitroInputTextEvent, type NitroInputFocusEvent, type NitroInputSelectionEvent, type NitroInputKeyPressEvent, type NitroInputTransition, type InputMode, type EnterKeyHint, } from './NitroInput';
|
|
3
2
|
export { isWorklet, type NitroInputSelection, type NitroInputTransform, type WorkletTextEvent, type WorkletFocusEvent, type WorkletSelectionEvent, type WorkletKeyPressEvent, } from './worklets';
|
|
4
3
|
export { useNitroInputState, type NitroInputState, type SharedValueLike, } from './useNitroInputState';
|
|
5
4
|
export type { NitroInputLabelBehavior, NitroInputMode, NitroInputNotation, NitroInputVariant, NitroInputEasing, NitroInputEffect, NitroInputTextAlign, NitroInputTextAlignVertical, NitroInputAffixAlign, NitroInputSignPlacement, NitroInputKeyboardType, NitroInputReturnKeyType, NitroInputAutoCapitalize, NitroInputSubmitBehavior, NitroInputKeyboardAppearance, NitroInputMethods, NitroInputProps as NativeNitroInputProps, NitroInputView, } from './specs/NitroInput.nitro';
|
|
6
5
|
export type { NitroInputWorklets } from './specs/NitroInputWorklets.nitro';
|
|
6
|
+
export { NitroNumber, NativeNitroNumberView, type NitroNumberProps, type NitroNumberHandle, type NitroNumberRef, } from './NitroNumber';
|
|
7
|
+
export type { NitroNumberAffixAlign, NitroNumberDirection, NitroNumberTransition, NitroNumberEasing, NitroNumberRevealStyle, NitroNumberTextAlign, NitroNumberMethods, NitroNumberProps as NativeNitroNumberProps, NitroNumberView, } from './specs/NitroNumber.nitro';
|
|
8
|
+
export { NumberFormat, type NumberFormatConstructor, type NumberFormatRangePart } from './NumberFormat';
|
|
9
|
+
export type { NumberFormatOptions, NumberFormatPart, ResolvedNumberFormatOptions, NumberFormatStyle, NumberFormatCurrencyDisplay, NumberFormatCurrencySign, NumberFormatUnitDisplay, NumberFormatNotation, NumberFormatCompactDisplay, NumberFormatSignDisplay, NumberFormatRoundingMode, NumberFormatRoundingPriority, NumberFormatTrailingZeroDisplay, NumberFormatGrouping, } from './specs/NumberFormat.nitro';
|
|
@@ -18,7 +18,7 @@ export interface NitroInputNotation {
|
|
|
18
18
|
isOptional: boolean;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Timing curve of the
|
|
21
|
+
* Timing curve of the reflow. `'expo'` is Torph's default
|
|
22
22
|
* (`cubic-bezier(0.19, 1, 0.22, 1)`): a fast take-off that settles gently.
|
|
23
23
|
*/
|
|
24
24
|
export type NitroInputEasing = 'expo' | 'easeOut' | 'easeInOut' | 'linear' | 'spring';
|
|
@@ -56,7 +56,7 @@ export type NitroInputTextAlignVertical = 'auto' | 'top' | 'center' | 'bottom';
|
|
|
56
56
|
* `'beforeAffix'` (the default) reads `-$1,234.56`, which is how a locale that
|
|
57
57
|
* leads with its symbol writes it. `'afterAffix'` reads `$-1,234.56`, which
|
|
58
58
|
* suits a symbol styled as an ornament rather than read as part of the number -
|
|
59
|
-
* small, raised, in another colour. Only the
|
|
59
|
+
* small, raised, in another colour. Only the reflow honours it: a plain field's
|
|
60
60
|
* affixes are accessory views that sit outside the text, so it is always
|
|
61
61
|
* `'afterAffix'`.
|
|
62
62
|
*/
|
|
@@ -92,7 +92,7 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
92
92
|
/** `'text'`, `'number'` or `'mask'`. Default: `'text'`. */
|
|
93
93
|
mode: NitroInputMode;
|
|
94
94
|
/**
|
|
95
|
-
* Draw the text with the system field itself and skip the
|
|
95
|
+
* Draw the text with the system field itself and skip the reflow overlay
|
|
96
96
|
* entirely: no glyph engine, no per-glyph layers, no custom caret. This is
|
|
97
97
|
* what `NitroInput` renders — an ordinary native input that keeps the rest of
|
|
98
98
|
* the component (native formatting, the focus path, the text-input registry
|
|
@@ -176,13 +176,23 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
176
176
|
prefixAlign: NitroInputAffixAlign;
|
|
177
177
|
/** Vertical alignment of `suffix` relative to the text (the wrapper folds its `affixAlign` into this). */
|
|
178
178
|
suffixAlign: NitroInputAffixAlign;
|
|
179
|
-
/**
|
|
179
|
+
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. */
|
|
180
|
+
letterSpacing: number;
|
|
181
|
+
/** Points between the prefix and the text, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
182
|
+
prefixSpacing: number;
|
|
183
|
+
/** Points between the text and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
184
|
+
suffixSpacing: number;
|
|
185
|
+
/** Points the prefix is moved down after its alignment (negative: up). */
|
|
186
|
+
prefixOffset: number;
|
|
187
|
+
/** Points the suffix is moved down after its alignment (negative: up). */
|
|
188
|
+
suffixOffset: number;
|
|
189
|
+
/** Shown (and reflowed away) while the field is empty. Default: `''`. */
|
|
180
190
|
placeholder: string;
|
|
181
191
|
/** Color of the placeholder as a processed ARGB integer; `NaN` = platform default. */
|
|
182
192
|
placeholderColor: number;
|
|
183
|
-
/** Duration in ms of the
|
|
193
|
+
/** Duration in ms of the reflow played on every change. `0` snaps. Default: `400`. */
|
|
184
194
|
duration: number;
|
|
185
|
-
/** Timing curve of the
|
|
195
|
+
/** Timing curve of the reflow. Default: `'expo'`. */
|
|
186
196
|
easing: NitroInputEasing;
|
|
187
197
|
/** Overshoot of the `'spring'` easing, `0`–`1`. Default: `0.15`. */
|
|
188
198
|
bounce: number;
|
|
@@ -248,9 +258,9 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
248
258
|
* Let the text wrap onto more than one line.
|
|
249
259
|
*
|
|
250
260
|
* A multiline field is always drawn by the system view — the glyph engine
|
|
251
|
-
* lays one run out on one baseline, so it cannot
|
|
261
|
+
* lays one run out on one baseline, so it cannot reflow wrapped text — and it
|
|
252
262
|
* is always `'text'` mode, since an amount and a mask are single-line ideas.
|
|
253
|
-
* Setting `
|
|
263
|
+
* Setting `transition="reflow"`, `'number'` or `'mask'` alongside it is ignored, with a
|
|
254
264
|
* warning. Default: `false`.
|
|
255
265
|
*/
|
|
256
266
|
multiline: boolean;
|
|
@@ -366,7 +376,7 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
366
376
|
export interface NitroInputMethods extends HybridViewMethods {
|
|
367
377
|
focus(): void;
|
|
368
378
|
blur(): void;
|
|
369
|
-
/** Empties the field (
|
|
379
|
+
/** Empties the field (reflowing the characters away). */
|
|
370
380
|
clear(): void;
|
|
371
381
|
/**
|
|
372
382
|
* Replaces the text (formatted in `'number'` mode), caret at the end.
|