!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["rc-input-number"]=t(require("react")):e["rc-input-number"]=t(e.React)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){n(1),e.exports=n(5)},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(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}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(){}function l(e){e.preventDefault()}function c(e){return e.replace(/[^\w.-]+/g,"")}Object.defineProperty(t,"__esModule",{value:!0});var p=n(2),f=n.n(p),h=n(3),d=n.n(h),v=n(4),E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},N=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),m=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,y=function(e){return void 0!==e&&null!==e},S=function(e,t){return t===e||"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)},b=function(e){function t(e){a(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));M.call(n);var r=void 0;r="value"in e?e.value:e.defaultValue,n.state={focused:e.autoFocus};var o=n.getValidValue(n.toNumber(r));return n.state=E({},n.state,{inputValue:n.toPrecisionAsStep(o),value:o}),n}return s(t,e),N(t,[{key:"componentDidMount",value:function(){this.componentDidUpdate()}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.value,r=t.onChange,o=t.max,a=t.min,i=this.state.focused;if(e){if(!S(e.value,n)||!S(e.max,o)||!S(e.min,a)){var s=i?n:this.getValidValue(n),u=void 0;u=this.pressingUpOrDown?s:this.inputting?this.rawInput:this.toPrecisionAsStep(s),this.setState({value:s,inputValue:u})}var l="value"in this.props?n:this.state.value;"max"in this.props&&e.max!==o&&"number"==typeof l&&l>o&&r&&r(o),"min"in this.props&&e.min!==a&&"number"==typeof l&&l<a&&r&&r(a)}try{if(void 0!==this.cursorStart&&this.state.focused)if(this.partRestoreByAfter(this.cursorAfter)||this.state.value===this.props.value){if(this.currentValue===this.input.value)switch(this.lastKeyCode){case v.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case v.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1)}}else{var c=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===v.a.BACKSPACE?c=this.cursorStart-1:this.lastKeyCode===v.a.DELETE&&(c=this.cursorStart):c=this.input.value.length,this.fixCaret(c,c)}}catch(e){}this.lastKeyCode=null,this.pressingUpOrDown&&this.props.focusOnUpDown&&this.state.focused&&document.activeElement!==this.input&&this.focus()}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(e){var t=e;return t=""===t?"":this.isNotCompleteNumber(parseFloat(t,10))?this.state.value:this.getValidValue(t),this.toNumber(t)}},{key:"getRatio",value:function(e){var t=1;return e.metaKey||e.ctrlKey?t=.1:e.shiftKey&&(t=10),t}},{key:"getValueFromEvent",value:function(e){var t=e.target.value.trim().replace(/。/g,".");return y(this.props.decimalSeparator)&&(t=t.replace(this.props.decimalSeparator,".")),t}},{key:"getValidValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.props.min,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.props.max,r=parseFloat(e,10);return isNaN(r)?e:(r<t&&(r=t),r>n&&(r=n),r)}},{key:"setValue",value:function(e,t){var n=this.props.precision,r=this.isNotCompleteNumber(parseFloat(e,10))?null:parseFloat(e,10),o=this.state,a=o.value,i=void 0===a?null:a,s=o.inputValue,u=void 0===s?null:s,l="number"==typeof r?r.toFixed(n):""+r,c=r!==i||l!==""+u;return"value"in this.props?this.setState({inputValue:this.toPrecisionAsStep(this.state.value)},t):this.setState({value:r,inputValue:this.toPrecisionAsStep(e)},t),c&&this.props.onChange(r),r}},{key:"getFullNum",value:function(e){return isNaN(e)?e:/e/i.test(String(e))?e.toFixed(18).replace(/\.?0+$/,""):e}},{key:"getPrecision",value:function(e){if(y(this.props.precision))return this.props.precision;var t=e.toString();if(t.indexOf("e-")>=0)return parseInt(t.slice(t.indexOf("e-")+2),10);var n=0;return t.indexOf(".")>=0&&(n=t.length-t.indexOf(".")-1),n}},{key:"getMaxPrecision",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.props,r=n.precision,o=n.step;if(y(r))return r;var a=this.getPrecision(t),i=this.getPrecision(o),s=this.getPrecision(e);return e?Math.max(s,a+i):a+i}},{key:"getPrecisionFactor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.getMaxPrecision(e,t);return Math.pow(10,n)}},{key:"fixCaret",value:function(e,t){if(void 0!==e&&void 0!==t&&this.input&&this.input.value)try{var n=this.input.selectionStart,r=this.input.selectionEnd;e===n&&t===r||this.input.setSelectionRange(e,t)}catch(e){}}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(e){return this.props.formatter?this.props.formatter(e):e}},{key:"toPrecisionAsStep",value:function(e){if(this.isNotCompleteNumber(e)||""===e)return e;var t=Math.abs(this.getMaxPrecision(e));return isNaN(t)?e.toString():Number(e).toFixed(t)}},{key:"isNotCompleteNumber",value:function(e){return isNaN(e)||""===e||null===e||e&&e.toString().indexOf(".")===e.toString().length-1}},{key:"toNumber",value:function(e){var t=this.props.precision,n=this.state.focused,r=e&&e.length>16&&n;return this.isNotCompleteNumber(e)||r?e:y(t)?Math.round(e*Math.pow(10,t))/Math.pow(10,t):Number(e)}},{key:"upStep",value:function(e,t){var n=this.props.step,r=this.getPrecisionFactor(e,t),o=Math.abs(this.getMaxPrecision(e,t)),a=((r*e+r*n*t)/r).toFixed(o);return this.toNumber(a)}},{key:"downStep",value:function(e,t){var n=this.props.step,r=this.getPrecisionFactor(e,t),o=Math.abs(this.getMaxPrecision(e,t)),a=((r*e-r*n*t)/r).toFixed(o);return this.toNumber(a)}},{key:"step",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments[3];this.stop(),t&&(t.persist(),t.preventDefault());var a=this.props;if(!a.disabled){var i=this.getCurrentValidValue(this.state.inputValue)||0;if(!this.isNotCompleteNumber(i)){var s=this[e+"Step"](i,r),u=s>a.max||s<a.min;s>a.max?s=a.max:s<a.min&&(s=a.min),this.setValue(s),this.setState({focused:!0},function(){n.pressingUpOrDown=!1}),u||(this.autoStepTimer=setTimeout(function(){n[e](t,r,!0)},o?200:600))}}}},{key:"render",value:function(){var e,t=this.props,n=t.prefixCls,a=t.disabled,i=t.readOnly,s=t.useTouch,c=t.autoComplete,p=t.upHandler,h=t.downHandler,v=t.className,N=t.max,m=t.min,y=t.style,S=t.title,b=t.onMouseEnter,M=t.onMouseLeave,C=t.onMouseOver,O=t.onMouseOut,g=t.required,A=t.onClick,U=t.tabIndex,P=t.type,_=t.placeholder,T=t.id,x=t.inputMode,I=t.pattern,w=t.step,F=t.maxLength,R=t.autoFocus,K=t.name,D=o(t,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name"]),V=this.state,L=V.value,k=V.focused,H=d()(n,(e={},r(e,v,!!v),r(e,n+"-disabled",a),r(e,n+"-focused",k),e)),B={};Object.keys(D).forEach(function(e){"data-"!==e.substr(0,5)&&"aria-"!==e.substr(0,5)&&"role"!==e||(B[e]=D[e])});var j=!i&&!a,W=this.getInputDisplayValue(),G=(L||0===L)&&(isNaN(L)||Number(L)>=N),Q=(L||0===L)&&(isNaN(L)||Number(L)<=m),Y=G||a||i,q=Q||a||i,X=d()(n+"-handler",n+"-handler-up",r({},n+"-handler-up-disabled",Y)),Z=d()(n+"-handler",n+"-handler-down",r({},n+"-handler-down-disabled",q)),J=s?{onTouchStart:Y?u:this.up,onTouchEnd:this.stop}:{onMouseDown:Y?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},$=s?{onTouchStart:q?u:this.down,onTouchEnd:this.stop}:{onMouseDown:q?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return f.a.createElement("div",{className:H,style:y,title:S,onMouseEnter:b,onMouseLeave:M,onMouseOver:C,onMouseOut:O,onFocus:function(){return null},onBlur:function(){return null}},f.a.createElement("div",{className:n+"-handler-wrap"},f.a.createElement("span",E({unselectable:"unselectable"},J,{role:"button","aria-label":"Increase Value","aria-disabled":Y,className:X}),p||f.a.createElement("span",{unselectable:"unselectable",className:n+"-handler-up-inner",onClick:l})),f.a.createElement("span",E({unselectable:"unselectable"},$,{role:"button","aria-label":"Decrease Value","aria-disabled":q,className:Z}),h||f.a.createElement("span",{unselectable:"unselectable",className:n+"-handler-down-inner",onClick:l}))),f.a.createElement("div",{className:n+"-input-wrap"},f.a.createElement("input",E({role:"spinbutton","aria-valuemin":m,"aria-valuemax":N,"aria-valuenow":L,required:g,type:P,placeholder:_,onClick:A,onMouseUp:this.onMouseUp,className:n+"-input",tabIndex:U,autoComplete:c,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:j?this.onKeyDown:u,onKeyUp:j?this.onKeyUp:u,autoFocus:R,maxLength:F,readOnly:i,disabled:a,max:N,min:m,step:w,name:K,title:S,id:T,onChange:this.onChange,ref:this.saveInput,value:W,pattern:I,inputMode:x},B))))}}]),t}(f.a.Component);b.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",min:-m,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:c,required:!1,autoComplete:"off"};var M=function(){var e=this;this.onKeyDown=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var a=e.props,i=a.onKeyDown,s=a.onPressEnter;if(t.keyCode===v.a.UP){var u=e.getRatio(t);e.up(t,u),e.stop()}else if(t.keyCode===v.a.DOWN){var l=e.getRatio(t);e.down(t,l),e.stop()}else t.keyCode===v.a.ENTER&&s&&s(t);e.recordCursorPosition(),e.lastKeyCode=t.keyCode,i&&i.apply(void 0,[t].concat(r))},this.onKeyUp=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var a=e.props.onKeyUp;e.stop(),e.recordCursorPosition(),a&&a.apply(void 0,[t].concat(r))},this.onChange=function(t){var n=e.props.onChange;e.state.focused&&(e.inputting=!0),e.rawInput=e.props.parser(e.getValueFromEvent(t)),e.setState({inputValue:e.rawInput}),n(e.toNumber(e.rawInput))},this.onMouseUp=function(){var t=e.props.onMouseUp;e.recordCursorPosition(),t&&t.apply(void 0,arguments)},this.onFocus=function(){var t;e.setState({focused:!0}),(t=e.props).onFocus.apply(t,arguments)},this.onBlur=function(){var t=e.props.onBlur;e.inputting=!1,e.setState({focused:!1});var n=e.getCurrentValidValue(e.state.inputValue),r=e.setValue(n);if(t){var o=e.input.value,a=Number(e.getInputDisplayValue({focus:!1,value:r}));e.input.value=a,t.apply(void 0,arguments),e.input.value=o}},this.getInputDisplayValue=function(t){var n=t||e.state,r=n.focused,o=n.inputValue,a=n.value,i=void 0;void 0!==(i=r?o:e.toPrecisionAsStep(a))&&null!==i||(i="");var s=e.formatWrapper(i);return y(e.props.decimalSeparator)&&(s=s.toString().replace(".",e.props.decimalSeparator)),e.getFullNum(s)},this.recordCursorPosition=function(){try{e.cursorStart=e.input.selectionStart,e.cursorEnd=e.input.selectionEnd,e.currentValue=e.input.value,e.cursorBefore=e.input.value.substring(0,e.cursorStart),e.cursorAfter=e.input.value.substring(e.cursorEnd)}catch(e){}},this.restoreByAfter=function(t){if(void 0===t)return!1;var n=e.input.value,r=n.lastIndexOf(t);if(-1===r)return!1;var o=e.cursorBefore.length;return e.lastKeyCode===v.a.DELETE&&e.cursorBefore.charAt(o-1)===t[0]?(e.fixCaret(o,o),!0):r+t.length===n.length&&(e.fixCaret(r,r),!0)},this.partRestoreByAfter=function(t){return void 0!==t&&Array.prototype.some.call(t,function(n,r){var o=t.substring(r);return e.restoreByAfter(o)})},this.stop=function(){e.autoStepTimer&&clearTimeout(e.autoStepTimer)},this.down=function(t,n,r){e.pressingUpOrDown=!0,e.step("down",t,n,r)},this.up=function(t,n,r){e.pressingUpOrDown=!0,e.step("up",t,n,r)},this.saveInput=function(t){e.input=t}};t.default=b},function(t,n){t.exports=e},function(e,t,n){var r,o;!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var i=n.apply(null,r);i&&e.push(i)}else if("object"===o)for(var s in r)a.call(r,s)&&r[s]&&e.push(s)}}return e.join(" ")}var a={}.hasOwnProperty;void 0!==e&&e.exports?(n.default=n,e.exports=n):(r=[],void 0!==(o=function(){return n}.apply(t,r))&&(e.exports=o))}()},function(e,t,n){"use strict";var r={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(e){var t=e.keyCode;if(e.altKey&&!e.ctrlKey||e.metaKey||t>=r.F1&&t<=r.F12)return!1;switch(t){case r.ALT:case r.CAPS_LOCK:case r.CONTEXT_MENU:case r.CTRL:case r.DOWN:case r.END:case r.ESC:case r.HOME:case r.INSERT:case r.LEFT:case r.MAC_FF_META:case r.META:case r.NUMLOCK:case r.NUM_CENTER:case r.PAGE_DOWN:case r.PAGE_UP:case r.PAUSE:case r.PRINT_SCREEN:case r.RIGHT:case r.SHIFT:case r.UP:case r.WIN_KEY:case r.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(e){if(e>=r.ZERO&&e<=r.NINE)return!0;if(e>=r.NUM_ZERO&&e<=r.NUM_MULTIPLY)return!0;if(e>=r.A&&e<=r.Z)return!0;if(-1!==window.navigator.userAgent.indexOf("WebKit")&&0===e)return!0;switch(e){case r.SPACE:case r.QUESTION_MARK:case r.NUM_PLUS:case r.NUM_MINUS:case r.NUM_PERIOD:case r.NUM_DIVISION:case r.SEMICOLON:case r.DASH:case r.EQUALS:case r.COMMA:case r.PERIOD:case r.SLASH:case r.APOSTROPHE:case r.SINGLE_QUOTE:case r.OPEN_SQUARE_BRACKET:case r.BACKSLASH:case r.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}};t.a=r},function(e,t){}]).default});