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