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
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroNumberViewComponent.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/ReactProp.hpp>
|
|
11
|
+
#include <NitroModules/ViewComponentDescriptor.hpp>
|
|
12
|
+
#include <NitroModules/ViewPropsHolderState.hpp>
|
|
13
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
14
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
15
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
16
|
+
#include <react/renderer/core/RawProps.h>
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <string>
|
|
22
|
+
#include "NitroNumberEasing.hpp"
|
|
23
|
+
#include "NitroNumberTransition.hpp"
|
|
24
|
+
#include "NitroNumberDirection.hpp"
|
|
25
|
+
#include "NitroNumberRevealStyle.hpp"
|
|
26
|
+
#include <vector>
|
|
27
|
+
#include "NitroNumberAffixAlign.hpp"
|
|
28
|
+
#include "NitroNumberTextAlign.hpp"
|
|
29
|
+
#include <functional>
|
|
30
|
+
#include <memory>
|
|
31
|
+
#include "HybridNitroNumberViewSpec.hpp"
|
|
32
|
+
|
|
33
|
+
namespace margelo::nitro::nitroinput::views {
|
|
34
|
+
|
|
35
|
+
using namespace facebook;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The name of the actual native View.
|
|
39
|
+
*/
|
|
40
|
+
extern const char HybridNitroNumberViewComponentName[];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Props for the "NitroNumberView" View.
|
|
44
|
+
*/
|
|
45
|
+
class HybridNitroNumberViewProps final: public react::ViewProps {
|
|
46
|
+
public:
|
|
47
|
+
HybridNitroNumberViewProps() = default;
|
|
48
|
+
HybridNitroNumberViewProps(const react::PropsParserContext& context,
|
|
49
|
+
const HybridNitroNumberViewProps& sourceProps,
|
|
50
|
+
const react::RawProps& rawProps);
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
nitro::ReactProp<double> value;
|
|
54
|
+
nitro::ReactProp<std::optional<double>> fractionDigits;
|
|
55
|
+
nitro::ReactProp<std::optional<double>> minimumIntegerDigits;
|
|
56
|
+
nitro::ReactProp<std::optional<std::string>> groupingSeparator;
|
|
57
|
+
nitro::ReactProp<std::optional<std::string>> decimalSeparator;
|
|
58
|
+
nitro::ReactProp<std::optional<std::string>> prefix;
|
|
59
|
+
nitro::ReactProp<std::optional<std::string>> suffix;
|
|
60
|
+
nitro::ReactProp<std::optional<double>> duration;
|
|
61
|
+
nitro::ReactProp<std::optional<NitroNumberEasing>> easing;
|
|
62
|
+
nitro::ReactProp<std::optional<double>> bounce;
|
|
63
|
+
nitro::ReactProp<std::optional<double>> stagger;
|
|
64
|
+
nitro::ReactProp<std::optional<NitroNumberTransition>> transition;
|
|
65
|
+
nitro::ReactProp<std::optional<double>> flashUpColor;
|
|
66
|
+
nitro::ReactProp<std::optional<double>> flashDownColor;
|
|
67
|
+
nitro::ReactProp<std::optional<double>> flashDuration;
|
|
68
|
+
nitro::ReactProp<std::optional<double>> popOnChange;
|
|
69
|
+
nitro::ReactProp<std::optional<NitroNumberDirection>> rollDirection;
|
|
70
|
+
nitro::ReactProp<std::optional<double>> revealState;
|
|
71
|
+
nitro::ReactProp<std::optional<NitroNumberRevealStyle>> revealStyle;
|
|
72
|
+
nitro::ReactProp<std::optional<double>> revealDuration;
|
|
73
|
+
nitro::ReactProp<std::optional<double>> revealBounce;
|
|
74
|
+
nitro::ReactProp<std::optional<double>> revealGrow;
|
|
75
|
+
nitro::ReactProp<std::optional<double>> revealStagger;
|
|
76
|
+
nitro::ReactProp<std::optional<std::vector<double>>> revealMilestones;
|
|
77
|
+
nitro::ReactProp<std::optional<double>> revealMilestoneHold;
|
|
78
|
+
nitro::ReactProp<std::optional<bool>> loading;
|
|
79
|
+
nitro::ReactProp<std::optional<double>> shimmerColor;
|
|
80
|
+
nitro::ReactProp<std::optional<double>> shimmerDuration;
|
|
81
|
+
nitro::ReactProp<std::optional<double>> fontSize;
|
|
82
|
+
nitro::ReactProp<std::optional<double>> prefixFontSize;
|
|
83
|
+
nitro::ReactProp<std::optional<double>> suffixFontSize;
|
|
84
|
+
nitro::ReactProp<std::optional<NitroNumberAffixAlign>> affixAlign;
|
|
85
|
+
nitro::ReactProp<std::optional<NitroNumberAffixAlign>> prefixAlign;
|
|
86
|
+
nitro::ReactProp<std::optional<NitroNumberAffixAlign>> suffixAlign;
|
|
87
|
+
nitro::ReactProp<std::optional<double>> letterSpacing;
|
|
88
|
+
nitro::ReactProp<std::optional<double>> prefixSpacing;
|
|
89
|
+
nitro::ReactProp<std::optional<double>> suffixSpacing;
|
|
90
|
+
nitro::ReactProp<std::optional<double>> prefixOffset;
|
|
91
|
+
nitro::ReactProp<std::optional<double>> suffixOffset;
|
|
92
|
+
nitro::ReactProp<std::optional<bool>> tabularNums;
|
|
93
|
+
nitro::ReactProp<std::optional<bool>> adjustsFontSizeToFit;
|
|
94
|
+
nitro::ReactProp<std::optional<double>> minimumFontScale;
|
|
95
|
+
nitro::ReactProp<std::optional<bool>> allowFontScaling;
|
|
96
|
+
nitro::ReactProp<std::optional<double>> maxFontSizeMultiplier;
|
|
97
|
+
nitro::ReactProp<std::optional<double>> fontWeight;
|
|
98
|
+
nitro::ReactProp<std::optional<std::string>> fontFamily;
|
|
99
|
+
nitro::ReactProp<std::optional<double>> color;
|
|
100
|
+
nitro::ReactProp<std::optional<NitroNumberTextAlign>> textAlign;
|
|
101
|
+
nitro::ReactProp<std::optional<bool>> rightToLeft;
|
|
102
|
+
nitro::ReactProp<std::optional<std::function<void(double /* width */, double /* height */)>>> onSizeChange;
|
|
103
|
+
nitro::ReactProp<std::optional<std::function<void()>>> onRevealEnd;
|
|
104
|
+
nitro::ReactProp<std::optional<std::function<void(double /* index */, double /* value */)>>> onRevealMilestone;
|
|
105
|
+
nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNitroNumberViewSpec>& /* ref */)>>> hybridRef;
|
|
106
|
+
|
|
107
|
+
[[nodiscard]]
|
|
108
|
+
bool hasSameProps(const HybridNitroNumberViewProps& other) const noexcept {
|
|
109
|
+
return value.hasSameValue(other.value) &&
|
|
110
|
+
fractionDigits.hasSameValue(other.fractionDigits) &&
|
|
111
|
+
minimumIntegerDigits.hasSameValue(other.minimumIntegerDigits) &&
|
|
112
|
+
groupingSeparator.hasSameValue(other.groupingSeparator) &&
|
|
113
|
+
decimalSeparator.hasSameValue(other.decimalSeparator) &&
|
|
114
|
+
prefix.hasSameValue(other.prefix) &&
|
|
115
|
+
suffix.hasSameValue(other.suffix) &&
|
|
116
|
+
duration.hasSameValue(other.duration) &&
|
|
117
|
+
easing.hasSameValue(other.easing) &&
|
|
118
|
+
bounce.hasSameValue(other.bounce) &&
|
|
119
|
+
stagger.hasSameValue(other.stagger) &&
|
|
120
|
+
transition.hasSameValue(other.transition) &&
|
|
121
|
+
flashUpColor.hasSameValue(other.flashUpColor) &&
|
|
122
|
+
flashDownColor.hasSameValue(other.flashDownColor) &&
|
|
123
|
+
flashDuration.hasSameValue(other.flashDuration) &&
|
|
124
|
+
popOnChange.hasSameValue(other.popOnChange) &&
|
|
125
|
+
rollDirection.hasSameValue(other.rollDirection) &&
|
|
126
|
+
revealState.hasSameValue(other.revealState) &&
|
|
127
|
+
revealStyle.hasSameValue(other.revealStyle) &&
|
|
128
|
+
revealDuration.hasSameValue(other.revealDuration) &&
|
|
129
|
+
revealBounce.hasSameValue(other.revealBounce) &&
|
|
130
|
+
revealGrow.hasSameValue(other.revealGrow) &&
|
|
131
|
+
revealStagger.hasSameValue(other.revealStagger) &&
|
|
132
|
+
revealMilestones.hasSameValue(other.revealMilestones) &&
|
|
133
|
+
revealMilestoneHold.hasSameValue(other.revealMilestoneHold) &&
|
|
134
|
+
loading.hasSameValue(other.loading) &&
|
|
135
|
+
shimmerColor.hasSameValue(other.shimmerColor) &&
|
|
136
|
+
shimmerDuration.hasSameValue(other.shimmerDuration) &&
|
|
137
|
+
fontSize.hasSameValue(other.fontSize) &&
|
|
138
|
+
prefixFontSize.hasSameValue(other.prefixFontSize) &&
|
|
139
|
+
suffixFontSize.hasSameValue(other.suffixFontSize) &&
|
|
140
|
+
affixAlign.hasSameValue(other.affixAlign) &&
|
|
141
|
+
prefixAlign.hasSameValue(other.prefixAlign) &&
|
|
142
|
+
suffixAlign.hasSameValue(other.suffixAlign) &&
|
|
143
|
+
letterSpacing.hasSameValue(other.letterSpacing) &&
|
|
144
|
+
prefixSpacing.hasSameValue(other.prefixSpacing) &&
|
|
145
|
+
suffixSpacing.hasSameValue(other.suffixSpacing) &&
|
|
146
|
+
prefixOffset.hasSameValue(other.prefixOffset) &&
|
|
147
|
+
suffixOffset.hasSameValue(other.suffixOffset) &&
|
|
148
|
+
tabularNums.hasSameValue(other.tabularNums) &&
|
|
149
|
+
adjustsFontSizeToFit.hasSameValue(other.adjustsFontSizeToFit) &&
|
|
150
|
+
minimumFontScale.hasSameValue(other.minimumFontScale) &&
|
|
151
|
+
allowFontScaling.hasSameValue(other.allowFontScaling) &&
|
|
152
|
+
maxFontSizeMultiplier.hasSameValue(other.maxFontSizeMultiplier) &&
|
|
153
|
+
fontWeight.hasSameValue(other.fontWeight) &&
|
|
154
|
+
fontFamily.hasSameValue(other.fontFamily) &&
|
|
155
|
+
color.hasSameValue(other.color) &&
|
|
156
|
+
textAlign.hasSameValue(other.textAlign) &&
|
|
157
|
+
rightToLeft.hasSameValue(other.rightToLeft) &&
|
|
158
|
+
onSizeChange.hasSameValue(other.onSizeChange) &&
|
|
159
|
+
onRevealEnd.hasSameValue(other.onRevealEnd) &&
|
|
160
|
+
onRevealMilestone.hasSameValue(other.onRevealMilestone) &&
|
|
161
|
+
hybridRef.hasSameValue(other.hybridRef);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
[[nodiscard]]
|
|
165
|
+
bool hasAnyProvidedProps() const noexcept {
|
|
166
|
+
return value.isProvided() ||
|
|
167
|
+
fractionDigits.isProvided() ||
|
|
168
|
+
minimumIntegerDigits.isProvided() ||
|
|
169
|
+
groupingSeparator.isProvided() ||
|
|
170
|
+
decimalSeparator.isProvided() ||
|
|
171
|
+
prefix.isProvided() ||
|
|
172
|
+
suffix.isProvided() ||
|
|
173
|
+
duration.isProvided() ||
|
|
174
|
+
easing.isProvided() ||
|
|
175
|
+
bounce.isProvided() ||
|
|
176
|
+
stagger.isProvided() ||
|
|
177
|
+
transition.isProvided() ||
|
|
178
|
+
flashUpColor.isProvided() ||
|
|
179
|
+
flashDownColor.isProvided() ||
|
|
180
|
+
flashDuration.isProvided() ||
|
|
181
|
+
popOnChange.isProvided() ||
|
|
182
|
+
rollDirection.isProvided() ||
|
|
183
|
+
revealState.isProvided() ||
|
|
184
|
+
revealStyle.isProvided() ||
|
|
185
|
+
revealDuration.isProvided() ||
|
|
186
|
+
revealBounce.isProvided() ||
|
|
187
|
+
revealGrow.isProvided() ||
|
|
188
|
+
revealStagger.isProvided() ||
|
|
189
|
+
revealMilestones.isProvided() ||
|
|
190
|
+
revealMilestoneHold.isProvided() ||
|
|
191
|
+
loading.isProvided() ||
|
|
192
|
+
shimmerColor.isProvided() ||
|
|
193
|
+
shimmerDuration.isProvided() ||
|
|
194
|
+
fontSize.isProvided() ||
|
|
195
|
+
prefixFontSize.isProvided() ||
|
|
196
|
+
suffixFontSize.isProvided() ||
|
|
197
|
+
affixAlign.isProvided() ||
|
|
198
|
+
prefixAlign.isProvided() ||
|
|
199
|
+
suffixAlign.isProvided() ||
|
|
200
|
+
letterSpacing.isProvided() ||
|
|
201
|
+
prefixSpacing.isProvided() ||
|
|
202
|
+
suffixSpacing.isProvided() ||
|
|
203
|
+
prefixOffset.isProvided() ||
|
|
204
|
+
suffixOffset.isProvided() ||
|
|
205
|
+
tabularNums.isProvided() ||
|
|
206
|
+
adjustsFontSizeToFit.isProvided() ||
|
|
207
|
+
minimumFontScale.isProvided() ||
|
|
208
|
+
allowFontScaling.isProvided() ||
|
|
209
|
+
maxFontSizeMultiplier.isProvided() ||
|
|
210
|
+
fontWeight.isProvided() ||
|
|
211
|
+
fontFamily.isProvided() ||
|
|
212
|
+
color.isProvided() ||
|
|
213
|
+
textAlign.isProvided() ||
|
|
214
|
+
rightToLeft.isProvided() ||
|
|
215
|
+
onSizeChange.isProvided() ||
|
|
216
|
+
onRevealEnd.isProvided() ||
|
|
217
|
+
onRevealMilestone.isProvided() ||
|
|
218
|
+
hybridRef.isProvided();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private:
|
|
222
|
+
static bool filterObjectKeys(const std::string& propName);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* State for the "NitroNumberView" View.
|
|
227
|
+
*/
|
|
228
|
+
using HybridNitroNumberViewState = nitro::ViewPropsHolderState<HybridNitroNumberViewProps>;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The Shadow Node for the "NitroNumberView" View.
|
|
232
|
+
*/
|
|
233
|
+
using HybridNitroNumberViewShadowNode = react::ConcreteViewShadowNode<HybridNitroNumberViewComponentName /* "HybridNitroNumberView" */,
|
|
234
|
+
HybridNitroNumberViewProps /* custom props */,
|
|
235
|
+
react::ViewEventEmitter /* default */,
|
|
236
|
+
HybridNitroNumberViewState /* custom state */>;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The Component Descriptor for the "NitroNumberView" View.
|
|
240
|
+
*/
|
|
241
|
+
using HybridNitroNumberViewComponentDescriptor = nitro::ViewComponentDescriptor<HybridNitroNumberViewShadowNode>;
|
|
242
|
+
|
|
243
|
+
/* The actual view for "NitroNumberView" needs to be implemented in platform-specific code. */
|
|
244
|
+
|
|
245
|
+
} // namespace margelo::nitro::nitroinput::views
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"signPlacement": true,
|
|
35
35
|
"prefixAlign": true,
|
|
36
36
|
"suffixAlign": true,
|
|
37
|
+
"letterSpacing": true,
|
|
38
|
+
"prefixSpacing": true,
|
|
39
|
+
"suffixSpacing": true,
|
|
40
|
+
"prefixOffset": true,
|
|
41
|
+
"suffixOffset": true,
|
|
37
42
|
"placeholder": true,
|
|
38
43
|
"placeholderColor": true,
|
|
39
44
|
"duration": true,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uiViewClassName": "NitroNumberView",
|
|
3
|
+
"supportsRawText": false,
|
|
4
|
+
"bubblingEventTypes": {},
|
|
5
|
+
"directEventTypes": {},
|
|
6
|
+
"validAttributes": {
|
|
7
|
+
"value": true,
|
|
8
|
+
"fractionDigits": true,
|
|
9
|
+
"minimumIntegerDigits": true,
|
|
10
|
+
"groupingSeparator": true,
|
|
11
|
+
"decimalSeparator": true,
|
|
12
|
+
"prefix": true,
|
|
13
|
+
"suffix": true,
|
|
14
|
+
"duration": true,
|
|
15
|
+
"easing": true,
|
|
16
|
+
"bounce": true,
|
|
17
|
+
"stagger": true,
|
|
18
|
+
"transition": true,
|
|
19
|
+
"flashUpColor": true,
|
|
20
|
+
"flashDownColor": true,
|
|
21
|
+
"flashDuration": true,
|
|
22
|
+
"popOnChange": true,
|
|
23
|
+
"rollDirection": true,
|
|
24
|
+
"revealState": true,
|
|
25
|
+
"revealStyle": true,
|
|
26
|
+
"revealDuration": true,
|
|
27
|
+
"revealBounce": true,
|
|
28
|
+
"revealGrow": true,
|
|
29
|
+
"revealStagger": true,
|
|
30
|
+
"revealMilestones": true,
|
|
31
|
+
"revealMilestoneHold": true,
|
|
32
|
+
"loading": true,
|
|
33
|
+
"shimmerColor": true,
|
|
34
|
+
"shimmerDuration": true,
|
|
35
|
+
"fontSize": true,
|
|
36
|
+
"prefixFontSize": true,
|
|
37
|
+
"suffixFontSize": true,
|
|
38
|
+
"affixAlign": true,
|
|
39
|
+
"prefixAlign": true,
|
|
40
|
+
"suffixAlign": true,
|
|
41
|
+
"letterSpacing": true,
|
|
42
|
+
"prefixSpacing": true,
|
|
43
|
+
"suffixSpacing": true,
|
|
44
|
+
"prefixOffset": true,
|
|
45
|
+
"suffixOffset": true,
|
|
46
|
+
"tabularNums": true,
|
|
47
|
+
"adjustsFontSizeToFit": true,
|
|
48
|
+
"minimumFontScale": true,
|
|
49
|
+
"allowFontScaling": true,
|
|
50
|
+
"maxFontSizeMultiplier": true,
|
|
51
|
+
"fontWeight": true,
|
|
52
|
+
"fontFamily": true,
|
|
53
|
+
"color": true,
|
|
54
|
+
"textAlign": true,
|
|
55
|
+
"rightToLeft": true,
|
|
56
|
+
"onSizeChange": true,
|
|
57
|
+
"onRevealEnd": true,
|
|
58
|
+
"onRevealMilestone": true,
|
|
59
|
+
"hybridRef": true
|
|
60
|
+
}
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-input",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Native text and amount input
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Native text for React Native, built with Nitro: a text and amount input with native formatting, masks and a Torph-style reflow, and an animated number (odometer, SwiftUI-style numeric text, ticker) whose digits roll or swap natively, with currency layouts and animated currency switches, shrink-to-fit, a loading shimmer and a jackpot reveal.",
|
|
5
5
|
"main": "lib/commonjs/src/index.js",
|
|
6
6
|
"module": "lib/module/src/index.js",
|
|
7
7
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"specs": "nitrogen --logLevel=\"debug\"",
|
|
40
40
|
"prepack": "bun run build",
|
|
41
41
|
"test": "jest",
|
|
42
|
-
"test:cpp": "mkdir -p .cache && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/
|
|
42
|
+
"test:cpp": "mkdir -p .cache && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/ReflowEngine.cpp cpp/AmountFormatter.cpp cpp/__tests__/ReflowEngineTest.cpp -o .cache/reflow-engine-test && .cache/reflow-engine-test && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/AmountFormatter.cpp cpp/__tests__/AmountFormatterTest.cpp -o .cache/amount-formatter-test && .cache/amount-formatter-test && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/AmountFormatter.cpp cpp/MaskEngine.cpp cpp/__tests__/MaskEngineTest.cpp -o .cache/mask-engine-test && .cache/mask-engine-test && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/OutlineGeometry.cpp cpp/__tests__/OutlineGeometryTest.cpp -o .cache/outline-geometry-test && .cache/outline-geometry-test && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/RollingEngine.cpp cpp/__tests__/RollingEngineTest.cpp -o .cache/rolling-engine-test && .cache/rolling-engine-test && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/numberformat/NumberFormatCore.cpp cpp/__tests__/NumberFormatCoreTest.cpp -o .cache/number-format-core-test && .cache/number-format-core-test && clang++ -std=c++20 -O1 -Wall -Wextra -Icpp cpp/numberformat/NumberFormatCore.cpp cpp/numberformat/NumberFormatProbe.cpp cpp/__tests__/NumberFormatProbeTest.cpp -o .cache/number-format-probe-test && .cache/number-format-probe-test",
|
|
43
|
+
"test:cpp:sanitize": "mkdir -p .cache && clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer -Icpp cpp/RollingEngine.cpp cpp/__tests__/RollingEngineTest.cpp -o .cache/rolling-engine-sanitize && .cache/rolling-engine-sanitize",
|
|
43
44
|
"release": "release-it"
|
|
44
45
|
},
|
|
45
46
|
"keywords": [
|
|
@@ -51,18 +52,25 @@
|
|
|
51
52
|
"currency-input",
|
|
52
53
|
"text-morph",
|
|
53
54
|
"torph",
|
|
54
|
-
"animated-input"
|
|
55
|
+
"animated-input",
|
|
56
|
+
"rolling-number",
|
|
57
|
+
"odometer",
|
|
58
|
+
"ticker",
|
|
59
|
+
"animated-number",
|
|
60
|
+
"numeric-text",
|
|
61
|
+
"number-flow",
|
|
62
|
+
"counter"
|
|
55
63
|
],
|
|
56
64
|
"repository": {
|
|
57
65
|
"type": "git",
|
|
58
|
-
"url": "git+https://github.com/ronickg/react-native-nitro-
|
|
66
|
+
"url": "git+https://github.com/ronickg/react-native-nitro-input.git"
|
|
59
67
|
},
|
|
60
68
|
"author": "Ronald Goedeke",
|
|
61
69
|
"license": "MIT",
|
|
62
70
|
"bugs": {
|
|
63
|
-
"url": "https://github.com/ronickg/react-native-nitro-
|
|
71
|
+
"url": "https://github.com/ronickg/react-native-nitro-input/issues"
|
|
64
72
|
},
|
|
65
|
-
"homepage": "https://github.com/ronickg/react-native-nitro-
|
|
73
|
+
"homepage": "https://github.com/ronickg/react-native-nitro-input/tree/main/packages/react-native-nitro-input#readme",
|
|
66
74
|
"publishConfig": {
|
|
67
75
|
"registry": "https://registry.npmjs.org/"
|
|
68
76
|
},
|
package/src/NitroInput.tsx
CHANGED
|
@@ -8,7 +8,6 @@ import React, {
|
|
|
8
8
|
} from 'react'
|
|
9
9
|
import {
|
|
10
10
|
I18nManager,
|
|
11
|
-
processColor,
|
|
12
11
|
StyleSheet,
|
|
13
12
|
type ColorValue,
|
|
14
13
|
type TextStyle,
|
|
@@ -52,6 +51,9 @@ import {
|
|
|
52
51
|
type NitroInputSelection,
|
|
53
52
|
type NitroInputTransform,
|
|
54
53
|
} from './worklets'
|
|
54
|
+
import { toNumericWeight, toProcessedColor } from './styleHelpers'
|
|
55
|
+
import { formatProps } from './formatProps'
|
|
56
|
+
import type { NumberFormat } from './NumberFormat'
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* React Native's registry of mounted text inputs. `TextInput.State` only
|
|
@@ -354,7 +356,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
354
356
|
* Where a negative amount's sign sits relative to `prefix`. `'beforeAffix'`
|
|
355
357
|
* (the default) reads `-$1,234.56`; `'afterAffix'` reads `$-1,234.56`, which
|
|
356
358
|
* suits a symbol styled as an ornament rather than read as part of the
|
|
357
|
-
* number. Only the
|
|
359
|
+
* number. Only the reflow honours it - a plain field's affixes are accessory
|
|
358
360
|
* views outside the text, so it is always `'afterAffix'`.
|
|
359
361
|
*/
|
|
360
362
|
signPlacement?: NitroInputSignPlacement
|
|
@@ -362,13 +364,34 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
362
364
|
prefixAlign?: NitroInputAffixAlign
|
|
363
365
|
/** Alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
364
366
|
suffixAlign?: NitroInputAffixAlign
|
|
365
|
-
/**
|
|
367
|
+
/**
|
|
368
|
+
* Points added after every glyph, like `Text`'s `letterSpacing` (negative
|
|
369
|
+
* tightens). A smaller prefix or suffix gets it in proportion to its size.
|
|
370
|
+
* Default: `0`.
|
|
371
|
+
*/
|
|
372
|
+
letterSpacing?: number
|
|
373
|
+
/** Points between the prefix and the text, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
374
|
+
prefixSpacing?: number
|
|
375
|
+
/** Points between the text and the suffix, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
376
|
+
suffixSpacing?: number
|
|
377
|
+
/** Points the prefix is moved down after `prefixAlign` places it (negative: up). Default: `0`. */
|
|
378
|
+
prefixOffset?: number
|
|
379
|
+
/** Points the suffix is moved down after `suffixAlign` places it (negative: up). Default: `0`. */
|
|
380
|
+
suffixOffset?: number
|
|
381
|
+
/**
|
|
382
|
+
* A `NumberFormat` the amount follows: its prefix and suffix (the currency
|
|
383
|
+
* where the locale puts it), grouping and decimal separators, fraction
|
|
384
|
+
* digits and where the sign goes. Sets `mode` to `'number'` unless it is
|
|
385
|
+
* given. The individual props override what it says.
|
|
386
|
+
*/
|
|
387
|
+
format?: NumberFormat
|
|
388
|
+
/** Shown while the field is empty and reflowed away by the first character. In `'number'` mode `'0'` reads well. */
|
|
366
389
|
placeholder?: string
|
|
367
390
|
/** Color of the placeholder. Defaults to the platform placeholder color. */
|
|
368
391
|
placeholderTextColor?: ColorValue
|
|
369
|
-
/** Duration in ms of the
|
|
392
|
+
/** Duration in ms of the reflow played on every change. `0` snaps. Default: `400`. */
|
|
370
393
|
duration?: number
|
|
371
|
-
/** Timing curve of the
|
|
394
|
+
/** Timing curve of the reflow. Default: `'expo'` (Torph's `cubic-bezier(0.19, 1, 0.22, 1)`). */
|
|
372
395
|
easing?: NitroInputEasing
|
|
373
396
|
/** Overshoot of the `'spring'` easing, `0`–`1`. Default: `0.15`. */
|
|
374
397
|
bounce?: number
|
|
@@ -385,7 +408,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
385
408
|
* line occupies rather than extra leading. Omit to use the font's own.
|
|
386
409
|
*
|
|
387
410
|
* Unlike `TextInput`, a line height *tighter* than the font is centred
|
|
388
|
-
* correctly too, and it applies to single-line and
|
|
411
|
+
* correctly too, and it applies to single-line and reflowing fields, not only
|
|
389
412
|
* wrapped ones.
|
|
390
413
|
*/
|
|
391
414
|
lineHeight?: number
|
|
@@ -433,8 +456,8 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
433
456
|
*
|
|
434
457
|
* A multiline field is always drawn by the system view and is always
|
|
435
458
|
* `'text'` mode: the glyph engine lays one run out on one baseline, so it
|
|
436
|
-
* cannot
|
|
437
|
-
* `
|
|
459
|
+
* cannot reflow wrapped text, and an amount or a mask is a single-line idea.
|
|
460
|
+
* `transition="reflow"`, `mode="number"`, `mode="mask"` and the `prefix` / `suffix`
|
|
438
461
|
* affixes are ignored alongside it, with one warning each in development.
|
|
439
462
|
* The return key inserts a line break unless `submitBehavior` says otherwise.
|
|
440
463
|
*/
|
|
@@ -489,20 +512,22 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
489
512
|
/** The caret/selection to apply, in code points. */
|
|
490
513
|
selection?: { start: number; end?: number }
|
|
491
514
|
/**
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
515
|
+
* How the text changes. `'none'` (the default) draws it the instant it
|
|
516
|
+
* changes: this is a text field first, and a `TextInput` does not animate
|
|
517
|
+
* its characters. `'reflow'` runs the glyph engine, so characters that stay
|
|
518
|
+
* glide to their new place, new ones slide or fade in and removed ones leave
|
|
519
|
+
* alongside their neighbours, which is what an amount field wants. A
|
|
520
|
+
* multiline field is always `'none'`.
|
|
496
521
|
*/
|
|
497
|
-
|
|
522
|
+
transition?: NitroInputTransition
|
|
498
523
|
/**
|
|
499
524
|
* Whether the field sizes itself to its content.
|
|
500
525
|
*
|
|
501
|
-
* `false`
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
526
|
+
* `false` takes no width of its own, so flexbox stretches it to its parent
|
|
527
|
+
* the way a `TextInput` is stretched — that is what makes this a drop-in.
|
|
528
|
+
* `true` always sizes to content. `'auto'` infers it: on unless `style`
|
|
529
|
+
* gives a `width` or `flex`, which is what lets an amount grow as digits
|
|
530
|
+
* arrive. Default: `'auto'` with `transition="reflow"`, else `false`.
|
|
506
531
|
*/
|
|
507
532
|
autoWidth?: boolean | 'auto'
|
|
508
533
|
/** `'text'` mode: most characters accepted. Default: unlimited. */
|
|
@@ -558,7 +583,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
558
583
|
export interface NitroInputHandle {
|
|
559
584
|
focus(): void
|
|
560
585
|
blur(): void
|
|
561
|
-
/** Empties the field,
|
|
586
|
+
/** Empties the field, reflowing the characters away. */
|
|
562
587
|
clear(): void
|
|
563
588
|
/** Replaces the text (formatted in `'number'` mode), caret at the end. */
|
|
564
589
|
setText(text: string): void
|
|
@@ -575,39 +600,6 @@ export interface NitroInputHandle {
|
|
|
575
600
|
readonly native: NitroInputRef | null
|
|
576
601
|
}
|
|
577
602
|
|
|
578
|
-
// shared-helpers:start
|
|
579
|
-
// Kept byte-for-byte identical with packages/react-native-nitro-rolling-number/src/RollingNumber.tsx
|
|
580
|
-
// (a test compares the two blocks); change both together.
|
|
581
|
-
const FONT_WEIGHTS: Record<string, number> = {
|
|
582
|
-
normal: 400,
|
|
583
|
-
regular: 400,
|
|
584
|
-
bold: 700,
|
|
585
|
-
ultralight: 100,
|
|
586
|
-
thin: 200,
|
|
587
|
-
light: 300,
|
|
588
|
-
medium: 500,
|
|
589
|
-
semibold: 600,
|
|
590
|
-
condensedBold: 700,
|
|
591
|
-
condensed: 400,
|
|
592
|
-
heavy: 800,
|
|
593
|
-
black: 900,
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
function toNumericWeight(weight: TextStyle['fontWeight']): number | undefined {
|
|
597
|
-
if (weight == null) return undefined
|
|
598
|
-
if (typeof weight === 'number') return weight
|
|
599
|
-
const parsed = Number(weight)
|
|
600
|
-
if (!Number.isNaN(parsed)) return parsed
|
|
601
|
-
return FONT_WEIGHTS[weight]
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
function toProcessedColor(color: ColorValue | undefined): number | undefined {
|
|
605
|
-
if (color == null) return undefined
|
|
606
|
-
const processed = processColor(color)
|
|
607
|
-
return typeof processed === 'number' ? processed : undefined
|
|
608
|
-
}
|
|
609
|
-
// shared-helpers:end
|
|
610
|
-
|
|
611
603
|
interface Size {
|
|
612
604
|
width: number
|
|
613
605
|
height: number
|
|
@@ -625,19 +617,25 @@ function warnIncompatible(what: string): void {
|
|
|
625
617
|
)
|
|
626
618
|
}
|
|
627
619
|
|
|
620
|
+
/**
|
|
621
|
+
* How a `NitroInput`'s text changes: drawn at once (`'none'`), or reflowed by
|
|
622
|
+
* the glyph engine (`'reflow'`).
|
|
623
|
+
*/
|
|
624
|
+
export type NitroInputTransition = 'none' | 'reflow'
|
|
625
|
+
|
|
628
626
|
/**
|
|
629
627
|
* A native text input: a system field (`UITextField` / `EditText`) that owns
|
|
630
628
|
* the keyboard, editing, selection, paste and accessibility, with native
|
|
631
629
|
* formatting (`mode="number"`), native masking (`mode="mask"`), an outlined
|
|
632
630
|
* or filled frame with a floating label, and optionally the glyph engine
|
|
633
|
-
* (`
|
|
631
|
+
* (`transition="reflow"`), under which characters that stay glide to their new place, new
|
|
634
632
|
* ones slide or fade in and removed ones leave alongside their neighbours.
|
|
635
633
|
* In `'number'` mode every edit is formatted on the native side before a
|
|
636
634
|
* frame is drawn, with the caret kept in place, so there is never an
|
|
637
635
|
* unformatted frame and never a round trip through JS.
|
|
638
636
|
*
|
|
639
|
-
* Like a `TextInput`, it takes its width from its parent; `autoWidth`
|
|
640
|
-
*
|
|
637
|
+
* Like a `TextInput`, it takes its width from its parent; `autoWidth` sizes
|
|
638
|
+
* it to its content instead, and is on by default when the text reflows.
|
|
641
639
|
*/
|
|
642
640
|
export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
643
641
|
function NitroInput(
|
|
@@ -657,6 +655,12 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
657
655
|
signPlacement,
|
|
658
656
|
prefixAlign,
|
|
659
657
|
suffixAlign,
|
|
658
|
+
letterSpacing,
|
|
659
|
+
prefixSpacing,
|
|
660
|
+
suffixSpacing,
|
|
661
|
+
prefixOffset,
|
|
662
|
+
suffixOffset,
|
|
663
|
+
format,
|
|
660
664
|
placeholder,
|
|
661
665
|
placeholderTextColor,
|
|
662
666
|
duration,
|
|
@@ -704,7 +708,7 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
704
708
|
textAlignVertical,
|
|
705
709
|
scrollEnabled,
|
|
706
710
|
autoFocus,
|
|
707
|
-
|
|
711
|
+
transition,
|
|
708
712
|
autoWidth: autoWidthProp,
|
|
709
713
|
submitBehavior,
|
|
710
714
|
blurOnSubmit,
|
|
@@ -881,8 +885,10 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
881
885
|
// `NitroInput` turns it off so flexbox gives it the parent's width, the
|
|
882
886
|
// way a `TextInput` gets one.
|
|
883
887
|
const inferredAutoWidth = flat?.width == null && flat?.flex == null
|
|
888
|
+
const autoWidthSetting =
|
|
889
|
+
autoWidthProp ?? (transition === 'reflow' && !multiline ? 'auto' : false)
|
|
884
890
|
const autoWidth =
|
|
885
|
-
|
|
891
|
+
autoWidthSetting === 'auto' ? inferredAutoWidth : autoWidthSetting
|
|
886
892
|
const autoWidthRef = useRef(autoWidth)
|
|
887
893
|
autoWidthRef.current = autoWidth
|
|
888
894
|
// When the style pins both axes, the measured size is never used: `style`
|
|
@@ -1093,17 +1099,18 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
1093
1099
|
if (mode != null && mode !== 'text') {
|
|
1094
1100
|
warnIncompatible(`mode="${mode}"`)
|
|
1095
1101
|
}
|
|
1096
|
-
if (
|
|
1102
|
+
if (transition === 'reflow') warnIncompatible('transition="reflow"')
|
|
1097
1103
|
if (prefix) warnIncompatible('prefix')
|
|
1098
1104
|
if (suffix) warnIncompatible('suffix')
|
|
1099
1105
|
}
|
|
1100
|
-
const
|
|
1101
|
-
const
|
|
1106
|
+
const derived = format ? formatProps(format) : undefined
|
|
1107
|
+
const resolvedMode = isMultiline ? 'text' : (mode ?? (derived ? 'number' : 'text'))
|
|
1108
|
+
const reflows = !isMultiline && transition === 'reflow'
|
|
1102
1109
|
// The affixes are accessory views beside one line of text; a wrapping text
|
|
1103
1110
|
// view has no slot for them, so they go with the mode rather than being
|
|
1104
1111
|
// half-drawn on one platform and not the other.
|
|
1105
|
-
const resolvedPrefix = isMultiline ? '' : (prefix ?? '')
|
|
1106
|
-
const resolvedSuffix = isMultiline ? '' : (suffix ?? '')
|
|
1112
|
+
const resolvedPrefix = isMultiline ? '' : (prefix ?? derived?.prefix ?? '')
|
|
1113
|
+
const resolvedSuffix = isMultiline ? '' : (suffix ?? derived?.suffix ?? '')
|
|
1107
1114
|
// A new `maskNotations` literal each render must not re-set the native
|
|
1108
1115
|
// prop, so it is keyed on its contents. Always an array (empty = none):
|
|
1109
1116
|
// removing the prop would reach native as `null`, which Nitro's array
|
|
@@ -1115,7 +1122,7 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
1115
1122
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1116
1123
|
[notationsKey]
|
|
1117
1124
|
)
|
|
1118
|
-
const resolvedFractionDigits = fractionDigits ?? 2
|
|
1125
|
+
const resolvedFractionDigits = fractionDigits ?? derived?.fractionDigits ?? 2
|
|
1119
1126
|
const resolvedKeyboardType =
|
|
1120
1127
|
keyboardType ??
|
|
1121
1128
|
(inputMode != null
|
|
@@ -1216,18 +1223,23 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
1216
1223
|
text={value ?? initialText}
|
|
1217
1224
|
mostRecentEventCount={eventCountRef.current}
|
|
1218
1225
|
mode={resolvedMode}
|
|
1219
|
-
plain={!
|
|
1226
|
+
plain={!reflows}
|
|
1220
1227
|
fractionDigits={resolvedFractionDigits}
|
|
1221
1228
|
maxIntegerDigits={maxIntegerDigits ?? 15}
|
|
1222
|
-
groupingSeparator={groupingSeparator ?? ','}
|
|
1223
|
-
decimalSeparator={decimalSeparator ?? '.'}
|
|
1229
|
+
groupingSeparator={groupingSeparator ?? derived?.groupingSeparator ?? ','}
|
|
1230
|
+
decimalSeparator={decimalSeparator ?? derived?.decimalSeparator ?? '.'}
|
|
1224
1231
|
prefix={resolvedPrefix}
|
|
1225
1232
|
suffix={resolvedSuffix}
|
|
1226
1233
|
prefixFontSize={prefixFontSize ?? resolvedFontSize}
|
|
1227
1234
|
suffixFontSize={suffixFontSize ?? resolvedFontSize}
|
|
1228
|
-
signPlacement={signPlacement ?? 'beforeAffix'}
|
|
1235
|
+
signPlacement={signPlacement ?? derived?.signPlacement ?? 'beforeAffix'}
|
|
1229
1236
|
prefixAlign={prefixAlign ?? resolvedAffixAlign}
|
|
1230
1237
|
suffixAlign={suffixAlign ?? resolvedAffixAlign}
|
|
1238
|
+
letterSpacing={letterSpacing ?? 0}
|
|
1239
|
+
prefixSpacing={prefixSpacing ?? Infinity}
|
|
1240
|
+
suffixSpacing={suffixSpacing ?? Infinity}
|
|
1241
|
+
prefixOffset={prefixOffset ?? 0}
|
|
1242
|
+
suffixOffset={suffixOffset ?? 0}
|
|
1231
1243
|
placeholder={placeholder ?? ''}
|
|
1232
1244
|
placeholderColor={processedPlaceholderColor}
|
|
1233
1245
|
duration={duration ?? 400}
|