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.
Files changed (51) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +75 -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 +49 -4
  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 +266 -8
  8. package/android/src/main/java/com/margelo/nitro/nitroinput/UnmountHandoffs.kt +57 -0
  9. package/cpp/MaskEngine.cpp +294 -33
  10. package/cpp/MaskEngine.hpp +68 -0
  11. package/ios/HybridNitroInputView.swift +37 -4
  12. package/ios/NitroInputCommands.mm +10 -0
  13. package/ios/NitroInputView.swift +474 -20
  14. package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
  15. package/lib/commonjs/src/NitroInput.js +116 -15
  16. package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
  17. package/lib/module/src/NitroInput.js +117 -16
  18. package/lib/typescript/src/NitroInput.d.ts +55 -1
  19. package/lib/typescript/src/index.d.ts +1 -1
  20. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +65 -0
  21. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +124 -0
  22. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +17 -0
  23. package/nitrogen/generated/android/c++/JNitroInputCharacterMapping.hpp +61 -0
  24. package/nitrogen/generated/android/c++/JNitroInputMaskAffinity.hpp +64 -0
  25. package/nitrogen/generated/android/c++/JNitroInputTextCase.hpp +61 -0
  26. package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +40 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +52 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputCharacterMapping.kt +56 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputMaskAffinity.kt +25 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputTextCase.kt +24 -0
  31. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +25 -11
  32. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +9 -0
  33. package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +68 -0
  34. package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +48 -0
  35. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +9 -0
  36. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +111 -0
  37. package/nitrogen/generated/ios/swift/NitroInputCharacterMapping.swift +34 -0
  38. package/nitrogen/generated/ios/swift/NitroInputMaskAffinity.swift +48 -0
  39. package/nitrogen/generated/ios/swift/NitroInputTextCase.swift +44 -0
  40. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +17 -0
  41. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +26 -0
  42. package/nitrogen/generated/shared/c++/NitroInputCharacterMapping.hpp +87 -0
  43. package/nitrogen/generated/shared/c++/NitroInputMaskAffinity.hpp +84 -0
  44. package/nitrogen/generated/shared/c++/NitroInputTextCase.hpp +80 -0
  45. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +16 -0
  46. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +27 -0
  47. package/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
  48. package/package.json +2 -2
  49. package/src/NitroInput.tsx +190 -11
  50. package/src/index.ts +3 -0
  51. package/src/specs/NitroInput.nitro.ts +68 -0
@@ -5,6 +5,21 @@ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-nativ
5
5
  * `'text'` is a plain single-line field.
6
6
  */
7
7
  export type NitroInputMode = 'text' | 'number' | 'mask';
8
+ /**
9
+ * How the best of `maskAffinityFormats` is chosen for the text in the field:
10
+ * `'wholeString'` the format that accepts the most characters and inserts the
11
+ * fewest, `'prefix'` the one whose output starts most like what was typed,
12
+ * `'capacity'` / `'extractedValueCapacity'` the fullest format that still
13
+ * holds all of the text / all of its value characters.
14
+ */
15
+ export type NitroInputMaskAffinity = 'wholeString' | 'prefix' | 'capacity' | 'extractedValueCapacity';
16
+ /** How letters are cased as they are typed into a mask. */
17
+ export type NitroInputTextCase = 'none' | 'upper' | 'lower';
18
+ /** One character replaced by another before masking; an empty `to` drops it. */
19
+ export interface NitroInputCharacterMapping {
20
+ from: string;
21
+ to: string;
22
+ }
8
23
  /**
9
24
  * A caller-defined slot character for `mask`, beyond the built-in
10
25
  * `0 9 A a _ - …`. `characterSet` lists every character the slot accepts.
@@ -131,6 +146,34 @@ export interface NitroInputProps extends HybridViewProps {
131
146
  * Default: `false`.
132
147
  */
133
148
  maskAutoSkip: boolean;
149
+ /**
150
+ * `'mask'`: more patterns the text may take, e.g. a 4-6-5 Amex card beside
151
+ * a 4-4-4-4 `mask`. Every edit is masked with each and the best, by
152
+ * `maskAffinityStrategy`, is kept; `mask` wins ties. Default: none.
153
+ */
154
+ maskAffinityFormats: string[];
155
+ /** `'mask'`: how the best of `maskAffinityFormats` is chosen. Default: `'wholeString'`. */
156
+ maskAffinityStrategy: NitroInputMaskAffinity;
157
+ /** `'mask'`: uppercases or lowercases letters as they are typed or pasted. Default: `'none'`. */
158
+ maskTextCase: NitroInputTextCase;
159
+ /**
160
+ * `'mask'`: characters replaced before masking, e.g. a Cyrillic "С" with a
161
+ * Latin "C", or "," with "." for a decimal mask. Default: none.
162
+ */
163
+ maskCharacterMap: NitroInputCharacterMapping[];
164
+ /**
165
+ * `'mask'`: the character each empty slot shows in the kept placeholder and
166
+ * in `onChangeMask`'s tail, e.g. `'_'`. Empty: the slot's own notation
167
+ * character. Default: `''`.
168
+ */
169
+ maskSlotPlaceholder: string;
170
+ /**
171
+ * `'mask'`: keeps the rest of the placeholder visible after what has been
172
+ * typed, so "1234 5" shows "678 9012" greyed after it. Without a
173
+ * `placeholder`, the mask itself is shown, empty slots as
174
+ * `maskSlotPlaceholder`: `+1 (212) ___-____`. Default: `false`.
175
+ */
176
+ keepPlaceholder: boolean;
134
177
  /** `'number'`: inserted between every three integer digits; empty disables grouping. Default: `','`. */
135
178
  groupingSeparator: string;
136
179
  /** `'number'`: between the integer and fraction digits. Default: `'.'`. */
@@ -308,6 +351,21 @@ export interface NitroInputProps extends HybridViewProps {
308
351
  selectTextOnFocus: boolean;
309
352
  /** Empty the field when it gains focus. Default: `false`. */
310
353
  clearTextOnFocus: boolean;
354
+ /**
355
+ * iOS: when this field loses its window while it has the keyboard (its
356
+ * screen is popped or unmounted), keep the keyboard up for this many
357
+ * milliseconds so the next field to focus takes it over in place, instead
358
+ * of the keyboard dropping and rising again. `0` lets it go at once.
359
+ * Default: `0`.
360
+ */
361
+ keyboardHandoffMs: number;
362
+ /**
363
+ * iOS: on the number, phone and decimal pads (no return key of their own),
364
+ * a bar over the keyboard with the `returnKeyType` key, as `TextInput`
365
+ * shows. `false` leaves the pad bare, for a screen with its own button on
366
+ * the keyboard. Default: `true`.
367
+ */
368
+ returnKeyBar: boolean;
311
369
  /** Hides the Cut/Copy/Paste menu. Default: `false`. */
312
370
  contextMenuHidden: boolean;
313
371
  /** Spell checking (`'text'` mode). Defaults to `autoCorrect`. */
@@ -396,5 +454,12 @@ export interface NitroInputMethods extends HybridViewMethods {
396
454
  * `end` defaults to `start` for a plain caret move; both are clamped.
397
455
  */
398
456
  setSelection(start: number, end: number): void;
457
+ /**
458
+ * The field is about to be unmounted: if it has the keyboard and
459
+ * `keyboardHandoffMs` is set, hand the keyboard to the stand-in now, while
460
+ * the field is still first responder (by the time its view is removed,
461
+ * UIKit has already taken that away). Called by `NitroInput` itself.
462
+ */
463
+ prepareForUnmount(): void;
399
464
  }
400
465
  export type NitroInputView = HybridView<NitroInputProps, NitroInputMethods>;
@@ -11,6 +11,12 @@
11
11
  namespace margelo::nitro::nitroinput { enum class NitroInputMode; }
12
12
  // Forward declaration of `NitroInputNotation` to properly resolve imports.
13
13
  namespace margelo::nitro::nitroinput { struct NitroInputNotation; }
14
+ // Forward declaration of `NitroInputMaskAffinity` to properly resolve imports.
15
+ namespace margelo::nitro::nitroinput { enum class NitroInputMaskAffinity; }
16
+ // Forward declaration of `NitroInputTextCase` to properly resolve imports.
17
+ namespace margelo::nitro::nitroinput { enum class NitroInputTextCase; }
18
+ // Forward declaration of `NitroInputCharacterMapping` to properly resolve imports.
19
+ namespace margelo::nitro::nitroinput { struct NitroInputCharacterMapping; }
14
20
  // Forward declaration of `NitroInputVariant` to properly resolve imports.
15
21
  namespace margelo::nitro::nitroinput { enum class NitroInputVariant; }
16
22
  // Forward declaration of `NitroInputLabelBehavior` to properly resolve imports.
@@ -44,6 +50,12 @@ namespace margelo::nitro::nitroinput { enum class NitroInputKeyboardAppearance;
44
50
  #include "NitroInputNotation.hpp"
45
51
  #include <vector>
46
52
  #include "JNitroInputNotation.hpp"
53
+ #include "NitroInputMaskAffinity.hpp"
54
+ #include "JNitroInputMaskAffinity.hpp"
55
+ #include "NitroInputTextCase.hpp"
56
+ #include "JNitroInputTextCase.hpp"
57
+ #include "NitroInputCharacterMapping.hpp"
58
+ #include "JNitroInputCharacterMapping.hpp"
47
59
  #include "NitroInputVariant.hpp"
48
60
  #include "JNitroInputVariant.hpp"
49
61
  #include "NitroInputLabelBehavior.hpp"
@@ -218,6 +230,96 @@ namespace margelo::nitro::nitroinput {
218
230
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* maskAutoSkip */)>("setMaskAutoSkip");
219
231
  method(_javaPart, maskAutoSkip);
220
232
  }
233
+ std::vector<std::string> JHybridNitroInputViewSpec::getMaskAffinityFormats() {
234
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<jni::JString>>()>("getMaskAffinityFormats");
235
+ auto __result = method(_javaPart);
236
+ return [&](auto&& __input) {
237
+ size_t __size = __input->size();
238
+ std::vector<std::string> __vector;
239
+ __vector.reserve(__size);
240
+ for (size_t __i = 0; __i < __size; __i++) {
241
+ auto __element = __input->getElement(__i);
242
+ __vector.push_back(__element->toStdString());
243
+ }
244
+ return __vector;
245
+ }(__result);
246
+ }
247
+ void JHybridNitroInputViewSpec::setMaskAffinityFormats(const std::vector<std::string>& maskAffinityFormats) {
248
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<jni::JString>> /* maskAffinityFormats */)>("setMaskAffinityFormats");
249
+ method(_javaPart, [&](auto&& __input) {
250
+ size_t __size = __input.size();
251
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
252
+ for (size_t __i = 0; __i < __size; __i++) {
253
+ const auto& __element = __input[__i];
254
+ auto __elementJni = jni::make_jstring(__element);
255
+ __array->setElement(__i, *__elementJni);
256
+ }
257
+ return __array;
258
+ }(maskAffinityFormats));
259
+ }
260
+ NitroInputMaskAffinity JHybridNitroInputViewSpec::getMaskAffinityStrategy() {
261
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JNitroInputMaskAffinity>()>("getMaskAffinityStrategy");
262
+ auto __result = method(_javaPart);
263
+ return __result->toCpp();
264
+ }
265
+ void JHybridNitroInputViewSpec::setMaskAffinityStrategy(NitroInputMaskAffinity maskAffinityStrategy) {
266
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JNitroInputMaskAffinity> /* maskAffinityStrategy */)>("setMaskAffinityStrategy");
267
+ method(_javaPart, JNitroInputMaskAffinity::fromCpp(maskAffinityStrategy));
268
+ }
269
+ NitroInputTextCase JHybridNitroInputViewSpec::getMaskTextCase() {
270
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JNitroInputTextCase>()>("getMaskTextCase");
271
+ auto __result = method(_javaPart);
272
+ return __result->toCpp();
273
+ }
274
+ void JHybridNitroInputViewSpec::setMaskTextCase(NitroInputTextCase maskTextCase) {
275
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JNitroInputTextCase> /* maskTextCase */)>("setMaskTextCase");
276
+ method(_javaPart, JNitroInputTextCase::fromCpp(maskTextCase));
277
+ }
278
+ std::vector<NitroInputCharacterMapping> JHybridNitroInputViewSpec::getMaskCharacterMap() {
279
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JNitroInputCharacterMapping>>()>("getMaskCharacterMap");
280
+ auto __result = method(_javaPart);
281
+ return [&](auto&& __input) {
282
+ size_t __size = __input->size();
283
+ std::vector<NitroInputCharacterMapping> __vector;
284
+ __vector.reserve(__size);
285
+ for (size_t __i = 0; __i < __size; __i++) {
286
+ auto __element = __input->getElement(__i);
287
+ __vector.push_back(__element->toCpp());
288
+ }
289
+ return __vector;
290
+ }(__result);
291
+ }
292
+ void JHybridNitroInputViewSpec::setMaskCharacterMap(const std::vector<NitroInputCharacterMapping>& maskCharacterMap) {
293
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JNitroInputCharacterMapping>> /* maskCharacterMap */)>("setMaskCharacterMap");
294
+ method(_javaPart, [&](auto&& __input) {
295
+ size_t __size = __input.size();
296
+ jni::local_ref<jni::JArrayClass<JNitroInputCharacterMapping>> __array = jni::JArrayClass<JNitroInputCharacterMapping>::newArray(__size);
297
+ for (size_t __i = 0; __i < __size; __i++) {
298
+ const auto& __element = __input[__i];
299
+ auto __elementJni = JNitroInputCharacterMapping::fromCpp(__element);
300
+ __array->setElement(__i, *__elementJni);
301
+ }
302
+ return __array;
303
+ }(maskCharacterMap));
304
+ }
305
+ std::string JHybridNitroInputViewSpec::getMaskSlotPlaceholder() {
306
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getMaskSlotPlaceholder");
307
+ auto __result = method(_javaPart);
308
+ return __result->toStdString();
309
+ }
310
+ void JHybridNitroInputViewSpec::setMaskSlotPlaceholder(const std::string& maskSlotPlaceholder) {
311
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* maskSlotPlaceholder */)>("setMaskSlotPlaceholder");
312
+ method(_javaPart, jni::make_jstring(maskSlotPlaceholder));
313
+ }
314
+ bool JHybridNitroInputViewSpec::getKeepPlaceholder() {
315
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getKeepPlaceholder");
316
+ auto __result = method(_javaPart);
317
+ return static_cast<bool>(__result);
318
+ }
319
+ void JHybridNitroInputViewSpec::setKeepPlaceholder(bool keepPlaceholder) {
320
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* keepPlaceholder */)>("setKeepPlaceholder");
321
+ method(_javaPart, keepPlaceholder);
322
+ }
221
323
  std::string JHybridNitroInputViewSpec::getGroupingSeparator() {
222
324
  static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getGroupingSeparator");
223
325
  auto __result = method(_javaPart);
@@ -803,6 +905,24 @@ namespace margelo::nitro::nitroinput {
803
905
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* clearTextOnFocus */)>("setClearTextOnFocus");
804
906
  method(_javaPart, clearTextOnFocus);
805
907
  }
908
+ double JHybridNitroInputViewSpec::getKeyboardHandoffMs() {
909
+ static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getKeyboardHandoffMs");
910
+ auto __result = method(_javaPart);
911
+ return __result;
912
+ }
913
+ void JHybridNitroInputViewSpec::setKeyboardHandoffMs(double keyboardHandoffMs) {
914
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* keyboardHandoffMs */)>("setKeyboardHandoffMs");
915
+ method(_javaPart, keyboardHandoffMs);
916
+ }
917
+ bool JHybridNitroInputViewSpec::getReturnKeyBar() {
918
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getReturnKeyBar");
919
+ auto __result = method(_javaPart);
920
+ return static_cast<bool>(__result);
921
+ }
922
+ void JHybridNitroInputViewSpec::setReturnKeyBar(bool returnKeyBar) {
923
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* returnKeyBar */)>("setReturnKeyBar");
924
+ method(_javaPart, returnKeyBar);
925
+ }
806
926
  bool JHybridNitroInputViewSpec::getContextMenuHidden() {
807
927
  static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getContextMenuHidden");
808
928
  auto __result = method(_javaPart);
@@ -1114,5 +1234,9 @@ namespace margelo::nitro::nitroinput {
1114
1234
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* start */, double /* end */)>("setSelection");
1115
1235
  method(_javaPart, start, end);
1116
1236
  }
1237
+ void JHybridNitroInputViewSpec::prepareForUnmount() {
1238
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("prepareForUnmount");
1239
+ method(_javaPart);
1240
+ }
1117
1241
 
1118
1242
  } // namespace margelo::nitro::nitroinput
@@ -70,6 +70,18 @@ namespace margelo::nitro::nitroinput {
70
70
  void setMaskAutocomplete(bool maskAutocomplete) override;
71
71
  bool getMaskAutoSkip() override;
72
72
  void setMaskAutoSkip(bool maskAutoSkip) override;
73
+ std::vector<std::string> getMaskAffinityFormats() override;
74
+ void setMaskAffinityFormats(const std::vector<std::string>& maskAffinityFormats) override;
75
+ NitroInputMaskAffinity getMaskAffinityStrategy() override;
76
+ void setMaskAffinityStrategy(NitroInputMaskAffinity maskAffinityStrategy) override;
77
+ NitroInputTextCase getMaskTextCase() override;
78
+ void setMaskTextCase(NitroInputTextCase maskTextCase) override;
79
+ std::vector<NitroInputCharacterMapping> getMaskCharacterMap() override;
80
+ void setMaskCharacterMap(const std::vector<NitroInputCharacterMapping>& maskCharacterMap) override;
81
+ std::string getMaskSlotPlaceholder() override;
82
+ void setMaskSlotPlaceholder(const std::string& maskSlotPlaceholder) override;
83
+ bool getKeepPlaceholder() override;
84
+ void setKeepPlaceholder(bool keepPlaceholder) override;
73
85
  std::string getGroupingSeparator() override;
74
86
  void setGroupingSeparator(const std::string& groupingSeparator) override;
75
87
  std::string getDecimalSeparator() override;
@@ -200,6 +212,10 @@ namespace margelo::nitro::nitroinput {
200
212
  void setSelectTextOnFocus(bool selectTextOnFocus) override;
201
213
  bool getClearTextOnFocus() override;
202
214
  void setClearTextOnFocus(bool clearTextOnFocus) override;
215
+ double getKeyboardHandoffMs() override;
216
+ void setKeyboardHandoffMs(double keyboardHandoffMs) override;
217
+ bool getReturnKeyBar() override;
218
+ void setReturnKeyBar(bool returnKeyBar) override;
203
219
  bool getContextMenuHidden() override;
204
220
  void setContextMenuHidden(bool contextMenuHidden) override;
205
221
  bool getSpellCheck() override;
@@ -256,6 +272,7 @@ namespace margelo::nitro::nitroinput {
256
272
  double getValue() override;
257
273
  bool isFocused() override;
258
274
  void setSelection(double start, double end) override;
275
+ void prepareForUnmount() override;
259
276
 
260
277
  private:
261
278
  jni::global_ref<JHybridNitroInputViewSpec::JavaPart> _javaPart;
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JNitroInputCharacterMapping.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 <fbjni/fbjni.h>
11
+ #include "NitroInputCharacterMapping.hpp"
12
+
13
+ #include <string>
14
+
15
+ namespace margelo::nitro::nitroinput {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "NitroInputCharacterMapping" and the Kotlin data class "NitroInputCharacterMapping".
21
+ */
22
+ struct JNitroInputCharacterMapping final: public jni::JavaClass<JNitroInputCharacterMapping> {
23
+ public:
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/NitroInputCharacterMapping;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct NitroInputCharacterMapping by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ NitroInputCharacterMapping toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldFrom = clazz->getField<jni::JString>("from");
35
+ jni::local_ref<jni::JString> from = this->getFieldValue(fieldFrom);
36
+ static const auto fieldTo = clazz->getField<jni::JString>("to");
37
+ jni::local_ref<jni::JString> to = this->getFieldValue(fieldTo);
38
+ return NitroInputCharacterMapping(
39
+ from->toStdString(),
40
+ to->toStdString()
41
+ );
42
+ }
43
+
44
+ public:
45
+ /**
46
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
47
+ */
48
+ [[maybe_unused]]
49
+ static jni::local_ref<JNitroInputCharacterMapping::javaobject> fromCpp(const NitroInputCharacterMapping& value) {
50
+ using JSignature = JNitroInputCharacterMapping(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
51
+ static const auto clazz = javaClassStatic();
52
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
53
+ return create(
54
+ clazz,
55
+ jni::make_jstring(value.from),
56
+ jni::make_jstring(value.to)
57
+ );
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::nitroinput
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// JNitroInputMaskAffinity.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 <fbjni/fbjni.h>
11
+ #include "NitroInputMaskAffinity.hpp"
12
+
13
+ namespace margelo::nitro::nitroinput {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "NitroInputMaskAffinity" and the Kotlin enum "NitroInputMaskAffinity".
19
+ */
20
+ struct JNitroInputMaskAffinity final: public jni::JavaClass<JNitroInputMaskAffinity> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/NitroInputMaskAffinity;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum NitroInputMaskAffinity.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ NitroInputMaskAffinity toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<NitroInputMaskAffinity>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JNitroInputMaskAffinity> fromCpp(NitroInputMaskAffinity value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case NitroInputMaskAffinity::WHOLESTRING:
46
+ static const auto fieldWHOLESTRING = clazz->getStaticField<JNitroInputMaskAffinity>("WHOLESTRING");
47
+ return clazz->getStaticFieldValue(fieldWHOLESTRING);
48
+ case NitroInputMaskAffinity::PREFIX:
49
+ static const auto fieldPREFIX = clazz->getStaticField<JNitroInputMaskAffinity>("PREFIX");
50
+ return clazz->getStaticFieldValue(fieldPREFIX);
51
+ case NitroInputMaskAffinity::CAPACITY:
52
+ static const auto fieldCAPACITY = clazz->getStaticField<JNitroInputMaskAffinity>("CAPACITY");
53
+ return clazz->getStaticFieldValue(fieldCAPACITY);
54
+ case NitroInputMaskAffinity::EXTRACTEDVALUECAPACITY:
55
+ static const auto fieldEXTRACTEDVALUECAPACITY = clazz->getStaticField<JNitroInputMaskAffinity>("EXTRACTEDVALUECAPACITY");
56
+ return clazz->getStaticFieldValue(fieldEXTRACTEDVALUECAPACITY);
57
+ default:
58
+ std::string stringValue = std::to_string(static_cast<int>(value));
59
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
60
+ }
61
+ }
62
+ };
63
+
64
+ } // namespace margelo::nitro::nitroinput
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JNitroInputTextCase.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 <fbjni/fbjni.h>
11
+ #include "NitroInputTextCase.hpp"
12
+
13
+ namespace margelo::nitro::nitroinput {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "NitroInputTextCase" and the Kotlin enum "NitroInputTextCase".
19
+ */
20
+ struct JNitroInputTextCase final: public jni::JavaClass<JNitroInputTextCase> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/NitroInputTextCase;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum NitroInputTextCase.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ NitroInputTextCase toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<NitroInputTextCase>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JNitroInputTextCase> fromCpp(NitroInputTextCase value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case NitroInputTextCase::NONE:
46
+ static const auto fieldNONE = clazz->getStaticField<JNitroInputTextCase>("NONE");
47
+ return clazz->getStaticFieldValue(fieldNONE);
48
+ case NitroInputTextCase::UPPER:
49
+ static const auto fieldUPPER = clazz->getStaticField<JNitroInputTextCase>("UPPER");
50
+ return clazz->getStaticFieldValue(fieldUPPER);
51
+ case NitroInputTextCase::LOWER:
52
+ static const auto fieldLOWER = clazz->getStaticField<JNitroInputTextCase>("LOWER");
53
+ return clazz->getStaticFieldValue(fieldLOWER);
54
+ default:
55
+ std::string stringValue = std::to_string(static_cast<int>(value));
56
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
57
+ }
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::nitroinput
@@ -103,6 +103,36 @@ void JHybridNitroInputViewStateUpdater::updateViewProps(jni::alias_ref<jni::JCla
103
103
  : !newProps->maskAutoSkip.hasSameValue(oldProps->maskAutoSkip)) {
104
104
  hybridView->setMaskAutoSkip(newProps->maskAutoSkip.get());
105
105
  }
106
+ if (oldProps == nullptr
107
+ ? newProps->maskAffinityFormats.isProvided()
108
+ : !newProps->maskAffinityFormats.hasSameValue(oldProps->maskAffinityFormats)) {
109
+ hybridView->setMaskAffinityFormats(newProps->maskAffinityFormats.get());
110
+ }
111
+ if (oldProps == nullptr
112
+ ? newProps->maskAffinityStrategy.isProvided()
113
+ : !newProps->maskAffinityStrategy.hasSameValue(oldProps->maskAffinityStrategy)) {
114
+ hybridView->setMaskAffinityStrategy(newProps->maskAffinityStrategy.get());
115
+ }
116
+ if (oldProps == nullptr
117
+ ? newProps->maskTextCase.isProvided()
118
+ : !newProps->maskTextCase.hasSameValue(oldProps->maskTextCase)) {
119
+ hybridView->setMaskTextCase(newProps->maskTextCase.get());
120
+ }
121
+ if (oldProps == nullptr
122
+ ? newProps->maskCharacterMap.isProvided()
123
+ : !newProps->maskCharacterMap.hasSameValue(oldProps->maskCharacterMap)) {
124
+ hybridView->setMaskCharacterMap(newProps->maskCharacterMap.get());
125
+ }
126
+ if (oldProps == nullptr
127
+ ? newProps->maskSlotPlaceholder.isProvided()
128
+ : !newProps->maskSlotPlaceholder.hasSameValue(oldProps->maskSlotPlaceholder)) {
129
+ hybridView->setMaskSlotPlaceholder(newProps->maskSlotPlaceholder.get());
130
+ }
131
+ if (oldProps == nullptr
132
+ ? newProps->keepPlaceholder.isProvided()
133
+ : !newProps->keepPlaceholder.hasSameValue(oldProps->keepPlaceholder)) {
134
+ hybridView->setKeepPlaceholder(newProps->keepPlaceholder.get());
135
+ }
106
136
  if (oldProps == nullptr
107
137
  ? newProps->groupingSeparator.isProvided()
108
138
  : !newProps->groupingSeparator.hasSameValue(oldProps->groupingSeparator)) {
@@ -428,6 +458,16 @@ void JHybridNitroInputViewStateUpdater::updateViewProps(jni::alias_ref<jni::JCla
428
458
  : !newProps->clearTextOnFocus.hasSameValue(oldProps->clearTextOnFocus)) {
429
459
  hybridView->setClearTextOnFocus(newProps->clearTextOnFocus.get());
430
460
  }
461
+ if (oldProps == nullptr
462
+ ? newProps->keyboardHandoffMs.isProvided()
463
+ : !newProps->keyboardHandoffMs.hasSameValue(oldProps->keyboardHandoffMs)) {
464
+ hybridView->setKeyboardHandoffMs(newProps->keyboardHandoffMs.get());
465
+ }
466
+ if (oldProps == nullptr
467
+ ? newProps->returnKeyBar.isProvided()
468
+ : !newProps->returnKeyBar.hasSameValue(oldProps->returnKeyBar)) {
469
+ hybridView->setReturnKeyBar(newProps->returnKeyBar.get());
470
+ }
431
471
  if (oldProps == nullptr
432
472
  ? newProps->contextMenuHidden.isProvided()
433
473
  : !newProps->contextMenuHidden.hasSameValue(oldProps->contextMenuHidden)) {
@@ -87,6 +87,42 @@ abstract class HybridNitroInputViewSpec: HybridView() {
87
87
  @set:Keep
88
88
  abstract var maskAutoSkip: Boolean
89
89
 
90
+ @get:DoNotStrip
91
+ @get:Keep
92
+ @set:DoNotStrip
93
+ @set:Keep
94
+ abstract var maskAffinityFormats: Array<String>
95
+
96
+ @get:DoNotStrip
97
+ @get:Keep
98
+ @set:DoNotStrip
99
+ @set:Keep
100
+ abstract var maskAffinityStrategy: NitroInputMaskAffinity
101
+
102
+ @get:DoNotStrip
103
+ @get:Keep
104
+ @set:DoNotStrip
105
+ @set:Keep
106
+ abstract var maskTextCase: NitroInputTextCase
107
+
108
+ @get:DoNotStrip
109
+ @get:Keep
110
+ @set:DoNotStrip
111
+ @set:Keep
112
+ abstract var maskCharacterMap: Array<NitroInputCharacterMapping>
113
+
114
+ @get:DoNotStrip
115
+ @get:Keep
116
+ @set:DoNotStrip
117
+ @set:Keep
118
+ abstract var maskSlotPlaceholder: String
119
+
120
+ @get:DoNotStrip
121
+ @get:Keep
122
+ @set:DoNotStrip
123
+ @set:Keep
124
+ abstract var keepPlaceholder: Boolean
125
+
90
126
  @get:DoNotStrip
91
127
  @get:Keep
92
128
  @set:DoNotStrip
@@ -477,6 +513,18 @@ abstract class HybridNitroInputViewSpec: HybridView() {
477
513
  @set:Keep
478
514
  abstract var clearTextOnFocus: Boolean
479
515
 
516
+ @get:DoNotStrip
517
+ @get:Keep
518
+ @set:DoNotStrip
519
+ @set:Keep
520
+ abstract var keyboardHandoffMs: Double
521
+
522
+ @get:DoNotStrip
523
+ @get:Keep
524
+ @set:DoNotStrip
525
+ @set:Keep
526
+ abstract var returnKeyBar: Boolean
527
+
480
528
  @get:DoNotStrip
481
529
  @get:Keep
482
530
  @set:DoNotStrip
@@ -717,6 +765,10 @@ abstract class HybridNitroInputViewSpec: HybridView() {
717
765
  @DoNotStrip
718
766
  @Keep
719
767
  abstract fun setSelection(start: Double, end: Double): Unit
768
+
769
+ @DoNotStrip
770
+ @Keep
771
+ abstract fun prepareForUnmount(): Unit
720
772
 
721
773
  // Default implementation of `HybridObject.toString()`
722
774
  override fun toString(): String {
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// NitroInputCharacterMapping.kt
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
+ package com.margelo.nitro.nitroinput
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import java.util.Objects
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "NitroInputCharacterMapping".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class NitroInputCharacterMapping(
21
+ @DoNotStrip
22
+ @Keep
23
+ val from: String,
24
+ @DoNotStrip
25
+ @Keep
26
+ val to: String
27
+ ) {
28
+ /* primary constructor */
29
+
30
+ override fun equals(other: Any?): Boolean {
31
+ if (this === other) return true
32
+ if (other !is NitroInputCharacterMapping) return false
33
+ return Objects.deepEquals(this.from, other.from)
34
+ && Objects.deepEquals(this.to, other.to)
35
+ }
36
+
37
+ override fun hashCode(): Int {
38
+ return arrayOf<Any?>(
39
+ from,
40
+ to
41
+ ).contentDeepHashCode()
42
+ }
43
+
44
+ companion object {
45
+ /**
46
+ * Constructor called from C++
47
+ */
48
+ @DoNotStrip
49
+ @Keep
50
+ @Suppress("unused")
51
+ @JvmStatic
52
+ private fun fromCpp(from: String, to: String): NitroInputCharacterMapping {
53
+ return NitroInputCharacterMapping(from, to)
54
+ }
55
+ }
56
+ }