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
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
resetMaskSet,
|
|
10
10
|
seekNext
|
|
11
11
|
} from "./positioning";
|
|
12
|
-
import {isComplete,
|
|
12
|
+
import {isComplete, refreshFromBuffer} from "./validation";
|
|
13
13
|
import {ie} from "./environment";
|
|
14
14
|
import {EventHandlers} from "./eventhandlers";
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@ function applyInputValue(input, value) {
|
|
|
23
23
|
if (typeof opts.onBeforeMask === "function") value = opts.onBeforeMask.call(inputmask, value, opts) || value;
|
|
24
24
|
value = value.toString().split("");
|
|
25
25
|
checkVal(input, true, false, value);
|
|
26
|
-
inputmask.undoValue =
|
|
26
|
+
inputmask.undoValue = inputmask._valueGet(true);
|
|
27
27
|
if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate.call(inputmask).join("") && getLastValidPosition.call(inputmask) === -1) {
|
|
28
28
|
input.inputmask._valueSet("");
|
|
29
29
|
}
|
|
@@ -42,7 +42,7 @@ function clearOptionalTail(buffer) {
|
|
|
42
42
|
function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
|
43
43
|
const inputmask = input ? input.inputmask : this,
|
|
44
44
|
maskset = inputmask.maskset,
|
|
45
|
-
opts = inputmask.opts
|
|
45
|
+
opts = inputmask.opts, $ = inputmask.dependencyLib;
|
|
46
46
|
|
|
47
47
|
var inputValue = nptvl.slice(),
|
|
48
48
|
charCodes = "",
|
|
@@ -51,7 +51,7 @@ function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
|
|
51
51
|
opts.skipOptionalPartCharacter = ""; //see issue #2311
|
|
52
52
|
|
|
53
53
|
function isTemplateMatch(ndx, charCodes) {
|
|
54
|
-
var targetTemplate = getMaskTemplate.call(inputmask, true, 0).slice(ndx, seekNext.call(inputmask, ndx)).join("").replace(/'/g, ""),
|
|
54
|
+
var targetTemplate = getMaskTemplate.call(inputmask, true, 0).slice(ndx, seekNext.call(inputmask, ndx, false, false)).join("").replace(/'/g, ""),
|
|
55
55
|
charCodeNdx = targetTemplate.indexOf(charCodes);
|
|
56
56
|
//strip spaces from targetTemplate
|
|
57
57
|
while (charCodeNdx > 0 && targetTemplate[charCodeNdx - 1] === " ") charCodeNdx--;
|
|
@@ -73,30 +73,34 @@ function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
|
|
73
73
|
|
|
74
74
|
resetMaskSet.call(inputmask);
|
|
75
75
|
maskset.tests = {}; //reset tests ~ possible after alternating
|
|
76
|
-
initialNdx = opts.radixPoint ? determineNewCaretPosition.call(inputmask, {
|
|
76
|
+
initialNdx = opts.radixPoint ? determineNewCaretPosition.call(inputmask, {
|
|
77
|
+
begin: 0,
|
|
78
|
+
end: 0
|
|
79
|
+
}, false, opts.__financeInput === false ? "radixFocus" : undefined).begin : 0;
|
|
77
80
|
maskset.p = initialNdx;
|
|
78
81
|
inputmask.caretPos = {begin: initialNdx};
|
|
79
82
|
|
|
80
83
|
var staticMatches = [], prevCaretPos = inputmask.caretPos;
|
|
81
|
-
inputValue.forEach(
|
|
84
|
+
inputValue.forEach(function (charCode, ndx) {
|
|
82
85
|
if (charCode !== undefined) { //inputfallback strips some elements out of the inputarray. $.each logically presents them as undefined
|
|
83
|
-
if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true) &&
|
|
84
|
-
isValid.call(inputmask, ndx, inputValue[ndx], true, undefined,
|
|
85
|
-
|
|
86
|
-
} else
|
|
86
|
+
/*if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true) &&
|
|
87
|
+
isValid.call(inputmask, ndx, inputValue[ndx], true, undefined, true, true) === false) {
|
|
88
|
+
inputmask.caretPos.begin++;
|
|
89
|
+
} else*/
|
|
90
|
+
{
|
|
87
91
|
var keypress = new $.Event("_checkval");
|
|
88
|
-
keypress.
|
|
92
|
+
keypress.keyCode = charCode.toString().charCodeAt(0);
|
|
89
93
|
charCodes += charCode;
|
|
90
94
|
var lvp = getLastValidPosition.call(inputmask, undefined, true);
|
|
91
95
|
if (!isTemplateMatch(initialNdx, charCodes)) {
|
|
92
|
-
result = EventHandlers.keypressEvent.call(
|
|
96
|
+
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, inputmask.caretPos.begin);
|
|
93
97
|
|
|
94
98
|
if (result) {
|
|
95
99
|
initialNdx = inputmask.caretPos.begin + 1;
|
|
96
100
|
charCodes = "";
|
|
97
101
|
}
|
|
98
102
|
} else {
|
|
99
|
-
result = EventHandlers.keypressEvent.call(
|
|
103
|
+
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, lvp + 1);
|
|
100
104
|
}
|
|
101
105
|
if (result) {
|
|
102
106
|
if (result.pos !== undefined && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true && maskset.validPositions[result.pos].alternation === undefined) {
|
|
@@ -109,8 +113,10 @@ function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
|
|
109
113
|
inputmask.caretPos = {begin: result.forwardPosition, end: result.forwardPosition};
|
|
110
114
|
prevCaretPos = inputmask.caretPos;
|
|
111
115
|
} else {
|
|
112
|
-
inputmask.
|
|
113
|
-
|
|
116
|
+
if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true)) {
|
|
117
|
+
inputmask.caretPos.begin++;
|
|
118
|
+
} else inputmask.caretPos = prevCaretPos; //restore the caret position from before the failed validation
|
|
119
|
+
}
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
});
|
|
@@ -123,8 +129,8 @@ function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
|
|
123
129
|
var keypress = new $.Event("_checkval");
|
|
124
130
|
validPos = maskset.validPositions[sndx];
|
|
125
131
|
validPos.generatedInput = true;
|
|
126
|
-
keypress.
|
|
127
|
-
result = EventHandlers.keypressEvent.call(
|
|
132
|
+
keypress.keyCode = validPos.input.charCodeAt(0);
|
|
133
|
+
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, nextSndx);
|
|
128
134
|
if (result && result.pos !== undefined && result.pos !== sndx && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true) {
|
|
129
135
|
staticMatches.push(result.pos);
|
|
130
136
|
} else if (!result) break;
|
|
@@ -140,7 +146,12 @@ function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
148
|
if (writeOut) {
|
|
143
|
-
writeBuffer.call(
|
|
149
|
+
writeBuffer.call(
|
|
150
|
+
inputmask,
|
|
151
|
+
input,
|
|
152
|
+
getBuffer.call(inputmask), result ? result.forwardPosition : inputmask.caretPos.begin,
|
|
153
|
+
initiatingEvent || new $.Event("checkval"),
|
|
154
|
+
initiatingEvent && ((initiatingEvent.type === "input" && inputmask.undoValue !== getBuffer.call(inputmask).join("")) || initiatingEvent.type === "paste"));
|
|
144
155
|
// for (var vndx in maskset.validPositions) {
|
|
145
156
|
// if (maskset.validPositions[vndx].match.generated !== true) { //only remove non forced generated
|
|
146
157
|
// delete maskset.validPositions[vndx].generatedInput; //clear generated markings ~ consider initializing with a value as fully typed
|
|
@@ -222,6 +233,7 @@ function writeBuffer(input, buffer, caretPos, event, triggerEvents) {
|
|
|
222
233
|
if (input !== undefined) {
|
|
223
234
|
input.inputmask._valueSet(buffer.join(""));
|
|
224
235
|
if (caretPos !== undefined && (event === undefined || event.type !== "blur")) {
|
|
236
|
+
// console.log(caretPos);
|
|
225
237
|
caret.call(inputmask, input, caretPos, undefined, undefined, (event !== undefined && event.type === "keydown" && (event.keyCode === keyCode.DELETE || event.keyCode === keyCode.BACKSPACE)));
|
|
226
238
|
}
|
|
227
239
|
if (triggerEvents === true) {
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Copyright (c) Robin Herbots
|
|
5
5
|
* Licensed under the MIT license
|
|
6
6
|
*/
|
|
7
|
-
import "./getPrototypeOf";
|
|
7
|
+
import "./polyfills/Object.getPrototypeOf";
|
|
8
|
+
import "./polyfills/Array.includes";
|
|
9
|
+
|
|
8
10
|
import {mask} from "./mask";
|
|
9
11
|
import $ from "./dependencyLibs/inputmask.dependencyLib";
|
|
10
12
|
import window from "./global/window";
|
|
@@ -16,10 +18,15 @@ import {checkVal, unmaskedvalue} from "./inputHandling";
|
|
|
16
18
|
import {EventRuler} from "./eventruler";
|
|
17
19
|
import definitions from "./definitions";
|
|
18
20
|
import defaults from "./defaults";
|
|
21
|
+
import canUseDOM from "./canUseDOM";
|
|
19
22
|
|
|
20
23
|
const document = window.document, dataKey = "_inputmask_opts";
|
|
21
24
|
|
|
22
25
|
function Inputmask(alias, options, internal) {
|
|
26
|
+
if (!canUseDOM) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
//allow instanciating without new
|
|
24
31
|
if (!(this instanceof Inputmask)) {
|
|
25
32
|
return new Inputmask(alias, options, internal);
|
|
@@ -73,7 +80,7 @@ Inputmask.prototype = {
|
|
|
73
80
|
if (typeof elems === "string") {
|
|
74
81
|
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
|
75
82
|
}
|
|
76
|
-
elems = elems.nodeName ? [elems] : elems;
|
|
83
|
+
elems = elems.nodeName ? [elems] : (Array.isArray(elems) ? elems : Array.from(elems));
|
|
77
84
|
elems.forEach(function (el, ndx) {
|
|
78
85
|
var scopedOpts = $.extend(true, {}, that.opts);
|
|
79
86
|
if (importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions), that.dataAttribute)) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import window from "./global/window";
|
|
2
2
|
import Inputmask from "./inputmask";
|
|
3
|
+
import canUseDOM from "./canUseDOM";
|
|
3
4
|
|
|
4
5
|
const document = window.document;
|
|
5
6
|
|
|
6
7
|
// add check if it is supported by the browser
|
|
7
8
|
// integrate shadowroot into maskcope
|
|
8
|
-
if (document && document.head && document.head.attachShadow && window.customElements && window.customElements.get("input-mask") === undefined) {
|
|
9
|
+
if (canUseDOM && document && document.head && document.head.attachShadow && window.customElements && window.customElements.get("input-mask") === undefined) {
|
|
9
10
|
class InputmaskElement extends HTMLElement {
|
|
10
11
|
constructor() {
|
|
11
12
|
super();
|