use-mask-input 1.0.2 → 2.0.1
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/dist/example/App.example.d.ts +3 -0
- package/dist/{useMaskInput.test.d.ts → example/index.d.ts} +0 -0
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -2
- package/dist/index.modern.js.map +1 -1
- package/dist/useMaskInput.d.ts +3 -3
- package/node_modules/inputmask/README.md +94 -61
- package/node_modules/inputmask/dist/inputmask.es6.js +5 -0
- package/node_modules/inputmask/dist/inputmask.js +2900 -2868
- package/node_modules/inputmask/dist/inputmask.min.js +3 -3
- package/node_modules/inputmask/dist/jquery.inputmask.js +2840 -2807
- package/node_modules/inputmask/dist/jquery.inputmask.min.js +3 -3
- package/node_modules/inputmask/lib/bindings/inputmask.es6.js +5 -0
- package/node_modules/inputmask/lib/canUseDOM.js +7 -0
- package/node_modules/inputmask/lib/defaults.js +36 -2
- package/node_modules/inputmask/lib/definitions.js +1 -1
- package/node_modules/inputmask/lib/dependencyLibs/events.js +19 -9
- package/node_modules/inputmask/lib/environment.js +2 -0
- package/node_modules/inputmask/lib/eventhandlers.js +55 -44
- package/node_modules/inputmask/lib/eventruler.js +10 -9
- package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +543 -430
- package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +117 -99
- package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +590 -574
- package/node_modules/inputmask/lib/global/window.js +2 -1
- package/node_modules/inputmask/lib/inputHandling.js +30 -18
- package/node_modules/inputmask/lib/inputmask.js +9 -2
- package/node_modules/inputmask/lib/inputmaskElement.js +2 -1
- package/node_modules/inputmask/lib/keycode.json +4 -0
- package/node_modules/inputmask/lib/mask-lexer.js +434 -436
- package/node_modules/inputmask/lib/mask.js +4 -4
- package/node_modules/inputmask/lib/masktoken.js +13 -0
- package/node_modules/inputmask/lib/polyfills/Array.includes.js +48 -0
- package/node_modules/inputmask/lib/{getPrototypeOf.js → polyfills/Object.getPrototypeOf.js} +0 -0
- package/node_modules/inputmask/lib/positioning.js +5 -5
- package/node_modules/inputmask/lib/validation-tests.js +108 -46
- package/node_modules/inputmask/lib/validation.js +82 -73
- package/node_modules/inputmask/package.json +41 -69
- package/package.json +40 -38
- package/node_modules/inputmask/CHANGELOG.md +0 -744
- package/node_modules/inputmask/index.js +0 -1
- package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js +0 -20
|
@@ -4,112 +4,130 @@
|
|
|
4
4
|
Copyright (c) Robin Herbots
|
|
5
5
|
Licensed under the MIT license
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import Inputmask from "../inputmask";
|
|
8
|
+
import {getLastValidPosition} from "../positioning";
|
|
9
|
+
import {getMaskTemplate} from "../validation-tests";
|
|
8
10
|
//extra definitions
|
|
9
11
|
Inputmask.extendDefinitions({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
"A": {
|
|
13
|
+
validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
|
14
|
+
casing: "upper" //auto uppercasing
|
|
15
|
+
},
|
|
16
|
+
"&": { //alfanumeric uppercasing
|
|
17
|
+
validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
|
18
|
+
casing: "upper"
|
|
19
|
+
},
|
|
20
|
+
"#": { //hexadecimal
|
|
21
|
+
validator: "[0-9A-Fa-f]",
|
|
22
|
+
casing: "upper"
|
|
23
|
+
}
|
|
22
24
|
});
|
|
23
25
|
|
|
24
26
|
var ipValidatorRegex = new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]");
|
|
27
|
+
|
|
25
28
|
function ipValidator(chrs, maskset, pos, strict, opts) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (pos - 1 > -1 && maskset.buffer[pos - 1] !== ".") {
|
|
30
|
+
chrs = maskset.buffer[pos - 1] + chrs;
|
|
31
|
+
if (pos - 2 > -1 && maskset.buffer[pos - 2] !== ".") {
|
|
32
|
+
chrs = maskset.buffer[pos - 2] + chrs;
|
|
33
|
+
} else chrs = "0" + chrs;
|
|
34
|
+
} else chrs = "00" + chrs;
|
|
35
|
+
return ipValidatorRegex.test(chrs);
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
|
|
36
39
|
Inputmask.extendAliases({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
40
|
+
"cssunit": {
|
|
41
|
+
regex: "[+-]?[0-9]+\\.?([0-9]+)?(px|em|rem|ex|%|in|cm|mm|pt|pc)"
|
|
42
|
+
},
|
|
43
|
+
"url": { //needs update => https://en.wikipedia.org/wiki/URL
|
|
44
|
+
regex: "(https?|ftp)://.*",
|
|
45
|
+
autoUnmask: false,
|
|
46
|
+
keepStatic: false,
|
|
47
|
+
tabThrough: true
|
|
48
|
+
},
|
|
49
|
+
"ip": { //ip-address mask
|
|
50
|
+
mask: "i{1,3}.j{1,3}.k{1,3}.l{1,3}",
|
|
51
|
+
definitions: {
|
|
52
|
+
"i": {
|
|
53
|
+
validator: ipValidator
|
|
54
|
+
},
|
|
55
|
+
"j": {
|
|
56
|
+
validator: ipValidator
|
|
57
|
+
},
|
|
58
|
+
"k": {
|
|
59
|
+
validator: ipValidator
|
|
60
|
+
},
|
|
61
|
+
"l": {
|
|
62
|
+
validator: ipValidator
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
|
66
|
+
return maskedValue;
|
|
67
|
+
},
|
|
68
|
+
inputmode: "decimal",
|
|
69
|
+
substitutes: {",": "."}
|
|
70
|
+
},
|
|
71
|
+
"email": {
|
|
72
|
+
//https://en.wikipedia.org/wiki/Domain_name#Domain_name_space
|
|
73
|
+
//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
|
|
74
|
+
//should be extended with the toplevel domains at the end
|
|
75
|
+
mask: function (opts) {
|
|
76
|
+
var emailMask = "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]";
|
|
77
|
+
var mask = emailMask;
|
|
78
|
+
if (opts.separator) {
|
|
79
|
+
for (let i = 0; i < opts.quantifier; i++) {
|
|
80
|
+
mask += `[${opts.separator}${emailMask}]`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return mask;
|
|
84
|
+
return opts.separator ? `${emailMask}(${opts.separator}${emailMask}){*}` : emailMask;
|
|
85
|
+
},
|
|
86
|
+
greedy: false,
|
|
87
|
+
casing: "lower",
|
|
88
|
+
separator: null,
|
|
89
|
+
quantifier: 5,
|
|
90
|
+
skipOptionalPartCharacter: "",
|
|
91
|
+
onBeforePaste: function (pastedValue, opts) {
|
|
92
|
+
pastedValue = pastedValue.toLowerCase();
|
|
93
|
+
return pastedValue.replace("mailto:", "");
|
|
94
|
+
},
|
|
95
|
+
definitions: {
|
|
96
|
+
"*": {
|
|
97
|
+
validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5!#$%&'*+/=?^_`{|}~-]"
|
|
98
|
+
},
|
|
99
|
+
"-": {
|
|
100
|
+
validator: "[0-9A-Za-z-]"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
|
104
|
+
return maskedValue;
|
|
105
|
+
},
|
|
106
|
+
inputmode: "email"
|
|
107
|
+
},
|
|
108
|
+
"mac": {
|
|
109
|
+
mask: "##:##:##:##:##:##"
|
|
110
|
+
},
|
|
111
|
+
//https://en.wikipedia.org/wiki/Vehicle_identification_number
|
|
112
|
+
// see issue #1199
|
|
113
|
+
"vin": {
|
|
114
|
+
mask: "V{13}9{4}",
|
|
115
|
+
definitions: {
|
|
116
|
+
"V": {
|
|
117
|
+
validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
|
|
118
|
+
casing: "upper"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
clearIncomplete: true,
|
|
122
|
+
autoUnmask: true
|
|
123
|
+
},
|
|
124
|
+
//http://rion.io/2013/09/10/validating-social-security-numbers-through-regular-expressions-2/
|
|
125
|
+
//https://en.wikipedia.org/wiki/Social_Security_number
|
|
126
|
+
"ssn": {
|
|
127
|
+
mask: "999-99-9999",
|
|
128
|
+
postValidation: function (buffer, pos, c, currentResult, opts, maskset, strict) {
|
|
129
|
+
var bffr = getMaskTemplate.call(this, true, getLastValidPosition.call(this), true, true);
|
|
130
|
+
return /^(?!219-09-9999|078-05-1120)(?!666|000|9.{2}).{3}-(?!00).{2}-(?!0{4}).{4}$/.test(bffr.join(""));
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
});
|