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
@@ -0,0 +1,7 @@
1
+ const canUseDOM = !!(
2
+ typeof window !== "undefined" &&
3
+ window.document &&
4
+ window.document.createElement
5
+ );
6
+
7
+ export default canUseDOM;
@@ -0,0 +1,101 @@
1
+ import keyCode from "./keycode.json";
2
+
3
+ export default {
4
+ _maxTestPos: 500,
5
+ placeholder: "_",
6
+ optionalmarker: ["[", "]"],
7
+ quantifiermarker: ["{", "}"],
8
+ groupmarker: ["(", ")"],
9
+ alternatormarker: "|",
10
+ escapeChar: "\\",
11
+ mask: null, //needs tobe null instead of undefined as the extend method does not consider props with the undefined value
12
+ regex: null, //regular expression as a mask
13
+ oncomplete: () => {
14
+ }, //executes when the mask is complete
15
+ onincomplete: () => {
16
+ }, //executes when the mask is incomplete and focus is lost
17
+ oncleared: () => {
18
+ }, //executes when the mask is cleared
19
+ repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
20
+ greedy: false, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
21
+ autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
22
+ removeMaskOnSubmit: false, //remove the mask before submitting the form.
23
+ clearMaskOnLostFocus: true,
24
+ insertMode: true, //insert the input or overwrite the input
25
+ insertModeVisual: true, //show selected caret when insertmode = false
26
+ clearIncomplete: false, //clear the incomplete input on blur
27
+ alias: null,
28
+ onKeyDown: () => {
29
+ }, //callback to implement autocomplete on certain keys for example. args => event, buffer, caretPos, opts
30
+ onBeforeMask: null, //executes before masking the initial value to allow preprocessing of the initial value. args => initialValue, opts => return processedValue
31
+ onBeforePaste: function (pastedValue, opts) {
32
+ return typeof opts.onBeforeMask === "function" ? opts.onBeforeMask.call(this, pastedValue, opts) : pastedValue;
33
+ }, //executes before masking the pasted value to allow preprocessing of the pasted value. args => pastedValue, opts => return processedValue
34
+ onBeforeWrite: null, //executes before writing to the masked element. args => event, opts
35
+ onUnMask: null, //executes after unmasking to allow postprocessing of the unmaskedvalue. args => maskedValue, unmaskedValue, opts
36
+ showMaskOnFocus: true, //show the mask-placeholder when the input has focus
37
+ showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
38
+ onKeyValidation: () => {
39
+ }, //executes on every key-press with the result of isValid. Params: key, result, opts
40
+ skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
41
+ numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
42
+ rightAlign: false, //align to the right
43
+ undoOnEscape: true, //pressing escape reverts the value to the value before focus
44
+ //numeric basic properties
45
+ radixPoint: "", //".", // | ","
46
+ _radixDance: false, //dance around the radixPoint
47
+ groupSeparator: "", //",", // | "."
48
+ //numeric basic properties
49
+ keepStatic: null, //try to keep the mask static while typing. Decisions to alter the mask will be posponed if possible
50
+ positionCaretOnTab: true, //when enabled the caret position is set after the latest valid position on TAB
51
+ tabThrough: false, //allows for tabbing through the different parts of the masked field
52
+ supportsInputType: ["text", "tel", "url", "password", "search"], //list with the supported input types
53
+ //specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
54
+ ignorables: [
55
+ keyCode.BACKSPACE,
56
+ keyCode.TAB,
57
+ keyCode["PAUSE/BREAK"],
58
+ keyCode.ESCAPE,
59
+ keyCode.PAGE_UP,
60
+ keyCode.PAGE_DOWN,
61
+ keyCode.END,
62
+ keyCode.HOME,
63
+ keyCode.LEFT,
64
+ keyCode.UP,
65
+ keyCode.RIGHT,
66
+ keyCode.DOWN,
67
+ keyCode.INSERT,
68
+ keyCode.DELETE,
69
+ 93,
70
+ 112,
71
+ 113,
72
+ 114,
73
+ 115,
74
+ 116,
75
+ 117,
76
+ 118,
77
+ 119,
78
+ 120,
79
+ 121,
80
+ 122,
81
+ 123,
82
+ 0,
83
+ 229
84
+ ],
85
+ isComplete: null, //override for isComplete - args => buffer, opts - return true || false
86
+ preValidation: null, //hook to preValidate the input. Usefull for validating regardless the definition. args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
87
+ postValidation: null, //hook to postValidate the result from isValid. Usefull for validating the entry as a whole. args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval => return true/false/json
88
+ staticDefinitionSymbol: undefined, //specify a definitionSymbol for static content, used to make matches for alternators
89
+ jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
90
+ nullable: true, //return nothing instead of the buffertemplate when the user hasn't entered anything.
91
+ inputEventOnly: false, //dev option - testing inputfallback behavior
92
+ noValuePatching: false, //disable value property patching
93
+ positionCaretOnClick: "lvp", //none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click), select (select the whole input), ignore (ignore the click and continue the mask)
94
+ casing: null, //mask-level casing. Options: null, "upper", "lower" or "title" or callback args => elem, test, pos, validPositions return charValue
95
+ inputmode: "text", //specify the inputmode
96
+ importDataAttributes: true, //import data-inputmask attributes
97
+ shiftPositions: true, //shift position of the mask entries on entry and deletion.
98
+ usePrototypeDefinitions: true, //use the default defined definitions from the prototype
99
+ validationEventTimeOut: 3000, //Time to show validation error on form submit
100
+ substitutes: {} //define character substitutes
101
+ };
@@ -0,0 +1,13 @@
1
+ export default {
2
+ "9": { //\uFF11-\uFF19 #1606
3
+ validator: "[0-9\uFF10-\uFF19]",
4
+ definitionSymbol: "*"
5
+ },
6
+ "a": { //\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5 #76
7
+ validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
8
+ definitionSymbol: "*"
9
+ },
10
+ "*": {
11
+ validator: "[0-9\uFF10-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]"
12
+ }
13
+ };
@@ -0,0 +1,8 @@
1
+ export default function (owner, key, value) {
2
+ if (value === undefined) {
3
+ return owner.__data ? owner.__data[key] : null;
4
+ } else {
5
+ owner.__data = owner.__data || {};
6
+ owner.__data[key] = value;
7
+ }
8
+ }
@@ -0,0 +1,199 @@
1
+ import extend from "./extend";
2
+ import window from "../global/window";
3
+ import DependencyLib from "./inputmask.dependencyLib";
4
+ import canUseDOM from "../canUseDOM";
5
+
6
+ export {on, off, trigger, Event};
7
+
8
+ function isValidElement(elem) {
9
+ return elem instanceof Element;
10
+ }
11
+
12
+ let Event;
13
+ if (typeof window.CustomEvent === "function") {
14
+ Event = window.CustomEvent;
15
+ } else {
16
+ if (canUseDOM) {
17
+ Event = function (event, params) {
18
+ params = params || {bubbles: false, cancelable: false, detail: undefined};
19
+ var evt = document.createEvent("CustomEvent");
20
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
21
+ return evt;
22
+ };
23
+ Event.prototype = window.Event.prototype;
24
+ }
25
+ }
26
+
27
+
28
+ function on(events, handler) {
29
+ function addEvent(ev, namespace) {
30
+ //register domevent
31
+ if (elem.addEventListener) { // all browsers except IE before version 9
32
+ elem.addEventListener(ev, handler, false);
33
+ } else if (elem.attachEvent) { // IE before version 9
34
+ elem.attachEvent("on" + ev, handler);
35
+ }
36
+ eventRegistry[ev] = eventRegistry[ev] || {};
37
+ eventRegistry[ev][namespace] = eventRegistry[ev][namespace] || [];
38
+ eventRegistry[ev][namespace].push(handler);
39
+ }
40
+
41
+ if (isValidElement(this[0])) {
42
+ var eventRegistry = this[0].eventRegistry,
43
+ elem = this[0];
44
+
45
+
46
+ var _events = events.split(" ");
47
+ for (var endx = 0; endx < _events.length; endx++) {
48
+ var nsEvent = _events[endx].split("."),
49
+ ev = nsEvent[0],
50
+ namespace = nsEvent[1] || "global";
51
+ addEvent(ev, namespace);
52
+ }
53
+ }
54
+ return this;
55
+ }
56
+
57
+ function off(events, handler) {
58
+ var eventRegistry, elem;
59
+
60
+ function removeEvent(ev, namespace, handler) {
61
+ if (ev in eventRegistry === true) {
62
+ //unbind to dom events
63
+ if (elem.removeEventListener) { // all browsers except IE before version 9
64
+ elem.removeEventListener(ev, handler, false);
65
+ } else if (elem.detachEvent) { // IE before version 9
66
+ elem.detachEvent("on" + ev, handler);
67
+ }
68
+ if (namespace === "global") {
69
+ for (var nmsp in eventRegistry[ev]) {
70
+ eventRegistry[ev][nmsp].splice(eventRegistry[ev][nmsp].indexOf(handler), 1);
71
+ }
72
+ } else {
73
+ eventRegistry[ev][namespace].splice(eventRegistry[ev][namespace].indexOf(handler), 1);
74
+ }
75
+ }
76
+ }
77
+
78
+ function resolveNamespace(ev, namespace) {
79
+ var evts = [],
80
+ hndx, hndL;
81
+ if (ev.length > 0) {
82
+ if (handler === undefined) {
83
+ for (hndx = 0, hndL = eventRegistry[ev][namespace].length; hndx < hndL; hndx++) {
84
+ evts.push({
85
+ ev: ev,
86
+ namespace: namespace && namespace.length > 0 ? namespace : "global",
87
+ handler: eventRegistry[ev][namespace][hndx]
88
+ });
89
+ }
90
+ } else {
91
+ evts.push({
92
+ ev: ev,
93
+ namespace: namespace && namespace.length > 0 ? namespace : "global",
94
+ handler: handler
95
+ });
96
+ }
97
+ } else if (namespace.length > 0) {
98
+ for (var evNdx in eventRegistry) {
99
+ for (var nmsp in eventRegistry[evNdx]) {
100
+ if (nmsp === namespace) {
101
+ if (handler === undefined) {
102
+ for (hndx = 0, hndL = eventRegistry[evNdx][nmsp].length; hndx < hndL; hndx++) {
103
+ evts.push({
104
+ ev: evNdx,
105
+ namespace: nmsp,
106
+ handler: eventRegistry[evNdx][nmsp][hndx]
107
+ });
108
+ }
109
+ } else {
110
+ evts.push({
111
+ ev: evNdx,
112
+ namespace: nmsp,
113
+ handler: handler
114
+ });
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+
121
+ return evts;
122
+ }
123
+
124
+ if (isValidElement(this[0]) && events) {
125
+ eventRegistry = this[0].eventRegistry;
126
+ elem = this[0];
127
+
128
+
129
+ var _events = events.split(" ");
130
+ for (var endx = 0; endx < _events.length; endx++) {
131
+ var nsEvent = _events[endx].split("."),
132
+ offEvents = resolveNamespace(nsEvent[0], nsEvent[1]);
133
+ for (var i = 0, offEventsL = offEvents.length; i < offEventsL; i++) {
134
+ removeEvent(offEvents[i].ev, offEvents[i].namespace, offEvents[i].handler);
135
+ }
136
+ }
137
+ }
138
+ return this;
139
+ }
140
+
141
+ function trigger(events /* , args... */) {
142
+ if (isValidElement(this[0])) {
143
+ var eventRegistry = this[0].eventRegistry,
144
+ elem = this[0];
145
+ var _events = typeof events === "string" ? events.split(" ") : [events.type];
146
+ for (var endx = 0; endx < _events.length; endx++) {
147
+ var nsEvent = _events[endx].split("."),
148
+ ev = nsEvent[0],
149
+ namespace = nsEvent[1] || "global";
150
+ if (document !== undefined && namespace === "global") {
151
+ //trigger domevent
152
+ var evnt, i, params = {
153
+ bubbles: true,
154
+ cancelable: true,
155
+ detail: arguments[1]
156
+ };
157
+ // The custom event that will be created
158
+ if (document.createEvent) {
159
+ try {
160
+ switch (ev) {
161
+ case "input":
162
+ params.inputType = "insertText";
163
+ evnt = new InputEvent(ev, params);
164
+ break;
165
+ default:
166
+ evnt = new CustomEvent(ev, params);
167
+ }
168
+ } catch (e) {
169
+ evnt = document.createEvent("CustomEvent");
170
+ evnt.initCustomEvent(ev, params.bubbles, params.cancelable, params.detail);
171
+ }
172
+ if (events.type) extend(evnt, events);
173
+ elem.dispatchEvent(evnt);
174
+ } else {
175
+ evnt = document.createEventObject();
176
+ evnt.eventType = ev;
177
+ evnt.detail = arguments[1];
178
+ if (events.type) extend(evnt, events);
179
+ elem.fireEvent("on" + evnt.eventType, evnt);
180
+ }
181
+ } else if (eventRegistry[ev] !== undefined) {
182
+ arguments[0] = arguments[0].type ? arguments[0] : DependencyLib.Event(arguments[0]);
183
+ arguments[0].detail = arguments.slice(1);
184
+ if (namespace === "global") {
185
+ for (var nmsp in eventRegistry[ev]) {
186
+ for (i = 0; i < eventRegistry[ev][nmsp].length; i++) {
187
+ eventRegistry[ev][nmsp][i].apply(elem, arguments);
188
+ }
189
+ }
190
+ } else {
191
+ for (i = 0; i < eventRegistry[ev][namespace].length; i++) {
192
+ eventRegistry[ev][namespace][i].apply(elem, arguments);
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+ return this;
199
+ }
@@ -0,0 +1,58 @@
1
+ export default function extend() {
2
+ let options, name, src, copy, copyIsArray, clone,
3
+ target = arguments[0] || {},
4
+ i = 1,
5
+ length = arguments.length,
6
+ deep = false;
7
+
8
+ // Handle a deep copy situation
9
+ if (typeof target === "boolean") {
10
+ deep = target;
11
+
12
+ // Skip the boolean and the target
13
+ target = arguments[i] || {};
14
+ i++;
15
+ }
16
+
17
+ // Handle case when target is a string or something (possible in deep copy)
18
+ if (typeof target !== "object" && typeof target !== "function") {
19
+ target = {};
20
+ }
21
+
22
+ for (; i < length; i++) {
23
+ // Only deal with non-null/undefined values
24
+ if ((options = arguments[i]) != null) {
25
+ // Extend the base object
26
+ for (name in options) {
27
+ src = target[name];
28
+ copy = options[name];
29
+
30
+ // Prevent never-ending loop
31
+ if (target === copy) {
32
+ continue;
33
+ }
34
+
35
+ // Recurse if we're merging plain objects or arrays
36
+ if (deep && copy && (Object.prototype.toString.call(copy) === "[object Object]" || (copyIsArray = Array.isArray(copy)))) {
37
+ if (copyIsArray) {
38
+ copyIsArray = false;
39
+ clone = src && Array.isArray(src) ? src : [];
40
+
41
+ } else {
42
+ clone = src && Object.prototype.toString.call(src) === "[object Object]" ? src : {};
43
+ }
44
+
45
+ // Never move original objects, clone them
46
+ target[name] = extend(deep, clone, copy);
47
+
48
+ // Don't bring in undefined values
49
+ } else if (copy !== undefined) {
50
+ target[name] = copy;
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ // Return the modified object
57
+ return target;
58
+ }
@@ -5,8 +5,9 @@
5
5
  Licensed under the MIT license
6
6
  */
7
7
 
8
- var jquery = require("jquery");
9
- if(jquery === undefined) {
8
+ import jQuery from "jquery";
9
+
10
+ if (jQuery === undefined) {
10
11
  throw "jQuery not loaded!";
11
12
  }
12
- module.exports = jquery;
13
+ export default jQuery;