use-mask-input 1.0.1 → 2.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.
Files changed (51) 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 +109 -79
  9. package/node_modules/inputmask/bundle.js +6 -5
  10. package/node_modules/inputmask/dist/inputmask.es6.js +5 -0
  11. package/node_modules/inputmask/dist/inputmask.js +2892 -2608
  12. package/node_modules/inputmask/dist/inputmask.min.js +3 -3
  13. package/node_modules/inputmask/dist/jquery.inputmask.js +2829 -2534
  14. package/node_modules/inputmask/dist/jquery.inputmask.min.js +3 -3
  15. package/node_modules/inputmask/lib/bindings/inputmask.es6.js +5 -0
  16. package/node_modules/inputmask/lib/canUseDOM.js +7 -0
  17. package/node_modules/inputmask/lib/defaults.js +101 -0
  18. package/node_modules/inputmask/lib/definitions.js +13 -0
  19. package/node_modules/inputmask/lib/dependencyLibs/data.js +8 -0
  20. package/node_modules/inputmask/lib/dependencyLibs/events.js +199 -0
  21. package/node_modules/inputmask/lib/dependencyLibs/extend.js +58 -0
  22. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js +4 -3
  23. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.js +12 -343
  24. package/node_modules/inputmask/lib/environment.js +9 -0
  25. package/node_modules/inputmask/lib/escapeRegex.js +4 -0
  26. package/node_modules/inputmask/lib/eventhandlers.js +513 -0
  27. package/node_modules/inputmask/lib/eventruler.js +124 -0
  28. package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +552 -385
  29. package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +116 -97
  30. package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +594 -565
  31. package/node_modules/inputmask/lib/global/window.js +2 -6
  32. package/node_modules/inputmask/lib/inputHandling.js +252 -0
  33. package/node_modules/inputmask/lib/inputmask.js +129 -126
  34. package/node_modules/inputmask/lib/inputmaskElement.js +26 -20
  35. package/node_modules/inputmask/lib/jquery.inputmask.js +3 -1
  36. package/node_modules/inputmask/lib/keycode.json +6 -1
  37. package/node_modules/inputmask/lib/mask-lexer.js +467 -0
  38. package/node_modules/inputmask/lib/mask.js +244 -0
  39. package/node_modules/inputmask/lib/masktoken.js +13 -0
  40. package/node_modules/inputmask/lib/polyfills/Array.includes.js +48 -0
  41. package/node_modules/inputmask/lib/polyfills/Object.getPrototypeOf.js +7 -0
  42. package/node_modules/inputmask/lib/positioning.js +348 -0
  43. package/node_modules/inputmask/lib/validation-tests.js +597 -0
  44. package/node_modules/inputmask/lib/validation.js +664 -0
  45. package/node_modules/inputmask/package.json +41 -71
  46. package/package.json +40 -43
  47. package/node_modules/inputmask/CHANGELOG.md +0 -714
  48. package/node_modules/inputmask/index.js +0 -1
  49. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js +0 -170
  50. package/node_modules/inputmask/lib/maskScope.js +0 -2498
  51. package/node_modules/inputmask/lib/maskset.js +0 -466
@@ -4,111 +4,130 @@
4
4
  Copyright (c) Robin Herbots
5
5
  Licensed under the MIT license
6
6
  */
7
- var Inputmask = require("../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
- },
44
- "ip": { //ip-address mask
45
- mask: "i[i[i]].j[j[j]].k[k[k]].l[l[l]]",
46
- definitions: {
47
- "i": {
48
- validator: ipValidator
49
- },
50
- "j": {
51
- validator: ipValidator
52
- },
53
- "k": {
54
- validator: ipValidator
55
- },
56
- "l": {
57
- validator: ipValidator
58
- }
59
- },
60
- onUnMask: function (maskedValue, unmaskedValue, opts) {
61
- return maskedValue;
62
- },
63
- inputmode: "numeric",
64
- },
65
- "email": {
66
- //https://en.wikipedia.org/wiki/Domain_name#Domain_name_space
67
- //https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
68
- //should be extended with the toplevel domains at the end
69
- mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",
70
- greedy: false,
71
- casing: "lower",
72
- onBeforePaste: function (pastedValue, opts) {
73
- pastedValue = pastedValue.toLowerCase();
74
- return pastedValue.replace("mailto:", "");
75
- },
76
- definitions: {
77
- "*": {
78
- validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5!#$%&'*+/=?^_`{|}~-]"
79
- },
80
- "-": {
81
- validator: "[0-9A-Za-z-]"
82
- }
83
- },
84
- onUnMask: function (maskedValue, unmaskedValue, opts) {
85
- return maskedValue;
86
- },
87
- inputmode: "email"
88
- },
89
- "mac": {
90
- mask: "##:##:##:##:##:##"
91
- },
92
- //https://en.wikipedia.org/wiki/Vehicle_identification_number
93
- // see issue #1199
94
- "vin": {
95
- mask: "V{13}9{4}",
96
- definitions: {
97
- "V": {
98
- validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
99
- casing: "upper"
100
- }
101
- },
102
- clearIncomplete: true,
103
- autoUnmask: true
104
- },
105
- //http://rion.io/2013/09/10/validating-social-security-numbers-through-regular-expressions-2/
106
- //https://en.wikipedia.org/wiki/Social_Security_number
107
- "ssn": {
108
- mask: "999-99-9999",
109
- postValidation: function (buffer, pos, c, currentResult, opts, maskset, strict) {
110
- return /^(?!219-09-9999|078-05-1120)(?!666|000|9.{2}).{3}-(?!00).{2}-(?!0{4}).{4}$/.test(buffer.join(""));
111
- }
112
- },
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
+ },
113
133
  });
114
- module.exports = Inputmask;