Comparing version 1.2.0 to 1.2.1
@@ -56,3 +56,3 @@ var _extends = Object.assign || function (target) { | ||
this._value = ''; | ||
this.updateOptions(_extends({}, Masked.DEFAULTS, opts)); | ||
this._update(_extends({}, Masked.DEFAULTS, opts)); | ||
this.isInitialized = true; | ||
@@ -62,5 +62,9 @@ } | ||
updateOptions(opts) { | ||
this.withValueRefresh(() => Object.assign(this, opts)); | ||
this.withValueRefresh(this._update.bind(this, opts)); | ||
} | ||
_update(opts) { | ||
Object.assign(this, opts); | ||
} | ||
clone() { | ||
@@ -176,10 +180,10 @@ const m = new Masked(this); | ||
withValueRefresh(fn) { | ||
if (this._refreshing) return fn(); | ||
if (this._refreshing || !this.isInitialized) return fn(); | ||
this._refreshing = true; | ||
const unmasked = this.isInitialized ? this.unmaskedValue : null; | ||
const unmasked = this.unmaskedValue; | ||
const ret = fn(); | ||
if (unmasked != null) this.unmaskedValue = unmasked; | ||
this.unmaskedValue = unmasked; | ||
@@ -247,5 +251,45 @@ delete this._refreshing; | ||
// cloned from https://github.com/epoberezkin/fast-deep-equal with small changes | ||
function objectIncludes(b, a) { | ||
if (a === b) return true; | ||
var arrA = Array.isArray(a), | ||
arrB = Array.isArray(b), | ||
i; | ||
if (arrA && arrB) { | ||
if (a.length != b.length) return false; | ||
for (i = 0; i < a.length; i++) if (!objectIncludes(a[i], b[i])) return false; | ||
return true; | ||
} | ||
if (arrA != arrB) return false; | ||
if (a && b && typeof a === 'object' && typeof b === 'object') { | ||
var keys = Object.keys(a); | ||
// if (keys.length !== Object.keys(b).length) return false; | ||
var dateA = a instanceof Date, | ||
dateB = b instanceof Date; | ||
if (dateA && dateB) return a.getTime() == b.getTime(); | ||
if (dateA != dateB) return false; | ||
var regexpA = a instanceof RegExp, | ||
regexpB = b instanceof RegExp; | ||
if (regexpA && regexpB) return a.toString() == b.toString(); | ||
if (regexpA != regexpB) return false; | ||
for (i = 0; i < keys.length; i++) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; | ||
for (i = 0; i < keys.length; i++) if (!objectIncludes(a[keys[i]], b[keys[i]])) return false; | ||
return true; | ||
} | ||
return false; | ||
} | ||
class MaskedRegExp extends Masked { | ||
constructor(opts = {}) { | ||
opts.validate = value => opts.mask.test(value); | ||
opts.validate = value => value.search(opts.mask) >= 0; | ||
super(opts); | ||
@@ -264,11 +308,10 @@ } | ||
constructor(opts) { | ||
opts.postFormat = Object.assign({}, MaskedNumber.DEFAULTS.postFormat, opts.postFormat); | ||
super(_extends({}, MaskedNumber.DEFAULTS, opts)); | ||
} | ||
updateOptions(opts) { | ||
opts._signed = opts.signed; | ||
delete opts.signed; | ||
opts.postFormat = Object.assign({}, MaskedNumber.DEFAULTS.postFormat, opts.postFormat); | ||
_update(opts) { | ||
opts.postFormat = Object.assign({}, this.postFormat, opts.postFormat); | ||
super.updateOptions(opts); | ||
super._update(opts); | ||
this._updateRegExps(); | ||
@@ -282,3 +325,3 @@ } | ||
if (this.signed) { | ||
if (this.allowNegative) { | ||
regExpStrSoft += '([+|\\-]?|([+|\\-]?(0|([1-9]+\\d*))))'; | ||
@@ -334,3 +377,2 @@ regExpStr += '[+|\\-]?'; | ||
let beforeTailPos = oldValueLength + appended - removedSeparatorsCount; | ||
this._value = this._insertThousandsSeparators(this.value); | ||
let insertedSeparatorsBeforeTailCount = 0; | ||
@@ -382,16 +424,9 @@ for (let pos = 0; pos <= beforeTailPos; ++pos) { | ||
if (validnum !== number) { | ||
this.unmaskedValue = '' + validnum; | ||
} | ||
if (validnum !== number) this.unmaskedValue = '' + validnum; | ||
let formatted = this.value; | ||
if (this.postFormat.normalizeZeros) { | ||
formatted = this._normalizeZeros(formatted); | ||
} | ||
if (this.postFormat.normalizeZeros) formatted = this._normalizeZeros(formatted); | ||
if (this.postFormat.padFractionalZeros) formatted = this._padFractionalZeros(formatted); | ||
if (this.postFormat.padFractionalZeros) { | ||
formatted = this._padFractionalZeros(formatted); | ||
} | ||
this._value = formatted; | ||
@@ -431,7 +466,7 @@ super.doCommit(); | ||
set number(number) { | ||
this.unmaskedValue = '' + number; | ||
this.unmaskedValue = ('' + number).replace('.', this.radix); | ||
} | ||
get signed() { | ||
return this._signed || this.min != null && this.min < 0 || this.max != null && this.max < 0; | ||
get allowNegative() { | ||
return this.signed || this.min != null && this.min < 0 || this.max != null && this.max < 0; | ||
} | ||
@@ -444,4 +479,6 @@ } | ||
scale: 2, | ||
signed: false, | ||
postFormat: { | ||
normalizeZeros: true | ||
normalizeZeros: true, | ||
padFractionalZeros: false | ||
} | ||
@@ -616,6 +653,12 @@ }; | ||
class MaskedPattern extends Masked { | ||
updateOptions(opts) { | ||
constructor(opts = {}) { | ||
opts.placeholder = Object.assign({}, MaskedPattern.DEFAULT_PLACEHOLDER, opts.placeholder); | ||
opts.definitions = Object.assign({}, PatternDefinition.DEFAULTS, opts.definitions); | ||
super.updateOptions(opts); | ||
super(opts); | ||
} | ||
_update(opts) { | ||
opts.placeholder = Object.assign({}, this.placeholder, opts.placeholder); | ||
opts.definitions = Object.assign({}, this.definitions, opts.definitions); | ||
super._update(opts); | ||
this._updateMask(); | ||
@@ -788,3 +831,2 @@ } | ||
// if ok - next di | ||
if (!chres) { | ||
@@ -949,3 +991,3 @@ if (!def.optional && !soft) { | ||
updateOptions(opts) { | ||
_update(opts) { | ||
if (opts.mask === Date) delete opts.mask; | ||
@@ -964,3 +1006,3 @@ if (opts.pattern) { | ||
super.updateOptions(opts); | ||
super._update(opts); | ||
} | ||
@@ -1077,4 +1119,4 @@ | ||
this._onDrop = this._onDrop.bind(this); | ||
this._alignCursor = this._alignCursor.bind(this); | ||
this._alignCursorFriendly = this._alignCursorFriendly.bind(this); | ||
this.alignCursor = this.alignCursor.bind(this); | ||
this.alignCursorFriendly = this.alignCursorFriendly.bind(this); | ||
@@ -1111,3 +1153,3 @@ this.bindEvents(); | ||
this.updateControl(); | ||
this._alignCursor(); | ||
this.alignCursor(); | ||
} | ||
@@ -1122,3 +1164,3 @@ | ||
this.updateControl(); | ||
this._alignCursor(); | ||
this.alignCursor(); | ||
} | ||
@@ -1130,3 +1172,3 @@ | ||
this.el.addEventListener('drop', this._onDrop); | ||
this.el.addEventListener('click', this._alignCursorFriendly); | ||
this.el.addEventListener('click', this.alignCursorFriendly); | ||
this.el.addEventListener('change', this._onChange); | ||
@@ -1139,3 +1181,3 @@ } | ||
this.el.removeEventListener('drop', this._onDrop); | ||
this.el.removeEventListener('click', this._alignCursorFriendly); | ||
this.el.removeEventListener('click', this.alignCursorFriendly); | ||
this.el.removeEventListener('change', this._onChange); | ||
@@ -1191,2 +1233,8 @@ } | ||
updateOptions(opts) { | ||
opts = Object.assign({}, opts); // clone | ||
if (opts.mask === Date && this.masked instanceof MaskedDate) delete opts.mask; | ||
// check if changed | ||
if (objectIncludes(this.masked, opts)) return; | ||
this.masked.updateOptions(opts); | ||
@@ -1225,9 +1273,9 @@ this.updateControl(); | ||
_alignCursor() { | ||
alignCursor() { | ||
this.cursorPos = this.masked.nearestInputPos(this.cursorPos); | ||
} | ||
_alignCursorFriendly() { | ||
alignCursorFriendly() { | ||
if (this.selectionStart !== this.cursorPos) return; | ||
this._alignCursor(); | ||
this.alignCursor(); | ||
} | ||
@@ -1234,0 +1282,0 @@ |
@@ -1,2 +0,2 @@ | ||
function isString(t){return"string"==typeof t||t instanceof String}function conform(t,e,s=""){return isString(t)?t:t?e:s}function indexInDirection(t,e){return e===DIRECTION.LEFT&&--t,t}function escapeRegExp(t){return t.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function maskedClass(t){return t instanceof RegExp?MaskedRegExp:isString(t)?IMask.MaskedPattern:t.prototype instanceof Masked?t:t instanceof Number||"number"==typeof t||t===Number?MaskedNumber:t instanceof Date||t===Date?IMask.MaskedDate:t instanceof Function?MaskedFunction:(console.warn("Mask not found for mask",t),Masked)}function createMask(t){const e=(t=Object.assign({},t)).mask;return e instanceof Masked?e:new(maskedClass(e))(t)}function EnumGroup(t){return{mask:"*".repeat(t[0].length),validate:(e,s)=>t.some(t=>t.indexOf(s.unmaskedValue)>=0)}}function IMask$1(t,e={}){return new InputMask(t,e)}var _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(t[u]=s[u])}return t},slicedToArray=function(){function t(t,e){var s=[],u=!0,i=!1,a=void 0;try{for(var n,r=t[Symbol.iterator]();!(u=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);u=!0);}catch(t){i=!0,a=t}finally{try{!u&&r.return&&r.return()}finally{if(i)throw a}}return s}return function(e,s){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();class Masked{constructor(t){this._value="",this.updateOptions(_extends({},Masked.DEFAULTS,t)),this.isInitialized=!0}updateOptions(t){this.withValueRefresh(()=>Object.assign(this,t))}clone(){const t=new Masked(this);return t._value=this.value.slice(),t}reset(){this._value=""}get value(){return this._value}set value(t){this.reset(),this.appendWithTail(t),this.doCommit()}get unmaskedValue(){return this._unmask()}set unmaskedValue(t){this.reset(),this._append(t),this.appendWithTail(""),this.doCommit()}get isComplete(){return!0}nearestInputPos(t){return t}extractInput(t=0,e=this.value.length){return this.value.slice(t,e)}extractTail(t=0,e=this.value.length){return this.extractInput(t,e)}_appendTail(t){return!t||this._append(t)}_append(t,e){const s=this.value.length;let u=this.clone();t=this.doPrepare(t,e);for(let s=0;s<t.length;++s){if(this._value+=t[s],!1===this.doValidate(e)&&(Object.assign(this,u),!e))return!1;u=this.clone()}return this.value.length-s}appendWithTail(t,e){let s,u=0,i=this.clone();for(let a=0;a<t.length;++a){const n=t[a],r=this._append(n,!0);if(s=this.clone(),!1===(!1!==r&&!1!==this._appendTail(e))||!1===this.doValidate(!0)){Object.assign(this,i);break}i=this.clone(),Object.assign(this,s),u+=r}return this._appendTail(e),u}_unmask(){return this.value}clear(t=0,e=this.value.length){this._value=this.value.slice(0,t)+this.value.slice(e)}withValueRefresh(t){if(this._refreshing)return t();this._refreshing=!0;const e=this.isInitialized?this.unmaskedValue:null,s=t();return null!=e&&(this.unmaskedValue=e),delete this._refreshing,s}doPrepare(t,e){return this.prepare(t,this,e)}doValidate(t){return this.validate(this.value,this,t)}doCommit(){this.commit(this.value,this)}}Masked.DEFAULTS={prepare:t=>t,validate:()=>!0,commit:()=>{}};const DIRECTION={NONE:0,LEFT:-1,RIGHT:1};class MaskedRegExp extends Masked{constructor(t={}){t.validate=(e=>t.mask.test(e)),super(t)}}class MaskedFunction extends Masked{constructor(t={}){t.validate=t.mask,super(t)}}class MaskedNumber extends Masked{constructor(t){super(_extends({},MaskedNumber.DEFAULTS,t))}updateOptions(t){t._signed=t.signed,delete t.signed,t.postFormat=Object.assign({},MaskedNumber.DEFAULTS.postFormat,t.postFormat),super.updateOptions(t),this._updateRegExps()}_updateRegExps(){let t="^",e="^";this.signed?(t+="([+|\\-]?|([+|\\-]?(0|([1-9]+\\d*))))",e+="[+|\\-]?"):t+="(0|([1-9]+\\d*))",e+="\\d*",this.scale&&(t+="("+this.radix+"\\d{0,"+this.scale+"})?",e+="("+this.radix+"\\d{0,"+this.scale+"})?"),t+="$",e+="$",this._numberRegExpSoft=new RegExp(t),this._numberRegExp=new RegExp(e),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(escapeRegExp).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(escapeRegExp(this.thousandsSeparator),"g")}extractTail(t=0,e=this.value.length){return this._removeThousandsSeparators(super.extractTail(t,e))}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)}doPrepare(t,e){return super.doPrepare(this._removeThousandsSeparators(t.replace(this._mapToRadixRegExp,this.radix)),e)}appendWithTail(t,e){const s=this.value.length;this._value=this._removeThousandsSeparators(this.value);let u=s-this.value.length;const i=super.appendWithTail(t,e);this._value=this._insertThousandsSeparators(this.value);let a=s+i-u;this._value=this._insertThousandsSeparators(this.value);let n=0;for(let t=0;t<=a;++t)this.value[t]===this.thousandsSeparator&&(++n,++a);return i-u+n}nearestInputPos(t,e=DIRECTION.LEFT){if(!e)return t;const s=indexInDirection(t,e);return this.value[s]===this.thousandsSeparator&&(t+=e),t}doValidate(t){let e=(t?this._numberRegExpSoft:this._numberRegExp).test(this._removeThousandsSeparators(this.value));if(e){const t=this.number;e=e&&!isNaN(t)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return e&&super.doValidate(t)}doCommit(){const t=this.number;let e=t;null!=this.min&&(e=Math.max(e,this.min)),null!=this.max&&(e=Math.min(e,this.max)),e!==t&&(this.unmaskedValue=""+e);let s=this.value;this.postFormat.normalizeZeros&&(s=this._normalizeZeros(s)),this.postFormat.padFractionalZeros&&(s=this._padFractionalZeros(s)),this._value=s,super.doCommit()}_normalizeZeros(t){const e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,(t,e,s,u)=>e+u),t.length&&!/\d$/.test(e[0])&&(e[0]=e[0]+"0"),e.length>1&&(e[1]=e[1].replace(/0*$/,""),e[1].length||(e.length=1)),this._insertThousandsSeparators(e.join(this.radix))}_padFractionalZeros(t){const e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)}get number(){let t=this._removeThousandsSeparators(this._normalizeZeros(this.unmaskedValue)).replace(this.radix,".");return Number(t)}set number(t){this.unmaskedValue=""+t}get signed(){return this._signed||null!=this.min&&this.min<0||null!=this.max&&this.max<0}}MaskedNumber.DEFAULTS={radix:",",thousandsSeparator:"",mapToRadix:["."],scale:2,postFormat:{normalizeZeros:!0}};class PatternDefinition{constructor(t){Object.assign(this,t),this.mask&&(this._masked=createMask(t))}reset(){this.isHollow=!1,this._masked&&this._masked.reset()}get isInput(){return this.type===PatternDefinition.TYPES.INPUT}get isHiddenHollow(){return this.isHollow&&this.optional}resolve(t){return!!this._masked&&(this._masked.value=t,this._masked.value)}}PatternDefinition.DEFAULTS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./},PatternDefinition.TYPES={INPUT:"input",FIXED:"fixed"};class PatternGroup{constructor(t,{name:e,offset:s,mask:u,validate:i}){this.masked=t,this.name=e,this.offset=s,this.mask=u,this.validate=i||(()=>!0)}get value(){return this.masked.value.slice(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}get unmaskedValue(){return this.masked.extractInput(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}doValidate(t){return this.validate(this.value,this,t)}}class RangeGroup{constructor([t,e],s=(e+"").length){this._from=t,this._to=e,this._maxLength=s,this.validate=this.validate.bind(this),this._update()}get to(){return this._to}set to(t){this._to=t,this._update()}get from(){return this._from}set from(t){this._from=t,this._update()}get maxLength(){return this._maxLength}set maxLength(t){this._maxLength=t,this._update()}get _matchFrom(){return this.maxLength-(this.from+"").length}_update(){this._maxLength=Math.max(this._maxLength,(this.to+"").length),this.mask="0".repeat(this._maxLength)}validate(t){let e="",s="";var u=t.match(/^(\D*)(\d*)(\D*)/),i=slicedToArray(u,3);const a=i[1],n=i[2];return n&&(e="0".repeat(a.length)+n,s="9".repeat(a.length)+n),-1===t.search(/[^0]/)&&t.length<=this._matchFrom||(e=e.padEnd(this._maxLength,"0"),s=s.padEnd(this._maxLength,"9"),this.from<=Number(s)&&Number(e)<=this.to)}}PatternGroup.Range=RangeGroup,PatternGroup.Enum=EnumGroup;class MaskedPattern extends Masked{updateOptions(t){t.placeholder=Object.assign({},MaskedPattern.DEFAULT_PLACEHOLDER,t.placeholder),t.definitions=Object.assign({},PatternDefinition.DEFAULTS,t.definitions),super.updateOptions(t),this._updateMask()}_updateMask(){const t=this.definitions;this._charDefs=[],this._groupDefs=[];let e=this.mask;if(!e||!t)return;let s=!1,u=!1,i=!1;for(let a=0;a<e.length;++a){if(this.groups){const t=e.slice(a),s=Object.keys(this.groups).filter(e=>0===t.indexOf(e));s.sort((t,e)=>e.length-t.length);const u=s[0];if(u){const t=this.groups[u];this._groupDefs.push(new PatternGroup(this,{name:u,offset:this._charDefs.length,mask:t.mask,validate:t.validate})),e=e.replace(u,t.mask)}}let n=e[a],r=!s&&n in t?PatternDefinition.TYPES.INPUT:PatternDefinition.TYPES.FIXED;const h=r===PatternDefinition.TYPES.INPUT||s,o=r===PatternDefinition.TYPES.INPUT&&u;if(n!==MaskedPattern.STOP_CHAR)if("{"!==n&&"}"!==n)if("["!==n&&"]"!==n){if(n===MaskedPattern.ESCAPE_CHAR){if(++a,!(n=e[a]))break;r=PatternDefinition.TYPES.FIXED}this._charDefs.push(new PatternDefinition({char:n,type:r,optional:o,stopAlign:i,unmasking:h,mask:r===PatternDefinition.TYPES.INPUT?t[n]:t=>t===n})),i=!1}else u=!u;else s=!s;else i=!0}}doValidate(t){return this._groupDefs.every(e=>e.doValidate(t))&&super.doValidate(t)}clone(){const t=new MaskedPattern(this);return t._value=this.value,t._charDefs.forEach((t,e)=>Object.assign(t,this._charDefs[e])),t._groupDefs.forEach((t,e)=>Object.assign(t,this._groupDefs[e])),t}reset(){super.reset(),this._charDefs.forEach(t=>{delete t.isHollow})}get isComplete(){return!this._charDefs.some((t,e)=>t.isInput&&!t.optional&&(t.isHollow||!this.extractInput(e,e+1)))}hiddenHollowsBefore(t){return this._charDefs.slice(0,t).filter(t=>t.isHiddenHollow).length}mapDefIndexToPos(t){if(null!=t)return t-this.hiddenHollowsBefore(t)}mapPosToDefIndex(t){if(null==t)return;let e=t;for(let t=0;t<this._charDefs.length;++t){const s=this._charDefs[t];if(t>=e)break;s.isHiddenHollow&&++e}return e}_unmask(){const t=this.value;let e="";for(let s=0,u=0;s<t.length&&u<this._charDefs.length;++u){const i=t[s],a=this._charDefs[u];a.isHiddenHollow||(a.unmasking&&!a.isHollow&&(e+=i),++s)}return e}_appendTail(t){return(!t||this._appendChunks(t))&&this._appendPlaceholder()}_append(t,e){const s=this.value.length;for(let s=0,u=this.mapPosToDefIndex(this.value.length);s<t.length;){const i=t[s],a=this._charDefs[u];if(!a)return!1;a.isHollow=!1;let n,r,h=conform(a.resolve(i),i);a.type===PatternDefinition.TYPES.INPUT?(h&&(this._value+=h,this.doValidate()||(h="",this._value=this.value.slice(0,-1))),n=!!h,r=!h&&!a.optional,h||(a.optional||e||(this._value+=this.placeholder.char,r=!1),r||(a.isHollow=!0))):(this._value+=a.char,n=h&&(a.unmasking||e)),r||++u,(n||r)&&++s}return this.value.length-s}_appendChunks(t,e){for(let u=0;u<t.length;++u){var s=slicedToArray(t[u],2);const i=s[0],a=s[1];if(null!=i&&this._appendPlaceholder(i),!1===this._append(a,e))return!1}return!0}extractTail(t,e){return this.extractInputChunks(t,e)}extractInput(t=0,e=this.value.length){const s=this.value;let u="";const i=this.mapPosToDefIndex(e);for(let a=t,n=this.mapPosToDefIndex(t);a<e&&a<s.length&&n<i;++n){const t=s[a],e=this._charDefs[n];if(!e)break;e.isHiddenHollow||(e.isInput&&!e.isHollow&&(u+=t),++a)}return u}extractInputChunks(t=0,e=this.value.length){const s=this.mapPosToDefIndex(t),u=this.mapPosToDefIndex(e),i=this._charDefs.map((t,e)=>[t,e]).slice(s,u).filter(([t])=>t.stopAlign).map(([,t])=>t),a=[s,...i,u];return a.map((t,e)=>[i.indexOf(t)>=0?t:null,this.extractInput(this.mapDefIndexToPos(t),this.mapDefIndexToPos(a[++e]))]).filter(([t,e])=>null!=t||e)}_appendPlaceholder(t){const e=t||this._charDefs.length;for(let s=this.mapPosToDefIndex(this.value.length);s<e;++s){const e=this._charDefs[s];e.isInput&&(e.isHollow=!0),this.placeholder.lazy&&!t||(this._value+=e.isInput?e.optional?"":this.placeholder.char:e.char)}}clear(t=0,e=this.value.length){this._value=this.value.slice(0,t)+this.value.slice(e);const s=this.mapPosToDefIndex(t),u=this.mapPosToDefIndex(e);this._charDefs.slice(s,u).forEach(t=>t.reset())}nearestInputPos(t,e=DIRECTION.LEFT){if(!e)return t;const s=this.mapPosToDefIndex(t);let u,i,a,n,r=s;for(n=indexInDirection(r,e);0<=n&&n<this._charDefs.length;r+=e,n+=e){const t=this._charDefs[n];if(null==u&&t.isInput&&(u=r),null==a&&t.isHollow&&!t.isHiddenHollow&&(a=r),t.isInput&&!t.isHollow){i=r;break}}if(e===DIRECTION.LEFT||null==u){let t=!1;for(n=indexInDirection(r,e=-e);0<=n&&n<this._charDefs.length;r+=e,n+=e){const e=this._charDefs[n];if(e.isInput&&(u=r,e.isHollow&&!e.isHiddenHollow))break;if(r===s&&(t=!0),t&&null!=u)break}(t=t||n>=this._charDefs.length)&&null!=u&&(r=u)}else null==i&&(r=null!=a?a:u);return this.mapDefIndexToPos(r)}group(t){return this.groupsByName(t)[0]}groupsByName(t){return this._groupDefs.filter(e=>e.name===t)}}MaskedPattern.DEFAULT_PLACEHOLDER={lazy:!0,char:"_"},MaskedPattern.STOP_CHAR="`",MaskedPattern.ESCAPE_CHAR="\\",MaskedPattern.Definition=PatternDefinition,MaskedPattern.Group=PatternGroup;class MaskedDate extends MaskedPattern{constructor(t){super(_extends({},MaskedDate.DEFAULTS,t))}updateOptions(t){t.mask===Date&&delete t.mask,t.pattern&&(t.mask=t.pattern,delete t.pattern);const e=t.groups;t.groups=Object.assign({},MaskedDate.GET_DEFAULT_GROUPS()),t.min&&(t.groups.Y.from=t.min.getFullYear()),t.max&&(t.groups.Y.to=t.max.getFullYear()),Object.assign(t.groups,e),super.updateOptions(t)}doValidate(t){const e=super.doValidate(t),s=this.date;return e&&(!this.isComplete||this.isDateExist(this.value)&&s&&(null==this.min||this.min<=s)&&(null==this.max||s<=this.max))}isDateExist(t){return this.format(this.parse(t))===t}get date(){return this.isComplete?this.parse(this.value):null}set date(t){this.value=this.format(t)}}MaskedDate.DEFAULTS={pattern:"d{.}`m{.}`Y",format:t=>[(""+t.getDate()).padStart(2,"0"),(""+(t.getMonth()+1)).padStart(2,"0"),t.getFullYear()].join("."),parse:t=>{var e=t.split("."),s=slicedToArray(e,3);const u=s[0],i=s[1],a=s[2];return new Date(a,i-1,u)}},MaskedDate.GET_DEFAULT_GROUPS=(()=>({d:new PatternGroup.Range([1,31]),m:new PatternGroup.Range([1,12]),Y:new PatternGroup.Range([1900,9999])}));class ActionDetails{constructor(t,e,s,u){for(this.value=t,this.cursorPos=e,this.oldValue=s,this.oldSelection=u;this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return this.removedCount&&!this.insertedCount&&(this.oldSelection.end===this.cursorPos?DIRECTION.RIGHT:DIRECTION.LEFT)}}class InputMask{constructor(t,e){this.el=t,this.masked=createMask(e),this._listeners={},this._value="",this._unmaskedValue="",this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._alignCursor=this._alignCursor.bind(this),this._alignCursorFriendly=this._alignCursorFriendly.bind(this),this.bindEvents(),this.updateValue(),this._onChange()}get mask(){return this.masked.mask}set mask(t){if(null==t||t===this.masked.mask)return;if(this.masked.constructor===maskedClass(t))return void(this.masked.mask=t);const e=createMask({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}get value(){return this._value}set value(t){this.masked.value=t,this.updateControl(),this._alignCursor()}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.masked.unmaskedValue=t,this.updateControl(),this._alignCursor()}bindEvents(){this.el.addEventListener("keydown",this._saveSelection),this.el.addEventListener("input",this._onInput),this.el.addEventListener("drop",this._onDrop),this.el.addEventListener("click",this._alignCursorFriendly),this.el.addEventListener("change",this._onChange)}unbindEvents(){this.el.removeEventListener("keydown",this._saveSelection),this.el.removeEventListener("input",this._onInput),this.el.removeEventListener("drop",this._onDrop),this.el.removeEventListener("click",this._alignCursorFriendly),this.el.removeEventListener("change",this._onChange)}fireEvent(t){(this._listeners[t]||[]).forEach(t=>t())}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){this.el===document.activeElement&&(this.el.setSelectionRange(t,t),this._saveSelection())}_saveSelection(){this.value!==this.el.value&&console.warn("Uncontrolled input change, refresh mask manually!"),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value}updateControl(){const t=this.masked.unmaskedValue,e=this.masked.value,s=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==e&&(this.el.value=e),s&&this._fireChangeEvents()}updateOptions(t){this.masked.updateOptions(t),this.updateControl()}updateCursor(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(()=>{this.cursorPos=this._changingCursorPos,this._abortUpdateCursor()},10)}_fireChangeEvents(){this.fireEvent("accept"),this.masked.isComplete&&this.fireEvent("complete")}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}_alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.cursorPos)}_alignCursorFriendly(){this.selectionStart===this.cursorPos&&this._alignCursor()}on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}off(t,e){if(!this._listeners[t])return;if(!e)return void delete this._listeners[t];const s=this._listeners[t].indexOf(e);return s>=0&&this._listeners.splice(s,1),this}_onInput(){this._abortUpdateCursor();const t=new ActionDetails(this.el.value,this.cursorPos,this.value,this._selection),e=t.startChangePos+t.removed.length,s=this.masked.extractTail(e),u=this.masked.nearestInputPos(t.startChangePos,t.removeDirection);this.masked.clear(u);const i=this.masked.appendWithTail(t.inserted,s),a=this.masked.nearestInputPos(u+i,t.removeDirection);this.updateControl(),this.updateCursor(a)}_onChange(){this.value!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl()}_onDrop(t){t.preventDefault(),t.stopPropagation()}destroy(){this.unbindEvents(),this._listeners.length=0}}IMask$1.InputMask=InputMask,IMask$1.Masked=Masked,IMask$1.MaskedPattern=MaskedPattern,IMask$1.MaskedNumber=MaskedNumber,IMask$1.MaskedDate=MaskedDate,IMask$1.MaskedRegExp=MaskedRegExp,IMask$1.MaskedFunction=MaskedFunction,window.IMask=IMask$1;export default IMask$1; | ||
function isString(t){return"string"==typeof t||t instanceof String}function conform(t,e,s=""){return isString(t)?t:t?e:s}function indexInDirection(t,e){return e===DIRECTION.LEFT&&--t,t}function escapeRegExp(t){return t.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function objectIncludes(t,e){if(e===t)return!0;var s,u=Array.isArray(e),i=Array.isArray(t);if(u&&i){if(e.length!=t.length)return!1;for(s=0;s<e.length;s++)if(!objectIncludes(e[s],t[s]))return!1;return!0}if(u!=i)return!1;if(e&&t&&"object"==typeof e&&"object"==typeof t){var a=Object.keys(e),n=e instanceof Date,r=t instanceof Date;if(n&&r)return e.getTime()==t.getTime();if(n!=r)return!1;var o=e instanceof RegExp,h=t instanceof RegExp;if(o&&h)return e.toString()==t.toString();if(o!=h)return!1;for(s=0;s<a.length;s++)if(!Object.prototype.hasOwnProperty.call(t,a[s]))return!1;for(s=0;s<a.length;s++)if(!objectIncludes(e[a[s]],t[a[s]]))return!1;return!0}return!1}function maskedClass(t){return t instanceof RegExp?MaskedRegExp:isString(t)?IMask.MaskedPattern:t.prototype instanceof Masked?t:t instanceof Number||"number"==typeof t||t===Number?MaskedNumber:t instanceof Date||t===Date?IMask.MaskedDate:t instanceof Function?MaskedFunction:(console.warn("Mask not found for mask",t),Masked)}function createMask(t){const e=(t=Object.assign({},t)).mask;return e instanceof Masked?e:new(maskedClass(e))(t)}function EnumGroup(t){return{mask:"*".repeat(t[0].length),validate:(e,s)=>t.some(t=>t.indexOf(s.unmaskedValue)>=0)}}function IMask$1(t,e={}){return new InputMask(t,e)}var _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(t[u]=s[u])}return t},slicedToArray=function(){function t(t,e){var s=[],u=!0,i=!1,a=void 0;try{for(var n,r=t[Symbol.iterator]();!(u=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);u=!0);}catch(t){i=!0,a=t}finally{try{!u&&r.return&&r.return()}finally{if(i)throw a}}return s}return function(e,s){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();class Masked{constructor(t){this._value="",this._update(_extends({},Masked.DEFAULTS,t)),this.isInitialized=!0}updateOptions(t){this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}clone(){const t=new Masked(this);return t._value=this.value.slice(),t}reset(){this._value=""}get value(){return this._value}set value(t){this.reset(),this.appendWithTail(t),this.doCommit()}get unmaskedValue(){return this._unmask()}set unmaskedValue(t){this.reset(),this._append(t),this.appendWithTail(""),this.doCommit()}get isComplete(){return!0}nearestInputPos(t){return t}extractInput(t=0,e=this.value.length){return this.value.slice(t,e)}extractTail(t=0,e=this.value.length){return this.extractInput(t,e)}_appendTail(t){return!t||this._append(t)}_append(t,e){const s=this.value.length;let u=this.clone();t=this.doPrepare(t,e);for(let s=0;s<t.length;++s){if(this._value+=t[s],!1===this.doValidate(e)&&(Object.assign(this,u),!e))return!1;u=this.clone()}return this.value.length-s}appendWithTail(t,e){let s,u=0,i=this.clone();for(let a=0;a<t.length;++a){const n=t[a],r=this._append(n,!0);if(s=this.clone(),!1===(!1!==r&&!1!==this._appendTail(e))||!1===this.doValidate(!0)){Object.assign(this,i);break}i=this.clone(),Object.assign(this,s),u+=r}return this._appendTail(e),u}_unmask(){return this.value}clear(t=0,e=this.value.length){this._value=this.value.slice(0,t)+this.value.slice(e)}withValueRefresh(t){if(this._refreshing||!this.isInitialized)return t();this._refreshing=!0;const e=this.unmaskedValue,s=t();return this.unmaskedValue=e,delete this._refreshing,s}doPrepare(t,e){return this.prepare(t,this,e)}doValidate(t){return this.validate(this.value,this,t)}doCommit(){this.commit(this.value,this)}}Masked.DEFAULTS={prepare:t=>t,validate:()=>!0,commit:()=>{}};const DIRECTION={NONE:0,LEFT:-1,RIGHT:1};class MaskedRegExp extends Masked{constructor(t={}){t.validate=(e=>e.search(t.mask)>=0),super(t)}}class MaskedFunction extends Masked{constructor(t={}){t.validate=t.mask,super(t)}}class MaskedNumber extends Masked{constructor(t){t.postFormat=Object.assign({},MaskedNumber.DEFAULTS.postFormat,t.postFormat),super(_extends({},MaskedNumber.DEFAULTS,t))}_update(t){t.postFormat=Object.assign({},this.postFormat,t.postFormat),super._update(t),this._updateRegExps()}_updateRegExps(){let t="^",e="^";this.allowNegative?(t+="([+|\\-]?|([+|\\-]?(0|([1-9]+\\d*))))",e+="[+|\\-]?"):t+="(0|([1-9]+\\d*))",e+="\\d*",this.scale&&(t+="("+this.radix+"\\d{0,"+this.scale+"})?",e+="("+this.radix+"\\d{0,"+this.scale+"})?"),t+="$",e+="$",this._numberRegExpSoft=new RegExp(t),this._numberRegExp=new RegExp(e),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(escapeRegExp).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(escapeRegExp(this.thousandsSeparator),"g")}extractTail(t=0,e=this.value.length){return this._removeThousandsSeparators(super.extractTail(t,e))}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)}doPrepare(t,e){return super.doPrepare(this._removeThousandsSeparators(t.replace(this._mapToRadixRegExp,this.radix)),e)}appendWithTail(t,e){const s=this.value.length;this._value=this._removeThousandsSeparators(this.value);let u=s-this.value.length;const i=super.appendWithTail(t,e);this._value=this._insertThousandsSeparators(this.value);let a=s+i-u,n=0;for(let t=0;t<=a;++t)this.value[t]===this.thousandsSeparator&&(++n,++a);return i-u+n}nearestInputPos(t,e=DIRECTION.LEFT){if(!e)return t;const s=indexInDirection(t,e);return this.value[s]===this.thousandsSeparator&&(t+=e),t}doValidate(t){let e=(t?this._numberRegExpSoft:this._numberRegExp).test(this._removeThousandsSeparators(this.value));if(e){const t=this.number;e=e&&!isNaN(t)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return e&&super.doValidate(t)}doCommit(){const t=this.number;let e=t;null!=this.min&&(e=Math.max(e,this.min)),null!=this.max&&(e=Math.min(e,this.max)),e!==t&&(this.unmaskedValue=""+e);let s=this.value;this.postFormat.normalizeZeros&&(s=this._normalizeZeros(s)),this.postFormat.padFractionalZeros&&(s=this._padFractionalZeros(s)),this._value=s,super.doCommit()}_normalizeZeros(t){const e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,(t,e,s,u)=>e+u),t.length&&!/\d$/.test(e[0])&&(e[0]=e[0]+"0"),e.length>1&&(e[1]=e[1].replace(/0*$/,""),e[1].length||(e.length=1)),this._insertThousandsSeparators(e.join(this.radix))}_padFractionalZeros(t){const e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)}get number(){let t=this._removeThousandsSeparators(this._normalizeZeros(this.unmaskedValue)).replace(this.radix,".");return Number(t)}set number(t){this.unmaskedValue=(""+t).replace(".",this.radix)}get allowNegative(){return this.signed||null!=this.min&&this.min<0||null!=this.max&&this.max<0}}MaskedNumber.DEFAULTS={radix:",",thousandsSeparator:"",mapToRadix:["."],scale:2,signed:!1,postFormat:{normalizeZeros:!0,padFractionalZeros:!1}};class PatternDefinition{constructor(t){Object.assign(this,t),this.mask&&(this._masked=createMask(t))}reset(){this.isHollow=!1,this._masked&&this._masked.reset()}get isInput(){return this.type===PatternDefinition.TYPES.INPUT}get isHiddenHollow(){return this.isHollow&&this.optional}resolve(t){return!!this._masked&&(this._masked.value=t,this._masked.value)}}PatternDefinition.DEFAULTS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./},PatternDefinition.TYPES={INPUT:"input",FIXED:"fixed"};class PatternGroup{constructor(t,{name:e,offset:s,mask:u,validate:i}){this.masked=t,this.name=e,this.offset=s,this.mask=u,this.validate=i||(()=>!0)}get value(){return this.masked.value.slice(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}get unmaskedValue(){return this.masked.extractInput(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}doValidate(t){return this.validate(this.value,this,t)}}class RangeGroup{constructor([t,e],s=(e+"").length){this._from=t,this._to=e,this._maxLength=s,this.validate=this.validate.bind(this),this._update()}get to(){return this._to}set to(t){this._to=t,this._update()}get from(){return this._from}set from(t){this._from=t,this._update()}get maxLength(){return this._maxLength}set maxLength(t){this._maxLength=t,this._update()}get _matchFrom(){return this.maxLength-(this.from+"").length}_update(){this._maxLength=Math.max(this._maxLength,(this.to+"").length),this.mask="0".repeat(this._maxLength)}validate(t){let e="",s="";var u=t.match(/^(\D*)(\d*)(\D*)/),i=slicedToArray(u,3);const a=i[1],n=i[2];return n&&(e="0".repeat(a.length)+n,s="9".repeat(a.length)+n),-1===t.search(/[^0]/)&&t.length<=this._matchFrom||(e=e.padEnd(this._maxLength,"0"),s=s.padEnd(this._maxLength,"9"),this.from<=Number(s)&&Number(e)<=this.to)}}PatternGroup.Range=RangeGroup,PatternGroup.Enum=EnumGroup;class MaskedPattern extends Masked{constructor(t={}){t.placeholder=Object.assign({},MaskedPattern.DEFAULT_PLACEHOLDER,t.placeholder),t.definitions=Object.assign({},PatternDefinition.DEFAULTS,t.definitions),super(t)}_update(t){t.placeholder=Object.assign({},this.placeholder,t.placeholder),t.definitions=Object.assign({},this.definitions,t.definitions),super._update(t),this._updateMask()}_updateMask(){const t=this.definitions;this._charDefs=[],this._groupDefs=[];let e=this.mask;if(!e||!t)return;let s=!1,u=!1,i=!1;for(let a=0;a<e.length;++a){if(this.groups){const t=e.slice(a),s=Object.keys(this.groups).filter(e=>0===t.indexOf(e));s.sort((t,e)=>e.length-t.length);const u=s[0];if(u){const t=this.groups[u];this._groupDefs.push(new PatternGroup(this,{name:u,offset:this._charDefs.length,mask:t.mask,validate:t.validate})),e=e.replace(u,t.mask)}}let n=e[a],r=!s&&n in t?PatternDefinition.TYPES.INPUT:PatternDefinition.TYPES.FIXED;const o=r===PatternDefinition.TYPES.INPUT||s,h=r===PatternDefinition.TYPES.INPUT&&u;if(n!==MaskedPattern.STOP_CHAR)if("{"!==n&&"}"!==n)if("["!==n&&"]"!==n){if(n===MaskedPattern.ESCAPE_CHAR){if(++a,!(n=e[a]))break;r=PatternDefinition.TYPES.FIXED}this._charDefs.push(new PatternDefinition({char:n,type:r,optional:h,stopAlign:i,unmasking:o,mask:r===PatternDefinition.TYPES.INPUT?t[n]:t=>t===n})),i=!1}else u=!u;else s=!s;else i=!0}}doValidate(t){return this._groupDefs.every(e=>e.doValidate(t))&&super.doValidate(t)}clone(){const t=new MaskedPattern(this);return t._value=this.value,t._charDefs.forEach((t,e)=>Object.assign(t,this._charDefs[e])),t._groupDefs.forEach((t,e)=>Object.assign(t,this._groupDefs[e])),t}reset(){super.reset(),this._charDefs.forEach(t=>{delete t.isHollow})}get isComplete(){return!this._charDefs.some((t,e)=>t.isInput&&!t.optional&&(t.isHollow||!this.extractInput(e,e+1)))}hiddenHollowsBefore(t){return this._charDefs.slice(0,t).filter(t=>t.isHiddenHollow).length}mapDefIndexToPos(t){if(null!=t)return t-this.hiddenHollowsBefore(t)}mapPosToDefIndex(t){if(null==t)return;let e=t;for(let t=0;t<this._charDefs.length;++t){const s=this._charDefs[t];if(t>=e)break;s.isHiddenHollow&&++e}return e}_unmask(){const t=this.value;let e="";for(let s=0,u=0;s<t.length&&u<this._charDefs.length;++u){const i=t[s],a=this._charDefs[u];a.isHiddenHollow||(a.unmasking&&!a.isHollow&&(e+=i),++s)}return e}_appendTail(t){return(!t||this._appendChunks(t))&&this._appendPlaceholder()}_append(t,e){const s=this.value.length;for(let s=0,u=this.mapPosToDefIndex(this.value.length);s<t.length;){const i=t[s],a=this._charDefs[u];if(!a)return!1;a.isHollow=!1;let n,r,o=conform(a.resolve(i),i);a.type===PatternDefinition.TYPES.INPUT?(o&&(this._value+=o,this.doValidate()||(o="",this._value=this.value.slice(0,-1))),n=!!o,r=!o&&!a.optional,o||(a.optional||e||(this._value+=this.placeholder.char,r=!1),r||(a.isHollow=!0))):(this._value+=a.char,n=o&&(a.unmasking||e)),r||++u,(n||r)&&++s}return this.value.length-s}_appendChunks(t,e){for(let u=0;u<t.length;++u){var s=slicedToArray(t[u],2);const i=s[0],a=s[1];if(null!=i&&this._appendPlaceholder(i),!1===this._append(a,e))return!1}return!0}extractTail(t,e){return this.extractInputChunks(t,e)}extractInput(t=0,e=this.value.length){const s=this.value;let u="";const i=this.mapPosToDefIndex(e);for(let a=t,n=this.mapPosToDefIndex(t);a<e&&a<s.length&&n<i;++n){const t=s[a],e=this._charDefs[n];if(!e)break;e.isHiddenHollow||(e.isInput&&!e.isHollow&&(u+=t),++a)}return u}extractInputChunks(t=0,e=this.value.length){const s=this.mapPosToDefIndex(t),u=this.mapPosToDefIndex(e),i=this._charDefs.map((t,e)=>[t,e]).slice(s,u).filter(([t])=>t.stopAlign).map(([,t])=>t),a=[s,...i,u];return a.map((t,e)=>[i.indexOf(t)>=0?t:null,this.extractInput(this.mapDefIndexToPos(t),this.mapDefIndexToPos(a[++e]))]).filter(([t,e])=>null!=t||e)}_appendPlaceholder(t){const e=t||this._charDefs.length;for(let s=this.mapPosToDefIndex(this.value.length);s<e;++s){const e=this._charDefs[s];e.isInput&&(e.isHollow=!0),this.placeholder.lazy&&!t||(this._value+=e.isInput?e.optional?"":this.placeholder.char:e.char)}}clear(t=0,e=this.value.length){this._value=this.value.slice(0,t)+this.value.slice(e);const s=this.mapPosToDefIndex(t),u=this.mapPosToDefIndex(e);this._charDefs.slice(s,u).forEach(t=>t.reset())}nearestInputPos(t,e=DIRECTION.LEFT){if(!e)return t;const s=this.mapPosToDefIndex(t);let u,i,a,n,r=s;for(n=indexInDirection(r,e);0<=n&&n<this._charDefs.length;r+=e,n+=e){const t=this._charDefs[n];if(null==u&&t.isInput&&(u=r),null==a&&t.isHollow&&!t.isHiddenHollow&&(a=r),t.isInput&&!t.isHollow){i=r;break}}if(e===DIRECTION.LEFT||null==u){let t=!1;for(n=indexInDirection(r,e=-e);0<=n&&n<this._charDefs.length;r+=e,n+=e){const e=this._charDefs[n];if(e.isInput&&(u=r,e.isHollow&&!e.isHiddenHollow))break;if(r===s&&(t=!0),t&&null!=u)break}(t=t||n>=this._charDefs.length)&&null!=u&&(r=u)}else null==i&&(r=null!=a?a:u);return this.mapDefIndexToPos(r)}group(t){return this.groupsByName(t)[0]}groupsByName(t){return this._groupDefs.filter(e=>e.name===t)}}MaskedPattern.DEFAULT_PLACEHOLDER={lazy:!0,char:"_"},MaskedPattern.STOP_CHAR="`",MaskedPattern.ESCAPE_CHAR="\\",MaskedPattern.Definition=PatternDefinition,MaskedPattern.Group=PatternGroup;class MaskedDate extends MaskedPattern{constructor(t){super(_extends({},MaskedDate.DEFAULTS,t))}_update(t){t.mask===Date&&delete t.mask,t.pattern&&(t.mask=t.pattern,delete t.pattern);const e=t.groups;t.groups=Object.assign({},MaskedDate.GET_DEFAULT_GROUPS()),t.min&&(t.groups.Y.from=t.min.getFullYear()),t.max&&(t.groups.Y.to=t.max.getFullYear()),Object.assign(t.groups,e),super._update(t)}doValidate(t){const e=super.doValidate(t),s=this.date;return e&&(!this.isComplete||this.isDateExist(this.value)&&s&&(null==this.min||this.min<=s)&&(null==this.max||s<=this.max))}isDateExist(t){return this.format(this.parse(t))===t}get date(){return this.isComplete?this.parse(this.value):null}set date(t){this.value=this.format(t)}}MaskedDate.DEFAULTS={pattern:"d{.}`m{.}`Y",format:t=>[(""+t.getDate()).padStart(2,"0"),(""+(t.getMonth()+1)).padStart(2,"0"),t.getFullYear()].join("."),parse:t=>{var e=t.split("."),s=slicedToArray(e,3);const u=s[0],i=s[1],a=s[2];return new Date(a,i-1,u)}},MaskedDate.GET_DEFAULT_GROUPS=(()=>({d:new PatternGroup.Range([1,31]),m:new PatternGroup.Range([1,12]),Y:new PatternGroup.Range([1900,9999])}));class ActionDetails{constructor(t,e,s,u){for(this.value=t,this.cursorPos=e,this.oldValue=s,this.oldSelection=u;this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return this.removedCount&&!this.insertedCount&&(this.oldSelection.end===this.cursorPos?DIRECTION.RIGHT:DIRECTION.LEFT)}}class InputMask{constructor(t,e){this.el=t,this.masked=createMask(e),this._listeners={},this._value="",this._unmaskedValue="",this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this.bindEvents(),this.updateValue(),this._onChange()}get mask(){return this.masked.mask}set mask(t){if(null==t||t===this.masked.mask)return;if(this.masked.constructor===maskedClass(t))return void(this.masked.mask=t);const e=createMask({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}get value(){return this._value}set value(t){this.masked.value=t,this.updateControl(),this.alignCursor()}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.masked.unmaskedValue=t,this.updateControl(),this.alignCursor()}bindEvents(){this.el.addEventListener("keydown",this._saveSelection),this.el.addEventListener("input",this._onInput),this.el.addEventListener("drop",this._onDrop),this.el.addEventListener("click",this.alignCursorFriendly),this.el.addEventListener("change",this._onChange)}unbindEvents(){this.el.removeEventListener("keydown",this._saveSelection),this.el.removeEventListener("input",this._onInput),this.el.removeEventListener("drop",this._onDrop),this.el.removeEventListener("click",this.alignCursorFriendly),this.el.removeEventListener("change",this._onChange)}fireEvent(t){(this._listeners[t]||[]).forEach(t=>t())}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){this.el===document.activeElement&&(this.el.setSelectionRange(t,t),this._saveSelection())}_saveSelection(){this.value!==this.el.value&&console.warn("Uncontrolled input change, refresh mask manually!"),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value}updateControl(){const t=this.masked.unmaskedValue,e=this.masked.value,s=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==e&&(this.el.value=e),s&&this._fireChangeEvents()}updateOptions(t){(t=Object.assign({},t)).mask===Date&&this.masked instanceof MaskedDate&&delete t.mask,objectIncludes(this.masked,t)||(this.masked.updateOptions(t),this.updateControl())}updateCursor(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(()=>{this.cursorPos=this._changingCursorPos,this._abortUpdateCursor()},10)}_fireChangeEvents(){this.fireEvent("accept"),this.masked.isComplete&&this.fireEvent("complete")}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.cursorPos)}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}off(t,e){if(!this._listeners[t])return;if(!e)return void delete this._listeners[t];const s=this._listeners[t].indexOf(e);return s>=0&&this._listeners.splice(s,1),this}_onInput(){this._abortUpdateCursor();const t=new ActionDetails(this.el.value,this.cursorPos,this.value,this._selection),e=t.startChangePos+t.removed.length,s=this.masked.extractTail(e),u=this.masked.nearestInputPos(t.startChangePos,t.removeDirection);this.masked.clear(u);const i=this.masked.appendWithTail(t.inserted,s),a=this.masked.nearestInputPos(u+i,t.removeDirection);this.updateControl(),this.updateCursor(a)}_onChange(){this.value!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl()}_onDrop(t){t.preventDefault(),t.stopPropagation()}destroy(){this.unbindEvents(),this._listeners.length=0}}IMask$1.InputMask=InputMask,IMask$1.Masked=Masked,IMask$1.MaskedPattern=MaskedPattern,IMask$1.MaskedNumber=MaskedNumber,IMask$1.MaskedDate=MaskedDate,IMask$1.MaskedRegExp=MaskedRegExp,IMask$1.MaskedFunction=MaskedFunction,window.IMask=IMask$1;export default IMask$1; | ||
//# sourceMappingURL=imask.es.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.IMask=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t){return"string"==typeof t||t instanceof String}function u(t,u){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return e(t)?t:t?u:n}function n(t,e){return e===at.LEFT&&--t,t}function i(t){return t.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function r(t){return t instanceof RegExp?ht:e(t)?IMask.MaskedPattern:t.prototype instanceof st?t:t instanceof Number||"number"==typeof t||t===Number?ct:t instanceof Date||t===Date?IMask.MaskedDate:t instanceof Function?lt:(console.warn("Mask not found for mask",t),st)}function o(t){var e=(t=it({},t)).mask;return e instanceof st?e:new(r(e))(t)}function s(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new gt(t,e)}var a=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t},h=function(t){return Object(a(t))},l={}.hasOwnProperty,c=function(t,e){return l.call(t,e)},p={}.toString,f=function(t){return p.call(t).slice(8,-1)},d=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==f(t)?t.split(""):Object(t)},v=function(t){return d(a(t))},A=Math.ceil,m=Math.floor,g=function(t){return isNaN(t=+t)?0:(t>0?m:A)(t)},F=Math.min,_=function(t){return t>0?F(g(t),9007199254740991):0},D=Math.max,C=Math.min,E=function(t,e){return(t=g(t))<0?D(t+e,0):C(t,e)},y=t(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),B=y["__core-js_shared__"]||(y["__core-js_shared__"]={}),k=0,x=Math.random(),P=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++k+x).toString(36))},T=function(t){return B[t]||(B[t]={})}("keys"),b=function(t){return function(e,u,n){var i,r=v(e),o=_(r.length),s=E(n,o);if(t&&u!=u){for(;o>s;)if((i=r[s++])!=i)return!0}else for(;o>s;s++)if((t||s in r)&&r[s]===u)return t||s||0;return!t&&-1}}(!1),S=function(t){return T[t]||(T[t]=P(t))}("IE_PROTO"),w=function(t,e){var u,n=v(t),i=0,r=[];for(u in n)u!=S&&c(n,u)&&r.push(u);for(;e.length>i;)c(n,u=e[i++])&&(~b(r,u)||r.push(u));return r},I="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),O=Object.keys||function(t){return w(t,I)},L=t(function(t){var e=t.exports={version:"2.5.1"};"number"==typeof __e&&(__e=e)}),R=function(t){return"object"==typeof t?null!==t:"function"==typeof t},V=function(t){if(!R(t))throw TypeError(t+" is not an object!");return t},H=function(t){try{return!!t()}catch(t){return!0}},j=!H(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),M=y.document,U=R(M)&&R(M.createElement),N=function(t){return U?M.createElement(t):{}},Y=!j&&!H(function(){return 7!=Object.defineProperty(N("div"),"a",{get:function(){return 7}}).a}),z=function(t,e){if(!R(t))return t;var u,n;if(e&&"function"==typeof(u=t.toString)&&!R(n=u.call(t)))return n;if("function"==typeof(u=t.valueOf)&&!R(n=u.call(t)))return n;if(!e&&"function"==typeof(u=t.toString)&&!R(n=u.call(t)))return n;throw TypeError("Can't convert object to primitive value")},G=Object.defineProperty,Z={f:j?Object.defineProperty:function(t,e,u){if(V(t),e=z(e,!0),V(u),Y)try{return G(t,e,u)}catch(t){}if("get"in u||"set"in u)throw TypeError("Accessors not supported!");return"value"in u&&(t[e]=u.value),t}},W=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},$=j?function(t,e,u){return Z.f(t,e,W(1,u))}:function(t,e,u){return t[e]=u,t},X=t(function(t){var e=P("src"),u=Function.toString,n=(""+u).split("toString");L.inspectSource=function(t){return u.call(t)},(t.exports=function(t,u,i,r){var o="function"==typeof i;o&&(c(i,"name")||$(i,"name",u)),t[u]!==i&&(o&&(c(i,e)||$(i,e,t[u]?""+t[u]:n.join(String(u)))),t===y?t[u]=i:r?t[u]?t[u]=i:$(t,u,i):(delete t[u],$(t,u,i)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[e]||u.call(this)})}),q=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t},J=function(t,e,u){if(q(t),void 0===e)return t;switch(u){case 1:return function(u){return t.call(e,u)};case 2:return function(u,n){return t.call(e,u,n)};case 3:return function(u,n,i){return t.call(e,u,n,i)}}return function(){return t.apply(e,arguments)}},K=function(t,e,u){var n,i,r,o,s=t&K.F,a=t&K.G,h=t&K.S,l=t&K.P,c=t&K.B,p=a?y:h?y[e]||(y[e]={}):(y[e]||{}).prototype,f=a?L:L[e]||(L[e]={}),d=f.prototype||(f.prototype={});a&&(u=e);for(n in u)r=((i=!s&&p&&void 0!==p[n])?p:u)[n],o=c&&i?J(r,y):l&&"function"==typeof r?J(Function.call,r):r,p&&X(p,n,r,t&K.U),f[n]!=r&&$(f,n,o),l&&d[n]!=r&&(d[n]=r)};y.core=L,K.F=1,K.G=2,K.S=4,K.P=8,K.B=16,K.W=32,K.U=64,K.R=128;var Q=K;!function(t,e){var u=(L.Object||{})[t]||Object[t],n={};n[t]=e(u),Q(Q.S+Q.F*H(function(){u(1)}),"Object",n)}("keys",function(){return function(t){return O(h(t))}});var tt=function(t){var e=String(a(this)),u="",n=g(t);if(n<0||n==1/0)throw RangeError("Count can't be negative");for(;n>0;(n>>>=1)&&(e+=e))1&n&&(u+=e);return u};Q(Q.P,"String",{repeat:tt});var et=function(t,e,u,n){var i=String(a(t)),r=i.length,o=void 0===u?" ":String(u),s=_(e);if(s<=r||""==o)return i;var h=s-r,l=tt.call(o,Math.ceil(h/o.length));return l.length>h&&(l=l.slice(0,h)),n?l+i:i+l};Q(Q.P,"String",{padStart:function(t){return et(this,t,arguments.length>1?arguments[1]:void 0,!0)}}),Q(Q.P,"String",{padEnd:function(t){return et(this,t,arguments.length>1?arguments[1]:void 0,!1)}});!function(){function t(t){this.value=t}function e(e){function u(i,r){try{var o=e[i](r),s=o.value;s instanceof t?Promise.resolve(s.value).then(function(t){u("next",t)},function(t){u("throw",t)}):n(o.done?"return":"normal",o.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}(i=i.next)?u(i.key,i.arg):r=null}var i,r;this._invoke=function(t,e){return new Promise(function(n,o){var s={key:t,arg:e,resolve:n,reject:o,next:null};r?r=r.next=s:(i=r=s,u(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var ut=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},nt=function(){function t(t,e){for(var u=0;u<e.length;u++){var n=e[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,u,n){return u&&t(e.prototype,u),n&&t(e,n),e}}(),it=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var u=arguments[e];for(var n in u)Object.prototype.hasOwnProperty.call(u,n)&&(t[n]=u[n])}return t},rt=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},ot=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},st=function(){function t(e){ut(this,t),this._value="",this.updateOptions(it({},t.DEFAULTS,e)),this.isInitialized=!0}return t.prototype.updateOptions=function(t){var e=this;this.withValueRefresh(function(){return it(e,t)})},t.prototype.clone=function(){var e=new t(this);return e._value=this.value.slice(),e},t.prototype.reset=function(){this._value=""},t.prototype.nearestInputPos=function(t){return t},t.prototype.extractInput=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this.value.slice(t,e)},t.prototype.extractTail=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this.extractInput(t,e)},t.prototype._appendTail=function(t){return!t||this._append(t)},t.prototype._append=function(t,e){var u=this.value.length,n=this.clone();t=this.doPrepare(t,e);for(var i=0;i<t.length;++i){if(this._value+=t[i],!1===this.doValidate(e)&&(it(this,n),!e))return!1;n=this.clone()}return this.value.length-u},t.prototype.appendWithTail=function(t,e){for(var u=0,n=this.clone(),i=void 0,r=0;r<t.length;++r){var o=t[r],s=this._append(o,!0);if(i=this.clone(),!1===(!1!==s&&!1!==this._appendTail(e))||!1===this.doValidate(!0)){it(this,n);break}n=this.clone(),it(this,i),u+=s}return this._appendTail(e),u},t.prototype._unmask=function(){return this.value},t.prototype.clear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;this._value=this.value.slice(0,t)+this.value.slice(e)},t.prototype.withValueRefresh=function(t){if(this._refreshing)return t();this._refreshing=!0;var e=this.isInitialized?this.unmaskedValue:null,u=t();return null!=e&&(this.unmaskedValue=e),delete this._refreshing,u},t.prototype.doPrepare=function(t,e){return this.prepare(t,this,e)},t.prototype.doValidate=function(t){return this.validate(this.value,this,t)},t.prototype.doCommit=function(){this.commit(this.value,this)},nt(t,[{key:"value",get:function(){return this._value},set:function(t){this.reset(),this.appendWithTail(t),this.doCommit()}},{key:"unmaskedValue",get:function(){return this._unmask()},set:function(t){this.reset(),this._append(t),this.appendWithTail(""),this.doCommit()}},{key:"isComplete",get:function(){return!0}}]),t}();st.DEFAULTS={prepare:function(t){return t},validate:function(){return!0},commit:function(){}};var at={NONE:0,LEFT:-1,RIGHT:1},ht=function(t){function e(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ut(this,e),u.validate=function(t){return u.mask.test(t)},ot(this,t.call(this,u))}return rt(e,t),e}(st),lt=function(t){function e(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ut(this,e),u.validate=u.mask,ot(this,t.call(this,u))}return rt(e,t),e}(st),ct=function(t){function e(u){return ut(this,e),ot(this,t.call(this,it({},e.DEFAULTS,u)))}return rt(e,t),e.prototype.updateOptions=function(u){u._signed=u.signed,delete u.signed,u.postFormat=it({},e.DEFAULTS.postFormat,u.postFormat),t.prototype.updateOptions.call(this,u),this._updateRegExps()},e.prototype._updateRegExps=function(){var t="^",e="^";this.signed?(t+="([+|\\-]?|([+|\\-]?(0|([1-9]+\\d*))))",e+="[+|\\-]?"):t+="(0|([1-9]+\\d*))",e+="\\d*",this.scale&&(t+="("+this.radix+"\\d{0,"+this.scale+"})?",e+="("+this.radix+"\\d{0,"+this.scale+"})?"),t+="$",e+="$",this._numberRegExpSoft=new RegExp(t),this._numberRegExp=new RegExp(e),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(i).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(i(this.thousandsSeparator),"g")},e.prototype.extractTail=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this._removeThousandsSeparators(t.prototype.extractTail.call(this,e,u))},e.prototype._removeThousandsSeparators=function(t){return t.replace(this._thousandsSeparatorRegExp,"")},e.prototype._insertThousandsSeparators=function(t){var e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)},e.prototype.doPrepare=function(e,u){return t.prototype.doPrepare.call(this,this._removeThousandsSeparators(e.replace(this._mapToRadixRegExp,this.radix)),u)},e.prototype.appendWithTail=function(e,u){var n=this.value.length;this._value=this._removeThousandsSeparators(this.value);var i=n-this.value.length,r=t.prototype.appendWithTail.call(this,e,u);this._value=this._insertThousandsSeparators(this.value);var o=n+r-i;this._value=this._insertThousandsSeparators(this.value);for(var s=0,a=0;a<=o;++a)this.value[a]===this.thousandsSeparator&&(++s,++o);return r-i+s},e.prototype.nearestInputPos=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:at.LEFT;if(!e)return t;var u=n(t,e);return this.value[u]===this.thousandsSeparator&&(t+=e),t},e.prototype.doValidate=function(e){var u=(e?this._numberRegExpSoft:this._numberRegExp).test(this._removeThousandsSeparators(this.value));if(u){var n=this.number;u=u&&!isNaN(n)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return u&&t.prototype.doValidate.call(this,e)},e.prototype.doCommit=function(){var e=this.number,u=e;null!=this.min&&(u=Math.max(u,this.min)),null!=this.max&&(u=Math.min(u,this.max)),u!==e&&(this.unmaskedValue=""+u);var n=this.value;this.postFormat.normalizeZeros&&(n=this._normalizeZeros(n)),this.postFormat.padFractionalZeros&&(n=this._padFractionalZeros(n)),this._value=n,t.prototype.doCommit.call(this)},e.prototype._normalizeZeros=function(t){var e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,function(t,e,u,n){return e+n}),t.length&&!/\d$/.test(e[0])&&(e[0]=e[0]+"0"),e.length>1&&(e[1]=e[1].replace(/0*$/,""),e[1].length||(e.length=1)),this._insertThousandsSeparators(e.join(this.radix))},e.prototype._padFractionalZeros=function(t){var e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)},nt(e,[{key:"number",get:function(){var t=this._removeThousandsSeparators(this._normalizeZeros(this.unmaskedValue)).replace(this.radix,".");return Number(t)},set:function(t){this.unmaskedValue=""+t}},{key:"signed",get:function(){return this._signed||null!=this.min&&this.min<0||null!=this.max&&this.max<0}}]),e}(st);ct.DEFAULTS={radix:",",thousandsSeparator:"",mapToRadix:["."],scale:2,postFormat:{normalizeZeros:!0}};var pt=function(){function t(e){ut(this,t),it(this,e),this.mask&&(this._masked=o(e))}return t.prototype.reset=function(){this.isHollow=!1,this._masked&&this._masked.reset()},t.prototype.resolve=function(t){return!!this._masked&&(this._masked.value=t,this._masked.value)},nt(t,[{key:"isInput",get:function(){return this.type===t.TYPES.INPUT}},{key:"isHiddenHollow",get:function(){return this.isHollow&&this.optional}}]),t}();pt.DEFAULTS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./},pt.TYPES={INPUT:"input",FIXED:"fixed"};var ft=function(){function t(e,u){var n=u.name,i=u.offset,r=u.mask,o=u.validate;ut(this,t),this.masked=e,this.name=n,this.offset=i,this.mask=r,this.validate=o||function(){return!0}}return t.prototype.doValidate=function(t){return this.validate(this.value,this,t)},nt(t,[{key:"value",get:function(){return this.masked.value.slice(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}},{key:"unmaskedValue",get:function(){return this.masked.extractInput(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}}]),t}(),dt=function(){function t(e){var u=e[0],n=e[1],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(n+"").length;ut(this,t),this._from=u,this._to=n,this._maxLength=i,this.validate=this.validate.bind(this),this._update()}return t.prototype._update=function(){this._maxLength=Math.max(this._maxLength,(this.to+"").length),this.mask="0".repeat(this._maxLength)},t.prototype.validate=function(t){var e="",u="",n=t.match(/^(\D*)(\d*)(\D*)/),i=n[1],r=n[2];return r&&(e="0".repeat(i.length)+r,u="9".repeat(i.length)+r),-1===t.search(/[^0]/)&&t.length<=this._matchFrom||(e=e.padEnd(this._maxLength,"0"),u=u.padEnd(this._maxLength,"9"),this.from<=Number(u)&&Number(e)<=this.to)},nt(t,[{key:"to",get:function(){return this._to},set:function(t){this._to=t,this._update()}},{key:"from",get:function(){return this._from},set:function(t){this._from=t,this._update()}},{key:"maxLength",get:function(){return this._maxLength},set:function(t){this._maxLength=t,this._update()}},{key:"_matchFrom",get:function(){return this.maxLength-(this.from+"").length}}]),t}();ft.Range=dt,ft.Enum=function(t){return{mask:"*".repeat(t[0].length),validate:function(e,u){return t.some(function(t){return t.indexOf(u.unmaskedValue)>=0})}}};var vt=function(t){function e(){return ut(this,e),ot(this,t.apply(this,arguments))}return rt(e,t),e.prototype.updateOptions=function(u){u.placeholder=it({},e.DEFAULT_PLACEHOLDER,u.placeholder),u.definitions=it({},pt.DEFAULTS,u.definitions),t.prototype.updateOptions.call(this,u),this._updateMask()},e.prototype._updateMask=function(){var t=this,u=this.definitions;this._charDefs=[],this._groupDefs=[];var n=this.mask;if(n&&u){var i=!1,r=!1,o=!1;t:for(var s=0;s<n.length;++s)switch(function(a){if(t.groups){var h=n.slice(a),l=Object.keys(t.groups).filter(function(t){return 0===h.indexOf(t)});l.sort(function(t,e){return e.length-t.length});var c=l[0];if(c){var p=t.groups[c];t._groupDefs.push(new ft(t,{name:c,offset:t._charDefs.length,mask:p.mask,validate:p.validate})),n=n.replace(c,p.mask)}}var f=n[a],d=!i&&f in u?pt.TYPES.INPUT:pt.TYPES.FIXED,v=d===pt.TYPES.INPUT||i,A=d===pt.TYPES.INPUT&&r;if(f===e.STOP_CHAR)return o=!0,"continue";if("{"===f||"}"===f)return i=!i,"continue";if("["===f||"]"===f)return r=!r,"continue";if(f===e.ESCAPE_CHAR){if(++a,!(f=n[a]))return"break";d=pt.TYPES.FIXED}t._charDefs.push(new pt({char:f,type:d,optional:A,stopAlign:o,unmasking:v,mask:d===pt.TYPES.INPUT?u[f]:function(t){return t===f}})),o=!1,s=a}(s)){case"continue":continue;case"break":break t}}},e.prototype.doValidate=function(e){return this._groupDefs.every(function(t){return t.doValidate(e)})&&t.prototype.doValidate.call(this,e)},e.prototype.clone=function(){var t=this,u=new e(this);return u._value=this.value,u._charDefs.forEach(function(e,u){return it(e,t._charDefs[u])}),u._groupDefs.forEach(function(e,u){return it(e,t._groupDefs[u])}),u},e.prototype.reset=function(){t.prototype.reset.call(this),this._charDefs.forEach(function(t){delete t.isHollow})},e.prototype.hiddenHollowsBefore=function(t){return this._charDefs.slice(0,t).filter(function(t){return t.isHiddenHollow}).length},e.prototype.mapDefIndexToPos=function(t){if(null!=t)return t-this.hiddenHollowsBefore(t)},e.prototype.mapPosToDefIndex=function(t){if(null!=t){for(var e=t,u=0;u<this._charDefs.length;++u){var n=this._charDefs[u];if(u>=e)break;n.isHiddenHollow&&++e}return e}},e.prototype._unmask=function(){for(var t=this.value,e="",u=0,n=0;u<t.length&&n<this._charDefs.length;++n){var i=t[u],r=this._charDefs[n];r.isHiddenHollow||(r.unmasking&&!r.isHollow&&(e+=i),++u)}return e},e.prototype._appendTail=function(t){return(!t||this._appendChunks(t))&&this._appendPlaceholder()},e.prototype._append=function(t,e){for(var n=this.value.length,i=0,r=this.mapPosToDefIndex(this.value.length);i<t.length;){var o=t[i],s=this._charDefs[r];if(!s)return!1;s.isHollow=!1;var a=void 0,h=void 0,l=u(s.resolve(o),o);s.type===pt.TYPES.INPUT?(l&&(this._value+=l,this.doValidate()||(l="",this._value=this.value.slice(0,-1))),a=!!l,h=!l&&!s.optional,l||(s.optional||e||(this._value+=this.placeholder.char,h=!1),h||(s.isHollow=!0))):(this._value+=s.char,a=l&&(s.unmasking||e)),h||++r,(a||h)&&++i}return this.value.length-n},e.prototype._appendChunks=function(t,e){for(var u=0;u<t.length;++u){var n=t[u],i=n[0],r=n[1];if(null!=i&&this._appendPlaceholder(i),!1===this._append(r,e))return!1}return!0},e.prototype.extractTail=function(t,e){return this.extractInputChunks(t,e)},e.prototype.extractInput=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,u=this.value,n="",i=this.mapPosToDefIndex(e),r=t,o=this.mapPosToDefIndex(t);r<e&&r<u.length&&o<i;++o){var s=u[r],a=this._charDefs[o];if(!a)break;a.isHiddenHollow||(a.isInput&&!a.isHollow&&(n+=s),++r)}return n},e.prototype.extractInputChunks=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=this.mapPosToDefIndex(e),i=this.mapPosToDefIndex(u),r=this._charDefs.map(function(t,e){return[t,e]}).slice(n,i).filter(function(t){return t[0].stopAlign}).map(function(t){return t[1]}),o=[n].concat(r,[i]);return o.map(function(e,u){return[r.indexOf(e)>=0?e:null,t.extractInput(t.mapDefIndexToPos(e),t.mapDefIndexToPos(o[++u]))]}).filter(function(t){var e=t[0],u=t[1];return null!=e||u})},e.prototype._appendPlaceholder=function(t){for(var e=t||this._charDefs.length,u=this.mapPosToDefIndex(this.value.length);u<e;++u){var n=this._charDefs[u];n.isInput&&(n.isHollow=!0),this.placeholder.lazy&&!t||(this._value+=n.isInput?n.optional?"":this.placeholder.char:n.char)}},e.prototype.clear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;this._value=this.value.slice(0,t)+this.value.slice(e);var u=this.mapPosToDefIndex(t),n=this.mapPosToDefIndex(e);this._charDefs.slice(u,n).forEach(function(t){return t.reset()})},e.prototype.nearestInputPos=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:at.LEFT;if(!e)return t;var u=this.mapPosToDefIndex(t),i=u,r=void 0,o=void 0,s=void 0,a=void 0;for(a=n(i,e);0<=a&&a<this._charDefs.length;i+=e,a+=e){var h=this._charDefs[a];if(null==r&&h.isInput&&(r=i),null==s&&h.isHollow&&!h.isHiddenHollow&&(s=i),h.isInput&&!h.isHollow){o=i;break}}if(e===at.LEFT||null==r){var l=!1;for(a=n(i,e=-e);0<=a&&a<this._charDefs.length;i+=e,a+=e){var c=this._charDefs[a];if(c.isInput&&(r=i,c.isHollow&&!c.isHiddenHollow))break;if(i===u&&(l=!0),l&&null!=r)break}(l=l||a>=this._charDefs.length)&&null!=r&&(i=r)}else null==o&&(i=null!=s?s:r);return this.mapDefIndexToPos(i)},e.prototype.group=function(t){return this.groupsByName(t)[0]},e.prototype.groupsByName=function(t){return this._groupDefs.filter(function(e){return e.name===t})},nt(e,[{key:"isComplete",get:function(){var t=this;return!this._charDefs.some(function(e,u){return e.isInput&&!e.optional&&(e.isHollow||!t.extractInput(u,u+1))})}}]),e}(st);vt.DEFAULT_PLACEHOLDER={lazy:!0,char:"_"},vt.STOP_CHAR="`",vt.ESCAPE_CHAR="\\",vt.Definition=pt,vt.Group=ft;var At=function(t){function e(u){return ut(this,e),ot(this,t.call(this,it({},e.DEFAULTS,u)))}return rt(e,t),e.prototype.updateOptions=function(u){u.mask===Date&&delete u.mask,u.pattern&&(u.mask=u.pattern,delete u.pattern);var n=u.groups;u.groups=it({},e.GET_DEFAULT_GROUPS()),u.min&&(u.groups.Y.from=u.min.getFullYear()),u.max&&(u.groups.Y.to=u.max.getFullYear()),it(u.groups,n),t.prototype.updateOptions.call(this,u)},e.prototype.doValidate=function(e){var u=t.prototype.doValidate.call(this,e),n=this.date;return u&&(!this.isComplete||this.isDateExist(this.value)&&n&&(null==this.min||this.min<=n)&&(null==this.max||n<=this.max))},e.prototype.isDateExist=function(t){return this.format(this.parse(t))===t},nt(e,[{key:"date",get:function(){return this.isComplete?this.parse(this.value):null},set:function(t){this.value=this.format(t)}}]),e}(vt);At.DEFAULTS={pattern:"d{.}`m{.}`Y",format:function(t){return[(""+t.getDate()).padStart(2,"0"),(""+(t.getMonth()+1)).padStart(2,"0"),t.getFullYear()].join(".")},parse:function(t){var e=t.split("."),u=e[0],n=e[1],i=e[2];return new Date(i,n-1,u)}},At.GET_DEFAULT_GROUPS=function(){return{d:new ft.Range([1,31]),m:new ft.Range([1,12]),Y:new ft.Range([1900,9999])}};var mt=function(){function t(e,u,n,i){for(ut(this,t),this.value=e,this.cursorPos=u,this.oldValue=n,this.oldSelection=i;this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}return nt(t,[{key:"startChangePos",get:function(){return Math.min(this.cursorPos,this.oldSelection.start)}},{key:"insertedCount",get:function(){return this.cursorPos-this.startChangePos}},{key:"inserted",get:function(){return this.value.substr(this.startChangePos,this.insertedCount)}},{key:"removedCount",get:function(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}},{key:"removed",get:function(){return this.oldValue.substr(this.startChangePos,this.removedCount)}},{key:"head",get:function(){return this.value.substring(0,this.startChangePos)}},{key:"tail",get:function(){this.value.substring(this.startChangePos+this.insertedCount)}},{key:"removeDirection",get:function(){return this.removedCount&&!this.insertedCount&&(this.oldSelection.end===this.cursorPos?at.RIGHT:at.LEFT)}}]),t}(),gt=function(){function t(e,u){ut(this,t),this.el=e,this.masked=o(u),this._listeners={},this._value="",this._unmaskedValue="",this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._alignCursor=this._alignCursor.bind(this),this._alignCursorFriendly=this._alignCursorFriendly.bind(this),this.bindEvents(),this.updateValue(),this._onChange()}return t.prototype.bindEvents=function(){this.el.addEventListener("keydown",this._saveSelection),this.el.addEventListener("input",this._onInput),this.el.addEventListener("drop",this._onDrop),this.el.addEventListener("click",this._alignCursorFriendly),this.el.addEventListener("change",this._onChange)},t.prototype.unbindEvents=function(){this.el.removeEventListener("keydown",this._saveSelection),this.el.removeEventListener("input",this._onInput),this.el.removeEventListener("drop",this._onDrop),this.el.removeEventListener("click",this._alignCursorFriendly),this.el.removeEventListener("change",this._onChange)},t.prototype.fireEvent=function(t){(this._listeners[t]||[]).forEach(function(t){return t()})},t.prototype._saveSelection=function(){this.value!==this.el.value&&console.warn("Uncontrolled input change, refresh mask manually!"),this._selection={start:this.selectionStart,end:this.cursorPos}},t.prototype.updateValue=function(){this.masked.value=this.el.value},t.prototype.updateControl=function(){var t=this.masked.unmaskedValue,e=this.masked.value,u=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==e&&(this.el.value=e),u&&this._fireChangeEvents()},t.prototype.updateOptions=function(t){this.masked.updateOptions(t),this.updateControl()},t.prototype.updateCursor=function(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))},t.prototype._delayUpdateCursor=function(t){var e=this;this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(function(){e.cursorPos=e._changingCursorPos,e._abortUpdateCursor()},10)},t.prototype._fireChangeEvents=function(){this.fireEvent("accept"),this.masked.isComplete&&this.fireEvent("complete")},t.prototype._abortUpdateCursor=function(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)},t.prototype._alignCursor=function(){this.cursorPos=this.masked.nearestInputPos(this.cursorPos)},t.prototype._alignCursorFriendly=function(){this.selectionStart===this.cursorPos&&this._alignCursor()},t.prototype.on=function(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this},t.prototype.off=function(t,e){if(this._listeners[t]){if(e){var u=this._listeners[t].indexOf(e);return u>=0&&this._listeners.splice(u,1),this}delete this._listeners[t]}},t.prototype._onInput=function(){this._abortUpdateCursor();var t=new mt(this.el.value,this.cursorPos,this.value,this._selection),e=t.startChangePos+t.removed.length,u=this.masked.extractTail(e),n=this.masked.nearestInputPos(t.startChangePos,t.removeDirection);this.masked.clear(n);var i=this.masked.appendWithTail(t.inserted,u),r=this.masked.nearestInputPos(n+i,t.removeDirection);this.updateControl(),this.updateCursor(r)},t.prototype._onChange=function(){this.value!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl()},t.prototype._onDrop=function(t){t.preventDefault(),t.stopPropagation()},t.prototype.destroy=function(){this.unbindEvents(),this._listeners.length=0},nt(t,[{key:"mask",get:function(){return this.masked.mask},set:function(t){if(null!=t&&t!==this.masked.mask)if(this.masked.constructor!==r(t)){var e=o({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}else this.masked.mask=t}},{key:"value",get:function(){return this._value},set:function(t){this.masked.value=t,this.updateControl(),this._alignCursor()}},{key:"unmaskedValue",get:function(){return this._unmaskedValue},set:function(t){this.masked.unmaskedValue=t,this.updateControl(),this._alignCursor()}},{key:"selectionStart",get:function(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}},{key:"cursorPos",get:function(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd},set:function(t){this.el===document.activeElement&&(this.el.setSelectionRange(t,t),this._saveSelection())}}]),t}();return s.InputMask=gt,s.Masked=st,s.MaskedPattern=vt,s.MaskedNumber=ct,s.MaskedDate=At,s.MaskedRegExp=ht,s.MaskedFunction=lt,window.IMask=s,s}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.IMask=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t){return"string"==typeof t||t instanceof String}function u(t,u){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return e(t)?t:t?u:n}function n(t,e){return e===lt.LEFT&&--t,t}function i(t){return t.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function r(t,e){if(e===t)return!0;var u,n=Array.isArray(e),i=Array.isArray(t);if(n&&i){if(e.length!=t.length)return!1;for(u=0;u<e.length;u++)if(!r(e[u],t[u]))return!1;return!0}if(n!=i)return!1;if(e&&t&&"object"===(void 0===e?"undefined":nt(e))&&"object"===(void 0===t?"undefined":nt(t))){var o=Object.keys(e),s=e instanceof Date,a=t instanceof Date;if(s&&a)return e.getTime()==t.getTime();if(s!=a)return!1;var h=e instanceof RegExp,l=t instanceof RegExp;if(h&&l)return e.toString()==t.toString();if(h!=l)return!1;for(u=0;u<o.length;u++)if(!Object.prototype.hasOwnProperty.call(t,o[u]))return!1;for(u=0;u<o.length;u++)if(!r(e[o[u]],t[o[u]]))return!1;return!0}return!1}function o(t){return t instanceof RegExp?ct:e(t)?IMask.MaskedPattern:t.prototype instanceof ht?t:t instanceof Number||"number"==typeof t||t===Number?ft:t instanceof Date||t===Date?IMask.MaskedDate:t instanceof Function?pt:(console.warn("Mask not found for mask",t),ht)}function s(t){var e=(t=ot({},t)).mask;return e instanceof ht?e:new(o(e))(t)}function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new yt(t,e)}var h=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t},l=function(t){return Object(h(t))},c={}.hasOwnProperty,p=function(t,e){return c.call(t,e)},f={}.toString,d=function(t){return f.call(t).slice(8,-1)},v=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==d(t)?t.split(""):Object(t)},m=function(t){return v(h(t))},A=Math.ceil,g=Math.floor,F=function(t){return isNaN(t=+t)?0:(t>0?g:A)(t)},y=Math.min,D=function(t){return t>0?y(F(t),9007199254740991):0},_=Math.max,C=Math.min,E=function(t,e){return(t=F(t))<0?_(t+e,0):C(t,e)},k=t(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),B=k["__core-js_shared__"]||(k["__core-js_shared__"]={}),x=0,P=Math.random(),b=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++x+P).toString(36))},T=function(t){return B[t]||(B[t]={})}("keys"),S=function(t){return function(e,u,n){var i,r=m(e),o=D(r.length),s=E(n,o);if(t&&u!=u){for(;o>s;)if((i=r[s++])!=i)return!0}else for(;o>s;s++)if((t||s in r)&&r[s]===u)return t||s||0;return!t&&-1}}(!1),w=function(t){return T[t]||(T[t]=b(t))}("IE_PROTO"),I=function(t,e){var u,n=m(t),i=0,r=[];for(u in n)u!=w&&p(n,u)&&r.push(u);for(;e.length>i;)p(n,u=e[i++])&&(~S(r,u)||r.push(u));return r},O="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),L=Object.keys||function(t){return I(t,O)},R=t(function(t){var e=t.exports={version:"2.5.1"};"number"==typeof __e&&(__e=e)}),j=function(t){return"object"==typeof t?null!==t:"function"==typeof t},V=function(t){if(!j(t))throw TypeError(t+" is not an object!");return t},H=function(t){try{return!!t()}catch(t){return!0}},M=!H(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),U=k.document,N=j(U)&&j(U.createElement),Y=function(t){return N?U.createElement(t):{}},z=!M&&!H(function(){return 7!=Object.defineProperty(Y("div"),"a",{get:function(){return 7}}).a}),G=function(t,e){if(!j(t))return t;var u,n;if(e&&"function"==typeof(u=t.toString)&&!j(n=u.call(t)))return n;if("function"==typeof(u=t.valueOf)&&!j(n=u.call(t)))return n;if(!e&&"function"==typeof(u=t.toString)&&!j(n=u.call(t)))return n;throw TypeError("Can't convert object to primitive value")},Z=Object.defineProperty,W={f:M?Object.defineProperty:function(t,e,u){if(V(t),e=G(e,!0),V(u),z)try{return Z(t,e,u)}catch(t){}if("get"in u||"set"in u)throw TypeError("Accessors not supported!");return"value"in u&&(t[e]=u.value),t}},$=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},X=M?function(t,e,u){return W.f(t,e,$(1,u))}:function(t,e,u){return t[e]=u,t},q=t(function(t){var e=b("src"),u=Function.toString,n=(""+u).split("toString");R.inspectSource=function(t){return u.call(t)},(t.exports=function(t,u,i,r){var o="function"==typeof i;o&&(p(i,"name")||X(i,"name",u)),t[u]!==i&&(o&&(p(i,e)||X(i,e,t[u]?""+t[u]:n.join(String(u)))),t===k?t[u]=i:r?t[u]?t[u]=i:X(t,u,i):(delete t[u],X(t,u,i)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[e]||u.call(this)})}),J=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t},K=function(t,e,u){if(J(t),void 0===e)return t;switch(u){case 1:return function(u){return t.call(e,u)};case 2:return function(u,n){return t.call(e,u,n)};case 3:return function(u,n,i){return t.call(e,u,n,i)}}return function(){return t.apply(e,arguments)}},Q=function(t,e,u){var n,i,r,o,s=t&Q.F,a=t&Q.G,h=t&Q.S,l=t&Q.P,c=t&Q.B,p=a?k:h?k[e]||(k[e]={}):(k[e]||{}).prototype,f=a?R:R[e]||(R[e]={}),d=f.prototype||(f.prototype={});a&&(u=e);for(n in u)r=((i=!s&&p&&void 0!==p[n])?p:u)[n],o=c&&i?K(r,k):l&&"function"==typeof r?K(Function.call,r):r,p&&q(p,n,r,t&Q.U),f[n]!=r&&X(f,n,o),l&&d[n]!=r&&(d[n]=r)};k.core=R,Q.F=1,Q.G=2,Q.S=4,Q.P=8,Q.B=16,Q.W=32,Q.U=64,Q.R=128;var tt=Q;!function(t,e){var u=(R.Object||{})[t]||Object[t],n={};n[t]=e(u),tt(tt.S+tt.F*H(function(){u(1)}),"Object",n)}("keys",function(){return function(t){return L(l(t))}});var et=function(t){var e=String(h(this)),u="",n=F(t);if(n<0||n==1/0)throw RangeError("Count can't be negative");for(;n>0;(n>>>=1)&&(e+=e))1&n&&(u+=e);return u};tt(tt.P,"String",{repeat:et});var ut=function(t,e,u,n){var i=String(h(t)),r=i.length,o=void 0===u?" ":String(u),s=D(e);if(s<=r||""==o)return i;var a=s-r,l=et.call(o,Math.ceil(a/o.length));return l.length>a&&(l=l.slice(0,a)),n?l+i:i+l};tt(tt.P,"String",{padStart:function(t){return ut(this,t,arguments.length>1?arguments[1]:void 0,!0)}}),tt(tt.P,"String",{padEnd:function(t){return ut(this,t,arguments.length>1?arguments[1]:void 0,!1)}});var nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},it=(function(){function t(t){this.value=t}function e(e){function u(i,r){try{var o=e[i](r),s=o.value;s instanceof t?Promise.resolve(s.value).then(function(t){u("next",t)},function(t){u("throw",t)}):n(o.done?"return":"normal",o.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}(i=i.next)?u(i.key,i.arg):r=null}var i,r;this._invoke=function(t,e){return new Promise(function(n,o){var s={key:t,arg:e,resolve:n,reject:o,next:null};r?r=r.next=s:(i=r=s,u(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),rt=function(){function t(t,e){for(var u=0;u<e.length;u++){var n=e[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,u,n){return u&&t(e.prototype,u),n&&t(e,n),e}}(),ot=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var u=arguments[e];for(var n in u)Object.prototype.hasOwnProperty.call(u,n)&&(t[n]=u[n])}return t},st=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},at=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},ht=function(){function t(e){it(this,t),this._value="",this._update(ot({},t.DEFAULTS,e)),this.isInitialized=!0}return t.prototype.updateOptions=function(t){this.withValueRefresh(this._update.bind(this,t))},t.prototype._update=function(t){ot(this,t)},t.prototype.clone=function(){var e=new t(this);return e._value=this.value.slice(),e},t.prototype.reset=function(){this._value=""},t.prototype.nearestInputPos=function(t){return t},t.prototype.extractInput=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this.value.slice(t,e)},t.prototype.extractTail=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this.extractInput(t,e)},t.prototype._appendTail=function(t){return!t||this._append(t)},t.prototype._append=function(t,e){var u=this.value.length,n=this.clone();t=this.doPrepare(t,e);for(var i=0;i<t.length;++i){if(this._value+=t[i],!1===this.doValidate(e)&&(ot(this,n),!e))return!1;n=this.clone()}return this.value.length-u},t.prototype.appendWithTail=function(t,e){for(var u=0,n=this.clone(),i=void 0,r=0;r<t.length;++r){var o=t[r],s=this._append(o,!0);if(i=this.clone(),!1===(!1!==s&&!1!==this._appendTail(e))||!1===this.doValidate(!0)){ot(this,n);break}n=this.clone(),ot(this,i),u+=s}return this._appendTail(e),u},t.prototype._unmask=function(){return this.value},t.prototype.clear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;this._value=this.value.slice(0,t)+this.value.slice(e)},t.prototype.withValueRefresh=function(t){if(this._refreshing||!this.isInitialized)return t();this._refreshing=!0;var e=this.unmaskedValue,u=t();return this.unmaskedValue=e,delete this._refreshing,u},t.prototype.doPrepare=function(t,e){return this.prepare(t,this,e)},t.prototype.doValidate=function(t){return this.validate(this.value,this,t)},t.prototype.doCommit=function(){this.commit(this.value,this)},rt(t,[{key:"value",get:function(){return this._value},set:function(t){this.reset(),this.appendWithTail(t),this.doCommit()}},{key:"unmaskedValue",get:function(){return this._unmask()},set:function(t){this.reset(),this._append(t),this.appendWithTail(""),this.doCommit()}},{key:"isComplete",get:function(){return!0}}]),t}();ht.DEFAULTS={prepare:function(t){return t},validate:function(){return!0},commit:function(){}};var lt={NONE:0,LEFT:-1,RIGHT:1},ct=function(t){function e(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return it(this,e),u.validate=function(t){return t.search(u.mask)>=0},at(this,t.call(this,u))}return st(e,t),e}(ht),pt=function(t){function e(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return it(this,e),u.validate=u.mask,at(this,t.call(this,u))}return st(e,t),e}(ht),ft=function(t){function e(u){return it(this,e),u.postFormat=ot({},e.DEFAULTS.postFormat,u.postFormat),at(this,t.call(this,ot({},e.DEFAULTS,u)))}return st(e,t),e.prototype._update=function(e){e.postFormat=ot({},this.postFormat,e.postFormat),t.prototype._update.call(this,e),this._updateRegExps()},e.prototype._updateRegExps=function(){var t="^",e="^";this.allowNegative?(t+="([+|\\-]?|([+|\\-]?(0|([1-9]+\\d*))))",e+="[+|\\-]?"):t+="(0|([1-9]+\\d*))",e+="\\d*",this.scale&&(t+="("+this.radix+"\\d{0,"+this.scale+"})?",e+="("+this.radix+"\\d{0,"+this.scale+"})?"),t+="$",e+="$",this._numberRegExpSoft=new RegExp(t),this._numberRegExp=new RegExp(e),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(i).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(i(this.thousandsSeparator),"g")},e.prototype.extractTail=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;return this._removeThousandsSeparators(t.prototype.extractTail.call(this,e,u))},e.prototype._removeThousandsSeparators=function(t){return t.replace(this._thousandsSeparatorRegExp,"")},e.prototype._insertThousandsSeparators=function(t){var e=t.split(this.radix);return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),e.join(this.radix)},e.prototype.doPrepare=function(e,u){return t.prototype.doPrepare.call(this,this._removeThousandsSeparators(e.replace(this._mapToRadixRegExp,this.radix)),u)},e.prototype.appendWithTail=function(e,u){var n=this.value.length;this._value=this._removeThousandsSeparators(this.value);var i=n-this.value.length,r=t.prototype.appendWithTail.call(this,e,u);this._value=this._insertThousandsSeparators(this.value);for(var o=n+r-i,s=0,a=0;a<=o;++a)this.value[a]===this.thousandsSeparator&&(++s,++o);return r-i+s},e.prototype.nearestInputPos=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt.LEFT;if(!e)return t;var u=n(t,e);return this.value[u]===this.thousandsSeparator&&(t+=e),t},e.prototype.doValidate=function(e){var u=(e?this._numberRegExpSoft:this._numberRegExp).test(this._removeThousandsSeparators(this.value));if(u){var n=this.number;u=u&&!isNaN(n)&&(null==this.min||this.min>=0||this.min<=this.number)&&(null==this.max||this.max<=0||this.number<=this.max)}return u&&t.prototype.doValidate.call(this,e)},e.prototype.doCommit=function(){var e=this.number,u=e;null!=this.min&&(u=Math.max(u,this.min)),null!=this.max&&(u=Math.min(u,this.max)),u!==e&&(this.unmaskedValue=""+u);var n=this.value;this.postFormat.normalizeZeros&&(n=this._normalizeZeros(n)),this.postFormat.padFractionalZeros&&(n=this._padFractionalZeros(n)),this._value=n,t.prototype.doCommit.call(this)},e.prototype._normalizeZeros=function(t){var e=this._removeThousandsSeparators(t).split(this.radix);return e[0]=e[0].replace(/^(\D*)(0*)(\d*)/,function(t,e,u,n){return e+n}),t.length&&!/\d$/.test(e[0])&&(e[0]=e[0]+"0"),e.length>1&&(e[1]=e[1].replace(/0*$/,""),e[1].length||(e.length=1)),this._insertThousandsSeparators(e.join(this.radix))},e.prototype._padFractionalZeros=function(t){var e=t.split(this.radix);return e.length<2&&e.push(""),e[1]=e[1].padEnd(this.scale,"0"),e.join(this.radix)},rt(e,[{key:"number",get:function(){var t=this._removeThousandsSeparators(this._normalizeZeros(this.unmaskedValue)).replace(this.radix,".");return Number(t)},set:function(t){this.unmaskedValue=(""+t).replace(".",this.radix)}},{key:"allowNegative",get:function(){return this.signed||null!=this.min&&this.min<0||null!=this.max&&this.max<0}}]),e}(ht);ft.DEFAULTS={radix:",",thousandsSeparator:"",mapToRadix:["."],scale:2,signed:!1,postFormat:{normalizeZeros:!0,padFractionalZeros:!1}};var dt=function(){function t(e){it(this,t),ot(this,e),this.mask&&(this._masked=s(e))}return t.prototype.reset=function(){this.isHollow=!1,this._masked&&this._masked.reset()},t.prototype.resolve=function(t){return!!this._masked&&(this._masked.value=t,this._masked.value)},rt(t,[{key:"isInput",get:function(){return this.type===t.TYPES.INPUT}},{key:"isHiddenHollow",get:function(){return this.isHollow&&this.optional}}]),t}();dt.DEFAULTS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./},dt.TYPES={INPUT:"input",FIXED:"fixed"};var vt=function(){function t(e,u){var n=u.name,i=u.offset,r=u.mask,o=u.validate;it(this,t),this.masked=e,this.name=n,this.offset=i,this.mask=r,this.validate=o||function(){return!0}}return t.prototype.doValidate=function(t){return this.validate(this.value,this,t)},rt(t,[{key:"value",get:function(){return this.masked.value.slice(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}},{key:"unmaskedValue",get:function(){return this.masked.extractInput(this.masked.mapDefIndexToPos(this.offset),this.masked.mapDefIndexToPos(this.offset+this.mask.length))}}]),t}(),mt=function(){function t(e){var u=e[0],n=e[1],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(n+"").length;it(this,t),this._from=u,this._to=n,this._maxLength=i,this.validate=this.validate.bind(this),this._update()}return t.prototype._update=function(){this._maxLength=Math.max(this._maxLength,(this.to+"").length),this.mask="0".repeat(this._maxLength)},t.prototype.validate=function(t){var e="",u="",n=t.match(/^(\D*)(\d*)(\D*)/),i=n[1],r=n[2];return r&&(e="0".repeat(i.length)+r,u="9".repeat(i.length)+r),-1===t.search(/[^0]/)&&t.length<=this._matchFrom||(e=e.padEnd(this._maxLength,"0"),u=u.padEnd(this._maxLength,"9"),this.from<=Number(u)&&Number(e)<=this.to)},rt(t,[{key:"to",get:function(){return this._to},set:function(t){this._to=t,this._update()}},{key:"from",get:function(){return this._from},set:function(t){this._from=t,this._update()}},{key:"maxLength",get:function(){return this._maxLength},set:function(t){this._maxLength=t,this._update()}},{key:"_matchFrom",get:function(){return this.maxLength-(this.from+"").length}}]),t}();vt.Range=mt,vt.Enum=function(t){return{mask:"*".repeat(t[0].length),validate:function(e,u){return t.some(function(t){return t.indexOf(u.unmaskedValue)>=0})}}};var At=function(t){function e(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return it(this,e),u.placeholder=ot({},e.DEFAULT_PLACEHOLDER,u.placeholder),u.definitions=ot({},dt.DEFAULTS,u.definitions),at(this,t.call(this,u))}return st(e,t),e.prototype._update=function(e){e.placeholder=ot({},this.placeholder,e.placeholder),e.definitions=ot({},this.definitions,e.definitions),t.prototype._update.call(this,e),this._updateMask()},e.prototype._updateMask=function(){var t=this,u=this.definitions;this._charDefs=[],this._groupDefs=[];var n=this.mask;if(n&&u){var i=!1,r=!1,o=!1;t:for(var s=0;s<n.length;++s)switch(function(a){if(t.groups){var h=n.slice(a),l=Object.keys(t.groups).filter(function(t){return 0===h.indexOf(t)});l.sort(function(t,e){return e.length-t.length});var c=l[0];if(c){var p=t.groups[c];t._groupDefs.push(new vt(t,{name:c,offset:t._charDefs.length,mask:p.mask,validate:p.validate})),n=n.replace(c,p.mask)}}var f=n[a],d=!i&&f in u?dt.TYPES.INPUT:dt.TYPES.FIXED,v=d===dt.TYPES.INPUT||i,m=d===dt.TYPES.INPUT&&r;if(f===e.STOP_CHAR)return o=!0,"continue";if("{"===f||"}"===f)return i=!i,"continue";if("["===f||"]"===f)return r=!r,"continue";if(f===e.ESCAPE_CHAR){if(++a,!(f=n[a]))return"break";d=dt.TYPES.FIXED}t._charDefs.push(new dt({char:f,type:d,optional:m,stopAlign:o,unmasking:v,mask:d===dt.TYPES.INPUT?u[f]:function(t){return t===f}})),o=!1,s=a}(s)){case"continue":continue;case"break":break t}}},e.prototype.doValidate=function(e){return this._groupDefs.every(function(t){return t.doValidate(e)})&&t.prototype.doValidate.call(this,e)},e.prototype.clone=function(){var t=this,u=new e(this);return u._value=this.value,u._charDefs.forEach(function(e,u){return ot(e,t._charDefs[u])}),u._groupDefs.forEach(function(e,u){return ot(e,t._groupDefs[u])}),u},e.prototype.reset=function(){t.prototype.reset.call(this),this._charDefs.forEach(function(t){delete t.isHollow})},e.prototype.hiddenHollowsBefore=function(t){return this._charDefs.slice(0,t).filter(function(t){return t.isHiddenHollow}).length},e.prototype.mapDefIndexToPos=function(t){if(null!=t)return t-this.hiddenHollowsBefore(t)},e.prototype.mapPosToDefIndex=function(t){if(null!=t){for(var e=t,u=0;u<this._charDefs.length;++u){var n=this._charDefs[u];if(u>=e)break;n.isHiddenHollow&&++e}return e}},e.prototype._unmask=function(){for(var t=this.value,e="",u=0,n=0;u<t.length&&n<this._charDefs.length;++n){var i=t[u],r=this._charDefs[n];r.isHiddenHollow||(r.unmasking&&!r.isHollow&&(e+=i),++u)}return e},e.prototype._appendTail=function(t){return(!t||this._appendChunks(t))&&this._appendPlaceholder()},e.prototype._append=function(t,e){for(var n=this.value.length,i=0,r=this.mapPosToDefIndex(this.value.length);i<t.length;){var o=t[i],s=this._charDefs[r];if(!s)return!1;s.isHollow=!1;var a=void 0,h=void 0,l=u(s.resolve(o),o);s.type===dt.TYPES.INPUT?(l&&(this._value+=l,this.doValidate()||(l="",this._value=this.value.slice(0,-1))),a=!!l,h=!l&&!s.optional,l||(s.optional||e||(this._value+=this.placeholder.char,h=!1),h||(s.isHollow=!0))):(this._value+=s.char,a=l&&(s.unmasking||e)),h||++r,(a||h)&&++i}return this.value.length-n},e.prototype._appendChunks=function(t,e){for(var u=0;u<t.length;++u){var n=t[u],i=n[0],r=n[1];if(null!=i&&this._appendPlaceholder(i),!1===this._append(r,e))return!1}return!0},e.prototype.extractTail=function(t,e){return this.extractInputChunks(t,e)},e.prototype.extractInput=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,u=this.value,n="",i=this.mapPosToDefIndex(e),r=t,o=this.mapPosToDefIndex(t);r<e&&r<u.length&&o<i;++o){var s=u[r],a=this._charDefs[o];if(!a)break;a.isHiddenHollow||(a.isInput&&!a.isHollow&&(n+=s),++r)}return n},e.prototype.extractInputChunks=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length,n=this.mapPosToDefIndex(e),i=this.mapPosToDefIndex(u),r=this._charDefs.map(function(t,e){return[t,e]}).slice(n,i).filter(function(t){return t[0].stopAlign}).map(function(t){return t[1]}),o=[n].concat(r,[i]);return o.map(function(e,u){return[r.indexOf(e)>=0?e:null,t.extractInput(t.mapDefIndexToPos(e),t.mapDefIndexToPos(o[++u]))]}).filter(function(t){var e=t[0],u=t[1];return null!=e||u})},e.prototype._appendPlaceholder=function(t){for(var e=t||this._charDefs.length,u=this.mapPosToDefIndex(this.value.length);u<e;++u){var n=this._charDefs[u];n.isInput&&(n.isHollow=!0),this.placeholder.lazy&&!t||(this._value+=n.isInput?n.optional?"":this.placeholder.char:n.char)}},e.prototype.clear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.value.length;this._value=this.value.slice(0,t)+this.value.slice(e);var u=this.mapPosToDefIndex(t),n=this.mapPosToDefIndex(e);this._charDefs.slice(u,n).forEach(function(t){return t.reset()})},e.prototype.nearestInputPos=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt.LEFT;if(!e)return t;var u=this.mapPosToDefIndex(t),i=u,r=void 0,o=void 0,s=void 0,a=void 0;for(a=n(i,e);0<=a&&a<this._charDefs.length;i+=e,a+=e){var h=this._charDefs[a];if(null==r&&h.isInput&&(r=i),null==s&&h.isHollow&&!h.isHiddenHollow&&(s=i),h.isInput&&!h.isHollow){o=i;break}}if(e===lt.LEFT||null==r){var l=!1;for(a=n(i,e=-e);0<=a&&a<this._charDefs.length;i+=e,a+=e){var c=this._charDefs[a];if(c.isInput&&(r=i,c.isHollow&&!c.isHiddenHollow))break;if(i===u&&(l=!0),l&&null!=r)break}(l=l||a>=this._charDefs.length)&&null!=r&&(i=r)}else null==o&&(i=null!=s?s:r);return this.mapDefIndexToPos(i)},e.prototype.group=function(t){return this.groupsByName(t)[0]},e.prototype.groupsByName=function(t){return this._groupDefs.filter(function(e){return e.name===t})},rt(e,[{key:"isComplete",get:function(){var t=this;return!this._charDefs.some(function(e,u){return e.isInput&&!e.optional&&(e.isHollow||!t.extractInput(u,u+1))})}}]),e}(ht);At.DEFAULT_PLACEHOLDER={lazy:!0,char:"_"},At.STOP_CHAR="`",At.ESCAPE_CHAR="\\",At.Definition=dt,At.Group=vt;var gt=function(t){function e(u){return it(this,e),at(this,t.call(this,ot({},e.DEFAULTS,u)))}return st(e,t),e.prototype._update=function(u){u.mask===Date&&delete u.mask,u.pattern&&(u.mask=u.pattern,delete u.pattern);var n=u.groups;u.groups=ot({},e.GET_DEFAULT_GROUPS()),u.min&&(u.groups.Y.from=u.min.getFullYear()),u.max&&(u.groups.Y.to=u.max.getFullYear()),ot(u.groups,n),t.prototype._update.call(this,u)},e.prototype.doValidate=function(e){var u=t.prototype.doValidate.call(this,e),n=this.date;return u&&(!this.isComplete||this.isDateExist(this.value)&&n&&(null==this.min||this.min<=n)&&(null==this.max||n<=this.max))},e.prototype.isDateExist=function(t){return this.format(this.parse(t))===t},rt(e,[{key:"date",get:function(){return this.isComplete?this.parse(this.value):null},set:function(t){this.value=this.format(t)}}]),e}(At);gt.DEFAULTS={pattern:"d{.}`m{.}`Y",format:function(t){return[(""+t.getDate()).padStart(2,"0"),(""+(t.getMonth()+1)).padStart(2,"0"),t.getFullYear()].join(".")},parse:function(t){var e=t.split("."),u=e[0],n=e[1],i=e[2];return new Date(i,n-1,u)}},gt.GET_DEFAULT_GROUPS=function(){return{d:new vt.Range([1,31]),m:new vt.Range([1,12]),Y:new vt.Range([1900,9999])}};var Ft=function(){function t(e,u,n,i){for(it(this,t),this.value=e,this.cursorPos=u,this.oldValue=n,this.oldSelection=i;this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start}return rt(t,[{key:"startChangePos",get:function(){return Math.min(this.cursorPos,this.oldSelection.start)}},{key:"insertedCount",get:function(){return this.cursorPos-this.startChangePos}},{key:"inserted",get:function(){return this.value.substr(this.startChangePos,this.insertedCount)}},{key:"removedCount",get:function(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}},{key:"removed",get:function(){return this.oldValue.substr(this.startChangePos,this.removedCount)}},{key:"head",get:function(){return this.value.substring(0,this.startChangePos)}},{key:"tail",get:function(){this.value.substring(this.startChangePos+this.insertedCount)}},{key:"removeDirection",get:function(){return this.removedCount&&!this.insertedCount&&(this.oldSelection.end===this.cursorPos?lt.RIGHT:lt.LEFT)}}]),t}(),yt=function(){function t(e,u){it(this,t),this.el=e,this.masked=s(u),this._listeners={},this._value="",this._unmaskedValue="",this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this.bindEvents(),this.updateValue(),this._onChange()}return t.prototype.bindEvents=function(){this.el.addEventListener("keydown",this._saveSelection),this.el.addEventListener("input",this._onInput),this.el.addEventListener("drop",this._onDrop),this.el.addEventListener("click",this.alignCursorFriendly),this.el.addEventListener("change",this._onChange)},t.prototype.unbindEvents=function(){this.el.removeEventListener("keydown",this._saveSelection),this.el.removeEventListener("input",this._onInput),this.el.removeEventListener("drop",this._onDrop),this.el.removeEventListener("click",this.alignCursorFriendly),this.el.removeEventListener("change",this._onChange)},t.prototype.fireEvent=function(t){(this._listeners[t]||[]).forEach(function(t){return t()})},t.prototype._saveSelection=function(){this.value!==this.el.value&&console.warn("Uncontrolled input change, refresh mask manually!"),this._selection={start:this.selectionStart,end:this.cursorPos}},t.prototype.updateValue=function(){this.masked.value=this.el.value},t.prototype.updateControl=function(){var t=this.masked.unmaskedValue,e=this.masked.value,u=this.unmaskedValue!==t||this.value!==e;this._unmaskedValue=t,this._value=e,this.el.value!==e&&(this.el.value=e),u&&this._fireChangeEvents()},t.prototype.updateOptions=function(t){(t=ot({},t)).mask===Date&&this.masked instanceof gt&&delete t.mask,r(this.masked,t)||(this.masked.updateOptions(t),this.updateControl())},t.prototype.updateCursor=function(t){null!=t&&(this.cursorPos=t,this._delayUpdateCursor(t))},t.prototype._delayUpdateCursor=function(t){var e=this;this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(function(){e.cursorPos=e._changingCursorPos,e._abortUpdateCursor()},10)},t.prototype._fireChangeEvents=function(){this.fireEvent("accept"),this.masked.isComplete&&this.fireEvent("complete")},t.prototype._abortUpdateCursor=function(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)},t.prototype.alignCursor=function(){this.cursorPos=this.masked.nearestInputPos(this.cursorPos)},t.prototype.alignCursorFriendly=function(){this.selectionStart===this.cursorPos&&this.alignCursor()},t.prototype.on=function(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this},t.prototype.off=function(t,e){if(this._listeners[t]){if(e){var u=this._listeners[t].indexOf(e);return u>=0&&this._listeners.splice(u,1),this}delete this._listeners[t]}},t.prototype._onInput=function(){this._abortUpdateCursor();var t=new Ft(this.el.value,this.cursorPos,this.value,this._selection),e=t.startChangePos+t.removed.length,u=this.masked.extractTail(e),n=this.masked.nearestInputPos(t.startChangePos,t.removeDirection);this.masked.clear(n);var i=this.masked.appendWithTail(t.inserted,u),r=this.masked.nearestInputPos(n+i,t.removeDirection);this.updateControl(),this.updateCursor(r)},t.prototype._onChange=function(){this.value!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl()},t.prototype._onDrop=function(t){t.preventDefault(),t.stopPropagation()},t.prototype.destroy=function(){this.unbindEvents(),this._listeners.length=0},rt(t,[{key:"mask",get:function(){return this.masked.mask},set:function(t){if(null!=t&&t!==this.masked.mask)if(this.masked.constructor!==o(t)){var e=s({mask:t});e.unmaskedValue=this.masked.unmaskedValue,this.masked=e}else this.masked.mask=t}},{key:"value",get:function(){return this._value},set:function(t){this.masked.value=t,this.updateControl(),this.alignCursor()}},{key:"unmaskedValue",get:function(){return this._unmaskedValue},set:function(t){this.masked.unmaskedValue=t,this.updateControl(),this.alignCursor()}},{key:"selectionStart",get:function(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}},{key:"cursorPos",get:function(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd},set:function(t){this.el===document.activeElement&&(this.el.setSelectionRange(t,t),this._saveSelection())}}]),t}();return a.InputMask=yt,a.Masked=ht,a.MaskedPattern=At,a.MaskedNumber=ft,a.MaskedDate=gt,a.MaskedRegExp=ct,a.MaskedFunction=pt,window.IMask=a,a}); | ||
//# sourceMappingURL=imask.min.js.map |
{ | ||
"name": "imask", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "vanilla javascript input mask", | ||
"main": "imask.js", | ||
"dependencies": { | ||
"babel-preset-env": "^1.6.1", | ||
"rollup-plugin-commonjs": "^8.2.5", | ||
"uglify-es": "^3.1.5" | ||
}, | ||
"main": "dist/imask.js", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -18,4 +14,5 @@ "babel-core": "^6.25.0", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-env": "^1.5.2", | ||
"babel-preset-env": "^1.6.1", | ||
"chai": "^4.0.2", | ||
"coveralls": "^3.0.0", | ||
"karma": "^1.7.0", | ||
@@ -34,3 +31,3 @@ "karma-chai": "^0.1.0", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-commonjs": "^8.2.0", | ||
"rollup-plugin-commonjs": "^8.2.6", | ||
"rollup-plugin-eslint": "^4.0.0", | ||
@@ -41,3 +38,3 @@ "rollup-plugin-node-resolve": "^3.0.0", | ||
"sinon": "^4.0.2", | ||
"uglify-es": "^3.0.20" | ||
"uglify-es": "^3.1.6" | ||
}, | ||
@@ -47,3 +44,3 @@ "scripts": { | ||
"watch": "rollup -c -w", | ||
"build": "npm-run-all -l build:*", | ||
"build": "npm run build:dev && npm run build:prod", | ||
"build:dev": "npm-run-all -l build:dev:*", | ||
@@ -54,3 +51,5 @@ "build:prod": "npm-run-all -l build:prod:*", | ||
"build:prod:es": "rollup -c --environment format:es,env:production", | ||
"build:prod:umd": "rollup -c --environment format:umd,env:production" | ||
"build:prod:umd": "rollup -c --environment format:umd,env:production", | ||
"prepublish": "npm run build", | ||
"coveralls": "npm run test && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
@@ -57,0 +56,0 @@ "repository": { |
# imaskjs | ||
vanilla javascript input mask | ||
[![Build Status](https://travis-ci.org/uNmAnNeR/imaskjs.svg?branch=gh-pages)](https://travis-ci.org/uNmAnNeR/imaskjs) | ||
[![Coverage Status](https://coveralls.io/repos/github/uNmAnNeR/imaskjs/badge.svg?branch=gh-pages)](https://coveralls.io/github/uNmAnNeR/imaskjs?branch=gh-pages) | ||
[![npm version](https://badge.fury.io/js/imask.svg)](https://badge.fury.io/js/imask) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
## Features | ||
@@ -5,0 +10,0 @@ * get and set raw and unmasked values easily |
@@ -1,3 +0,5 @@ | ||
import ActionDetails from '../core/action-details'; | ||
import createMask, {maskedClass} from '../masked/factory'; | ||
import {objectIncludes} from '../core/utils.js'; | ||
import ActionDetails from '../core/action-details.js'; | ||
import MaskedDate from '../masked/date.js'; | ||
import createMask, {maskedClass} from '../masked/factory.js'; | ||
@@ -19,4 +21,4 @@ | ||
this._onDrop = this._onDrop.bind(this); | ||
this._alignCursor = this._alignCursor.bind(this); | ||
this._alignCursorFriendly = this._alignCursorFriendly.bind(this); | ||
this.alignCursor = this.alignCursor.bind(this); | ||
this.alignCursorFriendly = this.alignCursorFriendly.bind(this); | ||
@@ -51,3 +53,3 @@ this.bindEvents(); | ||
this.updateControl(); | ||
this._alignCursor(); | ||
this.alignCursor(); | ||
} | ||
@@ -62,3 +64,3 @@ | ||
this.updateControl(); | ||
this._alignCursor(); | ||
this.alignCursor(); | ||
} | ||
@@ -70,3 +72,3 @@ | ||
this.el.addEventListener('drop', this._onDrop); | ||
this.el.addEventListener('click', this._alignCursorFriendly); | ||
this.el.addEventListener('click', this.alignCursorFriendly); | ||
this.el.addEventListener('change', this._onChange); | ||
@@ -79,3 +81,3 @@ } | ||
this.el.removeEventListener('drop', this._onDrop); | ||
this.el.removeEventListener('click', this._alignCursorFriendly); | ||
this.el.removeEventListener('click', this.alignCursorFriendly); | ||
this.el.removeEventListener('change', this._onChange); | ||
@@ -138,2 +140,8 @@ } | ||
updateOptions (opts) { | ||
opts = Object.assign({}, opts); // clone | ||
if (opts.mask === Date && this.masked instanceof MaskedDate) delete opts.mask; | ||
// check if changed | ||
if (objectIncludes(this.masked, opts)) return; | ||
this.masked.updateOptions(opts); | ||
@@ -172,9 +180,9 @@ this.updateControl(); | ||
_alignCursor () { | ||
alignCursor () { | ||
this.cursorPos = this.masked.nearestInputPos(this.cursorPos); | ||
} | ||
_alignCursorFriendly () { | ||
alignCursorFriendly () { | ||
if (this.selectionStart !== this.cursorPos) return; | ||
this._alignCursor(); | ||
this.alignCursor(); | ||
} | ||
@@ -181,0 +189,0 @@ |
@@ -1,2 +0,2 @@ | ||
import {DIRECTION} from './utils'; | ||
import {DIRECTION} from './utils.js'; | ||
@@ -3,0 +3,0 @@ |
@@ -32,1 +32,46 @@ export | ||
} | ||
// cloned from https://github.com/epoberezkin/fast-deep-equal with small changes | ||
export | ||
function objectIncludes (b, a) { | ||
if (a === b) return true; | ||
var arrA = Array.isArray(a) | ||
, arrB = Array.isArray(b) | ||
, i; | ||
if (arrA && arrB) { | ||
if (a.length != b.length) return false; | ||
for (i = 0; i < a.length; i++) | ||
if (!objectIncludes(a[i], b[i])) return false; | ||
return true; | ||
} | ||
if (arrA != arrB) return false; | ||
if (a && b && typeof a === 'object' && typeof b === 'object') { | ||
var keys = Object.keys(a); | ||
// if (keys.length !== Object.keys(b).length) return false; | ||
var dateA = a instanceof Date | ||
, dateB = b instanceof Date; | ||
if (dateA && dateB) return a.getTime() == b.getTime(); | ||
if (dateA != dateB) return false; | ||
var regexpA = a instanceof RegExp | ||
, regexpB = b instanceof RegExp; | ||
if (regexpA && regexpB) return a.toString() == b.toString(); | ||
if (regexpA != regexpB) return false; | ||
for (i = 0; i < keys.length; i++) | ||
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; | ||
for (i = 0; i < keys.length; i++) | ||
if(!objectIncludes(a[keys[i]], b[keys[i]])) return false; | ||
return true; | ||
} | ||
return false; | ||
} |
@@ -1,9 +0,9 @@ | ||
import Masked from './masked/base'; | ||
import MaskedPattern from './masked/pattern'; | ||
import MaskedNumber from './masked/number'; | ||
import MaskedDate from './masked/date'; | ||
import MaskedRegExp from './masked/regexp'; | ||
import MaskedFunction from './masked/function'; | ||
import Masked from './masked/base.js'; | ||
import MaskedPattern from './masked/pattern.js'; | ||
import MaskedNumber from './masked/number.js'; | ||
import MaskedDate from './masked/date.js'; | ||
import MaskedRegExp from './masked/regexp.js'; | ||
import MaskedFunction from './masked/function.js'; | ||
import InputMask from './controls/input'; | ||
import InputMask from './controls/input.js'; | ||
@@ -10,0 +10,0 @@ |
@@ -5,3 +5,3 @@ export default | ||
this._value = ''; | ||
this.updateOptions({ | ||
this._update({ | ||
...Masked.DEFAULTS, | ||
@@ -14,5 +14,9 @@ ...opts | ||
updateOptions (opts) { | ||
this.withValueRefresh(() => Object.assign(this, opts)); | ||
this.withValueRefresh(this._update.bind(this, opts)); | ||
} | ||
_update (opts) { | ||
Object.assign(this, opts); | ||
} | ||
clone () { | ||
@@ -129,10 +133,10 @@ const m = new Masked(this); | ||
withValueRefresh (fn) { | ||
if (this._refreshing) return fn(); | ||
if (this._refreshing || !this.isInitialized) return fn(); | ||
this._refreshing = true; | ||
const unmasked = this.isInitialized ? this.unmaskedValue : null; | ||
const unmasked = this.unmaskedValue; | ||
const ret = fn(); | ||
if (unmasked != null) this.unmaskedValue = unmasked; | ||
this.unmaskedValue = unmasked; | ||
@@ -139,0 +143,0 @@ delete this._refreshing; |
@@ -1,3 +0,3 @@ | ||
import MaskedPattern from './pattern'; | ||
import PatternGroup from './pattern/group'; | ||
import MaskedPattern from './pattern.js'; | ||
import PatternGroup from './pattern/group.js'; | ||
@@ -14,3 +14,3 @@ | ||
updateOptions (opts) { | ||
_update (opts) { | ||
if (opts.mask === Date) delete opts.mask; | ||
@@ -29,3 +29,3 @@ if (opts.pattern) { | ||
super.updateOptions(opts); | ||
super._update(opts); | ||
} | ||
@@ -32,0 +32,0 @@ |
@@ -1,6 +0,6 @@ | ||
import {isString} from '../core/utils'; | ||
import Masked from './base'; | ||
import MaskedRegExp from './regexp'; | ||
import MaskedFunction from './function'; | ||
import MaskedNumber from './number'; | ||
import {isString} from '../core/utils.js'; | ||
import Masked from './base.js'; | ||
import MaskedRegExp from './regexp.js'; | ||
import MaskedFunction from './function.js'; | ||
import MaskedNumber from './number.js'; | ||
@@ -7,0 +7,0 @@ |
@@ -1,2 +0,2 @@ | ||
import Masked from './base'; | ||
import Masked from './base.js'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,3 +0,3 @@ | ||
import {escapeRegExp, DIRECTION, indexInDirection} from '../core/utils'; | ||
import Masked from './base'; | ||
import {escapeRegExp, DIRECTION, indexInDirection} from '../core/utils.js'; | ||
import Masked from './base.js'; | ||
@@ -8,2 +8,3 @@ | ||
constructor (opts) { | ||
opts.postFormat = Object.assign({}, MaskedNumber.DEFAULTS.postFormat, opts.postFormat); | ||
super({ | ||
@@ -15,8 +16,6 @@ ...MaskedNumber.DEFAULTS, | ||
updateOptions (opts) { | ||
opts._signed = opts.signed; | ||
delete opts.signed; | ||
opts.postFormat = Object.assign({}, MaskedNumber.DEFAULTS.postFormat, opts.postFormat); | ||
_update (opts) { | ||
opts.postFormat = Object.assign({}, this.postFormat, opts.postFormat); | ||
super.updateOptions(opts); | ||
super._update(opts); | ||
this._updateRegExps(); | ||
@@ -30,3 +29,3 @@ } | ||
if (this.signed) { | ||
if (this.allowNegative) { | ||
regExpStrSoft += '([+|\\-]?|([+|\\-]?(0|([1-9]+\\d*))))'; | ||
@@ -86,3 +85,2 @@ regExpStr += '[+|\\-]?'; | ||
let beforeTailPos = oldValueLength + appended - removedSeparatorsCount; | ||
this._value = this._insertThousandsSeparators(this.value); | ||
let insertedSeparatorsBeforeTailCount = 0; | ||
@@ -134,16 +132,9 @@ for (let pos = 0; pos <= beforeTailPos; ++pos) { | ||
if (validnum !== number) { | ||
this.unmaskedValue = '' + validnum; | ||
} | ||
if (validnum !== number) this.unmaskedValue = '' + validnum; | ||
let formatted = this.value; | ||
if (this.postFormat.normalizeZeros) { | ||
formatted = this._normalizeZeros(formatted); | ||
} | ||
if (this.postFormat.normalizeZeros) formatted = this._normalizeZeros(formatted); | ||
if (this.postFormat.padFractionalZeros) formatted = this._padFractionalZeros(formatted); | ||
if (this.postFormat.padFractionalZeros) { | ||
formatted = this._padFractionalZeros(formatted); | ||
} | ||
this._value = formatted; | ||
@@ -187,7 +178,7 @@ super.doCommit(); | ||
set number (number) { | ||
this.unmaskedValue = '' + number; | ||
this.unmaskedValue = ('' + number).replace('.', this.radix); | ||
} | ||
get signed () { | ||
return this._signed || | ||
get allowNegative () { | ||
return this.signed || | ||
(this.min != null && this.min < 0) || | ||
@@ -202,5 +193,7 @@ (this.max != null && this.max < 0); | ||
scale: 2, | ||
signed: false, | ||
postFormat: { | ||
normalizeZeros: true, | ||
padFractionalZeros: false | ||
} | ||
}; |
@@ -1,5 +0,5 @@ | ||
import {conform, DIRECTION, indexInDirection} from '../core/utils'; | ||
import Masked from './base'; | ||
import PatternDefinition from './pattern/definition'; | ||
import PatternGroup from './pattern/group'; | ||
import {conform, DIRECTION, indexInDirection} from '../core/utils.js'; | ||
import Masked from './base.js'; | ||
import PatternDefinition from './pattern/definition.js'; | ||
import PatternGroup from './pattern/group.js'; | ||
@@ -9,6 +9,12 @@ | ||
class MaskedPattern extends Masked { | ||
updateOptions (opts) { | ||
constructor (opts={}) { | ||
opts.placeholder = Object.assign({}, MaskedPattern.DEFAULT_PLACEHOLDER, opts.placeholder); | ||
opts.definitions = Object.assign({}, PatternDefinition.DEFAULTS, opts.definitions); | ||
super.updateOptions(opts); | ||
super(opts); | ||
} | ||
_update (opts) { | ||
opts.placeholder = Object.assign({}, this.placeholder, opts.placeholder); | ||
opts.definitions = Object.assign({}, this.definitions, opts.definitions); | ||
super._update(opts); | ||
this._updateMask(); | ||
@@ -29,3 +35,2 @@ } | ||
for (let i=0; i<pattern.length; ++i) { | ||
@@ -189,3 +194,2 @@ if (this.groups) { | ||
// if ok - next di | ||
if (!chres) { | ||
@@ -192,0 +196,0 @@ if (!def.optional && !soft) { |
@@ -1,2 +0,2 @@ | ||
import createMask from '../factory'; | ||
import createMask from '../factory.js'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
import Masked from './base'; | ||
import Masked from './base.js'; | ||
@@ -7,5 +7,5 @@ | ||
constructor (opts={}) { | ||
opts.validate = (value) => opts.mask.test(value); | ||
opts.validate = (value) => value.search(opts.mask) >= 0; | ||
super(opts); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
0
45
0
551546
29
25
4180
1
- Removedbabel-preset-env@^1.6.1
- Removedrollup-plugin-commonjs@^8.2.5
- Removeduglify-es@^3.1.5
- Removedacorn@5.7.4(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-helper-builder-binary-assignment-operator-visitor@6.24.1(transitive)
- Removedbabel-helper-call-delegate@6.24.1(transitive)
- Removedbabel-helper-define-map@6.26.0(transitive)
- Removedbabel-helper-explode-assignable-expression@6.24.1(transitive)
- Removedbabel-helper-function-name@6.24.1(transitive)
- Removedbabel-helper-get-function-arity@6.24.1(transitive)
- Removedbabel-helper-hoist-variables@6.24.1(transitive)
- Removedbabel-helper-optimise-call-expression@6.24.1(transitive)
- Removedbabel-helper-regex@6.26.0(transitive)
- Removedbabel-helper-remap-async-to-generator@6.24.1(transitive)
- Removedbabel-helper-replace-supers@6.24.1(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-check-es2015-constants@6.22.0(transitive)
- Removedbabel-plugin-syntax-async-functions@6.13.0(transitive)
- Removedbabel-plugin-syntax-exponentiation-operator@6.13.0(transitive)
- Removedbabel-plugin-syntax-trailing-function-commas@6.22.0(transitive)
- Removedbabel-plugin-transform-async-to-generator@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-arrow-functions@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-block-scoped-functions@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-block-scoping@6.26.0(transitive)
- Removedbabel-plugin-transform-es2015-classes@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-computed-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-destructuring@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-duplicate-keys@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-for-of@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-function-name@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-literals@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-modules-amd@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-modules-commonjs@6.26.2(transitive)
- Removedbabel-plugin-transform-es2015-modules-systemjs@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-modules-umd@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-object-super@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-parameters@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-shorthand-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-spread@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-sticky-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-template-literals@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-typeof-symbol@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-unicode-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-exponentiation-operator@6.24.1(transitive)
- Removedbabel-plugin-transform-regenerator@6.26.0(transitive)
- Removedbabel-plugin-transform-strict-mode@6.24.1(transitive)
- Removedbabel-preset-env@1.7.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedbrowserslist@3.2.8(transitive)
- Removedcaniuse-lite@1.0.30001660(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcommander@2.14.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removedelectron-to-chromium@1.5.20(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedestree-walker@0.5.20.6.1(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedglobals@9.18.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjsesc@0.5.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedmagic-string@0.22.5(transitive)
- Removedms@2.0.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedprivate@0.1.8(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregenerator-transform@0.10.1(transitive)
- Removedregexpu-core@2.0.0(transitive)
- Removedregjsgen@0.2.0(transitive)
- Removedregjsparser@0.1.5(transitive)
- Removedresolve@1.22.8(transitive)
- Removedrollup-plugin-commonjs@8.4.1(transitive)
- Removedrollup-pluginutils@2.8.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)
- Removeduglify-es@3.3.10(transitive)
- Removedvlq@0.2.3(transitive)