katoikia-app/web-ui/web-react/node_modules/primereact/inputnumber/inputnumber.cjs.min.js

2 lines
25 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/inputtext"),n=require("primereact/utils"),i=require("primereact/tooltip"),r=require("primereact/ripple");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function u(e){if(Array.isArray(e))return a(e)}function l(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function p(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}function c(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){return m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},m(e,t)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function g(e,t){if(t&&("object"===v(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var k=function(s){y(C,e.Component);var a,m,v,x,w,k=(a=C,m=I(),function(){var e,t=b(a);if(m){var n=b(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function C(t){var n;return h(this,C),(n=k.call(this,t)).state={focused:!1},n.constructParser(),n.onInput=n.onInput.bind(d(n)),n.onInputKeyDown=n.onInputKeyDown.bind(d(n)),n.onInputKeyPress=n.onInputKeyPress.bind(d(n)),n.onInputClick=n.onInputClick.bind(d(n)),n.onInputBlur=n.onInputBlur.bind(d(n)),n.onInputFocus=n.onInputFocus.bind(d(n)),n.onPaste=n.onPaste.bind(d(n)),n.onUpButtonMouseLeave=n.onUpButtonMouseLeave.bind(d(n)),n.onUpButtonMouseDown=n.onUpButtonMouseDown.bind(d(n)),n.onUpButtonMouseUp=n.onUpButtonMouseUp.bind(d(n)),n.onUpButtonKeyDown=n.onUpButtonKeyDown.bind(d(n)),n.onUpButtonKeyUp=n.onUpButtonKeyUp.bind(d(n)),n.onDownButtonMouseLeave=n.onDownButtonMouseLeave.bind(d(n)),n.onDownButtonMouseDown=n.onDownButtonMouseDown.bind(d(n)),n.onDownButtonMouseUp=n.onDownButtonMouseUp.bind(d(n)),n.onDownButtonKeyDown=n.onDownButtonKeyDown.bind(d(n)),n.onDownButtonKeyUp=n.onDownButtonKeyUp.bind(d(n)),n.inputRef=e.createRef(n.props.inputRef),n}return v=C,x=[{key:"getOptions",value:function(){return{localeMatcher:this.props.localeMatcher,style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,useGrouping:this.props.useGrouping,minimumFractionDigits:this.props.minFractionDigits,maximumFractionDigits:this.props.maxFractionDigits}}},{key:"constructParser",value:function(){this.numberFormat=new Intl.NumberFormat(this.props.locale,this.getOptions());var e,t=(e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1}).format(9876543210),u(e)||l(e)||p(e)||c()).reverse(),n=new Map(t.map((function(e,t){return[e,t]})));this._numeral=new RegExp("[".concat(t.join(""),"]"),"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=function(e){return n.get(e)}}},{key:"escapeRegExp",value:function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},{key:"getDecimalExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,D(D({},this.getOptions()),{},{useGrouping:!1}));return new RegExp("[".concat(e.format(1.1).replace(this._currency,"").trim().replace(this._numeral,""),"]"),"g")}},{key:"getGroupingExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!0});return this.groupChar=e.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp("[".concat(this.groupChar,"]"),"g")}},{key:"getMinusSignExpression",value:function(){var e=new Intl.NumberFormat(this.props.locale,{useGrouping:!1});return new RegExp("[".concat(e.format(-1).trim().replace(this._numeral,""),"]"),"g")}},{key:"getCurrencyExpression",value:function(){if(this.props.currency){var e=new Intl.NumberFormat(this.props.locale,{style:"currency",currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp("[".concat(e.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,""),"]"),"g")}return new RegExp("[]","g")}},{key:"getPrefixExpression",value:function(){if(this.props.prefix)this.prefixChar=this.props.prefix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay});this.prefixChar=e.format(1).split("1")[0]}return new RegExp("".concat(this.escapeRegExp(this.prefixChar||"")),"g")}},{key:"getSuffixExpression",value:function(){if(this.props.suffix)this.suffixChar=this.props.suffix;else{var e=new Intl.NumberFormat(this.props.locale,{style:this.props.mode,currency:this.props.currency,currencyDisplay:this.props.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=e.format(1).split("1")[1]}return new RegExp("".concat(this.escapeRegExp(this.suffixChar||"")),"g")}},{key:"formatValue",value:function(e){if(null!=e){if("-"===e)return e;if(this.props.format){var t=new Intl.NumberFormat(this.props.locale,this.getOptions()).format(e);return this.props.prefix&&(t=this.props.prefix+t),this.props.suffix&&(t+=this.props.suffix),t}return e.toString()}return""}},{key:"parseValue",value:function(e){var t=e.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(t){if("-"===t)return t;var n=+t;return isNaN(n)?null:n}return null}},{key:"repeat",value:function(e,t,n){var i=this,r=t||500;this.clearTimer(),this.timer=setTimeout((function(){i.repeat(e,40,n)}),r),this.spin(e,n)}},{key:"spin",value:function(e,t){if(this.inputRef&&this.inputRef.current){var n=this.props.step*t,i=this.parseValue(this.inputRef.current.value)||0,r=this.validateValue(i+n);this.updateInput(r,null,"spin"),this.updateModel(e,r),this.handleOnChange(e,i,r)}}},{key:"onUpButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,1),e.preventDefault())}},{key:"onUpButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onUpButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)}},{key:"onDownButtonMouseDown",value:function(e){this.props.disabled||this.props.readOnly||(this.inputRef.current.focus(),this.repeat(e,null,-1),e.preventDefault())}},{key:"onDownButtonMouseUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonMouseLeave",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyUp",value:function(){this.props.disabled||this.props.readOnly||this.clearTimer()}},{key:"onDownButtonKeyDown",value:function(e){this.props.disabled||this.props.readOnly||32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,-1)}},{key:"onInput",value:function(e){this.props.disabled||this.props.readOnly||(this.isSpecialChar&&(e.target.value=this.lastValue),this.isSpecialChar=!1)}},{key:"onInputKeyDown",value:function(e){if(!this.props.disabled&&!this.props.readOnly)if(this.lastValue=e.target.value,e.shiftKey||e.altKey)this.isSpecialChar=!0;else{var t=e.target.selectionStart,n=e.target.selectionEnd,i=e.target.value,r=null;switch(e.altKey&&e.preventDefault(),e.which){case 38:this.spin(e,1),e.preventDefault();break;case 40:this.spin(e,-1),e.preventDefault();break;case 37:this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case 39:this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case 13:r=this.validateValue(this.parseValue(i)),this.inputRef.current.value=this.formatValue(r),this.inputRef.current.setAttribute("aria-valuenow",r),this.updateModel(e,r);break;case 8:if(e.preventDefault(),t===n){var s=i.charAt(t-1),o=this.getDecimalCharIndexes(i),a=o.decimalCharIndex,u=o.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(s)){var l=this.getDecimalLength(i);if(this._group.test(s))this._group.lastIndex=0,r=i.slice(0,t-2)+i.slice(t-1);else if(this._decimal.test(s))this._decimal.lastIndex=0,l?this.inputRef.current.setSelectionRange(t-1,t-1):r=i.slice(0,t-1)+i.slice(t);else if(a>0&&t>a){var p=this.isDecimalMode()&&(this.props.minFractionDigits||0)<l?"":"0";r=i.slice(0,t-1)+p+i.slice(t)}else 1===u?(r=i.slice(0,t-1)+"0"+i.slice(t),r=this.parseValue(r)>0?r:""):r=i.slice(0,t-1)+i.slice(t)}this.updateValue(e,r,null,"delete-single")}else r=this.deleteRange(i,t,n),this.updateValue(e,r,null,"delete-range");break;case 46:if(e.preventDefault(),t===n){var c=i.charAt(t),h=this.getDecimalCharIndexes(i),f=h.decimalCharIndex,d=h.decimalCharIndexWithoutPrefix;if(this.isNumeralChar(c)){var m=this.getDecimalLength(i);if(this._group.test(c))this._group.lastIndex=0,r=i.slice(0,t)+i.slice(t+2);else if(this._decimal.test(c))this._decimal.lastIndex=0,m?this.$refs.input.$el.setSelectionRange(t+1,t+1):r=i.slice(0,t)+i.slice(t+1);else if(f>0&&t>f){var y=this.isDecimalMode()&&(this.props.minFractionDigits||0)<m?"":"0";r=i.slice(0,t)+y+i.slice(t+1)}else 1===d?(r=i.slice(0,t)+"0"+i.slice(t+1),r=this.parseValue(r)>0?r:""):r=i.slice(0,t)+i.slice(t+1)}this.updateValue(e,r,null,"delete-back-single")}else r=this.deleteRange(i,t,n),this.updateValue(e,r,null,"delete-range")}this.props.onKeyDown&&this.props.onKeyDown(e)}}},{key:"onInputKeyPress",value:function(e){if(!this.props.disabled&&!this.props.readOnly){var t=e.which||e.keyCode,n=String.fromCharCode(t),i=this.isDecimalSign(n),r=this.isMinusSign(n);(48<=t&&t<=57||r||i)&&(this.insert(e,n,{isDecimalSign:i,isMinusSign:r}),e.preventDefault())}}},{key:"onPaste",value:function(e){if(e.preventDefault(),!this.props.disabled&&!this.props.readOnly){var t=(e.clipboardData||window.clipboardData).getData("Text");if(t){var n=this.parseValue(t);null!=n&&this.insert(e,n.toString())}}}},{key:"allowMinusSign",value:function(){return null===this.props.min||this.props.min<0}},{key:"isMinusSign",value:function(e){return!(!this._minusSign.test(e)&&"-"!==e||(this._minusSign.lastIndex=0,0))}},{key:"isDecimalSign",value:function(e){return!!this._decimal.test(e)&&(this._decimal.lastIndex=0,!0)}},{key:"isDecimalMode",value:function(){return"decimal"===this.props.mode}},{key:"getDecimalCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:n}}},{key:"getCharIndexes",value:function(e){var t=e.search(this._decimal);this._decimal.lastIndex=0;var n=e.search(this._minusSign);this._minusSign.lastIndex=0;var i=e.search(this._suffix);this._suffix.lastIndex=0;var r=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:r}}},{key:"insert",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{isDecimalSign:!1,isMinusSign:!1},i=t.search(this._minusSign);if(this._minusSign.lastIndex=0,this.allowMinusSign()||-1===i){var r,s=this.inputRef.current.selectionStart,o=this.inputRef.current.selectionEnd,a=this.inputRef.current.value.trim(),u=this.getCharIndexes(a),l=u.decimalCharIndex,p=u.minusCharIndex,c=u.suffixCharIndex,h=u.currencyCharIndex;if(n.isMinusSign)0===s&&(r=a,-1!==p&&0===o||(r=this.insertText(a,t,0,o)),this.updateValue(e,r,t,"insert"));else if(n.isDecimalSign)l>0&&s===l?this.updateValue(e,a,t,"insert"):(l>s&&l<o||-1===l&&this.props.maxFractionDigits)&&(r=this.insertText(a,t,s,o),this.updateValue(e,r,t,"insert"));else{var f=this.numberFormat.resolvedOptions().maximumFractionDigits,d=s!==o?"range-insert":"insert";if(l>0&&s>l){if(s+t.length-(l+1)<=f){var m=h>=s?h-1:c>=s?c:a.length;r=a.slice(0,s)+t+a.slice(s+t.length,m)+a.slice(m),this.updateValue(e,r,t,d)}}else r=this.insertText(a,t,s,o),this.updateValue(e,r,t,d)}}}},{key:"insertText",value:function(e,t,n,i){if(2===("."===t?t:t.split(".")).length){var r=e.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,r>0?e.slice(0,n)+this.formatValue(t)+e.slice(i):e||this.formatValue(t)}return i-n===e.length?this.formatValue(t):0===n?t+e.slice(i):i===e.length?e.slice(0,n)+t:e.slice(0,n)+t+e.slice(i)}},{key:"deleteRange",value:function(e,t,n){return n-t===e.length?"":0===t?e.slice(n):n===e.length?e.slice(0,t):e.slice(0,t)+e.slice(n)}},{key:"initCursor",value:function(){var e=this.inputRef.current.selectionStart,t=this.inputRef.current.value,n=t.length,i=null,r=(this.prefixChar||"").length,s=(t=t.replace(this._prefix,"")).charAt(e-=r);if(this.isNumeralChar(s))return e+r;for(var o=e-1;o>=0;){if(s=t.charAt(o),this.isNumeralChar(s)){i=o+r;break}o--}if(null!==i)this.inputRef.current.setSelectionRange(i+1,i+1);else{for(o=e;o<n;){if(s=t.charAt(o),this.isNumeralChar(s)){i=o+r;break}o++}null!==i&&this.inputRef.current.setSelectionRange(i,i)}return i||0}},{key:"onInputClick",value:function(){this.initCursor()}},{key:"isNumeralChar",value:function(e){return!(1!==e.length||!(this._numeral.test(e)||this._decimal.test(e)||this._group.test(e)||this._minusSign.test(e))||(this.resetRegex(),0))}},{key:"resetRegex",value:function(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0}},{key:"updateValue",value:function(e,t,n,i){var r=this.inputRef.current.value,s=null;null!=t&&(s=this.parseValue(t),s=this.evaluateEmpty(s),this.updateInput(s,n,i,t),this.handleOnChange(e,r,s))}},{key:"evaluateEmpty",value:function(e){return e||this.props.allowEmpty?e:this.props.min||0}},{key:"handleOnChange",value:function(e,t,n){this.props.onChange&&this.isValueChanged(t,n)&&this.props.onChange({originalEvent:e,value:n})}},{key:"isValueChanged",value:function(e,t){return null===t&&null!==e||null!=t&&t!==("string"==typeof e?this.parseValue(e):e)}},{key:"validateValue",value:function(e){return"-"===e||null==e?null:null!==this.props.min&&e<this.props.min?this.props.min:null!==this.props.max&&e>this.props.max?this.props.max:e}},{key:"updateInput",value:function(e,t,n,i){t=t||"";var r=this.inputRef.current,s=r.value,o=this.formatValue(e),a=s.length;if(o!==i&&(o=this.concatValues(o,i)),0===a){r.value=o,r.setSelectionRange(0,0);var u=this.initCursor()+t.length;r.setSelectionRange(u,u)}else{var l=r.selectionStart,p=r.selectionEnd;r.value=o;var c=o.length;if("range-insert"===n){var h=this.parseValue((s||"").slice(0,l)),f=(null!==h?h.toString():"").split("").join("(".concat(this.groupChar,")?")),d=new RegExp(f,"g");d.test(o);var m=t.split("").join("(".concat(this.groupChar,")?")),y=new RegExp(m,"g");y.test(o.slice(d.lastIndex)),r.setSelectionRange(p=d.lastIndex+y.lastIndex,p)}else if(c===a)"insert"===n||"delete-back-single"===n?r.setSelectionRange(p+1,p+1):"delete-single"===n?r.setSelectionRange(p-1,p-1):"delete-range"!==n&&"spin"!==n||r.setSelectionRange(p,p);else if("delete-back-single"===n){var v=s.charAt(p-1),g=s.charAt(p),b=a-c,x=this._group.test(g);x&&1===b?p+=1:!x&&this.isNumeralChar(v)&&(p+=-1*b+1),this._group.lastIndex=0,r.setSelectionRange(p,p)}else if("-"===s&&"insert"===n){r.setSelectionRange(0,0);var w=this.initCursor()+t.length+1;r.setSelectionRange(w,w)}else r.setSelectionRange(p+=c-a,p)}r.setAttribute("aria-valuenow",e)}},{key:"updateInputValue",value:function(e){e=this.evaluateEmpty(e);var t=this.inputRef.current,n=t.value,i=this.formattedValue(e);n!==i&&(t.value=i,t.setAttribute("aria-valuenow",e))}},{key:"formattedValue",value:function(e){var t=this.evaluateEmpty(e);return this.formatValue(t)}},{key:"concatValues",value:function(e,t){if(e&&t){var n=t.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?e.split(this._decimal)[0]+t.slice(n):e}return e}},{key:"getDecimalLength",value:function(e){if(e){var t=e.split(this._decimal);if(2===t.length)return t[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0}},{key:"updateModel",value:function(e,t){this.props.onValueChange&&this.props.onValueChange({originalEvent:e,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:t}})}},{key:"onInputFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onInputBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){var n=t.inputRef.current.value;if(t.isValueChanged(n,t.props.value)){var i=t.validateValue(t.parseValue(n));t.updateInputValue(i),t.updateModel(e,i)}t.props.onBlur&&t.props.onBlur(e)}))}},{key:"clearTimer",value:function(){this.timer&&clearInterval(this.timer)}},{key:"isStacked",value:function(){return this.props.showButtons&&"stacked"===this.props.buttonLayout}},{key:"isHorizontal",value:function(){return this.props.showButtons&&"horizontal"===this.props.buttonLayout}},{key:"isVertical",value:function(){return this.props.showButtons&&"vertical"===this.props.buttonLayout}},{key:"getInputMode",value:function(){return this.props.inputMode||("decimal"!==this.props.mode||this.props.minFractionDigits?"decimal":"numeric")}},{key:"getFormatter",value:function(){return this.numberFormat}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip();var e=this.validateValue(this.props.value);null!==this.props.value&&this.props.value!==e&&this.updateModel(null,e)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(D({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip());var t=this.isOptionChanged(e);if(t&&this.constructParser(),e.value!==this.props.value||t){var n=this.validateValue(this.props.value);this.updateInputValue(n),null!==this.props.value&&this.props.value!==n&&this.updateModel(null,n)}}},{key:"isOptionChanged",value:function(e){var t=this;return["locale","localeMatcher","mode","currency","currencyDisplay","useGrouping","minFractionDigits","maxFractionDigits","suffix","prefix"].some((function(n){return e[n]!==t.props[n]}))}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=i.tip({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderInputElement",value:function(){var e=n.classNames("p-inputnumber-input",this.props.inputClassName),i=this.formattedValue(this.props.value);return o.default.createElement(t.InputText,{ref:this.inputRef,id:this.props.inputId,style:this.props.inputStyle,role:"spinbutton",className:e,defaultValue:i,type:this.props.type,size:this.props.size,tabIndex:this.props.tabIndex,inputMode:this.getInputMode(),maxLength:this.props.maxLength,disabled:this.props.disabled,required:this.props.required,pattern:this.props.pattern,placeholder:this.props.placeholder,readOnly:this.props.readOnly,name:this.props.name,autoFocus:this.props.autoFocus,onKeyDown:this.onInputKeyDown,onKeyPress:this.onInputKeyPress,onInput:this.onInput,onClick:this.onInputClick,onBlur:this.onInputBlur,onFocus:this.onInputFocus,onPaste:this.onPaste,min:this.props.min,max:this.props.max,"aria-valuemin":this.props.min,"aria-valuemax":this.props.max,"aria-valuenow":this.props.value,"aria-labelledby":this.props.ariaLabelledBy})}},{key:"renderUpButton",value:function(){var e=n.classNames("p-inputnumber-button p-inputnumber-button-up p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.incrementButtonClassName),t=n.classNames("p-button-icon",this.props.incrementButtonIcon);return o.default.createElement("button",{type:"button",className:e,onMouseLeave:this.onUpButtonMouseLeave,onMouseDown:this.onUpButtonMouseDown,onMouseUp:this.onUpButtonMouseUp,onKeyDown:this.onUpButtonKeyDown,onKeyUp:this.onUpButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},o.default.createElement("span",{className:t}),o.default.createElement(r.Ripple,null))}},{key:"renderDownButton",value:function(){var e=n.classNames("p-inputnumber-button p-inputnumber-button-down p-button p-button-icon-only p-component",{"p-disabled":this.props.disabled},this.props.decrementButtonClassName),t=n.classNames("p-button-icon",this.props.decrementButtonIcon);return o.default.createElement("button",{type:"button",className:e,onMouseLeave:this.onDownButtonMouseLeave,onMouseDown:this.onDownButtonMouseDown,onMouseUp:this.onDownButtonMouseUp,onKeyDown:this.onDownButtonKeyDown,onKeyUp:this.onDownButtonKeyUp,disabled:this.props.disabled,tabIndex:-1},o.default.createElement("span",{className:t}),o.default.createElement(r.Ripple,null))}},{key:"renderButtonGroup",value:function(){var e=this.props.showButtons&&this.renderUpButton(),t=this.props.showButtons&&this.renderDownButton();return this.isStacked()?o.default.createElement("span",{className:"p-inputnumber-button-group"},e,t):o.default.createElement(o.default.Fragment,null,e,t)}},{key:"render",value:function(){var e=this,t=n.classNames("p-inputnumber p-component p-inputwrapper",this.props.className,{"p-inputwrapper-filled":null!=this.props.value&&this.props.value.toString().length>0,"p-inputwrapper-focus":this.state.focused,"p-inputnumber-buttons-stacked":this.isStacked(),"p-inputnumber-buttons-horizontal":this.isHorizontal(),"p-inputnumber-buttons-vertical":this.isVertical()}),i=this.renderInputElement(),r=this.renderButtonGroup();return o.default.createElement("span",{ref:function(t){return e.element=t},id:this.props.id,className:t,style:this.props.style},i,r)}}],x&&f(v.prototype,x),w&&f(v,w),Object.defineProperty(v,"prototype",{writable:!1}),C}();x(k,"defaultProps",{value:null,inputRef:null,format:!0,showButtons:!1,buttonLayout:"stacked",incrementButtonClassName:null,decrementButtonClassName:null,incrementButtonIcon:"pi pi-angle-up",decrementButtonIcon:"pi pi-angle-down",locale:void 0,localeMatcher:void 0,mode:"decimal",suffix:null,prefix:null,currency:void 0,currencyDisplay:void 0,useGrouping:!0,minFractionDigits:void 0,maxFractionDigits:void 0,id:null,name:null,type:"text",allowEmpty:!0,step:1,min:null,max:null,disabled:!1,required:!1,tabIndex:null,pattern:null,inputMode:null,placeholder:null,readOnly:!1,size:null,style:null,className:null,inputId:null,autoFocus:!1,inputStyle:null,inputClassName:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onValueChange:null,onChange:null,onBlur:null,onFocus:null,onKeyDown:null}),exports.InputNumber=k;