react-native-nitro-input 0.1.0 → 0.2.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 +305 -3
- package/NitroInput.podspec +4 -4
- package/README.md +378 -53
- package/android/CMakeLists.txt +5 -3
- 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 +222 -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 +1 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +471 -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 +38 -16
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +1741 -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 +59 -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 +1224 -0
- package/cpp/RollingEngine.hpp +468 -0
- package/cpp/SwiftNonCopyable.hpp +22 -0
- package/cpp/worklets/NitroInputWorkletsBridge.cpp +3 -3
- package/cpp/worklets/NitroInputWorkletsBridge.hpp +1 -1
- package/ios/{HybridMorphInputView.swift → HybridNitroInputView.swift} +1 -1
- package/ios/HybridNitroNumberView.swift +439 -0
- package/ios/NitroInputView.swift +69 -45
- package/ios/NitroNumberView.swift +1934 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
- package/lib/commonjs/src/NitroInput.js +21 -52
- package/lib/commonjs/src/NitroNumber.js +139 -0
- package/lib/commonjs/src/index.js +4 -3
- package/lib/commonjs/src/specs/NitroNumber.nitro.js +2 -0
- package/lib/commonjs/src/styleHelpers.js +36 -0
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
- package/lib/module/src/NitroInput.js +12 -43
- package/lib/module/src/NitroNumber.js +100 -0
- package/lib/module/src/index.js +1 -1
- package/lib/module/src/specs/NitroNumber.nitro.js +1 -0
- package/lib/module/src/styleHelpers.js +32 -0
- package/lib/typescript/src/NitroInput.d.ts +28 -21
- package/lib/typescript/src/NitroNumber.d.ts +211 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +9 -9
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +238 -0
- package/lib/typescript/src/styleHelpers.d.ts +3 -0
- package/nitro.json +10 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +4 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +20 -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++/JHybridNitroNumberViewSpec.cpp +536 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +156 -0
- package/nitrogen/generated/android/c++/JNitroNumberAffixAlign.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +61 -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++/views/JHybridNitroNumberViewStateUpdater.cpp +299 -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/HybridNitroNumberViewSpec.kt +363 -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 +24 -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/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 +25 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +248 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +23 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +432 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +414 -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/HybridNitroNumberViewSpec.swift +102 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +1243 -0
- package/nitrogen/generated/ios/swift/NitroNumberAffixAlign.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +44 -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/shared/c++/HybridNitroNumberViewSpec.cpp +115 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +175 -0
- package/nitrogen/generated/shared/c++/NitroNumberAffixAlign.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +80 -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++/views/HybridNitroNumberViewComponent.cpp +124 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +227 -0
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +55 -0
- package/package.json +15 -7
- package/src/NitroInput.tsx +37 -60
- package/src/NitroNumber.tsx +481 -0
- package/src/index.ts +20 -6
- package/src/specs/NitroInput.nitro.ts +9 -9
- package/src/specs/NitroNumber.nitro.ts +259 -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,227 @@
|
|
|
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<bool>> adjustsFontSizeToFit;
|
|
88
|
+
nitro::ReactProp<std::optional<double>> minimumFontScale;
|
|
89
|
+
nitro::ReactProp<std::optional<bool>> allowFontScaling;
|
|
90
|
+
nitro::ReactProp<std::optional<double>> maxFontSizeMultiplier;
|
|
91
|
+
nitro::ReactProp<std::optional<double>> fontWeight;
|
|
92
|
+
nitro::ReactProp<std::optional<std::string>> fontFamily;
|
|
93
|
+
nitro::ReactProp<std::optional<double>> color;
|
|
94
|
+
nitro::ReactProp<std::optional<NitroNumberTextAlign>> textAlign;
|
|
95
|
+
nitro::ReactProp<std::optional<bool>> rightToLeft;
|
|
96
|
+
nitro::ReactProp<std::optional<std::function<void(double /* width */, double /* height */)>>> onSizeChange;
|
|
97
|
+
nitro::ReactProp<std::optional<std::function<void()>>> onRevealEnd;
|
|
98
|
+
nitro::ReactProp<std::optional<std::function<void(double /* index */, double /* value */)>>> onRevealMilestone;
|
|
99
|
+
nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNitroNumberViewSpec>& /* ref */)>>> hybridRef;
|
|
100
|
+
|
|
101
|
+
[[nodiscard]]
|
|
102
|
+
bool hasSameProps(const HybridNitroNumberViewProps& other) const noexcept {
|
|
103
|
+
return value.hasSameValue(other.value) &&
|
|
104
|
+
fractionDigits.hasSameValue(other.fractionDigits) &&
|
|
105
|
+
minimumIntegerDigits.hasSameValue(other.minimumIntegerDigits) &&
|
|
106
|
+
groupingSeparator.hasSameValue(other.groupingSeparator) &&
|
|
107
|
+
decimalSeparator.hasSameValue(other.decimalSeparator) &&
|
|
108
|
+
prefix.hasSameValue(other.prefix) &&
|
|
109
|
+
suffix.hasSameValue(other.suffix) &&
|
|
110
|
+
duration.hasSameValue(other.duration) &&
|
|
111
|
+
easing.hasSameValue(other.easing) &&
|
|
112
|
+
bounce.hasSameValue(other.bounce) &&
|
|
113
|
+
stagger.hasSameValue(other.stagger) &&
|
|
114
|
+
transition.hasSameValue(other.transition) &&
|
|
115
|
+
flashUpColor.hasSameValue(other.flashUpColor) &&
|
|
116
|
+
flashDownColor.hasSameValue(other.flashDownColor) &&
|
|
117
|
+
flashDuration.hasSameValue(other.flashDuration) &&
|
|
118
|
+
popOnChange.hasSameValue(other.popOnChange) &&
|
|
119
|
+
rollDirection.hasSameValue(other.rollDirection) &&
|
|
120
|
+
revealState.hasSameValue(other.revealState) &&
|
|
121
|
+
revealStyle.hasSameValue(other.revealStyle) &&
|
|
122
|
+
revealDuration.hasSameValue(other.revealDuration) &&
|
|
123
|
+
revealBounce.hasSameValue(other.revealBounce) &&
|
|
124
|
+
revealGrow.hasSameValue(other.revealGrow) &&
|
|
125
|
+
revealStagger.hasSameValue(other.revealStagger) &&
|
|
126
|
+
revealMilestones.hasSameValue(other.revealMilestones) &&
|
|
127
|
+
revealMilestoneHold.hasSameValue(other.revealMilestoneHold) &&
|
|
128
|
+
loading.hasSameValue(other.loading) &&
|
|
129
|
+
shimmerColor.hasSameValue(other.shimmerColor) &&
|
|
130
|
+
shimmerDuration.hasSameValue(other.shimmerDuration) &&
|
|
131
|
+
fontSize.hasSameValue(other.fontSize) &&
|
|
132
|
+
prefixFontSize.hasSameValue(other.prefixFontSize) &&
|
|
133
|
+
suffixFontSize.hasSameValue(other.suffixFontSize) &&
|
|
134
|
+
affixAlign.hasSameValue(other.affixAlign) &&
|
|
135
|
+
prefixAlign.hasSameValue(other.prefixAlign) &&
|
|
136
|
+
suffixAlign.hasSameValue(other.suffixAlign) &&
|
|
137
|
+
adjustsFontSizeToFit.hasSameValue(other.adjustsFontSizeToFit) &&
|
|
138
|
+
minimumFontScale.hasSameValue(other.minimumFontScale) &&
|
|
139
|
+
allowFontScaling.hasSameValue(other.allowFontScaling) &&
|
|
140
|
+
maxFontSizeMultiplier.hasSameValue(other.maxFontSizeMultiplier) &&
|
|
141
|
+
fontWeight.hasSameValue(other.fontWeight) &&
|
|
142
|
+
fontFamily.hasSameValue(other.fontFamily) &&
|
|
143
|
+
color.hasSameValue(other.color) &&
|
|
144
|
+
textAlign.hasSameValue(other.textAlign) &&
|
|
145
|
+
rightToLeft.hasSameValue(other.rightToLeft) &&
|
|
146
|
+
onSizeChange.hasSameValue(other.onSizeChange) &&
|
|
147
|
+
onRevealEnd.hasSameValue(other.onRevealEnd) &&
|
|
148
|
+
onRevealMilestone.hasSameValue(other.onRevealMilestone) &&
|
|
149
|
+
hybridRef.hasSameValue(other.hybridRef);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[[nodiscard]]
|
|
153
|
+
bool hasAnyProvidedProps() const noexcept {
|
|
154
|
+
return value.isProvided() ||
|
|
155
|
+
fractionDigits.isProvided() ||
|
|
156
|
+
minimumIntegerDigits.isProvided() ||
|
|
157
|
+
groupingSeparator.isProvided() ||
|
|
158
|
+
decimalSeparator.isProvided() ||
|
|
159
|
+
prefix.isProvided() ||
|
|
160
|
+
suffix.isProvided() ||
|
|
161
|
+
duration.isProvided() ||
|
|
162
|
+
easing.isProvided() ||
|
|
163
|
+
bounce.isProvided() ||
|
|
164
|
+
stagger.isProvided() ||
|
|
165
|
+
transition.isProvided() ||
|
|
166
|
+
flashUpColor.isProvided() ||
|
|
167
|
+
flashDownColor.isProvided() ||
|
|
168
|
+
flashDuration.isProvided() ||
|
|
169
|
+
popOnChange.isProvided() ||
|
|
170
|
+
rollDirection.isProvided() ||
|
|
171
|
+
revealState.isProvided() ||
|
|
172
|
+
revealStyle.isProvided() ||
|
|
173
|
+
revealDuration.isProvided() ||
|
|
174
|
+
revealBounce.isProvided() ||
|
|
175
|
+
revealGrow.isProvided() ||
|
|
176
|
+
revealStagger.isProvided() ||
|
|
177
|
+
revealMilestones.isProvided() ||
|
|
178
|
+
revealMilestoneHold.isProvided() ||
|
|
179
|
+
loading.isProvided() ||
|
|
180
|
+
shimmerColor.isProvided() ||
|
|
181
|
+
shimmerDuration.isProvided() ||
|
|
182
|
+
fontSize.isProvided() ||
|
|
183
|
+
prefixFontSize.isProvided() ||
|
|
184
|
+
suffixFontSize.isProvided() ||
|
|
185
|
+
affixAlign.isProvided() ||
|
|
186
|
+
prefixAlign.isProvided() ||
|
|
187
|
+
suffixAlign.isProvided() ||
|
|
188
|
+
adjustsFontSizeToFit.isProvided() ||
|
|
189
|
+
minimumFontScale.isProvided() ||
|
|
190
|
+
allowFontScaling.isProvided() ||
|
|
191
|
+
maxFontSizeMultiplier.isProvided() ||
|
|
192
|
+
fontWeight.isProvided() ||
|
|
193
|
+
fontFamily.isProvided() ||
|
|
194
|
+
color.isProvided() ||
|
|
195
|
+
textAlign.isProvided() ||
|
|
196
|
+
rightToLeft.isProvided() ||
|
|
197
|
+
onSizeChange.isProvided() ||
|
|
198
|
+
onRevealEnd.isProvided() ||
|
|
199
|
+
onRevealMilestone.isProvided() ||
|
|
200
|
+
hybridRef.isProvided();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private:
|
|
204
|
+
static bool filterObjectKeys(const std::string& propName);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* State for the "NitroNumberView" View.
|
|
209
|
+
*/
|
|
210
|
+
using HybridNitroNumberViewState = nitro::ViewPropsHolderState<HybridNitroNumberViewProps>;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The Shadow Node for the "NitroNumberView" View.
|
|
214
|
+
*/
|
|
215
|
+
using HybridNitroNumberViewShadowNode = react::ConcreteViewShadowNode<HybridNitroNumberViewComponentName /* "HybridNitroNumberView" */,
|
|
216
|
+
HybridNitroNumberViewProps /* custom props */,
|
|
217
|
+
react::ViewEventEmitter /* default */,
|
|
218
|
+
HybridNitroNumberViewState /* custom state */>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The Component Descriptor for the "NitroNumberView" View.
|
|
222
|
+
*/
|
|
223
|
+
using HybridNitroNumberViewComponentDescriptor = nitro::ViewComponentDescriptor<HybridNitroNumberViewShadowNode>;
|
|
224
|
+
|
|
225
|
+
/* The actual view for "NitroNumberView" needs to be implemented in platform-specific code. */
|
|
226
|
+
|
|
227
|
+
} // namespace margelo::nitro::nitroinput::views
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
"adjustsFontSizeToFit": true,
|
|
42
|
+
"minimumFontScale": true,
|
|
43
|
+
"allowFontScaling": true,
|
|
44
|
+
"maxFontSizeMultiplier": true,
|
|
45
|
+
"fontWeight": true,
|
|
46
|
+
"fontFamily": true,
|
|
47
|
+
"color": true,
|
|
48
|
+
"textAlign": true,
|
|
49
|
+
"rightToLeft": true,
|
|
50
|
+
"onSizeChange": true,
|
|
51
|
+
"onRevealEnd": true,
|
|
52
|
+
"onRevealMilestone": true,
|
|
53
|
+
"hybridRef": true
|
|
54
|
+
}
|
|
55
|
+
}
|
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.2.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",
|
|
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,7 @@ import {
|
|
|
52
51
|
type NitroInputSelection,
|
|
53
52
|
type NitroInputTransform,
|
|
54
53
|
} from './worklets'
|
|
54
|
+
import { toNumericWeight, toProcessedColor } from './styleHelpers'
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* React Native's registry of mounted text inputs. `TextInput.State` only
|
|
@@ -354,7 +354,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
354
354
|
* Where a negative amount's sign sits relative to `prefix`. `'beforeAffix'`
|
|
355
355
|
* (the default) reads `-$1,234.56`; `'afterAffix'` reads `$-1,234.56`, which
|
|
356
356
|
* suits a symbol styled as an ornament rather than read as part of the
|
|
357
|
-
* number. Only the
|
|
357
|
+
* number. Only the reflow honours it - a plain field's affixes are accessory
|
|
358
358
|
* views outside the text, so it is always `'afterAffix'`.
|
|
359
359
|
*/
|
|
360
360
|
signPlacement?: NitroInputSignPlacement
|
|
@@ -362,13 +362,13 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
362
362
|
prefixAlign?: NitroInputAffixAlign
|
|
363
363
|
/** Alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
364
364
|
suffixAlign?: NitroInputAffixAlign
|
|
365
|
-
/** Shown while the field is empty and
|
|
365
|
+
/** Shown while the field is empty and reflowed away by the first character. In `'number'` mode `'0'` reads well. */
|
|
366
366
|
placeholder?: string
|
|
367
367
|
/** Color of the placeholder. Defaults to the platform placeholder color. */
|
|
368
368
|
placeholderTextColor?: ColorValue
|
|
369
|
-
/** Duration in ms of the
|
|
369
|
+
/** Duration in ms of the reflow played on every change. `0` snaps. Default: `400`. */
|
|
370
370
|
duration?: number
|
|
371
|
-
/** Timing curve of the
|
|
371
|
+
/** Timing curve of the reflow. Default: `'expo'` (Torph's `cubic-bezier(0.19, 1, 0.22, 1)`). */
|
|
372
372
|
easing?: NitroInputEasing
|
|
373
373
|
/** Overshoot of the `'spring'` easing, `0`–`1`. Default: `0.15`. */
|
|
374
374
|
bounce?: number
|
|
@@ -385,7 +385,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
385
385
|
* line occupies rather than extra leading. Omit to use the font's own.
|
|
386
386
|
*
|
|
387
387
|
* Unlike `TextInput`, a line height *tighter* than the font is centred
|
|
388
|
-
* correctly too, and it applies to single-line and
|
|
388
|
+
* correctly too, and it applies to single-line and reflowing fields, not only
|
|
389
389
|
* wrapped ones.
|
|
390
390
|
*/
|
|
391
391
|
lineHeight?: number
|
|
@@ -433,8 +433,8 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
433
433
|
*
|
|
434
434
|
* A multiline field is always drawn by the system view and is always
|
|
435
435
|
* `'text'` mode: the glyph engine lays one run out on one baseline, so it
|
|
436
|
-
* cannot
|
|
437
|
-
* `
|
|
436
|
+
* cannot reflow wrapped text, and an amount or a mask is a single-line idea.
|
|
437
|
+
* `transition="reflow"`, `mode="number"`, `mode="mask"` and the `prefix` / `suffix`
|
|
438
438
|
* affixes are ignored alongside it, with one warning each in development.
|
|
439
439
|
* The return key inserts a line break unless `submitBehavior` says otherwise.
|
|
440
440
|
*/
|
|
@@ -489,20 +489,22 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
489
489
|
/** The caret/selection to apply, in code points. */
|
|
490
490
|
selection?: { start: number; end?: number }
|
|
491
491
|
/**
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
492
|
+
* How the text changes. `'none'` (the default) draws it the instant it
|
|
493
|
+
* changes: this is a text field first, and a `TextInput` does not animate
|
|
494
|
+
* its characters. `'reflow'` runs the glyph engine, so characters that stay
|
|
495
|
+
* glide to their new place, new ones slide or fade in and removed ones leave
|
|
496
|
+
* alongside their neighbours, which is what an amount field wants. A
|
|
497
|
+
* multiline field is always `'none'`.
|
|
496
498
|
*/
|
|
497
|
-
|
|
499
|
+
transition?: NitroInputTransition
|
|
498
500
|
/**
|
|
499
501
|
* Whether the field sizes itself to its content.
|
|
500
502
|
*
|
|
501
|
-
* `false`
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
503
|
+
* `false` takes no width of its own, so flexbox stretches it to its parent
|
|
504
|
+
* the way a `TextInput` is stretched — that is what makes this a drop-in.
|
|
505
|
+
* `true` always sizes to content. `'auto'` infers it: on unless `style`
|
|
506
|
+
* gives a `width` or `flex`, which is what lets an amount grow as digits
|
|
507
|
+
* arrive. Default: `'auto'` with `transition="reflow"`, else `false`.
|
|
506
508
|
*/
|
|
507
509
|
autoWidth?: boolean | 'auto'
|
|
508
510
|
/** `'text'` mode: most characters accepted. Default: unlimited. */
|
|
@@ -558,7 +560,7 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
558
560
|
export interface NitroInputHandle {
|
|
559
561
|
focus(): void
|
|
560
562
|
blur(): void
|
|
561
|
-
/** Empties the field,
|
|
563
|
+
/** Empties the field, reflowing the characters away. */
|
|
562
564
|
clear(): void
|
|
563
565
|
/** Replaces the text (formatted in `'number'` mode), caret at the end. */
|
|
564
566
|
setText(text: string): void
|
|
@@ -575,39 +577,6 @@ export interface NitroInputHandle {
|
|
|
575
577
|
readonly native: NitroInputRef | null
|
|
576
578
|
}
|
|
577
579
|
|
|
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
580
|
interface Size {
|
|
612
581
|
width: number
|
|
613
582
|
height: number
|
|
@@ -625,19 +594,25 @@ function warnIncompatible(what: string): void {
|
|
|
625
594
|
)
|
|
626
595
|
}
|
|
627
596
|
|
|
597
|
+
/**
|
|
598
|
+
* How a `NitroInput`'s text changes: drawn at once (`'none'`), or reflowed by
|
|
599
|
+
* the glyph engine (`'reflow'`).
|
|
600
|
+
*/
|
|
601
|
+
export type NitroInputTransition = 'none' | 'reflow'
|
|
602
|
+
|
|
628
603
|
/**
|
|
629
604
|
* A native text input: a system field (`UITextField` / `EditText`) that owns
|
|
630
605
|
* the keyboard, editing, selection, paste and accessibility, with native
|
|
631
606
|
* formatting (`mode="number"`), native masking (`mode="mask"`), an outlined
|
|
632
607
|
* or filled frame with a floating label, and optionally the glyph engine
|
|
633
|
-
* (`
|
|
608
|
+
* (`transition="reflow"`), under which characters that stay glide to their new place, new
|
|
634
609
|
* ones slide or fade in and removed ones leave alongside their neighbours.
|
|
635
610
|
* In `'number'` mode every edit is formatted on the native side before a
|
|
636
611
|
* frame is drawn, with the caret kept in place, so there is never an
|
|
637
612
|
* unformatted frame and never a round trip through JS.
|
|
638
613
|
*
|
|
639
|
-
* Like a `TextInput`, it takes its width from its parent; `autoWidth`
|
|
640
|
-
*
|
|
614
|
+
* Like a `TextInput`, it takes its width from its parent; `autoWidth` sizes
|
|
615
|
+
* it to its content instead, and is on by default when the text reflows.
|
|
641
616
|
*/
|
|
642
617
|
export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
643
618
|
function NitroInput(
|
|
@@ -704,7 +679,7 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
704
679
|
textAlignVertical,
|
|
705
680
|
scrollEnabled,
|
|
706
681
|
autoFocus,
|
|
707
|
-
|
|
682
|
+
transition,
|
|
708
683
|
autoWidth: autoWidthProp,
|
|
709
684
|
submitBehavior,
|
|
710
685
|
blurOnSubmit,
|
|
@@ -881,8 +856,10 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
881
856
|
// `NitroInput` turns it off so flexbox gives it the parent's width, the
|
|
882
857
|
// way a `TextInput` gets one.
|
|
883
858
|
const inferredAutoWidth = flat?.width == null && flat?.flex == null
|
|
859
|
+
const autoWidthSetting =
|
|
860
|
+
autoWidthProp ?? (transition === 'reflow' && !multiline ? 'auto' : false)
|
|
884
861
|
const autoWidth =
|
|
885
|
-
|
|
862
|
+
autoWidthSetting === 'auto' ? inferredAutoWidth : autoWidthSetting
|
|
886
863
|
const autoWidthRef = useRef(autoWidth)
|
|
887
864
|
autoWidthRef.current = autoWidth
|
|
888
865
|
// When the style pins both axes, the measured size is never used: `style`
|
|
@@ -1093,12 +1070,12 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
1093
1070
|
if (mode != null && mode !== 'text') {
|
|
1094
1071
|
warnIncompatible(`mode="${mode}"`)
|
|
1095
1072
|
}
|
|
1096
|
-
if (
|
|
1073
|
+
if (transition === 'reflow') warnIncompatible('transition="reflow"')
|
|
1097
1074
|
if (prefix) warnIncompatible('prefix')
|
|
1098
1075
|
if (suffix) warnIncompatible('suffix')
|
|
1099
1076
|
}
|
|
1100
1077
|
const resolvedMode = isMultiline ? 'text' : (mode ?? 'text')
|
|
1101
|
-
const
|
|
1078
|
+
const reflows = !isMultiline && transition === 'reflow'
|
|
1102
1079
|
// The affixes are accessory views beside one line of text; a wrapping text
|
|
1103
1080
|
// view has no slot for them, so they go with the mode rather than being
|
|
1104
1081
|
// half-drawn on one platform and not the other.
|
|
@@ -1216,7 +1193,7 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
1216
1193
|
text={value ?? initialText}
|
|
1217
1194
|
mostRecentEventCount={eventCountRef.current}
|
|
1218
1195
|
mode={resolvedMode}
|
|
1219
|
-
plain={!
|
|
1196
|
+
plain={!reflows}
|
|
1220
1197
|
fractionDigits={resolvedFractionDigits}
|
|
1221
1198
|
maxIntegerDigits={maxIntegerDigits ?? 15}
|
|
1222
1199
|
groupingSeparator={groupingSeparator ?? ','}
|