react-native-nitro-input 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +132 -2
- package/android/CMakeLists.txt +4 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/cpp/JReflowEngine.cpp +32 -0
- package/android/src/main/cpp/JReflowEngine.hpp +13 -0
- package/android/src/main/cpp/JRollingEngine.cpp +43 -2
- package/android/src/main/cpp/JRollingEngine.hpp +9 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +20 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform.kt +284 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +113 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextMeasure.kt +25 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +140 -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 +69 -10
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +522 -130
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroTextView.kt +868 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/ReflowEngine.kt +21 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +14 -2
- package/cpp/RollingEngine.cpp +102 -8
- package/cpp/RollingEngine.hpp +44 -3
- 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/ios/HybridNitroInputView.swift +15 -0
- package/ios/HybridNitroNumberFormatPlatform.swift +426 -0
- package/ios/HybridNitroNumberView.swift +101 -1
- package/ios/HybridNitroTextView.swift +134 -0
- package/ios/NitroInputView.swift +79 -19
- package/ios/NitroNumberView.swift +520 -147
- package/ios/NitroTextView.swift +583 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
- package/lib/commonjs/src/NitroInput.js +8 -6
- package/lib/commonjs/src/NitroNumber.js +54 -3
- package/lib/commonjs/src/NitroText.js +138 -0
- package/lib/commonjs/src/NitroTime.js +65 -0
- package/lib/commonjs/src/NumberFormat.js +525 -0
- package/lib/commonjs/src/formatProps.js +108 -0
- package/lib/commonjs/src/index.js +8 -1
- package/lib/commonjs/src/specs/NitroText.nitro.js +2 -0
- package/lib/commonjs/src/specs/NumberFormat.nitro.js +2 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
- package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
- package/lib/module/src/NitroInput.js +8 -6
- package/lib/module/src/NitroNumber.js +54 -3
- package/lib/module/src/NitroText.js +98 -0
- package/lib/module/src/NitroTime.js +29 -0
- package/lib/module/src/NumberFormat.js +521 -0
- package/lib/module/src/formatProps.js +104 -0
- package/lib/module/src/index.js +3 -0
- package/lib/module/src/specs/NitroText.nitro.js +1 -0
- package/lib/module/src/specs/NumberFormat.nitro.js +1 -0
- package/lib/typescript/src/NitroInput.d.ts +22 -0
- package/lib/typescript/src/NitroNumber.d.ts +115 -2
- package/lib/typescript/src/NitroText.d.ts +67 -0
- package/lib/typescript/src/NitroTime.d.ts +19 -0
- package/lib/typescript/src/NumberFormat.d.ts +47 -0
- package/lib/typescript/src/formatProps.d.ts +47 -0
- package/lib/typescript/src/index.d.ts +6 -1
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +10 -0
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +80 -1
- package/lib/typescript/src/specs/NitroText.nitro.d.ts +60 -0
- package/lib/typescript/src/specs/NumberFormat.nitro.d.ts +139 -0
- package/nitro.json +36 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +12 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +62 -0
- 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 +297 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +52 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.cpp +58 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +253 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +104 -0
- package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +3 -0
- package/nitrogen/generated/android/c++/JNitroNumberShimmerDirection.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroNumberSignDisplay.hpp +67 -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 +130 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +174 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.hpp +54 -0
- 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 +172 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroPlatformNumberFormatterSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextMeasureSpec.kt +60 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +179 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberShimmerDirection.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberSignDisplay.kt +26 -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/HybridNitroTextViewManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroTextViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +68 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +184 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +56 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +34 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +36 -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.hpp +188 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.hpp +94 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.hpp +90 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +233 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +30 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +156 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +264 -0
- 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 +26 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +658 -21
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec_cxx.swift +150 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +75 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +608 -0
- package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +4 -0
- package/nitrogen/generated/ios/swift/NitroNumberShimmerDirection.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroNumberSignDisplay.swift +52 -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 +52 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +58 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +62 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +115 -0
- package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +4 -0
- package/nitrogen/generated/shared/c++/NitroNumberShimmerDirection.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroNumberSignDisplay.hpp +88 -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 +52 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +74 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +149 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
- package/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
- package/package.json +2 -2
- package/src/NitroInput.tsx +42 -7
- package/src/NitroNumber.tsx +236 -12
- package/src/NitroText.tsx +166 -0
- package/src/NitroTime.tsx +68 -0
- package/src/NumberFormat.ts +563 -0
- package/src/formatProps.ts +149 -0
- package/src/index.ts +23 -0
- package/src/specs/NitroInput.nitro.ts +10 -0
- package/src/specs/NitroNumber.nitro.ts +82 -1
- package/src/specs/NitroText.nitro.ts +65 -0
- package/src/specs/NumberFormat.nitro.ts +145 -0
|
@@ -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`. */
|
|
@@ -176,6 +177,27 @@ 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;
|
|
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;
|
|
179
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. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ColorValue, type TextStyle, type ViewProps } from 'react-native';
|
|
3
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';
|
|
4
|
+
import type { NitroNumberAffixAlign, NitroNumberDirection, NitroNumberTransition, NitroNumberEasing, NitroNumberMethods, NitroNumberProps as NativeNitroNumberProps, NitroNumberRevealStyle, NitroNumberShimmerDirection, NitroNumberSignDisplay, NitroNumberTextAlign } from './specs/NitroNumber.nitro';
|
|
5
|
+
import type { NumberFormat } from './NumberFormat';
|
|
5
6
|
/**
|
|
6
7
|
* The raw Nitro host component. Prefer {@link NitroNumber}, which adds
|
|
7
8
|
* auto-sizing, color/weight conversion and a convenient handle.
|
|
@@ -75,7 +76,12 @@ export interface NitroNumberProps extends Omit<ViewProps, 'children'> {
|
|
|
75
76
|
* (`150` for the numeric transition).
|
|
76
77
|
*/
|
|
77
78
|
stagger?: number;
|
|
78
|
-
/**
|
|
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
|
+
*/
|
|
79
85
|
direction?: NitroNumberDirection;
|
|
80
86
|
/**
|
|
81
87
|
* Jackpot reveal, the casino "you won" presentation. While `false` the view
|
|
@@ -133,6 +139,19 @@ export interface NitroNumberProps extends Omit<ViewProps, 'children'> {
|
|
|
133
139
|
shimmerColor?: ColorValue;
|
|
134
140
|
/** Duration of one sweep in ms (linear, repeating). Default: `950`. */
|
|
135
141
|
shimmerDuration?: number;
|
|
142
|
+
/** The band's slant in degrees: 0 upright, positive leans it like "/", negative the other way. Default: `31`. */
|
|
143
|
+
shimmerAngle?: number;
|
|
144
|
+
/** The band's width as a fraction of the number's: `0.5` is a narrow glint. Default: `1`. */
|
|
145
|
+
shimmerWidth?: number;
|
|
146
|
+
/**
|
|
147
|
+
* The glyphs' colour outside the band while loading: a light grey makes the
|
|
148
|
+
* figure a skeleton that the band lights up. Default: `color`.
|
|
149
|
+
*/
|
|
150
|
+
shimmerBaseColor?: ColorValue;
|
|
151
|
+
/** Which way the band sweeps. Default: `'auto'`, the layout direction. */
|
|
152
|
+
shimmerDirection?: NitroNumberShimmerDirection;
|
|
153
|
+
/** A pause after each sweep, in ms. Default: `0`. */
|
|
154
|
+
shimmerDelay?: number;
|
|
136
155
|
/** Font size of the digits in points. Default: `32`. */
|
|
137
156
|
fontSize?: number;
|
|
138
157
|
/** Font size of `prefix`, e.g. a smaller currency symbol. Defaults to `fontSize`. */
|
|
@@ -149,6 +168,35 @@ export interface NitroNumberProps extends Omit<ViewProps, 'children'> {
|
|
|
149
168
|
prefixAlign?: NitroNumberAffixAlign;
|
|
150
169
|
/** Alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
151
170
|
suffixAlign?: NitroNumberAffixAlign;
|
|
171
|
+
/**
|
|
172
|
+
* Points added after every glyph, like `Text`'s `letterSpacing` (negative
|
|
173
|
+
* tightens). A smaller prefix or suffix gets it in proportion to its size.
|
|
174
|
+
* Default: `0`.
|
|
175
|
+
*/
|
|
176
|
+
letterSpacing?: number;
|
|
177
|
+
/** Points between the prefix and the digits, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
178
|
+
prefixSpacing?: number;
|
|
179
|
+
/** Points between the digits and the suffix, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
180
|
+
suffixSpacing?: number;
|
|
181
|
+
/** Points the prefix is moved down after `prefixAlign` places it (negative: up). Default: `0`. */
|
|
182
|
+
prefixOffset?: number;
|
|
183
|
+
/** Points the suffix is moved down after `suffixAlign` places it (negative: up). Default: `0`. */
|
|
184
|
+
suffixOffset?: number;
|
|
185
|
+
/**
|
|
186
|
+
* `true` (the default): every digit as wide as the widest, so columns never
|
|
187
|
+
* move, what a ticker or a price wants. `false`: each digit at its own
|
|
188
|
+
* width, the font's proportional figures, for a face whose "1" is narrow
|
|
189
|
+
* (or that has no tabular figures at all); a changing column's width
|
|
190
|
+
* then eases once from the old digit's to the new one's.
|
|
191
|
+
*/
|
|
192
|
+
tabularNums?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* A `NumberFormat` the number follows: its prefix and suffix (the currency
|
|
195
|
+
* where the locale puts it), grouping and decimal separators, fraction
|
|
196
|
+
* digits and minimum integer digits. The individual props override what it
|
|
197
|
+
* says.
|
|
198
|
+
*/
|
|
199
|
+
format?: NumberFormat;
|
|
152
200
|
/**
|
|
153
201
|
* Scale the number down when the view is narrower than its content, and back
|
|
154
202
|
* up (never above `fontSize`) when it fits again. Give the view a fixed
|
|
@@ -178,6 +226,71 @@ export interface NitroNumberProps extends Omit<ViewProps, 'children'> {
|
|
|
178
226
|
* `'left'` and `'right'` are absolute.
|
|
179
227
|
*/
|
|
180
228
|
textAlign?: NitroNumberTextAlign;
|
|
229
|
+
/**
|
|
230
|
+
* Which values carry a sign, as `Intl.NumberFormat`'s `signDisplay`:
|
|
231
|
+
* `'always'` and `'exceptZero'` put a plus on gains ("+$12.40"), and a plus
|
|
232
|
+
* that turns into a minus swaps like any other glyph. A value that rounds to
|
|
233
|
+
* zero at the shown fraction digits counts as zero. Default: `'auto'`
|
|
234
|
+
* (negatives), or the `format`'s.
|
|
235
|
+
*/
|
|
236
|
+
signDisplay?: NitroNumberSignDisplay;
|
|
237
|
+
/** The glyph drawn for a plus sign. Default: `'+'`. */
|
|
238
|
+
plusSign?: string;
|
|
239
|
+
/** The glyph drawn for a minus sign, e.g. `'−'` (U+2212). Default: `'-'`, or the `format` locale's. */
|
|
240
|
+
minusSign?: string;
|
|
241
|
+
/** The prefix's color. Default: `color`. */
|
|
242
|
+
prefixColor?: ColorValue;
|
|
243
|
+
/** The suffix's color. Default: `color`. */
|
|
244
|
+
suffixColor?: ColorValue;
|
|
245
|
+
/** The fraction digits' and decimal separator's color: dimmer cents. Default: `color`. */
|
|
246
|
+
fractionColor?: ColorValue;
|
|
247
|
+
/** The fraction digits' and decimal separator's size: smaller cents. Default: `fontSize`. */
|
|
248
|
+
fractionFontSize?: number;
|
|
249
|
+
/**
|
|
250
|
+
* How smaller fraction digits line up with the integer ones: `'baseline'`,
|
|
251
|
+
* or `'top'` for superscript cents ("$12⁹⁹"). Default: `'baseline'`.
|
|
252
|
+
*/
|
|
253
|
+
fractionAlign?: NitroNumberAffixAlign;
|
|
254
|
+
/**
|
|
255
|
+
* The ten glyphs drawn for 0 to 9, for native digits (Arabic-Indic,
|
|
256
|
+
* Devanagari…). Default: `'0'`…`'9'`, or the `format`'s numbering system.
|
|
257
|
+
*/
|
|
258
|
+
digitGlyphs?: string[];
|
|
259
|
+
/**
|
|
260
|
+
* Digit group sizes counted from the decimal point: the first group, then
|
|
261
|
+
* every later one. `[3, 2]` is Indian grouping (12,34,567), `[2]` a clock
|
|
262
|
+
* (12:34:56 with `groupingSeparator=":"`). Default: `[3]`, or the `format`'s.
|
|
263
|
+
*/
|
|
264
|
+
groupingSizes?: number[];
|
|
265
|
+
/**
|
|
266
|
+
* The highest digit a position shows before it wraps to 0, keyed by integer
|
|
267
|
+
* position (0 the ones, 1 the tens…), as NumberFlow's `digits`:
|
|
268
|
+
* `{ 1: { max: 5 } }` makes the tens of a clock's seconds wrap after 5, so
|
|
269
|
+
* 59 → 00 turns them one step instead of five back.
|
|
270
|
+
*/
|
|
271
|
+
digits?: Record<number, {
|
|
272
|
+
max: number;
|
|
273
|
+
}>;
|
|
274
|
+
/**
|
|
275
|
+
* Rolls turn the wheels below the highest one that changes a full turn too,
|
|
276
|
+
* so 100 → 200 seems to pass through every value between. Rolls only.
|
|
277
|
+
* Default: `false`.
|
|
278
|
+
*/
|
|
279
|
+
continuous?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* `false` shows every change at once, without a roll or a reveal (the flash
|
|
282
|
+
* and the pop still play). Default: `true`.
|
|
283
|
+
*/
|
|
284
|
+
animated?: boolean;
|
|
285
|
+
/** Snap instead of animating while the system's Reduce Motion is on. Default: `true`. */
|
|
286
|
+
respectReduceMotion?: boolean;
|
|
287
|
+
/** Called when the figure starts moving from rest: a change, or a reveal. */
|
|
288
|
+
onAnimationStart?: () => void;
|
|
289
|
+
/**
|
|
290
|
+
* Called when the figure comes to rest, with the value it shows: once for a
|
|
291
|
+
* run of changes that arrived while it was moving. Snapped changes fire neither.
|
|
292
|
+
*/
|
|
293
|
+
onAnimationEnd?: (value: number) => void;
|
|
181
294
|
/** Receives the native Nitro object once the view is mounted. */
|
|
182
295
|
onNativeRef?: (ref: NitroNumberRef) => void;
|
|
183
296
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ColorValue, type TextStyle, type ViewProps } from 'react-native';
|
|
3
|
+
import type { NitroTextMethods, NitroTextProps as NativeNitroTextProps } from './specs/NitroText.nitro';
|
|
4
|
+
import type { NitroInputEasing, NitroInputEffect } from './specs/NitroInput.nitro';
|
|
5
|
+
import type { NitroNumberShimmerDirection, NitroNumberTextAlign } from './specs/NitroNumber.nitro';
|
|
6
|
+
/** The raw Nitro host component behind {@link NitroText}. */
|
|
7
|
+
export declare const NativeNitroTextView: import("react-native-nitro-modules").ReactNativeView<NativeNitroTextProps, NitroTextMethods>;
|
|
8
|
+
/** What a {@link NitroText} takes: the text, its typography, the morph's timing and the loading shimmer. */
|
|
9
|
+
export interface NitroTextProps extends Omit<ViewProps, 'children'> {
|
|
10
|
+
/** The text: a string or a number. A change morphs to it. */
|
|
11
|
+
children: string | number;
|
|
12
|
+
/** Default: `17`. */
|
|
13
|
+
fontSize?: number;
|
|
14
|
+
/** Like `Text`'s. Default: `'normal'`. */
|
|
15
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
16
|
+
/** Defaults to the system font. */
|
|
17
|
+
fontFamily?: string;
|
|
18
|
+
/** Defaults to the platform's label colour. */
|
|
19
|
+
color?: ColorValue;
|
|
20
|
+
/** Points after every character. Default: `0`. */
|
|
21
|
+
letterSpacing?: number;
|
|
22
|
+
/** Where the line sits in a wider view. Default: `'auto'`, the start edge. */
|
|
23
|
+
textAlign?: NitroNumberTextAlign;
|
|
24
|
+
/** Scale with the system text size, like `Text`. Default: `false`. */
|
|
25
|
+
allowFontScaling?: boolean;
|
|
26
|
+
/** Cap for `allowFontScaling`; `0` is none. Default: `0`. */
|
|
27
|
+
maxFontSizeMultiplier?: number;
|
|
28
|
+
/** Of a morph, in ms; `0` switches at once. Default: `400`. */
|
|
29
|
+
duration?: number;
|
|
30
|
+
/** Default: `'expo'`. */
|
|
31
|
+
easing?: NitroInputEasing;
|
|
32
|
+
/** Overshoot of the `'spring'` easing. Default: `0.15`. */
|
|
33
|
+
bounce?: number;
|
|
34
|
+
/** How characters enter and leave: `'auto'` slides digits and fades letters. Default: `'auto'`. */
|
|
35
|
+
effect?: NitroInputEffect;
|
|
36
|
+
/** Snap instead of morphing while Reduce Motion is on. Default: `true`. */
|
|
37
|
+
respectReduceMotion?: boolean;
|
|
38
|
+
/** A loading glint through the text, as `NitroNumber`'s `loading`. Default: `false`. */
|
|
39
|
+
loading?: boolean;
|
|
40
|
+
shimmerColor?: ColorValue;
|
|
41
|
+
/** ms per sweep. Default: `950`. */
|
|
42
|
+
shimmerDuration?: number;
|
|
43
|
+
/** Degrees; 0 upright. Default: `31`. */
|
|
44
|
+
shimmerAngle?: number;
|
|
45
|
+
/** A fraction of the text's width. Default: `1`. */
|
|
46
|
+
shimmerWidth?: number;
|
|
47
|
+
/** The glyphs' colour outside the band: a skeleton. Default: `color`. */
|
|
48
|
+
shimmerBaseColor?: ColorValue;
|
|
49
|
+
/** Default: `'auto'`, the layout direction. */
|
|
50
|
+
shimmerDirection?: NitroNumberShimmerDirection;
|
|
51
|
+
/** ms of pause after each sweep. Default: `0`. */
|
|
52
|
+
shimmerDelay?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A single line of text that morphs to the next, natively, as Torph does on
|
|
56
|
+
* the web: the characters the two share glide to their new places, digits
|
|
57
|
+
* matched by place ("$1,204" → "$1,318" rolls the hundreds and tens), and the
|
|
58
|
+
* rest fade out and in ("Sign in" → "Signing in…"). At rest it is one line
|
|
59
|
+
* drawn in one pass, like a label: no text field, no layer per character.
|
|
60
|
+
* It sizes itself to its text in the render that mounts it (a native
|
|
61
|
+
* measurement, synchronously); a `width` in `style` overrides it.
|
|
62
|
+
*
|
|
63
|
+
* Only the props that were set go to the native view, as
|
|
64
|
+
* react-native-plain-text does: every prop that crosses is converted and
|
|
65
|
+
* stored per view in the commit, and the native side holds the defaults.
|
|
66
|
+
*/
|
|
67
|
+
export declare function NitroText({ children, fontSize, fontWeight, fontFamily, color, letterSpacing, textAlign, allowFontScaling, maxFontSizeMultiplier, duration, easing, bounce, effect, respectReduceMotion, loading, shimmerColor, shimmerDuration, shimmerAngle, shimmerWidth, shimmerBaseColor, shimmerDirection, shimmerDelay, style, ...viewProps }: NitroTextProps): React.JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type NitroNumberHandle, type NitroNumberProps } from './NitroNumber';
|
|
3
|
+
/** How a {@link NitroTime} lays the time out. */
|
|
4
|
+
export type NitroTimeFormat = 'm:ss' | 'mm:ss' | 'h:mm:ss' | 'hh:mm:ss';
|
|
5
|
+
export interface NitroTimeProps extends Omit<NitroNumberProps, 'value' | 'digits' | 'groupingSizes' | 'groupingSeparator' | 'minimumIntegerDigits' | 'fractionDigits' | 'decimalSeparator' | 'format'> {
|
|
6
|
+
/** The time in whole seconds (a timer's elapsed time, a countdown's remaining one). Negatives show as 0. */
|
|
7
|
+
seconds: number;
|
|
8
|
+
/** Default: `'m:ss'`. Without hours the minutes run past 59 (125:00). */
|
|
9
|
+
timeFormat?: NitroTimeFormat;
|
|
10
|
+
/** Between the fields. Default: `':'`. */
|
|
11
|
+
separator?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A clock, a timer or a countdown: `NitroNumber` with the time as its figure
|
|
15
|
+
* (12:34:56 is 123456), grouped in pairs, and the tens of seconds and minutes
|
|
16
|
+
* wrapping after 5, so 0:59 → 1:00 turns them one step, as a clock's wheels
|
|
17
|
+
* do, instead of rolling back through 4, 3, 2, 1.
|
|
18
|
+
*/
|
|
19
|
+
export declare const NitroTime: React.ForwardRefExoticComponent<NitroTimeProps & 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,47 @@
|
|
|
1
|
+
import { 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
|
+
/** Which values carry a sign, as the format's `signDisplay`. */
|
|
14
|
+
signDisplay: 'auto' | 'always' | 'exceptZero' | 'negative' | 'never';
|
|
15
|
+
/** The minus sign the locale writes ("-", or "−" in Swedish and Finnish). */
|
|
16
|
+
minusSign: string;
|
|
17
|
+
/** The plus sign the locale writes. */
|
|
18
|
+
plusSign: string;
|
|
19
|
+
/** The glyphs for 0…9 in the format's numbering system; empty for Latin digits. */
|
|
20
|
+
digitGlyphs: string[];
|
|
21
|
+
/** The first digit group and every later one, from the decimal point ([3, 2]: 12,34,567). */
|
|
22
|
+
groupingSizes: number[];
|
|
23
|
+
/** Compact notation: the prefix, suffix and digits follow the value (`compactParts`). */
|
|
24
|
+
compact: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The prefix, suffix, separators and digit counts of `format`, read off its
|
|
28
|
+
* parts once and cached per formatter. The components keep their own model
|
|
29
|
+
* (a sign, a prefix, digits in groups, a suffix), so a format outside it
|
|
30
|
+
* (accounting parentheses, a unit between the digits) is followed as far as
|
|
31
|
+
* that model goes.
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatProps(format: NumberFormat): FormatProps;
|
|
34
|
+
/** What a compact format shows for one value: the figure to roll and the text around it. */
|
|
35
|
+
export interface CompactParts {
|
|
36
|
+
/** The figure as the digits show it: 1.2 for "1.2K". */
|
|
37
|
+
value: number;
|
|
38
|
+
fractionDigits: number;
|
|
39
|
+
prefix: string;
|
|
40
|
+
suffix: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Compact notation's parts for `value`: "1.2K" is the figure 1.2 with the
|
|
44
|
+
* suffix "K", so the digits roll and the suffix swaps as the value crosses
|
|
45
|
+
* a thousand, a million…
|
|
46
|
+
*/
|
|
47
|
+
export declare function compactParts(format: NumberFormat, value: number): CompactParts;
|
|
@@ -4,4 +4,9 @@ export { useNitroInputState, type NitroInputState, type SharedValueLike, } from
|
|
|
4
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';
|
|
5
5
|
export type { NitroInputWorklets } from './specs/NitroInputWorklets.nitro';
|
|
6
6
|
export { NitroNumber, NativeNitroNumberView, type NitroNumberProps, type NitroNumberHandle, type NitroNumberRef, } from './NitroNumber';
|
|
7
|
-
export
|
|
7
|
+
export { NitroTime, type NitroTimeProps, type NitroTimeFormat } from './NitroTime';
|
|
8
|
+
export { NitroText, NativeNitroTextView, type NitroTextProps } from './NitroText';
|
|
9
|
+
export type { NitroTextMeasure, NitroTextView } from './specs/NitroText.nitro';
|
|
10
|
+
export type { NitroNumberAffixAlign, NitroNumberDirection, NitroNumberTransition, NitroNumberEasing, NitroNumberRevealStyle, NitroNumberShimmerDirection, NitroNumberSignDisplay, NitroNumberTextAlign, NitroNumberMethods, NitroNumberProps as NativeNitroNumberProps, NitroNumberView, } from './specs/NitroNumber.nitro';
|
|
11
|
+
export { NumberFormat, type NumberFormatConstructor, type NumberFormatRangePart } from './NumberFormat';
|
|
12
|
+
export type { NumberFormatOptions, NumberFormatPart, ResolvedNumberFormatOptions, NumberFormatStyle, NumberFormatCurrencyDisplay, NumberFormatCurrencySign, NumberFormatUnitDisplay, NumberFormatNotation, NumberFormatCompactDisplay, NumberFormatSignDisplay, NumberFormatRoundingMode, NumberFormatRoundingPriority, NumberFormatTrailingZeroDisplay, NumberFormatGrouping, } from './specs/NumberFormat.nitro';
|
|
@@ -176,6 +176,16 @@ 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
|
+
/** 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;
|
|
179
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. */
|
|
@@ -11,7 +11,7 @@ export type NitroNumberTextAlign = 'auto' | 'left' | 'center' | 'right';
|
|
|
11
11
|
/** Timing curve used when a value change is rolled natively. */
|
|
12
12
|
export type NitroNumberEasing = 'linear' | 'easeIn' | 'easeOut' | 'easeInOut' | 'spring';
|
|
13
13
|
/** Which way the digits roll: `'auto'` follows the sign of the change. */
|
|
14
|
-
export type NitroNumberDirection = 'auto' | 'up' | 'down';
|
|
14
|
+
export type NitroNumberDirection = 'auto' | 'up' | 'down' | 'shortest';
|
|
15
15
|
/**
|
|
16
16
|
* How a value change plays. `'roll'` is the odometer: every changed digit
|
|
17
17
|
* rolls through the digits between its old and new glyph. `'numeric'` is the
|
|
@@ -36,6 +36,16 @@ export type NitroNumberRevealStyle = 'count' | 'spin';
|
|
|
36
36
|
* boxes, `baseline` shares the digits' baseline, `center` centres the boxes.
|
|
37
37
|
*/
|
|
38
38
|
export type NitroNumberAffixAlign = 'baseline' | 'center' | 'top' | 'bottom';
|
|
39
|
+
/**
|
|
40
|
+
* Which values carry a sign, as `Intl.NumberFormat`'s `signDisplay`:
|
|
41
|
+
* `'auto'` negatives, `'always'` a plus on positives and zero too,
|
|
42
|
+
* `'exceptZero'` a plus or minus on everything but zero, `'negative'`
|
|
43
|
+
* negatives, `'never'` none. A value that rounds to zero at the shown
|
|
44
|
+
* fraction digits counts as zero, so `-0.001` shows no minus.
|
|
45
|
+
*/
|
|
46
|
+
export type NitroNumberSignDisplay = 'auto' | 'always' | 'never' | 'exceptZero' | 'negative';
|
|
47
|
+
/** Which way the loading shimmer sweeps: `'auto'` follows the layout direction. */
|
|
48
|
+
export type NitroNumberShimmerDirection = 'auto' | 'ltr' | 'rtl';
|
|
39
49
|
export interface NitroNumberProps extends HybridViewProps {
|
|
40
50
|
/**
|
|
41
51
|
* The number to display.
|
|
@@ -157,6 +167,16 @@ export interface NitroNumberProps extends HybridViewProps {
|
|
|
157
167
|
shimmerColor?: number;
|
|
158
168
|
/** Duration of one sweep in ms (linear, repeating). Default: `950`. */
|
|
159
169
|
shimmerDuration?: number;
|
|
170
|
+
/** The band's slant in degrees: 0 upright, positive leans it like "/". Default: `31`. */
|
|
171
|
+
shimmerAngle?: number;
|
|
172
|
+
/** The band's width as a fraction of the number's. Default: `1`. */
|
|
173
|
+
shimmerWidth?: number;
|
|
174
|
+
/** The glyphs' colour while loading, outside the band (processed). Not finite: `color`. */
|
|
175
|
+
shimmerBaseColor?: number;
|
|
176
|
+
/** Which way the band sweeps. Default: `'auto'`, the layout direction. */
|
|
177
|
+
shimmerDirection?: NitroNumberShimmerDirection;
|
|
178
|
+
/** A pause after each sweep, in ms. Default: `0`. */
|
|
179
|
+
shimmerDelay?: number;
|
|
160
180
|
/** Font size of the digits in points. Default: `32`. */
|
|
161
181
|
fontSize?: number;
|
|
162
182
|
/** Font size of `prefix` in points. Defaults to `fontSize`. */
|
|
@@ -169,6 +189,58 @@ export interface NitroNumberProps extends HybridViewProps {
|
|
|
169
189
|
prefixAlign?: NitroNumberAffixAlign;
|
|
170
190
|
/** Vertical alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
171
191
|
suffixAlign?: NitroNumberAffixAlign;
|
|
192
|
+
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. Default: `0`. */
|
|
193
|
+
letterSpacing?: number;
|
|
194
|
+
/** Points between the prefix and the digits, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
195
|
+
prefixSpacing?: number;
|
|
196
|
+
/** Points between the digits and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
197
|
+
suffixSpacing?: number;
|
|
198
|
+
/** Points the prefix is moved down after its alignment (negative: up). Default: `0`. */
|
|
199
|
+
prefixOffset?: number;
|
|
200
|
+
/** Points the suffix is moved down after its alignment (negative: up). Default: `0`. */
|
|
201
|
+
suffixOffset?: number;
|
|
202
|
+
/** Every digit as wide as the widest (`true`, the default), or each digit at its own width. */
|
|
203
|
+
tabularNums?: boolean;
|
|
204
|
+
/** Which values carry a sign. Default: `'auto'`. */
|
|
205
|
+
signDisplay?: NitroNumberSignDisplay;
|
|
206
|
+
/** The glyph drawn for a plus sign. Default: `'+'`. */
|
|
207
|
+
plusSign?: string;
|
|
208
|
+
/** The glyph drawn for a minus sign. Default: `'-'`. */
|
|
209
|
+
minusSign?: string;
|
|
210
|
+
/**
|
|
211
|
+
* The ten glyphs drawn for 0 to 9: native digits (Arabic-Indic, Devanagari…).
|
|
212
|
+
* Empty: `'0'`…`'9'`.
|
|
213
|
+
*/
|
|
214
|
+
digitGlyphs?: string[];
|
|
215
|
+
/**
|
|
216
|
+
* Digit group sizes counted from the decimal point: the first group, then
|
|
217
|
+
* every one after it. Empty: `[3]`. `[3, 2]` is Indian grouping
|
|
218
|
+
* (12,34,567), `[2]` a clock's (12:34:56 with `groupingSeparator=":"`).
|
|
219
|
+
*/
|
|
220
|
+
groupingSizes?: number[];
|
|
221
|
+
/**
|
|
222
|
+
* Per integer position (0 the ones, 1 the tens…), the highest digit its
|
|
223
|
+
* wheel shows before it wraps to 0; missing or not 0–8 means 9. `[9, 5]`
|
|
224
|
+
* makes the tens wrap after 5, as on a clock: 59 → 00 turns them one step.
|
|
225
|
+
*/
|
|
226
|
+
digitMax?: number[];
|
|
227
|
+
/**
|
|
228
|
+
* Rolls turn the wheels below the highest one that changes a full turn
|
|
229
|
+
* too, so the figure seems to pass through every value between. Default: `false`.
|
|
230
|
+
*/
|
|
231
|
+
continuous?: boolean;
|
|
232
|
+
/** The prefix's color (processed). Not finite: `color`. */
|
|
233
|
+
prefixColor?: number;
|
|
234
|
+
/** The suffix's color (processed). Not finite: `color`. */
|
|
235
|
+
suffixColor?: number;
|
|
236
|
+
/** The fraction digits' and decimal separator's color (processed). Not finite: `color`. */
|
|
237
|
+
fractionColor?: number;
|
|
238
|
+
/** The fraction digits' and decimal separator's size. Not finite: `fontSize`. */
|
|
239
|
+
fractionFontSize?: number;
|
|
240
|
+
/** How smaller fraction digits line up with the integer ones. Default: `'baseline'`. */
|
|
241
|
+
fractionAlign?: NitroNumberAffixAlign;
|
|
242
|
+
/** Snap instead of animating while the system's Reduce Motion is on. Default: `true`. */
|
|
243
|
+
respectReduceMotion?: boolean;
|
|
172
244
|
/**
|
|
173
245
|
* When the view is narrower than the number (e.g. it has a fixed `width` or
|
|
174
246
|
* `maxWidth`), scale the whole number down so it fits. Default: `false`.
|
|
@@ -218,6 +290,13 @@ export interface NitroNumberProps extends HybridViewProps {
|
|
|
218
290
|
* banner, fire the confetti and play the sting.
|
|
219
291
|
*/
|
|
220
292
|
onRevealMilestone?: (index: number, value: number) => void;
|
|
293
|
+
/** Called when the figure starts moving from rest (a change, or a reveal). */
|
|
294
|
+
onAnimationStart?: () => void;
|
|
295
|
+
/**
|
|
296
|
+
* Called when the figure comes to rest again, with the value it shows:
|
|
297
|
+
* once, however many changes arrived while it was moving.
|
|
298
|
+
*/
|
|
299
|
+
onAnimationEnd?: (value: number) => void;
|
|
221
300
|
}
|
|
222
301
|
export interface NitroNumberMethods extends HybridViewMethods {
|
|
223
302
|
/**
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { HybridObject, HybridView, HybridViewMethods, HybridViewProps } from 'react-native-nitro-modules';
|
|
2
|
+
import type { NitroNumberShimmerDirection, NitroNumberTextAlign } from './NitroNumber.nitro';
|
|
3
|
+
import type { NitroInputEasing, NitroInputEffect } from './NitroInput.nitro';
|
|
4
|
+
/**
|
|
5
|
+
* A single line of text that morphs to the next: the reflow engine's
|
|
6
|
+
* characters drawn in one pass, no text field. `NitroText` measures it (see
|
|
7
|
+
* `NitroTextMeasure`) and gives it its size, so a label lays out in the same
|
|
8
|
+
* commit that mounts it.
|
|
9
|
+
*
|
|
10
|
+
* Everything but the text is optional and the wrapper sends only what was
|
|
11
|
+
* set: each prop that crosses costs a conversion and an allocation per view
|
|
12
|
+
* in the commit, and a label usually sets two or three. The native side holds
|
|
13
|
+
* the defaults, and forgets what the last element set when it is recycled.
|
|
14
|
+
*/
|
|
15
|
+
export interface NitroTextProps extends HybridViewProps {
|
|
16
|
+
text: string;
|
|
17
|
+
/** In points, already scaled for the system text size when the wrapper was asked to. Default 17. */
|
|
18
|
+
fontSize?: number;
|
|
19
|
+
/** Numeric weight, 100–900. Default 400. */
|
|
20
|
+
fontWeight?: number;
|
|
21
|
+
/** Default: the system font. */
|
|
22
|
+
fontFamily?: string;
|
|
23
|
+
/** Processed ARGB. Default: the platform label colour. */
|
|
24
|
+
color?: number;
|
|
25
|
+
/** Points after every character. */
|
|
26
|
+
letterSpacing?: number;
|
|
27
|
+
textAlign?: NitroNumberTextAlign;
|
|
28
|
+
rightToLeft?: boolean;
|
|
29
|
+
/** Of a morph, in ms. Default 400. */
|
|
30
|
+
duration?: number;
|
|
31
|
+
easing?: NitroInputEasing;
|
|
32
|
+
bounce?: number;
|
|
33
|
+
effect?: NitroInputEffect;
|
|
34
|
+
respectReduceMotion?: boolean;
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
shimmerColor?: number;
|
|
37
|
+
shimmerDuration?: number;
|
|
38
|
+
shimmerAngle?: number;
|
|
39
|
+
shimmerWidth?: number;
|
|
40
|
+
shimmerBaseColor?: number;
|
|
41
|
+
shimmerDirection?: NitroNumberShimmerDirection;
|
|
42
|
+
shimmerDelay?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface NitroTextMethods extends HybridViewMethods {
|
|
45
|
+
}
|
|
46
|
+
export type NitroTextView = HybridView<NitroTextProps, NitroTextMethods>;
|
|
47
|
+
/**
|
|
48
|
+
* Measures a line the way `NitroTextView` lays it out (the sum of each
|
|
49
|
+
* character's advance plus the letter spacing), synchronously, so the
|
|
50
|
+
* component knows its size while it renders.
|
|
51
|
+
*/
|
|
52
|
+
export interface NitroTextMeasure extends HybridObject<{
|
|
53
|
+
ios: 'swift';
|
|
54
|
+
android: 'kotlin';
|
|
55
|
+
}> {
|
|
56
|
+
/** The line's width in points. */
|
|
57
|
+
measure(text: string, fontSize: number, fontWeight: number, fontFamily: string, letterSpacing: number): number;
|
|
58
|
+
/** The line box's height in points. */
|
|
59
|
+
lineHeight(fontSize: number, fontWeight: number, fontFamily: string): number;
|
|
60
|
+
}
|