use-mask-input 3.0.6 → 3.1.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 (66) hide show
  1. package/README.md +13 -19
  2. package/dist/index.cjs +191 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.ts +34 -3
  5. package/dist/index.js +184 -1
  6. package/dist/index.js.map +1 -1
  7. package/package.json +49 -48
  8. package/src/index.tsx +3 -2
  9. package/src/types.ts +6 -0
  10. package/src/useMaskInput.ts +12 -9
  11. package/src/utils.spec.ts +14 -0
  12. package/src/utils.ts +23 -0
  13. package/src/withHookFormMask.ts +8 -17
  14. package/src/withMask.ts +5 -6
  15. package/dist/example/App.example.d.ts +0 -3
  16. package/dist/example/index.d.ts +0 -1
  17. package/dist/index.modern.js +0 -2
  18. package/dist/index.modern.js.map +0 -1
  19. package/dist/index.umd.js +0 -2
  20. package/dist/index.umd.js.map +0 -1
  21. package/dist/useMaskInput.d.ts +0 -9
  22. package/dist/withHookFormMask.d.ts +0 -16
  23. package/dist/withMask.d.ts +0 -3
  24. package/node_modules/inputmask/LICENSE.txt +0 -7
  25. package/node_modules/inputmask/README.md +0 -1279
  26. package/node_modules/inputmask/bundle.js +0 -6
  27. package/node_modules/inputmask/dist/bindings/inputmask.binding.js +0 -26
  28. package/node_modules/inputmask/dist/inputmask.es6.js +0 -5
  29. package/node_modules/inputmask/dist/inputmask.js +0 -3031
  30. package/node_modules/inputmask/dist/inputmask.min.js +0 -8
  31. package/node_modules/inputmask/dist/jquery.inputmask.js +0 -2985
  32. package/node_modules/inputmask/dist/jquery.inputmask.min.js +0 -8
  33. package/node_modules/inputmask/lib/bindings/inputmask.binding.js +0 -26
  34. package/node_modules/inputmask/lib/bindings/inputmask.es6.js +0 -5
  35. package/node_modules/inputmask/lib/canUseDOM.js +0 -7
  36. package/node_modules/inputmask/lib/defaults.js +0 -101
  37. package/node_modules/inputmask/lib/definitions.js +0 -13
  38. package/node_modules/inputmask/lib/dependencyLibs/data.js +0 -8
  39. package/node_modules/inputmask/lib/dependencyLibs/events.js +0 -199
  40. package/node_modules/inputmask/lib/dependencyLibs/extend.js +0 -58
  41. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js +0 -13
  42. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.js +0 -41
  43. package/node_modules/inputmask/lib/environment.js +0 -9
  44. package/node_modules/inputmask/lib/escapeRegex.js +0 -4
  45. package/node_modules/inputmask/lib/eventhandlers.js +0 -513
  46. package/node_modules/inputmask/lib/eventruler.js +0 -124
  47. package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +0 -588
  48. package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +0 -133
  49. package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +0 -631
  50. package/node_modules/inputmask/lib/global/window.js +0 -3
  51. package/node_modules/inputmask/lib/inputHandling.js +0 -252
  52. package/node_modules/inputmask/lib/inputmask.js +0 -355
  53. package/node_modules/inputmask/lib/inputmaskElement.js +0 -33
  54. package/node_modules/inputmask/lib/jquery.inputmask.js +0 -81
  55. package/node_modules/inputmask/lib/keycode.json +0 -25
  56. package/node_modules/inputmask/lib/mask-lexer.js +0 -467
  57. package/node_modules/inputmask/lib/mask.js +0 -244
  58. package/node_modules/inputmask/lib/masktoken.js +0 -13
  59. package/node_modules/inputmask/lib/polyfills/Array.includes.js +0 -48
  60. package/node_modules/inputmask/lib/polyfills/Object.getPrototypeOf.js +0 -7
  61. package/node_modules/inputmask/lib/positioning.js +0 -348
  62. package/node_modules/inputmask/lib/validation-tests.js +0 -597
  63. package/node_modules/inputmask/lib/validation.js +0 -664
  64. package/node_modules/inputmask/package.json +0 -60
  65. package/src/example/App.example.tsx +0 -68
  66. package/src/example/index.tsx +0 -5
@@ -1,124 +0,0 @@
1
- import Inputmask from "./inputmask";
2
- import keyCode from "./keycode.json";
3
- import {getBufferTemplate} from "./positioning";
4
- import {HandleNativePlaceholder} from "./inputHandling";
5
-
6
- export {EventRuler};
7
-
8
- var EventRuler = {
9
- on: function (input, eventName, eventHandler) {
10
- const $ = input.inputmask.dependencyLib;
11
-
12
- var ev = function (e) {
13
- if (e.originalEvent) {
14
- e = e.originalEvent || e; //get original event from jquery evenbt
15
- arguments[0] = e;
16
- }
17
- // console.log(e.type);
18
- var that = this, args, inputmask = that.inputmask, opts = inputmask ? inputmask.opts : undefined;
19
- if (inputmask === undefined && this.nodeName !== "FORM") { //happens when cloning an object with jquery.clone
20
- var imOpts = $.data(that, "_inputmask_opts");
21
- $(that).off(); //unbind all events
22
- if (imOpts) {
23
- (new Inputmask(imOpts)).mask(that);
24
- }
25
- } else if (!["submit", "reset", "setvalue"].includes(e.type) && this.nodeName !== "FORM" && (that.disabled || (that.readOnly && !(e.type === "keydown" && (e.ctrlKey && e.keyCode === 67) || (opts.tabThrough === false && e.keyCode === keyCode.TAB))))) {
26
- e.preventDefault();
27
- } else {
28
- switch (e.type) {
29
- case "input":
30
- if (inputmask.skipInputEvent === true || (e.inputType && e.inputType === "insertCompositionText")) {
31
- inputmask.skipInputEvent = false;
32
- return e.preventDefault();
33
- }
34
-
35
- // if (mobile) { //this causes problem see #2220
36
- // args = arguments;
37
- // setTimeout(function () { //needed for caret selection when entering a char on Android 8 - #1818
38
- // eventHandler.apply(that, args);
39
- // caret(that, that.inputmask.caretPos, undefined, true);
40
- // }, 0);
41
- // return false;
42
- // }
43
- break;
44
- case "keydown":
45
- //Safari 5.1.x - modal dialog fires keypress twice workaround
46
- inputmask.skipKeyPressEvent = false;
47
- inputmask.skipInputEvent = inputmask.isComposing = e.keyCode === keyCode.KEY_229;
48
- break;
49
- case "keyup":
50
- case "compositionend":
51
- if (inputmask.isComposing) {
52
- inputmask.skipInputEvent = false;
53
- }
54
- break;
55
- case "keypress":
56
- if (inputmask.skipKeyPressEvent === true) {
57
- return e.preventDefault();
58
- }
59
- inputmask.skipKeyPressEvent = true;
60
- break;
61
- case "click":
62
- case "focus":
63
- if (inputmask.validationEvent) { // #841
64
- inputmask.validationEvent = false;
65
- input.blur();
66
- HandleNativePlaceholder(input, (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join(""));
67
- setTimeout(function () {
68
- input.focus();
69
- }, opts.validationEventTimeOut);
70
- return false;
71
- }
72
- args = arguments;
73
- setTimeout(function () { //needed for Chrome ~ initial selection clears after the clickevent
74
- if (!input.inputmask) {
75
- // `inputmask.remove()` was called before this callback
76
- return;
77
- }
78
- eventHandler.apply(that, args);
79
- }, 0);
80
- return false;
81
- }
82
- var returnVal = eventHandler.apply(that, arguments);
83
- if (returnVal === false) {
84
- e.preventDefault();
85
- e.stopPropagation();
86
- }
87
- return returnVal;
88
- }
89
- };
90
- if (["submit", "reset"].includes(eventName)) {
91
- ev = ev.bind(input); //bind creates a new eventhandler (wrap)
92
- if (input.form !== null) $(input.form).on(eventName, ev);
93
- } else {
94
- $(input).on(eventName, ev);
95
- }
96
-
97
- //keep instance of the event
98
- input.inputmask.events[eventName] = input.inputmask.events[eventName] || [];
99
- input.inputmask.events[eventName].push(ev);
100
-
101
- },
102
- off: function (input, event) {
103
- if (input.inputmask && input.inputmask.events) {
104
- const $ = input.inputmask.dependencyLib;
105
- let events = input.inputmask.events;
106
- if (event) {
107
- events = [];
108
- events[event] = input.inputmask.events[event];
109
- }
110
- for (let eventName in events) {
111
- let evArr = events[eventName];
112
- while (evArr.length > 0) {
113
- let ev = evArr.pop();
114
- if (["submit", "reset",].includes(eventName)) {
115
- if (input.form !== null) $(input.form).off(eventName, ev);
116
- } else {
117
- $(input).off(eventName, ev);
118
- }
119
- }
120
- delete input.inputmask.events[eventName];
121
- }
122
- }
123
- }
124
- };