@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,46 @@
|
|
|
1
|
+
import NitroModules
|
|
2
|
+
|
|
3
|
+
struct DatetimeMaskEngine: MaskEngineProtocol {
|
|
4
|
+
private let compiled: CompiledMask
|
|
5
|
+
|
|
6
|
+
init(format: String) {
|
|
7
|
+
let pattern = DatetimeMaskEngine.formatToPattern(format)
|
|
8
|
+
self.compiled = MaskEngine.compile(mask: pattern)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
func apply(input: String) -> (masked: String, raw: String) {
|
|
12
|
+
return MaskEngine.apply(input: input, compiled: compiled)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var wantsTrailingCursor: Bool { false }
|
|
16
|
+
var expandedMask: String? { compiled.expandedMask }
|
|
17
|
+
|
|
18
|
+
// MARK: - Format → Pattern conversion
|
|
19
|
+
|
|
20
|
+
private static let tokens: [(token: String, pattern: String)] = [
|
|
21
|
+
("YYYY", "9999"),
|
|
22
|
+
("MM", "[1-12]"),
|
|
23
|
+
("DD", "[1-31]"),
|
|
24
|
+
("HH", "[0-23]"),
|
|
25
|
+
("hh", "[1-12]"),
|
|
26
|
+
("mm", "[0-59]"),
|
|
27
|
+
("ss", "[0-59]"),
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
private static func formatToPattern(_ format: String) -> String {
|
|
31
|
+
var result = ""
|
|
32
|
+
var i = format.startIndex
|
|
33
|
+
|
|
34
|
+
while i < format.endIndex {
|
|
35
|
+
if let match = tokens.first(where: { format[i...].hasPrefix($0.token) }) {
|
|
36
|
+
result += match.pattern
|
|
37
|
+
i = format.index(i, offsetBy: match.token.count)
|
|
38
|
+
} else {
|
|
39
|
+
result.append(format[i])
|
|
40
|
+
i = format.index(after: i)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import NitroModules
|
|
2
|
+
|
|
3
|
+
struct MoneyMaskEngine: MaskEngineProtocol {
|
|
4
|
+
private let precision: Int
|
|
5
|
+
private let separator: String
|
|
6
|
+
private let delimiter: String
|
|
7
|
+
private let unit: String
|
|
8
|
+
private let suffixUnit: String
|
|
9
|
+
private let zeroCents: Bool
|
|
10
|
+
|
|
11
|
+
init(options: NitroMaskOptions) {
|
|
12
|
+
self.precision = Int(options.precision ?? 2)
|
|
13
|
+
self.separator = options.separator ?? ","
|
|
14
|
+
self.delimiter = options.delimiter ?? "."
|
|
15
|
+
self.unit = options.unit ?? ""
|
|
16
|
+
self.suffixUnit = options.suffixUnit ?? ""
|
|
17
|
+
self.zeroCents = options.zeroCents ?? false
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func apply(input: String) -> (masked: String, raw: String) {
|
|
21
|
+
let digits = input.filter { $0.isNumber }
|
|
22
|
+
|
|
23
|
+
if digits.isEmpty {
|
|
24
|
+
return ("", "")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let effectivePrecision = zeroCents ? 0 : precision
|
|
28
|
+
|
|
29
|
+
// Pad on the left so we have at least (precision+1) digits
|
|
30
|
+
let minLength = effectivePrecision + 1
|
|
31
|
+
let padded = String(repeating: "0", count: max(0, minLength - digits.count)) + digits
|
|
32
|
+
|
|
33
|
+
// Split integer and decimal parts
|
|
34
|
+
let centPart = effectivePrecision > 0 ? String(padded.suffix(effectivePrecision)) : ""
|
|
35
|
+
var intPart = effectivePrecision > 0 ? String(padded.dropLast(effectivePrecision)) : padded
|
|
36
|
+
|
|
37
|
+
// Remove leading zeros from intPart, keep at least "0"
|
|
38
|
+
while intPart.count > 1 && intPart.hasPrefix("0") {
|
|
39
|
+
intPart = String(intPart.dropFirst())
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Insert delimiter every 3 digits from right
|
|
43
|
+
var formattedInt = ""
|
|
44
|
+
let intChars = Array(intPart)
|
|
45
|
+
let total = intChars.count
|
|
46
|
+
for (i, c) in intChars.enumerated() {
|
|
47
|
+
formattedInt.append(c)
|
|
48
|
+
let remaining = total - i - 1
|
|
49
|
+
if remaining > 0 && remaining % 3 == 0 {
|
|
50
|
+
formattedInt += delimiter
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Build result
|
|
55
|
+
var masked = unit + formattedInt
|
|
56
|
+
if effectivePrecision > 0 {
|
|
57
|
+
masked += separator + centPart
|
|
58
|
+
}
|
|
59
|
+
masked += suffixUnit
|
|
60
|
+
|
|
61
|
+
return (masked, digits)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var wantsTrailingCursor: Bool { true }
|
|
65
|
+
var expandedMask: String? { nil }
|
|
66
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NitroInputMaskService = void 0;
|
|
7
|
+
var _nitroModule = require("../../nitro-module");
|
|
8
|
+
/**
|
|
9
|
+
* Standalone service for applying input masks natively.
|
|
10
|
+
*
|
|
11
|
+
* Runs the same mask engine used by `<NitroInputMask />`, but as a
|
|
12
|
+
* plain function call — no component or ref required.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const masked = NitroInputMaskService.applyMask({
|
|
16
|
+
* value: '12345678901',
|
|
17
|
+
* maskOptions: { mask: '999.999.999-99' },
|
|
18
|
+
* })
|
|
19
|
+
* // '123.456.789-01'
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const masked = NitroInputMaskService.applyMask({
|
|
23
|
+
* value: '123456',
|
|
24
|
+
* maskType: 'money',
|
|
25
|
+
* maskOptions: { unit: 'R$ ', precision: 2 },
|
|
26
|
+
* })
|
|
27
|
+
* // 'R$ 1.234,56'
|
|
28
|
+
*/
|
|
29
|
+
class NitroInputMaskService {
|
|
30
|
+
/**
|
|
31
|
+
* Applies a mask to a string and returns the masked result.
|
|
32
|
+
*
|
|
33
|
+
* For `custom` masks, tokens are:
|
|
34
|
+
* - `9` — digit (0–9)
|
|
35
|
+
* - `A` — letter (a–z, A–Z)
|
|
36
|
+
* - `*` — letter or digit
|
|
37
|
+
* - `[n-m]` — integer in the inclusive range n–m (e.g. `[1-12]`, `[1-31]`)
|
|
38
|
+
* - Any other character — treated as a literal and inserted as-is
|
|
39
|
+
*
|
|
40
|
+
* @param props.value - The raw string to mask.
|
|
41
|
+
* @param props.maskType - The mask type: `'custom'` (default), `'money'`, `'datetime'`, `'credit-card'`.
|
|
42
|
+
* @param props.maskOptions - Options specific to the chosen mask type.
|
|
43
|
+
* @returns The masked string.
|
|
44
|
+
*
|
|
45
|
+
* @throws If `value` exceeds 1000 characters or `custom` mask exceeds 200 characters.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* NitroInputMaskService.applyMask({
|
|
49
|
+
* value: '11987654321',
|
|
50
|
+
* maskOptions: { mask: '(99) 99999-9999' },
|
|
51
|
+
* })
|
|
52
|
+
* // '(11) 98765-4321'
|
|
53
|
+
*/
|
|
54
|
+
static applyMask = props => {
|
|
55
|
+
const {
|
|
56
|
+
value,
|
|
57
|
+
maskType,
|
|
58
|
+
maskOptions
|
|
59
|
+
} = props;
|
|
60
|
+
const resolvedValue = String(value ?? '');
|
|
61
|
+
const resolvedMaskType = maskType ?? 'custom';
|
|
62
|
+
const resolvedOptions = maskOptions ?? {};
|
|
63
|
+
if (resolvedMaskType === 'custom') {
|
|
64
|
+
const mask = String(resolvedOptions.mask ?? '');
|
|
65
|
+
if (!mask) return resolvedValue;
|
|
66
|
+
if (resolvedValue.length > 1000 || mask.length > 200) {
|
|
67
|
+
throw new Error('NitroInputMaskService: value or mask exceeds maximum allowed length');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return (0, _nitroModule.getNitroServiceModule)().applyMask(resolvedValue, resolvedMaskType, resolvedOptions);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
exports.NitroInputMaskService = NitroInputMaskService;
|
|
74
|
+
//# sourceMappingURL=NitroInputMaskService.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_nitroModule","require","NitroInputMaskService","applyMask","props","value","maskType","maskOptions","resolvedValue","String","resolvedMaskType","resolvedOptions","mask","length","Error","getNitroServiceModule","exports"],"sourceRoot":"../../../../src","sources":["classes/NitroInputMaskService/NitroInputMaskService.class.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,CAAC;EACjC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,SAAS,GAAIC,KAAsB,IAAa;IACrD,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAY,CAAC,GAAGH,KAGxC;IAED,MAAMI,aAAa,GAAGC,MAAM,CAACJ,KAAK,IAAI,EAAE,CAAC;IACzC,MAAMK,gBAAgB,GAAGJ,QAAQ,IAAI,QAAQ;IAC7C,MAAMK,eAAe,GAAGJ,WAAW,IAAI,CAAC,CAAC;IAEzC,IAAIG,gBAAgB,KAAK,QAAQ,EAAE;MACjC,MAAME,IAAI,GAAGH,MAAM,CAAEE,eAAe,CAAuBC,IAAI,IAAI,EAAE,CAAC;MACtE,IAAI,CAACA,IAAI,EAAE,OAAOJ,aAAa;MAC/B,IAAIA,aAAa,CAACK,MAAM,GAAG,IAAI,IAAID,IAAI,CAACC,MAAM,GAAG,GAAG,EAAE;QACpD,MAAM,IAAIC,KAAK,CAAC,qEAAqE,CAAC;MACxF;IACF;IAEA,OAAO,IAAAC,kCAAqB,EAAC,CAAC,CAACZ,SAAS,CAACK,aAAa,EAAEE,gBAAgB,EAAEC,eAAe,CAAC;EAC5F,CAAC;AACH;AAACK,OAAA,CAAAd,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "NitroInputMaskService", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _NitroInputMaskService.NitroInputMaskService;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _NitroInputMaskService = require("./NitroInputMaskService.class");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NitroInputMaskService","require"],"sourceRoot":"../../../../src","sources":["classes/NitroInputMaskService/index.ts"],"mappings":";;;;;;;;;;;AACA,IAAAA,sBAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["classes/NitroInputMaskService/types/IApplyMaskProps.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["classes/NitroInputMaskService/types/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _NitroInputMaskService = require("./NitroInputMaskService");
|
|
7
|
+
Object.keys(_NitroInputMaskService).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _NitroInputMaskService[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _NitroInputMaskService[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NitroInputMaskService","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["classes/index.ts"],"mappings":";;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,sBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,sBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,sBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NitroInputMask = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _nitroModule = require("../../nitro-module");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
const NitroInputMask = props => {
|
|
13
|
+
const {
|
|
14
|
+
maskType,
|
|
15
|
+
maskOptions,
|
|
16
|
+
value,
|
|
17
|
+
...rest
|
|
18
|
+
} = props;
|
|
19
|
+
const resolvedMaskType = maskType ?? 'custom';
|
|
20
|
+
const reactId = (0, _react.useId)();
|
|
21
|
+
const id = `nitro-input-mask-${reactId}`;
|
|
22
|
+
const maskOptionsJson = JSON.stringify(maskOptions ?? {});
|
|
23
|
+
(0, _react.useEffect)(() => {
|
|
24
|
+
_nitroModule.nitroModule.attach(id, resolvedMaskType, maskOptions ?? {});
|
|
25
|
+
if (value != null) _nitroModule.nitroModule.setValue(id, String(value));
|
|
26
|
+
return () => _nitroModule.nitroModule.detach(id);
|
|
27
|
+
}, []);
|
|
28
|
+
(0, _react.useEffect)(() => {
|
|
29
|
+
_nitroModule.nitroModule.updateMask(id, resolvedMaskType, maskOptions ?? {});
|
|
30
|
+
}, [resolvedMaskType, maskOptionsJson]);
|
|
31
|
+
(0, _react.useEffect)(() => {
|
|
32
|
+
if (value == null) return;
|
|
33
|
+
_nitroModule.nitroModule.setValue(id, String(value));
|
|
34
|
+
}, [value]);
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
|
|
36
|
+
...rest,
|
|
37
|
+
nativeID: id
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.NitroInputMask = NitroInputMask;
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_nitroModule","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NitroInputMask","props","maskType","maskOptions","value","rest","resolvedMaskType","reactId","useId","id","maskOptionsJson","JSON","stringify","useEffect","nitroModule","attach","setValue","String","detach","updateMask","jsx","TextInput","nativeID","exports"],"sourceRoot":"../../../../src","sources":["components/NitroInputMask/index.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAAiD,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAE1C,MAAMkB,cAAc,GAAIC,KAA0B,IAAK;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,WAAW;IAAEC,KAAK;IAAE,GAAGC;EAAK,CAAC,GAAGJ,KAGjD;EAED,MAAMK,gBAAgB,GAAGJ,QAAQ,IAAI,QAAQ;EAC7C,MAAMK,OAAO,GAAG,IAAAC,YAAK,EAAC,CAAC;EACvB,MAAMC,EAAE,GAAG,oBAAoBF,OAAO,EAAE;EAExC,MAAMG,eAAe,GAAGC,IAAI,CAACC,SAAS,CAACT,WAAW,IAAI,CAAC,CAAC,CAAC;EAEzD,IAAAU,gBAAS,EAAC,MAAM;IACdC,wBAAW,CAACC,MAAM,CAACN,EAAE,EAAEH,gBAAgB,EAAEH,WAAW,IAAI,CAAC,CAAC,CAAC;IAC3D,IAAIC,KAAK,IAAI,IAAI,EAAEU,wBAAW,CAACE,QAAQ,CAACP,EAAE,EAAEQ,MAAM,CAACb,KAAK,CAAC,CAAC;IAC1D,OAAO,MAAMU,wBAAW,CAACI,MAAM,CAACT,EAAE,CAAC;EACrC,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAI,gBAAS,EAAC,MAAM;IACdC,wBAAW,CAACK,UAAU,CAACV,EAAE,EAAEH,gBAAgB,EAAEH,WAAW,IAAI,CAAC,CAAC,CAAC;EACjE,CAAC,EAAE,CAACG,gBAAgB,EAAEI,eAAe,CAAC,CAAC;EAEvC,IAAAG,gBAAS,EAAC,MAAM;IACd,IAAIT,KAAK,IAAI,IAAI,EAAE;IACnBU,wBAAW,CAACE,QAAQ,CAACP,EAAE,EAAEQ,MAAM,CAACb,KAAK,CAAC,CAAC;EACzC,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,oBACE,IAAAxB,WAAA,CAAAwC,GAAA,EAAC1C,YAAA,CAAA2C,SAAS;IAAA,GACJhB,IAAI;IACRiB,QAAQ,EAAEb;EAAG,CACd,CAAC;AAEN,CAAC;AAAAc,OAAA,CAAAvB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["components/NitroInputMask/types/NitroInputMaskProps.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["components/NitroInputMask/types/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _NitroInputMask = require("./NitroInputMask");
|
|
7
|
+
Object.keys(_NitroInputMask).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _NitroInputMask[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _NitroInputMask[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NitroInputMask","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _components = require("./components");
|
|
7
|
+
Object.keys(_components).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _components[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _components[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _classes = require("./classes");
|
|
18
|
+
Object.keys(_classes).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _classes[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _classes[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _types = require("./types");
|
|
29
|
+
Object.keys(_types).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _types[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_classes","_types"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,MAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,MAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,MAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,MAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.nitroModule = exports.getNitroServiceModule = void 0;
|
|
7
|
+
var _reactNativeNitroModules = require("react-native-nitro-modules");
|
|
8
|
+
const nitroModule = exports.nitroModule = _reactNativeNitroModules.NitroModules.createHybridObject('NitroInputMask');
|
|
9
|
+
let _nitroServiceModule = null;
|
|
10
|
+
const getNitroServiceModule = () => {
|
|
11
|
+
if (!_nitroServiceModule) {
|
|
12
|
+
_nitroServiceModule = _reactNativeNitroModules.NitroModules.createHybridObject('NitroInputMaskService');
|
|
13
|
+
}
|
|
14
|
+
return _nitroServiceModule;
|
|
15
|
+
};
|
|
16
|
+
exports.getNitroServiceModule = getNitroServiceModule;
|
|
17
|
+
//# sourceMappingURL=nitro-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","nitroModule","exports","NitroModules","createHybridObject","_nitroServiceModule","getNitroServiceModule"],"sourceRoot":"../../src","sources":["nitro-module.ts"],"mappings":";;;;;;AAEA,IAAAA,wBAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGE,qCAAY,CAACC,kBAAkB,CAAuB,gBAAgB,CAAC;AAClG,IAAIC,mBAAqD,GAAG,IAAI;AAEzD,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACzC,IAAI,CAACD,mBAAmB,EAAE;IACxBA,mBAAmB,GAAGF,qCAAY,CAACC,kBAAkB,CAA4B,uBAAuB,CAAC;EAC3G;EAEA,OAAOC,mBAAmB;AAC5B,CAAC;AAAAH,OAAA,CAAAI,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/nitro-input-mask-service.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/nitro-input-mask.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/CreditCardMaskOptions.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/CustomMaskOptions.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/DatetimeMaskOptions.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/MaskConfig.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/MoneyMaskOptions.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getNitroServiceModule } from '../../nitro-module';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Standalone service for applying input masks natively.
|
|
7
|
+
*
|
|
8
|
+
* Runs the same mask engine used by `<NitroInputMask />`, but as a
|
|
9
|
+
* plain function call — no component or ref required.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const masked = NitroInputMaskService.applyMask({
|
|
13
|
+
* value: '12345678901',
|
|
14
|
+
* maskOptions: { mask: '999.999.999-99' },
|
|
15
|
+
* })
|
|
16
|
+
* // '123.456.789-01'
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const masked = NitroInputMaskService.applyMask({
|
|
20
|
+
* value: '123456',
|
|
21
|
+
* maskType: 'money',
|
|
22
|
+
* maskOptions: { unit: 'R$ ', precision: 2 },
|
|
23
|
+
* })
|
|
24
|
+
* // 'R$ 1.234,56'
|
|
25
|
+
*/
|
|
26
|
+
export class NitroInputMaskService {
|
|
27
|
+
/**
|
|
28
|
+
* Applies a mask to a string and returns the masked result.
|
|
29
|
+
*
|
|
30
|
+
* For `custom` masks, tokens are:
|
|
31
|
+
* - `9` — digit (0–9)
|
|
32
|
+
* - `A` — letter (a–z, A–Z)
|
|
33
|
+
* - `*` — letter or digit
|
|
34
|
+
* - `[n-m]` — integer in the inclusive range n–m (e.g. `[1-12]`, `[1-31]`)
|
|
35
|
+
* - Any other character — treated as a literal and inserted as-is
|
|
36
|
+
*
|
|
37
|
+
* @param props.value - The raw string to mask.
|
|
38
|
+
* @param props.maskType - The mask type: `'custom'` (default), `'money'`, `'datetime'`, `'credit-card'`.
|
|
39
|
+
* @param props.maskOptions - Options specific to the chosen mask type.
|
|
40
|
+
* @returns The masked string.
|
|
41
|
+
*
|
|
42
|
+
* @throws If `value` exceeds 1000 characters or `custom` mask exceeds 200 characters.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* NitroInputMaskService.applyMask({
|
|
46
|
+
* value: '11987654321',
|
|
47
|
+
* maskOptions: { mask: '(99) 99999-9999' },
|
|
48
|
+
* })
|
|
49
|
+
* // '(11) 98765-4321'
|
|
50
|
+
*/
|
|
51
|
+
static applyMask = props => {
|
|
52
|
+
const {
|
|
53
|
+
value,
|
|
54
|
+
maskType,
|
|
55
|
+
maskOptions
|
|
56
|
+
} = props;
|
|
57
|
+
const resolvedValue = String(value ?? '');
|
|
58
|
+
const resolvedMaskType = maskType ?? 'custom';
|
|
59
|
+
const resolvedOptions = maskOptions ?? {};
|
|
60
|
+
if (resolvedMaskType === 'custom') {
|
|
61
|
+
const mask = String(resolvedOptions.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
|
+
return getNitroServiceModule().applyMask(resolvedValue, resolvedMaskType, resolvedOptions);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=NitroInputMaskService.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getNitroServiceModule","NitroInputMaskService","applyMask","props","value","maskType","maskOptions","resolvedValue","String","resolvedMaskType","resolvedOptions","mask","length","Error"],"sourceRoot":"../../../../src","sources":["classes/NitroInputMaskService/NitroInputMaskService.class.ts"],"mappings":";;AACA,SAASA,qBAAqB,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,CAAC;EACjC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,SAAS,GAAIC,KAAsB,IAAa;IACrD,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAY,CAAC,GAAGH,KAGxC;IAED,MAAMI,aAAa,GAAGC,MAAM,CAACJ,KAAK,IAAI,EAAE,CAAC;IACzC,MAAMK,gBAAgB,GAAGJ,QAAQ,IAAI,QAAQ;IAC7C,MAAMK,eAAe,GAAGJ,WAAW,IAAI,CAAC,CAAC;IAEzC,IAAIG,gBAAgB,KAAK,QAAQ,EAAE;MACjC,MAAME,IAAI,GAAGH,MAAM,CAAEE,eAAe,CAAuBC,IAAI,IAAI,EAAE,CAAC;MACtE,IAAI,CAACA,IAAI,EAAE,OAAOJ,aAAa;MAC/B,IAAIA,aAAa,CAACK,MAAM,GAAG,IAAI,IAAID,IAAI,CAACC,MAAM,GAAG,GAAG,EAAE;QACpD,MAAM,IAAIC,KAAK,CAAC,qEAAqE,CAAC;MACxF;IACF;IAEA,OAAOb,qBAAqB,CAAC,CAAC,CAACE,SAAS,CAACK,aAAa,EAAEE,gBAAgB,EAAEC,eAAe,CAAC;EAC5F,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NitroInputMaskService"],"sourceRoot":"../../../../src","sources":["classes/NitroInputMaskService/index.ts"],"mappings":";;AACA,SAASA,qBAAqB,QAAQ,+BAA+B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["classes/NitroInputMaskService/types/IApplyMaskProps.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["classes/NitroInputMaskService/types/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["classes/index.ts"],"mappings":";;AAAA,cAAc,yBAAyB","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useId } from 'react';
|
|
4
|
+
import { TextInput } from 'react-native';
|
|
5
|
+
import { nitroModule } from '../../nitro-module';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export const NitroInputMask = props => {
|
|
8
|
+
const {
|
|
9
|
+
maskType,
|
|
10
|
+
maskOptions,
|
|
11
|
+
value,
|
|
12
|
+
...rest
|
|
13
|
+
} = props;
|
|
14
|
+
const resolvedMaskType = maskType ?? 'custom';
|
|
15
|
+
const reactId = useId();
|
|
16
|
+
const id = `nitro-input-mask-${reactId}`;
|
|
17
|
+
const maskOptionsJson = JSON.stringify(maskOptions ?? {});
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
nitroModule.attach(id, resolvedMaskType, maskOptions ?? {});
|
|
20
|
+
if (value != null) nitroModule.setValue(id, String(value));
|
|
21
|
+
return () => nitroModule.detach(id);
|
|
22
|
+
}, []);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
nitroModule.updateMask(id, resolvedMaskType, maskOptions ?? {});
|
|
25
|
+
}, [resolvedMaskType, maskOptionsJson]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (value == null) return;
|
|
28
|
+
nitroModule.setValue(id, String(value));
|
|
29
|
+
}, [value]);
|
|
30
|
+
return /*#__PURE__*/_jsx(TextInput, {
|
|
31
|
+
...rest,
|
|
32
|
+
nativeID: id
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|