@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 salvesoftware
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "NitroInputMask"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
|
|
14
|
+
s.source = { :git => "https://github.com/Salve-Software/react-native-nitro-input-mask.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = [
|
|
17
|
+
# Implementation (Swift)
|
|
18
|
+
"ios/**/*.{swift}",
|
|
19
|
+
# Autolinking/Registration (Objective-C++)
|
|
20
|
+
"ios/**/*.{m,mm}",
|
|
21
|
+
# Implementation (C++ objects)
|
|
22
|
+
"cpp/**/*.{hpp,cpp}",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
load 'nitrogen/generated/ios/NitroInputMask+autolinking.rb'
|
|
26
|
+
add_nitrogen_files(s)
|
|
27
|
+
|
|
28
|
+
s.dependency 'React-jsi'
|
|
29
|
+
s.dependency 'React-callinvoker'
|
|
30
|
+
install_modules_dependencies(s)
|
|
31
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# react-native-nitro-input-mask
|
|
2
|
+
|
|
3
|
+
Native input masks for React Native — zero JS flicker, built on [Nitro Modules](https://github.com/mrousavy/nitro).
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/react-native-nitro-input-mask)
|
|
6
|
+
[](https://www.npmjs.com/package/react-native-nitro-input-mask)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="./assets/demo.gif" width="320" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why
|
|
16
|
+
|
|
17
|
+
Most React Native mask libraries apply the mask in JavaScript — every keystroke crosses the bridge before the field is updated, causing a visible flicker.
|
|
18
|
+
|
|
19
|
+
`react-native-nitro-input-mask` runs the entire mask engine natively (Swift on iOS, Kotlin on Android) via Nitro Modules, so the field is updated synchronously with no flicker.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Zero flicker** — mask applied synchronously on the native side
|
|
24
|
+
- **`<NitroInputMask />`** — drop-in replacement for React Native's `<TextInput />`
|
|
25
|
+
- **`NitroInputMaskService`** — apply a mask to any string without a component
|
|
26
|
+
- **Built-in mask types** — `custom`, `money`, `datetime`, `credit-card`
|
|
27
|
+
- **Range tokens** — e.g. `[1-12]` for month, `[1-31]` for day
|
|
28
|
+
- iOS and Android support
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
| | Minimum |
|
|
33
|
+
|---|---|
|
|
34
|
+
| React Native | 0.78 |
|
|
35
|
+
| Node | 18 |
|
|
36
|
+
|
|
37
|
+
> **New Architecture only.** The Old Architecture is not supported.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm install react-native-nitro-input-mask react-native-nitro-modules
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
yarn add react-native-nitro-input-mask react-native-nitro-modules
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
bun add react-native-nitro-input-mask react-native-nitro-modules
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### iOS
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
cd ios && pod install
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
### `<NitroInputMask />`
|
|
62
|
+
|
|
63
|
+
Drop-in replacement for `<TextInput />`. Accepts all standard `TextInputProps` plus `maskType` and `maskOptions`.
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import React, { useState } from 'react'
|
|
67
|
+
import { NitroInputMask } from 'react-native-nitro-input-mask'
|
|
68
|
+
|
|
69
|
+
function PhoneInput() {
|
|
70
|
+
const [value, setValue] = useState('')
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<NitroInputMask
|
|
74
|
+
maskOptions={{ mask: '(999) 999-9999' }}
|
|
75
|
+
placeholder="(555) 000-0000"
|
|
76
|
+
keyboardType="numeric"
|
|
77
|
+
onChangeText={setValue}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Money
|
|
85
|
+
<NitroInputMask
|
|
86
|
+
maskType="money"
|
|
87
|
+
maskOptions={{ unit: '$ ', precision: 2 }}
|
|
88
|
+
keyboardType="numeric"
|
|
89
|
+
onChangeText={setValue}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
// Date
|
|
93
|
+
<NitroInputMask
|
|
94
|
+
maskType="datetime"
|
|
95
|
+
maskOptions={{ format: 'MM/DD/YYYY' }}
|
|
96
|
+
keyboardType="numeric"
|
|
97
|
+
onChangeText={setValue}
|
|
98
|
+
/>
|
|
99
|
+
|
|
100
|
+
// Credit card
|
|
101
|
+
<NitroInputMask
|
|
102
|
+
maskType="credit-card"
|
|
103
|
+
maskOptions={{ issuer: 'visa-or-mastercard' }}
|
|
104
|
+
keyboardType="numeric"
|
|
105
|
+
onChangeText={setValue}
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `NitroInputMaskService`
|
|
110
|
+
|
|
111
|
+
Apply a mask to any string — useful for formatting values in lists, previews, etc.
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { NitroInputMaskService } from 'react-native-nitro-input-mask'
|
|
115
|
+
|
|
116
|
+
NitroInputMaskService.applyMask({
|
|
117
|
+
value: '5551234567',
|
|
118
|
+
maskOptions: { mask: '(999) 999-9999' },
|
|
119
|
+
})
|
|
120
|
+
// '(555) 123-4567'
|
|
121
|
+
|
|
122
|
+
NitroInputMaskService.applyMask({
|
|
123
|
+
value: '123456',
|
|
124
|
+
maskType: 'money',
|
|
125
|
+
maskOptions: { unit: '$ ', precision: 2 },
|
|
126
|
+
})
|
|
127
|
+
// '$ 1,234.56'
|
|
128
|
+
|
|
129
|
+
NitroInputMaskService.applyMask({
|
|
130
|
+
value: '06252025',
|
|
131
|
+
maskType: 'datetime',
|
|
132
|
+
maskOptions: { format: 'MM/DD/YYYY' },
|
|
133
|
+
})
|
|
134
|
+
// '06/25/2025'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Mask Syntax
|
|
138
|
+
|
|
139
|
+
| Token | Accepts |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `9` | Digit (0–9) |
|
|
142
|
+
| `A` | Letter (a–z, A–Z) |
|
|
143
|
+
| `*` | Letter or digit |
|
|
144
|
+
| `[n-m]` | Integer in range n–m (e.g. `[1-12]`, `[1-31]`) |
|
|
145
|
+
| Any other character | Literal — inserted as-is |
|
|
146
|
+
|
|
147
|
+
## API
|
|
148
|
+
|
|
149
|
+
### `<NitroInputMask />`
|
|
150
|
+
|
|
151
|
+
Extends React Native's [`TextInputProps`](https://reactnative.dev/docs/textinput#props).
|
|
152
|
+
|
|
153
|
+
| maskType | maskOptions | Docs |
|
|
154
|
+
|---|---|---|
|
|
155
|
+
| `'custom'` (default) | `{ mask: string }` | [docs/custom.md](./docs/custom.md) |
|
|
156
|
+
| `'money'` | `{ precision?, separator?, delimiter?, unit?, suffixUnit?, zeroCents? }` | [docs/money.md](./docs/money.md) |
|
|
157
|
+
| `'datetime'` | `{ format: string }` | [docs/datetime.md](./docs/datetime.md) |
|
|
158
|
+
| `'credit-card'` | `{ issuer?, obfuscated? }` | [docs/credit-card.md](./docs/credit-card.md) |
|
|
159
|
+
|
|
160
|
+
### `NitroInputMaskService.applyMask(props)`
|
|
161
|
+
|
|
162
|
+
| Prop | Type | Description |
|
|
163
|
+
|---|---|---|
|
|
164
|
+
| `value` | `string` | The raw string to mask |
|
|
165
|
+
| `maskType` | `'custom' \| 'money' \| 'datetime' \| 'credit-card'` | Mask type (default `'custom'`) |
|
|
166
|
+
| `maskOptions` | See table above | Options for the chosen mask type |
|
|
167
|
+
|
|
168
|
+
Returns the masked `string`.
|
|
169
|
+
|
|
170
|
+
## Contributing
|
|
171
|
+
|
|
172
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.
|
|
173
|
+
|
|
174
|
+
1. Fork the repo
|
|
175
|
+
2. Create your branch: `git checkout -b feat/your-feature`
|
|
176
|
+
3. Commit your changes following [Conventional Commits](https://www.conventionalcommits.org/)
|
|
177
|
+
4. Open a pull request
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
MIT © [Salve Software](https://github.com/Salve-Software)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
project(NitroInputMask)
|
|
2
|
+
cmake_minimum_required(VERSION 3.9.0)
|
|
3
|
+
|
|
4
|
+
set (PACKAGE_NAME NitroInputMask)
|
|
5
|
+
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set (CMAKE_CXX_STANDARD 20)
|
|
7
|
+
|
|
8
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
9
|
+
add_compile_options(-DRN_SERIALIZABLE_STATE=1)
|
|
10
|
+
|
|
11
|
+
# Define C++ library and add all sources
|
|
12
|
+
add_library(${PACKAGE_NAME} SHARED
|
|
13
|
+
src/main/cpp/cpp-adapter.cpp
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# Add Nitrogen specs :)
|
|
17
|
+
include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroInputMask+autolinking.cmake)
|
|
18
|
+
|
|
19
|
+
# Set up local includes
|
|
20
|
+
include_directories(
|
|
21
|
+
"src/main/cpp"
|
|
22
|
+
"../cpp"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
find_library(LOG_LIB log)
|
|
26
|
+
|
|
27
|
+
# Link all libraries together
|
|
28
|
+
target_link_libraries(
|
|
29
|
+
${PACKAGE_NAME}
|
|
30
|
+
${LOG_LIB}
|
|
31
|
+
android # <-- Android core
|
|
32
|
+
)
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.8.0"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def reactNativeArchitectures() {
|
|
13
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
14
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
23
|
+
apply from: '../nitrogen/generated/android/NitroInputMask+autolinking.gradle'
|
|
24
|
+
apply from: "./fix-prefab.gradle"
|
|
25
|
+
|
|
26
|
+
if (isNewArchitectureEnabled()) {
|
|
27
|
+
apply plugin: "com.facebook.react"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def getExtOrDefault(name) {
|
|
31
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["NitroInputMask_" + name]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def getExtOrIntegerDefault(name) {
|
|
35
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NitroInputMask_" + name]).toInteger()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
android {
|
|
39
|
+
namespace "com.nitroinputmask"
|
|
40
|
+
|
|
41
|
+
ndkVersion getExtOrDefault("ndkVersion")
|
|
42
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
43
|
+
|
|
44
|
+
defaultConfig {
|
|
45
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
46
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
47
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
48
|
+
|
|
49
|
+
externalNativeBuild {
|
|
50
|
+
cmake {
|
|
51
|
+
cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
|
|
52
|
+
arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
53
|
+
abiFilters (*reactNativeArchitectures())
|
|
54
|
+
|
|
55
|
+
buildTypes {
|
|
56
|
+
debug {
|
|
57
|
+
cppFlags "-O1 -g"
|
|
58
|
+
}
|
|
59
|
+
release {
|
|
60
|
+
cppFlags "-O2"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
externalNativeBuild {
|
|
68
|
+
cmake {
|
|
69
|
+
path "CMakeLists.txt"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
packagingOptions {
|
|
74
|
+
excludes = [
|
|
75
|
+
"META-INF",
|
|
76
|
+
"META-INF/**",
|
|
77
|
+
"**/libc++_shared.so",
|
|
78
|
+
"**/libfbjni.so",
|
|
79
|
+
"**/libjsi.so",
|
|
80
|
+
"**/libfolly_json.so",
|
|
81
|
+
"**/libfolly_runtime.so",
|
|
82
|
+
"**/libglog.so",
|
|
83
|
+
"**/libhermes.so",
|
|
84
|
+
"**/libhermes-executor-debug.so",
|
|
85
|
+
"**/libhermes_executor.so",
|
|
86
|
+
"**/libreactnative.so",
|
|
87
|
+
"**/libreactnativejni.so",
|
|
88
|
+
"**/libturbomodulejsijni.so",
|
|
89
|
+
"**/libreact_nativemodule_core.so",
|
|
90
|
+
"**/libjscexecutor.so"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
buildFeatures {
|
|
95
|
+
buildConfig true
|
|
96
|
+
prefab true
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
buildTypes {
|
|
100
|
+
release {
|
|
101
|
+
minifyEnabled false
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
lintOptions {
|
|
106
|
+
disable "GradleCompatible"
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
compileOptions {
|
|
110
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
111
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
sourceSets {
|
|
115
|
+
main {
|
|
116
|
+
if (isNewArchitectureEnabled()) {
|
|
117
|
+
java.srcDirs += [
|
|
118
|
+
// React Codegen files
|
|
119
|
+
"${project.buildDir}/generated/source/codegen/java"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
repositories {
|
|
127
|
+
mavenCentral()
|
|
128
|
+
google()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
dependencies {
|
|
133
|
+
// For < 0.71, this will be from the local maven repo
|
|
134
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
135
|
+
//noinspection GradleDynamicVersion
|
|
136
|
+
implementation "com.facebook.react:react-native:+"
|
|
137
|
+
|
|
138
|
+
// Add a dependency on NitroModules
|
|
139
|
+
implementation project(":react-native-nitro-modules")
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (isNewArchitectureEnabled()) {
|
|
143
|
+
react {
|
|
144
|
+
jsRootDir = file("../src/")
|
|
145
|
+
libraryName = "NitroInputMask"
|
|
146
|
+
codegenJavaPackageName = "com.nitroinputmask"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
tasks.configureEach { task ->
|
|
2
|
+
// Make sure that we generate our prefab publication file only after having built the native library
|
|
3
|
+
// so that not a header publication file, but a full configuration publication will be generated, which
|
|
4
|
+
// will include the .so file
|
|
5
|
+
|
|
6
|
+
def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
|
|
7
|
+
def matcher = task.name =~ prefabConfigurePattern
|
|
8
|
+
if (matcher.matches()) {
|
|
9
|
+
def variantName = matcher[0][1]
|
|
10
|
+
task.outputs.upToDateWhen { false }
|
|
11
|
+
task.dependsOn("externalNativeBuild${variantName}")
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
afterEvaluate {
|
|
16
|
+
def abis = reactNativeArchitectures()
|
|
17
|
+
rootProject.allprojects.each { proj ->
|
|
18
|
+
if (proj === rootProject) return
|
|
19
|
+
|
|
20
|
+
def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
|
|
21
|
+
config.dependencies.any { dep ->
|
|
22
|
+
dep.group == project.group && dep.name == project.name
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!dependsOnThisLib && proj != project) return
|
|
26
|
+
|
|
27
|
+
if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
|
|
32
|
+
// Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
|
|
33
|
+
// generate a libnameConfig.cmake file that will contain our native library (.so).
|
|
34
|
+
// See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
|
|
35
|
+
variants.all { variant ->
|
|
36
|
+
def variantName = variant.name
|
|
37
|
+
abis.each { abi ->
|
|
38
|
+
def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
|
|
39
|
+
if (!searchDir.exists()) return
|
|
40
|
+
def matches = []
|
|
41
|
+
searchDir.eachDir { randomDir ->
|
|
42
|
+
def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
|
|
43
|
+
if (prefabFile.exists()) matches << prefabFile
|
|
44
|
+
}
|
|
45
|
+
matches.each { prefabConfig ->
|
|
46
|
+
prefabConfig.setLastModified(System.currentTimeMillis())
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
package com.nitroinputmask
|
|
2
|
+
|
|
3
|
+
import android.os.Handler
|
|
4
|
+
import android.os.Looper
|
|
5
|
+
import android.view.View
|
|
6
|
+
import android.view.ViewGroup
|
|
7
|
+
import android.widget.EditText
|
|
8
|
+
import android.widget.TextView
|
|
9
|
+
import androidx.annotation.Keep
|
|
10
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
11
|
+
import com.margelo.nitro.nitroinputmask.HybridNitroInputMaskSpec
|
|
12
|
+
import com.margelo.nitro.nitroinputmask.NitroMaskOptions
|
|
13
|
+
import com.nitroinputmask.engine.MaskEngineFactory
|
|
14
|
+
import com.nitroinputmask.engine.MaskEngineProtocol
|
|
15
|
+
import java.lang.ref.WeakReference
|
|
16
|
+
|
|
17
|
+
private const val ATTACH_RETRIES = 5
|
|
18
|
+
private const val ATTACH_RETRY_DELAY_MS = 50L
|
|
19
|
+
|
|
20
|
+
@Keep
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
class HybridNitroInputMaskModule : HybridNitroInputMaskSpec() {
|
|
23
|
+
private data class MaskState(
|
|
24
|
+
val editTextRef: WeakReference<EditText>,
|
|
25
|
+
val watcher: NitroInputMaskTextWatcher
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
private val states = mutableMapOf<String, MaskState>()
|
|
29
|
+
|
|
30
|
+
override fun attach(nativeID: String, maskType: String, options: NitroMaskOptions) {
|
|
31
|
+
val engine = MaskEngineFactory.build(maskType, options)
|
|
32
|
+
attemptAttach(nativeID, engine, ATTACH_RETRIES)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private fun attemptAttach(nativeID: String, engine: MaskEngineProtocol, retries: Int) {
|
|
36
|
+
val context = NitroInputMaskContext.reactContext ?: return
|
|
37
|
+
context.currentActivity?.runOnUiThread {
|
|
38
|
+
val root = context.currentActivity?.window?.decorView ?: return@runOnUiThread
|
|
39
|
+
val editText = findEditText(root, nativeID)
|
|
40
|
+
if (editText != null) {
|
|
41
|
+
val watcher = NitroInputMaskTextWatcher(engine, editText)
|
|
42
|
+
states[nativeID] = MaskState(WeakReference(editText), watcher)
|
|
43
|
+
insertWatcherFirst(editText, watcher)
|
|
44
|
+
} else if (retries > 0) {
|
|
45
|
+
Handler(Looper.getMainLooper()).postDelayed(
|
|
46
|
+
{ attemptAttach(nativeID, engine, retries - 1) },
|
|
47
|
+
ATTACH_RETRY_DELAY_MS
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override fun detach(nativeID: String) {
|
|
54
|
+
val state = states.remove(nativeID) ?: return
|
|
55
|
+
NitroInputMaskContext.reactContext?.currentActivity?.runOnUiThread {
|
|
56
|
+
state.editTextRef.get()?.removeTextChangedListener(state.watcher)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override fun updateMask(nativeID: String, maskType: String, options: NitroMaskOptions) {
|
|
61
|
+
val engine = MaskEngineFactory.build(maskType, options)
|
|
62
|
+
states[nativeID]?.watcher?.engine = engine
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun setValue(nativeID: String, rawValue: String) {
|
|
66
|
+
val state = states[nativeID] ?: return
|
|
67
|
+
val editText = state.editTextRef.get() ?: return
|
|
68
|
+
val (masked, _) = state.watcher.engine.apply(rawValue)
|
|
69
|
+
NitroInputMaskContext.reactContext?.currentActivity?.runOnUiThread {
|
|
70
|
+
if (editText.text.toString() == masked) return@runOnUiThread
|
|
71
|
+
state.watcher.isProgrammatic = true
|
|
72
|
+
editText.setText(masked)
|
|
73
|
+
if (state.watcher.engine.wantsTrailingCursor) {
|
|
74
|
+
editText.setSelection(editText.text.length)
|
|
75
|
+
} else {
|
|
76
|
+
editText.setSelection(editText.text.length)
|
|
77
|
+
}
|
|
78
|
+
state.watcher.isProgrammatic = false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private fun findEditText(root: View, nativeID: String): EditText? {
|
|
83
|
+
val tag = root.getTag(com.facebook.react.R.id.view_tag_native_id)
|
|
84
|
+
if (root is EditText && tag == nativeID) return root
|
|
85
|
+
if (root is ViewGroup) {
|
|
86
|
+
for (i in 0 until root.childCount) {
|
|
87
|
+
findEditText(root.getChildAt(i), nativeID)?.let { return it }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Suppress("UNCHECKED_CAST")
|
|
94
|
+
private fun insertWatcherFirst(editText: EditText, watcher: NitroInputMaskTextWatcher) {
|
|
95
|
+
// Insert at index 0 so our watcher runs before React Native's own TextWatcher,
|
|
96
|
+
// ensuring the mask is applied before RN reads the new text.
|
|
97
|
+
try {
|
|
98
|
+
val field = TextView::class.java.getDeclaredField("mListeners")
|
|
99
|
+
field.isAccessible = true
|
|
100
|
+
val listeners = field.get(editText) as? ArrayList<android.text.TextWatcher>
|
|
101
|
+
if (listeners != null) {
|
|
102
|
+
listeners.add(0, watcher)
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
} catch (_: Exception) {}
|
|
106
|
+
editText.addTextChangedListener(watcher)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.nitroinputmask
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.NativeModule
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
6
|
+
import com.facebook.react.BaseReactPackage
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
import com.margelo.nitro.nitroinputmask.NitroInputMaskOnLoad
|
|
9
|
+
|
|
10
|
+
class NitroInputMaskPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
|
|
16
|
+
emptyMap()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
20
|
+
NitroInputMaskContext.reactContext = reactContext
|
|
21
|
+
return emptyList()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
companion object {
|
|
25
|
+
init {
|
|
26
|
+
NitroInputMaskOnLoad.initializeNative()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.nitroinputmask
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Keep
|
|
4
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
5
|
+
import com.margelo.nitro.nitroinputmask.HybridNitroInputMaskServiceSpec
|
|
6
|
+
import com.margelo.nitro.nitroinputmask.NitroMaskOptions
|
|
7
|
+
import com.nitroinputmask.engine.MaskEngineFactory
|
|
8
|
+
|
|
9
|
+
@Keep
|
|
10
|
+
@DoNotStrip
|
|
11
|
+
class HybridNitroInputMaskServiceModule : HybridNitroInputMaskServiceSpec() {
|
|
12
|
+
override fun applyMask(value: String, maskType: String, options: NitroMaskOptions): String {
|
|
13
|
+
val engine = MaskEngineFactory.build(maskType, options)
|
|
14
|
+
val (masked, _) = engine.apply(value)
|
|
15
|
+
return masked
|
|
16
|
+
}
|
|
17
|
+
}
|