diff --git a/README.md b/README.md index bfc8c60e..c761b30e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Cleave.js has a simple purpose: to help you format input text content automatica - CommonJS / AMD mode - ReactJS component - AngularJS directive (1.x) +- ES Module **TL;DR** [the demo page](http://nosir.github.io/cleave.js/) @@ -64,7 +65,7 @@ var cleave = new Cleave('.input-phone', { }); ``` -> `.input-element` here is a unique DOM element. If you want to apply Cleave for multiple elements, you need to give different CSS selectors and apply to each of them, effectively, you might want to create individual instance by a loop, e.g. [loop solution](https://github.com/nosir/cleave.js/issues/138#issuecomment-268024840) +> `.input-element` here is a unique DOM element. If you want to apply Cleave for multiple elements, you need to give different CSS selectors and apply to each of them, effectively, you might want to create individual instance by a loop, e.g. [loop solution](https://github.com/nosir/cleave.js/issues/138#issuecomment-268024840) More examples: [the demo page](http://nosir.github.io/cleave.js/) @@ -84,17 +85,14 @@ require(['cleave.js/dist/cleave.min', 'cleave.js/dist/addons/cleave-phone.{count }); ``` -#### ES Module (Rollup, WebPack) +#### ES Module ```js +// Rollup, WebPack import Cleave from 'cleave.js'; - var cleave = new Cleave(...) -``` -#### ES Module (Browser) -```js +// Browser import Cleave from 'node_modules/cleave.js/dist/cleave-esm.min.js'; - var cleave = new Cleave(...) ``` diff --git a/bower.json b/bower.json index 6d84ddb5..954d1f3d 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,7 @@ "description": "JavaScript library for formatting input text content when you are typing", "keywords": ["cleave", "javascript", "html", "form", "input"], - "version": "1.5.0", + "version": "1.5.1", "author": { "name": "Max Huang", "email": "risonhuang@gmail.com", diff --git a/dist/cleave-angular.min.js b/dist/cleave-angular.min.js index c3a3f3d1..d61d0c37 100644 --- a/dist/cleave-angular.min.js +++ b/dist/cleave-angular.min.js @@ -1,5 +1,5 @@ /*! - * cleave.js - 1.5.0 + * cleave.js - 1.5.1 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * diff --git a/dist/cleave-esm.js b/dist/cleave-esm.js index 84691cf3..e151ee78 100644 --- a/dist/cleave-esm.js +++ b/dist/cleave-esm.js @@ -6,6 +6,8 @@ var NumeralFormatter = function (numeralDecimalMark, numeralThousandsGroupStyle, numeralPositiveOnly, stripLeadingZeroes, + prefix, + signBeforePrefix, delimiter) { var owner = this; @@ -15,6 +17,8 @@ var NumeralFormatter = function (numeralDecimalMark, owner.numeralThousandsGroupStyle = numeralThousandsGroupStyle || NumeralFormatter.groupStyle.thousand; owner.numeralPositiveOnly = !!numeralPositiveOnly; owner.stripLeadingZeroes = stripLeadingZeroes !== false; + owner.prefix = (prefix || prefix === '') ? prefix : ''; + owner.signBeforePrefix = !!signBeforePrefix; owner.delimiter = (delimiter || delimiter === '') ? delimiter : ','; owner.delimiterRE = delimiter ? new RegExp('\\' + delimiter, 'g') : ''; }; @@ -32,7 +36,7 @@ NumeralFormatter.prototype = { }, format: function (value) { - var owner = this, parts, partInteger, partDecimal = ''; + var owner = this, parts, partSign, partSignAndPrefix, partInteger, partDecimal = ''; // strip alphabet letters value = value.replace(/[A-Za-z]/g, '') @@ -60,6 +64,17 @@ NumeralFormatter.prototype = { value = value.replace(/^(-)?0+(?=\d)/, '$1'); } + partSign = value.slice(0, 1) === '-' ? '-' : ''; + if (typeof owner.prefix != 'undefined') { + if (owner.signBeforePrefix) { + partSignAndPrefix = partSign + owner.prefix; + } else { + partSignAndPrefix = owner.prefix + partSign; + } + } else { + partSignAndPrefix = partSign; + } + partInteger = value; if (value.indexOf(owner.numeralDecimalMark) >= 0) { @@ -68,8 +83,12 @@ NumeralFormatter.prototype = { partDecimal = owner.numeralDecimalMark + parts[1].slice(0, owner.numeralDecimalScale); } + if(partSign === '-') { + partInteger = partInteger.slice(1); + } + if (owner.numeralIntegerScale > 0) { - partInteger = partInteger.slice(0, owner.numeralIntegerScale + (value.slice(0, 1) === '-' ? 1 : 0)); + partInteger = partInteger.slice(0, owner.numeralIntegerScale); } switch (owner.numeralThousandsGroupStyle) { @@ -89,18 +108,34 @@ NumeralFormatter.prototype = { break; } - return partInteger.toString() + (owner.numeralDecimalScale > 0 ? partDecimal.toString() : ''); + return partSignAndPrefix + partInteger.toString() + (owner.numeralDecimalScale > 0 ? partDecimal.toString() : ''); } }; var NumeralFormatter_1 = NumeralFormatter; -var DateFormatter = function (datePattern) { +var DateFormatter = function (datePattern, dateMin, dateMax) { var owner = this; owner.date = []; owner.blocks = []; owner.datePattern = datePattern; + owner.dateMin = dateMin + .split('-') + .reverse() + .map(function(x) { + return parseInt(x, 10); + }); + if (owner.dateMin.length === 2) owner.dateMin.unshift(0); + + owner.dateMax = dateMax + .split('-') + .reverse() + .map(function(x) { + return parseInt(x, 10); + }); + if (owner.dateMax.length === 2) owner.dateMax.unshift(0); + owner.initBlocks(); }; @@ -219,18 +254,77 @@ DateFormatter.prototype = { date = this.getFixedDate(day, month, year); } + // mm-yy || yy-mm + if (value.length === 4 && (datePattern[0] === 'y' || datePattern[1] === 'y')) { + monthStartIndex = datePattern[0] === 'm' ? 0 : 2; + yearStartIndex = 2 - monthStartIndex; + month = parseInt(value.slice(monthStartIndex, monthStartIndex + 2), 10); + year = parseInt(value.slice(yearStartIndex, yearStartIndex + 2), 10); + + fullYearDone = value.slice(yearStartIndex, yearStartIndex + 2).length === 2; + + date = [0, month, year]; + } + + // mm-yyyy || yyyy-mm + if (value.length === 6 && (datePattern[0] === 'Y' || datePattern[1] === 'Y')) { + monthStartIndex = datePattern[0] === 'm' ? 0 : 4; + yearStartIndex = 2 - 0.5 * monthStartIndex; + month = parseInt(value.slice(monthStartIndex, monthStartIndex + 2), 10); + year = parseInt(value.slice(yearStartIndex, yearStartIndex + 4), 10); + + fullYearDone = value.slice(yearStartIndex, yearStartIndex + 4).length === 4; + + date = [0, month, year]; + } + + date = owner.getRangeFixedDate(date); owner.date = date; - return date.length === 0 ? value : datePattern.reduce(function (previous, current) { + var result = date.length === 0 ? value : datePattern.reduce(function (previous, current) { switch (current) { case 'd': - return previous + owner.addLeadingZero(date[0]); + return previous + (date[0] === 0 ? '' : owner.addLeadingZero(date[0])); case 'm': - return previous + owner.addLeadingZero(date[1]); - default: - return previous + (fullYearDone ? owner.addLeadingZeroForYear(date[2]) : ''); + return previous + (date[1] === 0 ? '' : owner.addLeadingZero(date[1])); + case 'y': + return previous + (fullYearDone ? owner.addLeadingZeroForYear(date[2], false) : ''); + case 'Y': + return previous + (fullYearDone ? owner.addLeadingZeroForYear(date[2], true) : ''); } }, ''); + + return result; + }, + + getRangeFixedDate: function (date) { + var owner = this, + datePattern = owner.datePattern, + dateMin = owner.dateMin || [], + dateMax = owner.dateMax || []; + + if (!date.length || (dateMin.length < 3 && dateMax.length < 3)) return date; + + if ( + datePattern.find(function(x) { + return x.toLowerCase() === 'y'; + }) && + date[2] === 0 + ) return date; + + if (dateMax.length && (dateMax[2] < date[2] || ( + dateMax[2] === date[2] && (dateMax[1] < date[1] || ( + dateMax[1] === date[1] && dateMax[0] < date[0] + )) + ))) return dateMax; + + if (dateMin.length && (dateMin[2] > date[2] || ( + dateMin[2] === date[2] && (dateMin[1] > date[1] || ( + dateMin[1] === date[1] && dateMin[0] > date[0] + )) + ))) return dateMin; + + return date; }, getFixedDate: function (day, month, year) { @@ -253,8 +347,12 @@ DateFormatter.prototype = { return (number < 10 ? '0' : '') + number; }, - addLeadingZeroForYear: function (number) { - return (number < 10 ? '000' : (number < 100 ? '00' : (number < 1000 ? '0' : ''))) + number; + addLeadingZeroForYear: function (number, fullYearMode) { + if (fullYearMode) { + return (number < 10 ? '000' : (number < 100 ? '00' : (number < 1000 ? '0' : ''))) + number; + } + + return (number < 10 ? '0' : '') + number; } }; @@ -511,8 +609,7 @@ var CreditCardDetector = { visa: [4, 4, 4, 4], mir: [4, 4, 4, 4], unionPay: [4, 4, 4, 4], - general: [4, 4, 4, 4], - generalStrict: [4, 4, 4, 7] + general: [4, 4, 4, 4] }, re: { @@ -556,6 +653,14 @@ var CreditCardDetector = { unionPay: /^62\d{0,14}/ }, + getStrictBlocks: function (block) { + var total = block.reduce(function (prev, current) { + return prev + current; + }, 0); + + return block.concat(19 - total); + }, + getInfo: function (value, strictMode) { var blocks = CreditCardDetector.blocks, re = CreditCardDetector.re; @@ -568,24 +673,17 @@ var CreditCardDetector = { for (var key in re) { if (re[key].test(value)) { - var block; - - if (strictMode) { - block = blocks.generalStrict; - } else { - block = blocks[key]; - } - + var matchedBlocks = blocks[key]; return { type: key, - blocks: block + blocks: strictMode ? this.getStrictBlocks(matchedBlocks) : matchedBlocks }; } } return { - type: 'unknown', - blocks: strictMode ? blocks.generalStrict : blocks.general + type: 'unknown', + blocks: strictMode ? this.getStrictBlocks(blocks.general) : blocks.general }; } }; @@ -778,6 +876,18 @@ var Util = { }, 1); }, + // Check if input field is fully selected + checkFullSelection: function(value) { + try { + var selection = window.getSelection() || document.getSelection() || {}; + return selection.toString().length === value.length; + } catch (ex) { + // Ignore + } + + return false; + }, + setSelection: function (element, position, doc) { if (element !== this.getActiveElement(doc)) { return; @@ -862,6 +972,8 @@ var DefaultProperties = { // date target.date = !!opts.date; target.datePattern = opts.datePattern || ['d', 'm', 'Y']; + target.dateMin = opts.dateMin || ''; + target.dateMax = opts.dateMax || ''; target.dateFormatter = {}; // numeral @@ -872,6 +984,7 @@ var DefaultProperties = { target.numeralThousandsGroupStyle = opts.numeralThousandsGroupStyle || 'thousand'; target.numeralPositiveOnly = !!opts.numeralPositiveOnly; target.stripLeadingZeroes = opts.stripLeadingZeroes !== false; + target.signBeforePrefix = !!opts.signBeforePrefix; // others target.numericOnly = target.creditCard || target.date || !!opts.numericOnly; @@ -1014,6 +1127,8 @@ Cleave.prototype = { pps.numeralThousandsGroupStyle, pps.numeralPositiveOnly, pps.stripLeadingZeroes, + pps.prefix, + pps.signBeforePrefix, pps.delimiter ); }, @@ -1038,7 +1153,7 @@ Cleave.prototype = { return; } - pps.dateFormatter = new Cleave.DateFormatter(pps.datePattern); + pps.dateFormatter = new Cleave.DateFormatter(pps.datePattern, pps.dateMin, pps.dateMax); pps.blocks = pps.dateFormatter.getBlocks(); pps.blocksLength = pps.blocks.length; pps.maxLength = Cleave.Util.getMaxLength(pps.blocks); @@ -1101,11 +1216,13 @@ Cleave.prototype = { }, onCut: function (e) { + if (!Cleave.Util.checkFullSelection(this.element.value)) return; this.copyClipboardData(e); this.onInput(''); }, onCopy: function (e) { + if (!Cleave.Util.checkFullSelection(this.element.value)) return; this.copyClipboardData(e); }, @@ -1163,8 +1280,10 @@ Cleave.prototype = { // numeral formatter if (pps.numeral) { - if (pps.prefix && (!pps.noImmediatePrefix || value.length)) { - pps.result = pps.prefix + pps.numeralFormatter.format(value); + // Do not show prefix when noImmediatePrefix is specified + // This mostly because we need to show user the native input placeholder + if (pps.prefix && pps.noImmediatePrefix && value.length === 0) { + pps.result = ''; } else { pps.result = pps.numeralFormatter.format(value); } diff --git a/dist/cleave-esm.min.js b/dist/cleave-esm.min.js index a9318ae6..37353407 100644 --- a/dist/cleave-esm.min.js +++ b/dist/cleave-esm.min.js @@ -1 +1 @@ -var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(e,i,r,n,a,s,o){this.numeralDecimalMark=e||".",this.numeralIntegerScale=i>0?i:0,this.numeralDecimalScale=r>=0?r:2,this.numeralThousandsGroupStyle=n||t.groupStyle.thousand,this.numeralPositiveOnly=!!a,this.stripLeadingZeroes=!1!==s,this.delimiter=o||""===o?o:",",this.delimiterRE=o?new RegExp("\\"+o,"g"):""};t.groupStyle={thousand:"thousand",lakh:"lakh",wan:"wan",none:"none"},t.prototype={getRawValue:function(e){return e.replace(this.delimiterRE,"").replace(this.numeralDecimalMark,".")},format:function(e){var i,r,n="";switch(e=e.replace(/[A-Za-z]/g,"").replace(this.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",this.numeralPositiveOnly?"":"-").replace("M",this.numeralDecimalMark),this.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),r=e,e.indexOf(this.numeralDecimalMark)>=0&&(r=(i=e.split(this.numeralDecimalMark))[0],n=this.numeralDecimalMark+i[1].slice(0,this.numeralDecimalScale)),this.numeralIntegerScale>0&&(r=r.slice(0,this.numeralIntegerScale+("-"===e.slice(0,1)?1:0))),this.numeralThousandsGroupStyle){case t.groupStyle.lakh:r=r.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+this.delimiter);break;case t.groupStyle.wan:r=r.replace(/(\d)(?=(\d{4})+$)/g,"$1"+this.delimiter);break;case t.groupStyle.thousand:r=r.replace(/(\d)(?=(\d{3})+$)/g,"$1"+this.delimiter)}return r.toString()+(this.numeralDecimalScale>0?n.toString():"")}};var i=t,r=function(e){this.date=[],this.blocks=[],this.datePattern=e,this.initBlocks()};r.prototype={initBlocks:function(){var e=this;e.datePattern.forEach(function(t){"Y"===t?e.blocks.push(4):e.blocks.push(2)})},getISOFormatDate:function(){var e=this.date;return e[2]?e[2]+"-"+this.addLeadingZero(e[1])+"-"+this.addLeadingZero(e[0]):""},getBlocks:function(){return this.blocks},getValidatedDate:function(e){var t=this,i="";return e=e.replace(/[^\d]/g,""),t.blocks.forEach(function(r,n){if(e.length>0){var a=e.slice(0,r),s=a.slice(0,1),o=e.slice(r);switch(t.datePattern[n]){case"d":"00"===a?a="01":parseInt(s,10)>3?a="0"+s:parseInt(a,10)>31&&(a="31");break;case"m":"00"===a?a="01":parseInt(s,10)>1?a="0"+s:parseInt(a,10)>12&&(a="12")}i+=a,e=o}}),this.getFixedDateString(i)},getFixedDateString:function(e){var t,i,r,n=this,a=n.datePattern,s=[],o=0,l=0,c=0,u=0,m=0,d=0,h=!1;return 4===e.length&&"y"!==a[0].toLowerCase()&&"y"!==a[1].toLowerCase()&&(m=2-(u="d"===a[0]?0:2),t=parseInt(e.slice(u,u+2),10),i=parseInt(e.slice(m,m+2),10),s=this.getFixedDate(t,i,0)),8===e.length&&(a.forEach(function(e,t){switch(e){case"d":o=t;break;case"m":l=t;break;default:c=t}}),d=2*c,u=o<=c?2*o:2*o+2,m=l<=c?2*l:2*l+2,t=parseInt(e.slice(u,u+2),10),i=parseInt(e.slice(m,m+2),10),r=parseInt(e.slice(d,d+4),10),h=4===e.slice(d,d+4).length,s=this.getFixedDate(t,i,r)),n.date=s,0===s.length?e:a.reduce(function(e,t){switch(t){case"d":return e+n.addLeadingZero(s[0]);case"m":return e+n.addLeadingZero(s[1]);default:return e+(h?n.addLeadingZeroForYear(s[2]):"")}},"")},getFixedDate:function(e,t,i){return e=Math.min(e,31),t=Math.min(t,12),i=parseInt(i||0,10),(t<7&&t%2==0||t>8&&t%2==1)&&(e=Math.min(e,2===t?this.isLeapYear(i)?29:28:30)),[e,t,i]},isLeapYear:function(e){return e%4==0&&e%100!=0||e%400==0},addLeadingZero:function(e){return(e<10?"0":"")+e},addLeadingZeroForYear:function(e){return(e<10?"000":e<100?"00":e<1e3?"0":"")+e}};var n=r,a=function(e,t){this.time=[],this.blocks=[],this.timePattern=e,this.timeFormat=t,this.initBlocks()};a.prototype={initBlocks:function(){var e=this;e.timePattern.forEach(function(){e.blocks.push(2)})},getISOFormatTime:function(){var e=this.time;return e[2]?this.addLeadingZero(e[0])+":"+this.addLeadingZero(e[1])+":"+this.addLeadingZero(e[2]):""},getBlocks:function(){return this.blocks},getTimeFormatOptions:function(){return"12"===String(this.timeFormat)?{maxHourFirstDigit:1,maxHours:12,maxMinutesFirstDigit:5,maxMinutes:60}:{maxHourFirstDigit:2,maxHours:23,maxMinutesFirstDigit:5,maxMinutes:60}},getValidatedTime:function(e){var t=this,i="";e=e.replace(/[^\d]/g,"");var r=t.getTimeFormatOptions();return t.blocks.forEach(function(n,a){if(e.length>0){var s=e.slice(0,n),o=s.slice(0,1),l=e.slice(n);switch(t.timePattern[a]){case"h":parseInt(o,10)>r.maxHourFirstDigit?s="0"+o:parseInt(s,10)>r.maxHours&&(s=r.maxHours+"");break;case"m":case"s":parseInt(o,10)>r.maxMinutesFirstDigit?s="0"+o:parseInt(s,10)>r.maxMinutes&&(s=r.maxMinutes+"")}i+=s,e=l}}),this.getFixedTimeString(i)},getFixedTimeString:function(e){var t,i,r,n=this,a=n.timePattern,s=[],o=0,l=0,c=0,u=0,m=0,d=0;return 6===e.length&&(a.forEach(function(e,t){switch(e){case"s":o=2*t;break;case"m":l=2*t;break;case"h":c=2*t}}),d=c,m=l,u=o,t=parseInt(e.slice(u,u+2),10),i=parseInt(e.slice(m,m+2),10),r=parseInt(e.slice(d,d+2),10),s=this.getFixedTime(r,i,t)),4===e.length&&n.timePattern.indexOf("s")<0&&(a.forEach(function(e,t){switch(e){case"m":l=2*t;break;case"h":c=2*t}}),d=c,m=l,t=0,i=parseInt(e.slice(m,m+2),10),r=parseInt(e.slice(d,d+2),10),s=this.getFixedTime(r,i,t)),n.time=s,0===s.length?e:a.reduce(function(e,t){switch(t){case"s":return e+n.addLeadingZero(s[2]);case"m":return e+n.addLeadingZero(s[1]);case"h":return e+n.addLeadingZero(s[0])}},"")},getFixedTime:function(e,t,i){return i=Math.min(parseInt(i||0,10),60),t=Math.min(t,60),[e=Math.min(e,60),t,i]},addLeadingZero:function(e){return(e<10?"0":"")+e}};var s=a,o=function(e,t){this.delimiter=t||""===t?t:" ",this.delimiterRE=t?new RegExp("\\"+t,"g"):"",this.formatter=e};o.prototype={setFormatter:function(e){this.formatter=e},format:function(e){this.formatter.clear();for(var t,i="",r=!1,n=0,a=(e=(e=(e=e.replace(/[^\d+]/g,"")).replace(/^\+/,"B").replace(/\+/g,"").replace("B","+")).replace(this.delimiterRE,"")).length;n0;return 0===i?e:(t.forEach(function(t,c){if(e.length>0){var u=e.slice(0,t),m=e.slice(t);s=l?n[a?c-1:c]||s:r,a?(c>0&&(o+=s),o+=u):(o+=u,u.length===t&&c0?i.numeralIntegerScale:0,t.numeralDecimalScale=i.numeralDecimalScale>=0?i.numeralDecimalScale:2,t.numeralDecimalMark=i.numeralDecimalMark||".",t.numeralThousandsGroupStyle=i.numeralThousandsGroupStyle||"thousand",t.numeralPositiveOnly=!!i.numeralPositiveOnly,t.stripLeadingZeroes=!1!==i.stripLeadingZeroes,t.numericOnly=t.creditCard||t.date||!!i.numericOnly,t.uppercase=!!i.uppercase,t.lowercase=!!i.lowercase,t.prefix=t.creditCard||t.date?"":i.prefix||"",t.noImmediatePrefix=!!i.noImmediatePrefix,t.prefixLength=t.prefix.length,t.rawValueTrimPrefix=!!i.rawValueTrimPrefix,t.copyDelimiter=!!i.copyDelimiter,t.initValue=void 0!==i.initValue&&null!==i.initValue?i.initValue.toString():"",t.delimiter=i.delimiter||""===i.delimiter?i.delimiter:i.date?"/":i.time?":":i.numeral?",":(i.phone," "),t.delimiterLength=t.delimiter.length,t.delimiterLazyShow=!!i.delimiterLazyShow,t.delimiters=i.delimiters||[],t.blocks=i.blocks||[],t.blocksLength=t.blocks.length,t.root="object"==typeof e&&e?e:window,t.document=i.document||t.root.document,t.maxLength=0,t.backspace=!1,t.result="",t.onValueChanged=i.onValueChanged||function(){},t}},h=function(e,t){var i=!1;if("string"==typeof e?(this.element=document.querySelector(e),i=document.querySelectorAll(e).length>1):void 0!==e.length&&e.length>0?(this.element=e[0],i=e.length>1):this.element=e,!this.element)throw new Error("[cleave.js] Please check the element");if(i)try{console.warn("[cleave.js] Multiple input fields matched, cleave.js will only take the first one.")}catch(e){}t.initValue=this.element.value,this.properties=h.DefaultProperties.assign({},t),this.init()};h.prototype={init:function(){var e=this.properties;e.numeral||e.phone||e.creditCard||e.time||e.date||0!==e.blocksLength||e.prefix?(e.maxLength=h.Util.getMaxLength(e.blocks),this.isAndroid=h.Util.isAndroid(),this.lastInputValue="",this.onChangeListener=this.onChange.bind(this),this.onKeyDownListener=this.onKeyDown.bind(this),this.onFocusListener=this.onFocus.bind(this),this.onCutListener=this.onCut.bind(this),this.onCopyListener=this.onCopy.bind(this),this.element.addEventListener("input",this.onChangeListener),this.element.addEventListener("keydown",this.onKeyDownListener),this.element.addEventListener("focus",this.onFocusListener),this.element.addEventListener("cut",this.onCutListener),this.element.addEventListener("copy",this.onCopyListener),this.initPhoneFormatter(),this.initDateFormatter(),this.initTimeFormatter(),this.initNumeralFormatter(),(e.initValue||e.prefix&&!e.noImmediatePrefix)&&this.onInput(e.initValue)):this.onInput(e.initValue)},initNumeralFormatter:function(){var e=this.properties;e.numeral&&(e.numeralFormatter=new h.NumeralFormatter(e.numeralDecimalMark,e.numeralIntegerScale,e.numeralDecimalScale,e.numeralThousandsGroupStyle,e.numeralPositiveOnly,e.stripLeadingZeroes,e.delimiter))},initTimeFormatter:function(){var e=this.properties;e.time&&(e.timeFormatter=new h.TimeFormatter(e.timePattern,e.timeFormat),e.blocks=e.timeFormatter.getBlocks(),e.blocksLength=e.blocks.length,e.maxLength=h.Util.getMaxLength(e.blocks))},initDateFormatter:function(){var e=this.properties;e.date&&(e.dateFormatter=new h.DateFormatter(e.datePattern),e.blocks=e.dateFormatter.getBlocks(),e.blocksLength=e.blocks.length,e.maxLength=h.Util.getMaxLength(e.blocks))},initPhoneFormatter:function(){var e=this.properties;if(e.phone)try{e.phoneFormatter=new h.PhoneFormatter(new e.root.Cleave.AsYouTypeFormatter(e.phoneRegionCode),e.delimiter)}catch(e){throw new Error("[cleave.js] Please include phone-type-formatter.{country}.js lib")}},onKeyDown:function(e){var t=this.properties,i=e.which||e.keyCode,r=h.Util,n=this.element.value;this.hasBackspaceSupport=this.hasBackspaceSupport||8===i,!this.hasBackspaceSupport&&r.isAndroidBackspaceKeydown(this.lastInputValue,n)&&(i=8),this.lastInputValue=n;var a=r.getPostDelimiter(n,t.delimiter,t.delimiters);t.postDelimiterBackspace=!(8!==i||!a)&&a},onChange:function(){this.onInput(this.element.value)},onFocus:function(){var e=this.properties;h.Util.fixPrefixCursor(this.element,e.prefix,e.delimiter,e.delimiters)},onCut:function(e){this.copyClipboardData(e),this.onInput("")},onCopy:function(e){this.copyClipboardData(e)},copyClipboardData:function(e){var t=this.properties,i=h.Util,r=this.element.value,n="";n=t.copyDelimiter?r:i.stripDelimiters(r,t.delimiter,t.delimiters);try{e.clipboardData?e.clipboardData.setData("Text",n):window.clipboardData.setData("Text",n),e.preventDefault()}catch(e){}},onInput:function(e){var t=this.properties,i=h.Util,r=i.getPostDelimiter(e,t.delimiter,t.delimiters);return t.numeral||!t.postDelimiterBackspace||r||(e=i.headStr(e,e.length-t.postDelimiterBackspace.length)),t.phone?(!t.prefix||t.noImmediatePrefix&&!e.length?t.result=t.phoneFormatter.format(e):t.result=t.prefix+t.phoneFormatter.format(e).slice(t.prefix.length),void this.updateValueState()):t.numeral?(!t.prefix||t.noImmediatePrefix&&!e.length?t.result=t.numeralFormatter.format(e):t.result=t.prefix+t.numeralFormatter.format(e),void this.updateValueState()):(t.date&&(e=t.dateFormatter.getValidatedDate(e)),t.time&&(e=t.timeFormatter.getValidatedTime(e)),e=i.stripDelimiters(e,t.delimiter,t.delimiters),e=i.getPrefixStrippedValue(e,t.prefix,t.prefixLength,t.result,t.delimiter,t.delimiters),e=t.numericOnly?i.strip(e,/[^\d]/g):e,e=t.uppercase?e.toUpperCase():e,e=t.lowercase?e.toLowerCase():e,!t.prefix||t.noImmediatePrefix&&!e.length||(e=t.prefix+e,0!==t.blocksLength)?(t.creditCard&&this.updateCreditCardPropsByValue(e),e=i.headStr(e,t.maxLength),t.result=i.getFormattedValue(e,t.blocks,t.blocksLength,t.delimiter,t.delimiters,t.delimiterLazyShow),void this.updateValueState()):(t.result=e,void this.updateValueState()))},updateCreditCardPropsByValue:function(e){var t,i=this.properties,r=h.Util;r.headStr(i.result,4)!==r.headStr(e,4)&&(t=h.CreditCardDetector.getInfo(e,i.creditCardStrictMode),i.blocks=t.blocks,i.blocksLength=i.blocks.length,i.maxLength=r.getMaxLength(i.blocks),i.creditCardType!==t.type&&(i.creditCardType=t.type,i.onCreditCardTypeChanged.call(this,i.creditCardType)))},updateValueState:function(){var e=this,t=h.Util,i=e.properties;if(e.element){var r=e.element.selectionEnd,n=e.element.value,a=i.result;r=t.getNextCursorPosition(r,n,a,i.delimiter,i.delimiters),e.isAndroid?window.setTimeout(function(){e.element.value=a,t.setSelection(e.element,r,i.document,!1),e.callOnValueChanged()},1):(e.element.value=a,t.setSelection(e.element,r,i.document,!1),e.callOnValueChanged())}},callOnValueChanged:function(){var e=this.properties;e.onValueChanged.call(this,{target:{value:e.result,rawValue:this.getRawValue()}})},setPhoneRegionCode:function(e){this.properties.phoneRegionCode=e,this.initPhoneFormatter(),this.onChange()},setRawValue:function(e){var t=this.properties;e=null!=e?e.toString():"",t.numeral&&(e=e.replace(".",t.numeralDecimalMark)),t.postDelimiterBackspace=!1,this.element.value=e,this.onInput(e)},getRawValue:function(){var e=this.properties,t=h.Util,i=this.element.value;return e.rawValueTrimPrefix&&(i=t.getPrefixStrippedValue(i,e.prefix,e.prefixLength,e.result,e.delimiter,e.delimiters)),i=e.numeral?e.numeralFormatter.getRawValue(i):t.stripDelimiters(i,e.delimiter,e.delimiters)},getISOFormatDate:function(){var e=this.properties;return e.date?e.dateFormatter.getISOFormatDate():""},getISOFormatTime:function(){var e=this.properties;return e.time?e.timeFormatter.getISOFormatTime():""},getFormattedValue:function(){return this.element.value},destroy:function(){this.element.removeEventListener("input",this.onChangeListener),this.element.removeEventListener("keydown",this.onKeyDownListener),this.element.removeEventListener("focus",this.onFocusListener),this.element.removeEventListener("cut",this.onCutListener),this.element.removeEventListener("copy",this.onCopyListener)},toString:function(){return"[Cleave Object]"}},h.NumeralFormatter=i,h.DateFormatter=n,h.TimeFormatter=s,h.PhoneFormatter=l,h.CreditCardDetector=u,h.Util=m,h.DefaultProperties=d,("object"==typeof e&&e?e:window).Cleave=h;export default h; \ No newline at end of file +var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(e,i,r,n,a,s,o,l,c){this.numeralDecimalMark=e||".",this.numeralIntegerScale=i>0?i:0,this.numeralDecimalScale=r>=0?r:2,this.numeralThousandsGroupStyle=n||t.groupStyle.thousand,this.numeralPositiveOnly=!!a,this.stripLeadingZeroes=!1!==s,this.prefix=o||""===o?o:"",this.signBeforePrefix=!!l,this.delimiter=c||""===c?c:",",this.delimiterRE=c?new RegExp("\\"+c,"g"):""};t.groupStyle={thousand:"thousand",lakh:"lakh",wan:"wan",none:"none"},t.prototype={getRawValue:function(e){return e.replace(this.delimiterRE,"").replace(this.numeralDecimalMark,".")},format:function(e){var i,r,n,a,s="";switch(e=e.replace(/[A-Za-z]/g,"").replace(this.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",this.numeralPositiveOnly?"":"-").replace("M",this.numeralDecimalMark),this.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),r="-"===e.slice(0,1)?"-":"",n=void 0!==this.prefix?this.signBeforePrefix?r+this.prefix:this.prefix+r:r,a=e,e.indexOf(this.numeralDecimalMark)>=0&&(a=(i=e.split(this.numeralDecimalMark))[0],s=this.numeralDecimalMark+i[1].slice(0,this.numeralDecimalScale)),"-"===r&&(a=a.slice(1)),this.numeralIntegerScale>0&&(a=a.slice(0,this.numeralIntegerScale)),this.numeralThousandsGroupStyle){case t.groupStyle.lakh:a=a.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+this.delimiter);break;case t.groupStyle.wan:a=a.replace(/(\d)(?=(\d{4})+$)/g,"$1"+this.delimiter);break;case t.groupStyle.thousand:a=a.replace(/(\d)(?=(\d{3})+$)/g,"$1"+this.delimiter)}return n+a.toString()+(this.numeralDecimalScale>0?s.toString():"")}};var i=t,r=function(e,t,i){this.date=[],this.blocks=[],this.datePattern=e,this.dateMin=t.split("-").reverse().map(function(e){return parseInt(e,10)}),2===this.dateMin.length&&this.dateMin.unshift(0),this.dateMax=i.split("-").reverse().map(function(e){return parseInt(e,10)}),2===this.dateMax.length&&this.dateMax.unshift(0),this.initBlocks()};r.prototype={initBlocks:function(){var e=this;e.datePattern.forEach(function(t){"Y"===t?e.blocks.push(4):e.blocks.push(2)})},getISOFormatDate:function(){var e=this.date;return e[2]?e[2]+"-"+this.addLeadingZero(e[1])+"-"+this.addLeadingZero(e[0]):""},getBlocks:function(){return this.blocks},getValidatedDate:function(e){var t=this,i="";return e=e.replace(/[^\d]/g,""),t.blocks.forEach(function(r,n){if(e.length>0){var a=e.slice(0,r),s=a.slice(0,1),o=e.slice(r);switch(t.datePattern[n]){case"d":"00"===a?a="01":parseInt(s,10)>3?a="0"+s:parseInt(a,10)>31&&(a="31");break;case"m":"00"===a?a="01":parseInt(s,10)>1?a="0"+s:parseInt(a,10)>12&&(a="12")}i+=a,e=o}}),this.getFixedDateString(i)},getFixedDateString:function(e){var t,i,r,n=this,a=n.datePattern,s=[],o=0,l=0,c=0,u=0,h=0,d=0,m=!1;return 4===e.length&&"y"!==a[0].toLowerCase()&&"y"!==a[1].toLowerCase()&&(h=2-(u="d"===a[0]?0:2),t=parseInt(e.slice(u,u+2),10),i=parseInt(e.slice(h,h+2),10),s=this.getFixedDate(t,i,0)),8===e.length&&(a.forEach(function(e,t){switch(e){case"d":o=t;break;case"m":l=t;break;default:c=t}}),d=2*c,u=o<=c?2*o:2*o+2,h=l<=c?2*l:2*l+2,t=parseInt(e.slice(u,u+2),10),i=parseInt(e.slice(h,h+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,s=this.getFixedDate(t,i,r)),4!==e.length||"y"!==a[0]&&"y"!==a[1]||(d=2-(h="m"===a[0]?0:2),i=parseInt(e.slice(h,h+2),10),r=parseInt(e.slice(d,d+2),10),m=2===e.slice(d,d+2).length,s=[0,i,r]),6!==e.length||"Y"!==a[0]&&"Y"!==a[1]||(d=2-.5*(h="m"===a[0]?0:4),i=parseInt(e.slice(h,h+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,s=[0,i,r]),s=n.getRangeFixedDate(s),n.date=s,0===s.length?e:a.reduce(function(e,t){switch(t){case"d":return e+(0===s[0]?"":n.addLeadingZero(s[0]));case"m":return e+(0===s[1]?"":n.addLeadingZero(s[1]));case"y":return e+(m?n.addLeadingZeroForYear(s[2],!1):"");case"Y":return e+(m?n.addLeadingZeroForYear(s[2],!0):"")}},"")},getRangeFixedDate:function(e){var t=this.datePattern,i=this.dateMin||[],r=this.dateMax||[];return!e.length||i.length<3&&r.length<3?e:t.find(function(e){return"y"===e.toLowerCase()})&&0===e[2]?e:r.length&&(r[2]e[2]||i[2]===e[2]&&(i[1]>e[1]||i[1]===e[1]&&i[0]>e[0]))?i:e},getFixedDate:function(e,t,i){return e=Math.min(e,31),t=Math.min(t,12),i=parseInt(i||0,10),(t<7&&t%2==0||t>8&&t%2==1)&&(e=Math.min(e,2===t?this.isLeapYear(i)?29:28:30)),[e,t,i]},isLeapYear:function(e){return e%4==0&&e%100!=0||e%400==0},addLeadingZero:function(e){return(e<10?"0":"")+e},addLeadingZeroForYear:function(e,t){return t?(e<10?"000":e<100?"00":e<1e3?"0":"")+e:(e<10?"0":"")+e}};var n=r,a=function(e,t){this.time=[],this.blocks=[],this.timePattern=e,this.timeFormat=t,this.initBlocks()};a.prototype={initBlocks:function(){var e=this;e.timePattern.forEach(function(){e.blocks.push(2)})},getISOFormatTime:function(){var e=this.time;return e[2]?this.addLeadingZero(e[0])+":"+this.addLeadingZero(e[1])+":"+this.addLeadingZero(e[2]):""},getBlocks:function(){return this.blocks},getTimeFormatOptions:function(){return"12"===String(this.timeFormat)?{maxHourFirstDigit:1,maxHours:12,maxMinutesFirstDigit:5,maxMinutes:60}:{maxHourFirstDigit:2,maxHours:23,maxMinutesFirstDigit:5,maxMinutes:60}},getValidatedTime:function(e){var t=this,i="";e=e.replace(/[^\d]/g,"");var r=t.getTimeFormatOptions();return t.blocks.forEach(function(n,a){if(e.length>0){var s=e.slice(0,n),o=s.slice(0,1),l=e.slice(n);switch(t.timePattern[a]){case"h":parseInt(o,10)>r.maxHourFirstDigit?s="0"+o:parseInt(s,10)>r.maxHours&&(s=r.maxHours+"");break;case"m":case"s":parseInt(o,10)>r.maxMinutesFirstDigit?s="0"+o:parseInt(s,10)>r.maxMinutes&&(s=r.maxMinutes+"")}i+=s,e=l}}),this.getFixedTimeString(i)},getFixedTimeString:function(e){var t,i,r,n=this,a=n.timePattern,s=[],o=0,l=0,c=0,u=0,h=0,d=0;return 6===e.length&&(a.forEach(function(e,t){switch(e){case"s":o=2*t;break;case"m":l=2*t;break;case"h":c=2*t}}),d=c,h=l,u=o,t=parseInt(e.slice(u,u+2),10),i=parseInt(e.slice(h,h+2),10),r=parseInt(e.slice(d,d+2),10),s=this.getFixedTime(r,i,t)),4===e.length&&n.timePattern.indexOf("s")<0&&(a.forEach(function(e,t){switch(e){case"m":l=2*t;break;case"h":c=2*t}}),d=c,h=l,t=0,i=parseInt(e.slice(h,h+2),10),r=parseInt(e.slice(d,d+2),10),s=this.getFixedTime(r,i,t)),n.time=s,0===s.length?e:a.reduce(function(e,t){switch(t){case"s":return e+n.addLeadingZero(s[2]);case"m":return e+n.addLeadingZero(s[1]);case"h":return e+n.addLeadingZero(s[0])}},"")},getFixedTime:function(e,t,i){return i=Math.min(parseInt(i||0,10),60),t=Math.min(t,60),[e=Math.min(e,60),t,i]},addLeadingZero:function(e){return(e<10?"0":"")+e}};var s=a,o=function(e,t){this.delimiter=t||""===t?t:" ",this.delimiterRE=t?new RegExp("\\"+t,"g"):"",this.formatter=e};o.prototype={setFormatter:function(e){this.formatter=e},format:function(e){this.formatter.clear();for(var t,i="",r=!1,n=0,a=(e=(e=(e=e.replace(/[^\d+]/g,"")).replace(/^\+/,"B").replace(/\+/g,"").replace("B","+")).replace(this.delimiterRE,"")).length;n0;return 0===i?e:(t.forEach(function(t,c){if(e.length>0){var u=e.slice(0,t),h=e.slice(t);s=l?n[a?c-1:c]||s:r,a?(c>0&&(o+=s),o+=u):(o+=u,u.length===t&&c0?i.numeralIntegerScale:0,t.numeralDecimalScale=i.numeralDecimalScale>=0?i.numeralDecimalScale:2,t.numeralDecimalMark=i.numeralDecimalMark||".",t.numeralThousandsGroupStyle=i.numeralThousandsGroupStyle||"thousand",t.numeralPositiveOnly=!!i.numeralPositiveOnly,t.stripLeadingZeroes=!1!==i.stripLeadingZeroes,t.signBeforePrefix=!!i.signBeforePrefix,t.numericOnly=t.creditCard||t.date||!!i.numericOnly,t.uppercase=!!i.uppercase,t.lowercase=!!i.lowercase,t.prefix=t.creditCard||t.date?"":i.prefix||"",t.noImmediatePrefix=!!i.noImmediatePrefix,t.prefixLength=t.prefix.length,t.rawValueTrimPrefix=!!i.rawValueTrimPrefix,t.copyDelimiter=!!i.copyDelimiter,t.initValue=void 0!==i.initValue&&null!==i.initValue?i.initValue.toString():"",t.delimiter=i.delimiter||""===i.delimiter?i.delimiter:i.date?"/":i.time?":":i.numeral?",":(i.phone," "),t.delimiterLength=t.delimiter.length,t.delimiterLazyShow=!!i.delimiterLazyShow,t.delimiters=i.delimiters||[],t.blocks=i.blocks||[],t.blocksLength=t.blocks.length,t.root="object"==typeof e&&e?e:window,t.document=i.document||t.root.document,t.maxLength=0,t.backspace=!1,t.result="",t.onValueChanged=i.onValueChanged||function(){},t}},m=function(e,t){var i=!1;if("string"==typeof e?(this.element=document.querySelector(e),i=document.querySelectorAll(e).length>1):void 0!==e.length&&e.length>0?(this.element=e[0],i=e.length>1):this.element=e,!this.element)throw new Error("[cleave.js] Please check the element");if(i)try{console.warn("[cleave.js] Multiple input fields matched, cleave.js will only take the first one.")}catch(e){}t.initValue=this.element.value,this.properties=m.DefaultProperties.assign({},t),this.init()};m.prototype={init:function(){var e=this.properties;e.numeral||e.phone||e.creditCard||e.time||e.date||0!==e.blocksLength||e.prefix?(e.maxLength=m.Util.getMaxLength(e.blocks),this.isAndroid=m.Util.isAndroid(),this.lastInputValue="",this.onChangeListener=this.onChange.bind(this),this.onKeyDownListener=this.onKeyDown.bind(this),this.onFocusListener=this.onFocus.bind(this),this.onCutListener=this.onCut.bind(this),this.onCopyListener=this.onCopy.bind(this),this.element.addEventListener("input",this.onChangeListener),this.element.addEventListener("keydown",this.onKeyDownListener),this.element.addEventListener("focus",this.onFocusListener),this.element.addEventListener("cut",this.onCutListener),this.element.addEventListener("copy",this.onCopyListener),this.initPhoneFormatter(),this.initDateFormatter(),this.initTimeFormatter(),this.initNumeralFormatter(),(e.initValue||e.prefix&&!e.noImmediatePrefix)&&this.onInput(e.initValue)):this.onInput(e.initValue)},initNumeralFormatter:function(){var e=this.properties;e.numeral&&(e.numeralFormatter=new m.NumeralFormatter(e.numeralDecimalMark,e.numeralIntegerScale,e.numeralDecimalScale,e.numeralThousandsGroupStyle,e.numeralPositiveOnly,e.stripLeadingZeroes,e.prefix,e.signBeforePrefix,e.delimiter))},initTimeFormatter:function(){var e=this.properties;e.time&&(e.timeFormatter=new m.TimeFormatter(e.timePattern,e.timeFormat),e.blocks=e.timeFormatter.getBlocks(),e.blocksLength=e.blocks.length,e.maxLength=m.Util.getMaxLength(e.blocks))},initDateFormatter:function(){var e=this.properties;e.date&&(e.dateFormatter=new m.DateFormatter(e.datePattern,e.dateMin,e.dateMax),e.blocks=e.dateFormatter.getBlocks(),e.blocksLength=e.blocks.length,e.maxLength=m.Util.getMaxLength(e.blocks))},initPhoneFormatter:function(){var e=this.properties;if(e.phone)try{e.phoneFormatter=new m.PhoneFormatter(new e.root.Cleave.AsYouTypeFormatter(e.phoneRegionCode),e.delimiter)}catch(e){throw new Error("[cleave.js] Please include phone-type-formatter.{country}.js lib")}},onKeyDown:function(e){var t=this.properties,i=e.which||e.keyCode,r=m.Util,n=this.element.value;this.hasBackspaceSupport=this.hasBackspaceSupport||8===i,!this.hasBackspaceSupport&&r.isAndroidBackspaceKeydown(this.lastInputValue,n)&&(i=8),this.lastInputValue=n;var a=r.getPostDelimiter(n,t.delimiter,t.delimiters);t.postDelimiterBackspace=!(8!==i||!a)&&a},onChange:function(){this.onInput(this.element.value)},onFocus:function(){var e=this.properties;m.Util.fixPrefixCursor(this.element,e.prefix,e.delimiter,e.delimiters)},onCut:function(e){m.Util.checkFullSelection(this.element.value)&&(this.copyClipboardData(e),this.onInput(""))},onCopy:function(e){m.Util.checkFullSelection(this.element.value)&&this.copyClipboardData(e)},copyClipboardData:function(e){var t=this.properties,i=m.Util,r=this.element.value,n="";n=t.copyDelimiter?r:i.stripDelimiters(r,t.delimiter,t.delimiters);try{e.clipboardData?e.clipboardData.setData("Text",n):window.clipboardData.setData("Text",n),e.preventDefault()}catch(e){}},onInput:function(e){var t=this.properties,i=m.Util,r=i.getPostDelimiter(e,t.delimiter,t.delimiters);return t.numeral||!t.postDelimiterBackspace||r||(e=i.headStr(e,e.length-t.postDelimiterBackspace.length)),t.phone?(!t.prefix||t.noImmediatePrefix&&!e.length?t.result=t.phoneFormatter.format(e):t.result=t.prefix+t.phoneFormatter.format(e).slice(t.prefix.length),void this.updateValueState()):t.numeral?(t.prefix&&t.noImmediatePrefix&&0===e.length?t.result="":t.result=t.numeralFormatter.format(e),void this.updateValueState()):(t.date&&(e=t.dateFormatter.getValidatedDate(e)),t.time&&(e=t.timeFormatter.getValidatedTime(e)),e=i.stripDelimiters(e,t.delimiter,t.delimiters),e=i.getPrefixStrippedValue(e,t.prefix,t.prefixLength,t.result,t.delimiter,t.delimiters),e=t.numericOnly?i.strip(e,/[^\d]/g):e,e=t.uppercase?e.toUpperCase():e,e=t.lowercase?e.toLowerCase():e,!t.prefix||t.noImmediatePrefix&&!e.length||(e=t.prefix+e,0!==t.blocksLength)?(t.creditCard&&this.updateCreditCardPropsByValue(e),e=i.headStr(e,t.maxLength),t.result=i.getFormattedValue(e,t.blocks,t.blocksLength,t.delimiter,t.delimiters,t.delimiterLazyShow),void this.updateValueState()):(t.result=e,void this.updateValueState()))},updateCreditCardPropsByValue:function(e){var t,i=this.properties,r=m.Util;r.headStr(i.result,4)!==r.headStr(e,4)&&(t=m.CreditCardDetector.getInfo(e,i.creditCardStrictMode),i.blocks=t.blocks,i.blocksLength=i.blocks.length,i.maxLength=r.getMaxLength(i.blocks),i.creditCardType!==t.type&&(i.creditCardType=t.type,i.onCreditCardTypeChanged.call(this,i.creditCardType)))},updateValueState:function(){var e=this,t=m.Util,i=e.properties;if(e.element){var r=e.element.selectionEnd,n=e.element.value,a=i.result;r=t.getNextCursorPosition(r,n,a,i.delimiter,i.delimiters),e.isAndroid?window.setTimeout(function(){e.element.value=a,t.setSelection(e.element,r,i.document,!1),e.callOnValueChanged()},1):(e.element.value=a,t.setSelection(e.element,r,i.document,!1),e.callOnValueChanged())}},callOnValueChanged:function(){var e=this.properties;e.onValueChanged.call(this,{target:{value:e.result,rawValue:this.getRawValue()}})},setPhoneRegionCode:function(e){this.properties.phoneRegionCode=e,this.initPhoneFormatter(),this.onChange()},setRawValue:function(e){var t=this.properties;e=null!=e?e.toString():"",t.numeral&&(e=e.replace(".",t.numeralDecimalMark)),t.postDelimiterBackspace=!1,this.element.value=e,this.onInput(e)},getRawValue:function(){var e=this.properties,t=m.Util,i=this.element.value;return e.rawValueTrimPrefix&&(i=t.getPrefixStrippedValue(i,e.prefix,e.prefixLength,e.result,e.delimiter,e.delimiters)),i=e.numeral?e.numeralFormatter.getRawValue(i):t.stripDelimiters(i,e.delimiter,e.delimiters)},getISOFormatDate:function(){var e=this.properties;return e.date?e.dateFormatter.getISOFormatDate():""},getISOFormatTime:function(){var e=this.properties;return e.time?e.timeFormatter.getISOFormatTime():""},getFormattedValue:function(){return this.element.value},destroy:function(){this.element.removeEventListener("input",this.onChangeListener),this.element.removeEventListener("keydown",this.onKeyDownListener),this.element.removeEventListener("focus",this.onFocusListener),this.element.removeEventListener("cut",this.onCutListener),this.element.removeEventListener("copy",this.onCopyListener)},toString:function(){return"[Cleave Object]"}},m.NumeralFormatter=i,m.DateFormatter=n,m.TimeFormatter=s,m.PhoneFormatter=l,m.CreditCardDetector=u,m.Util=h,m.DefaultProperties=d,("object"==typeof e&&e?e:window).Cleave=m;export default m; \ No newline at end of file diff --git a/dist/cleave-react-node.js b/dist/cleave-react-node.js index 8b3473c2..f01929dc 100644 --- a/dist/cleave-react-node.js +++ b/dist/cleave-react-node.js @@ -88,6 +88,8 @@ return /******/ (function(modules) { // webpackBootstrap phoneRegionCode = (nextProps.options || {}).phoneRegionCode, newValue = nextProps.value; + owner.updateRegisteredEvents(nextProps); + if (newValue !== undefined) { newValue = newValue.toString(); @@ -105,6 +107,25 @@ return /******/ (function(modules) { // webpackBootstrap } }, + updateRegisteredEvents: function updateRegisteredEvents(props) { + var owner = this, + _owner$registeredEven = owner.registeredEvents, + onKeyDown = _owner$registeredEven.onKeyDown, + onChange = _owner$registeredEven.onChange, + onFocus = _owner$registeredEven.onFocus, + onBlur = _owner$registeredEven.onBlur, + onInit = _owner$registeredEven.onInit; + + + owner.registeredEvents = { + onInit: props.onInit === onInit ? onInit : props.onInit, + onChange: props.onChange === onChange ? onChange : props.onChange, + onFocus: props.onFocus === onFocus ? onFocus : props.onFocus, + onBlur: props.onBlur === onBlur ? onBlur : props.onBlur, + onKeyDown: props.onKeyDown === onKeyDown ? onKeyDown : props.onKeyDown + }; + }, + getInitialState: function getInitialState() { var owner = this, _owner$props = owner.props, @@ -202,7 +223,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } - pps.dateFormatter = new DateFormatter(pps.datePattern); + pps.dateFormatter = new DateFormatter(pps.datePattern, pps.dateMin, pps.dateMax); pps.blocks = pps.dateFormatter.getBlocks(); pps.blocksLength = pps.blocks.length; pps.maxLength = Util.getMaxLength(pps.blocks); @@ -2479,6 +2500,7 @@ return /******/ (function(modules) { // webpackBootstrap type: key, blocks: strictMode ? this.getStrictBlocks(matchedBlocks) : matchedBlocks }; + } } return { diff --git a/dist/cleave-react-node.min.js b/dist/cleave-react-node.min.js index b13472b3..4c5fa0eb 100644 --- a/dist/cleave-react-node.min.js +++ b/dist/cleave-react-node.min.js @@ -1,8 +1,8 @@ /*! - * cleave.js - 1.5.0 + * cleave.js - 1.5.1 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * * Copyright (C) 2012-2019 Max Huang https://github.com/nosir/ */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Cleave=t(require("react")):e.Cleave=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}var i=Object.assign||function(e){for(var t=1;t0?d.headStr(e,n.maxLength):e,n.result=d.getFormattedValue(e,n.blocks,n.blocksLength,n.delimiter,n.delimiters,n.delimiterLazyShow),void r.updateValueState()):(n.result=e,void r.updateValueState()))},updateCreditCardPropsByValue:function(e){var t,r=this,n=r.properties;d.headStr(n.result,4)!==d.headStr(e,4)&&(t=p.getInfo(e,n.creditCardStrictMode),n.blocks=t.blocks,n.blocksLength=n.blocks.length,n.maxLength=d.getMaxLength(n.blocks),n.creditCardType!==t.type&&(n.creditCardType=t.type,n.onCreditCardTypeChanged.call(r,n.creditCardType)))},updateValueState:function(){var e=this,t=e.properties;if(!e.element)return void e.setState({value:t.result});var r=e.element.selectionEnd,n=e.element.value,i=t.result;return e.lastInputValue=i,r=d.getNextCursorPosition(r,n,i,t.delimiter,t.delimiters),e.isAndroid?void window.setTimeout(function(){e.setState({value:i,cursorPosition:r})},1):void e.setState({value:i,cursorPosition:r})},render:function(){var e=this,t=e.props,r=(t.value,t.options,t.onKeyDown,t.onFocus,t.onBlur,t.onChange,t.onInit,t.htmlRef),a=n(t,["value","options","onKeyDown","onFocus","onBlur","onChange","onInit","htmlRef"]);return o.createElement("input",i({type:"text",ref:function(t){e.element=t,r&&r.apply(this,arguments)},value:e.state.value,onKeyDown:e.onKeyDown,onChange:e.onChange,onFocus:e.onFocus,onBlur:e.onBlur},a))}});e.exports=f},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=r(1),i=r(3);if("undefined"==typeof n)throw Error("create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.");var o=(new n.Component).updater;e.exports=i(n.Component,n.isValidElement,o)},function(e,t,r){"use strict";function n(e){return e}function i(e,t,r){function i(e,t,r){for(var n in t)t.hasOwnProperty(n)&&"production"!==process.env.NODE_ENV&&c("function"==typeof t[n],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",e.displayName||"ReactClass",l[r],n)}function p(e,t){var r=D.hasOwnProperty(t)?D[t]:null;N.hasOwnProperty(t)&&s("OVERRIDE_BASE"===r,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",t),e&&s("DEFINE_MANY"===r||"DEFINE_MANY_MERGED"===r,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",t)}function d(e,r){if(r){s("function"!=typeof r,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),s(!t(r),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var n=e.prototype,i=n.__reactAutoBindPairs;r.hasOwnProperty(u)&&b.mixins(e,r.mixins);for(var o in r)if(r.hasOwnProperty(o)&&o!==u){var a=r[o],l=n.hasOwnProperty(o);if(p(l,o),b.hasOwnProperty(o))b[o](e,a);else{var d=D.hasOwnProperty(o),m="function"==typeof a,f=m&&!d&&!l&&r.autobind!==!1;if(f)i.push(o,a),n[o]=a;else if(l){var v=D[o];s(d&&("DEFINE_MANY_MERGED"===v||"DEFINE_MANY"===v),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",v,o),"DEFINE_MANY_MERGED"===v?n[o]=h(n[o],a):"DEFINE_MANY"===v&&(n[o]=g(n[o],a))}else n[o]=a,"production"!==process.env.NODE_ENV&&"function"==typeof a&&r.displayName&&(n[o].displayName=r.displayName+"_"+o)}}}else if("production"!==process.env.NODE_ENV){var y=typeof r,x="object"===y&&null!==r;"production"!==process.env.NODE_ENV&&c(x,"%s: You're attempting to include a mixin that is either null or not an object. Check the mixins included by the component, as well as any mixins they include themselves. Expected object but got %s.",e.displayName||"ReactClass",null===r?null:y)}}function m(e,t){if(t)for(var r in t){var n=t[r];if(t.hasOwnProperty(r)){var i=r in b;s(!i,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',r);var o=r in e;s(!o,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",r),e[r]=n}}}function f(e,t){s(e&&t&&"object"==typeof e&&"object"==typeof t,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var r in t)t.hasOwnProperty(r)&&(s(void 0===e[r],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",r),e[r]=t[r]);return e}function h(e,t){return function(){var r=e.apply(this,arguments),n=t.apply(this,arguments);if(null==r)return n;if(null==n)return r;var i={};return f(i,r),f(i,n),i}}function g(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function v(e,t){var r=t.bind(e);if("production"!==process.env.NODE_ENV){r.__reactBoundContext=e,r.__reactBoundMethod=t,r.__reactBoundArguments=null;var n=e.constructor.displayName,i=r.bind;r.bind=function(o){for(var a=arguments.length,s=Array(a>1?a-1:0),l=1;l1?t-1:0),n=1;n2?r-2:0),i=2;i0?t:0,u.numeralDecimalScale=r>=0?r:2,u.numeralThousandsGroupStyle=i||n.groupStyle.thousand,u.numeralPositiveOnly=!!o,u.stripLeadingZeroes=a!==!1,u.prefix=s||""===s?s:"",u.signBeforePrefix=!!c,u.delimiter=l||""===l?l:",",u.delimiterRE=l?new RegExp("\\"+l,"g"):""};r.groupStyle={thousand:"thousand",lakh:"lakh",wan:"wan",none:"none"},r.prototype={getRawValue:function(e){return e.replace(this.delimiterRE,"").replace(this.numeralDecimalMark,".")},format:function(e){var t,n,i,o,a=this,s="";switch(e=e.replace(/[A-Za-z]/g,"").replace(a.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",a.numeralPositiveOnly?"":"-").replace("M",a.numeralDecimalMark),a.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),n="-"===e.slice(0,1)?"-":"",i="undefined"!=typeof a.prefix?a.signBeforePrefix?n+a.prefix:a.prefix+n:n,o=e,e.indexOf(a.numeralDecimalMark)>=0&&(t=e.split(a.numeralDecimalMark),o=t[0],s=a.numeralDecimalMark+t[1].slice(0,a.numeralDecimalScale)),"-"===n&&(o=o.slice(1)),a.numeralIntegerScale>0&&(o=o.slice(0,a.numeralIntegerScale)),a.numeralThousandsGroupStyle){case r.groupStyle.lakh:o=o.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+a.delimiter);break;case r.groupStyle.wan:o=o.replace(/(\d)(?=(\d{4})+$)/g,"$1"+a.delimiter);break;case r.groupStyle.thousand:o=o.replace(/(\d)(?=(\d{3})+$)/g,"$1"+a.delimiter)}return i+o.toString()+(a.numeralDecimalScale>0?s.toString():"")}},e.exports=r},function(e,t){"use strict";var r=function(e,t,r){var n=this;n.date=[],n.blocks=[],n.datePattern=e,n.dateMin=t.split("-").reverse().map(function(e){return parseInt(e,10)}),2===n.dateMin.length&&n.dateMin.unshift(0),n.dateMax=r.split("-").reverse().map(function(e){return parseInt(e,10)}),2===n.dateMax.length&&n.dateMax.unshift(0),n.initBlocks()};r.prototype={initBlocks:function(){var e=this;e.datePattern.forEach(function(t){"Y"===t?e.blocks.push(4):e.blocks.push(2)})},getISOFormatDate:function(){var e=this,t=e.date;return t[2]?t[2]+"-"+e.addLeadingZero(t[1])+"-"+e.addLeadingZero(t[0]):""},getBlocks:function(){return this.blocks},getValidatedDate:function(e){var t=this,r="";return e=e.replace(/[^\d]/g,""),t.blocks.forEach(function(n,i){if(e.length>0){var o=e.slice(0,n),a=o.slice(0,1),s=e.slice(n);switch(t.datePattern[i]){case"d":"00"===o?o="01":parseInt(a,10)>3?o="0"+a:parseInt(o,10)>31&&(o="31");break;case"m":"00"===o?o="01":parseInt(a,10)>1?o="0"+a:parseInt(o,10)>12&&(o="12")}r+=o,e=s}}),this.getFixedDateString(r)},getFixedDateString:function(e){var t,r,n,i=this,o=i.datePattern,a=[],s=0,c=0,l=0,u=0,p=0,d=0,m=!1;4===e.length&&"y"!==o[0].toLowerCase()&&"y"!==o[1].toLowerCase()&&(u="d"===o[0]?0:2,p=2-u,t=parseInt(e.slice(u,u+2),10),r=parseInt(e.slice(p,p+2),10),a=this.getFixedDate(t,r,0)),8===e.length&&(o.forEach(function(e,t){switch(e){case"d":s=t;break;case"m":c=t;break;default:l=t}}),d=2*l,u=s<=l?2*s:2*s+2,p=c<=l?2*c:2*c+2,t=parseInt(e.slice(u,u+2),10),r=parseInt(e.slice(p,p+2),10),n=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=this.getFixedDate(t,r,n)),4!==e.length||"y"!==o[0]&&"y"!==o[1]||(p="m"===o[0]?0:2,d=2-p,r=parseInt(e.slice(p,p+2),10),n=parseInt(e.slice(d,d+2),10),m=2===e.slice(d,d+2).length,a=[0,r,n]),6!==e.length||"Y"!==o[0]&&"Y"!==o[1]||(p="m"===o[0]?0:4,d=2-.5*p,r=parseInt(e.slice(p,p+2),10),n=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=[0,r,n]),a=i.getRangeFixedDate(a),i.date=a;var f=0===a.length?e:o.reduce(function(e,t){switch(t){case"d":return e+(0===a[0]?"":i.addLeadingZero(a[0]));case"m":return e+(0===a[1]?"":i.addLeadingZero(a[1]));case"y":return e+(m?i.addLeadingZeroForYear(a[2],!1):"");case"Y":return e+(m?i.addLeadingZeroForYear(a[2],!0):"")}},"");return f},getRangeFixedDate:function(e){var t=this,r=t.datePattern,n=t.dateMin||[],i=t.dateMax||[];return!e.length||n.length<3&&i.length<3?e:r.find(function(e){return"y"===e.toLowerCase()})&&0===e[2]?e:i.length&&(i[2]e[2]||n[2]===e[2]&&(n[1]>e[1]||n[1]===e[1]&&n[0]>e[0]))?n:e},getFixedDate:function(e,t,r){return e=Math.min(e,31),t=Math.min(t,12),r=parseInt(r||0,10),(t<7&&t%2===0||t>8&&t%2===1)&&(e=Math.min(e,2===t?this.isLeapYear(r)?29:28:30)),[e,t,r]},isLeapYear:function(e){return e%4===0&&e%100!==0||e%400===0},addLeadingZero:function(e){return(e<10?"0":"")+e},addLeadingZeroForYear:function(e,t){return t?(e<10?"000":e<100?"00":e<1e3?"0":"")+e:(e<10?"0":"")+e}},e.exports=r},function(e,t){"use strict";var r=function(e,t){var r=this;r.time=[],r.blocks=[],r.timePattern=e,r.timeFormat=t,r.initBlocks()};r.prototype={initBlocks:function(){var e=this;e.timePattern.forEach(function(){e.blocks.push(2)})},getISOFormatTime:function(){var e=this,t=e.time;return t[2]?e.addLeadingZero(t[0])+":"+e.addLeadingZero(t[1])+":"+e.addLeadingZero(t[2]):""},getBlocks:function(){return this.blocks},getTimeFormatOptions:function(){var e=this;return"12"===String(e.timeFormat)?{maxHourFirstDigit:1,maxHours:12,maxMinutesFirstDigit:5,maxMinutes:60}:{maxHourFirstDigit:2,maxHours:23,maxMinutesFirstDigit:5,maxMinutes:60}},getValidatedTime:function(e){var t=this,r="";e=e.replace(/[^\d]/g,"");var n=t.getTimeFormatOptions();return t.blocks.forEach(function(i,o){if(e.length>0){var a=e.slice(0,i),s=a.slice(0,1),c=e.slice(i);switch(t.timePattern[o]){case"h":parseInt(s,10)>n.maxHourFirstDigit?a="0"+s:parseInt(a,10)>n.maxHours&&(a=n.maxHours+"");break;case"m":case"s":parseInt(s,10)>n.maxMinutesFirstDigit?a="0"+s:parseInt(a,10)>n.maxMinutes&&(a=n.maxMinutes+"")}r+=a,e=c}}),this.getFixedTimeString(r)},getFixedTimeString:function(e){var t,r,n,i=this,o=i.timePattern,a=[],s=0,c=0,l=0,u=0,p=0,d=0;return 6===e.length&&(o.forEach(function(e,t){switch(e){case"s":s=2*t;break;case"m":c=2*t;break;case"h":l=2*t}}),d=l,p=c,u=s,t=parseInt(e.slice(u,u+2),10),r=parseInt(e.slice(p,p+2),10),n=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(n,r,t)),4===e.length&&i.timePattern.indexOf("s")<0&&(o.forEach(function(e,t){switch(e){case"m":c=2*t;break;case"h":l=2*t}}),d=l,p=c,t=0,r=parseInt(e.slice(p,p+2),10),n=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(n,r,t)),i.time=a,0===a.length?e:o.reduce(function(e,t){switch(t){case"s":return e+i.addLeadingZero(a[2]);case"m":return e+i.addLeadingZero(a[1]);case"h":return e+i.addLeadingZero(a[0])}},"")},getFixedTime:function(e,t,r){return r=Math.min(parseInt(r||0,10),60),t=Math.min(t,60),e=Math.min(e,60),[e,t,r]},addLeadingZero:function(e){return(e<10?"0":"")+e}},e.exports=r},function(e,t){"use strict";var r=function(e,t){var r=this;r.delimiter=t||""===t?t:" ",r.delimiterRE=t?new RegExp("\\"+t,"g"):"",r.formatter=e};r.prototype={setFormatter:function(e){this.formatter=e},format:function(e){var t=this;t.formatter.clear(),e=e.replace(/[^\d+]/g,""),e=e.replace(/^\+/,"B").replace(/\+/g,"").replace("B","+"),e=e.replace(t.delimiterRE,"");for(var r,n="",i=!1,o=0,a=e.length;o0;return 0===r?e:(t.forEach(function(t,l){if(e.length>0){var u=e.slice(0,t),p=e.slice(t);a=c?i[o?l-1:l]||a:n,o?(l>0&&(s+=a),s+=u):(s+=u,u.length===t&&l0?t.numeralIntegerScale:0,e.numeralDecimalScale=t.numeralDecimalScale>=0?t.numeralDecimalScale:2,e.numeralDecimalMark=t.numeralDecimalMark||".",e.numeralThousandsGroupStyle=t.numeralThousandsGroupStyle||"thousand",e.numeralPositiveOnly=!!t.numeralPositiveOnly,e.stripLeadingZeroes=t.stripLeadingZeroes!==!1,e.signBeforePrefix=!!t.signBeforePrefix,e.numericOnly=e.creditCard||e.date||!!t.numericOnly,e.uppercase=!!t.uppercase,e.lowercase=!!t.lowercase,e.prefix=e.creditCard||e.date?"":t.prefix||"",e.noImmediatePrefix=!!t.noImmediatePrefix,e.prefixLength=e.prefix.length,e.rawValueTrimPrefix=!!t.rawValueTrimPrefix,e.copyDelimiter=!!t.copyDelimiter,e.initValue=void 0!==t.initValue&&null!==t.initValue?t.initValue.toString():"",e.delimiter=t.delimiter||""===t.delimiter?t.delimiter:t.date?"/":t.time?":":t.numeral?",":(t.phone," "),e.delimiterLength=e.delimiter.length,e.delimiterLazyShow=!!t.delimiterLazyShow,e.delimiters=t.delimiters||[],e.blocks=t.blocks||[],e.blocksLength=e.blocks.length,e.root="object"===("undefined"==typeof global?"undefined":r(global))&&global?global:window,e.document=t.document||e.root.document,e.maxLength=0,e.backspace=!1,e.result="",e.onValueChanged=t.onValueChanged||function(){},e}};e.exports=n}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Cleave=t(require("react")):e.Cleave=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}var i=Object.assign||function(e){for(var t=1;t0?d.headStr(e,r.maxLength):e,r.result=d.getFormattedValue(e,r.blocks,r.blocksLength,r.delimiter,r.delimiters,r.delimiterLazyShow),void n.updateValueState()):(r.result=e,void n.updateValueState()))},updateCreditCardPropsByValue:function(e){var t,n=this,r=n.properties;d.headStr(r.result,4)!==d.headStr(e,4)&&(t=p.getInfo(e,r.creditCardStrictMode),r.blocks=t.blocks,r.blocksLength=r.blocks.length,r.maxLength=d.getMaxLength(r.blocks),r.creditCardType!==t.type&&(r.creditCardType=t.type,r.onCreditCardTypeChanged.call(n,r.creditCardType)))},updateValueState:function(){var e=this,t=e.properties;if(!e.element)return void e.setState({value:t.result});var n=e.element.selectionEnd,r=e.element.value,i=t.result;return e.lastInputValue=i,n=d.getNextCursorPosition(n,r,i,t.delimiter,t.delimiters),e.isAndroid?void window.setTimeout(function(){e.setState({value:i,cursorPosition:n})},1):void e.setState({value:i,cursorPosition:n})},render:function(){var e=this,t=e.props,n=(t.value,t.options,t.onKeyDown,t.onFocus,t.onBlur,t.onChange,t.onInit,t.htmlRef),a=r(t,["value","options","onKeyDown","onFocus","onBlur","onChange","onInit","htmlRef"]);return o.createElement("input",i({type:"text",ref:function(t){e.element=t,n&&n.apply(this,arguments)},value:e.state.value,onKeyDown:e.onKeyDown,onChange:e.onChange,onFocus:e.onFocus,onBlur:e.onBlur},a))}});e.exports=f},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=n(1),i=n(3);if("undefined"==typeof r)throw Error("create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.");var o=(new r.Component).updater;e.exports=i(r.Component,r.isValidElement,o)},function(e,t,n){"use strict";function r(e){return e}function i(e,t,n){function i(e,t,n){for(var r in t)t.hasOwnProperty(r)&&"production"!==process.env.NODE_ENV&&c("function"==typeof t[r],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",e.displayName||"ReactClass",l[n],r)}function p(e,t){var n=D.hasOwnProperty(t)?D[t]:null;w.hasOwnProperty(t)&&s("OVERRIDE_BASE"===n,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",t),e&&s("DEFINE_MANY"===n||"DEFINE_MANY_MERGED"===n,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",t)}function d(e,n){if(n){s("function"!=typeof n,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),s(!t(n),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var r=e.prototype,i=r.__reactAutoBindPairs;n.hasOwnProperty(u)&&N.mixins(e,n.mixins);for(var o in n)if(n.hasOwnProperty(o)&&o!==u){var a=n[o],l=r.hasOwnProperty(o);if(p(l,o),N.hasOwnProperty(o))N[o](e,a);else{var d=D.hasOwnProperty(o),m="function"==typeof a,f=m&&!d&&!l&&n.autobind!==!1;if(f)i.push(o,a),r[o]=a;else if(l){var v=D[o];s(d&&("DEFINE_MANY_MERGED"===v||"DEFINE_MANY"===v),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",v,o),"DEFINE_MANY_MERGED"===v?r[o]=h(r[o],a):"DEFINE_MANY"===v&&(r[o]=g(r[o],a))}else r[o]=a,"production"!==process.env.NODE_ENV&&"function"==typeof a&&n.displayName&&(r[o].displayName=n.displayName+"_"+o)}}}else if("production"!==process.env.NODE_ENV){var y=typeof n,E="object"===y&&null!==n;"production"!==process.env.NODE_ENV&&c(E,"%s: You're attempting to include a mixin that is either null or not an object. Check the mixins included by the component, as well as any mixins they include themselves. Expected object but got %s.",e.displayName||"ReactClass",null===n?null:y)}}function m(e,t){if(t)for(var n in t){var r=t[n];if(t.hasOwnProperty(n)){var i=n in N;s(!i,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',n);var o=n in e;if(o){var a=b.hasOwnProperty(n)?b[n]:null;return s("DEFINE_MANY_MERGED"===a,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",n),void(e[n]=h(e[n],r))}e[n]=r}}}function f(e,t){s(e&&t&&"object"==typeof e&&"object"==typeof t,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var n in t)t.hasOwnProperty(n)&&(s(void 0===e[n],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",n),e[n]=t[n]);return e}function h(e,t){return function(){var n=e.apply(this,arguments),r=t.apply(this,arguments);if(null==n)return r;if(null==r)return n;var i={};return f(i,n),f(i,r),i}}function g(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function v(e,t){var n=t.bind(e);if("production"!==process.env.NODE_ENV){n.__reactBoundContext=e,n.__reactBoundMethod=t,n.__reactBoundArguments=null;var r=e.constructor.displayName,i=n.bind;n.bind=function(o){for(var a=arguments.length,s=Array(a>1?a-1:0),l=1;l1?t-1:0),r=1;r2?n-2:0),i=2;i0?t:0,u.numeralDecimalScale=n>=0?n:2,u.numeralThousandsGroupStyle=i||r.groupStyle.thousand,u.numeralPositiveOnly=!!o,u.stripLeadingZeroes=a!==!1,u.prefix=s||""===s?s:"",u.signBeforePrefix=!!c,u.delimiter=l||""===l?l:",",u.delimiterRE=l?new RegExp("\\"+l,"g"):""};n.groupStyle={thousand:"thousand",lakh:"lakh",wan:"wan",none:"none"},n.prototype={getRawValue:function(e){return e.replace(this.delimiterRE,"").replace(this.numeralDecimalMark,".")},format:function(e){var t,r,i,o,a=this,s="";switch(e=e.replace(/[A-Za-z]/g,"").replace(a.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",a.numeralPositiveOnly?"":"-").replace("M",a.numeralDecimalMark),a.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),r="-"===e.slice(0,1)?"-":"",i="undefined"!=typeof a.prefix?a.signBeforePrefix?r+a.prefix:a.prefix+r:r,o=e,e.indexOf(a.numeralDecimalMark)>=0&&(t=e.split(a.numeralDecimalMark),o=t[0],s=a.numeralDecimalMark+t[1].slice(0,a.numeralDecimalScale)),"-"===r&&(o=o.slice(1)),a.numeralIntegerScale>0&&(o=o.slice(0,a.numeralIntegerScale)),a.numeralThousandsGroupStyle){case n.groupStyle.lakh:o=o.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+a.delimiter);break;case n.groupStyle.wan:o=o.replace(/(\d)(?=(\d{4})+$)/g,"$1"+a.delimiter);break;case n.groupStyle.thousand:o=o.replace(/(\d)(?=(\d{3})+$)/g,"$1"+a.delimiter)}return i+o.toString()+(a.numeralDecimalScale>0?s.toString():"")}},e.exports=n},function(e,t){"use strict";var n=function(e,t,n){var r=this;r.date=[],r.blocks=[],r.datePattern=e,r.dateMin=t.split("-").reverse().map(function(e){return parseInt(e,10)}),2===r.dateMin.length&&r.dateMin.unshift(0),r.dateMax=n.split("-").reverse().map(function(e){return parseInt(e,10)}),2===r.dateMax.length&&r.dateMax.unshift(0),r.initBlocks()};n.prototype={initBlocks:function(){var e=this;e.datePattern.forEach(function(t){"Y"===t?e.blocks.push(4):e.blocks.push(2)})},getISOFormatDate:function(){var e=this,t=e.date;return t[2]?t[2]+"-"+e.addLeadingZero(t[1])+"-"+e.addLeadingZero(t[0]):""},getBlocks:function(){return this.blocks},getValidatedDate:function(e){var t=this,n="";return e=e.replace(/[^\d]/g,""),t.blocks.forEach(function(r,i){if(e.length>0){var o=e.slice(0,r),a=o.slice(0,1),s=e.slice(r);switch(t.datePattern[i]){case"d":"00"===o?o="01":parseInt(a,10)>3?o="0"+a:parseInt(o,10)>31&&(o="31");break;case"m":"00"===o?o="01":parseInt(a,10)>1?o="0"+a:parseInt(o,10)>12&&(o="12")}n+=o,e=s}}),this.getFixedDateString(n)},getFixedDateString:function(e){var t,n,r,i=this,o=i.datePattern,a=[],s=0,c=0,l=0,u=0,p=0,d=0,m=!1;4===e.length&&"y"!==o[0].toLowerCase()&&"y"!==o[1].toLowerCase()&&(u="d"===o[0]?0:2,p=2-u,t=parseInt(e.slice(u,u+2),10),n=parseInt(e.slice(p,p+2),10),a=this.getFixedDate(t,n,0)),8===e.length&&(o.forEach(function(e,t){switch(e){case"d":s=t;break;case"m":c=t;break;default:l=t}}),d=2*l,u=s<=l?2*s:2*s+2,p=c<=l?2*c:2*c+2,t=parseInt(e.slice(u,u+2),10),n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=this.getFixedDate(t,n,r)),4!==e.length||"y"!==o[0]&&"y"!==o[1]||(p="m"===o[0]?0:2,d=2-p,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),m=2===e.slice(d,d+2).length,a=[0,n,r]),6!==e.length||"Y"!==o[0]&&"Y"!==o[1]||(p="m"===o[0]?0:4,d=2-.5*p,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=[0,n,r]),a=i.getRangeFixedDate(a),i.date=a;var f=0===a.length?e:o.reduce(function(e,t){switch(t){case"d":return e+(0===a[0]?"":i.addLeadingZero(a[0]));case"m":return e+(0===a[1]?"":i.addLeadingZero(a[1]));case"y":return e+(m?i.addLeadingZeroForYear(a[2],!1):"");case"Y":return e+(m?i.addLeadingZeroForYear(a[2],!0):"")}},"");return f},getRangeFixedDate:function(e){var t=this,n=t.datePattern,r=t.dateMin||[],i=t.dateMax||[];return!e.length||r.length<3&&i.length<3?e:n.find(function(e){return"y"===e.toLowerCase()})&&0===e[2]?e:i.length&&(i[2]e[2]||r[2]===e[2]&&(r[1]>e[1]||r[1]===e[1]&&r[0]>e[0]))?r:e},getFixedDate:function(e,t,n){return e=Math.min(e,31),t=Math.min(t,12),n=parseInt(n||0,10),(t<7&&t%2===0||t>8&&t%2===1)&&(e=Math.min(e,2===t?this.isLeapYear(n)?29:28:30)),[e,t,n]},isLeapYear:function(e){return e%4===0&&e%100!==0||e%400===0},addLeadingZero:function(e){return(e<10?"0":"")+e},addLeadingZeroForYear:function(e,t){return t?(e<10?"000":e<100?"00":e<1e3?"0":"")+e:(e<10?"0":"")+e}},e.exports=n},function(e,t){"use strict";var n=function(e,t){var n=this;n.time=[],n.blocks=[],n.timePattern=e,n.timeFormat=t,n.initBlocks()};n.prototype={initBlocks:function(){var e=this;e.timePattern.forEach(function(){e.blocks.push(2)})},getISOFormatTime:function(){var e=this,t=e.time;return t[2]?e.addLeadingZero(t[0])+":"+e.addLeadingZero(t[1])+":"+e.addLeadingZero(t[2]):""},getBlocks:function(){return this.blocks},getTimeFormatOptions:function(){var e=this;return"12"===String(e.timeFormat)?{maxHourFirstDigit:1,maxHours:12,maxMinutesFirstDigit:5,maxMinutes:60}:{maxHourFirstDigit:2,maxHours:23,maxMinutesFirstDigit:5,maxMinutes:60}},getValidatedTime:function(e){var t=this,n="";e=e.replace(/[^\d]/g,"");var r=t.getTimeFormatOptions();return t.blocks.forEach(function(i,o){if(e.length>0){var a=e.slice(0,i),s=a.slice(0,1),c=e.slice(i);switch(t.timePattern[o]){case"h":parseInt(s,10)>r.maxHourFirstDigit?a="0"+s:parseInt(a,10)>r.maxHours&&(a=r.maxHours+"");break;case"m":case"s":parseInt(s,10)>r.maxMinutesFirstDigit?a="0"+s:parseInt(a,10)>r.maxMinutes&&(a=r.maxMinutes+"")}n+=a,e=c}}),this.getFixedTimeString(n)},getFixedTimeString:function(e){var t,n,r,i=this,o=i.timePattern,a=[],s=0,c=0,l=0,u=0,p=0,d=0;return 6===e.length&&(o.forEach(function(e,t){switch(e){case"s":s=2*t;break;case"m":c=2*t;break;case"h":l=2*t}}),d=l,p=c,u=s,t=parseInt(e.slice(u,u+2),10),n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(r,n,t)),4===e.length&&i.timePattern.indexOf("s")<0&&(o.forEach(function(e,t){switch(e){case"m":c=2*t;break;case"h":l=2*t}}),d=l,p=c,t=0,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(r,n,t)),i.time=a,0===a.length?e:o.reduce(function(e,t){switch(t){case"s":return e+i.addLeadingZero(a[2]);case"m":return e+i.addLeadingZero(a[1]);case"h":return e+i.addLeadingZero(a[0])}},"")},getFixedTime:function(e,t,n){return n=Math.min(parseInt(n||0,10),60),t=Math.min(t,60),e=Math.min(e,60),[e,t,n]},addLeadingZero:function(e){return(e<10?"0":"")+e}},e.exports=n},function(e,t){"use strict";var n=function(e,t){var n=this;n.delimiter=t||""===t?t:" ",n.delimiterRE=t?new RegExp("\\"+t,"g"):"",n.formatter=e};n.prototype={setFormatter:function(e){this.formatter=e},format:function(e){var t=this;t.formatter.clear(),e=e.replace(/[^\d+]/g,""),e=e.replace(/^\+/,"B").replace(/\+/g,"").replace("B","+"),e=e.replace(t.delimiterRE,"");for(var n,r="",i=!1,o=0,a=e.length;o0;return 0===n?e:(t.forEach(function(t,l){if(e.length>0){var u=e.slice(0,t),p=e.slice(t);a=c?i[o?l-1:l]||a:r,o?(l>0&&(s+=a),s+=u):(s+=u,u.length===t&&l0?t.numeralIntegerScale:0,e.numeralDecimalScale=t.numeralDecimalScale>=0?t.numeralDecimalScale:2,e.numeralDecimalMark=t.numeralDecimalMark||".",e.numeralThousandsGroupStyle=t.numeralThousandsGroupStyle||"thousand",e.numeralPositiveOnly=!!t.numeralPositiveOnly,e.stripLeadingZeroes=t.stripLeadingZeroes!==!1,e.signBeforePrefix=!!t.signBeforePrefix,e.numericOnly=e.creditCard||e.date||!!t.numericOnly,e.uppercase=!!t.uppercase,e.lowercase=!!t.lowercase,e.prefix=e.creditCard||e.date?"":t.prefix||"",e.noImmediatePrefix=!!t.noImmediatePrefix,e.prefixLength=e.prefix.length,e.rawValueTrimPrefix=!!t.rawValueTrimPrefix,e.copyDelimiter=!!t.copyDelimiter,e.initValue=void 0!==t.initValue&&null!==t.initValue?t.initValue.toString():"",e.delimiter=t.delimiter||""===t.delimiter?t.delimiter:t.date?"/":t.time?":":t.numeral?",":(t.phone," "),e.delimiterLength=e.delimiter.length,e.delimiterLazyShow=!!t.delimiterLazyShow,e.delimiters=t.delimiters||[],e.blocks=t.blocks||[],e.blocksLength=e.blocks.length,e.root="object"===("undefined"==typeof global?"undefined":n(global))&&global?global:window,e.document=t.document||e.root.document,e.maxLength=0,e.backspace=!1,e.result="",e.onValueChanged=t.onValueChanged||function(){},e}};e.exports=r}])}); \ No newline at end of file diff --git a/dist/cleave-react.js b/dist/cleave-react.js index d5689a60..d305c78c 100644 --- a/dist/cleave-react.js +++ b/dist/cleave-react.js @@ -88,6 +88,8 @@ return /******/ (function(modules) { // webpackBootstrap phoneRegionCode = (nextProps.options || {}).phoneRegionCode, newValue = nextProps.value; + owner.updateRegisteredEvents(nextProps); + if (newValue !== undefined) { newValue = newValue.toString(); @@ -105,6 +107,25 @@ return /******/ (function(modules) { // webpackBootstrap } }, + updateRegisteredEvents: function updateRegisteredEvents(props) { + var owner = this, + _owner$registeredEven = owner.registeredEvents, + onKeyDown = _owner$registeredEven.onKeyDown, + onChange = _owner$registeredEven.onChange, + onFocus = _owner$registeredEven.onFocus, + onBlur = _owner$registeredEven.onBlur, + onInit = _owner$registeredEven.onInit; + + + owner.registeredEvents = { + onInit: props.onInit === onInit ? onInit : props.onInit, + onChange: props.onChange === onChange ? onChange : props.onChange, + onFocus: props.onFocus === onFocus ? onFocus : props.onFocus, + onBlur: props.onBlur === onBlur ? onBlur : props.onBlur, + onKeyDown: props.onKeyDown === onKeyDown ? onKeyDown : props.onKeyDown + }; + }, + getInitialState: function getInitialState() { var owner = this, _owner$props = owner.props, @@ -202,7 +223,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } - pps.dateFormatter = new DateFormatter(pps.datePattern); + pps.dateFormatter = new DateFormatter(pps.datePattern, pps.dateMin, pps.dateMax); pps.blocks = pps.dateFormatter.getBlocks(); pps.blocksLength = pps.blocks.length; pps.maxLength = Util.getMaxLength(pps.blocks); @@ -2673,6 +2694,7 @@ return /******/ (function(modules) { // webpackBootstrap type: key, blocks: strictMode ? this.getStrictBlocks(matchedBlocks) : matchedBlocks }; + } } return { @@ -2954,17 +2976,28 @@ return /******/ (function(modules) { // webpackBootstrap var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var DefaultProperties = { - // Maybe change to object-assign - // for now just keep it as simple - assign: function assign(target, opts) { - target = target || {}; - opts = opts || {}; - - // credit card - target.creditCard = !!opts.creditCard; - target.creditCardStrictMode = !!opts.creditCardStrictMode; - target.creditCardType = ''; - target.onCreditCardTypeChanged = opts.onCreditCardTypeChanged || function () {}; + // Maybe change to object-assign + // for now just keep it as simple + assign: function assign(target, opts) { + target = target || {}; + opts = opts || {}; + + // credit card + target.creditCard = !!opts.creditCard; + target.creditCardStrictMode = !!opts.creditCardStrictMode; + target.creditCardType = ''; + target.onCreditCardTypeChanged = opts.onCreditCardTypeChanged || function () {}; + + // phone + target.phone = !!opts.phone; + target.phoneRegionCode = opts.phoneRegionCode || 'AU'; + target.phoneFormatter = {}; + + // time + target.time = !!opts.time; + target.timePattern = opts.timePattern || ['h', 'm', 's']; + target.timeFormat = opts.timeFormat || '24'; + target.timeFormatter = {}; // date target.date = !!opts.date; @@ -2983,54 +3016,40 @@ return /******/ (function(modules) { // webpackBootstrap target.stripLeadingZeroes = opts.stripLeadingZeroes !== false; target.signBeforePrefix = !!opts.signBeforePrefix; - // date - target.date = !!opts.date; - target.datePattern = opts.datePattern || ['d', 'm', 'Y']; - target.dateFormatter = {}; - - // numeral - target.numeral = !!opts.numeral; - target.numeralIntegerScale = opts.numeralIntegerScale > 0 ? opts.numeralIntegerScale : 0; - target.numeralDecimalScale = opts.numeralDecimalScale >= 0 ? opts.numeralDecimalScale : 2; - target.numeralDecimalMark = opts.numeralDecimalMark || '.'; - target.numeralThousandsGroupStyle = opts.numeralThousandsGroupStyle || 'thousand'; - target.numeralPositiveOnly = !!opts.numeralPositiveOnly; - target.stripLeadingZeroes = opts.stripLeadingZeroes !== false; + // others + target.numericOnly = target.creditCard || target.date || !!opts.numericOnly; - // others - target.numericOnly = target.creditCard || target.date || !!opts.numericOnly; + target.uppercase = !!opts.uppercase; + target.lowercase = !!opts.lowercase; - target.uppercase = !!opts.uppercase; - target.lowercase = !!opts.lowercase; + target.prefix = target.creditCard || target.date ? '' : opts.prefix || ''; + target.noImmediatePrefix = !!opts.noImmediatePrefix; + target.prefixLength = target.prefix.length; + target.rawValueTrimPrefix = !!opts.rawValueTrimPrefix; + target.copyDelimiter = !!opts.copyDelimiter; - target.prefix = target.creditCard || target.date ? '' : opts.prefix || ''; - target.noImmediatePrefix = !!opts.noImmediatePrefix; - target.prefixLength = target.prefix.length; - target.rawValueTrimPrefix = !!opts.rawValueTrimPrefix; - target.copyDelimiter = !!opts.copyDelimiter; + target.initValue = opts.initValue !== undefined && opts.initValue !== null ? opts.initValue.toString() : ''; - target.initValue = opts.initValue !== undefined && opts.initValue !== null ? opts.initValue.toString() : ''; + target.delimiter = opts.delimiter || opts.delimiter === '' ? opts.delimiter : opts.date ? '/' : opts.time ? ':' : opts.numeral ? ',' : opts.phone ? ' ' : ' '; + target.delimiterLength = target.delimiter.length; + target.delimiterLazyShow = !!opts.delimiterLazyShow; + target.delimiters = opts.delimiters || []; - target.delimiter = opts.delimiter || opts.delimiter === '' ? opts.delimiter : opts.date ? '/' : opts.time ? ':' : opts.numeral ? ',' : opts.phone ? ' ' : ' '; - target.delimiterLength = target.delimiter.length; - target.delimiterLazyShow = !!opts.delimiterLazyShow; - target.delimiters = opts.delimiters || []; + target.blocks = opts.blocks || []; + target.blocksLength = target.blocks.length; - target.blocks = opts.blocks || []; - target.blocksLength = target.blocks.length; + target.root = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) === 'object' && global ? global : window; + target.document = opts.document || target.root.document; - target.root = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) === 'object' && global ? global : window; - target.document = opts.document || target.root.document; + target.maxLength = 0; - target.maxLength = 0; + target.backspace = false; + target.result = ''; - target.backspace = false; - target.result = ''; + target.onValueChanged = opts.onValueChanged || function () {}; - target.onValueChanged = opts.onValueChanged || function () {}; - - return target; - } + return target; + } }; module.exports = DefaultProperties; diff --git a/dist/cleave-react.min.js b/dist/cleave-react.min.js index 6c148ac0..6a2bb627 100644 --- a/dist/cleave-react.min.js +++ b/dist/cleave-react.min.js @@ -1,9 +1,9 @@ /*! - * cleave.js - 1.5.0 + * cleave.js - 1.5.1 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * * Copyright (C) 2012-2019 Max Huang https://github.com/nosir/ */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Cleave=t(require("react")):e.Cleave=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}var i=Object.assign||function(e){for(var t=1;t0?d.headStr(e,r.maxLength):e,r.result=d.getFormattedValue(e,r.blocks,r.blocksLength,r.delimiter,r.delimiters,r.delimiterLazyShow),void n.updateValueState()):(r.result=e,void n.updateValueState()))},updateCreditCardPropsByValue:function(e){var t,n=this,r=n.properties;d.headStr(r.result,4)!==d.headStr(e,4)&&(t=p.getInfo(e,r.creditCardStrictMode),r.blocks=t.blocks,r.blocksLength=r.blocks.length,r.maxLength=d.getMaxLength(r.blocks),r.creditCardType!==t.type&&(r.creditCardType=t.type,r.onCreditCardTypeChanged.call(n,r.creditCardType)))},updateValueState:function(){var e=this,t=e.properties;if(!e.element)return void e.setState({value:t.result});var n=e.element.selectionEnd,r=e.element.value,i=t.result;return e.lastInputValue=i,n=d.getNextCursorPosition(n,r,i,t.delimiter,t.delimiters),e.isAndroid?void window.setTimeout(function(){e.setState({value:i,cursorPosition:n})},1):void e.setState({value:i,cursorPosition:n})},render:function(){var e=this,t=e.props,n=(t.value,t.options,t.onKeyDown,t.onFocus,t.onBlur,t.onChange,t.onInit,t.htmlRef),a=r(t,["value","options","onKeyDown","onFocus","onBlur","onChange","onInit","htmlRef"]);return o.createElement("input",i({type:"text",ref:function(t){e.element=t,n&&n.apply(this,arguments)},value:e.state.value,onKeyDown:e.onKeyDown,onChange:e.onChange,onFocus:e.onFocus,onBlur:e.onBlur},a))}});e.exports=f},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=n(1),i=n(3);if("undefined"==typeof r)throw Error("create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.");var o=(new r.Component).updater;e.exports=i(r.Component,r.isValidElement,o)},function(e,t,n){(function(t){"use strict";function r(e){return e}function i(e,n,i){function p(e,n,r){for(var i in n)n.hasOwnProperty(i)&&"production"!==t.env.NODE_ENV&&c("function"==typeof n[i],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",e.displayName||"ReactClass",u[r],i)}function d(e,t){var n=b.hasOwnProperty(t)?b[t]:null;S.hasOwnProperty(t)&&s("OVERRIDE_BASE"===n,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",t),e&&s("DEFINE_MANY"===n||"DEFINE_MANY_MERGED"===n,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",t)}function m(e,r){if(r){s("function"!=typeof r,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),s(!n(r),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var i=e.prototype,o=i.__reactAutoBindPairs;r.hasOwnProperty(l)&&w.mixins(e,r.mixins);for(var a in r)if(r.hasOwnProperty(a)&&a!==l){var u=r[a],p=i.hasOwnProperty(a);if(d(p,a),w.hasOwnProperty(a))w[a](e,u);else{var m=b.hasOwnProperty(a),f="function"==typeof u,h=f&&!m&&!p&&r.autobind!==!1;if(h)o.push(a,u),i[a]=u;else if(p){var y=b[a];s(m&&("DEFINE_MANY_MERGED"===y||"DEFINE_MANY"===y),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",y,a),"DEFINE_MANY_MERGED"===y?i[a]=g(i[a],u):"DEFINE_MANY"===y&&(i[a]=v(i[a],u))}else i[a]=u,"production"!==t.env.NODE_ENV&&"function"==typeof u&&r.displayName&&(i[a].displayName=r.displayName+"_"+a)}}}else if("production"!==t.env.NODE_ENV){var x=typeof r,E="object"===x&&null!==r;"production"!==t.env.NODE_ENV&&c(E,"%s: You're attempting to include a mixin that is either null or not an object. Check the mixins included by the component, as well as any mixins they include themselves. Expected object but got %s.",e.displayName||"ReactClass",null===r?null:x)}}function f(e,t){if(t)for(var n in t){var r=t[n];if(t.hasOwnProperty(n)){var i=n in w;s(!i,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',n);var o=n in e;s(!o,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",n),e[n]=r}}}function h(e,t){s(e&&t&&"object"==typeof e&&"object"==typeof t,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var n in t)t.hasOwnProperty(n)&&(s(void 0===e[n],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",n),e[n]=t[n]);return e}function g(e,t){return function(){var n=e.apply(this,arguments),r=t.apply(this,arguments);if(null==n)return r;if(null==r)return n;var i={};return h(i,n),h(i,r),i}}function v(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function y(e,n){var r=n.bind(e);if("production"!==t.env.NODE_ENV){r.__reactBoundContext=e,r.__reactBoundMethod=n,r.__reactBoundArguments=null;var i=e.constructor.displayName,o=r.bind;r.bind=function(a){for(var s=arguments.length,u=Array(s>1?s-1:0),l=1;l1)for(var n=1;n1?t-1:0),r=1;r2?n-2:0),i=2;i0?t:0,l.numeralDecimalScale=n>=0?n:2,l.numeralThousandsGroupStyle=i||r.groupStyle.thousand,l.numeralPositiveOnly=!!o,l.stripLeadingZeroes=a!==!1,l.prefix=s||""===s?s:"",l.signBeforePrefix=!!c,l.delimiter=u||""===u?u:",",l.delimiterRE=u?new RegExp("\\"+u,"g"):""};n.groupStyle={thousand:"thousand",lakh:"lakh",wan:"wan",none:"none"},n.prototype={getRawValue:function(e){return e.replace(this.delimiterRE,"").replace(this.numeralDecimalMark,".")},format:function(e){var t,r,i,o,a=this,s="";switch(e=e.replace(/[A-Za-z]/g,"").replace(a.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",a.numeralPositiveOnly?"":"-").replace("M",a.numeralDecimalMark),a.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),r="-"===e.slice(0,1)?"-":"",i="undefined"!=typeof a.prefix?a.signBeforePrefix?r+a.prefix:a.prefix+r:r,o=e,e.indexOf(a.numeralDecimalMark)>=0&&(t=e.split(a.numeralDecimalMark),o=t[0],s=a.numeralDecimalMark+t[1].slice(0,a.numeralDecimalScale)),"-"===r&&(o=o.slice(1)),a.numeralIntegerScale>0&&(o=o.slice(0,a.numeralIntegerScale)),a.numeralThousandsGroupStyle){case n.groupStyle.lakh:o=o.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+a.delimiter);break;case n.groupStyle.wan:o=o.replace(/(\d)(?=(\d{4})+$)/g,"$1"+a.delimiter);break;case n.groupStyle.thousand:o=o.replace(/(\d)(?=(\d{3})+$)/g,"$1"+a.delimiter)}return i+o.toString()+(a.numeralDecimalScale>0?s.toString():"")}},e.exports=n},function(e,t){"use strict";var n=function(e,t,n){var r=this;r.date=[],r.blocks=[],r.datePattern=e,r.dateMin=t.split("-").reverse().map(function(e){return parseInt(e,10)}),2===r.dateMin.length&&r.dateMin.unshift(0),r.dateMax=n.split("-").reverse().map(function(e){return parseInt(e,10)}),2===r.dateMax.length&&r.dateMax.unshift(0),r.initBlocks()};n.prototype={initBlocks:function(){var e=this;e.datePattern.forEach(function(t){"Y"===t?e.blocks.push(4):e.blocks.push(2)})},getISOFormatDate:function(){var e=this,t=e.date;return t[2]?t[2]+"-"+e.addLeadingZero(t[1])+"-"+e.addLeadingZero(t[0]):""},getBlocks:function(){return this.blocks},getValidatedDate:function(e){var t=this,n="";return e=e.replace(/[^\d]/g,""),t.blocks.forEach(function(r,i){if(e.length>0){var o=e.slice(0,r),a=o.slice(0,1),s=e.slice(r);switch(t.datePattern[i]){case"d":"00"===o?o="01":parseInt(a,10)>3?o="0"+a:parseInt(o,10)>31&&(o="31");break;case"m":"00"===o?o="01":parseInt(a,10)>1?o="0"+a:parseInt(o,10)>12&&(o="12")}n+=o,e=s}}),this.getFixedDateString(n)},getFixedDateString:function(e){var t,n,r,i=this,o=i.datePattern,a=[],s=0,c=0,u=0,l=0,p=0,d=0,m=!1;4===e.length&&"y"!==o[0].toLowerCase()&&"y"!==o[1].toLowerCase()&&(l="d"===o[0]?0:2,p=2-l,t=parseInt(e.slice(l,l+2),10),n=parseInt(e.slice(p,p+2),10),a=this.getFixedDate(t,n,0)),8===e.length&&(o.forEach(function(e,t){switch(e){case"d":s=t;break;case"m":c=t;break;default:u=t}}),d=2*u,l=s<=u?2*s:2*s+2,p=c<=u?2*c:2*c+2,t=parseInt(e.slice(l,l+2),10),n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=this.getFixedDate(t,n,r)),4!==e.length||"y"!==o[0]&&"y"!==o[1]||(p="m"===o[0]?0:2,d=2-p,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),m=2===e.slice(d,d+2).length,a=[0,n,r]),6!==e.length||"Y"!==o[0]&&"Y"!==o[1]||(p="m"===o[0]?0:4,d=2-.5*p,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=[0,n,r]),a=i.getRangeFixedDate(a),i.date=a;var f=0===a.length?e:o.reduce(function(e,t){switch(t){case"d":return e+(0===a[0]?"":i.addLeadingZero(a[0]));case"m":return e+(0===a[1]?"":i.addLeadingZero(a[1]));case"y":return e+(m?i.addLeadingZeroForYear(a[2],!1):"");case"Y":return e+(m?i.addLeadingZeroForYear(a[2],!0):"")}},"");return f},getRangeFixedDate:function(e){var t=this,n=t.datePattern,r=t.dateMin||[],i=t.dateMax||[];return!e.length||r.length<3&&i.length<3?e:n.find(function(e){return"y"===e.toLowerCase()})&&0===e[2]?e:i.length&&(i[2]e[2]||r[2]===e[2]&&(r[1]>e[1]||r[1]===e[1]&&r[0]>e[0]))?r:e},getFixedDate:function(e,t,n){return e=Math.min(e,31),t=Math.min(t,12),n=parseInt(n||0,10),(t<7&&t%2===0||t>8&&t%2===1)&&(e=Math.min(e,2===t?this.isLeapYear(n)?29:28:30)),[e,t,n]},isLeapYear:function(e){return e%4===0&&e%100!==0||e%400===0},addLeadingZero:function(e){return(e<10?"0":"")+e},addLeadingZeroForYear:function(e,t){return t?(e<10?"000":e<100?"00":e<1e3?"0":"")+e:(e<10?"0":"")+e}},e.exports=n},function(e,t){"use strict";var n=function(e,t){var n=this;n.time=[],n.blocks=[],n.timePattern=e,n.timeFormat=t,n.initBlocks()};n.prototype={initBlocks:function(){var e=this;e.timePattern.forEach(function(){e.blocks.push(2)})},getISOFormatTime:function(){var e=this,t=e.time;return t[2]?e.addLeadingZero(t[0])+":"+e.addLeadingZero(t[1])+":"+e.addLeadingZero(t[2]):""},getBlocks:function(){return this.blocks},getTimeFormatOptions:function(){var e=this;return"12"===String(e.timeFormat)?{maxHourFirstDigit:1,maxHours:12,maxMinutesFirstDigit:5,maxMinutes:60}:{maxHourFirstDigit:2,maxHours:23,maxMinutesFirstDigit:5,maxMinutes:60}},getValidatedTime:function(e){var t=this,n="";e=e.replace(/[^\d]/g,"");var r=t.getTimeFormatOptions();return t.blocks.forEach(function(i,o){if(e.length>0){var a=e.slice(0,i),s=a.slice(0,1),c=e.slice(i);switch(t.timePattern[o]){case"h":parseInt(s,10)>r.maxHourFirstDigit?a="0"+s:parseInt(a,10)>r.maxHours&&(a=r.maxHours+"");break;case"m":case"s":parseInt(s,10)>r.maxMinutesFirstDigit?a="0"+s:parseInt(a,10)>r.maxMinutes&&(a=r.maxMinutes+"")}n+=a,e=c}}),this.getFixedTimeString(n)},getFixedTimeString:function(e){var t,n,r,i=this,o=i.timePattern,a=[],s=0,c=0,u=0,l=0,p=0,d=0;return 6===e.length&&(o.forEach(function(e,t){switch(e){case"s":s=2*t;break;case"m":c=2*t;break;case"h":u=2*t}}),d=u,p=c,l=s,t=parseInt(e.slice(l,l+2),10),n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(r,n,t)),4===e.length&&i.timePattern.indexOf("s")<0&&(o.forEach(function(e,t){switch(e){case"m":c=2*t;break;case"h":u=2*t}}),d=u,p=c,t=0,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(r,n,t)),i.time=a,0===a.length?e:o.reduce(function(e,t){switch(t){case"s":return e+i.addLeadingZero(a[2]);case"m":return e+i.addLeadingZero(a[1]);case"h":return e+i.addLeadingZero(a[0])}},"")},getFixedTime:function(e,t,n){return n=Math.min(parseInt(n||0,10),60),t=Math.min(t,60),e=Math.min(e,60),[e,t,n]},addLeadingZero:function(e){return(e<10?"0":"")+e}},e.exports=n},function(e,t){"use strict";var n=function(e,t){var n=this;n.delimiter=t||""===t?t:" ",n.delimiterRE=t?new RegExp("\\"+t,"g"):"",n.formatter=e};n.prototype={setFormatter:function(e){this.formatter=e},format:function(e){var t=this;t.formatter.clear(),e=e.replace(/[^\d+]/g,""),e=e.replace(/^\+/,"B").replace(/\+/g,"").replace("B","+"),e=e.replace(t.delimiterRE,"");for(var n,r="",i=!1,o=0,a=e.length;o0;return 0===n?e:(t.forEach(function(t,u){if(e.length>0){var l=e.slice(0,t),p=e.slice(t);a=c?i[o?u-1:u]||a:r,o?(u>0&&(s+=a),s+=l):(s+=l,l.length===t&&u0?r.numeralIntegerScale:0,e.numeralDecimalScale=r.numeralDecimalScale>=0?r.numeralDecimalScale:2,e.numeralDecimalMark=r.numeralDecimalMark||".",e.numeralThousandsGroupStyle=r.numeralThousandsGroupStyle||"thousand",e.numeralPositiveOnly=!!r.numeralPositiveOnly,e.stripLeadingZeroes=r.stripLeadingZeroes!==!1,e.signBeforePrefix=!!r.signBeforePrefix,e.numericOnly=e.creditCard||e.date||!!r.numericOnly,e.uppercase=!!r.uppercase,e.lowercase=!!r.lowercase,e.prefix=e.creditCard||e.date?"":r.prefix||"",e.noImmediatePrefix=!!r.noImmediatePrefix,e.prefixLength=e.prefix.length,e.rawValueTrimPrefix=!!r.rawValueTrimPrefix,e.copyDelimiter=!!r.copyDelimiter,e.initValue=void 0!==r.initValue&&null!==r.initValue?r.initValue.toString():"",e.delimiter=r.delimiter||""===r.delimiter?r.delimiter:r.date?"/":r.time?":":r.numeral?",":(r.phone," "),e.delimiterLength=e.delimiter.length,e.delimiterLazyShow=!!r.delimiterLazyShow,e.delimiters=r.delimiters||[],e.blocks=r.blocks||[],e.blocksLength=e.blocks.length,e.root="object"===("undefined"==typeof t?"undefined":n(t))&&t?t:window,e.document=r.document||e.root.document,e.maxLength=0,e.backspace=!1,e.result="",e.onValueChanged=r.onValueChanged||function(){},e}};e.exports=r}).call(t,function(){return this}()); -}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Cleave=t(require("react")):e.Cleave=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}var i=Object.assign||function(e){for(var t=1;t0?d.headStr(e,r.maxLength):e,r.result=d.getFormattedValue(e,r.blocks,r.blocksLength,r.delimiter,r.delimiters,r.delimiterLazyShow),void n.updateValueState()):(r.result=e,void n.updateValueState()))},updateCreditCardPropsByValue:function(e){var t,n=this,r=n.properties;d.headStr(r.result,4)!==d.headStr(e,4)&&(t=p.getInfo(e,r.creditCardStrictMode),r.blocks=t.blocks,r.blocksLength=r.blocks.length,r.maxLength=d.getMaxLength(r.blocks),r.creditCardType!==t.type&&(r.creditCardType=t.type,r.onCreditCardTypeChanged.call(n,r.creditCardType)))},updateValueState:function(){var e=this,t=e.properties;if(!e.element)return void e.setState({value:t.result});var n=e.element.selectionEnd,r=e.element.value,i=t.result;return e.lastInputValue=i,n=d.getNextCursorPosition(n,r,i,t.delimiter,t.delimiters),e.isAndroid?void window.setTimeout(function(){e.setState({value:i,cursorPosition:n})},1):void e.setState({value:i,cursorPosition:n})},render:function(){var e=this,t=e.props,n=(t.value,t.options,t.onKeyDown,t.onFocus,t.onBlur,t.onChange,t.onInit,t.htmlRef),a=r(t,["value","options","onKeyDown","onFocus","onBlur","onChange","onInit","htmlRef"]);return o.createElement("input",i({type:"text",ref:function(t){e.element=t,n&&n.apply(this,arguments)},value:e.state.value,onKeyDown:e.onKeyDown,onChange:e.onChange,onFocus:e.onFocus,onBlur:e.onBlur},a))}});e.exports=f},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=n(1),i=n(3);if("undefined"==typeof r)throw Error("create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.");var o=(new r.Component).updater;e.exports=i(r.Component,r.isValidElement,o)},function(e,t,n){(function(t){"use strict";function r(e){return e}function i(e,n,i){function p(e,n,r){for(var i in n)n.hasOwnProperty(i)&&"production"!==t.env.NODE_ENV&&c("function"==typeof n[i],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",e.displayName||"ReactClass",u[r],i)}function d(e,t){var n=b.hasOwnProperty(t)?b[t]:null;S.hasOwnProperty(t)&&s("OVERRIDE_BASE"===n,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",t),e&&s("DEFINE_MANY"===n||"DEFINE_MANY_MERGED"===n,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",t)}function m(e,r){if(r){s("function"!=typeof r,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),s(!n(r),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var i=e.prototype,o=i.__reactAutoBindPairs;r.hasOwnProperty(l)&&N.mixins(e,r.mixins);for(var a in r)if(r.hasOwnProperty(a)&&a!==l){var u=r[a],p=i.hasOwnProperty(a);if(d(p,a),N.hasOwnProperty(a))N[a](e,u);else{var m=b.hasOwnProperty(a),f="function"==typeof u,h=f&&!m&&!p&&r.autobind!==!1;if(h)o.push(a,u),i[a]=u;else if(p){var y=b[a];s(m&&("DEFINE_MANY_MERGED"===y||"DEFINE_MANY"===y),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",y,a),"DEFINE_MANY_MERGED"===y?i[a]=g(i[a],u):"DEFINE_MANY"===y&&(i[a]=v(i[a],u))}else i[a]=u,"production"!==t.env.NODE_ENV&&"function"==typeof u&&r.displayName&&(i[a].displayName=r.displayName+"_"+a)}}}else if("production"!==t.env.NODE_ENV){var E=typeof r,x="object"===E&&null!==r;"production"!==t.env.NODE_ENV&&c(x,"%s: You're attempting to include a mixin that is either null or not an object. Check the mixins included by the component, as well as any mixins they include themselves. Expected object but got %s.",e.displayName||"ReactClass",null===r?null:E)}}function f(e,t){if(t)for(var n in t){var r=t[n];if(t.hasOwnProperty(n)){var i=n in N;s(!i,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',n);var o=n in e;if(o){var a=w.hasOwnProperty(n)?w[n]:null;return s("DEFINE_MANY_MERGED"===a,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",n),void(e[n]=g(e[n],r))}e[n]=r}}}function h(e,t){s(e&&t&&"object"==typeof e&&"object"==typeof t,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var n in t)t.hasOwnProperty(n)&&(s(void 0===e[n],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",n),e[n]=t[n]);return e}function g(e,t){return function(){var n=e.apply(this,arguments),r=t.apply(this,arguments);if(null==n)return r;if(null==r)return n;var i={};return h(i,n),h(i,r),i}}function v(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function y(e,n){var r=n.bind(e);if("production"!==t.env.NODE_ENV){r.__reactBoundContext=e,r.__reactBoundMethod=n,r.__reactBoundArguments=null;var i=e.constructor.displayName,o=r.bind;r.bind=function(a){for(var s=arguments.length,u=Array(s>1?s-1:0),l=1;l1)for(var n=1;n1?t-1:0),r=1;r2?n-2:0),i=2;i0?t:0,l.numeralDecimalScale=n>=0?n:2,l.numeralThousandsGroupStyle=i||r.groupStyle.thousand,l.numeralPositiveOnly=!!o,l.stripLeadingZeroes=a!==!1,l.prefix=s||""===s?s:"",l.signBeforePrefix=!!c,l.delimiter=u||""===u?u:",",l.delimiterRE=u?new RegExp("\\"+u,"g"):""};n.groupStyle={thousand:"thousand",lakh:"lakh",wan:"wan",none:"none"},n.prototype={getRawValue:function(e){return e.replace(this.delimiterRE,"").replace(this.numeralDecimalMark,".")},format:function(e){var t,r,i,o,a=this,s="";switch(e=e.replace(/[A-Za-z]/g,"").replace(a.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",a.numeralPositiveOnly?"":"-").replace("M",a.numeralDecimalMark),a.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),r="-"===e.slice(0,1)?"-":"",i="undefined"!=typeof a.prefix?a.signBeforePrefix?r+a.prefix:a.prefix+r:r,o=e,e.indexOf(a.numeralDecimalMark)>=0&&(t=e.split(a.numeralDecimalMark),o=t[0],s=a.numeralDecimalMark+t[1].slice(0,a.numeralDecimalScale)),"-"===r&&(o=o.slice(1)),a.numeralIntegerScale>0&&(o=o.slice(0,a.numeralIntegerScale)),a.numeralThousandsGroupStyle){case n.groupStyle.lakh:o=o.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+a.delimiter);break;case n.groupStyle.wan:o=o.replace(/(\d)(?=(\d{4})+$)/g,"$1"+a.delimiter);break;case n.groupStyle.thousand:o=o.replace(/(\d)(?=(\d{3})+$)/g,"$1"+a.delimiter)}return i+o.toString()+(a.numeralDecimalScale>0?s.toString():"")}},e.exports=n},function(e,t){"use strict";var n=function(e,t,n){var r=this;r.date=[],r.blocks=[],r.datePattern=e,r.dateMin=t.split("-").reverse().map(function(e){return parseInt(e,10)}),2===r.dateMin.length&&r.dateMin.unshift(0),r.dateMax=n.split("-").reverse().map(function(e){return parseInt(e,10)}),2===r.dateMax.length&&r.dateMax.unshift(0),r.initBlocks()};n.prototype={initBlocks:function(){var e=this;e.datePattern.forEach(function(t){"Y"===t?e.blocks.push(4):e.blocks.push(2)})},getISOFormatDate:function(){var e=this,t=e.date;return t[2]?t[2]+"-"+e.addLeadingZero(t[1])+"-"+e.addLeadingZero(t[0]):""},getBlocks:function(){return this.blocks},getValidatedDate:function(e){var t=this,n="";return e=e.replace(/[^\d]/g,""),t.blocks.forEach(function(r,i){if(e.length>0){var o=e.slice(0,r),a=o.slice(0,1),s=e.slice(r);switch(t.datePattern[i]){case"d":"00"===o?o="01":parseInt(a,10)>3?o="0"+a:parseInt(o,10)>31&&(o="31");break;case"m":"00"===o?o="01":parseInt(a,10)>1?o="0"+a:parseInt(o,10)>12&&(o="12")}n+=o,e=s}}),this.getFixedDateString(n)},getFixedDateString:function(e){var t,n,r,i=this,o=i.datePattern,a=[],s=0,c=0,u=0,l=0,p=0,d=0,m=!1;4===e.length&&"y"!==o[0].toLowerCase()&&"y"!==o[1].toLowerCase()&&(l="d"===o[0]?0:2,p=2-l,t=parseInt(e.slice(l,l+2),10),n=parseInt(e.slice(p,p+2),10),a=this.getFixedDate(t,n,0)),8===e.length&&(o.forEach(function(e,t){switch(e){case"d":s=t;break;case"m":c=t;break;default:u=t}}),d=2*u,l=s<=u?2*s:2*s+2,p=c<=u?2*c:2*c+2,t=parseInt(e.slice(l,l+2),10),n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=this.getFixedDate(t,n,r)),4!==e.length||"y"!==o[0]&&"y"!==o[1]||(p="m"===o[0]?0:2,d=2-p,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),m=2===e.slice(d,d+2).length,a=[0,n,r]),6!==e.length||"Y"!==o[0]&&"Y"!==o[1]||(p="m"===o[0]?0:4,d=2-.5*p,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+4),10),m=4===e.slice(d,d+4).length,a=[0,n,r]),a=i.getRangeFixedDate(a),i.date=a;var f=0===a.length?e:o.reduce(function(e,t){switch(t){case"d":return e+(0===a[0]?"":i.addLeadingZero(a[0]));case"m":return e+(0===a[1]?"":i.addLeadingZero(a[1]));case"y":return e+(m?i.addLeadingZeroForYear(a[2],!1):"");case"Y":return e+(m?i.addLeadingZeroForYear(a[2],!0):"")}},"");return f},getRangeFixedDate:function(e){var t=this,n=t.datePattern,r=t.dateMin||[],i=t.dateMax||[];return!e.length||r.length<3&&i.length<3?e:n.find(function(e){return"y"===e.toLowerCase()})&&0===e[2]?e:i.length&&(i[2]e[2]||r[2]===e[2]&&(r[1]>e[1]||r[1]===e[1]&&r[0]>e[0]))?r:e},getFixedDate:function(e,t,n){return e=Math.min(e,31),t=Math.min(t,12),n=parseInt(n||0,10),(t<7&&t%2===0||t>8&&t%2===1)&&(e=Math.min(e,2===t?this.isLeapYear(n)?29:28:30)),[e,t,n]},isLeapYear:function(e){return e%4===0&&e%100!==0||e%400===0},addLeadingZero:function(e){return(e<10?"0":"")+e},addLeadingZeroForYear:function(e,t){return t?(e<10?"000":e<100?"00":e<1e3?"0":"")+e:(e<10?"0":"")+e}},e.exports=n},function(e,t){"use strict";var n=function(e,t){var n=this;n.time=[],n.blocks=[],n.timePattern=e,n.timeFormat=t,n.initBlocks()};n.prototype={initBlocks:function(){var e=this;e.timePattern.forEach(function(){e.blocks.push(2)})},getISOFormatTime:function(){var e=this,t=e.time;return t[2]?e.addLeadingZero(t[0])+":"+e.addLeadingZero(t[1])+":"+e.addLeadingZero(t[2]):""},getBlocks:function(){return this.blocks},getTimeFormatOptions:function(){var e=this;return"12"===String(e.timeFormat)?{maxHourFirstDigit:1,maxHours:12,maxMinutesFirstDigit:5,maxMinutes:60}:{maxHourFirstDigit:2,maxHours:23,maxMinutesFirstDigit:5,maxMinutes:60}},getValidatedTime:function(e){var t=this,n="";e=e.replace(/[^\d]/g,"");var r=t.getTimeFormatOptions();return t.blocks.forEach(function(i,o){if(e.length>0){var a=e.slice(0,i),s=a.slice(0,1),c=e.slice(i);switch(t.timePattern[o]){case"h":parseInt(s,10)>r.maxHourFirstDigit?a="0"+s:parseInt(a,10)>r.maxHours&&(a=r.maxHours+"");break;case"m":case"s":parseInt(s,10)>r.maxMinutesFirstDigit?a="0"+s:parseInt(a,10)>r.maxMinutes&&(a=r.maxMinutes+"")}n+=a,e=c}}),this.getFixedTimeString(n)},getFixedTimeString:function(e){var t,n,r,i=this,o=i.timePattern,a=[],s=0,c=0,u=0,l=0,p=0,d=0;return 6===e.length&&(o.forEach(function(e,t){switch(e){case"s":s=2*t;break;case"m":c=2*t;break;case"h":u=2*t}}),d=u,p=c,l=s,t=parseInt(e.slice(l,l+2),10),n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(r,n,t)),4===e.length&&i.timePattern.indexOf("s")<0&&(o.forEach(function(e,t){switch(e){case"m":c=2*t;break;case"h":u=2*t}}),d=u,p=c,t=0,n=parseInt(e.slice(p,p+2),10),r=parseInt(e.slice(d,d+2),10),a=this.getFixedTime(r,n,t)),i.time=a,0===a.length?e:o.reduce(function(e,t){switch(t){case"s":return e+i.addLeadingZero(a[2]);case"m":return e+i.addLeadingZero(a[1]);case"h":return e+i.addLeadingZero(a[0])}},"")},getFixedTime:function(e,t,n){return n=Math.min(parseInt(n||0,10),60),t=Math.min(t,60),e=Math.min(e,60),[e,t,n]},addLeadingZero:function(e){return(e<10?"0":"")+e}},e.exports=n},function(e,t){"use strict";var n=function(e,t){var n=this;n.delimiter=t||""===t?t:" ",n.delimiterRE=t?new RegExp("\\"+t,"g"):"",n.formatter=e};n.prototype={setFormatter:function(e){this.formatter=e},format:function(e){var t=this;t.formatter.clear(),e=e.replace(/[^\d+]/g,""),e=e.replace(/^\+/,"B").replace(/\+/g,"").replace("B","+"),e=e.replace(t.delimiterRE,"");for(var n,r="",i=!1,o=0,a=e.length;o0;return 0===n?e:(t.forEach(function(t,u){if(e.length>0){var l=e.slice(0,t),p=e.slice(t);a=c?i[o?u-1:u]||a:r,o?(u>0&&(s+=a),s+=l):(s+=l,l.length===t&&u0?r.numeralIntegerScale:0,e.numeralDecimalScale=r.numeralDecimalScale>=0?r.numeralDecimalScale:2,e.numeralDecimalMark=r.numeralDecimalMark||".",e.numeralThousandsGroupStyle=r.numeralThousandsGroupStyle||"thousand",e.numeralPositiveOnly=!!r.numeralPositiveOnly,e.stripLeadingZeroes=r.stripLeadingZeroes!==!1,e.signBeforePrefix=!!r.signBeforePrefix,e.numericOnly=e.creditCard||e.date||!!r.numericOnly,e.uppercase=!!r.uppercase, +e.lowercase=!!r.lowercase,e.prefix=e.creditCard||e.date?"":r.prefix||"",e.noImmediatePrefix=!!r.noImmediatePrefix,e.prefixLength=e.prefix.length,e.rawValueTrimPrefix=!!r.rawValueTrimPrefix,e.copyDelimiter=!!r.copyDelimiter,e.initValue=void 0!==r.initValue&&null!==r.initValue?r.initValue.toString():"",e.delimiter=r.delimiter||""===r.delimiter?r.delimiter:r.date?"/":r.time?":":r.numeral?",":(r.phone," "),e.delimiterLength=e.delimiter.length,e.delimiterLazyShow=!!r.delimiterLazyShow,e.delimiters=r.delimiters||[],e.blocks=r.blocks||[],e.blocksLength=e.blocks.length,e.root="object"===("undefined"==typeof t?"undefined":n(t))&&t?t:window,e.document=r.document||e.root.document,e.maxLength=0,e.backspace=!1,e.result="",e.onValueChanged=r.onValueChanged||function(){},e}};e.exports=r}).call(t,function(){return this}())}])}); \ No newline at end of file diff --git a/dist/cleave.min.js b/dist/cleave.min.js index 93cb8d7a..5f3ad62a 100644 --- a/dist/cleave.min.js +++ b/dist/cleave.min.js @@ -1,5 +1,5 @@ /*! - * cleave.js - 1.5.0 + * cleave.js - 1.5.1 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * diff --git a/package-lock.json b/package-lock.json index 876345e6..e2fa71bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cleave.js", - "version": "1.4.10", + "version": "1.5.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6ff46dd9..6c7b4b6b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "form", "input" ], - "version": "1.5.0", + "version": "1.5.1", "files": [ "src", "dist", diff --git a/yarn.lock b/yarn.lock index 6e157f64..0170d2a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,28 @@ # yarn lockfile v1 +"@babel/code-frame@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" + dependencies: + "@babel/highlight" "^7.0.0" + +"@babel/highlight@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" + dependencies: + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^4.0.0" + +"@types/estree@0.0.39": + version "0.0.39" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" + +"@types/node@^12.0.8": + version "12.0.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.10.tgz#51babf9c7deadd5343620055fc8aff7995c8b031" + JSONStream@^1.0.3: version "1.3.1" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.1.tgz#707f761e01dae9e16f1bcf93703b78c70966579a" @@ -31,6 +53,10 @@ acorn@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.1.tgz#53fe161111f912ab999ee887a90a0bc52822fd75" +acorn@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.1.1.tgz#7d25ae05bb8ad1f9b699108e1094ecd7884adc1f" + ajv-keywords@^1.0.0: version "1.5.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" @@ -70,6 +96,12 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + dependencies: + color-convert "^1.9.0" + anymatch@^1.3.0: version "1.3.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a" @@ -1157,6 +1189,10 @@ browserify@^14.0.0: vm-browserify "~0.0.1" xtend "^4.0.0" +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + buffer-xor@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" @@ -1233,6 +1269,14 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" +chalk@^2.0.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + chokidar@^1.0.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" @@ -1317,6 +1361,16 @@ code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + combine-source-map@~0.7.1: version "0.7.2" resolved "https://registry.yarnpkg.com/combine-source-map/-/combine-source-map-0.7.2.tgz#0870312856b307a87cc4ac486f3a9a62aeccc09e" @@ -1346,6 +1400,10 @@ commander@2.9.0: dependencies: graceful-readlink ">= 1.0.0" +commander@^2.19.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" + commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -1840,6 +1898,10 @@ estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" +estree-walker@^0.6.0, estree-walker@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" + esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -2434,6 +2496,10 @@ has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + has-gulplog@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" @@ -2815,10 +2881,21 @@ jade@0.26.3: commander "0.6.1" mkdirp "0.3.0" +jest-worker@^24.0.0: + version "24.6.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.6.0.tgz#7f81ceae34b7cde0c9827a6980c35b7cdc0161b3" + dependencies: + merge-stream "^1.0.1" + supports-color "^6.1.0" + js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" +js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + js-yaml@^3.5.1: version "3.9.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.1.tgz#08775cebdfdd359209f0d2acd383c8f86a6904a0" @@ -3123,6 +3200,12 @@ lru-cache@2: version "2.7.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" +magic-string@^0.25.2: + version "0.25.2" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.2.tgz#139c3a729515ec55e96e69e82a11fe890a293ad9" + dependencies: + sourcemap-codec "^1.4.4" + map-cache@^0.2.0: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -3145,6 +3228,12 @@ memory-fs@^0.3.0, memory-fs@~0.3.0: errno "^0.1.3" readable-stream "^2.0.1" +merge-stream@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1" + dependencies: + readable-stream "^2.0.1" + micromatch@^2.1.5, micromatch@^2.3.7: version "2.3.11" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" @@ -3570,6 +3659,10 @@ path-parse@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + path-platform@~0.11.15: version "0.11.15" resolved "https://registry.yarnpkg.com/path-platform/-/path-platform-0.11.15.tgz#e864217f74c36850f0852b78dc7bf7d4a5721bf2" @@ -3972,6 +4065,12 @@ resolve@^1.1.3, resolve@^1.1.4, resolve@^1.1.6, resolve@^1.1.7: dependencies: path-parse "^1.0.5" +resolve@^1.10.0: + version "1.11.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e" + dependencies: + path-parse "^1.0.6" + restore-cursor@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" @@ -4006,6 +4105,38 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^2.0.0" inherits "^2.0.1" +rollup-plugin-commonjs@^9.2.1: + version "9.3.4" + resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.3.4.tgz#2b3dddbbbded83d45c36ff101cdd29e924fd23bc" + dependencies: + estree-walker "^0.6.0" + magic-string "^0.25.2" + resolve "^1.10.0" + rollup-pluginutils "^2.6.0" + +rollup-plugin-terser@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-4.0.4.tgz#6f661ef284fa7c27963d242601691dc3d23f994e" + dependencies: + "@babel/code-frame" "^7.0.0" + jest-worker "^24.0.0" + serialize-javascript "^1.6.1" + terser "^3.14.1" + +rollup-pluginutils@^2.6.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz#8fa6dd0697344938ef26c2c09d2488ce9e33ce97" + dependencies: + estree-walker "^0.6.1" + +rollup@^1.7.0: + version "1.16.3" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.16.3.tgz#9b8bcf31523efc83447a9624bd2fe6ca58caa1e7" + dependencies: + "@types/estree" "0.0.39" + "@types/node" "^12.0.8" + acorn "^6.1.1" + run-async@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" @@ -4032,6 +4163,10 @@ sequencify@~0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" +serialize-javascript@^1.6.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.7.0.tgz#d6e0dfb2a3832a8c94468e6eb1db97e55a192a65" + set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" @@ -4130,16 +4265,31 @@ source-map-support@^0.4.15: dependencies: source-map "^0.5.6" +source-map-support@~0.5.10: + version "0.5.12" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599" + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + source-map@^0.5.1, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.3: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" +source-map@^0.6.0, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + source-map@~0.4.1: version "0.4.4" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" dependencies: amdefine ">=0.0.4" +sourcemap-codec@^1.4.4: + version "1.4.4" + resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.4.tgz#c63ea927c029dd6bd9a2b7fa03b3fec02ad56e9f" + sparkles@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" @@ -4273,6 +4423,18 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + dependencies: + has-flag "^3.0.0" + +supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + dependencies: + has-flag "^3.0.0" + syntax-error@^1.1.1: version "1.3.0" resolved "https://registry.yarnpkg.com/syntax-error/-/syntax-error-1.3.0.tgz#1ed9266c4d40be75dc55bf9bb1cb77062bb96ca1" @@ -4322,6 +4484,14 @@ temp@^0.8.3: os-tmpdir "^1.0.0" rimraf "~2.2.6" +terser@^3.14.1: + version "3.17.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-3.17.0.tgz#f88ffbeda0deb5637f9d24b0da66f4e15ab10cb2" + dependencies: + commander "^2.19.0" + source-map "~0.6.1" + source-map-support "~0.5.10" + text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"