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
package/src/index.ts
CHANGED
|
@@ -8,15 +8,10 @@ export {
|
|
|
8
8
|
type NitroInputFocusEvent,
|
|
9
9
|
type NitroInputSelectionEvent,
|
|
10
10
|
type NitroInputKeyPressEvent,
|
|
11
|
+
type NitroInputTransition,
|
|
11
12
|
type InputMode,
|
|
12
13
|
type EnterKeyHint,
|
|
13
14
|
} from './NitroInput'
|
|
14
|
-
export {
|
|
15
|
-
MorphInput,
|
|
16
|
-
type MorphInputProps,
|
|
17
|
-
type MorphInputHandle,
|
|
18
|
-
type MorphInputRef,
|
|
19
|
-
} from './MorphInput'
|
|
20
15
|
export {
|
|
21
16
|
isWorklet,
|
|
22
17
|
type NitroInputSelection,
|
|
@@ -53,3 +48,40 @@ export type {
|
|
|
53
48
|
NitroInputView,
|
|
54
49
|
} from './specs/NitroInput.nitro'
|
|
55
50
|
export type { NitroInputWorklets } from './specs/NitroInputWorklets.nitro'
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
NitroNumber,
|
|
54
|
+
NativeNitroNumberView,
|
|
55
|
+
type NitroNumberProps,
|
|
56
|
+
type NitroNumberHandle,
|
|
57
|
+
type NitroNumberRef,
|
|
58
|
+
} from './NitroNumber'
|
|
59
|
+
export type {
|
|
60
|
+
NitroNumberAffixAlign,
|
|
61
|
+
NitroNumberDirection,
|
|
62
|
+
NitroNumberTransition,
|
|
63
|
+
NitroNumberEasing,
|
|
64
|
+
NitroNumberRevealStyle,
|
|
65
|
+
NitroNumberTextAlign,
|
|
66
|
+
NitroNumberMethods,
|
|
67
|
+
NitroNumberProps as NativeNitroNumberProps,
|
|
68
|
+
NitroNumberView,
|
|
69
|
+
} from './specs/NitroNumber.nitro'
|
|
70
|
+
|
|
71
|
+
export { NumberFormat, type NumberFormatConstructor, type NumberFormatRangePart } from './NumberFormat'
|
|
72
|
+
export type {
|
|
73
|
+
NumberFormatOptions,
|
|
74
|
+
NumberFormatPart,
|
|
75
|
+
ResolvedNumberFormatOptions,
|
|
76
|
+
NumberFormatStyle,
|
|
77
|
+
NumberFormatCurrencyDisplay,
|
|
78
|
+
NumberFormatCurrencySign,
|
|
79
|
+
NumberFormatUnitDisplay,
|
|
80
|
+
NumberFormatNotation,
|
|
81
|
+
NumberFormatCompactDisplay,
|
|
82
|
+
NumberFormatSignDisplay,
|
|
83
|
+
NumberFormatRoundingMode,
|
|
84
|
+
NumberFormatRoundingPriority,
|
|
85
|
+
NumberFormatTrailingZeroDisplay,
|
|
86
|
+
NumberFormatGrouping,
|
|
87
|
+
} from './specs/NumberFormat.nitro'
|
|
@@ -25,7 +25,7 @@ export interface NitroInputNotation {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Timing curve of the
|
|
28
|
+
* Timing curve of the reflow. `'expo'` is Torph's default
|
|
29
29
|
* (`cubic-bezier(0.19, 1, 0.22, 1)`): a fast take-off that settles gently.
|
|
30
30
|
*/
|
|
31
31
|
export type NitroInputEasing =
|
|
@@ -74,7 +74,7 @@ export type NitroInputTextAlignVertical = 'auto' | 'top' | 'center' | 'bottom'
|
|
|
74
74
|
* `'beforeAffix'` (the default) reads `-$1,234.56`, which is how a locale that
|
|
75
75
|
* leads with its symbol writes it. `'afterAffix'` reads `$-1,234.56`, which
|
|
76
76
|
* suits a symbol styled as an ornament rather than read as part of the number -
|
|
77
|
-
* small, raised, in another colour. Only the
|
|
77
|
+
* small, raised, in another colour. Only the reflow honours it: a plain field's
|
|
78
78
|
* affixes are accessory views that sit outside the text, so it is always
|
|
79
79
|
* `'afterAffix'`.
|
|
80
80
|
*/
|
|
@@ -136,7 +136,7 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
136
136
|
/** `'text'`, `'number'` or `'mask'`. Default: `'text'`. */
|
|
137
137
|
mode: NitroInputMode
|
|
138
138
|
/**
|
|
139
|
-
* Draw the text with the system field itself and skip the
|
|
139
|
+
* Draw the text with the system field itself and skip the reflow overlay
|
|
140
140
|
* entirely: no glyph engine, no per-glyph layers, no custom caret. This is
|
|
141
141
|
* what `NitroInput` renders — an ordinary native input that keeps the rest of
|
|
142
142
|
* the component (native formatting, the focus path, the text-input registry
|
|
@@ -220,13 +220,23 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
220
220
|
prefixAlign: NitroInputAffixAlign
|
|
221
221
|
/** Vertical alignment of `suffix` relative to the text (the wrapper folds its `affixAlign` into this). */
|
|
222
222
|
suffixAlign: NitroInputAffixAlign
|
|
223
|
-
/**
|
|
223
|
+
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. */
|
|
224
|
+
letterSpacing: number
|
|
225
|
+
/** Points between the prefix and the text, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
226
|
+
prefixSpacing: number
|
|
227
|
+
/** Points between the text and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
228
|
+
suffixSpacing: number
|
|
229
|
+
/** Points the prefix is moved down after its alignment (negative: up). */
|
|
230
|
+
prefixOffset: number
|
|
231
|
+
/** Points the suffix is moved down after its alignment (negative: up). */
|
|
232
|
+
suffixOffset: number
|
|
233
|
+
/** Shown (and reflowed away) while the field is empty. Default: `''`. */
|
|
224
234
|
placeholder: string
|
|
225
235
|
/** Color of the placeholder as a processed ARGB integer; `NaN` = platform default. */
|
|
226
236
|
placeholderColor: number
|
|
227
|
-
/** Duration in ms of the
|
|
237
|
+
/** Duration in ms of the reflow played on every change. `0` snaps. Default: `400`. */
|
|
228
238
|
duration: number
|
|
229
|
-
/** Timing curve of the
|
|
239
|
+
/** Timing curve of the reflow. Default: `'expo'`. */
|
|
230
240
|
easing: NitroInputEasing
|
|
231
241
|
/** Overshoot of the `'spring'` easing, `0`–`1`. Default: `0.15`. */
|
|
232
242
|
bounce: number
|
|
@@ -292,9 +302,9 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
292
302
|
* Let the text wrap onto more than one line.
|
|
293
303
|
*
|
|
294
304
|
* A multiline field is always drawn by the system view — the glyph engine
|
|
295
|
-
* lays one run out on one baseline, so it cannot
|
|
305
|
+
* lays one run out on one baseline, so it cannot reflow wrapped text — and it
|
|
296
306
|
* is always `'text'` mode, since an amount and a mask are single-line ideas.
|
|
297
|
-
* Setting `
|
|
307
|
+
* Setting `transition="reflow"`, `'number'` or `'mask'` alongside it is ignored, with a
|
|
298
308
|
* warning. Default: `false`.
|
|
299
309
|
*/
|
|
300
310
|
multiline: boolean
|
|
@@ -411,7 +421,7 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
411
421
|
export interface NitroInputMethods extends HybridViewMethods {
|
|
412
422
|
focus(): void
|
|
413
423
|
blur(): void
|
|
414
|
-
/** Empties the field (
|
|
424
|
+
/** Empties the field (reflowing the characters away). */
|
|
415
425
|
clear(): void
|
|
416
426
|
/**
|
|
417
427
|
* Replaces the text (formatted in `'number'` mode), caret at the end.
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HybridView,
|
|
3
|
+
HybridViewMethods,
|
|
4
|
+
HybridViewProps,
|
|
5
|
+
} from 'react-native-nitro-modules'
|
|
6
|
+
|
|
7
|
+
/** Horizontal alignment of the number inside the view's frame. */
|
|
8
|
+
/**
|
|
9
|
+
* `'auto'` is the start edge of the layout direction - left in a left-to-right
|
|
10
|
+
* app, right in a right-to-left one - which is what `Text` does with no
|
|
11
|
+
* `textAlign`; in a view that hugs the number it is the edge the parent keeps
|
|
12
|
+
* the view to (the end of a row: right), so the digits open and close against
|
|
13
|
+
* it. `'left'` and `'right'` are absolute, whatever the direction.
|
|
14
|
+
*/
|
|
15
|
+
export type NitroNumberTextAlign = 'auto' | 'left' | 'center' | 'right'
|
|
16
|
+
|
|
17
|
+
/** Timing curve used when a value change is rolled natively. */
|
|
18
|
+
export type NitroNumberEasing =
|
|
19
|
+
| 'linear'
|
|
20
|
+
| 'easeIn'
|
|
21
|
+
| 'easeOut'
|
|
22
|
+
| 'easeInOut'
|
|
23
|
+
| 'spring'
|
|
24
|
+
|
|
25
|
+
/** Which way the digits roll: `'auto'` follows the sign of the change. */
|
|
26
|
+
export type NitroNumberDirection = 'auto' | 'up' | 'down' | 'shortest'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* How a value change plays. `'roll'` is the odometer: every changed digit
|
|
30
|
+
* rolls through the digits between its old and new glyph. `'numeric'` is the
|
|
31
|
+
* numeric transition of SwiftUI's `.contentTransition(.numericText())`: each
|
|
32
|
+
* changed glyph swaps in place, the old one softening, shrinking and sliding
|
|
33
|
+
* out while the new one slides in from the other side and comes into focus,
|
|
34
|
+
* digits cascading from the left; the unchanged digits stay put. `'scramble'`
|
|
35
|
+
* shows a different random digit every few frames until each changed digit
|
|
36
|
+
* locks on its target, from the left.
|
|
37
|
+
*/
|
|
38
|
+
export type NitroNumberTransition = 'roll' | 'numeric' | 'scramble'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* How a jackpot reveal plays: `'count'` is the casino win-meter rollup (the
|
|
42
|
+
* figure counts up from 0, digits swapping in place); `'spin'` is the jackpot
|
|
43
|
+
* reels (every digit spins like a slot reel, then the reels lock one at a
|
|
44
|
+
* time from the left).
|
|
45
|
+
*/
|
|
46
|
+
export type NitroNumberRevealStyle = 'count' | 'spin'
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* How a prefix/suffix drawn at a different size lines up with the digits:
|
|
50
|
+
* `top` pins glyph tops (cap height), `bottom` pins the bottom of the line
|
|
51
|
+
* boxes, `baseline` shares the digits' baseline, `center` centres the boxes.
|
|
52
|
+
*/
|
|
53
|
+
export type NitroNumberAffixAlign = 'baseline' | 'center' | 'top' | 'bottom'
|
|
54
|
+
|
|
55
|
+
export interface NitroNumberProps extends HybridViewProps {
|
|
56
|
+
/**
|
|
57
|
+
* The number to display.
|
|
58
|
+
*
|
|
59
|
+
* When this prop changes, every digit rolls natively from its old glyph to
|
|
60
|
+
* its new glyph (in the direction of the change), using `duration` and
|
|
61
|
+
* `easing`. The very first value is displayed without an animation.
|
|
62
|
+
*
|
|
63
|
+
* Reading it on the hybrid ref returns the value the view is currently
|
|
64
|
+
* showing or rolling towards (also after `jumpTo` / `animateTo`).
|
|
65
|
+
*
|
|
66
|
+
* At most 18 digits are shown: `|value| × 10^fractionDigits` is clamped at
|
|
67
|
+
* 10^17 (the same limit for a jump and a roll), and a JS number carries exact
|
|
68
|
+
* integers only up to 2^53.
|
|
69
|
+
*/
|
|
70
|
+
value: number
|
|
71
|
+
/** Digits shown after the decimal separator. Default: `0`. */
|
|
72
|
+
fractionDigits?: number
|
|
73
|
+
/** Zero-pads the integer part to at least this many digits. Default: `1`. */
|
|
74
|
+
minimumIntegerDigits?: number
|
|
75
|
+
/** Inserted between every three integer digits. Empty string disables grouping. Default: `''`. */
|
|
76
|
+
groupingSeparator?: string
|
|
77
|
+
/** Placed between the integer and fraction digits. Default: `'.'`. */
|
|
78
|
+
decimalSeparator?: string
|
|
79
|
+
/** Static text drawn before the number (e.g. `'$'`). Default: `''`. */
|
|
80
|
+
prefix?: string
|
|
81
|
+
/** Static text drawn after the number (e.g. `'%'`). Default: `''`. */
|
|
82
|
+
suffix?: string
|
|
83
|
+
/**
|
|
84
|
+
* Duration in milliseconds of the native roll that plays when `value` changes.
|
|
85
|
+
* `0` snaps to the new value immediately. Default: `500`.
|
|
86
|
+
*/
|
|
87
|
+
duration?: number
|
|
88
|
+
/** Timing curve of the native roll. Default: `'easeInOut'`. */
|
|
89
|
+
easing?: NitroNumberEasing
|
|
90
|
+
/** Overshoot of the `'spring'` easing, from `0` (none) to `1`. Default: `0.15`. */
|
|
91
|
+
bounce?: number
|
|
92
|
+
/**
|
|
93
|
+
* Delay in ms between the start of each digit's roll, from the least
|
|
94
|
+
* significant digit upwards (a cascading carry). Default: `0`.
|
|
95
|
+
*/
|
|
96
|
+
stagger?: number
|
|
97
|
+
/**
|
|
98
|
+
* How a value change plays: the odometer roll, or the numeric transition
|
|
99
|
+
* (glyphs swap in place). Default: `'roll'`.
|
|
100
|
+
*/
|
|
101
|
+
transition?: NitroNumberTransition
|
|
102
|
+
/**
|
|
103
|
+
* The change flash: every digit whose glyph changes lights up in this
|
|
104
|
+
* colour when the value grew, fading back over `flashDuration`. A processed
|
|
105
|
+
* ARGB integer; `Infinity` (the wrapper's "unset") turns the flash off.
|
|
106
|
+
*/
|
|
107
|
+
flashUpColor?: number
|
|
108
|
+
/** The change flash's colour when the value shrank. `Infinity` = off. */
|
|
109
|
+
flashDownColor?: number
|
|
110
|
+
/** Milliseconds a change flash takes to fade. Default: `600`. */
|
|
111
|
+
flashDuration?: number
|
|
112
|
+
/**
|
|
113
|
+
* A punch of the whole figure on every value change, its peak overshoot
|
|
114
|
+
* as a fraction of the size, `0` (none, the default) to `1`; rung out like
|
|
115
|
+
* the reveal's landing pop.
|
|
116
|
+
*/
|
|
117
|
+
popOnChange?: number
|
|
118
|
+
/**
|
|
119
|
+
* Which way the digits roll. Default: `'auto'`.
|
|
120
|
+
*
|
|
121
|
+
* Named `rollDirection` and not `direction` because a Hybrid View's props
|
|
122
|
+
* derive from `react::ViewProps`, so React Native parses every name we
|
|
123
|
+
* declare as well: `direction` is Yoga's layout property, and it logged
|
|
124
|
+
* `Could not parse yoga::Direction: up` on every update. The public prop the
|
|
125
|
+
* wrapper exposes is still `direction`; see `NitroNumber.tsx`.
|
|
126
|
+
*/
|
|
127
|
+
rollDirection?: NitroNumberDirection
|
|
128
|
+
/**
|
|
129
|
+
* Jackpot reveal state. `0` (default): a normal NitroNumber, `value`
|
|
130
|
+
* changes roll. `1`: the view shows the opening frame of `value`, its layout
|
|
131
|
+
* with every digit blank except the mandatory ones ("$0.00"). `2`: the
|
|
132
|
+
* figure plays its `revealStyle` (counts up from 0, or spins its reels) to
|
|
133
|
+
* `value` and lands with a pop. The JS wrapper maps its `reveal` boolean to
|
|
134
|
+
* this; it is a number so the wrapper can always pass it (an optional prop
|
|
135
|
+
* that is removed reaches native as `null`, which Nitro's parser rejects).
|
|
136
|
+
*/
|
|
137
|
+
revealState?: number
|
|
138
|
+
/** How the reveal plays. Default: `'count'`. */
|
|
139
|
+
revealStyle?: NitroNumberRevealStyle
|
|
140
|
+
/** Duration of the reveal in ms (the count, or the time until the last reel locks). Default: `2200`. */
|
|
141
|
+
revealDuration?: number
|
|
142
|
+
/** Peak overshoot of the reveal's landing pop, `0` (none) to `1`. Default: `0.12`. */
|
|
143
|
+
revealBounce?: number
|
|
144
|
+
/**
|
|
145
|
+
* `'count'` style: how much smaller the figure opens, as a fraction of its
|
|
146
|
+
* size, growing to full size over the count (a big win's meter is enlarged
|
|
147
|
+
* as it climbs). `0` = no growth. Default: `0.2`.
|
|
148
|
+
*/
|
|
149
|
+
revealGrow?: number
|
|
150
|
+
/**
|
|
151
|
+
* `'spin'` style: delay in ms between one reel locking and the next, from
|
|
152
|
+
* the left. Shortened automatically when the reels wouldn't fit `revealDuration`. Default: `200`.
|
|
153
|
+
*/
|
|
154
|
+
revealStagger?: number
|
|
155
|
+
/**
|
|
156
|
+
* `'count'` style: win tiers, in the figure's units. When the count reaches
|
|
157
|
+
* one the figure punches, pauses on it for `revealMilestoneHold` and
|
|
158
|
+
* `onRevealMilestone` fires. Values at or above `value` are ignored.
|
|
159
|
+
*/
|
|
160
|
+
revealMilestones?: number[]
|
|
161
|
+
/** `'count'` style: ms the count pauses on each milestone. Default: `0`. */
|
|
162
|
+
revealMilestoneHold?: number
|
|
163
|
+
/**
|
|
164
|
+
* Shows a "shine" glint over the number: the ink keeps its color while a
|
|
165
|
+
* slanted, text-wide band of `shimmerColor` sweeps through the glyphs.
|
|
166
|
+
* Toggling fades the glint in/out. Default: `false`.
|
|
167
|
+
*/
|
|
168
|
+
loading?: boolean
|
|
169
|
+
/**
|
|
170
|
+
* Color of the glint's core as a processed ARGB integer. Defaults to a light
|
|
171
|
+
* neutral (`#D6D9E1`, or `#2B2E37` in dark mode).
|
|
172
|
+
*/
|
|
173
|
+
shimmerColor?: number
|
|
174
|
+
/** Duration of one sweep in ms (linear, repeating). Default: `950`. */
|
|
175
|
+
shimmerDuration?: number
|
|
176
|
+
/** Font size of the digits in points. Default: `32`. */
|
|
177
|
+
fontSize?: number
|
|
178
|
+
/** Font size of `prefix` in points. Defaults to `fontSize`. */
|
|
179
|
+
prefixFontSize?: number
|
|
180
|
+
/** Font size of `suffix` in points. Defaults to `fontSize`. */
|
|
181
|
+
suffixFontSize?: number
|
|
182
|
+
/** Vertical alignment of prefix and suffix relative to the digits. Default: `'baseline'`. */
|
|
183
|
+
affixAlign?: NitroNumberAffixAlign
|
|
184
|
+
/** Vertical alignment of `prefix` only. Defaults to `affixAlign`. */
|
|
185
|
+
prefixAlign?: NitroNumberAffixAlign
|
|
186
|
+
/** Vertical alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
187
|
+
suffixAlign?: NitroNumberAffixAlign
|
|
188
|
+
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. Default: `0`. */
|
|
189
|
+
letterSpacing?: number
|
|
190
|
+
/** Points between the prefix and the digits, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
191
|
+
prefixSpacing?: number
|
|
192
|
+
/** Points between the digits and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
193
|
+
suffixSpacing?: number
|
|
194
|
+
/** Points the prefix is moved down after its alignment (negative: up). Default: `0`. */
|
|
195
|
+
prefixOffset?: number
|
|
196
|
+
/** Points the suffix is moved down after its alignment (negative: up). Default: `0`. */
|
|
197
|
+
suffixOffset?: number
|
|
198
|
+
/** Every digit as wide as the widest (`true`, the default), or each digit at its own width. */
|
|
199
|
+
tabularNums?: boolean
|
|
200
|
+
/**
|
|
201
|
+
* When the view is narrower than the number (e.g. it has a fixed `width` or
|
|
202
|
+
* `maxWidth`), scale the whole number down so it fits. Default: `false`.
|
|
203
|
+
*/
|
|
204
|
+
adjustsFontSizeToFit?: boolean
|
|
205
|
+
/** Smallest scale `adjustsFontSizeToFit` may apply, `0`–`1`. Default: `0.5`. */
|
|
206
|
+
minimumFontScale?: number
|
|
207
|
+
/**
|
|
208
|
+
* Scale the fonts with the user's system text size (Dynamic Type / Android
|
|
209
|
+
* font scale), like `Text`. Off by default so amounts keep their design size.
|
|
210
|
+
*/
|
|
211
|
+
allowFontScaling?: boolean
|
|
212
|
+
/** Upper bound for `allowFontScaling`, e.g. `1.3`. `0` means no cap. Default: `0`. */
|
|
213
|
+
maxFontSizeMultiplier?: number
|
|
214
|
+
/** Numeric font weight, `100`–`900`. Default: `400`. */
|
|
215
|
+
fontWeight?: number
|
|
216
|
+
/** Font family name. Defaults to the system font. */
|
|
217
|
+
fontFamily?: string
|
|
218
|
+
/** Text color as a processed ARGB integer (from `processColor`). Defaults to the platform label color. */
|
|
219
|
+
color?: number
|
|
220
|
+
/** Where the number sits inside the view when the view is wider than the number. Default: `'auto'`, the start edge. */
|
|
221
|
+
textAlign?: NitroNumberTextAlign
|
|
222
|
+
/**
|
|
223
|
+
* Lay the figure out right-to-left: `'auto'` alignment resolves to the right
|
|
224
|
+
* edge, the prefix moves to the right and the suffix to the left, and the
|
|
225
|
+
* digits still read left to right. Fabric does not hand a Hybrid View its
|
|
226
|
+
* layout direction, so the JS side resolves it - from the view's
|
|
227
|
+
* `style.direction`, else `I18nManager.isRTL` - the way React Native
|
|
228
|
+
* resolves its own views. Default: `false`.
|
|
229
|
+
*/
|
|
230
|
+
rightToLeft?: boolean
|
|
231
|
+
/**
|
|
232
|
+
* Called whenever the settled (target) intrinsic size of the number changes,
|
|
233
|
+
* e.g. after the first layout, when a digit column appears/disappears, or
|
|
234
|
+
* when the font changes. `NitroNumber` uses this to size itself.
|
|
235
|
+
*/
|
|
236
|
+
onSizeChange?: (width: number, height: number) => void
|
|
237
|
+
/**
|
|
238
|
+
* Called when a reveal has landed: the count reached `value` and the landing
|
|
239
|
+
* pop has rung out. Sequence whatever follows the figure (a haptic, the next
|
|
240
|
+
* block of copy) from here.
|
|
241
|
+
*/
|
|
242
|
+
onRevealEnd?: () => void
|
|
243
|
+
/**
|
|
244
|
+
* Called when a count-style reveal reaches a milestone, with its index in
|
|
245
|
+
* the sorted usable milestones and its value: the moment to swap the win
|
|
246
|
+
* banner, fire the confetti and play the sting.
|
|
247
|
+
*/
|
|
248
|
+
onRevealMilestone?: (index: number, value: number) => void
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface NitroNumberMethods extends HybridViewMethods {
|
|
252
|
+
/**
|
|
253
|
+
* Displays `value` immediately, positioning the digit columns continuously
|
|
254
|
+
* (odometer style: `12.5` shows the last digit half way between `2` and `3`).
|
|
255
|
+
* No animation is started and any running roll is cancelled. Useful for
|
|
256
|
+
* scrubbing (scroll / drag handlers). Safe to call from any thread.
|
|
257
|
+
*/
|
|
258
|
+
jumpTo(value: number): void
|
|
259
|
+
/** Rolls to `value` natively, exactly like changing the `value` prop. Safe to call from any thread. */
|
|
260
|
+
animateTo(value: number): void
|
|
261
|
+
/**
|
|
262
|
+
* Plays a jackpot reveal to `value` in the current `revealStyle` (see the
|
|
263
|
+
* `reveal` prop) regardless of the prop's state. Safe to call from any thread.
|
|
264
|
+
*/
|
|
265
|
+
revealTo(value: number): void
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export type NitroNumberView = HybridView<
|
|
269
|
+
NitroNumberProps,
|
|
270
|
+
NitroNumberMethods
|
|
271
|
+
>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { HybridObject, Int64 } from 'react-native-nitro-modules'
|
|
2
|
+
|
|
3
|
+
// The option types of `Intl.NumberFormat` (ECMA-402), for the native `NumberFormat`.
|
|
4
|
+
|
|
5
|
+
export type NumberFormatStyle = 'decimal' | 'currency' | 'percent' | 'unit'
|
|
6
|
+
export type NumberFormatCurrencyDisplay = 'symbol' | 'narrowSymbol' | 'code' | 'name'
|
|
7
|
+
export type NumberFormatCurrencySign = 'standard' | 'accounting'
|
|
8
|
+
export type NumberFormatUnitDisplay = 'short' | 'narrow' | 'long'
|
|
9
|
+
export type NumberFormatNotation = 'standard' | 'scientific' | 'engineering' | 'compact'
|
|
10
|
+
export type NumberFormatCompactDisplay = 'short' | 'long'
|
|
11
|
+
export type NumberFormatSignDisplay = 'auto' | 'never' | 'always' | 'exceptZero' | 'negative'
|
|
12
|
+
export type NumberFormatRoundingMode = 'ceil' | 'floor' | 'expand' | 'trunc' | 'halfCeil' | 'halfFloor' | 'halfExpand' | 'halfTrunc' | 'halfEven'
|
|
13
|
+
export type NumberFormatRoundingPriority = 'auto' | 'morePrecision' | 'lessPrecision'
|
|
14
|
+
export type NumberFormatTrailingZeroDisplay = 'auto' | 'stripIfInteger'
|
|
15
|
+
export type NumberFormatGrouping = 'always' | 'auto' | 'min2'
|
|
16
|
+
|
|
17
|
+
/** `Intl.NumberFormatOptions`, less `localeMatcher` (the lookup matcher is always used). */
|
|
18
|
+
export interface NumberFormatOptions {
|
|
19
|
+
numberingSystem?: string
|
|
20
|
+
style?: NumberFormatStyle
|
|
21
|
+
currency?: string
|
|
22
|
+
currencyDisplay?: NumberFormatCurrencyDisplay
|
|
23
|
+
currencySign?: NumberFormatCurrencySign
|
|
24
|
+
unit?: string
|
|
25
|
+
unitDisplay?: NumberFormatUnitDisplay
|
|
26
|
+
minimumIntegerDigits?: number
|
|
27
|
+
minimumFractionDigits?: number
|
|
28
|
+
maximumFractionDigits?: number
|
|
29
|
+
minimumSignificantDigits?: number
|
|
30
|
+
maximumSignificantDigits?: number
|
|
31
|
+
roundingPriority?: NumberFormatRoundingPriority
|
|
32
|
+
roundingIncrement?: number
|
|
33
|
+
roundingMode?: NumberFormatRoundingMode
|
|
34
|
+
trailingZeroDisplay?: NumberFormatTrailingZeroDisplay
|
|
35
|
+
notation?: NumberFormatNotation
|
|
36
|
+
compactDisplay?: NumberFormatCompactDisplay
|
|
37
|
+
useGrouping?: boolean | NumberFormatGrouping
|
|
38
|
+
signDisplay?: NumberFormatSignDisplay
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** `Intl.ResolvedNumberFormatOptions`. */
|
|
42
|
+
export interface ResolvedNumberFormatOptions {
|
|
43
|
+
locale: string
|
|
44
|
+
numberingSystem: string
|
|
45
|
+
style: NumberFormatStyle
|
|
46
|
+
currency?: string
|
|
47
|
+
currencyDisplay?: NumberFormatCurrencyDisplay
|
|
48
|
+
currencySign?: NumberFormatCurrencySign
|
|
49
|
+
unit?: string
|
|
50
|
+
unitDisplay?: NumberFormatUnitDisplay
|
|
51
|
+
minimumIntegerDigits: number
|
|
52
|
+
minimumFractionDigits?: number
|
|
53
|
+
maximumFractionDigits?: number
|
|
54
|
+
minimumSignificantDigits?: number
|
|
55
|
+
maximumSignificantDigits?: number
|
|
56
|
+
useGrouping: boolean | NumberFormatGrouping
|
|
57
|
+
notation: NumberFormatNotation
|
|
58
|
+
compactDisplay?: NumberFormatCompactDisplay
|
|
59
|
+
signDisplay: NumberFormatSignDisplay
|
|
60
|
+
roundingIncrement: number
|
|
61
|
+
roundingMode: NumberFormatRoundingMode
|
|
62
|
+
roundingPriority: NumberFormatRoundingPriority
|
|
63
|
+
trailingZeroDisplay: NumberFormatTrailingZeroDisplay
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** One piece of a formatted number, as `Intl.NumberFormat#formatToParts` reports it. */
|
|
67
|
+
export interface NumberFormatPart {
|
|
68
|
+
type: string
|
|
69
|
+
value: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A number formatter with the API of `Intl.NumberFormat`. It learns a
|
|
74
|
+
* locale's format once from the platform (Foundation on iOS, ICU on Android)
|
|
75
|
+
* and formats in C++ from then on, without calling into the platform per
|
|
76
|
+
* number. Instances are immutable and shared: the same locales and options
|
|
77
|
+
* return the same object.
|
|
78
|
+
*/
|
|
79
|
+
export interface NitroNumberFormat extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
80
|
+
format(value: number | Int64 | string): string
|
|
81
|
+
formatToParts(value: number | Int64 | string): NumberFormatPart[]
|
|
82
|
+
resolvedOptions(): ResolvedNumberFormatOptions
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface NitroNumberFormatFactory extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
86
|
+
create(locales: string[], options: NumberFormatOptions): NitroNumberFormat
|
|
87
|
+
supportedLocalesOf(locales: string[]): string[]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// The platform side, used by the C++ formatter only: builds the system's own
|
|
92
|
+
// formatter for a configuration, so C++ can learn the locale's format from it,
|
|
93
|
+
// and formats with it where C++ does not (compact and scientific notation,
|
|
94
|
+
// units, currency names).
|
|
95
|
+
|
|
96
|
+
export interface NumberFormatPlatformOptions {
|
|
97
|
+
locales: string[]
|
|
98
|
+
numberingSystem?: string
|
|
99
|
+
style: NumberFormatStyle
|
|
100
|
+
currency?: string
|
|
101
|
+
currencyDisplay: NumberFormatCurrencyDisplay
|
|
102
|
+
currencySign: NumberFormatCurrencySign
|
|
103
|
+
unit?: string
|
|
104
|
+
unitDisplay: NumberFormatUnitDisplay
|
|
105
|
+
notation: NumberFormatNotation
|
|
106
|
+
compactDisplay: NumberFormatCompactDisplay
|
|
107
|
+
useGrouping: boolean
|
|
108
|
+
minimumIntegerDigits: number
|
|
109
|
+
minimumFractionDigits: number
|
|
110
|
+
maximumFractionDigits: number
|
|
111
|
+
/** 0 when significant digits are not used. */
|
|
112
|
+
minimumSignificantDigits: number
|
|
113
|
+
maximumSignificantDigits: number
|
|
114
|
+
roundingMode: NumberFormatRoundingMode
|
|
115
|
+
signDisplay: NumberFormatSignDisplay
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface NumberFormatPlatformSymbols {
|
|
119
|
+
/** The locale the platform resolved the request to, as a BCP 47 tag. */
|
|
120
|
+
locale: string
|
|
121
|
+
numberingSystem: string
|
|
122
|
+
minusSign: string
|
|
123
|
+
plusSign: string
|
|
124
|
+
percentSign: string
|
|
125
|
+
/** The currency as this formatter shows it (symbol, narrow symbol or code). */
|
|
126
|
+
currency: string
|
|
127
|
+
/** The locale's symbol for NaN. */
|
|
128
|
+
nan: string
|
|
129
|
+
/** The locale's symbol for infinity, without a sign. */
|
|
130
|
+
infinity: string
|
|
131
|
+
/** The "E" of scientific notation. */
|
|
132
|
+
exponentSeparator: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface NitroPlatformNumberFormatter extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
136
|
+
readonly symbols: NumberFormatPlatformSymbols
|
|
137
|
+
format(value: number): string
|
|
138
|
+
/** A decimal string, formatted without going through a double. */
|
|
139
|
+
formatDecimal(value: string): string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface NitroNumberFormatPlatform extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
143
|
+
create(options: NumberFormatPlatformOptions): NitroPlatformNumberFormatter
|
|
144
|
+
supportedLocalesOf(locales: string[]): string[]
|
|
145
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { processColor, type ColorValue, type TextStyle } from 'react-native'
|
|
2
|
+
|
|
3
|
+
// Style resolution shared by `NitroNumber` and `NitroInput`.
|
|
4
|
+
|
|
5
|
+
const FONT_WEIGHTS: Record<string, number> = {
|
|
6
|
+
normal: 400,
|
|
7
|
+
regular: 400,
|
|
8
|
+
bold: 700,
|
|
9
|
+
ultralight: 100,
|
|
10
|
+
thin: 200,
|
|
11
|
+
light: 300,
|
|
12
|
+
medium: 500,
|
|
13
|
+
semibold: 600,
|
|
14
|
+
condensedBold: 700,
|
|
15
|
+
condensed: 400,
|
|
16
|
+
heavy: 800,
|
|
17
|
+
black: 900,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function toNumericWeight(weight: TextStyle['fontWeight']): number | undefined {
|
|
21
|
+
if (weight == null) return undefined
|
|
22
|
+
if (typeof weight === 'number') return weight
|
|
23
|
+
const parsed = Number(weight)
|
|
24
|
+
if (!Number.isNaN(parsed)) return parsed
|
|
25
|
+
return FONT_WEIGHTS[weight]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function toProcessedColor(color: ColorValue | undefined): number | undefined {
|
|
29
|
+
if (color == null) return undefined
|
|
30
|
+
const processed = processColor(color)
|
|
31
|
+
return typeof processed === 'number' ? processed : undefined
|
|
32
|
+
}
|