diff --git a/bower.json b/bower.json index fc97f132..aa9216ce 100644 --- a/bower.json +++ b/bower.json @@ -8,7 +8,7 @@ "form", "input" ], - "version": "1.1.1", + "version": "1.1.2", "author": { "name": "Max Huang", "email": "risonhuang@gmail.com", diff --git a/dist/cleave-angular.min.js b/dist/cleave-angular.min.js index 01660b3c..64663b7a 100644 --- a/dist/cleave-angular.min.js +++ b/dist/cleave-angular.min.js @@ -1,5 +1,5 @@ /*! - * cleave.js - 1.1.1 + * cleave.js - 1.1.2 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * diff --git a/dist/cleave-react-node.js b/dist/cleave-react-node.js index 1eac10e8..76686e49 100644 --- a/dist/cleave-react-node.js +++ b/dist/cleave-react-node.js @@ -525,10 +525,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ (function(module, exports, __webpack_require__) { /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -559,10 +561,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ (function(module, exports, __webpack_require__) { /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -830,27 +834,6 @@ return /******/ (function(modules) { // webpackBootstrap */ componentWillUnmount: 'DEFINE_MANY', - /** - * Replacement for (deprecated) `componentWillMount`. - * - * @optional - */ - UNSAFE_componentWillMount: 'DEFINE_MANY', - - /** - * Replacement for (deprecated) `componentWillReceiveProps`. - * - * @optional - */ - UNSAFE_componentWillReceiveProps: 'DEFINE_MANY', - - /** - * Replacement for (deprecated) `componentWillUpdate`. - * - * @optional - */ - UNSAFE_componentWillUpdate: 'DEFINE_MANY', - // ==== Advanced methods ==== /** @@ -866,23 +849,6 @@ return /******/ (function(modules) { // webpackBootstrap updateComponent: 'OVERRIDE_BASE' }; - /** - * Similar to ReactClassInterface but for static methods. - */ - var ReactClassStaticInterface = { - /** - * This method is invoked after a component is instantiated and when it - * receives new props. Return an object to update state in response to - * prop changes. Return null to indicate no change to state. - * - * If an object is returned, its keys will be merged into the existing state. - * - * @return {object || null} - * @optional - */ - getDerivedStateFromProps: 'DEFINE_MANY_MERGED' - }; - /** * Mapping from class specification keys to special processing functions. * @@ -1117,7 +1083,6 @@ return /******/ (function(modules) { // webpackBootstrap if (!statics) { return; } - for (var name in statics) { var property = statics[name]; if (!statics.hasOwnProperty(name)) { @@ -1134,25 +1099,14 @@ return /******/ (function(modules) { // webpackBootstrap name ); - var isAlreadyDefined = name in Constructor; - if (isAlreadyDefined) { - var specPolicy = ReactClassStaticInterface.hasOwnProperty(name) - ? ReactClassStaticInterface[name] - : null; - - _invariant( - specPolicy === 'DEFINE_MANY_MERGED', - 'ReactClass: You are attempting to define ' + - '`%s` on your component more than once. This conflict may be ' + - 'due to a mixin.', - name - ); - - Constructor[name] = createMergedResultFunction(Constructor[name], property); - - return; - } - + var isInherited = name in Constructor; + _invariant( + !isInherited, + 'ReactClass: You are attempting to define ' + + '`%s` on your component more than once. This conflict may be ' + + 'due to a mixin.', + name + ); Constructor[name] = property; } } @@ -1462,12 +1416,6 @@ return /******/ (function(modules) { // webpackBootstrap 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component' ); - warning( - !Constructor.prototype.UNSAFE_componentWillRecieveProps, - '%s has a method called UNSAFE_componentWillRecieveProps(). ' + - 'Did you mean UNSAFE_componentWillReceiveProps()?', - spec.displayName || 'A component' - ); } // Reduce time spent doing lookups by setting these on the prototype. @@ -1588,9 +1536,11 @@ return /******/ (function(modules) { // webpackBootstrap /** * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -1610,9 +1560,11 @@ return /******/ (function(modules) { // webpackBootstrap /** * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -1667,10 +1619,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ (function(module, exports, __webpack_require__) { /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -1737,9 +1691,11 @@ return /******/ (function(modules) { // webpackBootstrap /** * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * * */ diff --git a/dist/cleave-react-node.min.js b/dist/cleave-react-node.min.js index 01d18df3..09e6af99 100644 --- a/dist/cleave-react-node.min.js +++ b/dist/cleave-react-node.min.js @@ -1,8 +1,8 @@ /*! - * cleave.js - 1.1.1 + * cleave.js - 1.1.2 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * * Copyright (C) 2012-2018 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 o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.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 o=Object.assign||function(e){for(var t=1;t0?p.headStr(e,n.maxLength):e,n.result=p.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;p.headStr(n.result,4)!==p.headStr(e,4)&&(t=u.getInfo(e,n.creditCardStrictMode),n.blocks=t.blocks,n.blocksLength=n.blocks.length,n.maxLength=p.getMaxLength(n.blocks),n.creditCardType!==t.type&&(n.creditCardType=t.type,n.onCreditCardTypeChanged.call(r,n.creditCardType)))},getNextCursorPosition:function(e,t,r){return t.length===e?r.length:e},setCurrentSelection:function(e){var t=this.element;if(this.setState({updateCursorPosition:!1}),t===document.activeElement)if(t.createTextRange){var r=t.createTextRange();r.move("character",e),r.select()}else t.setSelectionRange(e,e)},updateValueState:function(){var e=this;e.element||e.setState({value:e.properties.result});var t=e.element.selectionEnd,r=e.element.value,n=e.properties.result,o=e.getNextCursorPosition(t,r,n);return e.lastInputValue=e.properties.result,e.isAndroid?void window.setTimeout(function(){e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},1):void e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},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 i.createElement("input",o({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=m},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=r(1),o=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 i=(new n.Component).updater;e.exports=o(n.Component,n.isValidElement,i)},function(e,t,r){"use strict";function n(e){return e}function o(e,t,r){function o(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=N.hasOwnProperty(t)?N[t]:null;C.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,o=n.__reactAutoBindPairs;r.hasOwnProperty(u)&&x.mixins(e,r.mixins);for(var i in r)if(r.hasOwnProperty(i)&&i!==u){var a=r[i],l=n.hasOwnProperty(i);if(p(l,i),x.hasOwnProperty(i))x[i](e,a);else{var d=N.hasOwnProperty(i),m="function"==typeof a,f=m&&!d&&!l&&r.autobind!==!1;if(f)o.push(i,a),n[i]=a;else if(l){var v=N[i];s(d&&("DEFINE_MANY_MERGED"===v||"DEFINE_MANY"===v),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",v,i),"DEFINE_MANY_MERGED"===v?n[i]=h(n[i],a):"DEFINE_MANY"===v&&(n[i]=g(n[i],a))}else n[i]=a,"production"!==process.env.NODE_ENV&&"function"==typeof a&&r.displayName&&(n[i].displayName=r.displayName+"_"+i)}}}else if("production"!==process.env.NODE_ENV){var y=typeof r,E="object"===y&&null!==r;"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===r?null:y)}}function m(e,t){if(t)for(var r in t){var n=t[r];if(t.hasOwnProperty(r)){var o=r in x;s(!o,'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 i=r in e;if(i){var a=b.hasOwnProperty(r)?b[r]: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.",r),void(e[r]=h(e[r],n))}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 o={};return f(o,r),f(o,n),o}}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,o=r.bind;r.bind=function(i){for(var a=arguments.length,s=Array(a>1?a-1:0),l=1;l1?t-1:0),n=1;n2?r-2:0),o=2;o0?t:0,c.numeralDecimalScale=r>=0?r:2,c.numeralThousandsGroupStyle=o||n.groupStyle.thousand,c.numeralPositiveOnly=!!i,c.stripLeadingZeroes=a!==!1,c.delimiter=s||""===s?s:",",c.delimiterRE=s?new RegExp("\\"+s,"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,o=this,i="";switch(e=e.replace(/[A-Za-z]/g,"").replace(o.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",o.numeralPositiveOnly?"":"-").replace("M",o.numeralDecimalMark),o.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),n=e,e.indexOf(o.numeralDecimalMark)>=0&&(t=e.split(o.numeralDecimalMark),n=t[0],i=o.numeralDecimalMark+t[1].slice(0,o.numeralDecimalScale)),o.numeralIntegerScale>0&&(n=n.slice(0,o.numeralIntegerScale+("-"===e.slice(0,1)?1:0))),o.numeralThousandsGroupStyle){case r.groupStyle.lakh:n=n.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+o.delimiter);break;case r.groupStyle.wan:n=n.replace(/(\d)(?=(\d{4})+$)/g,"$1"+o.delimiter);break;case r.groupStyle.thousand:n=n.replace(/(\d)(?=(\d{3})+$)/g,"$1"+o.delimiter)}return n.toString()+(o.numeralDecimalScale>0?i.toString():"")}},e.exports=r},function(e,t){"use strict";var r=function(e){var t=this;t.date=[],t.blocks=[],t.datePattern=e,t.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,o){if(e.length>0){var i=e.slice(0,n),a=i.slice(0,1),s=e.slice(n);switch(t.datePattern[o]){case"d":"00"===i?i="01":parseInt(a,10)>3?i="0"+a:parseInt(i,10)>31&&(i="31");break;case"m":"00"===i?i="01":parseInt(a,10)>1?i="0"+a:parseInt(i,10)>12&&(i="12")}r+=i,e=s}}),this.getFixedDateString(r)},getFixedDateString:function(e){var t,r,n,o=this,i=o.datePattern,a=[],s=0,c=0,l=0,u=0,p=0,d=0;return 4===e.length&&"y"!==i[0].toLowerCase()&&"y"!==i[1].toLowerCase()&&(u="d"===i[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&&(i.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),a=this.getFixedDate(t,r,n)),o.date=a,0===a.length?e:i.reduce(function(e,t){switch(t){case"d":return e+o.addLeadingZero(a[0]);case"m":return e+o.addLeadingZero(a[1]);default:return e+""+(a[2]||"")}},"")},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}},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(t.delimiterRE,"");for(var r,n="",o=!1,i=0,a=e.length;i0;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?o[i?l-1:l]||a:n,i?(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.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.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.maxLength=0,e.backspace=!1,e.result="",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(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.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 o=Object.assign||function(e){for(var t=1;t0?p.headStr(e,n.maxLength):e,n.result=p.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;p.headStr(n.result,4)!==p.headStr(e,4)&&(t=l.getInfo(e,n.creditCardStrictMode),n.blocks=t.blocks,n.blocksLength=n.blocks.length,n.maxLength=p.getMaxLength(n.blocks),n.creditCardType!==t.type&&(n.creditCardType=t.type,n.onCreditCardTypeChanged.call(r,n.creditCardType)))},getNextCursorPosition:function(e,t,r){return t.length===e?r.length:e},setCurrentSelection:function(e){var t=this.element;if(this.setState({updateCursorPosition:!1}),t===document.activeElement)if(t.createTextRange){var r=t.createTextRange();r.move("character",e),r.select()}else t.setSelectionRange(e,e)},updateValueState:function(){var e=this;e.element||e.setState({value:e.properties.result});var t=e.element.selectionEnd,r=e.element.value,n=e.properties.result,o=e.getNextCursorPosition(t,r,n);return e.lastInputValue=e.properties.result,e.isAndroid?void window.setTimeout(function(){e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},1):void e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},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 i.createElement("input",o({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=m},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=r(1),o=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 i=(new n.Component).updater;e.exports=o(n.Component,n.isValidElement,i)},function(e,t,r){"use strict";function n(e){return e}function o(e,t,r){function o(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",u[r],n)}function p(e,t){var r=b.hasOwnProperty(t)?b[t]:null;C.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,o=n.__reactAutoBindPairs;r.hasOwnProperty(l)&&x.mixins(e,r.mixins);for(var i in r)if(r.hasOwnProperty(i)&&i!==l){var a=r[i],u=n.hasOwnProperty(i);if(p(u,i),x.hasOwnProperty(i))x[i](e,a);else{var d=b.hasOwnProperty(i),m="function"==typeof a,f=m&&!d&&!u&&r.autobind!==!1;if(f)o.push(i,a),n[i]=a;else if(u){var y=b[i];s(d&&("DEFINE_MANY_MERGED"===y||"DEFINE_MANY"===y),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",y,i),"DEFINE_MANY_MERGED"===y?n[i]=h(n[i],a):"DEFINE_MANY"===y&&(n[i]=g(n[i],a))}else n[i]=a,"production"!==process.env.NODE_ENV&&"function"==typeof a&&r.displayName&&(n[i].displayName=r.displayName+"_"+i)}}}else if("production"!==process.env.NODE_ENV){var v=typeof r,E="object"===v&&null!==r;"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===r?null:v)}}function m(e,t){if(t)for(var r in t){var n=t[r];if(t.hasOwnProperty(r)){var o=r in x;s(!o,'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 i=r in e;s(!i,"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 o={};return f(o,r),f(o,n),o}}function g(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function y(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,o=r.bind;r.bind=function(i){for(var a=arguments.length,s=Array(a>1?a-1:0),u=1;u1?t-1:0),n=1;n2?r-2:0),o=2;o0?t:0,c.numeralDecimalScale=r>=0?r:2,c.numeralThousandsGroupStyle=o||n.groupStyle.thousand,c.numeralPositiveOnly=!!i,c.stripLeadingZeroes=a!==!1,c.delimiter=s||""===s?s:",",c.delimiterRE=s?new RegExp("\\"+s,"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,o=this,i="";switch(e=e.replace(/[A-Za-z]/g,"").replace(o.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",o.numeralPositiveOnly?"":"-").replace("M",o.numeralDecimalMark),o.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),n=e,e.indexOf(o.numeralDecimalMark)>=0&&(t=e.split(o.numeralDecimalMark),n=t[0],i=o.numeralDecimalMark+t[1].slice(0,o.numeralDecimalScale)),o.numeralIntegerScale>0&&(n=n.slice(0,o.numeralIntegerScale+("-"===e.slice(0,1)?1:0))),o.numeralThousandsGroupStyle){case r.groupStyle.lakh:n=n.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+o.delimiter);break;case r.groupStyle.wan:n=n.replace(/(\d)(?=(\d{4})+$)/g,"$1"+o.delimiter);break;case r.groupStyle.thousand:n=n.replace(/(\d)(?=(\d{3})+$)/g,"$1"+o.delimiter)}return n.toString()+(o.numeralDecimalScale>0?i.toString():"")}},e.exports=r},function(e,t){"use strict";var r=function(e){var t=this;t.date=[],t.blocks=[],t.datePattern=e,t.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,o){if(e.length>0){var i=e.slice(0,n),a=i.slice(0,1),s=e.slice(n);switch(t.datePattern[o]){case"d":"00"===i?i="01":parseInt(a,10)>3?i="0"+a:parseInt(i,10)>31&&(i="31");break;case"m":"00"===i?i="01":parseInt(a,10)>1?i="0"+a:parseInt(i,10)>12&&(i="12")}r+=i,e=s}}),this.getFixedDateString(r)},getFixedDateString:function(e){var t,r,n,o=this,i=o.datePattern,a=[],s=0,c=0,u=0,l=0,p=0,d=0;return 4===e.length&&"y"!==i[0].toLowerCase()&&"y"!==i[1].toLowerCase()&&(l="d"===i[0]?0:2,p=2-l,t=parseInt(e.slice(l,l+2),10),r=parseInt(e.slice(p,p+2),10),a=this.getFixedDate(t,r,0)),8===e.length&&(i.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),r=parseInt(e.slice(p,p+2),10),n=parseInt(e.slice(d,d+4),10),a=this.getFixedDate(t,r,n)),o.date=a,0===a.length?e:i.reduce(function(e,t){switch(t){case"d":return e+o.addLeadingZero(a[0]);case"m":return e+o.addLeadingZero(a[1]);default:return e+""+(a[2]||"")}},"")},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}},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(t.delimiterRE,"");for(var r,n="",o=!1,i=0,a=e.length;i0;return 0===r?e:(t.forEach(function(t,u){if(e.length>0){var l=e.slice(0,t),p=e.slice(t);a=c?o[i?u-1:u]||a:n,i?(u>0&&(s+=a),s+=l):(s+=l,l.length===t&&u0?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.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.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.maxLength=0,e.backspace=!1,e.result="",e}};e.exports=n}])}); \ No newline at end of file diff --git a/dist/cleave-react.js b/dist/cleave-react.js index 626f90f5..1ab08b11 100644 --- a/dist/cleave-react.js +++ b/dist/cleave-react.js @@ -525,10 +525,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ (function(module, exports, __webpack_require__) { /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -559,10 +561,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -830,27 +834,6 @@ return /******/ (function(modules) { // webpackBootstrap */ componentWillUnmount: 'DEFINE_MANY', - /** - * Replacement for (deprecated) `componentWillMount`. - * - * @optional - */ - UNSAFE_componentWillMount: 'DEFINE_MANY', - - /** - * Replacement for (deprecated) `componentWillReceiveProps`. - * - * @optional - */ - UNSAFE_componentWillReceiveProps: 'DEFINE_MANY', - - /** - * Replacement for (deprecated) `componentWillUpdate`. - * - * @optional - */ - UNSAFE_componentWillUpdate: 'DEFINE_MANY', - // ==== Advanced methods ==== /** @@ -866,23 +849,6 @@ return /******/ (function(modules) { // webpackBootstrap updateComponent: 'OVERRIDE_BASE' }; - /** - * Similar to ReactClassInterface but for static methods. - */ - var ReactClassStaticInterface = { - /** - * This method is invoked after a component is instantiated and when it - * receives new props. Return an object to update state in response to - * prop changes. Return null to indicate no change to state. - * - * If an object is returned, its keys will be merged into the existing state. - * - * @return {object || null} - * @optional - */ - getDerivedStateFromProps: 'DEFINE_MANY_MERGED' - }; - /** * Mapping from class specification keys to special processing functions. * @@ -1117,7 +1083,6 @@ return /******/ (function(modules) { // webpackBootstrap if (!statics) { return; } - for (var name in statics) { var property = statics[name]; if (!statics.hasOwnProperty(name)) { @@ -1134,25 +1099,14 @@ return /******/ (function(modules) { // webpackBootstrap name ); - var isAlreadyDefined = name in Constructor; - if (isAlreadyDefined) { - var specPolicy = ReactClassStaticInterface.hasOwnProperty(name) - ? ReactClassStaticInterface[name] - : null; - - _invariant( - specPolicy === 'DEFINE_MANY_MERGED', - 'ReactClass: You are attempting to define ' + - '`%s` on your component more than once. This conflict may be ' + - 'due to a mixin.', - name - ); - - Constructor[name] = createMergedResultFunction(Constructor[name], property); - - return; - } - + var isInherited = name in Constructor; + _invariant( + !isInherited, + 'ReactClass: You are attempting to define ' + + '`%s` on your component more than once. This conflict may be ' + + 'due to a mixin.', + name + ); Constructor[name] = property; } } @@ -1462,12 +1416,6 @@ return /******/ (function(modules) { // webpackBootstrap 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component' ); - warning( - !Constructor.prototype.UNSAFE_componentWillRecieveProps, - '%s has a method called UNSAFE_componentWillRecieveProps(). ' + - 'Did you mean UNSAFE_componentWillReceiveProps()?', - spec.displayName || 'A component' - ); } // Reduce time spent doing lookups by setting these on the prototype. @@ -1779,9 +1727,11 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -1802,9 +1752,11 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -1860,10 +1812,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * */ @@ -1931,9 +1885,11 @@ return /******/ (function(modules) { // webpackBootstrap /** * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * * */ diff --git a/dist/cleave-react.min.js b/dist/cleave-react.min.js index e3e4b478..64484a3b 100644 --- a/dist/cleave-react.min.js +++ b/dist/cleave-react.min.js @@ -1,8 +1,8 @@ /*! - * cleave.js - 1.1.1 + * cleave.js - 1.1.2 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * * Copyright (C) 2012-2018 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 o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.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 o=Object.assign||function(e){for(var t=1;t0?p.headStr(e,r.maxLength):e,r.result=p.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;p.headStr(r.result,4)!==p.headStr(e,4)&&(t=l.getInfo(e,r.creditCardStrictMode),r.blocks=t.blocks,r.blocksLength=r.blocks.length,r.maxLength=p.getMaxLength(r.blocks),r.creditCardType!==t.type&&(r.creditCardType=t.type,r.onCreditCardTypeChanged.call(n,r.creditCardType)))},getNextCursorPosition:function(e,t,n){return t.length===e?n.length:e},setCurrentSelection:function(e){var t=this.element;if(this.setState({updateCursorPosition:!1}),t===document.activeElement)if(t.createTextRange){var n=t.createTextRange();n.move("character",e),n.select()}else t.setSelectionRange(e,e)},updateValueState:function(){var e=this;e.element||e.setState({value:e.properties.result});var t=e.element.selectionEnd,n=e.element.value,r=e.properties.result,o=e.getNextCursorPosition(t,n,r);return e.lastInputValue=e.properties.result,e.isAndroid?void window.setTimeout(function(){e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},1):void e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},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 i.createElement("input",o({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=m},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=n(1),o=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 i=(new r.Component).updater;e.exports=o(r.Component,r.isValidElement,i)},function(e,t,n){(function(t){"use strict";function r(e){return e}function o(e,n,o){function p(e,n,r){for(var o in n)n.hasOwnProperty(o)&&"production"!==t.env.NODE_ENV&&u("function"==typeof n[o],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",e.displayName||"ReactClass",c[r],o)}function d(e,t){var n=b.hasOwnProperty(t)?b[t]:null;_.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 o=e.prototype,i=o.__reactAutoBindPairs;r.hasOwnProperty(l)&&w.mixins(e,r.mixins);for(var a in r)if(r.hasOwnProperty(a)&&a!==l){var c=r[a],p=o.hasOwnProperty(a);if(d(p,a),w.hasOwnProperty(a))w[a](e,c);else{var m=b.hasOwnProperty(a),f="function"==typeof c,h=f&&!m&&!p&&r.autobind!==!1;if(h)i.push(a,c),o[a]=c;else if(p){var v=b[a];s(m&&("DEFINE_MANY_MERGED"===v||"DEFINE_MANY"===v),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",v,a),"DEFINE_MANY_MERGED"===v?o[a]=g(o[a],c):"DEFINE_MANY"===v&&(o[a]=y(o[a],c))}else o[a]=c,"production"!==t.env.NODE_ENV&&"function"==typeof c&&r.displayName&&(o[a].displayName=r.displayName+"_"+a)}}}else if("production"!==t.env.NODE_ENV){var E=typeof r,D="object"===E&&null!==r;"production"!==t.env.NODE_ENV&&u(D,"%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 o=n in w;s(!o,'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 i=n in e;if(i){var a=x.hasOwnProperty(n)?x[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 o={};return h(o,n),h(o,r),o}}function y(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function v(e,n){var r=n.bind(e);if("production"!==t.env.NODE_ENV){r.__reactBoundContext=e,r.__reactBoundMethod=n,r.__reactBoundArguments=null;var o=e.constructor.displayName,i=r.bind;r.bind=function(a){for(var s=arguments.length,c=Array(s>1?s-1:0),l=1;l1)for(var n=1;n1?t-1:0),r=1;r2?n-2:0),o=2;o0?t:0,u.numeralDecimalScale=n>=0?n:2,u.numeralThousandsGroupStyle=o||r.groupStyle.thousand,u.numeralPositiveOnly=!!i,u.stripLeadingZeroes=a!==!1,u.delimiter=s||""===s?s:",",u.delimiterRE=s?new RegExp("\\"+s,"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,o=this,i="";switch(e=e.replace(/[A-Za-z]/g,"").replace(o.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",o.numeralPositiveOnly?"":"-").replace("M",o.numeralDecimalMark),o.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),r=e,e.indexOf(o.numeralDecimalMark)>=0&&(t=e.split(o.numeralDecimalMark),r=t[0],i=o.numeralDecimalMark+t[1].slice(0,o.numeralDecimalScale)),o.numeralIntegerScale>0&&(r=r.slice(0,o.numeralIntegerScale+("-"===e.slice(0,1)?1:0))),o.numeralThousandsGroupStyle){case n.groupStyle.lakh:r=r.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+o.delimiter);break;case n.groupStyle.wan:r=r.replace(/(\d)(?=(\d{4})+$)/g,"$1"+o.delimiter);break;case n.groupStyle.thousand:r=r.replace(/(\d)(?=(\d{3})+$)/g,"$1"+o.delimiter)}return r.toString()+(o.numeralDecimalScale>0?i.toString():"")}},e.exports=n},function(e,t){"use strict";var n=function(e){var t=this;t.date=[],t.blocks=[],t.datePattern=e,t.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,o){if(e.length>0){var i=e.slice(0,r),a=i.slice(0,1),s=e.slice(r);switch(t.datePattern[o]){case"d":"00"===i?i="01":parseInt(a,10)>3?i="0"+a:parseInt(i,10)>31&&(i="31");break;case"m":"00"===i?i="01":parseInt(a,10)>1?i="0"+a:parseInt(i,10)>12&&(i="12")}n+=i,e=s}}),this.getFixedDateString(n)},getFixedDateString:function(e){var t,n,r,o=this,i=o.datePattern,a=[],s=0,u=0,c=0,l=0,p=0,d=0;return 4===e.length&&"y"!==i[0].toLowerCase()&&"y"!==i[1].toLowerCase()&&(l="d"===i[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&&(i.forEach(function(e,t){switch(e){case"d":s=t;break;case"m":u=t;break;default:c=t}}),d=2*c,l=s<=c?2*s:2*s+2,p=u<=c?2*u:2*u+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),a=this.getFixedDate(t,n,r)),o.date=a,0===a.length?e:i.reduce(function(e,t){switch(t){case"d":return e+o.addLeadingZero(a[0]);case"m":return e+o.addLeadingZero(a[1]);default:return e+""+(a[2]||"")}},"")},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}},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(t.delimiterRE,"");for(var n,r="",o=!1,i=0,a=e.length;i0;return 0===n?e:(t.forEach(function(t,c){if(e.length>0){var l=e.slice(0,t),p=e.slice(t);a=u?o[i?c-1:c]||a:r,i?(c>0&&(s+=a),s+=l):(s+=l,l.length===t&&c0?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.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.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.maxLength=0,e.backspace=!1,e.result="",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 o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.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 o=Object.assign||function(e){for(var t=1;t0?p.headStr(e,r.maxLength):e,r.result=p.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;p.headStr(r.result,4)!==p.headStr(e,4)&&(t=l.getInfo(e,r.creditCardStrictMode),r.blocks=t.blocks,r.blocksLength=r.blocks.length,r.maxLength=p.getMaxLength(r.blocks),r.creditCardType!==t.type&&(r.creditCardType=t.type,r.onCreditCardTypeChanged.call(n,r.creditCardType)))},getNextCursorPosition:function(e,t,n){return t.length===e?n.length:e},setCurrentSelection:function(e){var t=this.element;if(this.setState({updateCursorPosition:!1}),t===document.activeElement)if(t.createTextRange){var n=t.createTextRange();n.move("character",e),n.select()}else t.setSelectionRange(e,e)},updateValueState:function(){var e=this;e.element||e.setState({value:e.properties.result});var t=e.element.selectionEnd,n=e.element.value,r=e.properties.result,o=e.getNextCursorPosition(t,n,r);return e.lastInputValue=e.properties.result,e.isAndroid?void window.setTimeout(function(){e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},1):void e.setState({value:e.properties.result,cursorPosition:o,updateCursorPosition:!0})},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 i.createElement("input",o({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=m},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=n(1),o=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 i=(new r.Component).updater;e.exports=o(r.Component,r.isValidElement,i)},function(e,t,n){(function(t){"use strict";function r(e){return e}function o(e,n,o){function p(e,n,r){for(var o in n)n.hasOwnProperty(o)&&"production"!==t.env.NODE_ENV&&u("function"==typeof n[o],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",e.displayName||"ReactClass",c[r],o)}function d(e,t){var n=x.hasOwnProperty(t)?x[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 o=e.prototype,i=o.__reactAutoBindPairs;r.hasOwnProperty(l)&&w.mixins(e,r.mixins);for(var a in r)if(r.hasOwnProperty(a)&&a!==l){var c=r[a],p=o.hasOwnProperty(a);if(d(p,a),w.hasOwnProperty(a))w[a](e,c);else{var m=x.hasOwnProperty(a),f="function"==typeof c,h=f&&!m&&!p&&r.autobind!==!1;if(h)i.push(a,c),o[a]=c;else if(p){var v=x[a];s(m&&("DEFINE_MANY_MERGED"===v||"DEFINE_MANY"===v),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",v,a),"DEFINE_MANY_MERGED"===v?o[a]=g(o[a],c):"DEFINE_MANY"===v&&(o[a]=y(o[a],c))}else o[a]=c,"production"!==t.env.NODE_ENV&&"function"==typeof c&&r.displayName&&(o[a].displayName=r.displayName+"_"+a)}}}else if("production"!==t.env.NODE_ENV){var E=typeof r,D="object"===E&&null!==r;"production"!==t.env.NODE_ENV&&u(D,"%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 o=n in w;s(!o,'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 i=n in e;s(!i,"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 o={};return h(o,n),h(o,r),o}}function y(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function v(e,n){var r=n.bind(e);if("production"!==t.env.NODE_ENV){r.__reactBoundContext=e,r.__reactBoundMethod=n,r.__reactBoundArguments=null;var o=e.constructor.displayName,i=r.bind;r.bind=function(a){for(var s=arguments.length,c=Array(s>1?s-1:0),l=1;l1)for(var n=1;n1?t-1:0),r=1;r2?n-2:0),o=2;o0?t:0,u.numeralDecimalScale=n>=0?n:2,u.numeralThousandsGroupStyle=o||r.groupStyle.thousand,u.numeralPositiveOnly=!!i,u.stripLeadingZeroes=a!==!1,u.delimiter=s||""===s?s:",",u.delimiterRE=s?new RegExp("\\"+s,"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,o=this,i="";switch(e=e.replace(/[A-Za-z]/g,"").replace(o.numeralDecimalMark,"M").replace(/[^\dM-]/g,"").replace(/^\-/,"N").replace(/\-/g,"").replace("N",o.numeralPositiveOnly?"":"-").replace("M",o.numeralDecimalMark),o.stripLeadingZeroes&&(e=e.replace(/^(-)?0+(?=\d)/,"$1")),r=e,e.indexOf(o.numeralDecimalMark)>=0&&(t=e.split(o.numeralDecimalMark),r=t[0],i=o.numeralDecimalMark+t[1].slice(0,o.numeralDecimalScale)),o.numeralIntegerScale>0&&(r=r.slice(0,o.numeralIntegerScale+("-"===e.slice(0,1)?1:0))),o.numeralThousandsGroupStyle){case n.groupStyle.lakh:r=r.replace(/(\d)(?=(\d\d)+\d$)/g,"$1"+o.delimiter);break;case n.groupStyle.wan:r=r.replace(/(\d)(?=(\d{4})+$)/g,"$1"+o.delimiter);break;case n.groupStyle.thousand:r=r.replace(/(\d)(?=(\d{3})+$)/g,"$1"+o.delimiter)}return r.toString()+(o.numeralDecimalScale>0?i.toString():"")}},e.exports=n},function(e,t){"use strict";var n=function(e){var t=this;t.date=[],t.blocks=[],t.datePattern=e,t.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,o){if(e.length>0){var i=e.slice(0,r),a=i.slice(0,1),s=e.slice(r);switch(t.datePattern[o]){case"d":"00"===i?i="01":parseInt(a,10)>3?i="0"+a:parseInt(i,10)>31&&(i="31");break;case"m":"00"===i?i="01":parseInt(a,10)>1?i="0"+a:parseInt(i,10)>12&&(i="12")}n+=i,e=s}}),this.getFixedDateString(n)},getFixedDateString:function(e){var t,n,r,o=this,i=o.datePattern,a=[],s=0,u=0,c=0,l=0,p=0,d=0;return 4===e.length&&"y"!==i[0].toLowerCase()&&"y"!==i[1].toLowerCase()&&(l="d"===i[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&&(i.forEach(function(e,t){switch(e){case"d":s=t;break;case"m":u=t;break;default:c=t}}),d=2*c,l=s<=c?2*s:2*s+2,p=u<=c?2*u:2*u+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),a=this.getFixedDate(t,n,r)),o.date=a,0===a.length?e:i.reduce(function(e,t){switch(t){case"d":return e+o.addLeadingZero(a[0]);case"m":return e+o.addLeadingZero(a[1]);default:return e+""+(a[2]||"")}},"")},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}},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(t.delimiterRE,"");for(var n,r="",o=!1,i=0,a=e.length;i0;return 0===n?e:(t.forEach(function(t,c){if(e.length>0){var l=e.slice(0,t),p=e.slice(t);a=u?o[i?c-1:c]||a:r,i?(c>0&&(s+=a),s+=l):(s+=l,l.length===t&&c0?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.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.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.maxLength=0,e.backspace=!1,e.result="",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 325b4419..e39d3b1c 100644 --- a/dist/cleave.min.js +++ b/dist/cleave.min.js @@ -1,5 +1,5 @@ /*! - * cleave.js - 1.1.1 + * cleave.js - 1.1.2 * https://github.com/nosir/cleave.js * Apache License Version 2.0 * diff --git a/package.json b/package.json index 03e7b9cf..e6d1b76e 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "form", "input" ], - "version": "1.1.1", + "version": "1.1.2", "author": { "name": "Max Huang", "url": "http://github.com/nosir",