????
Current Path : C:/inetpub/vhost/xaydung.gdtsolutions.vn/build/static/js/ |
Current File : C:/inetpub/vhost/xaydung.gdtsolutions.vn/build/static/js/639.35165e56.chunk.js |
"use strict";(self.webpackChunk_qlxd_frontend=self.webpackChunk_qlxd_frontend||[]).push([[639],{639:(t,e,n)=>{n.d(e,{A:()=>y});var r=n(82210),o=n(24021),s=n(71723),i=n.n(s);function a(){}function l(t){return!!(t||"").match(/\d/)}function u(t){return t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}function c(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n="-"===t[0],r=n&&e,o=(t=t.replace("-","")).split(".");return{beforeDecimal:o[0],afterDecimal:o[1]||"",hasNagation:n,addNegation:r}}function h(t,e,n){let r="";const o=n?"0":"";for(let s=0;s<=e-1;s++)r+=t[s]||o;return r}function f(t,e){if(null!==t){if(t.createTextRange){const n=t.createTextRange();return n.move("character",e),n.select(),!0}return t.selectionStart||0===t.selectionStart?(t.focus(),t.setSelectionRange(e,e),!0):(t.focus(),!1)}}function p(t,e,n){return Math.min(Math.max(t,e),n)}function g(t){return Math.max(t.selectionStart,t.selectionEnd)}var d=n(6058);const m={thousandSeparator:i().oneOfType([i().string,i().oneOf([!0])]),decimalSeparator:i().string,thousandsGroupStyle:i().oneOf(["thousand","lakh","wan"]),decimalScale:i().number,fixedDecimalScale:i().bool,displayType:i().oneOf(["input","text"]),prefix:i().string,suffix:i().string,format:i().oneOfType([i().string,i().func]),removeFormatting:i().func,mask:i().oneOfType([i().string,i().arrayOf(i().string)]),value:i().oneOfType([i().number,i().string]),defaultValue:i().oneOfType([i().number,i().string]),isNumericString:i().bool,customInput:i().elementType,allowNegative:i().bool,allowEmptyFormatting:i().bool,allowLeadingZeros:i().bool,onValueChange:i().func,onKeyDown:i().func,onMouseUp:i().func,onChange:i().func,onFocus:i().func,onBlur:i().func,type:i().oneOf(["text","tel","password"]),isAllowed:i().func,renderText:i().func,getInputRef:i().func},S={displayType:"input",decimalSeparator:".",thousandsGroupStyle:"thousand",fixedDecimalScale:!1,prefix:"",suffix:"",allowNegative:!0,allowEmptyFormatting:!1,allowLeadingZeros:!1,isNumericString:!1,type:"text",onValueChange:a,onChange:a,onKeyDown:a,onMouseUp:a,onFocus:a,onBlur:a,isAllowed:function(){return!0},getInputRef:a};class x extends r.Component{constructor(t){super(t);const{defaultValue:e}=t;this.validateProps();const n=this.formatValueProp(e);this.state={value:n,numAsString:this.removeFormatting(n)},this.selectionBeforeInput={selectionStart:0,selectionEnd:0},this.onChange=this.onChange.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this)}componentDidUpdate(t){this.updateValueIfRequired(t)}updateValueIfRequired(t){const{props:e,state:n,focusedElm:r}=this,{value:o,numAsString:s=""}=n;if(t!==e){this.validateProps();const t=this.formatNumString(s),n=void 0===e.value?t:this.formatValueProp(),i=this.removeFormatting(n),a=parseFloat(i),l=parseFloat(s);(isNaN(a)&&isNaN(l)||a===l)&&t===o&&(null!==r||n===o)||this.updateValue({formattedValue:n,numAsString:i,input:r})}}getFloatString(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{decimalScale:e}=this.props,{decimalSeparator:n}=this.getSeparators(),r=this.getNumberRegex(!0),o="-"===t[0];o&&(t=t.replace("-","")),n&&0===e&&(t=t.split(n)[0]),t=(t.match(r)||[]).join("").replace(n,".");const s=t.indexOf(".");return-1!==s&&(t=`${t.substring(0,s)}.${t.substring(s+1,t.length).replace(new RegExp(u(n),"g"),"")}`),o&&(t="-"+t),t}getNumberRegex(t,e){const{format:n,decimalScale:r}=this.props,{decimalSeparator:o}=this.getSeparators();return new RegExp("\\d"+(!o||0===r||e||n?"":"|"+u(o)),t?"g":void 0)}getSeparators(){const{decimalSeparator:t}=this.props;let{thousandSeparator:e}=this.props;return!0===e&&(e=","),{decimalSeparator:t,thousandSeparator:e}}getMaskAtIndex(t){const{mask:e=" "}=this.props;return"string"===typeof e?e:e[t]||" "}getValueObject(t,e){const n=parseFloat(e);return{formattedValue:t,value:e,floatValue:isNaN(n)?void 0:n}}validateProps(){const{mask:t}=this.props,{decimalSeparator:e,thousandSeparator:n}=this.getSeparators();if(e===n)throw new Error(`\n Decimal separator can't be same as thousand separator.\n thousandSeparator: ${n} (thousandSeparator = {true} is same as thousandSeparator = ",")\n decimalSeparator: ${e} (default value for decimalSeparator is .)\n `);if(t){if(("string"===t?t:t.toString()).match(/\d/g))throw new Error(`\n Mask ${t} should not contain numeric character;\n `)}}setPatchedCaretPosition(t,e,n){f(t,e),setTimeout((()=>{t.value===n&&f(t,e)}),0)}correctCaretPosition(t,e,n){const{prefix:r,suffix:o,format:s}=this.props;if(""===t)return 0;if(e=p(e,0,t.length),!s){const n="-"===t[0];return p(e,r.length+(n?1:0),t.length-o.length)}if("function"===typeof s)return e;if("#"===s[e]&&l(t[e]))return e;if("#"===s[e-1]&&l(t[e-1]))return e;const i=s.indexOf("#");e=p(e,i,s.lastIndexOf("#")+1);const a=s.substring(e,s.length).indexOf("#");let u=e;const c=e+(-1===a?0:a);for(;u>i&&("#"!==s[u]||!l(t[u]));)u-=1;return!l(t[c])||"left"===n&&e!==i||e-u<c-e?l(t[u])?u+1:u:c}getCaretPosition(t,e,n){const{format:r}=this.props,o=this.state.value,s=this.getNumberRegex(!0),i=(t.match(s)||[]).join(""),a=(e.match(s)||[]).join("");let l,u;for(l=0,u=0;u<n;u++){const n=t[u]||"",r=e[l]||"";if((n.match(s)||n===r)&&("0"!==n||!r.match(s)||"0"===r||i.length===a.length)){for(;n!==e[l]&&l<e.length;)l++;l++}}return"string"!==typeof r||o||(l=e.length),l=this.correctCaretPosition(e,l),l}removePrefixAndSuffix(t){const{format:e,prefix:n,suffix:r}=this.props;if(!e&&t){const e="-"===t[0];e&&(t=t.substring(1,t.length));const o=(t=n&&0===t.indexOf(n)?t.substring(n.length,t.length):t).lastIndexOf(r);t=r&&-1!==o&&o===t.length-r.length?t.substring(0,o):t,e&&(t="-"+t)}return t}removePatternFormatting(t){const{format:e}=this.props,n=e.split("#").filter((t=>""!==t));let r=0,o="";for(let s=0,i=n.length;s<=i;s++){const e=n[s]||"",a=s===i?t.length:t.indexOf(e,r);if(-1===a){o=t;break}o+=t.substring(r,a),r=a+e.length}return(o.match(/\d/g)||[]).join("")}removeFormatting(t){const{format:e,removeFormatting:n}=this.props;return t?(e?t="string"===typeof e?this.removePatternFormatting(t):"function"===typeof n?n(t):(t.match(/\d/g)||[]).join(""):(t=this.removePrefixAndSuffix(t),t=this.getFloatString(t)),t):t}formatWithPattern(t){const{format:e}=this.props;let n=0;const r=e.split("");for(let o=0,s=e.length;o<s;o++)"#"===e[o]&&(r[o]=t[n]||this.getMaskAtIndex(n),n+=1);return r.join("")}formatAsNumber(t){const{decimalScale:e,fixedDecimalScale:n,prefix:r,suffix:o,allowNegative:s,thousandsGroupStyle:i}=this.props,{thousandSeparator:a,decimalSeparator:l}=this.getSeparators(),u=-1!==t.indexOf(".")||e&&n;let{beforeDecimal:f,afterDecimal:p,addNegation:g}=c(t,s);return void 0!==e&&(p=h(p,e,n)),a&&(f=function(t,e,n){const r=function(t){switch(t){case"lakh":return/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;case"wan":return/(\d)(?=(\d{4})+(?!\d))/g;default:return/(\d)(?=(\d{3})+(?!\d))/g}}(n);let o=t.search(/[1-9]/);return o=-1===o?t.length:o,t.substring(0,o)+t.substring(o,t.length).replace(r,"$1"+e)}(f,a,i)),r&&(f=r+f),o&&(p+=o),g&&(f="-"+f),t=f+(u&&l||"")+p}formatNumString(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{format:e,allowEmptyFormatting:n}=this.props;let r=t;return r=""!==t||n?"-"!==t||e?"string"===typeof e?this.formatWithPattern(r):"function"===typeof e?e(r):this.formatAsNumber(r):"-":"",r}formatValueProp(t){const{format:e,decimalScale:n,fixedDecimalScale:r,allowEmptyFormatting:o}=this.props;let{value:s=t,isNumericString:i}=this.props;const a=!s&&0!==s;if(a&&o&&(s=""),a&&!o)return"";"number"===typeof s&&(s=s.toString(),i=!0),"Infinity"===s&&i&&(s=""),i&&!e&&"number"===typeof n&&(s=function(t,e,n){if(-1!==["","-"].indexOf(t))return t;const r=-1!==t.indexOf(".")&&e,{beforeDecimal:o,afterDecimal:s,hasNagation:i}=c(t),a=parseFloat(`0.${s||"0"}`).toFixed(e).split(".");return`${i?"-":""}${o.split("").reverse().reduce(((t,e,n)=>t.length>n?(Number(t[0])+Number(e)).toString()+t.substring(1,t.length):e+t),a[0])}${r?".":""}${h(a[1]||"",Math.min(e,s.length),n)}`}(s,n,r));return i?this.formatNumString(s):this.formatInput(s)}formatNegation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{allowNegative:e}=this.props,n=new RegExp("(-)"),r=new RegExp("(-)(.)*(-)"),o=n.test(t),s=r.test(t);return t=t.replace(/-/g,""),o&&!s&&e&&(t="-"+t),t}formatInput(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{format:e}=this.props;return e||(t=this.removePrefixAndSuffix(t),t=this.formatNegation(t)),t=this.removeFormatting(t),this.formatNumString(t)}isCharacterAFormat(t,e){const{format:n,prefix:r,suffix:o,decimalScale:s,fixedDecimalScale:i}=this.props,{decimalSeparator:a}=this.getSeparators();return"string"===typeof n&&"#"!==n[t]||!(n||!(t<r.length||t>=e.length-o.length||s&&i&&e[t]===a))}checkIfFormatGotDeleted(t,e,n){for(let r=t;r<e;r++)if(this.isCharacterAFormat(r,n))return!0;return!1}correctInputValue(t,e,n){const{format:r,allowNegative:o,prefix:s,suffix:i}=this.props,{decimalSeparator:a}=this.getSeparators(),l=this.state.numAsString||"",{selectionStart:u,selectionEnd:h}=this.selectionBeforeInput,{start:f,end:p}=function(t,e){let n=0,r=0;const o=t.length,s=e.length;for(;t[n]===e[n]&&n<o;)n++;for(;t[o-1-r]===e[s-1-r]&&s-r>n&&o-r>n;)r++;return{start:n,end:o-r}}(e,n);if(!r&&"."!==a&&f===p&&"."===n[u])return n.substr(0,u)+a+n.substr(u+1,n.length);const g=r?0:s.length,d=e.length-(r?0:i.length);if(n.length>e.length||!n.length||f===p||0===u&&h===e.length||u===g&&h===d)return n;if(this.checkIfFormatGotDeleted(f,p,e)&&(n=e),!r){const e=this.removeFormatting(n);let{beforeDecimal:r,afterDecimal:s,addNegation:i}=c(e,o);const u=t<n.indexOf(a)+1;if(e.length<l.length&&u&&""===r&&!parseFloat(s))return i?"-":""}return n}updateValue(t,e){const{formattedValue:n,input:r}=t;let{numAsString:o,caretPos:s}=t;const{onValueChange:i}=this.props,{value:a}=this.state;if(r){if(!s){const e=t.inputValue||r.value,o=g(r);s=this.getCaretPosition(e,n,o)}r.value=n,this.setPatchedCaretPosition(r,s,n)}void 0===o&&(o=this.removeFormatting(n)),n!==a&&this.setState({value:n,numAsString:o},(()=>{i(this.getValueObject(n,o))}))}onChange(t){t.persist();const e=t.target;let n=e.value;const{state:r,props:o}=this,{isAllowed:s}=o,i=r.value||"",a=g(e);n=this.correctInputValue(a,i,n);let l=this.formatInput(n)||"";const u=this.removeFormatting(l);s(this.getValueObject(l,u))||(l=i),this.updateValue({formattedValue:l,numAsString:u,inputValue:n,input:e},(()=>{o.onChange(t)}))}onBlur(t){const{props:e,state:n}=this,{format:r,onBlur:o,allowLeadingZeros:s}=e;let{numAsString:i}=n;const a=n.value;if(this.focusedElm=null,!r){s||(i=function(t){if(!t)return t;const e="-"===t[0];e&&(t=t.substring(1,t.length));const n=t.split("."),r=n[0].replace(/^0+/,"")||"0",o=n[1]||"";return`${e?"-":""}${r}${o?`.${o}`:""}`}(i));const e=this.formatNumString(i);if(e!==a)return t.persist(),void this.updateValue({formattedValue:e,numAsString:i},(()=>{o(t)}))}o(t)}onKeyDown(t){const e=t.target,{key:n}=t,{selectionStart:r,selectionEnd:o,value:s=""}=e;let i;const{decimalScale:a,fixedDecimalScale:l,prefix:u,suffix:c,format:h,onKeyDown:f}=this.props,p=void 0!==a&&l,g=this.getNumberRegex(!1,p),d=new RegExp("-"),m="string"===typeof h;if(this.selectionBeforeInput={selectionStart:r,selectionEnd:o},"ArrowLeft"===n||"Backspace"===n?i=r-1:"ArrowRight"===n?i=r+1:"Delete"===n&&(i=r),void 0===i||r!==o)return void f(t);let S=i;const x=m?h.indexOf("#"):u.length,v=m?h.lastIndexOf("#")+1:s.length-c.length;if("ArrowLeft"===n||"ArrowRight"===n){const t="ArrowLeft"===n?"left":"right";S=this.correctCaretPosition(s,i,t)}else if("Delete"!==n||g.test(s[i])||d.test(s[i])){if("Backspace"===n&&!g.test(s[i]))if(r<=x+1&&"-"===s[0]&&"undefined"===typeof h){const n=s.substring(1);t.persist(),this.updateValue({formattedValue:n,caretPos:S,input:e})}else if(!d.test(s[i])){for(;!g.test(s[S-1])&&S>x;)S--;S=this.correctCaretPosition(s,S,"left")}}else for(;!g.test(s[S])&&S<v;)S++;(S!==i||i<x||i>v)&&(t.preventDefault(),this.setPatchedCaretPosition(e,S,s)),t.isUnitTestRun&&this.setPatchedCaretPosition(e,S,s),this.props.onKeyDown(t)}onMouseUp(t){const e=t.target,{selectionStart:n,selectionEnd:r,value:o=""}=e;if(n===r){const t=this.correctCaretPosition(o,n);t!==n&&this.setPatchedCaretPosition(e,t,o)}this.props.onMouseUp(t)}onFocus(t){t.persist(),this.focusedElm=t.target,setTimeout((()=>{const e=t.target,{selectionStart:n,selectionEnd:r,value:o=""}=e,s=this.correctCaretPosition(o,n);s===n||0===n&&r===o.length||this.setPatchedCaretPosition(e,s,o),this.props.onFocus(t)}),0)}render(){const{type:t,displayType:e,customInput:n,renderText:r,getInputRef:o}=this.props,{value:s}=this.state,i=function(t,e){const n={};return Object.keys(t).forEach((r=>{e[r]||(n[r]=t[r])})),n}(this.props,m),a=Object.assign({},i,{type:t,value:s,onChange:this.onChange,onKeyDown:this.onKeyDown,onMouseUp:this.onMouseUp,onFocus:this.onFocus,onBlur:this.onBlur});if("text"===e)return r?r(s)||null:(0,d.jsx)("span",{...i,ref:o,children:s});if(n){const t=n;return(0,d.jsx)(t,{...a,ref:o})}return(0,d.jsx)("input",{...a,ref:o})}}x.defaultProps=S;const v=x;class b extends r.Component{render(){const{name:t,value:e,onValueChange:n,thousandSeparator:r,decimalSeparator:s,invalid:i,decimalScale:a,...l}=this.props;return(0,d.jsx)(v,{...l,style:{textAlign:"right"},value:e,thousandSeparator:r||",",decimalSeparator:s||".",decimalScale:a||2,onValueChange:e=>n({values:e,name:t}),invalid:i,customInput:o.A})}}b.defaultProps={placeholder:"Nh\xe2p..."};const y=b}}]); //# sourceMappingURL=639.35165e56.chunk.js.map