react-native-nitro-input 0.3.1 → 0.3.3
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 +114 -0
- package/README.md +75 -3
- package/android/src/main/cpp/JMaskEngine.cpp +45 -0
- package/android/src/main/cpp/JMaskEngine.hpp +9 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +49 -4
- package/android/src/main/java/com/margelo/nitro/nitroinput/MaskEngine.kt +16 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +266 -8
- package/android/src/main/java/com/margelo/nitro/nitroinput/UnmountHandoffs.kt +57 -0
- package/cpp/MaskEngine.cpp +294 -33
- package/cpp/MaskEngine.hpp +68 -0
- package/ios/HybridNitroInputView.swift +37 -4
- package/ios/NitroInputCommands.mm +10 -0
- package/ios/NitroInputView.swift +474 -20
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
- package/lib/commonjs/src/NitroInput.js +116 -15
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
- package/lib/module/src/NitroInput.js +117 -16
- package/lib/typescript/src/NitroInput.d.ts +55 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +124 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +17 -0
- package/nitrogen/generated/android/c++/JNitroInputCharacterMapping.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputMaskAffinity.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroInputTextCase.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +40 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputCharacterMapping.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputMaskAffinity.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputTextCase.kt +24 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +25 -11
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +68 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +48 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +9 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +111 -0
- package/nitrogen/generated/ios/swift/NitroInputCharacterMapping.swift +34 -0
- package/nitrogen/generated/ios/swift/NitroInputMaskAffinity.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroInputTextCase.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +17 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +26 -0
- package/nitrogen/generated/shared/c++/NitroInputCharacterMapping.hpp +87 -0
- package/nitrogen/generated/shared/c++/NitroInputMaskAffinity.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroInputTextCase.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +16 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +27 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
- package/package.json +2 -2
- package/src/NitroInput.tsx +190 -11
- package/src/index.ts +3 -0
- package/src/specs/NitroInput.nitro.ts +68 -0
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
namespace margelo::nitro::nitroinput { enum class NitroInputMode; }
|
|
18
18
|
// Forward declaration of `NitroInputNotation` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::nitroinput { struct NitroInputNotation; }
|
|
20
|
+
// Forward declaration of `NitroInputMaskAffinity` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::nitroinput { enum class NitroInputMaskAffinity; }
|
|
22
|
+
// Forward declaration of `NitroInputTextCase` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitroinput { enum class NitroInputTextCase; }
|
|
24
|
+
// Forward declaration of `NitroInputCharacterMapping` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::nitroinput { struct NitroInputCharacterMapping; }
|
|
20
26
|
// Forward declaration of `NitroInputVariant` to properly resolve imports.
|
|
21
27
|
namespace margelo::nitro::nitroinput { enum class NitroInputVariant; }
|
|
22
28
|
// Forward declaration of `NitroInputLabelBehavior` to properly resolve imports.
|
|
@@ -48,6 +54,9 @@ namespace margelo::nitro::nitroinput { enum class NitroInputKeyboardAppearance;
|
|
|
48
54
|
#include "NitroInputMode.hpp"
|
|
49
55
|
#include "NitroInputNotation.hpp"
|
|
50
56
|
#include <vector>
|
|
57
|
+
#include "NitroInputMaskAffinity.hpp"
|
|
58
|
+
#include "NitroInputTextCase.hpp"
|
|
59
|
+
#include "NitroInputCharacterMapping.hpp"
|
|
51
60
|
#include "NitroInputVariant.hpp"
|
|
52
61
|
#include "NitroInputLabelBehavior.hpp"
|
|
53
62
|
#include "NitroInputSignPlacement.hpp"
|
|
@@ -111,6 +120,18 @@ namespace margelo::nitro::nitroinput {
|
|
|
111
120
|
virtual void setMaskAutocomplete(bool maskAutocomplete) = 0;
|
|
112
121
|
virtual bool getMaskAutoSkip() = 0;
|
|
113
122
|
virtual void setMaskAutoSkip(bool maskAutoSkip) = 0;
|
|
123
|
+
virtual std::vector<std::string> getMaskAffinityFormats() = 0;
|
|
124
|
+
virtual void setMaskAffinityFormats(const std::vector<std::string>& maskAffinityFormats) = 0;
|
|
125
|
+
virtual NitroInputMaskAffinity getMaskAffinityStrategy() = 0;
|
|
126
|
+
virtual void setMaskAffinityStrategy(NitroInputMaskAffinity maskAffinityStrategy) = 0;
|
|
127
|
+
virtual NitroInputTextCase getMaskTextCase() = 0;
|
|
128
|
+
virtual void setMaskTextCase(NitroInputTextCase maskTextCase) = 0;
|
|
129
|
+
virtual std::vector<NitroInputCharacterMapping> getMaskCharacterMap() = 0;
|
|
130
|
+
virtual void setMaskCharacterMap(const std::vector<NitroInputCharacterMapping>& maskCharacterMap) = 0;
|
|
131
|
+
virtual std::string getMaskSlotPlaceholder() = 0;
|
|
132
|
+
virtual void setMaskSlotPlaceholder(const std::string& maskSlotPlaceholder) = 0;
|
|
133
|
+
virtual bool getKeepPlaceholder() = 0;
|
|
134
|
+
virtual void setKeepPlaceholder(bool keepPlaceholder) = 0;
|
|
114
135
|
virtual std::string getGroupingSeparator() = 0;
|
|
115
136
|
virtual void setGroupingSeparator(const std::string& groupingSeparator) = 0;
|
|
116
137
|
virtual std::string getDecimalSeparator() = 0;
|
|
@@ -241,6 +262,10 @@ namespace margelo::nitro::nitroinput {
|
|
|
241
262
|
virtual void setSelectTextOnFocus(bool selectTextOnFocus) = 0;
|
|
242
263
|
virtual bool getClearTextOnFocus() = 0;
|
|
243
264
|
virtual void setClearTextOnFocus(bool clearTextOnFocus) = 0;
|
|
265
|
+
virtual double getKeyboardHandoffMs() = 0;
|
|
266
|
+
virtual void setKeyboardHandoffMs(double keyboardHandoffMs) = 0;
|
|
267
|
+
virtual bool getReturnKeyBar() = 0;
|
|
268
|
+
virtual void setReturnKeyBar(bool returnKeyBar) = 0;
|
|
244
269
|
virtual bool getContextMenuHidden() = 0;
|
|
245
270
|
virtual void setContextMenuHidden(bool contextMenuHidden) = 0;
|
|
246
271
|
virtual bool getSpellCheck() = 0;
|
|
@@ -297,6 +322,7 @@ namespace margelo::nitro::nitroinput {
|
|
|
297
322
|
virtual double getValue() = 0;
|
|
298
323
|
virtual bool isFocused() = 0;
|
|
299
324
|
virtual void setSelection(double start, double end) = 0;
|
|
325
|
+
virtual void prepareForUnmount() = 0;
|
|
300
326
|
|
|
301
327
|
protected:
|
|
302
328
|
// Hybrid Setup
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroInputCharacterMapping.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
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitroinput {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (NitroInputCharacterMapping).
|
|
39
|
+
*/
|
|
40
|
+
struct NitroInputCharacterMapping final {
|
|
41
|
+
public:
|
|
42
|
+
std::string from SWIFT_PRIVATE;
|
|
43
|
+
std::string to SWIFT_PRIVATE;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
NitroInputCharacterMapping() = default;
|
|
47
|
+
explicit NitroInputCharacterMapping(std::string from, std::string to): from(from), to(to) {}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
friend bool operator==(const NitroInputCharacterMapping& lhs, const NitroInputCharacterMapping& rhs) = default;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace margelo::nitro::nitroinput
|
|
54
|
+
|
|
55
|
+
namespace margelo::nitro {
|
|
56
|
+
|
|
57
|
+
// C++ NitroInputCharacterMapping <> JS NitroInputCharacterMapping (object)
|
|
58
|
+
template <>
|
|
59
|
+
struct JSIConverter<margelo::nitro::nitroinput::NitroInputCharacterMapping> final {
|
|
60
|
+
static inline margelo::nitro::nitroinput::NitroInputCharacterMapping fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
61
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
62
|
+
return margelo::nitro::nitroinput::NitroInputCharacterMapping(
|
|
63
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "from"))),
|
|
64
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "to")))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroinput::NitroInputCharacterMapping& arg) {
|
|
68
|
+
jsi::Object obj(runtime);
|
|
69
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "from"), JSIConverter<std::string>::toJSI(runtime, arg.from));
|
|
70
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "to"), JSIConverter<std::string>::toJSI(runtime, arg.to));
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
74
|
+
if (!value.isObject()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
jsi::Object obj = value.getObject(runtime);
|
|
78
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "from")))) return false;
|
|
82
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "to")))) return false;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroInputMaskAffinity.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
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitroinput {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (NitroInputMaskAffinity).
|
|
30
|
+
*/
|
|
31
|
+
enum class NitroInputMaskAffinity {
|
|
32
|
+
WHOLESTRING SWIFT_NAME(wholestring) = 0,
|
|
33
|
+
PREFIX SWIFT_NAME(prefix) = 1,
|
|
34
|
+
CAPACITY SWIFT_NAME(capacity) = 2,
|
|
35
|
+
EXTRACTEDVALUECAPACITY SWIFT_NAME(extractedvaluecapacity) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::nitroinput
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ NitroInputMaskAffinity <> JS NitroInputMaskAffinity (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::nitroinput::NitroInputMaskAffinity> final {
|
|
45
|
+
static inline margelo::nitro::nitroinput::NitroInputMaskAffinity fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("wholeString"): return margelo::nitro::nitroinput::NitroInputMaskAffinity::WHOLESTRING;
|
|
49
|
+
case hashString("prefix"): return margelo::nitro::nitroinput::NitroInputMaskAffinity::PREFIX;
|
|
50
|
+
case hashString("capacity"): return margelo::nitro::nitroinput::NitroInputMaskAffinity::CAPACITY;
|
|
51
|
+
case hashString("extractedValueCapacity"): return margelo::nitro::nitroinput::NitroInputMaskAffinity::EXTRACTEDVALUECAPACITY;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum NitroInputMaskAffinity - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitroinput::NitroInputMaskAffinity arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::nitroinput::NitroInputMaskAffinity::WHOLESTRING: return JSIConverter<std::string>::toJSI(runtime, "wholeString");
|
|
59
|
+
case margelo::nitro::nitroinput::NitroInputMaskAffinity::PREFIX: return JSIConverter<std::string>::toJSI(runtime, "prefix");
|
|
60
|
+
case margelo::nitro::nitroinput::NitroInputMaskAffinity::CAPACITY: return JSIConverter<std::string>::toJSI(runtime, "capacity");
|
|
61
|
+
case margelo::nitro::nitroinput::NitroInputMaskAffinity::EXTRACTEDVALUECAPACITY: return JSIConverter<std::string>::toJSI(runtime, "extractedValueCapacity");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert NitroInputMaskAffinity to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("wholeString"):
|
|
74
|
+
case hashString("prefix"):
|
|
75
|
+
case hashString("capacity"):
|
|
76
|
+
case hashString("extractedValueCapacity"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroInputTextCase.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
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitroinput {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (NitroInputTextCase).
|
|
30
|
+
*/
|
|
31
|
+
enum class NitroInputTextCase {
|
|
32
|
+
NONE SWIFT_NAME(none) = 0,
|
|
33
|
+
UPPER SWIFT_NAME(upper) = 1,
|
|
34
|
+
LOWER SWIFT_NAME(lower) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::nitroinput
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ NitroInputTextCase <> JS NitroInputTextCase (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::nitroinput::NitroInputTextCase> final {
|
|
44
|
+
static inline margelo::nitro::nitroinput::NitroInputTextCase fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("none"): return margelo::nitro::nitroinput::NitroInputTextCase::NONE;
|
|
48
|
+
case hashString("upper"): return margelo::nitro::nitroinput::NitroInputTextCase::UPPER;
|
|
49
|
+
case hashString("lower"): return margelo::nitro::nitroinput::NitroInputTextCase::LOWER;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum NitroInputTextCase - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitroinput::NitroInputTextCase arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::nitroinput::NitroInputTextCase::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
|
|
57
|
+
case margelo::nitro::nitroinput::NitroInputTextCase::UPPER: return JSIConverter<std::string>::toJSI(runtime, "upper");
|
|
58
|
+
case margelo::nitro::nitroinput::NitroInputTextCase::LOWER: return JSIConverter<std::string>::toJSI(runtime, "lower");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert NitroInputTextCase to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("none"):
|
|
71
|
+
case hashString("upper"):
|
|
72
|
+
case hashString("lower"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -30,6 +30,12 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
30
30
|
maskNotations(nitro::ReactProp<std::vector<NitroInputNotation>>::fromRawValue("NitroInputView", "maskNotations", rawProps, sourceProps.maskNotations)),
|
|
31
31
|
maskAutocomplete(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "maskAutocomplete", rawProps, sourceProps.maskAutocomplete)),
|
|
32
32
|
maskAutoSkip(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "maskAutoSkip", rawProps, sourceProps.maskAutoSkip)),
|
|
33
|
+
maskAffinityFormats(nitro::ReactProp<std::vector<std::string>>::fromRawValue("NitroInputView", "maskAffinityFormats", rawProps, sourceProps.maskAffinityFormats)),
|
|
34
|
+
maskAffinityStrategy(nitro::ReactProp<NitroInputMaskAffinity>::fromRawValue("NitroInputView", "maskAffinityStrategy", rawProps, sourceProps.maskAffinityStrategy)),
|
|
35
|
+
maskTextCase(nitro::ReactProp<NitroInputTextCase>::fromRawValue("NitroInputView", "maskTextCase", rawProps, sourceProps.maskTextCase)),
|
|
36
|
+
maskCharacterMap(nitro::ReactProp<std::vector<NitroInputCharacterMapping>>::fromRawValue("NitroInputView", "maskCharacterMap", rawProps, sourceProps.maskCharacterMap)),
|
|
37
|
+
maskSlotPlaceholder(nitro::ReactProp<std::string>::fromRawValue("NitroInputView", "maskSlotPlaceholder", rawProps, sourceProps.maskSlotPlaceholder)),
|
|
38
|
+
keepPlaceholder(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "keepPlaceholder", rawProps, sourceProps.keepPlaceholder)),
|
|
33
39
|
groupingSeparator(nitro::ReactProp<std::string>::fromRawValue("NitroInputView", "groupingSeparator", rawProps, sourceProps.groupingSeparator)),
|
|
34
40
|
decimalSeparator(nitro::ReactProp<std::string>::fromRawValue("NitroInputView", "decimalSeparator", rawProps, sourceProps.decimalSeparator)),
|
|
35
41
|
variant(nitro::ReactProp<NitroInputVariant>::fromRawValue("NitroInputView", "variant", rawProps, sourceProps.variant)),
|
|
@@ -95,6 +101,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
95
101
|
showSoftInputOnFocus(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "showSoftInputOnFocus", rawProps, sourceProps.showSoftInputOnFocus)),
|
|
96
102
|
selectTextOnFocus(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "selectTextOnFocus", rawProps, sourceProps.selectTextOnFocus)),
|
|
97
103
|
clearTextOnFocus(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "clearTextOnFocus", rawProps, sourceProps.clearTextOnFocus)),
|
|
104
|
+
keyboardHandoffMs(nitro::ReactProp<double>::fromRawValue("NitroInputView", "keyboardHandoffMs", rawProps, sourceProps.keyboardHandoffMs)),
|
|
105
|
+
returnKeyBar(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "returnKeyBar", rawProps, sourceProps.returnKeyBar)),
|
|
98
106
|
contextMenuHidden(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "contextMenuHidden", rawProps, sourceProps.contextMenuHidden)),
|
|
99
107
|
spellCheck(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "spellCheck", rawProps, sourceProps.spellCheck)),
|
|
100
108
|
selectionStart(nitro::ReactProp<double>::fromRawValue("NitroInputView", "selectionStart", rawProps, sourceProps.selectionStart)),
|
|
@@ -131,6 +139,12 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
131
139
|
case hashString("maskNotations"): return true;
|
|
132
140
|
case hashString("maskAutocomplete"): return true;
|
|
133
141
|
case hashString("maskAutoSkip"): return true;
|
|
142
|
+
case hashString("maskAffinityFormats"): return true;
|
|
143
|
+
case hashString("maskAffinityStrategy"): return true;
|
|
144
|
+
case hashString("maskTextCase"): return true;
|
|
145
|
+
case hashString("maskCharacterMap"): return true;
|
|
146
|
+
case hashString("maskSlotPlaceholder"): return true;
|
|
147
|
+
case hashString("keepPlaceholder"): return true;
|
|
134
148
|
case hashString("groupingSeparator"): return true;
|
|
135
149
|
case hashString("decimalSeparator"): return true;
|
|
136
150
|
case hashString("variant"): return true;
|
|
@@ -196,6 +210,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
196
210
|
case hashString("showSoftInputOnFocus"): return true;
|
|
197
211
|
case hashString("selectTextOnFocus"): return true;
|
|
198
212
|
case hashString("clearTextOnFocus"): return true;
|
|
213
|
+
case hashString("keyboardHandoffMs"): return true;
|
|
214
|
+
case hashString("returnKeyBar"): return true;
|
|
199
215
|
case hashString("contextMenuHidden"): return true;
|
|
200
216
|
case hashString("spellCheck"): return true;
|
|
201
217
|
case hashString("selectionStart"): return true;
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
#include "NitroInputMode.hpp"
|
|
22
22
|
#include "NitroInputNotation.hpp"
|
|
23
23
|
#include <vector>
|
|
24
|
+
#include "NitroInputMaskAffinity.hpp"
|
|
25
|
+
#include "NitroInputTextCase.hpp"
|
|
26
|
+
#include "NitroInputCharacterMapping.hpp"
|
|
24
27
|
#include "NitroInputVariant.hpp"
|
|
25
28
|
#include "NitroInputLabelBehavior.hpp"
|
|
26
29
|
#include "NitroInputSignPlacement.hpp"
|
|
@@ -69,6 +72,12 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
69
72
|
nitro::ReactProp<std::vector<NitroInputNotation>> maskNotations;
|
|
70
73
|
nitro::ReactProp<bool> maskAutocomplete;
|
|
71
74
|
nitro::ReactProp<bool> maskAutoSkip;
|
|
75
|
+
nitro::ReactProp<std::vector<std::string>> maskAffinityFormats;
|
|
76
|
+
nitro::ReactProp<NitroInputMaskAffinity> maskAffinityStrategy;
|
|
77
|
+
nitro::ReactProp<NitroInputTextCase> maskTextCase;
|
|
78
|
+
nitro::ReactProp<std::vector<NitroInputCharacterMapping>> maskCharacterMap;
|
|
79
|
+
nitro::ReactProp<std::string> maskSlotPlaceholder;
|
|
80
|
+
nitro::ReactProp<bool> keepPlaceholder;
|
|
72
81
|
nitro::ReactProp<std::string> groupingSeparator;
|
|
73
82
|
nitro::ReactProp<std::string> decimalSeparator;
|
|
74
83
|
nitro::ReactProp<NitroInputVariant> variant;
|
|
@@ -134,6 +143,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
134
143
|
nitro::ReactProp<bool> showSoftInputOnFocus;
|
|
135
144
|
nitro::ReactProp<bool> selectTextOnFocus;
|
|
136
145
|
nitro::ReactProp<bool> clearTextOnFocus;
|
|
146
|
+
nitro::ReactProp<double> keyboardHandoffMs;
|
|
147
|
+
nitro::ReactProp<bool> returnKeyBar;
|
|
137
148
|
nitro::ReactProp<bool> contextMenuHidden;
|
|
138
149
|
nitro::ReactProp<bool> spellCheck;
|
|
139
150
|
nitro::ReactProp<double> selectionStart;
|
|
@@ -170,6 +181,12 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
170
181
|
maskNotations.hasSameValue(other.maskNotations) &&
|
|
171
182
|
maskAutocomplete.hasSameValue(other.maskAutocomplete) &&
|
|
172
183
|
maskAutoSkip.hasSameValue(other.maskAutoSkip) &&
|
|
184
|
+
maskAffinityFormats.hasSameValue(other.maskAffinityFormats) &&
|
|
185
|
+
maskAffinityStrategy.hasSameValue(other.maskAffinityStrategy) &&
|
|
186
|
+
maskTextCase.hasSameValue(other.maskTextCase) &&
|
|
187
|
+
maskCharacterMap.hasSameValue(other.maskCharacterMap) &&
|
|
188
|
+
maskSlotPlaceholder.hasSameValue(other.maskSlotPlaceholder) &&
|
|
189
|
+
keepPlaceholder.hasSameValue(other.keepPlaceholder) &&
|
|
173
190
|
groupingSeparator.hasSameValue(other.groupingSeparator) &&
|
|
174
191
|
decimalSeparator.hasSameValue(other.decimalSeparator) &&
|
|
175
192
|
variant.hasSameValue(other.variant) &&
|
|
@@ -235,6 +252,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
235
252
|
showSoftInputOnFocus.hasSameValue(other.showSoftInputOnFocus) &&
|
|
236
253
|
selectTextOnFocus.hasSameValue(other.selectTextOnFocus) &&
|
|
237
254
|
clearTextOnFocus.hasSameValue(other.clearTextOnFocus) &&
|
|
255
|
+
keyboardHandoffMs.hasSameValue(other.keyboardHandoffMs) &&
|
|
256
|
+
returnKeyBar.hasSameValue(other.returnKeyBar) &&
|
|
238
257
|
contextMenuHidden.hasSameValue(other.contextMenuHidden) &&
|
|
239
258
|
spellCheck.hasSameValue(other.spellCheck) &&
|
|
240
259
|
selectionStart.hasSameValue(other.selectionStart) &&
|
|
@@ -272,6 +291,12 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
272
291
|
maskNotations.isProvided() ||
|
|
273
292
|
maskAutocomplete.isProvided() ||
|
|
274
293
|
maskAutoSkip.isProvided() ||
|
|
294
|
+
maskAffinityFormats.isProvided() ||
|
|
295
|
+
maskAffinityStrategy.isProvided() ||
|
|
296
|
+
maskTextCase.isProvided() ||
|
|
297
|
+
maskCharacterMap.isProvided() ||
|
|
298
|
+
maskSlotPlaceholder.isProvided() ||
|
|
299
|
+
keepPlaceholder.isProvided() ||
|
|
275
300
|
groupingSeparator.isProvided() ||
|
|
276
301
|
decimalSeparator.isProvided() ||
|
|
277
302
|
variant.isProvided() ||
|
|
@@ -337,6 +362,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
337
362
|
showSoftInputOnFocus.isProvided() ||
|
|
338
363
|
selectTextOnFocus.isProvided() ||
|
|
339
364
|
clearTextOnFocus.isProvided() ||
|
|
365
|
+
keyboardHandoffMs.isProvided() ||
|
|
366
|
+
returnKeyBar.isProvided() ||
|
|
340
367
|
contextMenuHidden.isProvided() ||
|
|
341
368
|
spellCheck.isProvided() ||
|
|
342
369
|
selectionStart.isProvided() ||
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
"maskNotations": true,
|
|
15
15
|
"maskAutocomplete": true,
|
|
16
16
|
"maskAutoSkip": true,
|
|
17
|
+
"maskAffinityFormats": true,
|
|
18
|
+
"maskAffinityStrategy": true,
|
|
19
|
+
"maskTextCase": true,
|
|
20
|
+
"maskCharacterMap": true,
|
|
21
|
+
"maskSlotPlaceholder": true,
|
|
22
|
+
"keepPlaceholder": true,
|
|
17
23
|
"groupingSeparator": true,
|
|
18
24
|
"decimalSeparator": true,
|
|
19
25
|
"variant": true,
|
|
@@ -79,6 +85,8 @@
|
|
|
79
85
|
"showSoftInputOnFocus": true,
|
|
80
86
|
"selectTextOnFocus": true,
|
|
81
87
|
"clearTextOnFocus": true,
|
|
88
|
+
"keyboardHandoffMs": true,
|
|
89
|
+
"returnKeyBar": true,
|
|
82
90
|
"contextMenuHidden": true,
|
|
83
91
|
"spellCheck": true,
|
|
84
92
|
"selectionStart": true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-input",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
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/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",
|
|
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/AmountFormatter.cpp cpp/MaskEngine.cpp cpp/__tests__/MaskEngineCorpusTest.cpp -o .cache/mask-engine-corpus-test && .cache/mask-engine-corpus-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
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",
|
|
44
44
|
"release": "release-it"
|
|
45
45
|
},
|