@salve-software/react-native-nitro-input-mask 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NitroInputMask.podspec +31 -0
- package/README.md +181 -0
- package/android/CMakeLists.txt +32 -0
- package/android/build.gradle +148 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/nitroinputmask/NitroInputMaskContext.kt +7 -0
- package/android/src/main/java/com/nitroinputmask/NitroInputMaskModule.kt +108 -0
- package/android/src/main/java/com/nitroinputmask/NitroInputMaskPackage.kt +29 -0
- package/android/src/main/java/com/nitroinputmask/NitroInputMaskServiceModule.kt +17 -0
- package/android/src/main/java/com/nitroinputmask/NitroInputMaskTextWatcher.kt +127 -0
- package/android/src/main/java/com/nitroinputmask/engine/CursorEngine.kt +30 -0
- package/android/src/main/java/com/nitroinputmask/engine/MaskEngine.kt +261 -0
- package/android/src/main/java/com/nitroinputmask/engine/MaskEngineFactory.kt +18 -0
- package/android/src/main/java/com/nitroinputmask/engine/MaskEngineProtocol.kt +8 -0
- package/android/src/main/java/com/nitroinputmask/masks/CreditCardMaskEngine.kt +47 -0
- package/android/src/main/java/com/nitroinputmask/masks/CustomMaskEngine.kt +16 -0
- package/android/src/main/java/com/nitroinputmask/masks/DatetimeMaskEngine.kt +38 -0
- package/android/src/main/java/com/nitroinputmask/masks/MoneyMaskEngine.kt +66 -0
- package/ios/Bridge.h +8 -0
- package/ios/NitroInputMaskDelegateProxy.swift +194 -0
- package/ios/NitroInputMaskModule.swift +114 -0
- package/ios/NitroInputMaskServiceModule.swift +11 -0
- package/ios/engine/CursorEngine.swift +52 -0
- package/ios/engine/MaskEngine.swift +221 -0
- package/ios/engine/MaskEngineFactory.swift +16 -0
- package/ios/engine/MaskEngineProtocol.swift +7 -0
- package/ios/masks/CreditCardMaskEngine.swift +57 -0
- package/ios/masks/CustomMaskEngine.swift +16 -0
- package/ios/masks/DatetimeMaskEngine.swift +46 -0
- package/ios/masks/MoneyMaskEngine.swift +66 -0
- package/lib/commonjs/classes/NitroInputMaskService/NitroInputMaskService.class.js +74 -0
- package/lib/commonjs/classes/NitroInputMaskService/NitroInputMaskService.class.js.map +1 -0
- package/lib/commonjs/classes/NitroInputMaskService/index.js +13 -0
- package/lib/commonjs/classes/NitroInputMaskService/index.js.map +1 -0
- package/lib/commonjs/classes/NitroInputMaskService/types/IApplyMaskProps.js +6 -0
- package/lib/commonjs/classes/NitroInputMaskService/types/IApplyMaskProps.js.map +1 -0
- package/lib/commonjs/classes/NitroInputMaskService/types/index.js +2 -0
- package/lib/commonjs/classes/NitroInputMaskService/types/index.js.map +1 -0
- package/lib/commonjs/classes/index.js +17 -0
- package/lib/commonjs/classes/index.js.map +1 -0
- package/lib/commonjs/components/NitroInputMask/index.js +41 -0
- package/lib/commonjs/components/NitroInputMask/index.js.map +1 -0
- package/lib/commonjs/components/NitroInputMask/types/NitroInputMaskProps.js +6 -0
- package/lib/commonjs/components/NitroInputMask/types/NitroInputMaskProps.js.map +1 -0
- package/lib/commonjs/components/NitroInputMask/types/index.js +2 -0
- package/lib/commonjs/components/NitroInputMask/types/index.js.map +1 -0
- package/lib/commonjs/components/index.js +17 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/nitro-module.js +17 -0
- package/lib/commonjs/nitro-module.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/nitro-input-mask-service.nitro.js +6 -0
- package/lib/commonjs/specs/nitro-input-mask-service.nitro.js.map +1 -0
- package/lib/commonjs/specs/nitro-input-mask.nitro.js +6 -0
- package/lib/commonjs/specs/nitro-input-mask.nitro.js.map +1 -0
- package/lib/commonjs/types/CreditCardMaskOptions.js +2 -0
- package/lib/commonjs/types/CreditCardMaskOptions.js.map +1 -0
- package/lib/commonjs/types/CustomMaskOptions.js +2 -0
- package/lib/commonjs/types/CustomMaskOptions.js.map +1 -0
- package/lib/commonjs/types/DatetimeMaskOptions.js +2 -0
- package/lib/commonjs/types/DatetimeMaskOptions.js.map +1 -0
- package/lib/commonjs/types/MaskConfig.js +6 -0
- package/lib/commonjs/types/MaskConfig.js.map +1 -0
- package/lib/commonjs/types/MoneyMaskOptions.js +2 -0
- package/lib/commonjs/types/MoneyMaskOptions.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/module/classes/NitroInputMaskService/NitroInputMaskService.class.js +70 -0
- package/lib/module/classes/NitroInputMaskService/NitroInputMaskService.class.js.map +1 -0
- package/lib/module/classes/NitroInputMaskService/index.js +4 -0
- package/lib/module/classes/NitroInputMaskService/index.js.map +1 -0
- package/lib/module/classes/NitroInputMaskService/types/IApplyMaskProps.js +4 -0
- package/lib/module/classes/NitroInputMaskService/types/IApplyMaskProps.js.map +1 -0
- package/lib/module/classes/NitroInputMaskService/types/index.js +2 -0
- package/lib/module/classes/NitroInputMaskService/types/index.js.map +1 -0
- package/lib/module/classes/index.js +4 -0
- package/lib/module/classes/index.js.map +1 -0
- package/lib/module/components/NitroInputMask/index.js +35 -0
- package/lib/module/components/NitroInputMask/index.js.map +1 -0
- package/lib/module/components/NitroInputMask/types/NitroInputMaskProps.js +4 -0
- package/lib/module/components/NitroInputMask/types/NitroInputMaskProps.js.map +1 -0
- package/lib/module/components/NitroInputMask/types/index.js +2 -0
- package/lib/module/components/NitroInputMask/types/index.js.map +1 -0
- package/lib/module/components/index.js +4 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/nitro-module.js +12 -0
- package/lib/module/nitro-module.js.map +1 -0
- package/lib/module/specs/nitro-input-mask-service.nitro.js +4 -0
- package/lib/module/specs/nitro-input-mask-service.nitro.js.map +1 -0
- package/lib/module/specs/nitro-input-mask.nitro.js +4 -0
- package/lib/module/specs/nitro-input-mask.nitro.js.map +1 -0
- package/lib/module/types/CreditCardMaskOptions.js +2 -0
- package/lib/module/types/CreditCardMaskOptions.js.map +1 -0
- package/lib/module/types/CustomMaskOptions.js +2 -0
- package/lib/module/types/CustomMaskOptions.js.map +1 -0
- package/lib/module/types/DatetimeMaskOptions.js +2 -0
- package/lib/module/types/DatetimeMaskOptions.js.map +1 -0
- package/lib/module/types/MaskConfig.js +4 -0
- package/lib/module/types/MaskConfig.js.map +1 -0
- package/lib/module/types/MoneyMaskOptions.js +2 -0
- package/lib/module/types/MoneyMaskOptions.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/src/classes/NitroInputMaskService/NitroInputMaskService.class.d.ts +50 -0
- package/lib/typescript/src/classes/NitroInputMaskService/NitroInputMaskService.class.d.ts.map +1 -0
- package/lib/typescript/src/classes/NitroInputMaskService/index.d.ts +3 -0
- package/lib/typescript/src/classes/NitroInputMaskService/index.d.ts.map +1 -0
- package/lib/typescript/src/classes/NitroInputMaskService/types/IApplyMaskProps.d.ts +5 -0
- package/lib/typescript/src/classes/NitroInputMaskService/types/IApplyMaskProps.d.ts.map +1 -0
- package/lib/typescript/src/classes/NitroInputMaskService/types/index.d.ts +2 -0
- package/lib/typescript/src/classes/NitroInputMaskService/types/index.d.ts.map +1 -0
- package/lib/typescript/src/classes/index.d.ts +2 -0
- package/lib/typescript/src/classes/index.d.ts.map +1 -0
- package/lib/typescript/src/components/NitroInputMask/index.d.ts +5 -0
- package/lib/typescript/src/components/NitroInputMask/index.d.ts.map +1 -0
- package/lib/typescript/src/components/NitroInputMask/types/NitroInputMaskProps.d.ts +4 -0
- package/lib/typescript/src/components/NitroInputMask/types/NitroInputMaskProps.d.ts.map +1 -0
- package/lib/typescript/src/components/NitroInputMask/types/index.d.ts +2 -0
- package/lib/typescript/src/components/NitroInputMask/types/index.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +2 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/nitro-module.d.ts +5 -0
- package/lib/typescript/src/nitro-module.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-input-mask-service.nitro.d.ts +9 -0
- package/lib/typescript/src/specs/nitro-input-mask-service.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-input-mask.nitro.d.ts +23 -0
- package/lib/typescript/src/specs/nitro-input-mask.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types/CreditCardMaskOptions.d.ts +5 -0
- package/lib/typescript/src/types/CreditCardMaskOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/CustomMaskOptions.d.ts +4 -0
- package/lib/typescript/src/types/CustomMaskOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/DatetimeMaskOptions.d.ts +4 -0
- package/lib/typescript/src/types/DatetimeMaskOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/MaskConfig.d.ts +18 -0
- package/lib/typescript/src/types/MaskConfig.d.ts.map +1 -0
- package/lib/typescript/src/types/MoneyMaskOptions.d.ts +9 -0
- package/lib/typescript/src/types/MoneyMaskOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +6 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/nitro.json +40 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroInputMask+autolinking.cmake +83 -0
- package/nitrogen/generated/android/NitroInputMask+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroInputMaskOnLoad.cpp +70 -0
- package/nitrogen/generated/android/NitroInputMaskOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMaskServiceSpec.cpp +57 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMaskServiceSpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMaskSpec.cpp +68 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputMaskSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JNitroMaskOptions.hpp +94 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinputmask/HybridNitroInputMaskServiceSpec.kt +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinputmask/HybridNitroInputMaskSpec.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinputmask/NitroInputMaskOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinputmask/NitroMaskOptions.kt +96 -0
- package/nitrogen/generated/ios/NitroInputMask+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroInputMask-Swift-Cxx-Bridge.cpp +50 -0
- package/nitrogen/generated/ios/NitroInputMask-Swift-Cxx-Bridge.hpp +124 -0
- package/nitrogen/generated/ios/NitroInputMask-Swift-Cxx-Umbrella.hpp +53 -0
- package/nitrogen/generated/ios/NitroInputMaskAutolinking.mm +41 -0
- package/nitrogen/generated/ios/NitroInputMaskAutolinking.swift +38 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMaskServiceSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMaskServiceSpecSwift.hpp +85 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMaskSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputMaskSpecSwift.hpp +101 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputMaskServiceSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputMaskServiceSpec_cxx.swift +138 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputMaskSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputMaskSpec_cxx.swift +170 -0
- package/nitrogen/generated/ios/swift/NitroMaskOptions.swift +204 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMaskServiceSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMaskServiceSpec.hpp +64 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMaskSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputMaskSpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/NitroMaskOptions.hpp +120 -0
- package/package.json +136 -0
- package/src/classes/NitroInputMaskService/NitroInputMaskService.class.ts +70 -0
- package/src/classes/NitroInputMaskService/index.ts +2 -0
- package/src/classes/NitroInputMaskService/types/IApplyMaskProps.ts +3 -0
- package/src/classes/NitroInputMaskService/types/index.ts +1 -0
- package/src/classes/index.ts +1 -0
- package/src/components/NitroInputMask/index.tsx +41 -0
- package/src/components/NitroInputMask/types/NitroInputMaskProps.ts +4 -0
- package/src/components/NitroInputMask/types/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/nitro-module.ts +14 -0
- package/src/specs/nitro-input-mask-service.nitro.ts +6 -0
- package/src/specs/nitro-input-mask.nitro.ts +25 -0
- package/src/types/CreditCardMaskOptions.ts +4 -0
- package/src/types/CustomMaskOptions.ts +3 -0
- package/src/types/DatetimeMaskOptions.ts +3 -0
- package/src/types/MaskConfig.ts +10 -0
- package/src/types/MoneyMaskOptions.ts +8 -0
- package/src/types/index.ts +5 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroInputMaskServiceSpec.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/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `NitroMaskOptions` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitroinputmask { struct NitroMaskOptions; }
|
|
18
|
+
|
|
19
|
+
#include <string>
|
|
20
|
+
#include "NitroMaskOptions.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::nitroinputmask {
|
|
23
|
+
|
|
24
|
+
using namespace margelo::nitro;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An abstract base class for `NitroInputMaskService`
|
|
28
|
+
* Inherit this class to create instances of `HybridNitroInputMaskServiceSpec` in C++.
|
|
29
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
30
|
+
* @example
|
|
31
|
+
* ```cpp
|
|
32
|
+
* class HybridNitroInputMaskService: public HybridNitroInputMaskServiceSpec {
|
|
33
|
+
* public:
|
|
34
|
+
* HybridNitroInputMaskService(...): HybridObject(TAG) { ... }
|
|
35
|
+
* // ...
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class HybridNitroInputMaskServiceSpec: public virtual HybridObject {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor
|
|
42
|
+
explicit HybridNitroInputMaskServiceSpec(): HybridObject(TAG) { }
|
|
43
|
+
|
|
44
|
+
// Destructor
|
|
45
|
+
~HybridNitroInputMaskServiceSpec() override = default;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
// Properties
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Methods
|
|
53
|
+
virtual std::string applyMask(const std::string& value, const std::string& maskType, const NitroMaskOptions& options) = 0;
|
|
54
|
+
|
|
55
|
+
protected:
|
|
56
|
+
// Hybrid Setup
|
|
57
|
+
void loadHybridMethods() override;
|
|
58
|
+
|
|
59
|
+
protected:
|
|
60
|
+
// Tag for logging
|
|
61
|
+
static constexpr auto TAG = "NitroInputMaskService";
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::nitroinputmask
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroInputMaskSpec.cpp
|
|
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
|
+
#include "HybridNitroInputMaskSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitroinputmask {
|
|
11
|
+
|
|
12
|
+
void HybridNitroInputMaskSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("attach", &HybridNitroInputMaskSpec::attach);
|
|
18
|
+
prototype.registerHybridMethod("detach", &HybridNitroInputMaskSpec::detach);
|
|
19
|
+
prototype.registerHybridMethod("updateMask", &HybridNitroInputMaskSpec::updateMask);
|
|
20
|
+
prototype.registerHybridMethod("setValue", &HybridNitroInputMaskSpec::setValue);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace margelo::nitro::nitroinputmask
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroInputMaskSpec.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/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `NitroMaskOptions` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitroinputmask { struct NitroMaskOptions; }
|
|
18
|
+
|
|
19
|
+
#include <string>
|
|
20
|
+
#include "NitroMaskOptions.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::nitroinputmask {
|
|
23
|
+
|
|
24
|
+
using namespace margelo::nitro;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An abstract base class for `NitroInputMask`
|
|
28
|
+
* Inherit this class to create instances of `HybridNitroInputMaskSpec` in C++.
|
|
29
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
30
|
+
* @example
|
|
31
|
+
* ```cpp
|
|
32
|
+
* class HybridNitroInputMask: public HybridNitroInputMaskSpec {
|
|
33
|
+
* public:
|
|
34
|
+
* HybridNitroInputMask(...): HybridObject(TAG) { ... }
|
|
35
|
+
* // ...
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class HybridNitroInputMaskSpec: public virtual HybridObject {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor
|
|
42
|
+
explicit HybridNitroInputMaskSpec(): HybridObject(TAG) { }
|
|
43
|
+
|
|
44
|
+
// Destructor
|
|
45
|
+
~HybridNitroInputMaskSpec() override = default;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
// Properties
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Methods
|
|
53
|
+
virtual void attach(const std::string& nativeID, const std::string& maskType, const NitroMaskOptions& options) = 0;
|
|
54
|
+
virtual void detach(const std::string& nativeID) = 0;
|
|
55
|
+
virtual void updateMask(const std::string& nativeID, const std::string& maskType, const NitroMaskOptions& options) = 0;
|
|
56
|
+
virtual void setValue(const std::string& nativeID, const std::string& rawValue) = 0;
|
|
57
|
+
|
|
58
|
+
protected:
|
|
59
|
+
// Hybrid Setup
|
|
60
|
+
void loadHybridMethods() override;
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
// Tag for logging
|
|
64
|
+
static constexpr auto TAG = "NitroInputMask";
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace margelo::nitro::nitroinputmask
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroMaskOptions.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
|
+
#include <optional>
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::nitroinputmask {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (NitroMaskOptions).
|
|
40
|
+
*/
|
|
41
|
+
struct NitroMaskOptions final {
|
|
42
|
+
public:
|
|
43
|
+
std::optional<std::string> mask SWIFT_PRIVATE;
|
|
44
|
+
std::optional<double> precision SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> separator SWIFT_PRIVATE;
|
|
46
|
+
std::optional<std::string> delimiter SWIFT_PRIVATE;
|
|
47
|
+
std::optional<std::string> unit SWIFT_PRIVATE;
|
|
48
|
+
std::optional<std::string> suffixUnit SWIFT_PRIVATE;
|
|
49
|
+
std::optional<bool> zeroCents SWIFT_PRIVATE;
|
|
50
|
+
std::optional<std::string> format SWIFT_PRIVATE;
|
|
51
|
+
std::optional<std::string> issuer SWIFT_PRIVATE;
|
|
52
|
+
std::optional<bool> obfuscated SWIFT_PRIVATE;
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
NitroMaskOptions() = default;
|
|
56
|
+
explicit NitroMaskOptions(std::optional<std::string> mask, std::optional<double> precision, std::optional<std::string> separator, std::optional<std::string> delimiter, std::optional<std::string> unit, std::optional<std::string> suffixUnit, std::optional<bool> zeroCents, std::optional<std::string> format, std::optional<std::string> issuer, std::optional<bool> obfuscated): mask(mask), precision(precision), separator(separator), delimiter(delimiter), unit(unit), suffixUnit(suffixUnit), zeroCents(zeroCents), format(format), issuer(issuer), obfuscated(obfuscated) {}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
friend bool operator==(const NitroMaskOptions& lhs, const NitroMaskOptions& rhs) = default;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::nitroinputmask
|
|
63
|
+
|
|
64
|
+
namespace margelo::nitro {
|
|
65
|
+
|
|
66
|
+
// C++ NitroMaskOptions <> JS NitroMaskOptions (object)
|
|
67
|
+
template <>
|
|
68
|
+
struct JSIConverter<margelo::nitro::nitroinputmask::NitroMaskOptions> final {
|
|
69
|
+
static inline margelo::nitro::nitroinputmask::NitroMaskOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
70
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
71
|
+
return margelo::nitro::nitroinputmask::NitroMaskOptions(
|
|
72
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mask"))),
|
|
73
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "precision"))),
|
|
74
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "separator"))),
|
|
75
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delimiter"))),
|
|
76
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit"))),
|
|
77
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "suffixUnit"))),
|
|
78
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "zeroCents"))),
|
|
79
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "format"))),
|
|
80
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "issuer"))),
|
|
81
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "obfuscated")))
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroinputmask::NitroMaskOptions& arg) {
|
|
85
|
+
jsi::Object obj(runtime);
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "mask"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mask));
|
|
87
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "precision"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.precision));
|
|
88
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "separator"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.separator));
|
|
89
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "delimiter"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.delimiter));
|
|
90
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "unit"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.unit));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "suffixUnit"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.suffixUnit));
|
|
92
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "zeroCents"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.zeroCents));
|
|
93
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "format"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.format));
|
|
94
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "issuer"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.issuer));
|
|
95
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "obfuscated"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.obfuscated));
|
|
96
|
+
return obj;
|
|
97
|
+
}
|
|
98
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
99
|
+
if (!value.isObject()) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
jsi::Object obj = value.getObject(runtime);
|
|
103
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mask")))) return false;
|
|
107
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "precision")))) return false;
|
|
108
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "separator")))) return false;
|
|
109
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delimiter")))) return false;
|
|
110
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit")))) return false;
|
|
111
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "suffixUnit")))) return false;
|
|
112
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "zeroCents")))) return false;
|
|
113
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "format")))) return false;
|
|
114
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "issuer")))) return false;
|
|
115
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "obfuscated")))) return false;
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
} // namespace margelo::nitro
|
package/package.json
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salve-software/react-native-nitro-input-mask",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "High-performance native input masks for React Native built with Nitro Modules. Phone, currency, CPF, credit card and custom masks with zero JS flicker.",
|
|
5
|
+
"main": "./lib/commonjs/index.js",
|
|
6
|
+
"module": "./lib/module/index.js",
|
|
7
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"clean": "git clean -dfX",
|
|
13
|
+
"release": "semantic-release",
|
|
14
|
+
"build": "yarn typecheck && bob build",
|
|
15
|
+
"codegen": "nitrogen --logLevel=\"debug\" && yarn build && node post-script.js",
|
|
16
|
+
"example": "yarn workspace react-native-nitro-input-mask-example"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"react-native-nitro-input-mask",
|
|
21
|
+
"input-mask",
|
|
22
|
+
"input",
|
|
23
|
+
"mask",
|
|
24
|
+
"text-input",
|
|
25
|
+
"react-native-mask",
|
|
26
|
+
"react-native-input-mask",
|
|
27
|
+
"nitro-modules",
|
|
28
|
+
"nitro-module",
|
|
29
|
+
"native-module",
|
|
30
|
+
"formatter",
|
|
31
|
+
"currency-mask",
|
|
32
|
+
"phone-mask"
|
|
33
|
+
],
|
|
34
|
+
"files": [
|
|
35
|
+
"src",
|
|
36
|
+
"react-native.config.js",
|
|
37
|
+
"lib",
|
|
38
|
+
"nitrogen",
|
|
39
|
+
"cpp",
|
|
40
|
+
"nitro.json",
|
|
41
|
+
"android/build.gradle",
|
|
42
|
+
"android/fix-prefab.gradle",
|
|
43
|
+
"android/gradle.properties",
|
|
44
|
+
"android/CMakeLists.txt",
|
|
45
|
+
"android/src",
|
|
46
|
+
"ios/**/*.h",
|
|
47
|
+
"ios/**/*.m",
|
|
48
|
+
"ios/**/*.mm",
|
|
49
|
+
"ios/**/*.cpp",
|
|
50
|
+
"ios/**/*.swift",
|
|
51
|
+
"app.plugin.js",
|
|
52
|
+
"*.podspec",
|
|
53
|
+
"README.md"
|
|
54
|
+
],
|
|
55
|
+
"packageManager": "yarn@4.9.1",
|
|
56
|
+
"workspaces": [
|
|
57
|
+
"example"
|
|
58
|
+
],
|
|
59
|
+
"repository": "https://github.com/Salve-Software/react-native-nitro-input-mask.git",
|
|
60
|
+
"author": "salvesoftware",
|
|
61
|
+
"license": "MIT",
|
|
62
|
+
"bugs": "https://github.com/Salve-Software/react-native-nitro-input-mask/issues",
|
|
63
|
+
"homepage": "https://github.com/Salve-Software/react-native-nitro-input-mask#readme",
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
66
|
+
"registry": "https://registry.npmjs.org/"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
|
|
70
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
71
|
+
"@semantic-release/git": "^10.0.1",
|
|
72
|
+
"@types/jest": "^29.5.12",
|
|
73
|
+
"@types/react": "19.2.0",
|
|
74
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
75
|
+
"nitrogen": "0.35.6",
|
|
76
|
+
"react": "19.2.3",
|
|
77
|
+
"react-native": "0.84.1",
|
|
78
|
+
"react-native-builder-bob": "^0.40.18",
|
|
79
|
+
"react-native-nitro-modules": "0.35.6",
|
|
80
|
+
"semantic-release": "^25.0.3",
|
|
81
|
+
"typescript": "^5.8.3"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"react": "*",
|
|
85
|
+
"react-native": "*",
|
|
86
|
+
"react-native-nitro-modules": "*"
|
|
87
|
+
},
|
|
88
|
+
"eslintConfig": {
|
|
89
|
+
"root": true,
|
|
90
|
+
"extends": [
|
|
91
|
+
"@react-native",
|
|
92
|
+
"prettier"
|
|
93
|
+
],
|
|
94
|
+
"plugins": [
|
|
95
|
+
"prettier"
|
|
96
|
+
],
|
|
97
|
+
"rules": {
|
|
98
|
+
"prettier/prettier": [
|
|
99
|
+
"warn",
|
|
100
|
+
{
|
|
101
|
+
"quoteProps": "consistent",
|
|
102
|
+
"singleQuote": true,
|
|
103
|
+
"tabWidth": 2,
|
|
104
|
+
"trailingComma": "es5",
|
|
105
|
+
"useTabs": false
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"eslintIgnore": [
|
|
111
|
+
"node_modules/",
|
|
112
|
+
"lib/"
|
|
113
|
+
],
|
|
114
|
+
"prettier": {
|
|
115
|
+
"quoteProps": "consistent",
|
|
116
|
+
"singleQuote": true,
|
|
117
|
+
"tabWidth": 2,
|
|
118
|
+
"trailingComma": "es5",
|
|
119
|
+
"useTabs": false,
|
|
120
|
+
"semi": false
|
|
121
|
+
},
|
|
122
|
+
"react-native-builder-bob": {
|
|
123
|
+
"source": "src",
|
|
124
|
+
"output": "lib",
|
|
125
|
+
"targets": [
|
|
126
|
+
"commonjs",
|
|
127
|
+
"module",
|
|
128
|
+
[
|
|
129
|
+
"typescript",
|
|
130
|
+
{
|
|
131
|
+
"project": "tsconfig.json"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { IApplyMaskProps } from './types';
|
|
2
|
+
import { getNitroServiceModule } from '../../nitro-module';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Standalone service for applying input masks natively.
|
|
6
|
+
*
|
|
7
|
+
* Runs the same mask engine used by `<NitroInputMask />`, but as a
|
|
8
|
+
* plain function call — no component or ref required.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const masked = NitroInputMaskService.applyMask({
|
|
12
|
+
* value: '12345678901',
|
|
13
|
+
* maskOptions: { mask: '999.999.999-99' },
|
|
14
|
+
* })
|
|
15
|
+
* // '123.456.789-01'
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const masked = NitroInputMaskService.applyMask({
|
|
19
|
+
* value: '123456',
|
|
20
|
+
* maskType: 'money',
|
|
21
|
+
* maskOptions: { unit: 'R$ ', precision: 2 },
|
|
22
|
+
* })
|
|
23
|
+
* // 'R$ 1.234,56'
|
|
24
|
+
*/
|
|
25
|
+
export class NitroInputMaskService {
|
|
26
|
+
/**
|
|
27
|
+
* Applies a mask to a string and returns the masked result.
|
|
28
|
+
*
|
|
29
|
+
* For `custom` masks, tokens are:
|
|
30
|
+
* - `9` — digit (0–9)
|
|
31
|
+
* - `A` — letter (a–z, A–Z)
|
|
32
|
+
* - `*` — letter or digit
|
|
33
|
+
* - `[n-m]` — integer in the inclusive range n–m (e.g. `[1-12]`, `[1-31]`)
|
|
34
|
+
* - Any other character — treated as a literal and inserted as-is
|
|
35
|
+
*
|
|
36
|
+
* @param props.value - The raw string to mask.
|
|
37
|
+
* @param props.maskType - The mask type: `'custom'` (default), `'money'`, `'datetime'`, `'credit-card'`.
|
|
38
|
+
* @param props.maskOptions - Options specific to the chosen mask type.
|
|
39
|
+
* @returns The masked string.
|
|
40
|
+
*
|
|
41
|
+
* @throws If `value` exceeds 1000 characters or `custom` mask exceeds 200 characters.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* NitroInputMaskService.applyMask({
|
|
45
|
+
* value: '11987654321',
|
|
46
|
+
* maskOptions: { mask: '(99) 99999-9999' },
|
|
47
|
+
* })
|
|
48
|
+
* // '(11) 98765-4321'
|
|
49
|
+
*/
|
|
50
|
+
static applyMask = (props: IApplyMaskProps): string => {
|
|
51
|
+
const { value, maskType, maskOptions } = props as IApplyMaskProps & {
|
|
52
|
+
maskType?: string;
|
|
53
|
+
maskOptions?: Record<string, unknown>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const resolvedValue = String(value ?? '');
|
|
57
|
+
const resolvedMaskType = maskType ?? 'custom';
|
|
58
|
+
const resolvedOptions = maskOptions ?? {};
|
|
59
|
+
|
|
60
|
+
if (resolvedMaskType === 'custom') {
|
|
61
|
+
const mask = String((resolvedOptions as { mask?: string }).mask ?? '');
|
|
62
|
+
if (!mask) return resolvedValue;
|
|
63
|
+
if (resolvedValue.length > 1000 || mask.length > 200) {
|
|
64
|
+
throw new Error('NitroInputMaskService: value or mask exceeds maximum allowed length');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return getNitroServiceModule().applyMask(resolvedValue, resolvedMaskType, resolvedOptions);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './IApplyMaskProps';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NitroInputMaskService';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { NitroInputMaskProps } from './types';
|
|
2
|
+
import React, { useEffect, useId } from 'react';
|
|
3
|
+
import { TextInput } from 'react-native';
|
|
4
|
+
import { nitroModule } from '../../nitro-module';
|
|
5
|
+
|
|
6
|
+
export const NitroInputMask = (props: NitroInputMaskProps) => {
|
|
7
|
+
const { maskType, maskOptions, value, ...rest } = props as NitroInputMaskProps & {
|
|
8
|
+
maskType?: string;
|
|
9
|
+
maskOptions?: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const resolvedMaskType = maskType ?? 'custom';
|
|
13
|
+
const reactId = useId();
|
|
14
|
+
const id = `nitro-input-mask-${reactId}`;
|
|
15
|
+
|
|
16
|
+
const maskOptionsJson = JSON.stringify(maskOptions ?? {});
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
nitroModule.attach(id, resolvedMaskType, maskOptions ?? {});
|
|
20
|
+
if (value != null) nitroModule.setValue(id, String(value));
|
|
21
|
+
return () => nitroModule.detach(id);
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
nitroModule.updateMask(id, resolvedMaskType, maskOptions ?? {});
|
|
26
|
+
}, [resolvedMaskType, maskOptionsJson]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (value == null) return;
|
|
30
|
+
nitroModule.setValue(id, String(value));
|
|
31
|
+
}, [value]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<TextInput
|
|
35
|
+
{...rest}
|
|
36
|
+
nativeID={id}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type * from './types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './NitroInputMaskProps';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NitroInputMask';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NitroInputMask as NitroInputMaskModule } from './specs/nitro-input-mask.nitro';
|
|
2
|
+
import type { NitroInputMaskService as NitroInputMaskServiceSpec } from './specs/nitro-input-mask-service.nitro';
|
|
3
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
4
|
+
|
|
5
|
+
export const nitroModule = NitroModules.createHybridObject<NitroInputMaskModule>('NitroInputMask');
|
|
6
|
+
let _nitroServiceModule: NitroInputMaskServiceSpec | null = null;
|
|
7
|
+
|
|
8
|
+
export const getNitroServiceModule = () => {
|
|
9
|
+
if (!_nitroServiceModule) {
|
|
10
|
+
_nitroServiceModule = NitroModules.createHybridObject<NitroInputMaskServiceSpec>('NitroInputMaskService');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return _nitroServiceModule;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules'
|
|
2
|
+
import type { NitroMaskOptions } from './nitro-input-mask.nitro'
|
|
3
|
+
|
|
4
|
+
export interface NitroInputMaskService extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
5
|
+
applyMask(value: string, maskType: string, options: NitroMaskOptions): string
|
|
6
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules'
|
|
2
|
+
|
|
3
|
+
export interface NitroMaskOptions {
|
|
4
|
+
// custom
|
|
5
|
+
mask?: string
|
|
6
|
+
// money
|
|
7
|
+
precision?: number
|
|
8
|
+
separator?: string
|
|
9
|
+
delimiter?: string
|
|
10
|
+
unit?: string
|
|
11
|
+
suffixUnit?: string
|
|
12
|
+
zeroCents?: boolean
|
|
13
|
+
// datetime
|
|
14
|
+
format?: string
|
|
15
|
+
// credit-card
|
|
16
|
+
issuer?: string
|
|
17
|
+
obfuscated?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface NitroInputMask extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
21
|
+
attach(nativeID: string, maskType: string, options: NitroMaskOptions): void
|
|
22
|
+
detach(nativeID: string): void
|
|
23
|
+
updateMask(nativeID: string, maskType: string, options: NitroMaskOptions): void
|
|
24
|
+
setValue(nativeID: string, rawValue: string): void
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CreditCardMaskOptions } from "./CreditCardMaskOptions";
|
|
2
|
+
import type { CustomMaskOptions } from "./CustomMaskOptions";
|
|
3
|
+
import type { DatetimeMaskOptions } from "./DatetimeMaskOptions";
|
|
4
|
+
import type { MoneyMaskOptions } from "./MoneyMaskOptions";
|
|
5
|
+
|
|
6
|
+
export type MaskConfig =
|
|
7
|
+
| { maskType?: 'custom'; maskOptions: CustomMaskOptions }
|
|
8
|
+
| { maskType: 'money'; maskOptions?: MoneyMaskOptions }
|
|
9
|
+
| { maskType: 'datetime'; maskOptions: DatetimeMaskOptions }
|
|
10
|
+
| { maskType: 'credit-card'; maskOptions?: CreditCardMaskOptions }
|