mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
parent
746e163d01
commit
1c7ea28b46
808 changed files with 316395 additions and 381162 deletions
1264
node_modules/inputmask/README.md
generated
vendored
1264
node_modules/inputmask/README.md
generated
vendored
File diff suppressed because it is too large
Load diff
5
node_modules/inputmask/bundle.js
generated
vendored
5
node_modules/inputmask/bundle.js
generated
vendored
|
@ -1,3 +1,8 @@
|
|||
import "./lib/polyfills/Object.getPrototypeOf";
|
||||
import "./lib/polyfills/Array.includes";
|
||||
import "./lib/polyfills/Object.entries";
|
||||
import "./lib/polyfills/String.includes";
|
||||
|
||||
import "./lib/extensions/inputmask.extensions";
|
||||
import "./lib/extensions/inputmask.date.extensions";
|
||||
import "./lib/extensions/inputmask.numeric.extensions";
|
||||
|
|
2799
node_modules/inputmask/dist/inputmask.js
generated
vendored
2799
node_modules/inputmask/dist/inputmask.js
generated
vendored
File diff suppressed because it is too large
Load diff
6
node_modules/inputmask/dist/inputmask.min.js
generated
vendored
6
node_modules/inputmask/dist/inputmask.min.js
generated
vendored
File diff suppressed because one or more lines are too long
1893
node_modules/inputmask/dist/jquery.inputmask.js
generated
vendored
1893
node_modules/inputmask/dist/jquery.inputmask.js
generated
vendored
File diff suppressed because it is too large
Load diff
6
node_modules/inputmask/dist/jquery.inputmask.min.js
generated
vendored
6
node_modules/inputmask/dist/jquery.inputmask.min.js
generated
vendored
File diff suppressed because one or more lines are too long
68
node_modules/inputmask/lib/defaults.js
generated
vendored
68
node_modules/inputmask/lib/defaults.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
import keyCode from "./keycode.json";
|
||||
import {keys} from "./keycode.js";
|
||||
|
||||
export default {
|
||||
_maxTestPos: 500,
|
||||
|
@ -52,35 +52,41 @@ export default {
|
|||
supportsInputType: ["text", "tel", "url", "password", "search"], //list with the supported input types
|
||||
//specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
|
||||
ignorables: [
|
||||
keyCode.BACKSPACE,
|
||||
keyCode.TAB,
|
||||
keyCode["PAUSE/BREAK"],
|
||||
keyCode.ESCAPE,
|
||||
keyCode.PAGE_UP,
|
||||
keyCode.PAGE_DOWN,
|
||||
keyCode.END,
|
||||
keyCode.HOME,
|
||||
keyCode.LEFT,
|
||||
keyCode.UP,
|
||||
keyCode.RIGHT,
|
||||
keyCode.DOWN,
|
||||
keyCode.INSERT,
|
||||
keyCode.DELETE,
|
||||
93,
|
||||
112,
|
||||
113,
|
||||
114,
|
||||
115,
|
||||
116,
|
||||
117,
|
||||
118,
|
||||
119,
|
||||
120,
|
||||
121,
|
||||
122,
|
||||
123,
|
||||
0,
|
||||
229
|
||||
keys.Backspace,
|
||||
keys.Tab,
|
||||
keys.Pause,
|
||||
keys.Escape,
|
||||
keys.PageUp,
|
||||
keys.PageDown,
|
||||
keys.End,
|
||||
keys.Home,
|
||||
keys.ArrowLeft,
|
||||
keys.ArrowUp,
|
||||
keys.ArrowRight,
|
||||
keys.ArrowDown,
|
||||
keys.Insert,
|
||||
keys.Delete,
|
||||
keys.ContextMenu,
|
||||
keys.F1,
|
||||
keys.F2,
|
||||
keys.F3,
|
||||
keys.F4,
|
||||
keys.F5,
|
||||
keys.F6,
|
||||
keys.F7,
|
||||
keys.F8,
|
||||
keys.F9,
|
||||
keys.F10,
|
||||
keys.F11,
|
||||
keys.F12,
|
||||
keys.Process,
|
||||
keys.Unidentified,
|
||||
keys.Shift,
|
||||
keys.Control,
|
||||
keys.Alt,
|
||||
keys.Tab,
|
||||
keys.AltGraph,
|
||||
keys.CapsLock
|
||||
],
|
||||
isComplete: null, //override for isComplete - args => buffer, opts - return true || false
|
||||
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
|
||||
|
@ -98,4 +104,4 @@ export default {
|
|||
usePrototypeDefinitions: true, //use the default defined definitions from the prototype
|
||||
validationEventTimeOut: 3000, //Time to show validation error on form submit
|
||||
substitutes: {} //define character substitutes
|
||||
};
|
||||
};
|
||||
|
|
49
node_modules/inputmask/lib/dependencyLibs/events.js
generated
vendored
49
node_modules/inputmask/lib/dependencyLibs/events.js
generated
vendored
|
@ -15,7 +15,7 @@ if (typeof window.CustomEvent === "function") {
|
|||
} else {
|
||||
if (canUseDOM) {
|
||||
Event = function (event, params) {
|
||||
params = params || {bubbles: false, cancelable: false, detail: undefined};
|
||||
params = params || {bubbles: false, cancelable: false, composed: true, detail: undefined};
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
return evt;
|
||||
|
@ -31,7 +31,7 @@ function on(events, handler) {
|
|||
if (elem.addEventListener) { // all browsers except IE before version 9
|
||||
elem.addEventListener(ev, handler, false);
|
||||
} else if (elem.attachEvent) { // IE before version 9
|
||||
elem.attachEvent("on" + ev, handler);
|
||||
elem.attachEvent(`on${ev}`, handler);
|
||||
}
|
||||
eventRegistry[ev] = eventRegistry[ev] || {};
|
||||
eventRegistry[ev][namespace] = eventRegistry[ev][namespace] || [];
|
||||
|
@ -42,14 +42,10 @@ function on(events, handler) {
|
|||
var eventRegistry = this[0].eventRegistry,
|
||||
elem = this[0];
|
||||
|
||||
|
||||
var _events = events.split(" ");
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
ev = nsEvent[0],
|
||||
namespace = nsEvent[1] || "global";
|
||||
events.split(" ").forEach((event) => {
|
||||
const [ev, namespace = "global"] = event.split(".");
|
||||
addEvent(ev, namespace);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -63,7 +59,7 @@ function off(events, handler) {
|
|||
if (elem.removeEventListener) { // all browsers except IE before version 9
|
||||
elem.removeEventListener(ev, handler, false);
|
||||
} else if (elem.detachEvent) { // IE before version 9
|
||||
elem.detachEvent("on" + ev, handler);
|
||||
elem.detachEvent(`on${ev}`, handler);
|
||||
}
|
||||
if (namespace === "global") {
|
||||
for (var nmsp in eventRegistry[ev]) {
|
||||
|
@ -125,15 +121,12 @@ function off(events, handler) {
|
|||
eventRegistry = this[0].eventRegistry;
|
||||
elem = this[0];
|
||||
|
||||
|
||||
var _events = events.split(" ");
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
offEvents = resolveNamespace(nsEvent[0], nsEvent[1]);
|
||||
for (var i = 0, offEventsL = offEvents.length; i < offEventsL; i++) {
|
||||
removeEvent(offEvents[i].ev, offEvents[i].namespace, offEvents[i].handler);
|
||||
}
|
||||
}
|
||||
events.split(" ").forEach((event) => {
|
||||
const [ev, namespace] = event.split(".");
|
||||
resolveNamespace(ev, namespace).forEach(({ev: ev1, handler: handler1, namespace: namespace1}) => {
|
||||
removeEvent(ev1, namespace1, handler1);
|
||||
});
|
||||
});
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -152,6 +145,7 @@ function trigger(events /* , args... */) {
|
|||
var evnt, i, params = {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true,
|
||||
detail: arguments[1]
|
||||
};
|
||||
// The custom event that will be created
|
||||
|
@ -181,19 +175,12 @@ function trigger(events /* , args... */) {
|
|||
} else if (eventRegistry[ev] !== undefined) {
|
||||
arguments[0] = arguments[0].type ? arguments[0] : DependencyLib.Event(arguments[0]);
|
||||
arguments[0].detail = arguments.slice(1);
|
||||
if (namespace === "global") {
|
||||
for (var nmsp in eventRegistry[ev]) {
|
||||
for (i = 0; i < eventRegistry[ev][nmsp].length; i++) {
|
||||
eventRegistry[ev][nmsp][i].apply(elem, arguments);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < eventRegistry[ev][namespace].length; i++) {
|
||||
eventRegistry[ev][namespace][i].apply(elem, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
const registry = eventRegistry[ev],
|
||||
handlers = namespace === "global" ? Object.values(registry).flat() : registry[namespace];
|
||||
handlers.forEach(handler => handler.apply(elem, arguments));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
9
node_modules/inputmask/lib/environment.js
generated
vendored
9
node_modules/inputmask/lib/environment.js
generated
vendored
|
@ -1,9 +1,8 @@
|
|||
import window from "./global/window";
|
||||
|
||||
const ua = (window.navigator && window.navigator.userAgent) || "",
|
||||
ie = (ua.indexOf("MSIE ") > 0) || (ua.indexOf("Trident/") > 0),
|
||||
mobile = "ontouchstart" in window, //not entirely correct but will currently do
|
||||
iemobile = /iemobile/i.test(ua),
|
||||
iphone = /iphone/i.test(ua) && !iemobile;
|
||||
ie = (ua.indexOf("MSIE ") > 0) || (ua.indexOf("Trident/") > 0),
|
||||
mobile = (navigator.userAgentData && navigator.userAgentData.mobile) || (window.navigator && window.navigator.maxTouchPoints) || "ontouchstart" in window, //not entirely correct but will currently do
|
||||
iphone = /iphone/i.test(ua);
|
||||
|
||||
export {ua, ie, mobile, iemobile, iphone};
|
||||
export {ie, mobile, iphone};
|
||||
|
|
907
node_modules/inputmask/lib/eventhandlers.js
generated
vendored
907
node_modules/inputmask/lib/eventhandlers.js
generated
vendored
|
@ -1,513 +1,502 @@
|
|||
import {
|
||||
caret, determineNewCaretPosition,
|
||||
getBuffer, getBufferTemplate,
|
||||
getLastValidPosition, isMask,
|
||||
resetMaskSet,
|
||||
seekNext,
|
||||
seekPrevious,
|
||||
translatePosition
|
||||
caret, determineNewCaretPosition,
|
||||
getBuffer, getBufferTemplate,
|
||||
getLastValidPosition, isMask,
|
||||
resetMaskSet,
|
||||
seekNext,
|
||||
seekPrevious,
|
||||
translatePosition
|
||||
} from "./positioning";
|
||||
import keyCode from "./keycode.json";
|
||||
import { iemobile, iphone } from "./environment";
|
||||
import { handleRemove, isComplete, isSelection, isValid } from "./validation";
|
||||
import { applyInputValue, checkVal, clearOptionalTail, HandleNativePlaceholder, writeBuffer } from "./inputHandling";
|
||||
import { getPlaceholder, getTest } from "./validation-tests";
|
||||
import {keys} from "./keycode.js";
|
||||
import {iphone, mobile} from "./environment";
|
||||
import {handleRemove, isComplete, isSelection, isValid} from "./validation";
|
||||
import {applyInputValue, checkVal, clearOptionalTail, HandleNativePlaceholder, writeBuffer} from "./inputHandling";
|
||||
import {getPlaceholder, getTest} from "./validation-tests";
|
||||
|
||||
export { EventHandlers };
|
||||
export {EventHandlers};
|
||||
|
||||
var EventHandlers = {
|
||||
keydownEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib,
|
||||
maskset = inputmask.maskset;
|
||||
keyEvent: function (e, checkval, writeOut, strict, ndx) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
var input = this,
|
||||
$input = $(input),
|
||||
k = e.keyCode,
|
||||
pos = caret.call(inputmask, input);
|
||||
var input = this,
|
||||
$input = $(input),
|
||||
c = e.key,
|
||||
pos = caret.call(inputmask, input);
|
||||
|
||||
var kdResult = opts.onKeyDown.call(this, e, getBuffer.call(inputmask), pos, opts);
|
||||
if (kdResult !== undefined) return kdResult;
|
||||
var kdResult = opts.onKeyDown.call(this, e, getBuffer.call(inputmask), pos, opts);
|
||||
if (kdResult !== undefined) return kdResult;
|
||||
|
||||
//backspace, delete, and escape get special treatment
|
||||
if (k === keyCode.BACKSPACE || k === keyCode.DELETE || (iphone && k === keyCode.BACKSPACE_SAFARI) || (e.ctrlKey && k === keyCode.X && !("oncut" in input))) { //backspace/delete
|
||||
e.preventDefault(); //stop default action but allow propagation
|
||||
handleRemove.call(inputmask, input, k, pos);
|
||||
writeBuffer(input, getBuffer.call(inputmask, true), maskset.p, e, input.inputmask._valueGet() !== getBuffer.call(inputmask).join(""));
|
||||
} else if (k === keyCode.END || k === keyCode.PAGE_DOWN) { //when END or PAGE_DOWN pressed set position at lastmatch
|
||||
e.preventDefault();
|
||||
var caretPos = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
|
||||
caret.call(inputmask, input, e.shiftKey ? pos.begin : caretPos, caretPos, true);
|
||||
} else if ((k === keyCode.HOME && !e.shiftKey) || k === keyCode.PAGE_UP) { //Home or page_up
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, 0, e.shiftKey ? pos.begin : 0, true);
|
||||
} else if (((opts.undoOnEscape && k === keyCode.ESCAPE) || (false && k === keyCode.Z && e.ctrlKey)) && e.altKey !== true) { //escape && undo && #762
|
||||
checkVal(input, true, false, inputmask.undoValue.split(""));
|
||||
$input.trigger("click");
|
||||
} else if (k === keyCode.INSERT && !(e.shiftKey || e.ctrlKey) && inputmask.userOptions.insertMode === undefined) { //insert
|
||||
if (!isSelection.call(inputmask, pos)) {
|
||||
opts.insertMode = !opts.insertMode;
|
||||
caret.call(inputmask, input, pos.begin, pos.begin);
|
||||
} else opts.insertMode = !opts.insertMode;
|
||||
} else if (opts.tabThrough === true && k === keyCode.TAB) {
|
||||
if (e.shiftKey === true) {
|
||||
pos.end = seekPrevious.call(inputmask, pos.end, true);
|
||||
if (getTest.call(inputmask, pos.end - 1).match.static === true) {
|
||||
pos.end--;
|
||||
}
|
||||
pos.begin = seekPrevious.call(inputmask, pos.end, true);
|
||||
if (pos.begin >= 0 && pos.end > 0) {
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, pos.begin, pos.end);
|
||||
}
|
||||
} else {
|
||||
pos.begin = seekNext.call(inputmask, pos.begin, true);
|
||||
pos.end = seekNext.call(inputmask, pos.begin, true);
|
||||
if (pos.end < maskset.maskLength) pos.end--;
|
||||
if (pos.begin <= maskset.maskLength) {
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, pos.begin, pos.end);
|
||||
}
|
||||
}
|
||||
} else if (!e.shiftKey) {
|
||||
if (opts.insertModeVisual && opts.insertMode === false) {
|
||||
if (k === keyCode.RIGHT) {
|
||||
setTimeout(function () {
|
||||
var caretPos = caret.call(inputmask, input);
|
||||
caret.call(inputmask, input, caretPos.begin);
|
||||
}, 0);
|
||||
} else if (k === keyCode.LEFT) {
|
||||
setTimeout(function () {
|
||||
var caretPos = {
|
||||
begin: translatePosition.call(inputmask, input.inputmask.caretPos.begin),
|
||||
end: translatePosition.call(inputmask, input.inputmask.caretPos.end)
|
||||
};
|
||||
if (inputmask.isRTL) {
|
||||
caret.call(inputmask, input, caretPos.begin + (caretPos.begin === maskset.maskLength ? 0 : 1));
|
||||
} else {
|
||||
caret.call(inputmask, input, caretPos.begin - (caretPos.begin === 0 ? 0 : 1));
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//backspace, delete, and escape get special treatment
|
||||
if (c === keys.Backspace || c === keys.Delete || (iphone && c === keys.BACKSPACE_SAFARI) || (e.ctrlKey && c === keys.x && !("oncut" in input))) { //backspace/delete
|
||||
e.preventDefault(); //stop default action but allow propagation
|
||||
handleRemove.call(inputmask, input, c, pos);
|
||||
writeBuffer(input, getBuffer.call(inputmask, true), maskset.p, e, input.inputmask._valueGet() !== getBuffer.call(inputmask).join(""));
|
||||
} else if (c === keys.End || c === keys.PageDown) { //when END or PAGE_DOWN pressed set position at lastmatch
|
||||
e.preventDefault();
|
||||
var caretPos = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
|
||||
caret.call(inputmask, input, e.shiftKey ? pos.begin : caretPos, caretPos, true);
|
||||
} else if ((c === keys.Home && !e.shiftKey) || c === keys.PageUp) { //Home or page_up
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, 0, e.shiftKey ? pos.begin : 0, true);
|
||||
} else if (((opts.undoOnEscape && c === keys.Escape) || (false && c === keys.z && e.ctrlKey)) && e.altKey !== true) { //escape && undo && #762
|
||||
checkVal(input, true, false, inputmask.undoValue.split(""));
|
||||
$input.trigger("click");
|
||||
} else if (c === keys.Insert && !(e.shiftKey || e.ctrlKey) && inputmask.userOptions.insertMode === undefined) { //insert
|
||||
if (!isSelection.call(inputmask, pos)) {
|
||||
opts.insertMode = !opts.insertMode;
|
||||
caret.call(inputmask, input, pos.begin, pos.begin);
|
||||
} else opts.insertMode = !opts.insertMode;
|
||||
} else if (opts.tabThrough === true && c === keys.Tab) {
|
||||
if (e.shiftKey === true) {
|
||||
pos.end = seekPrevious.call(inputmask, pos.end, true);
|
||||
if (getTest.call(inputmask, pos.end - 1).match.static === true) {
|
||||
pos.end--;
|
||||
}
|
||||
pos.begin = seekPrevious.call(inputmask, pos.end, true);
|
||||
if (pos.begin >= 0 && pos.end > 0) {
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, pos.begin, pos.end);
|
||||
}
|
||||
} else {
|
||||
pos.begin = seekNext.call(inputmask, pos.begin, true);
|
||||
pos.end = seekNext.call(inputmask, pos.begin, true);
|
||||
if (pos.end < maskset.maskLength) pos.end--;
|
||||
if (pos.begin <= maskset.maskLength) {
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, pos.begin, pos.end);
|
||||
}
|
||||
}
|
||||
} else if (!e.shiftKey) {
|
||||
if (opts.insertModeVisual && opts.insertMode === false) {
|
||||
if (c === keys.ArrowRight) {
|
||||
setTimeout(function () {
|
||||
var caretPos = caret.call(inputmask, input);
|
||||
caret.call(inputmask, input, caretPos.begin);
|
||||
}, 0);
|
||||
} else if (c === keys.ArrowLeft) {
|
||||
setTimeout(function () {
|
||||
var caretPos = {
|
||||
begin: translatePosition.call(inputmask, input.inputmask.caretPos.begin),
|
||||
end: translatePosition.call(inputmask, input.inputmask.caretPos.end)
|
||||
};
|
||||
if (inputmask.isRTL) {
|
||||
caret.call(inputmask, input, caretPos.begin + (caretPos.begin === maskset.maskLength ? 0 : 1));
|
||||
} else {
|
||||
caret.call(inputmask, input, caretPos.begin - (caretPos.begin === 0 ? 0 : 1));
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputmask.ignorable = opts.ignorables.includes(k);
|
||||
},
|
||||
keypressEvent: function (e, checkval, writeOut, strict, ndx) {
|
||||
const inputmask = this.inputmask || this, opts = inputmask.opts, $ = inputmask.dependencyLib,
|
||||
maskset = inputmask.maskset;
|
||||
inputmask.isComposing = (c == keys.Process || c == keys.Unidentified);
|
||||
inputmask.ignorable = opts.ignorables.includes(c);
|
||||
return EventHandlers.keypressEvent.call(this, e, checkval, writeOut, strict, ndx);
|
||||
},
|
||||
keypressEvent: function (e, checkval, writeOut, strict, ndx) {
|
||||
const inputmask = this.inputmask || this, opts = inputmask.opts, $ = inputmask.dependencyLib,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
var input = inputmask.el,
|
||||
$input = $(input),
|
||||
k = e.keyCode;
|
||||
var input = inputmask.el,
|
||||
$input = $(input),
|
||||
c = e.key;
|
||||
|
||||
if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || inputmask.ignorable))) {
|
||||
if (k === keyCode.ENTER && inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
// e.preventDefault();
|
||||
setTimeout(function () {
|
||||
$input.trigger("change");
|
||||
}, 0);
|
||||
}
|
||||
inputmask.skipInputEvent = true; //skip the input as otherwise the skipped char could be picked up for validation by the inputfallback
|
||||
return true;
|
||||
} else if (k) {
|
||||
//special treat the decimal separator
|
||||
if ((k === 44 || k === 46) && e.location === 3 && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0);
|
||||
var pos = checkval ? {
|
||||
begin: ndx,
|
||||
end: ndx
|
||||
} : caret.call(inputmask, input),
|
||||
forwardPosition, c = String.fromCharCode(k);
|
||||
if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || inputmask.ignorable))) {
|
||||
if (c === keys.Enter) {
|
||||
if (inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
// e.preventDefault();
|
||||
|
||||
//allow for character substitution
|
||||
c = opts.substitutes[c] || c;
|
||||
maskset.writeOutBuffer = true;
|
||||
var valResult = isValid.call(inputmask, pos, c, strict, undefined, undefined, undefined, checkval);
|
||||
if (valResult !== false) {
|
||||
resetMaskSet.call(inputmask, true);
|
||||
forwardPosition = valResult.caret !== undefined ? valResult.caret : seekNext.call(inputmask, valResult.pos.begin ? valResult.pos.begin : valResult.pos);
|
||||
maskset.p = forwardPosition; //needed for checkval
|
||||
}
|
||||
setTimeout(function () {
|
||||
$input.trigger("change");
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
//inputmask.skipInputEvent = true; //skip the input as otherwise the skipped char could be picked up for validation by the inputfallback
|
||||
return;
|
||||
} else if (c) {
|
||||
//special treat the decimal separator
|
||||
// if ((k === 44 || k === 46) && e.location === 3 && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0);
|
||||
var pos = checkval ? {
|
||||
begin: ndx,
|
||||
end: ndx
|
||||
} : caret.call(inputmask, input),
|
||||
forwardPosition;
|
||||
|
||||
forwardPosition = ((opts.numericInput && valResult.caret === undefined) ? seekPrevious.call(inputmask, forwardPosition) : forwardPosition);
|
||||
if (writeOut !== false) {
|
||||
//allow for character substitution
|
||||
c = opts.substitutes[c] || c;
|
||||
maskset.writeOutBuffer = true;
|
||||
var valResult = isValid.call(inputmask, pos, c, strict, undefined, undefined, undefined, checkval);
|
||||
if (valResult !== false) {
|
||||
resetMaskSet.call(inputmask, true);
|
||||
forwardPosition = valResult.caret !== undefined ? valResult.caret : seekNext.call(inputmask, valResult.pos.begin ? valResult.pos.begin : valResult.pos);
|
||||
maskset.p = forwardPosition; //needed for checkval
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
opts.onKeyValidation.call(input, k, valResult);
|
||||
}, 0);
|
||||
if (maskset.writeOutBuffer && valResult !== false) {
|
||||
var buffer = getBuffer.call(inputmask);
|
||||
writeBuffer(input, buffer, forwardPosition, e, checkval !== true);
|
||||
}
|
||||
}
|
||||
forwardPosition = ((opts.numericInput && valResult.caret === undefined) ? seekPrevious.call(inputmask, forwardPosition) : forwardPosition);
|
||||
if (writeOut !== false) {
|
||||
|
||||
e.preventDefault();
|
||||
setTimeout(function () {
|
||||
opts.onKeyValidation.call(input, c, valResult);
|
||||
}, 0);
|
||||
if (maskset.writeOutBuffer && valResult !== false) {
|
||||
var buffer = getBuffer.call(inputmask);
|
||||
writeBuffer(input, buffer, forwardPosition, e, checkval !== true);
|
||||
}
|
||||
}
|
||||
|
||||
if (checkval) {
|
||||
if (valResult !== false) valResult.forwardPosition = forwardPosition;
|
||||
return valResult;
|
||||
}
|
||||
}
|
||||
},
|
||||
keyupEvent: function (e) {
|
||||
const inputmask = this.inputmask;
|
||||
e.preventDefault();
|
||||
|
||||
if (inputmask.isComposing && (e.keyCode === keyCode.KEY_229 || e.keyCode === keyCode.ENTER)) {
|
||||
inputmask.$el.trigger("input");
|
||||
}
|
||||
},
|
||||
pasteEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
if (checkval) {
|
||||
if (valResult !== false) valResult.forwardPosition = forwardPosition;
|
||||
return valResult;
|
||||
}
|
||||
}
|
||||
},
|
||||
pasteEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
|
||||
var input = this,
|
||||
inputValue = inputmask._valueGet(true),
|
||||
caretPos = caret.call(inputmask, input),
|
||||
tempValue;
|
||||
var input = this,
|
||||
inputValue = inputmask._valueGet(true),
|
||||
caretPos = caret.call(inputmask, input),
|
||||
tempValue;
|
||||
|
||||
if (inputmask.isRTL) {
|
||||
tempValue = caretPos.end;
|
||||
caretPos.end = translatePosition.call(inputmask, caretPos.begin);
|
||||
caretPos.begin = translatePosition.call(inputmask, tempValue);
|
||||
}
|
||||
if (inputmask.isRTL) {
|
||||
tempValue = caretPos.end;
|
||||
caretPos.end = translatePosition.call(inputmask, caretPos.begin);
|
||||
caretPos.begin = translatePosition.call(inputmask, tempValue);
|
||||
}
|
||||
|
||||
var valueBeforeCaret = inputValue.substr(0, caretPos.begin),
|
||||
valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
|
||||
var valueBeforeCaret = inputValue.substr(0, caretPos.begin),
|
||||
valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
|
||||
|
||||
if (valueBeforeCaret == (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).slice(0, caretPos.begin).join("")) valueBeforeCaret = "";
|
||||
if (valueAfterCaret == (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).slice(caretPos.end).join("")) valueAfterCaret = "";
|
||||
if (valueBeforeCaret == (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).slice(0, caretPos.begin).join("")) valueBeforeCaret = "";
|
||||
if (valueAfterCaret == (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).slice(caretPos.end).join("")) valueAfterCaret = "";
|
||||
|
||||
if (window.clipboardData && window.clipboardData.getData) { // IE
|
||||
inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret;
|
||||
} else if (e.clipboardData && e.clipboardData.getData) {
|
||||
inputValue = valueBeforeCaret + e.clipboardData.getData("text/plain") + valueAfterCaret;
|
||||
} else {
|
||||
return true;
|
||||
} //allow native paste event as fallback ~ masking will continue by inputfallback
|
||||
if (window.clipboardData && window.clipboardData.getData) { // IE
|
||||
inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret;
|
||||
} else if (e.clipboardData && e.clipboardData.getData) {
|
||||
inputValue = valueBeforeCaret + e.clipboardData.getData("text/plain") + valueAfterCaret;
|
||||
} else {
|
||||
return true;
|
||||
} //allow native paste event as fallback ~ masking will continue by inputfallback
|
||||
|
||||
var pasteValue = inputValue;
|
||||
if (inputmask.isRTL) {
|
||||
pasteValue = pasteValue.split("")
|
||||
for (let c of getBufferTemplate.call(inputmask)) {
|
||||
if (pasteValue[0] === c)
|
||||
pasteValue.shift();
|
||||
}
|
||||
pasteValue = pasteValue.join("");
|
||||
}
|
||||
if (typeof opts.onBeforePaste === "function") {
|
||||
pasteValue = opts.onBeforePaste.call(inputmask, pasteValue, opts);
|
||||
if (pasteValue === false) {
|
||||
return false;
|
||||
}
|
||||
if (!pasteValue) {
|
||||
pasteValue = inputValue;
|
||||
}
|
||||
}
|
||||
checkVal(input, true, false, pasteValue.toString().split(""), e);
|
||||
e.preventDefault()
|
||||
},
|
||||
inputFallBackEvent: function (e) { //fallback when keypress is not triggered
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
var pasteValue = inputValue;
|
||||
if (inputmask.isRTL) {
|
||||
pasteValue = pasteValue.split("");
|
||||
for (let c of getBufferTemplate.call(inputmask)) {
|
||||
if (pasteValue[0] === c)
|
||||
pasteValue.shift();
|
||||
}
|
||||
pasteValue = pasteValue.join("");
|
||||
}
|
||||
if (typeof opts.onBeforePaste === "function") {
|
||||
pasteValue = opts.onBeforePaste.call(inputmask, pasteValue, opts);
|
||||
if (pasteValue === false) {
|
||||
return false;
|
||||
}
|
||||
if (!pasteValue) {
|
||||
pasteValue = inputValue;
|
||||
}
|
||||
}
|
||||
checkVal(input, true, false, pasteValue.toString().split(""), e);
|
||||
e.preventDefault();
|
||||
},
|
||||
inputFallBackEvent: function (e) { //fallback when keypress is not triggered
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
// console.log(e.inputType);
|
||||
|
||||
function ieMobileHandler(input, inputValue, caretPos) {
|
||||
if (iemobile) { //iemobile just sets the character at the end althought the caret position is correctly set
|
||||
var inputChar = inputValue.replace(getBuffer.call(inputmask).join(""), "");
|
||||
if (inputChar.length === 1) {
|
||||
var iv = inputValue.split("");
|
||||
iv.splice(caretPos.begin, 0, inputChar);
|
||||
inputValue = iv.join("");
|
||||
}
|
||||
}
|
||||
return inputValue;
|
||||
}
|
||||
function analyseChanges(inputValue, buffer, caretPos) {
|
||||
var frontPart = inputValue.substr(0, caretPos.begin).split(""),
|
||||
backPart = inputValue.substr(caretPos.begin).split(""),
|
||||
frontBufferPart = buffer.substr(0, caretPos.begin).split(""),
|
||||
backBufferPart = buffer.substr(caretPos.begin).split("");
|
||||
|
||||
function analyseChanges(inputValue, buffer, caretPos) {
|
||||
var frontPart = inputValue.substr(0, caretPos.begin).split(""),
|
||||
backPart = inputValue.substr(caretPos.begin).split(""),
|
||||
frontBufferPart = buffer.substr(0, caretPos.begin).split(""),
|
||||
backBufferPart = buffer.substr(caretPos.begin).split("");
|
||||
var fpl = frontPart.length >= frontBufferPart.length ? frontPart.length : frontBufferPart.length,
|
||||
bpl = backPart.length >= backBufferPart.length ? backPart.length : backBufferPart.length,
|
||||
bl, i, action = "", data = [], marker = "~", placeholder;
|
||||
|
||||
var fpl = frontPart.length >= frontBufferPart.length ? frontPart.length : frontBufferPart.length,
|
||||
bpl = backPart.length >= backBufferPart.length ? backPart.length : backBufferPart.length,
|
||||
bl, i, action = "", data = [], marker = "~", placeholder;
|
||||
//align buffers
|
||||
while (frontPart.length < fpl) frontPart.push(marker);
|
||||
while (frontBufferPart.length < fpl) frontBufferPart.push(marker);
|
||||
while (backPart.length < bpl) backPart.unshift(marker);
|
||||
while (backBufferPart.length < bpl) backBufferPart.unshift(marker);
|
||||
|
||||
//align buffers
|
||||
while (frontPart.length < fpl) frontPart.push(marker);
|
||||
while (frontBufferPart.length < fpl) frontBufferPart.push(marker);
|
||||
while (backPart.length < bpl) backPart.unshift(marker);
|
||||
while (backBufferPart.length < bpl) backBufferPart.unshift(marker);
|
||||
var newBuffer = frontPart.concat(backPart);
|
||||
var oldBuffer = frontBufferPart.concat(backBufferPart);
|
||||
|
||||
var newBuffer = frontPart.concat(backPart);
|
||||
var oldBuffer = frontBufferPart.concat(backBufferPart);
|
||||
// console.log("N " + newBuffer);
|
||||
// console.log("O " + oldBuffer);
|
||||
|
||||
// console.log("N " + newBuffer);
|
||||
// console.log("O " + oldBuffer);
|
||||
for (i = 0, bl = newBuffer.length; i < bl; i++) {
|
||||
placeholder = getPlaceholder.call(inputmask, translatePosition.call(inputmask, i));
|
||||
switch (action) {
|
||||
case "insertText":
|
||||
if (oldBuffer[i - 1] === newBuffer[i] && caretPos.begin == newBuffer.length - 1) {
|
||||
data.push(newBuffer[i]);
|
||||
}
|
||||
i = bl;
|
||||
break;
|
||||
case "insertReplacementText":
|
||||
if (newBuffer[i] === marker) { //extend selection
|
||||
caretPos.end++;
|
||||
} else {
|
||||
// breakout loop
|
||||
i = bl;
|
||||
}
|
||||
break;
|
||||
case "deleteContentBackward":
|
||||
if (newBuffer[i] === marker) {
|
||||
caretPos.end++;
|
||||
} else {
|
||||
//breakout loop
|
||||
i = bl;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (newBuffer[i] !== oldBuffer[i]) {
|
||||
if ((newBuffer[i + 1] === marker || newBuffer[i + 1] === placeholder || newBuffer[i + 1] === undefined) && ((oldBuffer[i] === placeholder && oldBuffer[i + 1] === marker) || oldBuffer[i] === marker)) { //basic insert
|
||||
action = "insertText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
caretPos.end--;
|
||||
} else if (oldBuffer[i + 1] === marker && oldBuffer[i] === newBuffer[i + 1]) { //insert between
|
||||
action = "insertText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
caretPos.end--;
|
||||
} else if (newBuffer[i] !== placeholder && newBuffer[i] !== marker &&
|
||||
(newBuffer[i + 1] === marker || (oldBuffer[i] !== newBuffer[i] && oldBuffer[i + 1] === newBuffer[i + 1] /*single char replacement*/))) { //replace selection
|
||||
action = "insertReplacementText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
} else if (newBuffer[i] === marker) { //delete~backspace
|
||||
action = "deleteContentBackward";
|
||||
if (isMask.call(inputmask, translatePosition.call(inputmask, i), true) || oldBuffer[i] === opts.radixPoint) caretPos.end++;
|
||||
} else {
|
||||
i = bl;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, bl = newBuffer.length; i < bl; i++) {
|
||||
placeholder = getPlaceholder.call(inputmask, translatePosition.call(inputmask, i));
|
||||
switch (action) {
|
||||
case "insertText":
|
||||
if (oldBuffer[i - 1] === newBuffer[i] && caretPos.begin == newBuffer.length - 1) {
|
||||
data.push(newBuffer[i]);
|
||||
}
|
||||
i = bl;
|
||||
break;
|
||||
case "insertReplacementText":
|
||||
if (newBuffer[i] === marker) { //extend selection
|
||||
caretPos.end++;
|
||||
} else {
|
||||
// breakout loop
|
||||
i = bl;
|
||||
}
|
||||
break;
|
||||
case "deleteContentBackward":
|
||||
if (newBuffer[i] === marker) {
|
||||
caretPos.end++;
|
||||
} else {
|
||||
//breakout loop
|
||||
i = bl;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (newBuffer[i] !== oldBuffer[i]) {
|
||||
if ((newBuffer[i + 1] === marker || newBuffer[i + 1] === placeholder || newBuffer[i + 1] === undefined) && ((oldBuffer[i] === placeholder && oldBuffer[i + 1] === marker) || oldBuffer[i] === marker)) { //basic insert
|
||||
action = "insertText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
caretPos.end--;
|
||||
} else if (oldBuffer[i + 1] === marker && oldBuffer[i] === newBuffer[i + 1]) { //insert between
|
||||
action = "insertText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
caretPos.end--;
|
||||
} else if (newBuffer[i] !== placeholder && newBuffer[i] !== marker &&
|
||||
(newBuffer[i + 1] === marker || (oldBuffer[i] !== newBuffer[i] && oldBuffer[i + 1] === newBuffer[i + 1] /*single char replacement*/))) { //replace selection
|
||||
action = "insertReplacementText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
} else if (newBuffer[i] === marker) { //delete~backspace
|
||||
action = "deleteContentBackward";
|
||||
if (isMask.call(inputmask, translatePosition.call(inputmask, i), true) || oldBuffer[i] === opts.radixPoint) caretPos.end++;
|
||||
} else {
|
||||
i = bl;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
action: action,
|
||||
data: data,
|
||||
caret: caretPos
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
action: action,
|
||||
data: data,
|
||||
caret: caretPos
|
||||
};
|
||||
}
|
||||
var input = this,
|
||||
inputValue = input.inputmask._valueGet(true),
|
||||
buffer = (inputmask.isRTL ? getBuffer.call(inputmask).slice().reverse() : getBuffer.call(inputmask)).join(""),
|
||||
caretPos = caret.call(inputmask, input, undefined, undefined, true),
|
||||
changes;
|
||||
|
||||
var input = this,
|
||||
inputValue = input.inputmask._valueGet(true),
|
||||
buffer = (inputmask.isRTL ? getBuffer.call(inputmask).slice().reverse() : getBuffer.call(inputmask)).join(""),
|
||||
caretPos = caret.call(inputmask, input, undefined, undefined, true);
|
||||
if (buffer !== inputValue) {
|
||||
changes = analyseChanges(inputValue, buffer, caretPos);
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
input.focus();
|
||||
}
|
||||
writeBuffer(input, getBuffer.call(inputmask));
|
||||
caret.call(inputmask, input, caretPos.begin, caretPos.end, true);
|
||||
|
||||
if (buffer !== inputValue) {
|
||||
inputValue = ieMobileHandler(input, inputValue, caretPos);
|
||||
// Japanese IME hack #2662
|
||||
if (!mobile && inputmask.skipNextInsert && e.inputType === "insertText" && changes.action === "insertText" && inputmask.isComposing) {
|
||||
return false;
|
||||
}
|
||||
if (e.inputType === "insertCompositionText" && changes.action === "insertText" && inputmask.isComposing) {
|
||||
inputmask.skipNextInsert = true;
|
||||
} else {
|
||||
inputmask.skipNextInsert = false;
|
||||
}
|
||||
|
||||
var changes = analyseChanges(inputValue, buffer, caretPos);
|
||||
switch (changes.action) {
|
||||
case "insertText":
|
||||
case "insertReplacementText":
|
||||
changes.data.forEach(function (entry, ndx) {
|
||||
var keypress = new $.Event("keypress");
|
||||
keypress.key = entry;
|
||||
inputmask.ignorable = false; //make sure ignorable is ignored ;-)
|
||||
EventHandlers.keypressEvent.call(input, keypress);
|
||||
});
|
||||
setTimeout(function () { //#2195 trigger keyup to help some other plugins to track changes
|
||||
inputmask.$el.trigger("keyup");
|
||||
}, 0);
|
||||
break;
|
||||
case "deleteContentBackward":
|
||||
var keydown = new $.Event("keydown");
|
||||
keydown.key = keys.Backspace;
|
||||
EventHandlers.keyEvent.call(input, keydown);
|
||||
break;
|
||||
default:
|
||||
applyInputValue(input, inputValue);
|
||||
caret.call(inputmask, input, caretPos.begin, caretPos.end, true);
|
||||
break;
|
||||
}
|
||||
|
||||
// console.log(JSON.stringify(changes));
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
input.focus();
|
||||
}
|
||||
writeBuffer(input, getBuffer.call(inputmask));
|
||||
caret.call(inputmask, input, caretPos.begin, caretPos.end, true);
|
||||
switch (changes.action) {
|
||||
case "insertText":
|
||||
case "insertReplacementText":
|
||||
changes.data.forEach(function (entry, ndx) {
|
||||
var keypress = new $.Event("keypress");
|
||||
keypress.keyCode = entry.charCodeAt(0);
|
||||
inputmask.ignorable = false; //make sure ignorable is ignored ;-)
|
||||
EventHandlers.keypressEvent.call(input, keypress);
|
||||
});
|
||||
setTimeout(function () { //#2195 trigger keyup to help some other plugins to track changes
|
||||
inputmask.$el.trigger("keyup");
|
||||
}, 0);
|
||||
break;
|
||||
case "deleteContentBackward":
|
||||
var keydown = new $.Event("keydown");
|
||||
keydown.keyCode = keyCode.BACKSPACE;
|
||||
EventHandlers.keydownEvent.call(input, keydown);
|
||||
break;
|
||||
default:
|
||||
applyInputValue(input, inputValue);
|
||||
break;
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
setValueEvent: function (e) {
|
||||
const inputmask = this.inputmask;
|
||||
var input = this,
|
||||
value = (e && e.detail) ? e.detail[0] : arguments[1];
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
compositionendEvent: function (e) {
|
||||
const inputmask = this.inputmask;
|
||||
if (value === undefined) {
|
||||
value = input.inputmask._valueGet(true);
|
||||
}
|
||||
|
||||
inputmask.isComposing = false;
|
||||
inputmask.$el.trigger("input");
|
||||
},
|
||||
setValueEvent: function (e) {
|
||||
const inputmask = this.inputmask;
|
||||
var input = this,
|
||||
value = (e && e.detail) ? e.detail[0] : arguments[1];
|
||||
applyInputValue(input, value);
|
||||
|
||||
if (value === undefined) {
|
||||
value = input.inputmask._valueGet(true);
|
||||
}
|
||||
if ((e.detail && e.detail[1] !== undefined) || arguments[2] !== undefined) {
|
||||
caret.call(inputmask, input, e.detail ? e.detail[1] : arguments[2]);
|
||||
}
|
||||
}
|
||||
,
|
||||
focusEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
var input = this,
|
||||
nptValue = inputmask?._valueGet();
|
||||
|
||||
applyInputValue(input, value);
|
||||
|
||||
if ((e.detail && e.detail[1] !== undefined) || arguments[2] !== undefined) {
|
||||
caret.call(inputmask, input, e.detail ? e.detail[1] : arguments[2]);
|
||||
}
|
||||
}
|
||||
,
|
||||
focusEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
var input = this,
|
||||
nptValue = input.inputmask._valueGet();
|
||||
|
||||
if (opts.showMaskOnFocus) {
|
||||
if (nptValue !== getBuffer.call(inputmask).join("")) {
|
||||
writeBuffer(input, getBuffer.call(inputmask), seekNext.call(inputmask, getLastValidPosition.call(inputmask)));
|
||||
} /*else if (mouseEnter === false) { //only executed on focus without mouseenter
|
||||
if (opts.showMaskOnFocus) {
|
||||
if (nptValue !== getBuffer.call(inputmask).join("")) {
|
||||
writeBuffer(input, getBuffer.call(inputmask), seekNext.call(inputmask, getLastValidPosition.call(inputmask)));
|
||||
} /*else if (mouseEnter === false) { //only executed on focus without mouseenter
|
||||
caret(input, seekNext(getLastValidPosition()));
|
||||
}*/
|
||||
}
|
||||
if (opts.positionCaretOnTab === true && inputmask.mouseEnter === false && (!isComplete.call(inputmask, getBuffer.call(inputmask)) || getLastValidPosition.call(inputmask) === -1)) {
|
||||
EventHandlers.clickEvent.apply(input, [e, true]);
|
||||
}
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
},
|
||||
invalidEvent: function (e) {
|
||||
this.inputmask.validationEvent = true;
|
||||
},
|
||||
mouseleaveEvent: function () {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
}
|
||||
if (opts.positionCaretOnTab === true && inputmask.mouseEnter === false && (!isComplete.call(inputmask, getBuffer.call(inputmask)) || getLastValidPosition.call(inputmask) === -1)) {
|
||||
EventHandlers.clickEvent.apply(input, [e, true]);
|
||||
}
|
||||
inputmask.undoValue = inputmask?._valueGet(true);
|
||||
},
|
||||
invalidEvent: function (e) {
|
||||
this.inputmask.validationEvent = true;
|
||||
},
|
||||
mouseleaveEvent: function () {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
|
||||
var input = this;
|
||||
inputmask.mouseEnter = false;
|
||||
if (opts.clearMaskOnLostFocus && (input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
HandleNativePlaceholder(input, inputmask.originalPlaceholder);
|
||||
}
|
||||
},
|
||||
clickEvent: function (e, tabbed) {
|
||||
const inputmask = this.inputmask;
|
||||
var input = this;
|
||||
inputmask.mouseEnter = false;
|
||||
if (opts.clearMaskOnLostFocus && (input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
HandleNativePlaceholder(input, inputmask.originalPlaceholder);
|
||||
}
|
||||
},
|
||||
clickEvent: function (e, tabbed) {
|
||||
const inputmask = this.inputmask;
|
||||
inputmask.clicked++;
|
||||
|
||||
var input = this;
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement === input) {
|
||||
var newCaretPosition = determineNewCaretPosition.call(inputmask, caret.call(inputmask, input), tabbed);
|
||||
if (newCaretPosition !== undefined) {
|
||||
caret.call(inputmask, input, newCaretPosition);
|
||||
}
|
||||
}
|
||||
},
|
||||
cutEvent: function (e) {
|
||||
const inputmask = this.inputmask, maskset = inputmask.maskset;
|
||||
var input = this;
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement === input) {
|
||||
var newCaretPosition = determineNewCaretPosition.call(inputmask, caret.call(inputmask, input), tabbed);
|
||||
if (newCaretPosition !== undefined) {
|
||||
caret.call(inputmask, input, newCaretPosition);
|
||||
}
|
||||
}
|
||||
},
|
||||
cutEvent: function (e) {
|
||||
const inputmask = this.inputmask, maskset = inputmask.maskset;
|
||||
|
||||
var input = this,
|
||||
pos = caret.call(inputmask, input);
|
||||
var input = this,
|
||||
pos = caret.call(inputmask, input);
|
||||
|
||||
//correct clipboardData
|
||||
var clipData = inputmask.isRTL ? getBuffer.call(inputmask).slice(pos.end, pos.begin) : getBuffer.call(inputmask).slice(pos.begin, pos.end),
|
||||
clipDataText = inputmask.isRTL ? clipData.reverse().join("") : clipData.join("");
|
||||
if (window.navigator.clipboard) window.navigator.clipboard.writeText(clipDataText);
|
||||
else if (window.clipboardData && window.clipboardData.getData) { // IE
|
||||
window.clipboardData.setData("Text", clipDataText);
|
||||
}
|
||||
handleRemove.call(inputmask, input, keyCode.DELETE, pos);
|
||||
writeBuffer(input, getBuffer.call(inputmask), maskset.p, e, inputmask.undoValue !== inputmask._valueGet(true));
|
||||
},
|
||||
blurEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
//correct clipboardData
|
||||
var clipData = inputmask.isRTL ? getBuffer.call(inputmask).slice(pos.end, pos.begin) : getBuffer.call(inputmask).slice(pos.begin, pos.end),
|
||||
clipDataText = inputmask.isRTL ? clipData.reverse().join("") : clipData.join("");
|
||||
if (window.navigator.clipboard) window.navigator.clipboard.writeText(clipDataText);
|
||||
else if (window.clipboardData && window.clipboardData.getData) { // IE
|
||||
window.clipboardData.setData("Text", clipDataText);
|
||||
}
|
||||
handleRemove.call(inputmask, input, keys.Delete, pos);
|
||||
writeBuffer(input, getBuffer.call(inputmask), maskset.p, e, inputmask.undoValue !== inputmask._valueGet(true));
|
||||
},
|
||||
blurEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
inputmask.clicked = 0;
|
||||
|
||||
var $input = $(this),
|
||||
input = this;
|
||||
if (input.inputmask) {
|
||||
HandleNativePlaceholder(input, inputmask.originalPlaceholder);
|
||||
var nptValue = input.inputmask._valueGet(),
|
||||
buffer = getBuffer.call(inputmask).slice();
|
||||
var $input = $(this),
|
||||
input = this;
|
||||
if (input.inputmask) {
|
||||
HandleNativePlaceholder(input, inputmask.originalPlaceholder);
|
||||
var nptValue = input.inputmask._valueGet(),
|
||||
buffer = getBuffer.call(inputmask).slice();
|
||||
|
||||
if (nptValue !== "") {
|
||||
if (opts.clearMaskOnLostFocus) {
|
||||
if (getLastValidPosition.call(inputmask) === -1 && nptValue === getBufferTemplate.call(inputmask).join("")) {
|
||||
buffer = [];
|
||||
} else { //clearout optional tail of the mask
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
}
|
||||
if (isComplete.call(inputmask, buffer) === false) {
|
||||
setTimeout(function () {
|
||||
$input.trigger("incomplete");
|
||||
}, 0);
|
||||
if (opts.clearIncomplete) {
|
||||
resetMaskSet.call(inputmask);
|
||||
if (opts.clearMaskOnLostFocus) {
|
||||
buffer = [];
|
||||
} else {
|
||||
buffer = getBufferTemplate.call(inputmask).slice();
|
||||
}
|
||||
if (nptValue !== "") {
|
||||
if (opts.clearMaskOnLostFocus) {
|
||||
if (getLastValidPosition.call(inputmask) === -1 && nptValue === getBufferTemplate.call(inputmask).join("")) {
|
||||
buffer = [];
|
||||
} else { //clearout optional tail of the mask
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
}
|
||||
if (isComplete.call(inputmask, buffer) === false) {
|
||||
setTimeout(function () {
|
||||
$input.trigger("incomplete");
|
||||
}, 0);
|
||||
if (opts.clearIncomplete) {
|
||||
resetMaskSet.call(inputmask);
|
||||
if (opts.clearMaskOnLostFocus) {
|
||||
buffer = [];
|
||||
} else {
|
||||
buffer = getBufferTemplate.call(inputmask).slice();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeBuffer(input, buffer, undefined, e);
|
||||
}
|
||||
writeBuffer(input, buffer, undefined, e);
|
||||
}
|
||||
|
||||
if (inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
$input.trigger("change");
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
mouseenterEvent: function () {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
if (inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
$input.trigger("change");
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
mouseenterEvent: function () {
|
||||
const inputmask = this.inputmask, {showMaskOnHover} = inputmask.opts;
|
||||
|
||||
var input = this;
|
||||
inputmask.mouseEnter = true;
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
var bufferTemplate = (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join("");
|
||||
if (inputmask.placeholder !== bufferTemplate && input.placeholder !== inputmask.originalPlaceholder) {
|
||||
inputmask.originalPlaceholder = input.placeholder;
|
||||
}
|
||||
if (opts.showMaskOnHover) {
|
||||
HandleNativePlaceholder(input, bufferTemplate);
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
submitEvent: function () { //trigger change on submit if any
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
var input = this;
|
||||
inputmask.mouseEnter = true;
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
var bufferTemplate = (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join("");
|
||||
if (showMaskOnHover) {
|
||||
HandleNativePlaceholder(input, bufferTemplate);
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
submitEvent: function () { //trigger change on submit if any
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
|
||||
if (inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.$el.trigger("change");
|
||||
}
|
||||
if (/*opts.clearMaskOnLostFocus && */getLastValidPosition.call(inputmask) === -1 && inputmask._valueGet && inputmask._valueGet() === getBufferTemplate.call(inputmask).join("")) {
|
||||
inputmask._valueSet(""); //clear masktemplete on submit and still has focus
|
||||
}
|
||||
if (opts.clearIncomplete && isComplete.call(inputmask, getBuffer.call(inputmask)) === false) {
|
||||
inputmask._valueSet("");
|
||||
}
|
||||
if (opts.removeMaskOnSubmit) {
|
||||
inputmask._valueSet(inputmask.unmaskedvalue(), true);
|
||||
setTimeout(function () {
|
||||
writeBuffer(inputmask.el, getBuffer.call(inputmask));
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
,
|
||||
resetEvent: function () {
|
||||
const inputmask = this.inputmask;
|
||||
if (inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.$el.trigger("change");
|
||||
}
|
||||
if (/*opts.clearMaskOnLostFocus && */getLastValidPosition.call(inputmask) === -1 && inputmask._valueGet && inputmask._valueGet() === getBufferTemplate.call(inputmask).join("")) {
|
||||
inputmask._valueSet(""); //clear masktemplete on submit and still has focus
|
||||
}
|
||||
if (opts.clearIncomplete && isComplete.call(inputmask, getBuffer.call(inputmask)) === false) {
|
||||
inputmask._valueSet("");
|
||||
}
|
||||
if (opts.removeMaskOnSubmit) {
|
||||
inputmask._valueSet(inputmask.unmaskedvalue(), true);
|
||||
setTimeout(function () {
|
||||
writeBuffer(inputmask.el, getBuffer.call(inputmask));
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
,
|
||||
resetEvent: function () {
|
||||
const inputmask = this.inputmask;
|
||||
|
||||
inputmask.refreshValue = true; //indicate a forced refresh when there is a call to the value before leaving the triggering event fn
|
||||
setTimeout(function () {
|
||||
applyInputValue(inputmask.el, inputmask._valueGet(true));
|
||||
}, 0);
|
||||
}
|
||||
inputmask.refreshValue = true; //indicate a forced refresh when there is a call to the value before leaving the triggering event fn
|
||||
setTimeout(function () {
|
||||
applyInputValue(inputmask.el, inputmask._valueGet(true));
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
|
209
node_modules/inputmask/lib/eventruler.js
generated
vendored
209
node_modules/inputmask/lib/eventruler.js
generated
vendored
|
@ -1,124 +1,107 @@
|
|||
import Inputmask from "./inputmask";
|
||||
import keyCode from "./keycode.json";
|
||||
import {keys} from "./keycode.js";
|
||||
import {getBufferTemplate} from "./positioning";
|
||||
import {HandleNativePlaceholder} from "./inputHandling";
|
||||
|
||||
export {EventRuler};
|
||||
|
||||
var EventRuler = {
|
||||
on: function (input, eventName, eventHandler) {
|
||||
const $ = input.inputmask.dependencyLib;
|
||||
on: function (input, eventName, eventHandler) {
|
||||
const $ = input.inputmask.dependencyLib;
|
||||
|
||||
var ev = function (e) {
|
||||
if (e.originalEvent) {
|
||||
e = e.originalEvent || e; //get original event from jquery evenbt
|
||||
arguments[0] = e;
|
||||
}
|
||||
// console.log(e.type);
|
||||
var that = this, args, inputmask = that.inputmask, opts = inputmask ? inputmask.opts : undefined;
|
||||
if (inputmask === undefined && this.nodeName !== "FORM") { //happens when cloning an object with jquery.clone
|
||||
var imOpts = $.data(that, "_inputmask_opts");
|
||||
$(that).off(); //unbind all events
|
||||
if (imOpts) {
|
||||
(new Inputmask(imOpts)).mask(that);
|
||||
}
|
||||
} 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))))) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
switch (e.type) {
|
||||
case "input":
|
||||
if (inputmask.skipInputEvent === true || (e.inputType && e.inputType === "insertCompositionText")) {
|
||||
inputmask.skipInputEvent = false;
|
||||
return e.preventDefault();
|
||||
}
|
||||
var ev = function (e) {
|
||||
if (e.originalEvent) {
|
||||
e = e.originalEvent || e; //get original event from jquery evenbt
|
||||
arguments[0] = e;
|
||||
}
|
||||
// console.log(e.type);
|
||||
var that = this, args, inputmask = that.inputmask, opts = inputmask ? inputmask.opts : undefined;
|
||||
if (inputmask === undefined && this.nodeName !== "FORM") { //happens when cloning an object with jquery.clone
|
||||
var imOpts = $.data(that, "_inputmask_opts");
|
||||
$(that).off(); //unbind all events
|
||||
if (imOpts) {
|
||||
(new Inputmask(imOpts)).mask(that);
|
||||
}
|
||||
} else if (!["submit", "reset", "setvalue"].includes(e.type) && this.nodeName !== "FORM" && (that.disabled || (that.readOnly && !(e.type === "keydown" && (e.ctrlKey && e.key === keys.c) || (opts.tabThrough === false && e.key === keys.Tab))))) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
switch (e.type) {
|
||||
case "input":
|
||||
if (inputmask.skipInputEvent === true) {
|
||||
inputmask.skipInputEvent = false;
|
||||
return e.preventDefault();
|
||||
}
|
||||
|
||||
// if (mobile) { //this causes problem see #2220
|
||||
// args = arguments;
|
||||
// setTimeout(function () { //needed for caret selection when entering a char on Android 8 - #1818
|
||||
// eventHandler.apply(that, args);
|
||||
// caret(that, that.inputmask.caretPos, undefined, true);
|
||||
// }, 0);
|
||||
// return false;
|
||||
// }
|
||||
break;
|
||||
case "keydown":
|
||||
//Safari 5.1.x - modal dialog fires keypress twice workaround
|
||||
inputmask.skipKeyPressEvent = false;
|
||||
inputmask.skipInputEvent = inputmask.isComposing = e.keyCode === keyCode.KEY_229;
|
||||
break;
|
||||
case "keyup":
|
||||
case "compositionend":
|
||||
if (inputmask.isComposing) {
|
||||
inputmask.skipInputEvent = false;
|
||||
}
|
||||
break;
|
||||
case "keypress":
|
||||
if (inputmask.skipKeyPressEvent === true) {
|
||||
return e.preventDefault();
|
||||
}
|
||||
inputmask.skipKeyPressEvent = true;
|
||||
break;
|
||||
case "click":
|
||||
case "focus":
|
||||
if (inputmask.validationEvent) { // #841
|
||||
inputmask.validationEvent = false;
|
||||
input.blur();
|
||||
HandleNativePlaceholder(input, (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join(""));
|
||||
setTimeout(function () {
|
||||
input.focus();
|
||||
}, opts.validationEventTimeOut);
|
||||
return false;
|
||||
}
|
||||
args = arguments;
|
||||
setTimeout(function () { //needed for Chrome ~ initial selection clears after the clickevent
|
||||
if (!input.inputmask) {
|
||||
// `inputmask.remove()` was called before this callback
|
||||
return;
|
||||
}
|
||||
eventHandler.apply(that, args);
|
||||
}, 0);
|
||||
return false;
|
||||
}
|
||||
var returnVal = eventHandler.apply(that, arguments);
|
||||
if (returnVal === false) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
};
|
||||
if (["submit", "reset"].includes(eventName)) {
|
||||
ev = ev.bind(input); //bind creates a new eventhandler (wrap)
|
||||
if (input.form !== null) $(input.form).on(eventName, ev);
|
||||
} else {
|
||||
$(input).on(eventName, ev);
|
||||
}
|
||||
// if (mobile) { //this causes problem see #2220
|
||||
// args = arguments;
|
||||
// setTimeout(function () { //needed for caret selection when entering a char on Android 8 - #1818
|
||||
// eventHandler.apply(that, args);
|
||||
// caret(that, that.inputmask.caretPos, undefined, true);
|
||||
// }, 0);
|
||||
// return false;
|
||||
// }
|
||||
break;
|
||||
case "click":
|
||||
case "focus":
|
||||
if (inputmask.validationEvent) { // #841
|
||||
inputmask.validationEvent = false;
|
||||
input.blur();
|
||||
HandleNativePlaceholder(input, (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join(""));
|
||||
setTimeout(function () {
|
||||
input.focus();
|
||||
}, opts.validationEventTimeOut);
|
||||
return false;
|
||||
}
|
||||
args = arguments;
|
||||
setTimeout(function () { //needed for Chrome ~ initial selection clears after the clickevent
|
||||
if (!input.inputmask) {
|
||||
// `inputmask.remove()` was called before this callback
|
||||
return;
|
||||
}
|
||||
eventHandler.apply(that, args);
|
||||
}, 0);
|
||||
return /*false*/; //#2423
|
||||
}
|
||||
var returnVal = eventHandler.apply(that, arguments);
|
||||
if (returnVal === false) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
};
|
||||
if (["submit", "reset"].includes(eventName)) {
|
||||
ev = ev.bind(input); //bind creates a new eventhandler (wrap)
|
||||
if (input.form !== null) $(input.form).on(eventName, ev);
|
||||
} else {
|
||||
$(input).on(eventName, ev);
|
||||
}
|
||||
|
||||
//keep instance of the event
|
||||
input.inputmask.events[eventName] = input.inputmask.events[eventName] || [];
|
||||
input.inputmask.events[eventName].push(ev);
|
||||
//keep instance of the event
|
||||
input.inputmask.events[eventName] = input.inputmask.events[eventName] || [];
|
||||
input.inputmask.events[eventName].push(ev);
|
||||
|
||||
},
|
||||
off: function (input, event) {
|
||||
if (input.inputmask && input.inputmask.events) {
|
||||
const $ = input.inputmask.dependencyLib;
|
||||
let events = input.inputmask.events;
|
||||
if (event) {
|
||||
events = [];
|
||||
events[event] = input.inputmask.events[event];
|
||||
}
|
||||
for (let eventName in events) {
|
||||
let evArr = events[eventName];
|
||||
while (evArr.length > 0) {
|
||||
let ev = evArr.pop();
|
||||
if (["submit", "reset",].includes(eventName)) {
|
||||
if (input.form !== null) $(input.form).off(eventName, ev);
|
||||
} else {
|
||||
$(input).off(eventName, ev);
|
||||
}
|
||||
}
|
||||
delete input.inputmask.events[eventName];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
off: function (input, event) {
|
||||
if (input.inputmask && input.inputmask.events) {
|
||||
const $ = input.inputmask.dependencyLib;
|
||||
let events = input.inputmask.events;
|
||||
if (event) {
|
||||
events = [];
|
||||
events[event] = input.inputmask.events[event];
|
||||
}
|
||||
for (let eventName in events) {
|
||||
let evArr = events[eventName];
|
||||
while (evArr.length > 0) {
|
||||
let ev = evArr.pop();
|
||||
if (["submit", "reset",].includes(eventName)) {
|
||||
if (input.form !== null) $(input.form).off(eventName, ev);
|
||||
} else {
|
||||
$(input).off(eventName, ev);
|
||||
}
|
||||
}
|
||||
delete input.inputmask.events[eventName];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
23
node_modules/inputmask/lib/extensions/inputmask.date.extensions.js
generated
vendored
23
node_modules/inputmask/lib/extensions/inputmask.date.extensions.js
generated
vendored
|
@ -5,7 +5,7 @@
|
|||
Licensed under the MIT license
|
||||
*/
|
||||
import Inputmask from "../inputmask";
|
||||
import keyCode from "../keycode.json";
|
||||
import {keys} from "../keycode.js";
|
||||
import escapeRegex from "../escapeRegex";
|
||||
import {seekNext} from "../positioning";
|
||||
import {getMaskTemplate} from "../validation-tests";
|
||||
|
@ -39,11 +39,11 @@ class DateObject {
|
|||
if (mask !== undefined) {
|
||||
if (dynMatches) {
|
||||
let lastIndex = getTokenizer(opts).lastIndex,
|
||||
tokanMatch = getTokenMatch(match.index, opts);
|
||||
tokenMatch = getTokenMatch(match.index, opts);
|
||||
getTokenizer(opts).lastIndex = lastIndex;
|
||||
value = mask.slice(0, mask.indexOf(tokanMatch.nextMatch[0]));
|
||||
value = mask.slice(0, mask.indexOf(tokenMatch.nextMatch[0]));
|
||||
} else {
|
||||
value = mask.slice(0, fcode.length);
|
||||
value = mask.slice(0, (formatCode[fcode] && formatCode[fcode][4]) || fcode.length);
|
||||
}
|
||||
mask = mask.slice(value.length);
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ let currentYear = new Date().getFullYear(),
|
|||
//supported codes for formatting
|
||||
//http://blog.stevenlevithan.com/archives/date-time-format
|
||||
//https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.7
|
||||
formatCode = { //regex, valueSetter, type, displayformatter
|
||||
formatCode = { //regex, valueSetter, type, displayformatter, #entries (optional)
|
||||
d: ["[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate], //Day of the month as digits; no leading zero for single-digit days.
|
||||
dd: ["0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function () {
|
||||
return pad(Date.prototype.getDate.call(this), 2);
|
||||
|
@ -159,10 +159,10 @@ let currentYear = new Date().getFullYear(),
|
|||
}], //Seconds; leading zero for single-digit seconds.
|
||||
l: ["[0-9]{3}", Date.prototype.setMilliseconds, "milliseconds", function () {
|
||||
return pad(Date.prototype.getMilliseconds.call(this), 3);
|
||||
}], //Milliseconds. 3 digits.
|
||||
}, 3], //Milliseconds. 3 digits.
|
||||
L: ["[0-9]{2}", Date.prototype.setMilliseconds, "milliseconds", function () {
|
||||
return pad(Date.prototype.getMilliseconds.call(this), 2);
|
||||
}], //Milliseconds. 2 digits.
|
||||
}, 2], //Milliseconds. 2 digits.
|
||||
t: ["[ap]", setAMPM, "ampm", getAMPM, 1], //Lowercase, single-character time marker string: a or p.
|
||||
tt: ["[ap]m", setAMPM, "ampm", getAMPM, 2], //two-character time marker string: am or pm.
|
||||
T: ["[AP]", setAMPM, "ampm", getAMPM, 1], //single-character time marker string: A or P.
|
||||
|
@ -294,7 +294,7 @@ function isValidDate(dateParts, currentResult, opts) {
|
|||
function isDateInRange(dateParts, result, opts, maskset, fromCheckval) {
|
||||
if (!result) return result;
|
||||
if (result && opts.min) {
|
||||
if (/*useDateObject && (dateParts["year"] === undefined || dateParts["yearSet"]) && */opts.min.date.getTime() === opts.min.date.getTime()) {
|
||||
if (/*useDateObject && (dateParts["year"] === undefined || dateParts["yearSet"]) && */!isNaN(opts.min.date.getTime())) {
|
||||
let match;
|
||||
dateParts.reset();
|
||||
getTokenizer(opts).lastIndex = 0;
|
||||
|
@ -334,7 +334,7 @@ function isDateInRange(dateParts, result, opts, maskset, fromCheckval) {
|
|||
}
|
||||
|
||||
if (result && opts.max) {
|
||||
if (opts.max.date.getTime() === opts.max.date.getTime()) {
|
||||
if (!isNaN(opts.max.date.getTime())) {
|
||||
result = opts.max.date.getTime() >= dateParts.date.getTime();
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ Inputmask.extendAliases({
|
|||
}
|
||||
|
||||
var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
|
||||
if (result && dateParts.date.getTime() === dateParts.date.getTime()) { //check for a valid date ~ an invalid date returns NaN which isn't equal
|
||||
if (result && !isNaN(dateParts.date.getTime())) { //check for a valid date ~ an invalid date returns NaN which isn't equal
|
||||
if (opts.prefillYear) result = prefillYear(dateParts, result, opts);
|
||||
result = isValidDate.call(inputmask, dateParts, result, opts);
|
||||
result = isDateInRange(dateParts, result, opts, maskset, fromCheckval);
|
||||
|
@ -559,7 +559,7 @@ Inputmask.extendAliases({
|
|||
},
|
||||
onKeyDown: function (e, buffer, caretPos, opts) {
|
||||
var input = this;
|
||||
if (e.ctrlKey && e.keyCode === keyCode.RIGHT) {
|
||||
if (e.ctrlKey && e.key === keys.ArrowRight) {
|
||||
input.inputmask._valueSet(importDate(new Date(), opts));
|
||||
$(input).trigger("setvalue");
|
||||
}
|
||||
|
@ -580,6 +580,7 @@ Inputmask.extendAliases({
|
|||
return initialValue;
|
||||
},
|
||||
insertMode: false,
|
||||
insertModeVisual: false,
|
||||
shiftPositions: false,
|
||||
keepStatic: false,
|
||||
inputmode: "numeric",
|
||||
|
|
9
node_modules/inputmask/lib/extensions/inputmask.extensions.js
generated
vendored
9
node_modules/inputmask/lib/extensions/inputmask.extensions.js
generated
vendored
|
@ -72,16 +72,15 @@ Inputmask.extendAliases({
|
|||
//https://en.wikipedia.org/wiki/Domain_name#Domain_name_space
|
||||
//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
|
||||
//should be extended with the toplevel domains at the end
|
||||
mask: function (opts) {
|
||||
mask: function ({separator, quantifier}) {
|
||||
var emailMask = "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]";
|
||||
var mask = emailMask;
|
||||
if (opts.separator) {
|
||||
for (let i = 0; i < opts.quantifier; i++) {
|
||||
mask += `[${opts.separator}${emailMask}]`;
|
||||
if (separator) {
|
||||
for (let i = 0; i < quantifier; i++) {
|
||||
mask += `[${separator}${emailMask}]`;
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
return opts.separator ? `${emailMask}(${opts.separator}${emailMask}){*}` : emailMask;
|
||||
},
|
||||
greedy: false,
|
||||
casing: "lower",
|
||||
|
|
1135
node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js
generated
vendored
1135
node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js
generated
vendored
File diff suppressed because it is too large
Load diff
424
node_modules/inputmask/lib/inputHandling.js
generated
vendored
424
node_modules/inputmask/lib/inputHandling.js
generated
vendored
|
@ -1,13 +1,13 @@
|
|||
import keyCode from "./keycode.json";
|
||||
import {keys} from "./keycode.js";
|
||||
import {getMaskTemplate, getPlaceholder, getTest} from "./validation-tests";
|
||||
import {
|
||||
caret,
|
||||
determineNewCaretPosition,
|
||||
getBuffer, getBufferTemplate,
|
||||
getLastValidPosition,
|
||||
isMask,
|
||||
resetMaskSet,
|
||||
seekNext
|
||||
caret,
|
||||
determineNewCaretPosition,
|
||||
getBuffer, getBufferTemplate,
|
||||
getLastValidPosition,
|
||||
isMask,
|
||||
resetMaskSet,
|
||||
seekNext
|
||||
} from "./positioning";
|
||||
import {isComplete, refreshFromBuffer} from "./validation";
|
||||
import {ie} from "./environment";
|
||||
|
@ -17,236 +17,236 @@ import {EventHandlers} from "./eventhandlers";
|
|||
export {applyInputValue, clearOptionalTail, checkVal, HandleNativePlaceholder, unmaskedvalue, writeBuffer};
|
||||
|
||||
function applyInputValue(input, value) {
|
||||
const inputmask = input ? input.inputmask : this, opts = inputmask.opts;
|
||||
const inputmask = input ? input.inputmask : this, opts = inputmask.opts;
|
||||
|
||||
input.inputmask.refreshValue = false;
|
||||
if (typeof opts.onBeforeMask === "function") value = opts.onBeforeMask.call(inputmask, value, opts) || value;
|
||||
value = value.toString().split("");
|
||||
checkVal(input, true, false, value);
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate.call(inputmask).join("") && getLastValidPosition.call(inputmask) === -1) {
|
||||
input.inputmask._valueSet("");
|
||||
}
|
||||
input.inputmask.refreshValue = false;
|
||||
if (typeof opts.onBeforeMask === "function") value = opts.onBeforeMask.call(inputmask, value, opts) || value;
|
||||
value = (value || "").toString().split("");
|
||||
checkVal(input, true, false, value);
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate.call(inputmask).join("") && getLastValidPosition.call(inputmask) === -1) {
|
||||
input.inputmask._valueSet("");
|
||||
}
|
||||
}
|
||||
|
||||
//todo put on prototype?
|
||||
function clearOptionalTail(buffer) {
|
||||
const inputmask = this;
|
||||
const inputmask = this;
|
||||
|
||||
buffer.length = 0;
|
||||
var template = getMaskTemplate.call(inputmask, true, 0, true, undefined, true), lmnt;
|
||||
while ((lmnt = template.shift()) !== undefined) buffer.push(lmnt);
|
||||
return buffer;
|
||||
buffer.length = 0;
|
||||
var template = getMaskTemplate.call(inputmask, true, 0, true, undefined, true), lmnt;
|
||||
while ((lmnt = template.shift()) !== undefined) buffer.push(lmnt);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
maskset = inputmask.maskset,
|
||||
opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
maskset = inputmask.maskset,
|
||||
opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
|
||||
var inputValue = nptvl.slice(),
|
||||
charCodes = "",
|
||||
initialNdx = -1,
|
||||
result = undefined, skipOptionalPartCharacter = opts.skipOptionalPartCharacter;
|
||||
opts.skipOptionalPartCharacter = ""; //see issue #2311
|
||||
var inputValue = nptvl.slice(),
|
||||
charCodes = "",
|
||||
initialNdx = -1,
|
||||
result = undefined, skipOptionalPartCharacter = opts.skipOptionalPartCharacter;
|
||||
opts.skipOptionalPartCharacter = ""; //see issue #2311
|
||||
|
||||
function isTemplateMatch(ndx, charCodes) {
|
||||
var targetTemplate = getMaskTemplate.call(inputmask, true, 0).slice(ndx, seekNext.call(inputmask, ndx, false, false)).join("").replace(/'/g, ""),
|
||||
charCodeNdx = targetTemplate.indexOf(charCodes);
|
||||
//strip spaces from targetTemplate
|
||||
while (charCodeNdx > 0 && targetTemplate[charCodeNdx - 1] === " ") charCodeNdx--;
|
||||
function isTemplateMatch(ndx, charCodes) {
|
||||
var targetTemplate = getMaskTemplate.call(inputmask, true, 0).slice(ndx, seekNext.call(inputmask, ndx, false, false)).join("").replace(/'/g, ""),
|
||||
charCodeNdx = targetTemplate.indexOf(charCodes);
|
||||
//strip spaces from targetTemplate
|
||||
while (charCodeNdx > 0 && targetTemplate[charCodeNdx - 1] === " ") charCodeNdx--;
|
||||
|
||||
var match = charCodeNdx === 0 && !isMask.call(inputmask, ndx)
|
||||
&& (getTest.call(inputmask, ndx).match.nativeDef === charCodes.charAt(0)
|
||||
|| (getTest.call(inputmask, ndx).match.static === true && getTest.call(inputmask, ndx).match.nativeDef === ("'" + charCodes.charAt(0)))
|
||||
|| (getTest.call(inputmask, ndx).match.nativeDef === " " && (getTest.call(inputmask, ndx + 1).match.nativeDef === charCodes.charAt(0)
|
||||
|| (getTest.call(inputmask, ndx + 1).match.static === true && getTest.call(inputmask, ndx + 1).match.nativeDef === ("'" + charCodes.charAt(0))))));
|
||||
var match = charCodeNdx === 0 && !isMask.call(inputmask, ndx)
|
||||
&& (getTest.call(inputmask, ndx).match.nativeDef === charCodes.charAt(0)
|
||||
|| (getTest.call(inputmask, ndx).match.static === true && getTest.call(inputmask, ndx).match.nativeDef === ("'" + charCodes.charAt(0)))
|
||||
|| (getTest.call(inputmask, ndx).match.nativeDef === " " && (getTest.call(inputmask, ndx + 1).match.nativeDef === charCodes.charAt(0)
|
||||
|| (getTest.call(inputmask, ndx + 1).match.static === true && getTest.call(inputmask, ndx + 1).match.nativeDef === ("'" + charCodes.charAt(0))))));
|
||||
|
||||
if (!match && charCodeNdx > 0 && !isMask.call(inputmask, ndx, false, true)) {
|
||||
var nextPos = seekNext.call(inputmask, ndx);
|
||||
if (inputmask.caretPos.begin < nextPos) {
|
||||
inputmask.caretPos = {begin: nextPos};
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
if (!match && charCodeNdx > 0 && !isMask.call(inputmask, ndx, false, true)) {
|
||||
var nextPos = seekNext.call(inputmask, ndx);
|
||||
if (inputmask.caretPos.begin < nextPos) {
|
||||
inputmask.caretPos = {begin: nextPos};
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
resetMaskSet.call(inputmask);
|
||||
maskset.tests = {}; //reset tests ~ possible after alternating
|
||||
initialNdx = opts.radixPoint ? determineNewCaretPosition.call(inputmask, {
|
||||
begin: 0,
|
||||
end: 0
|
||||
}, false, opts.__financeInput === false ? "radixFocus" : undefined).begin : 0;
|
||||
maskset.p = initialNdx;
|
||||
inputmask.caretPos = {begin: initialNdx};
|
||||
resetMaskSet.call(inputmask);
|
||||
maskset.tests = {}; //reset tests ~ possible after alternating
|
||||
initialNdx = opts.radixPoint ? determineNewCaretPosition.call(inputmask, {
|
||||
begin: 0,
|
||||
end: 0
|
||||
}, false, opts.__financeInput === false ? "radixFocus" : undefined).begin : 0;
|
||||
maskset.p = initialNdx;
|
||||
inputmask.caretPos = {begin: initialNdx};
|
||||
|
||||
var staticMatches = [], prevCaretPos = inputmask.caretPos;
|
||||
inputValue.forEach(function (charCode, ndx) {
|
||||
if (charCode !== undefined) { //inputfallback strips some elements out of the inputarray. $.each logically presents them as undefined
|
||||
/*if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true) &&
|
||||
isValid.call(inputmask, ndx, inputValue[ndx], true, undefined, true, true) === false) {
|
||||
inputmask.caretPos.begin++;
|
||||
} else*/
|
||||
{
|
||||
var keypress = new $.Event("_checkval");
|
||||
keypress.keyCode = charCode.toString().charCodeAt(0);
|
||||
charCodes += charCode;
|
||||
var lvp = getLastValidPosition.call(inputmask, undefined, true);
|
||||
if (!isTemplateMatch(initialNdx, charCodes)) {
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, inputmask.caretPos.begin);
|
||||
var staticMatches = [], prevCaretPos = inputmask.caretPos;
|
||||
inputValue.forEach(function (charCode, ndx) {
|
||||
if (charCode !== undefined) { //inputfallback strips some elements out of the inputarray. $.each logically presents them as undefined
|
||||
/*if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true) &&
|
||||
isValid.call(inputmask, ndx, inputValue[ndx], true, undefined, true, true) === false) {
|
||||
inputmask.caretPos.begin++;
|
||||
} else*/
|
||||
{
|
||||
var keypress = new $.Event("_checkval");
|
||||
keypress.key = charCode;
|
||||
charCodes += charCode;
|
||||
var lvp = getLastValidPosition.call(inputmask, undefined, true);
|
||||
if (!isTemplateMatch(initialNdx, charCodes)) {
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, inputmask.caretPos.begin);
|
||||
|
||||
if (result) {
|
||||
initialNdx = inputmask.caretPos.begin + 1;
|
||||
charCodes = "";
|
||||
}
|
||||
} else {
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, lvp + 1);
|
||||
}
|
||||
if (result) {
|
||||
if (result.pos !== undefined && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true && maskset.validPositions[result.pos].alternation === undefined) {
|
||||
staticMatches.push(result.pos);
|
||||
if (!inputmask.isRTL) {
|
||||
result.forwardPosition = result.pos + 1;
|
||||
}
|
||||
}
|
||||
writeBuffer.call(inputmask, undefined, getBuffer.call(inputmask), result.forwardPosition, keypress, false);
|
||||
inputmask.caretPos = {begin: result.forwardPosition, end: result.forwardPosition};
|
||||
prevCaretPos = inputmask.caretPos;
|
||||
} else {
|
||||
if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true)) {
|
||||
inputmask.caretPos.begin++;
|
||||
} else inputmask.caretPos = prevCaretPos; //restore the caret position from before the failed validation
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (staticMatches.length > 0) {
|
||||
var sndx, validPos, nextValid = seekNext.call(inputmask, -1, undefined, false);
|
||||
if ((!isComplete.call(inputmask, getBuffer.call(inputmask)) && staticMatches.length <= nextValid)
|
||||
|| (isComplete.call(inputmask, getBuffer.call(inputmask)) && staticMatches.length > 0 && (staticMatches.length !== nextValid && staticMatches[0] === 0))) { //should check if is sequence starting from 0
|
||||
var nextSndx = nextValid;
|
||||
while ((sndx = staticMatches.shift()) !== undefined) {
|
||||
var keypress = new $.Event("_checkval");
|
||||
validPos = maskset.validPositions[sndx];
|
||||
validPos.generatedInput = true;
|
||||
keypress.keyCode = validPos.input.charCodeAt(0);
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, nextSndx);
|
||||
if (result && result.pos !== undefined && result.pos !== sndx && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true) {
|
||||
staticMatches.push(result.pos);
|
||||
} else if (!result) break;
|
||||
nextSndx++;
|
||||
}
|
||||
} else { //mark al statics as generated
|
||||
// while ((sndx = staticMatches.pop())) {
|
||||
// validPos = maskset.validPositions[sndx];
|
||||
// if (validPos) {
|
||||
// validPos.generatedInput = true;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (writeOut) {
|
||||
writeBuffer.call(
|
||||
inputmask,
|
||||
input,
|
||||
getBuffer.call(inputmask), result ? result.forwardPosition : inputmask.caretPos.begin,
|
||||
initiatingEvent || new $.Event("checkval"),
|
||||
initiatingEvent && ((initiatingEvent.type === "input" && inputmask.undoValue !== getBuffer.call(inputmask).join("")) || initiatingEvent.type === "paste"));
|
||||
// for (var vndx in maskset.validPositions) {
|
||||
// if (maskset.validPositions[vndx].match.generated !== true) { //only remove non forced generated
|
||||
// delete maskset.validPositions[vndx].generatedInput; //clear generated markings ~ consider initializing with a value as fully typed
|
||||
// }
|
||||
// }
|
||||
}
|
||||
opts.skipOptionalPartCharacter = skipOptionalPartCharacter;
|
||||
if (result) {
|
||||
initialNdx = inputmask.caretPos.begin + 1;
|
||||
charCodes = "";
|
||||
}
|
||||
} else {
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, lvp + 1);
|
||||
}
|
||||
if (result) {
|
||||
if (result.pos !== undefined && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true && maskset.validPositions[result.pos].alternation === undefined) {
|
||||
staticMatches.push(result.pos);
|
||||
if (!inputmask.isRTL) {
|
||||
result.forwardPosition = result.pos + 1;
|
||||
}
|
||||
}
|
||||
writeBuffer.call(inputmask, undefined, getBuffer.call(inputmask), result.forwardPosition, keypress, false);
|
||||
inputmask.caretPos = {begin: result.forwardPosition, end: result.forwardPosition};
|
||||
prevCaretPos = inputmask.caretPos;
|
||||
} else {
|
||||
if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true)) {
|
||||
inputmask.caretPos.begin++;
|
||||
} else inputmask.caretPos = prevCaretPos; //restore the caret position from before the failed validation
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (staticMatches.length > 0) {
|
||||
var sndx, validPos, nextValid = seekNext.call(inputmask, -1, undefined, false);
|
||||
if ((!isComplete.call(inputmask, getBuffer.call(inputmask)) && staticMatches.length <= nextValid)
|
||||
|| (isComplete.call(inputmask, getBuffer.call(inputmask)) && staticMatches.length > 0 && (staticMatches.length !== nextValid && staticMatches[0] === 0))) { //should check if is sequence starting from 0
|
||||
var nextSndx = nextValid;
|
||||
while ((sndx = staticMatches.shift()) !== undefined) {
|
||||
var keypress = new $.Event("_checkval");
|
||||
validPos = maskset.validPositions[sndx];
|
||||
validPos.generatedInput = true;
|
||||
keypress.key = validPos.input;
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, nextSndx);
|
||||
if (result && result.pos !== undefined && result.pos !== sndx && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true) {
|
||||
staticMatches.push(result.pos);
|
||||
} else if (!result) break;
|
||||
nextSndx++;
|
||||
}
|
||||
} else { //mark al statics as generated
|
||||
// while ((sndx = staticMatches.pop())) {
|
||||
// validPos = maskset.validPositions[sndx];
|
||||
// if (validPos) {
|
||||
// validPos.generatedInput = true;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (writeOut) {
|
||||
writeBuffer.call(
|
||||
inputmask,
|
||||
input,
|
||||
getBuffer.call(inputmask), result ? result.forwardPosition : inputmask.caretPos.begin,
|
||||
initiatingEvent || new $.Event("checkval"),
|
||||
initiatingEvent && ((initiatingEvent.type === "input" && inputmask.undoValue !== getBuffer.call(inputmask).join("")) || initiatingEvent.type === "paste"));
|
||||
// for (var vndx in maskset.validPositions) {
|
||||
// if (maskset.validPositions[vndx].match.generated !== true) { //only remove non forced generated
|
||||
// delete maskset.validPositions[vndx].generatedInput; //clear generated markings ~ consider initializing with a value as fully typed
|
||||
// }
|
||||
// }
|
||||
}
|
||||
opts.skipOptionalPartCharacter = skipOptionalPartCharacter;
|
||||
}
|
||||
|
||||
function HandleNativePlaceholder(npt, value) {
|
||||
const inputmask = npt ? npt.inputmask : this;
|
||||
const inputmask = npt ? npt.inputmask : this;
|
||||
|
||||
if (ie) {
|
||||
if (npt.inputmask._valueGet() !== value && (npt.placeholder !== value || npt.placeholder === "")) {
|
||||
var buffer = getBuffer.call(inputmask).slice(),
|
||||
nptValue = npt.inputmask._valueGet();
|
||||
if (nptValue !== value) {
|
||||
var lvp = getLastValidPosition.call(inputmask);
|
||||
if (lvp === -1 && nptValue === getBufferTemplate.call(inputmask).join("")) {
|
||||
buffer = [];
|
||||
} else if (lvp !== -1) { //clearout optional tail of the mask
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
writeBuffer(npt, buffer);
|
||||
}
|
||||
}
|
||||
} else if (npt.placeholder !== value) {
|
||||
npt.placeholder = value;
|
||||
if (npt.placeholder === "") npt.removeAttribute("placeholder");
|
||||
}
|
||||
if (ie) {
|
||||
if (npt.inputmask._valueGet() !== value && (npt.placeholder !== value || npt.placeholder === "")) {
|
||||
var buffer = getBuffer.call(inputmask).slice(),
|
||||
nptValue = npt.inputmask._valueGet();
|
||||
if (nptValue !== value) {
|
||||
var lvp = getLastValidPosition.call(inputmask);
|
||||
if (lvp === -1 && nptValue === getBufferTemplate.call(inputmask).join("")) {
|
||||
buffer = [];
|
||||
} else if (lvp !== -1) { //clearout optional tail of the mask
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
writeBuffer(npt, buffer);
|
||||
}
|
||||
}
|
||||
} else if (npt.placeholder !== value) {
|
||||
npt.placeholder = value;
|
||||
if (npt.placeholder === "") npt.removeAttribute("placeholder");
|
||||
}
|
||||
}
|
||||
|
||||
function unmaskedvalue(input) {
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
opts = inputmask.opts,
|
||||
maskset = inputmask.maskset;
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
opts = inputmask.opts,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
if (input) {
|
||||
if (input.inputmask === undefined) {
|
||||
return input.value;
|
||||
}
|
||||
if (input.inputmask && input.inputmask.refreshValue) { //forced refresh from the value form.reset
|
||||
applyInputValue(input, input.inputmask._valueGet(true));
|
||||
}
|
||||
}
|
||||
var umValue = [],
|
||||
vps = maskset.validPositions;
|
||||
for (var pndx in vps) {
|
||||
if (vps[pndx] && vps[pndx].match && (vps[pndx].match.static != true || (Array.isArray(maskset.metadata) && vps[pndx].generatedInput !== true))) {
|
||||
//only include generated input with multiple masks (check on metadata)
|
||||
umValue.push(vps[pndx].input);
|
||||
}
|
||||
}
|
||||
var unmaskedValue = umValue.length === 0 ? "" : (inputmask.isRTL ? umValue.reverse() : umValue).join("");
|
||||
if (typeof opts.onUnMask === "function") {
|
||||
var bufferValue = (inputmask.isRTL ? getBuffer.call(inputmask).slice().reverse() : getBuffer.call(inputmask)).join("");
|
||||
unmaskedValue = opts.onUnMask.call(inputmask, bufferValue, unmaskedValue, opts);
|
||||
}
|
||||
return unmaskedValue;
|
||||
if (input) {
|
||||
if (input.inputmask === undefined) {
|
||||
return input.value;
|
||||
}
|
||||
if (input.inputmask && input.inputmask.refreshValue) { //forced refresh from the value form.reset
|
||||
applyInputValue(input, input.inputmask._valueGet(true));
|
||||
}
|
||||
}
|
||||
var umValue = [],
|
||||
vps = maskset.validPositions;
|
||||
for (let pndx = 0, vpl = vps.length; pndx < vpl; pndx++) {
|
||||
if (vps[pndx] && vps[pndx].match && (vps[pndx].match.static != true || (Array.isArray(maskset.metadata) && vps[pndx].generatedInput !== true))) {
|
||||
//only include generated input with multiple masks (check on metadata)
|
||||
umValue.push(vps[pndx].input);
|
||||
}
|
||||
}
|
||||
var unmaskedValue = umValue.length === 0 ? "" : (inputmask.isRTL ? umValue.reverse() : umValue).join("");
|
||||
if (typeof opts.onUnMask === "function") {
|
||||
var bufferValue = (inputmask.isRTL ? getBuffer.call(inputmask).slice().reverse() : getBuffer.call(inputmask)).join("");
|
||||
unmaskedValue = opts.onUnMask.call(inputmask, bufferValue, unmaskedValue, opts);
|
||||
}
|
||||
return unmaskedValue;
|
||||
}
|
||||
|
||||
function writeBuffer(input, buffer, caretPos, event, triggerEvents) {
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
opts = inputmask.opts,
|
||||
$ = inputmask.dependencyLib;
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
opts = inputmask.opts,
|
||||
$ = inputmask.dependencyLib;
|
||||
|
||||
if (event && typeof opts.onBeforeWrite === "function") {
|
||||
// buffer = buffer.slice(); //prevent uncontrolled manipulation of the internal buffer
|
||||
var result = opts.onBeforeWrite.call(inputmask, event, buffer, caretPos, opts);
|
||||
if (result) {
|
||||
if (result.refreshFromBuffer) {
|
||||
var refresh = result.refreshFromBuffer;
|
||||
refreshFromBuffer.call(inputmask, refresh === true ? refresh : refresh.start, refresh.end, result.buffer || buffer);
|
||||
buffer = getBuffer.call(inputmask, true);
|
||||
}
|
||||
if (caretPos !== undefined) caretPos = result.caret !== undefined ? result.caret : caretPos;
|
||||
}
|
||||
}
|
||||
if (input !== undefined) {
|
||||
input.inputmask._valueSet(buffer.join(""));
|
||||
if (caretPos !== undefined && (event === undefined || event.type !== "blur")) {
|
||||
// console.log(caretPos);
|
||||
caret.call(inputmask, input, caretPos, undefined, undefined, (event !== undefined && event.type === "keydown" && (event.keyCode === keyCode.DELETE || event.keyCode === keyCode.BACKSPACE)));
|
||||
}
|
||||
if (triggerEvents === true) {
|
||||
var $input = $(input), nptVal = input.inputmask._valueGet();
|
||||
input.inputmask.skipInputEvent = true;
|
||||
$input.trigger("input");
|
||||
setTimeout(function () { //timeout needed for IE
|
||||
if (nptVal === getBufferTemplate.call(inputmask).join("")) {
|
||||
$input.trigger("cleared");
|
||||
} else if (isComplete.call(inputmask, buffer) === true) {
|
||||
$input.trigger("complete");
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
if (event && typeof opts.onBeforeWrite === "function") {
|
||||
// buffer = buffer.slice(); //prevent uncontrolled manipulation of the internal buffer
|
||||
var result = opts.onBeforeWrite.call(inputmask, event, buffer, caretPos, opts);
|
||||
if (result) {
|
||||
if (result.refreshFromBuffer) {
|
||||
var refresh = result.refreshFromBuffer;
|
||||
refreshFromBuffer.call(inputmask, refresh === true ? refresh : refresh.start, refresh.end, result.buffer || buffer);
|
||||
buffer = getBuffer.call(inputmask, true);
|
||||
}
|
||||
if (caretPos !== undefined) caretPos = result.caret !== undefined ? result.caret : caretPos;
|
||||
}
|
||||
}
|
||||
if (input !== undefined) {
|
||||
input.inputmask._valueSet(buffer.join(""));
|
||||
if (caretPos !== undefined && (event === undefined || event.type !== "blur")) {
|
||||
// console.log(caretPos);
|
||||
caret.call(inputmask, input, caretPos, undefined, undefined, (event !== undefined && event.type === "keydown" && (event.key === keys.Delete || event.key === keys.Backspace)));
|
||||
}
|
||||
if (triggerEvents === true) {
|
||||
var $input = $(input), nptVal = input.inputmask._valueGet();
|
||||
input.inputmask.skipInputEvent = true;
|
||||
$input.trigger("input");
|
||||
setTimeout(function () { //timeout needed for IE
|
||||
if (nptVal === getBufferTemplate.call(inputmask).join("")) {
|
||||
$input.trigger("cleared");
|
||||
} else if (isComplete.call(inputmask, buffer) === true) {
|
||||
$input.trigger("complete");
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
561
node_modules/inputmask/lib/inputmask.js
generated
vendored
561
node_modules/inputmask/lib/inputmask.js
generated
vendored
|
@ -4,8 +4,6 @@
|
|||
* Copyright (c) Robin Herbots
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
import "./polyfills/Object.getPrototypeOf";
|
||||
import "./polyfills/Array.includes";
|
||||
|
||||
import {mask} from "./mask";
|
||||
import $ from "./dependencyLibs/inputmask.dependencyLib";
|
||||
|
@ -23,329 +21,330 @@ import canUseDOM from "./canUseDOM";
|
|||
const document = window.document, dataKey = "_inputmask_opts";
|
||||
|
||||
function Inputmask(alias, options, internal) {
|
||||
if (!canUseDOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
//allow instanciating without new
|
||||
if (!(this instanceof Inputmask)) {
|
||||
return new Inputmask(alias, options, internal);
|
||||
}
|
||||
if (!canUseDOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dependencyLib = $;
|
||||
this.el = undefined;
|
||||
this.events = {};
|
||||
this.maskset = undefined;
|
||||
//allow instanciating without new
|
||||
if (!(this instanceof Inputmask)) {
|
||||
return new Inputmask(alias, options, internal);
|
||||
}
|
||||
|
||||
if (internal !== true) {
|
||||
//init options
|
||||
if (Object.prototype.toString.call(alias) === "[object Object]") {
|
||||
options = alias;
|
||||
} else {
|
||||
options = options || {};
|
||||
if (alias) options.alias = alias;
|
||||
}
|
||||
this.opts = $.extend(true, {}, this.defaults, options);
|
||||
this.noMasksCache = options && options.definitions !== undefined;
|
||||
this.userOptions = options || {}; //user passed options
|
||||
resolveAlias(this.opts.alias, options, this.opts);
|
||||
}
|
||||
this.dependencyLib = $;
|
||||
this.el = undefined;
|
||||
this.events = {};
|
||||
this.maskset = undefined;
|
||||
|
||||
//maskscope properties
|
||||
this.refreshValue = false; //indicate a refresh from the inputvalue is needed (form.reset)
|
||||
this.undoValue = undefined;
|
||||
this.$el = undefined;
|
||||
this.skipKeyPressEvent = false; //Safari 5.1.x - modal dialog fires keypress twice workaround
|
||||
this.skipInputEvent = false; //skip when triggered from within inputmask
|
||||
this.validationEvent = false;
|
||||
this.ignorable = false;
|
||||
this.maxLength;
|
||||
this.mouseEnter = false;
|
||||
this.originalPlaceholder = undefined; //needed for FF
|
||||
this.isComposing = false; //keydowncode == 229 compositionevent fallback
|
||||
if (internal !== true) {
|
||||
//init options
|
||||
if (Object.prototype.toString.call(alias) === "[object Object]") {
|
||||
options = alias;
|
||||
} else {
|
||||
options = options || {};
|
||||
if (alias) options.alias = alias;
|
||||
}
|
||||
this.opts = $.extend(true, {}, this.defaults, options);
|
||||
this.noMasksCache = options && options.definitions !== undefined;
|
||||
this.userOptions = options || {}; //user passed options
|
||||
resolveAlias(this.opts.alias, options, this.opts);
|
||||
}
|
||||
|
||||
//maskscope properties
|
||||
this.refreshValue = false; //indicate a refresh from the inputvalue is needed (form.reset)
|
||||
this.undoValue = undefined;
|
||||
this.$el = undefined;
|
||||
this.skipInputEvent = false; //skip when triggered from within inputmask
|
||||
this.validationEvent = false;
|
||||
this.ignorable = false;
|
||||
this.maxLength;
|
||||
this.mouseEnter = false;
|
||||
this.clicked = 0;
|
||||
this.originalPlaceholder = undefined; //needed for FF
|
||||
this.isComposing = false, //keydowncode == 229 compositionevent fallback
|
||||
this.hasAlternator = false;
|
||||
}
|
||||
|
||||
Inputmask.prototype = {
|
||||
dataAttribute: "data-inputmask", //data attribute prefix used for attribute binding
|
||||
//options default
|
||||
defaults: defaults,
|
||||
definitions: definitions,
|
||||
aliases: {}, //aliases definitions
|
||||
masksCache: {},
|
||||
get isRTL() {
|
||||
return this.opts.isRTL || this.opts.numericInput;
|
||||
},
|
||||
mask: function (elems) {
|
||||
var that = this;
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : (Array.isArray(elems) ? elems : Array.from(elems));
|
||||
elems.forEach(function (el, ndx) {
|
||||
var scopedOpts = $.extend(true, {}, that.opts);
|
||||
if (importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions), that.dataAttribute)) {
|
||||
var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
|
||||
if (maskset !== undefined) {
|
||||
if (el.inputmask !== undefined) {
|
||||
el.inputmask.opts.autoUnmask = true; //force autounmasking when remasking
|
||||
el.inputmask.remove();
|
||||
}
|
||||
//store inputmask instance on the input with element reference
|
||||
el.inputmask = new Inputmask(undefined, undefined, true);
|
||||
el.inputmask.opts = scopedOpts;
|
||||
el.inputmask.noMasksCache = that.noMasksCache;
|
||||
el.inputmask.userOptions = $.extend(true, {}, that.userOptions);
|
||||
// el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput;
|
||||
el.inputmask.el = el;
|
||||
el.inputmask.$el = $(el);
|
||||
el.inputmask.maskset = maskset;
|
||||
dataAttribute: "data-inputmask", //data attribute prefix used for attribute binding
|
||||
//options default
|
||||
defaults: defaults,
|
||||
definitions: definitions,
|
||||
aliases: {}, //aliases definitions
|
||||
masksCache: {},
|
||||
get isRTL() {
|
||||
return this.opts.isRTL || this.opts.numericInput;
|
||||
},
|
||||
mask: function (elems) {
|
||||
var that = this;
|
||||
if (typeof elems === "string") {
|
||||
elems = (document.getElementById(elems) || document.querySelectorAll(elems));
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : (Array.isArray(elems) ? elems : [].slice.call(elems)); //[].slice as alternate for Array.from (Yandex browser)
|
||||
elems.forEach(function (el, ndx) {
|
||||
var scopedOpts = $.extend(true, {}, that.opts);
|
||||
if (importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions), that.dataAttribute)) {
|
||||
var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
|
||||
if (maskset !== undefined) {
|
||||
if (el.inputmask !== undefined) {
|
||||
el.inputmask.opts.autoUnmask = true; //force autounmasking when remasking
|
||||
el.inputmask.remove();
|
||||
}
|
||||
//store inputmask instance on the input with element reference
|
||||
el.inputmask = new Inputmask(undefined, undefined, true);
|
||||
el.inputmask.opts = scopedOpts;
|
||||
el.inputmask.noMasksCache = that.noMasksCache;
|
||||
el.inputmask.userOptions = $.extend(true, {}, that.userOptions);
|
||||
// el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput;
|
||||
el.inputmask.el = el;
|
||||
el.inputmask.$el = $(el);
|
||||
el.inputmask.maskset = maskset;
|
||||
|
||||
$.data(el, dataKey, that.userOptions);
|
||||
mask.call(el.inputmask);
|
||||
}
|
||||
}
|
||||
});
|
||||
return elems && elems[0] ? (elems[0].inputmask || this) : this;
|
||||
},
|
||||
option: function (options, noremask) { //set extra options || retrieve value of a current option
|
||||
if (typeof options === "string") {
|
||||
return this.opts[options];
|
||||
} else if (typeof options === "object") {
|
||||
$.extend(this.userOptions, options); //user passed options
|
||||
//remask
|
||||
if (this.el && noremask !== true) {
|
||||
this.mask(this.el);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
},
|
||||
unmaskedvalue: function (value) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (this.el === undefined || value !== undefined) {
|
||||
var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, false, false, valueBuffer);
|
||||
if (typeof this.opts.onBeforeWrite === "function") this.opts.onBeforeWrite.call(this, undefined, getBuffer.call(this), 0, this.opts);
|
||||
}
|
||||
return unmaskedvalue.call(this, this.el);
|
||||
},
|
||||
remove: function () {
|
||||
if (this.el) {
|
||||
$.data(this.el, dataKey, null); //invalidate
|
||||
//writeout the value
|
||||
var cv = this.opts.autoUnmask ? unmaskedvalue(this.el) : this._valueGet(this.opts.autoUnmask);
|
||||
if (cv !== getBufferTemplate.call(this).join("")) this._valueSet(cv, this.opts.autoUnmask); else this._valueSet("");
|
||||
//unbind all events
|
||||
EventRuler.off(this.el);
|
||||
$.data(el, dataKey, that.userOptions);
|
||||
mask.call(el.inputmask);
|
||||
}
|
||||
}
|
||||
});
|
||||
return elems && elems[0] ? (elems[0].inputmask || this) : this;
|
||||
},
|
||||
option: function (options, noremask) { //set extra options || retrieve value of a current option
|
||||
if (typeof options === "string") {
|
||||
return this.opts[options];
|
||||
} else if (typeof options === "object") {
|
||||
$.extend(this.userOptions, options); //user passed options
|
||||
//remask
|
||||
if (this.el && noremask !== true) {
|
||||
this.mask(this.el);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
},
|
||||
unmaskedvalue: function (value) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (this.el === undefined || value !== undefined) {
|
||||
var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, false, false, valueBuffer);
|
||||
if (typeof this.opts.onBeforeWrite === "function") this.opts.onBeforeWrite.call(this, undefined, getBuffer.call(this), 0, this.opts);
|
||||
}
|
||||
return unmaskedvalue.call(this, this.el);
|
||||
},
|
||||
remove: function () {
|
||||
if (this.el) {
|
||||
$.data(this.el, dataKey, null); //invalidate
|
||||
//writeout the value
|
||||
var cv = this.opts.autoUnmask ? unmaskedvalue(this.el) : this._valueGet(this.opts.autoUnmask);
|
||||
if (cv !== getBufferTemplate.call(this).join("")) this._valueSet(cv, this.opts.autoUnmask); else this._valueSet("");
|
||||
//unbind all events
|
||||
EventRuler.off(this.el);
|
||||
|
||||
//restore the value property
|
||||
var valueProperty;
|
||||
if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf) {
|
||||
valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.el), "value");
|
||||
if (valueProperty) {
|
||||
if (this.__valueGet) {
|
||||
Object.defineProperty(this.el, "value", {
|
||||
get: this.__valueGet,
|
||||
set: this.__valueSet,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (document.__lookupGetter__ && this.el.__lookupGetter__("value")) {
|
||||
if (this.__valueGet) {
|
||||
this.el.__defineGetter__("value", this.__valueGet);
|
||||
this.el.__defineSetter__("value", this.__valueSet);
|
||||
}
|
||||
}
|
||||
//clear data
|
||||
this.el.inputmask = undefined;
|
||||
}
|
||||
return this.el;
|
||||
},
|
||||
getemptymask: function () { //return the default (empty) mask value, usefull for setting the default value in validation
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return getBufferTemplate.call(this).join("");
|
||||
},
|
||||
hasMaskedValue: function () { //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
|
||||
return !this.opts.autoUnmask;
|
||||
},
|
||||
isComplete: function () {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return isComplete.call(this, getBuffer.call(this));
|
||||
},
|
||||
getmetadata: function () { //return mask metadata if exists
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (Array.isArray(this.maskset.metadata)) {
|
||||
var maskTarget = getMaskTemplate.call(this, true, 0, false).join("");
|
||||
this.maskset.metadata.forEach(function (mtdt) {
|
||||
if (mtdt.mask === maskTarget) {
|
||||
maskTarget = mtdt;
|
||||
return false;
|
||||
}
|
||||
//restore the value property
|
||||
var valueProperty;
|
||||
if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf) {
|
||||
valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.el), "value");
|
||||
if (valueProperty) {
|
||||
if (this.__valueGet) {
|
||||
Object.defineProperty(this.el, "value", {
|
||||
get: this.__valueGet,
|
||||
set: this.__valueSet,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (document.__lookupGetter__ && this.el.__lookupGetter__("value")) {
|
||||
if (this.__valueGet) {
|
||||
this.el.__defineGetter__("value", this.__valueGet);
|
||||
this.el.__defineSetter__("value", this.__valueSet);
|
||||
}
|
||||
}
|
||||
//clear data
|
||||
this.el.inputmask = undefined;
|
||||
}
|
||||
return this.el;
|
||||
},
|
||||
getemptymask: function () { //return the default (empty) mask value, usefull for setting the default value in validation
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return (this.isRTL ? getBufferTemplate.call(this).reverse() : getBufferTemplate.call(this)).join("");
|
||||
},
|
||||
hasMaskedValue: function () { //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
|
||||
return !this.opts.autoUnmask;
|
||||
},
|
||||
isComplete: function () {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return isComplete.call(this, getBuffer.call(this));
|
||||
},
|
||||
getmetadata: function () { //return mask metadata if exists
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (Array.isArray(this.maskset.metadata)) {
|
||||
var maskTarget = getMaskTemplate.call(this, true, 0, false).join("");
|
||||
this.maskset.metadata.forEach(function (mtdt) {
|
||||
if (mtdt.mask === maskTarget) {
|
||||
maskTarget = mtdt;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
return maskTarget;
|
||||
}
|
||||
return this.maskset.metadata;
|
||||
},
|
||||
isValid: function (value) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (value) {
|
||||
var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, true, false, valueBuffer);
|
||||
} else {
|
||||
value = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
|
||||
}
|
||||
var buffer = getBuffer.call(this);
|
||||
var rl = determineLastRequiredPosition.call(this),
|
||||
lmib = buffer.length - 1;
|
||||
for (; lmib > rl; lmib--) {
|
||||
if (isMask.call(this, lmib)) break;
|
||||
}
|
||||
buffer.splice(rl, lmib + 1 - rl);
|
||||
return true;
|
||||
});
|
||||
return maskTarget;
|
||||
}
|
||||
return this.maskset.metadata;
|
||||
},
|
||||
isValid: function (value) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (value) {
|
||||
var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, true, false, valueBuffer);
|
||||
} else {
|
||||
value = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
|
||||
}
|
||||
var buffer = getBuffer.call(this);
|
||||
var rl = determineLastRequiredPosition.call(this),
|
||||
lmib = buffer.length - 1;
|
||||
for (; lmib > rl; lmib--) {
|
||||
if (isMask.call(this, lmib)) break;
|
||||
}
|
||||
buffer.splice(rl, lmib + 1 - rl);
|
||||
|
||||
return isComplete.call(this, buffer) && value === (this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join(""));
|
||||
return isComplete.call(this, buffer) && value === (this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join(""));
|
||||
|
||||
},
|
||||
format: function (value, metadata) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
let valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, true, false, valueBuffer);
|
||||
let formattedValue = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
|
||||
return metadata ? {
|
||||
value: formattedValue,
|
||||
metadata: this.getmetadata()
|
||||
} : formattedValue;
|
||||
},
|
||||
setValue: function (value) {
|
||||
if (this.el) {
|
||||
$(this.el).trigger("setvalue", [value]);
|
||||
}
|
||||
},
|
||||
analyseMask: analyseMask
|
||||
},
|
||||
format: function (value, metadata) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
let valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, true, false, valueBuffer);
|
||||
let formattedValue = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
|
||||
return metadata ? {
|
||||
value: formattedValue,
|
||||
metadata: this.getmetadata()
|
||||
} : formattedValue;
|
||||
},
|
||||
setValue: function (value) {
|
||||
if (this.el) {
|
||||
$(this.el).trigger("setvalue", [value]);
|
||||
}
|
||||
},
|
||||
analyseMask: analyseMask
|
||||
};
|
||||
|
||||
function resolveAlias(aliasStr, options, opts) {
|
||||
var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
|
||||
if (aliasDefinition) {
|
||||
if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
|
||||
$.extend(true, opts, aliasDefinition); //merge alias definition in the options
|
||||
$.extend(true, opts, options); //reapply extra given options
|
||||
return true;
|
||||
} else //alias not found - try as mask
|
||||
if (opts.mask === null) {
|
||||
opts.mask = aliasStr;
|
||||
}
|
||||
var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
|
||||
if (aliasDefinition) {
|
||||
if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
|
||||
$.extend(true, opts, aliasDefinition); //merge alias definition in the options
|
||||
$.extend(true, opts, options); //reapply extra given options
|
||||
return true;
|
||||
} else //alias not found - try as mask
|
||||
if (opts.mask === null) {
|
||||
opts.mask = aliasStr;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
|
||||
function importOption(option, optionData) {
|
||||
const attrOption = dataAttribute === "" ? option : dataAttribute + "-" + option;
|
||||
optionData = optionData !== undefined ? optionData : npt.getAttribute(attrOption);
|
||||
if (optionData !== null) {
|
||||
if (typeof optionData === "string") {
|
||||
if (option.indexOf("on") === 0) {
|
||||
optionData = window[optionData];
|
||||
}//get function definition
|
||||
else if (optionData === "false") {
|
||||
optionData = false;
|
||||
} else if (optionData === "true") optionData = true;
|
||||
}
|
||||
userOptions[option] = optionData;
|
||||
}
|
||||
}
|
||||
function importOption(option, optionData) {
|
||||
const attrOption = dataAttribute === "" ? option : dataAttribute + "-" + option;
|
||||
optionData = optionData !== undefined ? optionData : npt.getAttribute(attrOption);
|
||||
if (optionData !== null) {
|
||||
if (typeof optionData === "string") {
|
||||
if (option.indexOf("on") === 0) {
|
||||
optionData = window[optionData];
|
||||
}//get function definition
|
||||
else if (optionData === "false") {
|
||||
optionData = false;
|
||||
} else if (optionData === "true") optionData = true;
|
||||
}
|
||||
userOptions[option] = optionData;
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.importDataAttributes === true) {
|
||||
var attrOptions = npt.getAttribute(dataAttribute), option, dataoptions, optionData, p;
|
||||
if (opts.importDataAttributes === true) {
|
||||
var attrOptions = npt.getAttribute(dataAttribute), option, dataoptions, optionData, p;
|
||||
|
||||
if (attrOptions && attrOptions !== "") {
|
||||
attrOptions = attrOptions.replace(/'/g, "\"");
|
||||
dataoptions = JSON.parse("{" + attrOptions + "}");
|
||||
}
|
||||
if (attrOptions && attrOptions !== "") {
|
||||
attrOptions = attrOptions.replace(/'/g, "\"");
|
||||
dataoptions = JSON.parse("{" + attrOptions + "}");
|
||||
}
|
||||
|
||||
//resolve aliases
|
||||
if (dataoptions) { //pickup alias from dataAttribute
|
||||
optionData = undefined;
|
||||
for (p in dataoptions) {
|
||||
if (p.toLowerCase() === "alias") {
|
||||
optionData = dataoptions[p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
importOption("alias", optionData); //pickup alias from dataAttribute-alias
|
||||
if (userOptions.alias) {
|
||||
resolveAlias(userOptions.alias, userOptions, opts);
|
||||
}
|
||||
//resolve aliases
|
||||
if (dataoptions) { //pickup alias from dataAttribute
|
||||
optionData = undefined;
|
||||
for (p in dataoptions) {
|
||||
if (p.toLowerCase() === "alias") {
|
||||
optionData = dataoptions[p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
importOption("alias", optionData); //pickup alias from dataAttribute-alias
|
||||
if (userOptions.alias) {
|
||||
resolveAlias(userOptions.alias, userOptions, opts);
|
||||
}
|
||||
|
||||
for (option in opts) {
|
||||
if (dataoptions) {
|
||||
optionData = undefined;
|
||||
for (p in dataoptions) {
|
||||
if (p.toLowerCase() === option.toLowerCase()) {
|
||||
optionData = dataoptions[p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
importOption(option, optionData);
|
||||
}
|
||||
}
|
||||
$.extend(true, opts, userOptions);
|
||||
for (option in opts) {
|
||||
if (dataoptions) {
|
||||
optionData = undefined;
|
||||
for (p in dataoptions) {
|
||||
if (p.toLowerCase() === option.toLowerCase()) {
|
||||
optionData = dataoptions[p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
importOption(option, optionData);
|
||||
}
|
||||
}
|
||||
$.extend(true, opts, userOptions);
|
||||
|
||||
//handle dir=rtl
|
||||
if (npt.dir === "rtl" || opts.rightAlign) {
|
||||
npt.style.textAlign = "right";
|
||||
}
|
||||
//handle dir=rtl
|
||||
if (npt.dir === "rtl" || opts.rightAlign) {
|
||||
npt.style.textAlign = "right";
|
||||
}
|
||||
|
||||
if (npt.dir === "rtl" || opts.numericInput) {
|
||||
npt.dir = "ltr";
|
||||
npt.removeAttribute("dir");
|
||||
opts.isRTL = true;
|
||||
}
|
||||
if (npt.dir === "rtl" || opts.numericInput) {
|
||||
npt.dir = "ltr";
|
||||
npt.removeAttribute("dir");
|
||||
opts.isRTL = true;
|
||||
}
|
||||
|
||||
return Object.keys(userOptions).length;
|
||||
return Object.keys(userOptions).length;
|
||||
}
|
||||
|
||||
//apply defaults, definitions, aliases
|
||||
Inputmask.extendDefaults = function (options) {
|
||||
$.extend(true, Inputmask.prototype.defaults, options);
|
||||
$.extend(true, Inputmask.prototype.defaults, options);
|
||||
};
|
||||
Inputmask.extendDefinitions = function (definition) {
|
||||
$.extend(true, Inputmask.prototype.definitions, definition);
|
||||
$.extend(true, Inputmask.prototype.definitions, definition);
|
||||
};
|
||||
Inputmask.extendAliases = function (alias) {
|
||||
$.extend(true, Inputmask.prototype.aliases, alias);
|
||||
$.extend(true, Inputmask.prototype.aliases, alias);
|
||||
};
|
||||
//static fn on inputmask
|
||||
Inputmask.format = function (value, options, metadata) {
|
||||
return Inputmask(options).format(value, metadata);
|
||||
return Inputmask(options).format(value, metadata);
|
||||
};
|
||||
Inputmask.unmask = function (value, options) {
|
||||
return Inputmask(options).unmaskedvalue(value);
|
||||
return Inputmask(options).unmaskedvalue(value);
|
||||
};
|
||||
Inputmask.isValid = function (value, options) {
|
||||
return Inputmask(options).isValid(value);
|
||||
return Inputmask(options).isValid(value);
|
||||
};
|
||||
Inputmask.remove = function (elems) {
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : elems;
|
||||
elems.forEach(function (el) {
|
||||
if (el.inputmask) el.inputmask.remove();
|
||||
});
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : elems;
|
||||
elems.forEach(function (el) {
|
||||
if (el.inputmask) el.inputmask.remove();
|
||||
});
|
||||
};
|
||||
Inputmask.setValue = function (elems, value) {
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : elems;
|
||||
elems.forEach(function (el) {
|
||||
if (el.inputmask) el.inputmask.setValue(value); else $(el).trigger("setvalue", [value]);
|
||||
});
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : elems;
|
||||
elems.forEach(function (el) {
|
||||
if (el.inputmask) el.inputmask.setValue(value); else $(el).trigger("setvalue", [value]);
|
||||
});
|
||||
};
|
||||
|
||||
Inputmask.dependencyLib = $;
|
||||
|
|
25
node_modules/inputmask/lib/keycode.json
generated
vendored
25
node_modules/inputmask/lib/keycode.json
generated
vendored
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"BACKSPACE": 8,
|
||||
"BACKSPACE_SAFARI": 127,
|
||||
"DELETE": 46,
|
||||
"DOWN": 40,
|
||||
"END": 35,
|
||||
"ENTER": 13,
|
||||
"ESCAPE": 27,
|
||||
"HOME": 36,
|
||||
"INSERT": 45,
|
||||
"LEFT": 37,
|
||||
"PAGE_DOWN": 34,
|
||||
"PAGE_UP": 33,
|
||||
"RIGHT": 39,
|
||||
"SPACE": 32,
|
||||
"TAB": 9,
|
||||
"UP": 38,
|
||||
"X": 88,
|
||||
"Z": 90,
|
||||
"CONTROL": 17,
|
||||
"PAUSE/BREAK": 19,
|
||||
"WINDOWS_LEFT": 91,
|
||||
"WINDOWS_RIGHT": 92,
|
||||
"KEY_229": 229
|
||||
}
|
72
node_modules/inputmask/lib/mask-lexer.js
generated
vendored
72
node_modules/inputmask/lib/mask-lexer.js
generated
vendored
|
@ -1,12 +1,34 @@
|
|||
import $ from "./dependencyLibs/inputmask.dependencyLib";
|
||||
import MaskToken from "./masktoken";
|
||||
import Inputmask from "./inputmask";
|
||||
import escapeRegex from "./escapeRegex";
|
||||
|
||||
export {generateMaskSet, analyseMask};
|
||||
|
||||
function generateMaskSet(opts, nocache) {
|
||||
var ms;
|
||||
|
||||
function preProcessMask(mask, {repeat, groupmarker, quantifiermarker, keepStatic}) {
|
||||
if (repeat > 0 || repeat === "*" || repeat === "+") {
|
||||
var repeatStart = repeat === "*" ? 0 : (repeat === "+" ? 1 : repeat);
|
||||
mask = groupmarker[0] + mask + groupmarker[1] + quantifiermarker[0] + repeatStart + "," + repeat + quantifiermarker[1];
|
||||
}
|
||||
if (keepStatic === true) {
|
||||
let optionalRegex = "(.)\\[([^\\]]*)\\]", // "(?<p1>.)\\[(?<p2>[^\\]]*)\\]", remove named capture group @2428
|
||||
maskMatches = mask.match(new RegExp(optionalRegex, "g"));
|
||||
maskMatches && maskMatches.forEach((m, i) => {
|
||||
let [p1, p2] = m.split("["); p2 = p2.replace("]", "");
|
||||
mask = mask.replace(new RegExp(`${escapeRegex(p1)}\\[${escapeRegex(p2)}\\]`),
|
||||
p1.charAt(0) === p2.charAt(0) ?
|
||||
`(${p1}|${p1}${p2})` :
|
||||
`${p1}[${p2}]`);
|
||||
// console.log(mask);
|
||||
});
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
function generateMask(mask, metadata, opts) {
|
||||
var regexMask = false;
|
||||
if (mask === null || mask === "") {
|
||||
|
@ -22,10 +44,7 @@ function generateMaskSet(opts, nocache) {
|
|||
if (mask.length === 1 && opts.greedy === false && opts.repeat !== 0) {
|
||||
opts.placeholder = "";
|
||||
} //hide placeholder with single non-greedy mask
|
||||
if (opts.repeat > 0 || opts.repeat === "*" || opts.repeat === "+") {
|
||||
var repeatStart = opts.repeat === "*" ? 0 : (opts.repeat === "+" ? 1 : opts.repeat);
|
||||
mask = opts.groupmarker[0] + mask + opts.groupmarker[1] + opts.quantifiermarker[0] + repeatStart + "," + opts.repeat + opts.quantifiermarker[1];
|
||||
}
|
||||
mask = preProcessMask(mask, opts);
|
||||
|
||||
// console.log(mask);
|
||||
var masksetDefinition, maskdefKey;
|
||||
|
@ -38,7 +57,7 @@ function generateMaskSet(opts, nocache) {
|
|||
masksetDefinition = {
|
||||
"mask": mask,
|
||||
"maskToken": Inputmask.prototype.analyseMask(mask, regexMask, opts),
|
||||
"validPositions": {},
|
||||
"validPositions": [],
|
||||
"_buffer": undefined,
|
||||
"buffer": undefined,
|
||||
"tests": {},
|
||||
|
@ -114,9 +133,12 @@ function analyseMask(mask, regexMask, opts) {
|
|||
position = position !== undefined ? position : mtoken.matches.length;
|
||||
var prevMatch = mtoken.matches[position - 1];
|
||||
if (regexMask) {
|
||||
if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w/i.test(element)) || element === ".") {
|
||||
if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w|\\p/i.test(element)) || element === ".") {
|
||||
let flag = opts.casing ? "i" : "";
|
||||
if (/^\\p\{.*}$/i.test(element))
|
||||
flag += "u";
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: new RegExp(element, opts.casing ? "i" : ""),
|
||||
fn: new RegExp(element, flag),
|
||||
static: false,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element,
|
||||
|
@ -151,6 +173,7 @@ function analyseMask(mask, regexMask, opts) {
|
|||
} : new RegExp("."),
|
||||
static: maskdef.static || false,
|
||||
optionality: maskdef.optional || false,
|
||||
defOptionality: maskdef.optional || false, //indicator for an optional from the definition
|
||||
newBlockMarker: (prevMatch === undefined || maskdef.optional) ? "master" : prevMatch.def !== (maskdef.definitionSymbol || element),
|
||||
casing: maskdef.casing,
|
||||
def: maskdef.definitionSymbol || element,
|
||||
|
@ -327,17 +350,16 @@ function analyseMask(mask, regexMask, opts) {
|
|||
case "\\d":
|
||||
m = "[0-9]";
|
||||
break;
|
||||
case "\\p": //Unicode Categories
|
||||
m += regexTokenizer.exec(mask)[0]; // {
|
||||
m += regexTokenizer.exec(mask)[0]; // ?}
|
||||
break;
|
||||
case "(?:": //non capturing group
|
||||
case "(?=": //lookahead
|
||||
// openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case "(?!": //negative lookahead
|
||||
// openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case "(?<=": //lookbehind
|
||||
// openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case "(?<!": //negative lookbehind
|
||||
// openenings.push(new MaskToken(true));
|
||||
// treat as group
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -391,20 +413,16 @@ function analyseMask(mask, regexMask, opts) {
|
|||
};
|
||||
var matches = openenings.length > 0 ? openenings[openenings.length - 1].matches : currentToken.matches;
|
||||
match = matches.pop();
|
||||
if (match.isAlternator) { //handle quantifier in an alternation [0-9]{2}|[0-9]{3}
|
||||
matches.push(match); //push back alternator
|
||||
matches = match.matches; //remap target matches
|
||||
var groupToken = new MaskToken(true);
|
||||
var tmpMatch = matches.pop();
|
||||
matches.push(groupToken); //push the group
|
||||
matches = groupToken.matches;
|
||||
match = tmpMatch;
|
||||
}
|
||||
// if (match.isAlternator) { //handle quantifier in an alternation [0-9]{2}|[0-9]{3}
|
||||
// matches.push(match); //push back alternator
|
||||
// matches = match.matches; //remap target matches
|
||||
// var groupToken = new MaskToken(true);
|
||||
// var tmpMatch = matches.pop();
|
||||
// matches.push(groupToken); //push the group
|
||||
// matches = groupToken.matches;
|
||||
// match = tmpMatch;
|
||||
// }
|
||||
if (!match.isGroup) {
|
||||
// if (regexMask && match.fn === null) { //why is this needed???
|
||||
// if (match.def === ".") match.fn = new RegExp(match.def, opts.casing ? "i" : "");
|
||||
// }
|
||||
|
||||
match = groupify([match]);
|
||||
}
|
||||
matches.push(match);
|
||||
|
|
433
node_modules/inputmask/lib/mask.js
generated
vendored
433
node_modules/inputmask/lib/mask.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
import keyCode from "./keycode.json";
|
||||
import {keys} from "./keycode.js";
|
||||
import {caret, getBuffer, getBufferTemplate, getLastValidPosition, resetMaskSet, seekNext} from "./positioning";
|
||||
import {applyInputValue, clearOptionalTail, writeBuffer} from "./inputHandling";
|
||||
import {EventRuler} from "./eventruler";
|
||||
|
@ -6,239 +6,240 @@ import {iphone, mobile} from "./environment";
|
|||
import {isComplete} from "./validation";
|
||||
import {EventHandlers} from "./eventhandlers";
|
||||
|
||||
export{mask};
|
||||
export {mask};
|
||||
|
||||
//todo put on the prototype?
|
||||
function mask() {
|
||||
const inputmask = this,
|
||||
opts= this.opts,
|
||||
el=this.el,$=this.dependencyLib;
|
||||
const inputmask = this,
|
||||
opts = this.opts,
|
||||
el = this.el, $ = this.dependencyLib;
|
||||
|
||||
|
||||
function isElementTypeSupported(input, opts) {
|
||||
function patchValueProperty(npt) {
|
||||
var valueGet;
|
||||
var valueSet;
|
||||
function isElementTypeSupported(input, opts) {
|
||||
function patchValueProperty(npt) {
|
||||
var valueGet;
|
||||
var valueSet;
|
||||
|
||||
function patchValhook(type) {
|
||||
if ($.valHooks && ($.valHooks[type] === undefined || $.valHooks[type].inputmaskpatch !== true)) {
|
||||
var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function (elem) {
|
||||
return elem.value;
|
||||
};
|
||||
var valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function (elem, value) {
|
||||
elem.value = value;
|
||||
return elem;
|
||||
};
|
||||
function patchValhook(type) {
|
||||
if ($.valHooks && ($.valHooks[type] === undefined || $.valHooks[type].inputmaskpatch !== true)) {
|
||||
var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function (elem) {
|
||||
return elem.value;
|
||||
};
|
||||
var valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function (elem, value) {
|
||||
elem.value = value;
|
||||
return elem;
|
||||
};
|
||||
|
||||
$.valHooks[type] = {
|
||||
get: function (elem) {
|
||||
if (elem.inputmask) {
|
||||
if (elem.inputmask.opts.autoUnmask) {
|
||||
return elem.inputmask.unmaskedvalue();
|
||||
} else {
|
||||
var result = valhookGet(elem);
|
||||
return getLastValidPosition.call(inputmask, undefined, undefined, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== true ? result : "";
|
||||
}
|
||||
} else {
|
||||
return valhookGet(elem);
|
||||
}
|
||||
},
|
||||
set: function (elem, value) {
|
||||
var result = valhookSet(elem, value);
|
||||
if (elem.inputmask) {
|
||||
applyInputValue(elem, value);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
inputmaskpatch: true
|
||||
};
|
||||
}
|
||||
}
|
||||
$.valHooks[type] = {
|
||||
get: function (elem) {
|
||||
if (elem.inputmask) {
|
||||
if (elem.inputmask.opts.autoUnmask) {
|
||||
return elem.inputmask.unmaskedvalue();
|
||||
} else {
|
||||
var result = valhookGet(elem);
|
||||
return getLastValidPosition.call(inputmask, undefined, undefined, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== true ? result : "";
|
||||
}
|
||||
} else {
|
||||
return valhookGet(elem);
|
||||
}
|
||||
},
|
||||
set: function (elem, value) {
|
||||
var result = valhookSet(elem, value);
|
||||
if (elem.inputmask) {
|
||||
applyInputValue(elem, value);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
inputmaskpatch: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function getter() {
|
||||
if (this.inputmask) {
|
||||
return this.inputmask.opts.autoUnmask ?
|
||||
this.inputmask.unmaskedvalue() :
|
||||
(getLastValidPosition.call(inputmask) !== -1 || opts.nullable !== true ?
|
||||
(((this.inputmask.shadowRoot || this.ownerDocument).activeElement) === this && opts.clearMaskOnLostFocus ?
|
||||
(inputmask.isRTL ? clearOptionalTail.call(inputmask,getBuffer.call(inputmask).slice()).reverse() : clearOptionalTail.call(inputmask,getBuffer.call(inputmask).slice())).join("") :
|
||||
valueGet.call(this)) :
|
||||
"");
|
||||
} else {
|
||||
return valueGet.call(this);
|
||||
}
|
||||
}
|
||||
function getter() {
|
||||
if (this.inputmask) {
|
||||
return this.inputmask.opts.autoUnmask ?
|
||||
this.inputmask.unmaskedvalue() :
|
||||
(getLastValidPosition.call(inputmask) !== -1 || opts.nullable !== true ?
|
||||
(((this.inputmask.shadowRoot || this.ownerDocument).activeElement) === this && opts.clearMaskOnLostFocus ?
|
||||
(inputmask.isRTL ? clearOptionalTail.call(inputmask, getBuffer.call(inputmask).slice()).reverse() : clearOptionalTail.call(inputmask, getBuffer.call(inputmask).slice())).join("") :
|
||||
valueGet.call(this)) :
|
||||
"");
|
||||
} else {
|
||||
return valueGet.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
function setter(value) {
|
||||
valueSet.call(this, value);
|
||||
if (this.inputmask) {
|
||||
applyInputValue(this, value);
|
||||
}
|
||||
}
|
||||
function setter(value) {
|
||||
valueSet.call(this, value);
|
||||
if (this.inputmask) {
|
||||
applyInputValue(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
function installNativeValueSetFallback(npt) {
|
||||
EventRuler.on(npt, "mouseenter", function () {
|
||||
var input = this,
|
||||
value = input.inputmask._valueGet(true);
|
||||
if (value !== (inputmask.isRTL ? getBuffer.call(inputmask).reverse() : getBuffer.call(inputmask)).join("")) { //Is this correct? to apply RTL? TOCHECK
|
||||
applyInputValue(input, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
function installNativeValueSetFallback(npt) {
|
||||
EventRuler.on(npt, "mouseenter", function () {
|
||||
let input = this,
|
||||
value = input.inputmask._valueGet(true),
|
||||
bufferValue = (input.inputmask.isRTL ? getBuffer.call(input.inputmask).slice().reverse() : getBuffer.call(input.inputmask)).join("");
|
||||
if (value != bufferValue) {
|
||||
applyInputValue(input, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!npt.inputmask.__valueGet) {
|
||||
if (opts.noValuePatching !== true) {
|
||||
if (Object.getOwnPropertyDescriptor) {
|
||||
var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined;
|
||||
if (valueProperty && valueProperty.get && valueProperty.set) {
|
||||
valueGet = valueProperty.get;
|
||||
valueSet = valueProperty.set;
|
||||
Object.defineProperty(npt, "value", {
|
||||
get: getter,
|
||||
set: setter,
|
||||
configurable: true
|
||||
});
|
||||
} else if (npt.tagName.toLowerCase() !== "input") {
|
||||
valueGet = function () {
|
||||
return this.textContent;
|
||||
};
|
||||
valueSet = function (value) {
|
||||
this.textContent = value;
|
||||
};
|
||||
Object.defineProperty(npt, "value", {
|
||||
get: getter,
|
||||
set: setter,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
} else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) {
|
||||
valueGet = npt.__lookupGetter__("value");
|
||||
valueSet = npt.__lookupSetter__("value");
|
||||
if (!npt.inputmask.__valueGet) {
|
||||
if (opts.noValuePatching !== true) {
|
||||
if (Object.getOwnPropertyDescriptor) {
|
||||
var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined;
|
||||
if (valueProperty && valueProperty.get && valueProperty.set) {
|
||||
valueGet = valueProperty.get;
|
||||
valueSet = valueProperty.set;
|
||||
Object.defineProperty(npt, "value", {
|
||||
get: getter,
|
||||
set: setter,
|
||||
configurable: true
|
||||
});
|
||||
} else if (npt.tagName.toLowerCase() !== "input") {
|
||||
valueGet = function () {
|
||||
return this.textContent;
|
||||
};
|
||||
valueSet = function (value) {
|
||||
this.textContent = value;
|
||||
};
|
||||
Object.defineProperty(npt, "value", {
|
||||
get: getter,
|
||||
set: setter,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
} else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) {
|
||||
valueGet = npt.__lookupGetter__("value");
|
||||
valueSet = npt.__lookupSetter__("value");
|
||||
|
||||
npt.__defineGetter__("value", getter);
|
||||
npt.__defineSetter__("value", setter);
|
||||
}
|
||||
npt.inputmask.__valueGet = valueGet; //store native property getter
|
||||
npt.inputmask.__valueSet = valueSet; //store native property setter
|
||||
}
|
||||
npt.inputmask._valueGet = function (overruleRTL) {
|
||||
return inputmask.isRTL && overruleRTL !== true ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
|
||||
};
|
||||
npt.inputmask._valueSet = function (value, overruleRTL) { //null check is needed for IE8 => otherwise converts to "null"
|
||||
valueSet.call(this.el, (value === null || value === undefined) ? "" : ((overruleRTL !== true && inputmask.isRTL) ? value.split("").reverse().join("") : value));
|
||||
};
|
||||
npt.__defineGetter__("value", getter);
|
||||
npt.__defineSetter__("value", setter);
|
||||
}
|
||||
npt.inputmask.__valueGet = valueGet; //store native property getter
|
||||
npt.inputmask.__valueSet = valueSet; //store native property setter
|
||||
}
|
||||
npt.inputmask._valueGet = function (overruleRTL) {
|
||||
return inputmask.isRTL && overruleRTL !== true ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
|
||||
};
|
||||
npt.inputmask._valueSet = function (value, overruleRTL) { //null check is needed for IE8 => otherwise converts to "null"
|
||||
valueSet.call(this.el, (value === null || value === undefined) ? "" : ((overruleRTL !== true && inputmask.isRTL) ? value.split("").reverse().join("") : value));
|
||||
};
|
||||
|
||||
if (valueGet === undefined) { //jquery.val fallback
|
||||
valueGet = function () {
|
||||
return this.value;
|
||||
};
|
||||
valueSet = function (value) {
|
||||
this.value = value;
|
||||
};
|
||||
patchValhook(npt.type);
|
||||
installNativeValueSetFallback(npt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valueGet === undefined) { //jquery.val fallback
|
||||
valueGet = function () {
|
||||
return this.value;
|
||||
};
|
||||
valueSet = function (value) {
|
||||
this.value = value;
|
||||
};
|
||||
patchValhook(npt.type);
|
||||
installNativeValueSetFallback(npt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (input.tagName.toLowerCase() !== "textarea") {
|
||||
opts.ignorables.push(keyCode.ENTER);
|
||||
}
|
||||
if (input.tagName.toLowerCase() !== "textarea") {
|
||||
opts.ignorables.push(keys.Enter);
|
||||
}
|
||||
|
||||
var elementType = input.getAttribute("type");
|
||||
var isSupported = (input.tagName.toLowerCase() === "input" && opts.supportsInputType.includes(elementType)) || input.isContentEditable || input.tagName.toLowerCase() === "textarea";
|
||||
if (!isSupported) {
|
||||
if (input.tagName.toLowerCase() === "input") {
|
||||
var el = document.createElement("input");
|
||||
el.setAttribute("type", elementType);
|
||||
isSupported = el.type === "text"; //apply mask only if the type is not natively supported
|
||||
el = null;
|
||||
} else {
|
||||
isSupported = "partial";
|
||||
}
|
||||
}
|
||||
if (isSupported !== false) {
|
||||
patchValueProperty(input);
|
||||
} else {
|
||||
input.inputmask = undefined;
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
var elementType = input.getAttribute("type");
|
||||
var isSupported = (input.tagName.toLowerCase() === "input" && opts.supportsInputType.includes(elementType)) || input.isContentEditable || input.tagName.toLowerCase() === "textarea";
|
||||
if (!isSupported) {
|
||||
if (input.tagName.toLowerCase() === "input") {
|
||||
var el = document.createElement("input");
|
||||
el.setAttribute("type", elementType);
|
||||
isSupported = el.type === "text"; //apply mask only if the type is not natively supported
|
||||
el = null;
|
||||
} else {
|
||||
isSupported = "partial";
|
||||
}
|
||||
}
|
||||
if (isSupported !== false) {
|
||||
patchValueProperty(input);
|
||||
} else {
|
||||
input.inputmask = undefined;
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
//unbind all events - to make sure that no other mask will interfere when re-masking
|
||||
EventRuler.off(el);
|
||||
var isSupported = isElementTypeSupported(el, opts);
|
||||
if (isSupported !== false) {
|
||||
inputmask.originalPlaceholder = el.placeholder;
|
||||
//unbind all events - to make sure that no other mask will interfere when re-masking
|
||||
EventRuler.off(el);
|
||||
var isSupported = isElementTypeSupported(el, opts);
|
||||
if (isSupported !== false) {
|
||||
inputmask.originalPlaceholder = el.placeholder;
|
||||
|
||||
//read maxlength prop from el
|
||||
inputmask.maxLength = el !== undefined ? el.maxLength : undefined;
|
||||
if (inputmask.maxLength === -1) inputmask.maxLength = undefined;
|
||||
if ("inputMode" in el && el.getAttribute("inputmode") === null) {
|
||||
el.inputMode = opts.inputmode;
|
||||
el.setAttribute("inputmode", opts.inputmode);
|
||||
}
|
||||
//read maxlength prop from el
|
||||
inputmask.maxLength = el !== undefined ? el.maxLength : undefined;
|
||||
if (inputmask.maxLength === -1) inputmask.maxLength = undefined;
|
||||
if ("inputMode" in el && el.getAttribute("inputmode") === null) {
|
||||
el.inputMode = opts.inputmode;
|
||||
el.setAttribute("inputmode", opts.inputmode);
|
||||
}
|
||||
|
||||
|
||||
if (isSupported === true) {
|
||||
opts.showMaskOnFocus = opts.showMaskOnFocus && ["cc-number", "cc-exp"].indexOf(el.autocomplete) === -1;
|
||||
if (iphone) { //selecting the caret shows as a slection on iphone
|
||||
opts.insertModeVisual = false;
|
||||
}
|
||||
if (isSupported === true) {
|
||||
opts.showMaskOnFocus = opts.showMaskOnFocus && ["cc-number", "cc-exp"].indexOf(el.autocomplete) === -1;
|
||||
if (iphone) {
|
||||
//selecting the caret shows as a selection on iphone
|
||||
opts.insertModeVisual = false;
|
||||
//disable autocorrect
|
||||
el.setAttribute("autocorrect", "off");
|
||||
}
|
||||
|
||||
//bind events
|
||||
EventRuler.on(el, "submit", EventHandlers.submitEvent);
|
||||
EventRuler.on(el, "reset", EventHandlers.resetEvent);
|
||||
EventRuler.on(el, "blur", EventHandlers.blurEvent);
|
||||
EventRuler.on(el, "focus", EventHandlers.focusEvent);
|
||||
EventRuler.on(el, "invalid", EventHandlers.invalidEvent);
|
||||
EventRuler.on(el, "click", EventHandlers.clickEvent);
|
||||
EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent);
|
||||
EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent);
|
||||
EventRuler.on(el, "paste", EventHandlers.pasteEvent);
|
||||
EventRuler.on(el, "cut", EventHandlers.cutEvent);
|
||||
EventRuler.on(el, "complete", opts.oncomplete);
|
||||
EventRuler.on(el, "incomplete", opts.onincomplete);
|
||||
EventRuler.on(el, "cleared", opts.oncleared);
|
||||
if (opts.inputEventOnly !== true) {
|
||||
EventRuler.on(el, "keydown", EventHandlers.keydownEvent);
|
||||
EventRuler.on(el, "keypress", EventHandlers.keypressEvent);
|
||||
EventRuler.on(el, "keyup", EventHandlers.keyupEvent);
|
||||
}
|
||||
if (mobile || opts.inputEventOnly) {
|
||||
el.removeAttribute("maxLength");
|
||||
}
|
||||
EventRuler.on(el, "input", EventHandlers.inputFallBackEvent);
|
||||
EventRuler.on(el, "compositionend", EventHandlers.compositionendEvent);
|
||||
// EventRuler.on(el, "beforeinput", EventHandlers.beforeInputEvent); //https://github.com/w3c/input-events - to implement
|
||||
}
|
||||
EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);
|
||||
//bind events
|
||||
EventRuler.on(el, "submit", EventHandlers.submitEvent);
|
||||
EventRuler.on(el, "reset", EventHandlers.resetEvent);
|
||||
EventRuler.on(el, "blur", EventHandlers.blurEvent);
|
||||
EventRuler.on(el, "focus", EventHandlers.focusEvent);
|
||||
EventRuler.on(el, "invalid", EventHandlers.invalidEvent);
|
||||
EventRuler.on(el, "click", EventHandlers.clickEvent);
|
||||
EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent);
|
||||
EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent);
|
||||
EventRuler.on(el, "paste", EventHandlers.pasteEvent);
|
||||
EventRuler.on(el, "cut", EventHandlers.cutEvent);
|
||||
EventRuler.on(el, "complete", opts.oncomplete);
|
||||
EventRuler.on(el, "incomplete", opts.onincomplete);
|
||||
EventRuler.on(el, "cleared", opts.oncleared);
|
||||
if (opts.inputEventOnly !== true) {
|
||||
EventRuler.on(el, "keydown", EventHandlers.keyEvent);
|
||||
}
|
||||
if (mobile || opts.inputEventOnly) {
|
||||
el.removeAttribute("maxLength");
|
||||
}
|
||||
EventRuler.on(el, "input", EventHandlers.inputFallBackEvent);
|
||||
// EventRuler.on(el, "beforeinput", EventHandlers.beforeInputEvent); //https://github.com/w3c/input-events - to implement
|
||||
}
|
||||
EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);
|
||||
|
||||
//apply mask
|
||||
getBufferTemplate.call(inputmask).join(""); //initialize the buffer and getmasklength
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
var activeElement = (el.inputmask.shadowRoot || el.ownerDocument).activeElement;
|
||||
if (el.inputmask._valueGet(true) !== "" || opts.clearMaskOnLostFocus === false || activeElement === el) {
|
||||
applyInputValue(el, el.inputmask._valueGet(true), opts);
|
||||
var buffer = getBuffer.call(inputmask).slice();
|
||||
if (isComplete.call(inputmask, buffer) === false) {
|
||||
if (opts.clearIncomplete) {
|
||||
resetMaskSet.call(inputmask);
|
||||
}
|
||||
}
|
||||
if (opts.clearMaskOnLostFocus && activeElement !== el) {
|
||||
if (getLastValidPosition.call(inputmask) === -1) {
|
||||
buffer = [];
|
||||
} else {
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
}
|
||||
if (opts.clearMaskOnLostFocus === false || (opts.showMaskOnFocus && activeElement === el) || el.inputmask._valueGet(true) !== "") {
|
||||
writeBuffer(el, buffer);
|
||||
}
|
||||
if (activeElement === el) { //position the caret when in focus
|
||||
caret.call(inputmask,el, seekNext.call(inputmask, getLastValidPosition.call(inputmask)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//apply mask
|
||||
getBufferTemplate.call(inputmask).join(""); //initialize the buffer and getmasklength
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
var activeElement = (el.inputmask.shadowRoot || el.ownerDocument).activeElement;
|
||||
if (el.inputmask._valueGet(true) !== "" || opts.clearMaskOnLostFocus === false || activeElement === el) {
|
||||
applyInputValue(el, el.inputmask._valueGet(true), opts);
|
||||
var buffer = getBuffer.call(inputmask).slice();
|
||||
if (isComplete.call(inputmask, buffer) === false) {
|
||||
if (opts.clearIncomplete) {
|
||||
resetMaskSet.call(inputmask);
|
||||
}
|
||||
}
|
||||
if (opts.clearMaskOnLostFocus && activeElement !== el) {
|
||||
if (getLastValidPosition.call(inputmask) === -1) {
|
||||
buffer = [];
|
||||
} else {
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
}
|
||||
if (opts.clearMaskOnLostFocus === false || (opts.showMaskOnFocus && activeElement === el) || el.inputmask._valueGet(true) !== "") {
|
||||
writeBuffer(el, buffer);
|
||||
}
|
||||
if (activeElement === el) { //position the caret when in focus
|
||||
caret.call(inputmask, el, seekNext.call(inputmask, getLastValidPosition.call(inputmask)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
548
node_modules/inputmask/lib/positioning.js
generated
vendored
548
node_modules/inputmask/lib/positioning.js
generated
vendored
|
@ -1,348 +1,346 @@
|
|||
import {
|
||||
determineTestTemplate,
|
||||
getMaskTemplate,
|
||||
getPlaceholder,
|
||||
getTest,
|
||||
getTests,
|
||||
getTestTemplate
|
||||
determineTestTemplate,
|
||||
getMaskTemplate,
|
||||
getPlaceholder,
|
||||
getTest,
|
||||
getTests,
|
||||
getTestTemplate
|
||||
} from "./validation-tests";
|
||||
import {checkAlternationMatch} from "./validation";
|
||||
|
||||
export {
|
||||
caret,
|
||||
determineLastRequiredPosition,
|
||||
determineNewCaretPosition,
|
||||
getBuffer,
|
||||
getBufferTemplate,
|
||||
getLastValidPosition,
|
||||
isMask,
|
||||
resetMaskSet,
|
||||
seekNext,
|
||||
seekPrevious,
|
||||
translatePosition
|
||||
caret,
|
||||
determineLastRequiredPosition,
|
||||
determineNewCaretPosition,
|
||||
getBuffer,
|
||||
getBufferTemplate,
|
||||
getLastValidPosition,
|
||||
isMask,
|
||||
resetMaskSet,
|
||||
seekNext,
|
||||
seekPrevious,
|
||||
translatePosition
|
||||
};
|
||||
|
||||
//tobe put on prototype?
|
||||
function caret(input, begin, end, notranslate, isDelete) {
|
||||
const inputmask = this,
|
||||
opts = this.opts;
|
||||
const inputmask = this,
|
||||
opts = this.opts;
|
||||
|
||||
var range;
|
||||
if (begin !== undefined) {
|
||||
if (Array.isArray(begin)) {
|
||||
end = inputmask.isRTL ? begin[0] : begin[1];
|
||||
begin = inputmask.isRTL ? begin[1] : begin[0];
|
||||
}
|
||||
if (begin.begin !== undefined) {
|
||||
end = inputmask.isRTL ? begin.begin : begin.end;
|
||||
begin = inputmask.isRTL ? begin.end : begin.begin;
|
||||
}
|
||||
if (typeof begin === "number") {
|
||||
begin = notranslate ? begin : translatePosition.call(inputmask, begin);
|
||||
end = notranslate ? end : translatePosition.call(inputmask, end);
|
||||
end = (typeof end == "number") ? end : begin;
|
||||
// if (!$(input).is(":visible")) {
|
||||
// return;
|
||||
// }
|
||||
var range;
|
||||
if (begin !== undefined) {
|
||||
if (Array.isArray(begin)) {
|
||||
end = inputmask.isRTL ? begin[0] : begin[1];
|
||||
begin = inputmask.isRTL ? begin[1] : begin[0];
|
||||
}
|
||||
if (begin.begin !== undefined) {
|
||||
end = inputmask.isRTL ? begin.begin : begin.end;
|
||||
begin = inputmask.isRTL ? begin.end : begin.begin;
|
||||
}
|
||||
if (typeof begin === "number") {
|
||||
begin = notranslate ? begin : translatePosition.call(inputmask, begin);
|
||||
end = notranslate ? end : translatePosition.call(inputmask, end);
|
||||
end = (typeof end == "number") ? end : begin;
|
||||
// if (!$(input).is(":visible")) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
|
||||
input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0;
|
||||
input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
|
||||
if (opts.insertModeVisual && opts.insertMode === false && begin === end) {
|
||||
if (!isDelete) {
|
||||
end++; //set visualization for insert/overwrite mode
|
||||
}
|
||||
}
|
||||
if (input === (input.inputmask.shadowRoot || input.ownerDocument).activeElement) {
|
||||
if ("setSelectionRange" in input) {
|
||||
input.setSelectionRange(begin, end);
|
||||
} else if (window.getSelection) {
|
||||
range = document.createRange();
|
||||
if (input.firstChild === undefined || input.firstChild === null) {
|
||||
var textNode = document.createTextNode("");
|
||||
input.appendChild(textNode);
|
||||
}
|
||||
range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length);
|
||||
range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length);
|
||||
range.collapse(true);
|
||||
var sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
//input.focus();
|
||||
} else if (input.createTextRange) {
|
||||
range = input.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd("character", end);
|
||||
range.moveStart("character", begin);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("selectionStart" in input && "selectionEnd" in input) {
|
||||
begin = input.selectionStart;
|
||||
end = input.selectionEnd;
|
||||
} else if (window.getSelection) {
|
||||
range = window.getSelection().getRangeAt(0);
|
||||
if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
|
||||
begin = range.startOffset;
|
||||
end = range.endOffset;
|
||||
}
|
||||
} else if (document.selection && document.selection.createRange) {
|
||||
range = document.selection.createRange();
|
||||
begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length);
|
||||
end = begin + range.text.length;
|
||||
}
|
||||
var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
|
||||
input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0;
|
||||
input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
|
||||
if (opts.insertModeVisual && opts.insertMode === false && begin === end) {
|
||||
if (!isDelete) {
|
||||
end++; //set visualization for insert/overwrite mode
|
||||
}
|
||||
}
|
||||
if (input === (input.inputmask.shadowRoot || input.ownerDocument).activeElement) {
|
||||
if ("setSelectionRange" in input) {
|
||||
input.setSelectionRange(begin, end);
|
||||
} else if (window.getSelection) {
|
||||
range = document.createRange();
|
||||
if (input.firstChild === undefined || input.firstChild === null) {
|
||||
var textNode = document.createTextNode("");
|
||||
input.appendChild(textNode);
|
||||
}
|
||||
range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length);
|
||||
range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length);
|
||||
range.collapse(true);
|
||||
var sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
//input.focus();
|
||||
} else if (input.createTextRange) {
|
||||
range = input.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd("character", end);
|
||||
range.moveStart("character", begin);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("selectionStart" in input && "selectionEnd" in input) {
|
||||
begin = input.selectionStart;
|
||||
end = input.selectionEnd;
|
||||
} else if (window.getSelection) {
|
||||
range = window.getSelection().getRangeAt(0);
|
||||
if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
|
||||
begin = range.startOffset;
|
||||
end = range.endOffset;
|
||||
}
|
||||
} else if (document.selection && document.selection.createRange) {
|
||||
range = document.selection.createRange();
|
||||
begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length);
|
||||
end = begin + range.text.length;
|
||||
}
|
||||
|
||||
// if (opts.insertModeVisual && opts.insertMode === false && begin === (end - 1)) end--; //correct caret for insert/overwrite mode
|
||||
// if (opts.insertModeVisual && opts.insertMode === false && begin === (end - 1)) end--; //correct caret for insert/overwrite mode
|
||||
|
||||
/*eslint-disable consistent-return */
|
||||
return {
|
||||
"begin": notranslate ? begin : translatePosition.call(inputmask, begin),
|
||||
"end": notranslate ? end : translatePosition.call(inputmask, end)
|
||||
};
|
||||
/*eslint-enable consistent-return */
|
||||
}
|
||||
/*eslint-disable consistent-return */
|
||||
return {
|
||||
"begin": notranslate ? begin : translatePosition.call(inputmask, begin),
|
||||
"end": notranslate ? end : translatePosition.call(inputmask, end)
|
||||
};
|
||||
/*eslint-enable consistent-return */
|
||||
}
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function determineLastRequiredPosition(returnDefinition) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset,
|
||||
$ = this.dependencyLib;
|
||||
const inputmask = this, {maskset, dependencyLib: $} = inputmask;
|
||||
|
||||
var buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true, true),
|
||||
bl = buffer.length,
|
||||
pos, lvp = getLastValidPosition.call(inputmask),
|
||||
positions = {},
|
||||
lvTest = maskset.validPositions[lvp],
|
||||
ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined,
|
||||
testPos;
|
||||
for (pos = lvp + 1; pos < buffer.length; pos++) {
|
||||
testPos = getTestTemplate.call(inputmask, pos, ndxIntlzr, pos - 1);
|
||||
ndxIntlzr = testPos.locator.slice();
|
||||
positions[pos] = $.extend(true, {}, testPos);
|
||||
}
|
||||
var buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true, true),
|
||||
bl = buffer.length,
|
||||
pos, lvp = getLastValidPosition.call(inputmask),
|
||||
positions = {},
|
||||
lvTest = maskset.validPositions[lvp],
|
||||
ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined,
|
||||
testPos;
|
||||
for (pos = lvp + 1; pos < buffer.length; pos++) {
|
||||
testPos = getTestTemplate.call(inputmask, pos, ndxIntlzr, pos - 1);
|
||||
ndxIntlzr = testPos.locator.slice();
|
||||
positions[pos] = $.extend(true, {}, testPos);
|
||||
}
|
||||
|
||||
var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
|
||||
for (pos = bl - 1; pos > lvp; pos--) {
|
||||
testPos = positions[pos];
|
||||
if ((testPos.match.optionality ||
|
||||
(testPos.match.optionalQuantifier && testPos.match.newBlockMarker) ||
|
||||
(lvTestAlt &&
|
||||
(
|
||||
(lvTestAlt !== positions[pos].locator[lvTest.alternation] && testPos.match.static != true) ||
|
||||
(testPos.match.static === true &&
|
||||
testPos.locator[lvTest.alternation] &&
|
||||
checkAlternationMatch.call(inputmask, testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) &&
|
||||
getTests.call(inputmask, pos)[0].def !== "")
|
||||
)
|
||||
)) &&
|
||||
buffer[pos] === getPlaceholder.call(inputmask, pos, testPos.match)) {
|
||||
bl--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnDefinition ? {
|
||||
"l": bl,
|
||||
"def": positions[bl] ? positions[bl].match : undefined
|
||||
} : bl;
|
||||
var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
|
||||
for (pos = bl - 1; pos > lvp; pos--) {
|
||||
testPos = positions[pos];
|
||||
if ((testPos.match.optionality ||
|
||||
(testPos.match.optionalQuantifier && testPos.match.newBlockMarker) ||
|
||||
(lvTestAlt &&
|
||||
(
|
||||
(lvTestAlt !== positions[pos].locator[lvTest.alternation] && testPos.match.static != true) ||
|
||||
(testPos.match.static === true &&
|
||||
testPos.locator[lvTest.alternation] &&
|
||||
checkAlternationMatch.call(inputmask, testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) &&
|
||||
getTests.call(inputmask, pos)[0].def !== "")
|
||||
)
|
||||
)) &&
|
||||
buffer[pos] === getPlaceholder.call(inputmask, pos, testPos.match)) {
|
||||
bl--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnDefinition ? {
|
||||
"l": bl,
|
||||
"def": positions[bl] ? positions[bl].match : undefined
|
||||
} : bl;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function determineNewCaretPosition(selectedCaret, tabbed, positionCaretOnClick) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset,
|
||||
opts = this.opts;
|
||||
const inputmask = this, {maskset, opts} = inputmask;
|
||||
|
||||
function doRadixFocus(clickPos) {
|
||||
if (opts.radixPoint !== "" && opts.digits !== 0) {
|
||||
var vps = maskset.validPositions;
|
||||
if (vps[clickPos] === undefined || (vps[clickPos].input === getPlaceholder.call(inputmask, clickPos))) {
|
||||
if (clickPos < seekNext.call(inputmask, -1)) return true;
|
||||
var radixPos = getBuffer.call(inputmask).indexOf(opts.radixPoint);
|
||||
if (radixPos !== -1) {
|
||||
for (var vp in vps) {
|
||||
if (vps[vp] && radixPos < vp && vps[vp].input !== getPlaceholder.call(inputmask, vp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function doRadixFocus(clickPos) {
|
||||
if (opts.radixPoint !== "" && opts.digits !== 0) {
|
||||
var vps = maskset.validPositions;
|
||||
if (vps[clickPos] === undefined || (vps[clickPos].input === getPlaceholder.call(inputmask, clickPos))) {
|
||||
if (clickPos < seekNext.call(inputmask, -1)) return true;
|
||||
var radixPos = getBuffer.call(inputmask).indexOf(opts.radixPoint);
|
||||
if (radixPos !== -1) {
|
||||
for (let vp = 0, vpl = vps.length; vp < vpl; vp++) {
|
||||
if (vps[vp] && radixPos < vp && vps[vp].input !== getPlaceholder.call(inputmask, vp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tabbed) {
|
||||
if (inputmask.isRTL) {
|
||||
selectedCaret.end = selectedCaret.begin;
|
||||
} else {
|
||||
selectedCaret.begin = selectedCaret.end;
|
||||
}
|
||||
}
|
||||
if (selectedCaret.begin === selectedCaret.end) {
|
||||
positionCaretOnClick = positionCaretOnClick || opts.positionCaretOnClick;
|
||||
switch (positionCaretOnClick) {
|
||||
case "none":
|
||||
break;
|
||||
case "select":
|
||||
selectedCaret = {begin: 0, end: getBuffer.call(inputmask).length};
|
||||
break;
|
||||
case "ignore":
|
||||
selectedCaret.end = selectedCaret.begin = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
|
||||
break;
|
||||
case "radixFocus":
|
||||
if (doRadixFocus(selectedCaret.begin)) {
|
||||
var radixPos = getBuffer.call(inputmask).join("").indexOf(opts.radixPoint);
|
||||
selectedCaret.end = selectedCaret.begin = opts.numericInput ? seekNext.call(inputmask, radixPos) : radixPos;
|
||||
break;
|
||||
} //fallback to lvp
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
default: //lvp:
|
||||
var clickPosition = selectedCaret.begin,
|
||||
lvclickPosition = getLastValidPosition.call(inputmask, clickPosition, true),
|
||||
lastPosition = seekNext.call(inputmask, (lvclickPosition === -1 && !isMask.call(inputmask, 0)) ? -1 : lvclickPosition);
|
||||
if (tabbed) {
|
||||
if (inputmask.isRTL) {
|
||||
selectedCaret.end = selectedCaret.begin;
|
||||
} else {
|
||||
selectedCaret.begin = selectedCaret.end;
|
||||
}
|
||||
}
|
||||
if (selectedCaret.begin === selectedCaret.end) {
|
||||
positionCaretOnClick = positionCaretOnClick || opts.positionCaretOnClick;
|
||||
switch (positionCaretOnClick) {
|
||||
case "none":
|
||||
break;
|
||||
case "select":
|
||||
selectedCaret = {begin: 0, end: getBuffer.call(inputmask).length};
|
||||
break;
|
||||
case "ignore":
|
||||
selectedCaret.end = selectedCaret.begin = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
|
||||
break;
|
||||
case "radixFocus":
|
||||
if (inputmask.clicked > 1 && maskset.validPositions.length == 0)
|
||||
break;
|
||||
if (doRadixFocus(selectedCaret.begin)) {
|
||||
var radixPos = getBuffer.call(inputmask).join("").indexOf(opts.radixPoint);
|
||||
selectedCaret.end = selectedCaret.begin = opts.numericInput ? seekNext.call(inputmask, radixPos) : radixPos;
|
||||
break;
|
||||
} //fallback to lvp
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
default: //lvp:
|
||||
var clickPosition = selectedCaret.begin,
|
||||
lvclickPosition = getLastValidPosition.call(inputmask, clickPosition, true),
|
||||
lastPosition = seekNext.call(inputmask, (lvclickPosition === -1 && !isMask.call(inputmask, 0)) ? -1 : lvclickPosition);
|
||||
|
||||
if (clickPosition <= lastPosition) {
|
||||
selectedCaret.end = selectedCaret.begin = !isMask.call(inputmask, clickPosition, false, true) ? seekNext.call(inputmask, clickPosition) : clickPosition;
|
||||
} else {
|
||||
var lvp = maskset.validPositions[lvclickPosition],
|
||||
tt = getTestTemplate.call(inputmask, lastPosition, lvp ? lvp.match.locator : undefined, lvp),
|
||||
placeholder = getPlaceholder.call(inputmask, lastPosition, tt.match);
|
||||
if ((placeholder !== "" && getBuffer.call(inputmask)[lastPosition] !== placeholder && tt.match.optionalQuantifier !== true && tt.match.newBlockMarker !== true) || (!isMask.call(inputmask, lastPosition, opts.keepStatic, true) && tt.match.def === placeholder)) {
|
||||
var newPos = seekNext.call(inputmask, lastPosition);
|
||||
if (clickPosition >= newPos || clickPosition === lastPosition) {
|
||||
lastPosition = newPos;
|
||||
}
|
||||
}
|
||||
selectedCaret.end = selectedCaret.begin = lastPosition;
|
||||
}
|
||||
}
|
||||
if (clickPosition <= lastPosition) {
|
||||
selectedCaret.end = selectedCaret.begin = !isMask.call(inputmask, clickPosition, false, true) ? seekNext.call(inputmask, clickPosition) : clickPosition;
|
||||
} else {
|
||||
var lvp = maskset.validPositions[lvclickPosition],
|
||||
tt = getTestTemplate.call(inputmask, lastPosition, lvp ? lvp.match.locator : undefined, lvp),
|
||||
placeholder = getPlaceholder.call(inputmask, lastPosition, tt.match);
|
||||
if ((placeholder !== "" && getBuffer.call(inputmask)[lastPosition] !== placeholder && tt.match.optionalQuantifier !== true && tt.match.newBlockMarker !== true) || (!isMask.call(inputmask, lastPosition, opts.keepStatic, true) && tt.match.def === placeholder)) {
|
||||
var newPos = seekNext.call(inputmask, lastPosition);
|
||||
if (clickPosition >= newPos || clickPosition === lastPosition) {
|
||||
lastPosition = newPos;
|
||||
}
|
||||
}
|
||||
selectedCaret.end = selectedCaret.begin = lastPosition;
|
||||
}
|
||||
}
|
||||
|
||||
return selectedCaret;
|
||||
}
|
||||
return selectedCaret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//tobe put on prototype?
|
||||
function getBuffer(noCache) {
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
const inputmask = this, {maskset} = inputmask;
|
||||
|
||||
if (maskset.buffer === undefined || noCache === true) {
|
||||
maskset.buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true);
|
||||
if (maskset._buffer === undefined) maskset._buffer = maskset.buffer.slice();
|
||||
}
|
||||
return maskset.buffer;
|
||||
if (maskset.buffer === undefined || noCache === true) {
|
||||
maskset.buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true);
|
||||
if (maskset._buffer === undefined) maskset._buffer = maskset.buffer.slice();
|
||||
}
|
||||
return maskset.buffer;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getBufferTemplate() {
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
|
||||
if (maskset._buffer === undefined) {
|
||||
//generate template
|
||||
maskset._buffer = getMaskTemplate.call(inputmask, false, 1);
|
||||
if (maskset.buffer === undefined) maskset.buffer = maskset._buffer.slice();
|
||||
}
|
||||
return maskset._buffer;
|
||||
if (maskset._buffer === undefined) {
|
||||
//generate template
|
||||
maskset._buffer = getMaskTemplate.call(inputmask, false, 1);
|
||||
if (maskset.buffer === undefined) maskset.buffer = maskset._buffer.slice();
|
||||
}
|
||||
return maskset._buffer;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getLastValidPosition(closestTo, strict, validPositions) {
|
||||
const maskset = this.maskset;
|
||||
const maskset = this.maskset;
|
||||
|
||||
var before = -1,
|
||||
after = -1,
|
||||
valids = validPositions || maskset.validPositions; //for use in valhook ~ context switch
|
||||
if (closestTo === undefined) closestTo = -1;
|
||||
for (var posNdx in valids) {
|
||||
var psNdx = parseInt(posNdx);
|
||||
if (valids[psNdx] && (strict || valids[psNdx].generatedInput !== true)) {
|
||||
if (psNdx <= closestTo) before = psNdx;
|
||||
if (psNdx >= closestTo) after = psNdx;
|
||||
}
|
||||
}
|
||||
return (before === -1 || before == closestTo) ? after : after == -1 ? before : (closestTo - before) < (after - closestTo) ? before : after;
|
||||
var before = -1,
|
||||
after = -1,
|
||||
valids = validPositions || maskset.validPositions; //for use in valhook ~ context switch
|
||||
if (closestTo === undefined) closestTo = -1;
|
||||
for (var psNdx = 0, vpl = valids.length; psNdx < vpl; psNdx++) {
|
||||
if (valids[psNdx] && (strict || valids[psNdx].generatedInput !== true)) {
|
||||
if (psNdx <= closestTo) before = psNdx;
|
||||
if (psNdx >= closestTo) after = psNdx;
|
||||
}
|
||||
}
|
||||
return (before === -1 || before == closestTo) ? after : after == -1 ? before : (closestTo - before) < (after - closestTo) ? before : after;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function isMask(pos, strict, fuzzy) {
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
|
||||
var test = getTestTemplate.call(inputmask, pos).match;
|
||||
if (test.def === "") test = getTest.call(inputmask, pos).match;
|
||||
var test = getTestTemplate.call(inputmask, pos).match;
|
||||
if (test.def === "") test = getTest.call(inputmask, pos).match;
|
||||
|
||||
if (test.static !== true) {
|
||||
return test.fn;
|
||||
}
|
||||
if (fuzzy === true && (maskset.validPositions[pos] !== undefined && maskset.validPositions[pos].generatedInput !== true)) {
|
||||
return true;
|
||||
}
|
||||
if (test.static !== true) {
|
||||
return test.fn;
|
||||
}
|
||||
if (fuzzy === true && (maskset.validPositions[pos] !== undefined && maskset.validPositions[pos].generatedInput !== true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strict !== true && pos > -1) {
|
||||
if (fuzzy) { //check on the number of tests
|
||||
var tests = getTests.call(inputmask, pos);
|
||||
return tests.length > (1 + (tests[tests.length - 1].match.def === "" ? 1 : 0));
|
||||
}
|
||||
//else based on the template
|
||||
var testTemplate = determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos));
|
||||
var testPlaceHolder = getPlaceholder.call(inputmask, pos, testTemplate.match);
|
||||
return testTemplate.match.def !== testPlaceHolder;
|
||||
if (strict !== true && pos > -1) {
|
||||
if (fuzzy) { //check on the number of tests
|
||||
var tests = getTests.call(inputmask, pos);
|
||||
return tests.length > (1 + (tests[tests.length - 1].match.def === "" ? 1 : 0));
|
||||
}
|
||||
//else based on the template
|
||||
var testTemplate = determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos));
|
||||
var testPlaceHolder = getPlaceholder.call(inputmask, pos, testTemplate.match);
|
||||
return testTemplate.match.def !== testPlaceHolder;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function resetMaskSet(soft) {
|
||||
const maskset = this.maskset;
|
||||
const maskset = this.maskset;
|
||||
|
||||
maskset.buffer = undefined;
|
||||
if (soft !== true) {
|
||||
maskset.validPositions = {};
|
||||
maskset.p = 0;
|
||||
}
|
||||
maskset.buffer = undefined;
|
||||
if (soft !== true) {
|
||||
maskset.validPositions = [];
|
||||
maskset.p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function seekNext(pos, newBlock, fuzzy) {
|
||||
const inputmask = this;
|
||||
const inputmask = this;
|
||||
|
||||
if (fuzzy === undefined) fuzzy = true;
|
||||
var position = pos + 1;
|
||||
while (getTest.call(inputmask, position).match.def !== "" &&
|
||||
((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
|
||||
(newBlock !== true && !isMask.call(inputmask, position, undefined, fuzzy)))) {
|
||||
position++;
|
||||
}
|
||||
return position;
|
||||
if (fuzzy === undefined) fuzzy = true;
|
||||
var position = pos + 1;
|
||||
while (getTest.call(inputmask, position).match.def !== "" &&
|
||||
((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
|
||||
(newBlock !== true && !isMask.call(inputmask, position, undefined, fuzzy)))) {
|
||||
position++;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function seekPrevious(pos, newBlock) {
|
||||
const inputmask = this;
|
||||
const inputmask = this;
|
||||
|
||||
var position = pos - 1;
|
||||
if (pos <= 0) return 0;
|
||||
var position = pos - 1;
|
||||
if (pos <= 0) return 0;
|
||||
|
||||
while (position > 0 &&
|
||||
((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
|
||||
(newBlock !== true && !isMask.call(inputmask, position, undefined, true)))) {
|
||||
position--;
|
||||
}
|
||||
return position;
|
||||
while (position > 0 &&
|
||||
((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
|
||||
(newBlock !== true && !isMask.call(inputmask, position, undefined, true)))) {
|
||||
position--;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function translatePosition(pos) {
|
||||
const inputmask = this,
|
||||
opts = this.opts,
|
||||
el = this.el;
|
||||
const inputmask = this,
|
||||
opts = this.opts,
|
||||
el = this.el;
|
||||
|
||||
if (inputmask.isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) {
|
||||
pos = Math.abs(inputmask._valueGet().length - pos);
|
||||
}
|
||||
return pos;
|
||||
if (inputmask.isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) {
|
||||
pos = inputmask._valueGet().length - pos;
|
||||
if (pos < 0) pos = 0;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
|
1090
node_modules/inputmask/lib/validation-tests.js
generated
vendored
1090
node_modules/inputmask/lib/validation-tests.js
generated
vendored
File diff suppressed because it is too large
Load diff
1151
node_modules/inputmask/lib/validation.js
generated
vendored
1151
node_modules/inputmask/lib/validation.js
generated
vendored
File diff suppressed because it is too large
Load diff
31
node_modules/inputmask/package.json
generated
vendored
31
node_modules/inputmask/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "inputmask",
|
||||
"version": "5.0.7",
|
||||
"version": "5.0.8",
|
||||
"description": "Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.",
|
||||
"main": "dist/inputmask.js",
|
||||
"files": [
|
||||
|
@ -36,25 +36,30 @@
|
|||
},
|
||||
"homepage": "https://github.com/RobinHerbots/Inputmask",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.5",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.16.5",
|
||||
"@babel/preset-env": "^7.16.5",
|
||||
"@babel/preset-typescript": "^7.16.5",
|
||||
"@babel/core": "^7.20.5",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.19.6",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@robinherbots/grunt-available-tasks": "^0.6.4",
|
||||
"@robinherbots/grunt-nuget": "^0.3.2",
|
||||
"babel-loader": "^8.2.3",
|
||||
"grunt": "^1.4.1",
|
||||
"@robinherbots/grunt-nuget": "^0.3.3",
|
||||
"babel-loader": "^9.1.0",
|
||||
"grunt": "^1.5.3",
|
||||
"grunt-bump": "^0.8.0",
|
||||
"grunt-contrib-clean": "^2.0.0",
|
||||
"grunt-contrib-clean": "^2.0.1",
|
||||
"grunt-contrib-copy": "^1.0.0",
|
||||
"grunt-eslint": "^24.0.0",
|
||||
"grunt-karma": "^4.0.2",
|
||||
"grunt-release": "^0.14.0",
|
||||
"grunt-webpack": "^5.0.0",
|
||||
"jquery": "^3.6.0",
|
||||
"jquery": "^3.6.1",
|
||||
"karma": "^6.4.1",
|
||||
"karma-browserstack-launcher": "^1.6.0",
|
||||
"karma-chrome-launcher": "^3.1.1",
|
||||
"karma-qunit": "^4.1.2",
|
||||
"load-grunt-tasks": "^5.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
"qunit": "^2.17.2",
|
||||
"webpack": "^5.65.0",
|
||||
"webpack-cli": "^4.9.1"
|
||||
"qunit": "^2.19.3",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue