react-native-nitro-input 0.3.1 → 0.3.2

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +30 -3
  3. package/android/src/main/cpp/JMaskEngine.cpp +45 -0
  4. package/android/src/main/cpp/JMaskEngine.hpp +9 -0
  5. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +24 -0
  6. package/android/src/main/java/com/margelo/nitro/nitroinput/MaskEngine.kt +16 -0
  7. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +96 -6
  8. package/cpp/MaskEngine.cpp +294 -33
  9. package/cpp/MaskEngine.hpp +68 -0
  10. package/ios/HybridNitroInputView.swift +18 -0
  11. package/ios/NitroInputView.swift +125 -7
  12. package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +6 -0
  13. package/lib/commonjs/src/NitroInput.js +15 -2
  14. package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +6 -0
  15. package/lib/module/src/NitroInput.js +15 -2
  16. package/lib/typescript/src/NitroInput.d.ts +39 -1
  17. package/lib/typescript/src/index.d.ts +1 -1
  18. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +43 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +102 -0
  20. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +12 -0
  21. package/nitrogen/generated/android/c++/JNitroInputCharacterMapping.hpp +61 -0
  22. package/nitrogen/generated/android/c++/JNitroInputMaskAffinity.hpp +64 -0
  23. package/nitrogen/generated/android/c++/JNitroInputTextCase.hpp +61 -0
  24. package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +30 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +36 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputCharacterMapping.kt +56 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputMaskAffinity.kt +25 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputTextCase.kt +24 -0
  29. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +25 -11
  30. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +9 -0
  31. package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +50 -0
  32. package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +36 -0
  33. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +6 -0
  34. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +78 -0
  35. package/nitrogen/generated/ios/swift/NitroInputCharacterMapping.swift +34 -0
  36. package/nitrogen/generated/ios/swift/NitroInputMaskAffinity.swift +48 -0
  37. package/nitrogen/generated/ios/swift/NitroInputTextCase.swift +44 -0
  38. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +12 -0
  39. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +21 -0
  40. package/nitrogen/generated/shared/c++/NitroInputCharacterMapping.hpp +87 -0
  41. package/nitrogen/generated/shared/c++/NitroInputMaskAffinity.hpp +84 -0
  42. package/nitrogen/generated/shared/c++/NitroInputTextCase.hpp +80 -0
  43. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +12 -0
  44. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +21 -0
  45. package/nitrogen/generated/shared/json/NitroInputViewConfig.json +6 -0
  46. package/package.json +2 -2
  47. package/src/NitroInput.tsx +73 -0
  48. package/src/index.ts +3 -0
  49. package/src/specs/NitroInput.nitro.ts +46 -0
@@ -237,6 +237,84 @@ open class HybridNitroInputViewSpec_cxx {
237
237
  }
238
238
  }
239
239
 
240
+ public final var maskAffinityFormats: bridge.std__vector_std__string_ {
241
+ @inline(__always)
242
+ get {
243
+ return { () -> bridge.std__vector_std__string_ in
244
+ var __vector = bridge.create_std__vector_std__string_(self.__implementation.maskAffinityFormats.count)
245
+ for __item in self.__implementation.maskAffinityFormats {
246
+ __vector.push_back(std.string(__item))
247
+ }
248
+ return __vector
249
+ }()
250
+ }
251
+ @inline(__always)
252
+ set {
253
+ self.__implementation.maskAffinityFormats = newValue.map({ __item in String(__item) })
254
+ }
255
+ }
256
+
257
+ public final var maskAffinityStrategy: Int32 {
258
+ @inline(__always)
259
+ get {
260
+ return self.__implementation.maskAffinityStrategy.rawValue
261
+ }
262
+ @inline(__always)
263
+ set {
264
+ self.__implementation.maskAffinityStrategy = margelo.nitro.nitroinput.NitroInputMaskAffinity(rawValue: newValue)!
265
+ }
266
+ }
267
+
268
+ public final var maskTextCase: Int32 {
269
+ @inline(__always)
270
+ get {
271
+ return self.__implementation.maskTextCase.rawValue
272
+ }
273
+ @inline(__always)
274
+ set {
275
+ self.__implementation.maskTextCase = margelo.nitro.nitroinput.NitroInputTextCase(rawValue: newValue)!
276
+ }
277
+ }
278
+
279
+ public final var maskCharacterMap: bridge.std__vector_NitroInputCharacterMapping_ {
280
+ @inline(__always)
281
+ get {
282
+ return { () -> bridge.std__vector_NitroInputCharacterMapping_ in
283
+ var __vector = bridge.create_std__vector_NitroInputCharacterMapping_(self.__implementation.maskCharacterMap.count)
284
+ for __item in self.__implementation.maskCharacterMap {
285
+ __vector.push_back(__item)
286
+ }
287
+ return __vector
288
+ }()
289
+ }
290
+ @inline(__always)
291
+ set {
292
+ self.__implementation.maskCharacterMap = newValue.map({ __item in __item })
293
+ }
294
+ }
295
+
296
+ public final var maskSlotPlaceholder: std.string {
297
+ @inline(__always)
298
+ get {
299
+ return std.string(self.__implementation.maskSlotPlaceholder)
300
+ }
301
+ @inline(__always)
302
+ set {
303
+ self.__implementation.maskSlotPlaceholder = String(newValue)
304
+ }
305
+ }
306
+
307
+ public final var keepPlaceholder: Bool {
308
+ @inline(__always)
309
+ get {
310
+ return self.__implementation.keepPlaceholder
311
+ }
312
+ @inline(__always)
313
+ set {
314
+ self.__implementation.keepPlaceholder = newValue
315
+ }
316
+ }
317
+
240
318
  public final var groupingSeparator: std.string {
241
319
  @inline(__always)
242
320
  get {
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// NitroInputCharacterMapping.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `NitroInputCharacterMapping`, backed by a C++ struct.
12
+ */
13
+ public typealias NitroInputCharacterMapping = margelo.nitro.nitroinput.NitroInputCharacterMapping
14
+
15
+ public extension NitroInputCharacterMapping {
16
+ private typealias bridge = margelo.nitro.nitroinput.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `NitroInputCharacterMapping`.
20
+ */
21
+ init(from: String, to: String) {
22
+ self.init(std.string(from), std.string(to))
23
+ }
24
+
25
+ @inline(__always)
26
+ var from: String {
27
+ return String(self.__from)
28
+ }
29
+
30
+ @inline(__always)
31
+ var to: String {
32
+ return String(self.__to)
33
+ }
34
+ }
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// NitroInputMaskAffinity.swift
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
+ /**
9
+ * Represents the JS union `NitroInputMaskAffinity`, backed by a C++ enum.
10
+ */
11
+ public typealias NitroInputMaskAffinity = margelo.nitro.nitroinput.NitroInputMaskAffinity
12
+
13
+ public extension NitroInputMaskAffinity {
14
+ /**
15
+ * Get a NitroInputMaskAffinity for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "wholeString":
21
+ self = .wholestring
22
+ case "prefix":
23
+ self = .prefix
24
+ case "capacity":
25
+ self = .capacity
26
+ case "extractedValueCapacity":
27
+ self = .extractedvaluecapacity
28
+ default:
29
+ return nil
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get the String value this NitroInputMaskAffinity represents.
35
+ */
36
+ var stringValue: String {
37
+ switch self {
38
+ case .wholestring:
39
+ return "wholeString"
40
+ case .prefix:
41
+ return "prefix"
42
+ case .capacity:
43
+ return "capacity"
44
+ case .extractedvaluecapacity:
45
+ return "extractedValueCapacity"
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// NitroInputTextCase.swift
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
+ /**
9
+ * Represents the JS union `NitroInputTextCase`, backed by a C++ enum.
10
+ */
11
+ public typealias NitroInputTextCase = margelo.nitro.nitroinput.NitroInputTextCase
12
+
13
+ public extension NitroInputTextCase {
14
+ /**
15
+ * Get a NitroInputTextCase for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "none":
21
+ self = .none
22
+ case "upper":
23
+ self = .upper
24
+ case "lower":
25
+ self = .lower
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this NitroInputTextCase represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .none:
37
+ return "none"
38
+ case .upper:
39
+ return "upper"
40
+ case .lower:
41
+ return "lower"
42
+ }
43
+ }
44
+ }
@@ -34,6 +34,18 @@ namespace margelo::nitro::nitroinput {
34
34
  prototype.registerHybridSetter("maskAutocomplete", &HybridNitroInputViewSpec::setMaskAutocomplete);
35
35
  prototype.registerHybridGetter("maskAutoSkip", &HybridNitroInputViewSpec::getMaskAutoSkip);
36
36
  prototype.registerHybridSetter("maskAutoSkip", &HybridNitroInputViewSpec::setMaskAutoSkip);
37
+ prototype.registerHybridGetter("maskAffinityFormats", &HybridNitroInputViewSpec::getMaskAffinityFormats);
38
+ prototype.registerHybridSetter("maskAffinityFormats", &HybridNitroInputViewSpec::setMaskAffinityFormats);
39
+ prototype.registerHybridGetter("maskAffinityStrategy", &HybridNitroInputViewSpec::getMaskAffinityStrategy);
40
+ prototype.registerHybridSetter("maskAffinityStrategy", &HybridNitroInputViewSpec::setMaskAffinityStrategy);
41
+ prototype.registerHybridGetter("maskTextCase", &HybridNitroInputViewSpec::getMaskTextCase);
42
+ prototype.registerHybridSetter("maskTextCase", &HybridNitroInputViewSpec::setMaskTextCase);
43
+ prototype.registerHybridGetter("maskCharacterMap", &HybridNitroInputViewSpec::getMaskCharacterMap);
44
+ prototype.registerHybridSetter("maskCharacterMap", &HybridNitroInputViewSpec::setMaskCharacterMap);
45
+ prototype.registerHybridGetter("maskSlotPlaceholder", &HybridNitroInputViewSpec::getMaskSlotPlaceholder);
46
+ prototype.registerHybridSetter("maskSlotPlaceholder", &HybridNitroInputViewSpec::setMaskSlotPlaceholder);
47
+ prototype.registerHybridGetter("keepPlaceholder", &HybridNitroInputViewSpec::getKeepPlaceholder);
48
+ prototype.registerHybridSetter("keepPlaceholder", &HybridNitroInputViewSpec::setKeepPlaceholder);
37
49
  prototype.registerHybridGetter("groupingSeparator", &HybridNitroInputViewSpec::getGroupingSeparator);
38
50
  prototype.registerHybridSetter("groupingSeparator", &HybridNitroInputViewSpec::setGroupingSeparator);
39
51
  prototype.registerHybridGetter("decimalSeparator", &HybridNitroInputViewSpec::getDecimalSeparator);
@@ -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;
@@ -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)),
@@ -131,6 +137,12 @@ namespace margelo::nitro::nitroinput::views {
131
137
  case hashString("maskNotations"): return true;
132
138
  case hashString("maskAutocomplete"): return true;
133
139
  case hashString("maskAutoSkip"): return true;
140
+ case hashString("maskAffinityFormats"): return true;
141
+ case hashString("maskAffinityStrategy"): return true;
142
+ case hashString("maskTextCase"): return true;
143
+ case hashString("maskCharacterMap"): return true;
144
+ case hashString("maskSlotPlaceholder"): return true;
145
+ case hashString("keepPlaceholder"): return true;
134
146
  case hashString("groupingSeparator"): return true;
135
147
  case hashString("decimalSeparator"): return true;
136
148
  case hashString("variant"): 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;
@@ -170,6 +179,12 @@ namespace margelo::nitro::nitroinput::views {
170
179
  maskNotations.hasSameValue(other.maskNotations) &&
171
180
  maskAutocomplete.hasSameValue(other.maskAutocomplete) &&
172
181
  maskAutoSkip.hasSameValue(other.maskAutoSkip) &&
182
+ maskAffinityFormats.hasSameValue(other.maskAffinityFormats) &&
183
+ maskAffinityStrategy.hasSameValue(other.maskAffinityStrategy) &&
184
+ maskTextCase.hasSameValue(other.maskTextCase) &&
185
+ maskCharacterMap.hasSameValue(other.maskCharacterMap) &&
186
+ maskSlotPlaceholder.hasSameValue(other.maskSlotPlaceholder) &&
187
+ keepPlaceholder.hasSameValue(other.keepPlaceholder) &&
173
188
  groupingSeparator.hasSameValue(other.groupingSeparator) &&
174
189
  decimalSeparator.hasSameValue(other.decimalSeparator) &&
175
190
  variant.hasSameValue(other.variant) &&
@@ -272,6 +287,12 @@ namespace margelo::nitro::nitroinput::views {
272
287
  maskNotations.isProvided() ||
273
288
  maskAutocomplete.isProvided() ||
274
289
  maskAutoSkip.isProvided() ||
290
+ maskAffinityFormats.isProvided() ||
291
+ maskAffinityStrategy.isProvided() ||
292
+ maskTextCase.isProvided() ||
293
+ maskCharacterMap.isProvided() ||
294
+ maskSlotPlaceholder.isProvided() ||
295
+ keepPlaceholder.isProvided() ||
275
296
  groupingSeparator.isProvided() ||
276
297
  decimalSeparator.isProvided() ||
277
298
  variant.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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-input",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
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
  },