????
Current Path : C:/inetpub/vhost/qlk.nextform.vn/www/wwwroot/static/js/ |
Current File : C:/inetpub/vhost/qlk.nextform.vn/www/wwwroot/static/js/6803.9db41be5.chunk.js |
"use strict";(self.webpackChunkgdt=self.webpackChunkgdt||[]).push([[6803],{86803:(e,t,r)=>{var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=s(r(11942)),i=s(r(9950)),u=r(87527);function s(e){return e&&e.__esModule?e:{default:e}}var l={thousandSeparator:o.default.oneOfType([o.default.string,o.default.oneOf([!0])]),thousandSpacing:o.default.oneOf(["2","2s","3","4"]),decimalSeparator:o.default.string,decimalScale:o.default.number,fixedDecimalScale:o.default.bool,displayType:o.default.oneOf(["input","text"]),prefix:o.default.string,suffix:o.default.string,format:o.default.oneOfType([o.default.string,o.default.func]),removeFormatting:o.default.func,mask:o.default.oneOfType([o.default.string,o.default.arrayOf(o.default.string)]),value:o.default.oneOfType([o.default.number,o.default.string]),isNumericString:o.default.bool,customInput:o.default.func,allowNegative:o.default.bool,onValueChange:o.default.func,onKeyDown:o.default.func,onMouseUp:o.default.func,onChange:o.default.func,onFocus:o.default.func,onBlur:o.default.func,type:o.default.oneOf(["text","tel"]),isAllowed:o.default.func,renderText:o.default.func},f={displayType:"input",decimalSeparator:".",thousandSpacing:"3",fixedDecimalScale:!1,prefix:"",suffix:"",allowNegative:!0,isNumericString:!1,type:"text",onValueChange:u.noop,onChange:u.noop,onKeyDown:u.noop,onMouseUp:u.noop,onFocus:u.noop,onBlur:u.noop,isAllowed:u.returnTrue},c=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));r.validateProps();var a=r.formatValueProp();return r.state={value:a,numAsString:r.removeFormatting(a)},r.onChange=r.onChange.bind(r),r.onKeyDown=r.onKeyDown.bind(r),r.onMouseUp=r.onMouseUp.bind(r),r.onFocus=r.onFocus.bind(r),r.onBlur=r.onBlur.bind(r),r}return function(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)}(t,e),n(t,[{key:"componentDidUpdate",value:function(e){this.updateValueIfRequired(e)}},{key:"updateValueIfRequired",value:function(e){var t=this.props,r=this.state;if(e!==t){this.validateProps();var a=r.value,n=r.numAsString||"",o=void 0===t.value?this.formatNumString(n):this.formatValueProp();o!==a&&this.setState({value:o,numAsString:this.removeFormatting(o)})}}},{key:"getFloatString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.getSeparators().decimalSeparator,r=this.getNumberRegex(!0),a="-"===e[0];a&&(e=e.replace("-",""));var n=(e=(e.match(r)||[]).join("").replace(t,".")).indexOf(".");return-1!==n&&(e=e.substring(0,n)+"."+e.substring(n+1,e.length).replace(new RegExp((0,u.escapeRegExp)(t),"g"),"")),a&&(e="-"+e),e}},{key:"getNumberRegex",value:function(e,t){var r=this.props,a=r.format,n=r.decimalScale,o=this.getSeparators().decimalSeparator;return new RegExp("\\d"+(!o||0===n||t||a?"":"|"+(0,u.escapeRegExp)(o)),e?"g":void 0)}},{key:"getSeparators",value:function(){var e=this.props,t=e.decimalSeparator,r=e.thousandSpacing,a=this.props.thousandSeparator;return!0===a&&(a=","),{decimalSeparator:t,thousandSeparator:a,thousandSpacing:r}}},{key:"getMaskAtIndex",value:function(e){var t=this.props.mask,r=void 0===t?" ":t;return"string"===typeof r?r:r[e]||" "}},{key:"validateProps",value:function(){var e=this.props.mask,t=this.getSeparators(),r=t.decimalSeparator,a=t.thousandSeparator;if(r===a)throw new Error("\n Decimal separator can't be same as thousand separator.\n\n thousandSeparator: "+a+' (thousandSeparator = {true} is same as thousandSeparator = ",")\n decimalSeparator: '+r+" (default value for decimalSeparator is .)\n ");if(e&&("string"===e?e:e.toString()).match(/\d/g))throw new Error("\n Mask "+e+" should not contain numeric character;\n ")}},{key:"splitDecimal",value:function(e){var t=this.props.allowNegative,r="-"===e[0],a=r&&t,n=(e=e.replace("-","")).split(".");return{beforeDecimal:n[0],afterDecimal:n[1]||"",hasNagation:r,addNegation:a}}},{key:"setPatchedCaretPosition",value:function(e,t,r){(0,u.setCaretPosition)(e,t),setTimeout((function(){e.value===r&&(0,u.setCaretPosition)(e,t)}),0)}},{key:"correctCaretPosition",value:function(e,t,r){var a=this.props,n=a.prefix,o=a.suffix,i=a.format;if(!i){var s="-"===e[0];return Math.min(Math.max(t,n.length+(s?1:0)),e.length-o.length)}if("function"===typeof i)return t;if("#"===i[t]&&(0,u.charIsNumber)(e[t]))return t;if("#"===i[t-1]&&(0,u.charIsNumber)(e[t-1]))return t;var l=i.indexOf("#"),f=i.lastIndexOf("#");t=Math.min(Math.max(t,l),f+1);for(var c=i.substring(t,i.length).indexOf("#"),p=t,h=t+(-1===c?0:c);p>l&&("#"!==i[p]||!(0,u.charIsNumber)(e[p]));)p-=1;return!(0,u.charIsNumber)(e[h])||"left"===r&&t!==l||t-p<h-t?p+1:h}},{key:"getCaretPosition",value:function(e,t,r){var a=this.props.format,n=this.state.value,o=this.getNumberRegex(!0),i=(e.match(o)||[]).join(""),u=(t.match(o)||[]).join(""),s=void 0,l=void 0;for(s=0,l=0;l<r;l++){var f=e[l]||"",c=t[s]||"";if((f.match(o)||f===c)&&("0"!==f||!c.match(o)||"0"===c||i.length===u.length)){for(;f!==t[s]&&s<t.length;)s++;s++}}return"string"!==typeof a||n||(s=t.length),s=this.correctCaretPosition(t,s)}},{key:"removePrefixAndSuffix",value:function(e){var t=this.props,r=t.format,a=t.prefix,n=t.suffix;if(!r&&e){var o="-"===e[0];o&&(e=e.substring(1,e.length));var i=(e=a&&0===e.indexOf(a)?e.substring(a.length,e.length):e).lastIndexOf(n);e=n&&-1!==i&&i===e.length-n.length?e.substring(0,i):e,o&&(e="-"+e)}return e}},{key:"removePatternFormatting",value:function(e){for(var t=this.props.format.split("#").filter((function(e){return""!==e})),r=0,a="",n=0,o=t.length;n<=o;n++){var i=t[n]||"",u=n===o?e.length:e.indexOf(i,r);if(-1===u){a=e;break}a+=e.substring(r,u),r=u+i.length}return(a.match(/\d/g)||[]).join("")}},{key:"removeFormatting",value:function(e){var t=this.props,r=t.format,a=t.removeFormatting;return e?(r?e="string"===typeof r?this.removePatternFormatting(e):"function"===typeof a?a(e):(e.match(/\d/g)||[]).join(""):(e=this.removePrefixAndSuffix(e),e=this.getFloatString(e)),e):e}},{key:"formatWithPattern",value:function(e){for(var t=this.props.format,r=0,a=t.split(""),n=0,o=t.length;n<o;n++)"#"===t[n]&&(a[n]=e[r]||this.getMaskAtIndex(r),r+=1);return a.join("")}},{key:"formatThousand",value:function(e,t,r){var a=void 0;switch(r){case u.thousandGroupSpacing.two:a=/(\d)(?=(\d{2})+(?!\d))/g;break;case u.thousandGroupSpacing.twoScaled:a=/(\d)(?=(((\d{2})+)(\d{1})(?!\d)))/g;break;case u.thousandGroupSpacing.four:a=/(\d)(?=(\d{4})+(?!\d))/g;break;default:a=/(\d)(?=(\d{3})+(?!\d))/g}return e.replace(a,"$1"+t)}},{key:"formatAsNumber",value:function(e){var t=this.props,r=t.decimalScale,a=t.fixedDecimalScale,n=t.prefix,o=t.suffix,i=this.getSeparators(),s=i.thousandSeparator,l=i.decimalSeparator,f=i.thousandSpacing,c=-1!==e.indexOf(".")||r&&a,p=this.splitDecimal(e),h=p.beforeDecimal,d=p.afterDecimal,g=p.addNegation;return void 0!==r&&(d=(0,u.limitToScale)(d,r,a)),s&&(h=this.formatThousand(h,s,f)),n&&(h=n+h),o&&(d+=o),g&&(h="-"+h),e=h+(c&&l||"")+d}},{key:"formatNumString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.props.format,r=e;return""===e?r="":"-"!==e||t?r="string"===typeof t?this.formatWithPattern(r):"function"===typeof t?t(r):this.formatAsNumber(r):(r="-",e=""),r}},{key:"formatValueProp",value:function(){var e=this.props,t=e.format,r=e.decimalScale,a=e.fixedDecimalScale,n=this.props,o=n.value,i=n.isNumericString;return void 0===o?"":("number"===typeof o&&(o=o.toString(),i=!0),i&&!t&&"number"===typeof r&&(o=(0,u.roundToPrecision)(o,r,a)),i?this.formatNumString(o):this.formatInput(o))}},{key:"formatNegation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.props.allowNegative,r=new RegExp("(-)"),a=new RegExp("(-)(.)*(-)"),n=r.test(e),o=a.test(e);return e=e.replace(/-/g,""),n&&!o&&t&&(e="-"+e),e}},{key:"formatInput",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.props.format||(e=this.formatNegation(e)),e=this.removeFormatting(e),this.formatNumString(e)}},{key:"isCharacterAFormat",value:function(e,t){var r=this.props,a=r.format,n=r.prefix,o=r.suffix,i=r.decimalScale,u=r.fixedDecimalScale,s=this.getSeparators().decimalSeparator;return"string"===typeof a&&"#"!==a[e]||!(a||!(e<n.length||e>=t.length-o.length||i&&u&&t[e]===s))}},{key:"checkIfFormatGotDeleted",value:function(e,t,r){for(var a=e;a<t;a++)if(this.isCharacterAFormat(a,r))return!0;return!1}},{key:"correctInputValue",value:function(e,t,r){var a=this.props.format,n=this.state.numAsString||"";if(r.length>=t.length||!r.length)return r;var o=e,i=(0,u.splitString)(t,e),s=(0,u.splitString)(r,e),l=i[1].lastIndexOf(s[1]),f=o+(-1!==l?i[1].substring(0,l):"").length;if(this.checkIfFormatGotDeleted(o,f,t)&&(r=t),!a){var c=this.removeFormatting(r),p=this.splitDecimal(c),h=p.beforeDecimal,d=p.afterDecimal,g=p.addNegation;if(c.length<n.length&&""===h&&!parseFloat(d))return g?"-":""}return r}},{key:"onChange",value:function(e){e.persist();var t=e.target,r=t.value,a=this.state,n=this.props,o=n.isAllowed,i=a.value||"",u=Math.max(t.selectionStart,t.selectionEnd);r=this.correctInputValue(u,i,r);var s=this.formatInput(r)||"",l=this.removeFormatting(s),f={formattedValue:s,value:l,floatValue:parseFloat(l)};o(f)||(s=i),t.value=s;var c=this.getCaretPosition(r,s,u);this.setPatchedCaretPosition(t,c,s),s!==i?this.setState({value:s,numAsString:l},(function(){n.onValueChange(f),n.onChange(e)})):n.onChange(e)}},{key:"onBlur",value:function(e){var t=this.props,r=this.state,a=t.format,n=t.onBlur,o=r.numAsString,i=r.value;if(!a){o=(0,u.fixLeadingZero)(o);var s=this.formatNumString(o),l={formattedValue:s,value:o,floatValue:parseFloat(o)};if(s!==i)return e.persist(),void this.setState({value:s,numAsString:o},(function(){t.onValueChange(l),n(e)}))}n(e)}},{key:"onKeyDown",value:function(e){var t=e.target,r=e.key,a=t.selectionEnd,n=t.value,o=t.selectionStart,i=void 0,u=this.props,s=u.decimalScale,l=u.fixedDecimalScale,f=u.prefix,c=u.suffix,p=u.format,h=u.onKeyDown,d=void 0!==s&&l,g=this.getNumberRegex(!1,d),m=new RegExp("-"),v="string"===typeof p;if("ArrowLeft"===r||"Backspace"===r?i=o-1:"ArrowRight"===r?i=o+1:"Delete"===r&&(i=o),void 0!==i&&o===a){var S=i,y=v?p.indexOf("#"):f.length,b=v?p.lastIndexOf("#")+1:n.length-c.length;if("ArrowLeft"===r||"ArrowRight"===r){var x="ArrowLeft"===r?"left":"right";S=this.correctCaretPosition(n,i,x)}else if("Delete"!==r||g.test(n[i])||m.test(n[i])){if("Backspace"===r&&!g.test(n[i])&&!m.test(n[i])){for(;!g.test(n[S-1])&&S>y;)S--;S=this.correctCaretPosition(n,S,"left")}}else for(;!g.test(n[S])&&S<b;)S++;(S!==i||i<y||i>b)&&(e.preventDefault(),this.setPatchedCaretPosition(t,S,n)),e.isUnitTestRun&&this.setPatchedCaretPosition(t,S,n),this.props.onKeyDown(e)}else h(e)}},{key:"onMouseUp",value:function(e){var t=e.target,r=t.selectionStart,a=t.selectionEnd,n=t.value;if(r===a){var o=this.correctCaretPosition(n,r);o!==r&&this.setPatchedCaretPosition(t,o,n)}this.props.onMouseUp(e)}},{key:"onFocus",value:function(e){var t=this;e.persist(),setTimeout((function(){var r=e.target,a=r.selectionStart,n=r.value,o=t.correctCaretPosition(n,a);o!==a&&t.setPatchedCaretPosition(r,o,n),t.props.onFocus(e)}))}},{key:"render",value:function(){var e=this.props,t=e.type,r=e.displayType,n=e.customInput,o=e.renderText,s=this.state.value,f=(0,u.omit)(this.props,l),c=a({},f,{type:t,value:s,onChange:this.onChange,onKeyDown:this.onKeyDown,onMouseUp:this.onMouseUp,onFocus:this.onFocus,onBlur:this.onBlur});if("text"===r)return o?o(s)||null:i.default.createElement("span",f,s);if(n){var p=n;return i.default.createElement(p,c)}return i.default.createElement("input",c)}}]),t}(i.default.Component);c.propTypes=l,c.defaultProps=f,e.exports=c},87527:(e,t)=>{function r(e,t,r){for(var a="",n=r?"0":"",o=0;o<=t-1;o++)a+=e[o]||n;return a}Object.defineProperty(t,"__esModule",{value:!0}),t.noop=function(){},t.returnTrue=function(){return!0},t.charIsNumber=function(e){return!!(e||"").match(/\d/)},t.escapeRegExp=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},t.fixLeadingZero=function(e){if(!e)return e;var t="-"===e[0];t&&(e=e.substring(1,e.length));var r=e.split("."),a=r[0].replace(/^0+/,"")||"0",n=r[1]||"";return(t?"-":"")+a+(n?"."+n:"")},t.splitString=function(e,t){return[e.substring(0,t),e.substring(t)]},t.limitToScale=r,t.roundToPrecision=function(e,t,a){var n=e.split("."),o=parseFloat("0."+(n[1]||"0")).toFixed(t).split("."),i=n[0].split("").reverse().reduce((function(e,t,r){return e.length>r?(Number(e[0])+Number(t)).toString()+e.substring(1,e.length):t+e}),o[0]),u=r(o[1]||"",(n[1]||"").length,a);return i+(u?"."+u:"")},t.omit=function(e,t){var r={};return Object.keys(e).forEach((function(a){t[a]||(r[a]=e[a])})),r},t.setCaretPosition=function(e,t){if(e.value=e.value,null!==e){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||0===e.selectionStart?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}};t.thousandGroupSpacing={two:"2",twoScaled:"2s",three:"3",four:"4"}}}]);