????

Your IP : 216.73.216.64


Current Path : C:/inetpub/vhost/gdnn.gdtsolutions.vn/build/assets/
Upload File :
Current File : C:/inetpub/vhost/gdnn.gdtsolutions.vn/build/assets/SelectCustom-028e0a1b.js

import{P as l,R as B,j as S,ah as $,r as v}from"./index-fa055cb8.js";import{I as M}from"./reactstrap.modern-274e1102.js";import{S as L}from"./ButtonLoad-5b8d7df7.js";function b(){}function U(){return!0}function w(i){return!!(i||"").match(/\d/)}function j(i){return i.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}function K(i){switch(i){case"lakh":return/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;case"wan":return/(\d)(?=(\d{4})+(?!\d))/g;case"thousand":default:return/(\d)(?=(\d{3})+(?!\d))/g}}function G(i,t,e){const n=K(e);let o=i.search(/[1-9]/);return o=o===-1?i.length:o,i.substring(0,o)+i.substring(o,i.length).replace(n,"$1"+t)}function R(i,t=!0){const e=i[0]==="-",n=e&&t;i=i.replace("-","");const o=i.split("."),r=o[0],s=o[1]||"";return{beforeDecimal:r,afterDecimal:s,hasNagation:e,addNegation:n}}function Z(i){if(!i)return i;const t=i[0]==="-";t&&(i=i.substring(1,i.length));const e=i.split("."),n=e[0].replace(/^0+/,"")||"0",o=e[1]||"";return`${t?"-":""}${n}${o?`.${o}`:""}`}function O(i,t,e){let n="";const o=e?"0":"";for(let r=0;r<=t-1;r++)n+=i[r]||o;return n}function H(i,t,e){if(["","-"].indexOf(i)!==-1)return i;const n=i.indexOf(".")!==-1&&t,{beforeDecimal:o,afterDecimal:r,hasNagation:s}=R(i),a=parseFloat(`0.${r||"0"}`).toFixed(t).split("."),u=o.split("").reverse().reduce((p,g,x)=>p.length>x?(Number(p[0])+Number(g)).toString()+p.substring(1,p.length):g+p,a[0]),c=O(a[1]||"",Math.min(t,r.length),e);return`${s?"-":""}${u}${n?".":""}${c}`}function W(i,t){const e={};return Object.keys(i).forEach(n=>{t[n]||(e[n]=i[n])}),e}function I(i,t){if(i!==null){if(i.createTextRange){const e=i.createTextRange();return e.move("character",t),e.select(),!0}return i.selectionStart||i.selectionStart===0?(i.focus(),i.setSelectionRange(t,t),!0):(i.focus(),!1)}}function q(i,t){let e=0,n=0;const o=i.length,r=t.length;for(;i[e]===t[e]&&e<o;)e++;for(;i[o-1-n]===t[r-1-n]&&r-n>e&&o-n>e;)n++;return{start:e,end:o-n}}function P(i,t,e){return Math.min(Math.max(i,t),e)}function E(i){return Math.max(i.selectionStart,i.selectionEnd)}const T={thousandSeparator:l.oneOfType([l.string,l.oneOf([!0])]),decimalSeparator:l.string,thousandsGroupStyle:l.oneOf(["thousand","lakh","wan"]),decimalScale:l.number,fixedDecimalScale:l.bool,displayType:l.oneOf(["input","text"]),prefix:l.string,suffix:l.string,format:l.oneOfType([l.string,l.func]),removeFormatting:l.func,mask:l.oneOfType([l.string,l.arrayOf(l.string)]),value:l.oneOfType([l.number,l.string]),defaultValue:l.oneOfType([l.number,l.string]),isNumericString:l.bool,customInput:l.elementType,allowNegative:l.bool,allowEmptyFormatting:l.bool,allowLeadingZeros:l.bool,onValueChange:l.func,onKeyDown:l.func,onMouseUp:l.func,onChange:l.func,onFocus:l.func,onBlur:l.func,type:l.oneOf(["text","tel","password"]),isAllowed:l.func,renderText:l.func,getInputRef:l.func},z={displayType:"input",decimalSeparator:".",thousandsGroupStyle:"thousand",fixedDecimalScale:!1,prefix:"",suffix:"",allowNegative:!0,allowEmptyFormatting:!1,allowLeadingZeros:!1,isNumericString:!1,type:"text",onValueChange:b,onChange:b,onKeyDown:b,onMouseUp:b,onFocus:b,onBlur:b,isAllowed:U,getInputRef:b};let V=class extends B.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:o}=this,{value:r,numAsString:s=""}=n;if(t!==e){this.validateProps();const a=this.formatNumString(s),u=e.value===void 0?a:this.formatValueProp(),c=this.removeFormatting(u),f=parseFloat(c),h=parseFloat(s);((!isNaN(f)||!isNaN(h))&&f!==h||a!==r||o===null&&u!==r)&&this.updateValue({formattedValue:u,numAsString:c,input:o})}}getFloatString(t=""){const{decimalScale:e}=this.props,{decimalSeparator:n}=this.getSeparators(),o=this.getNumberRegex(!0),r=t[0]==="-";r&&(t=t.replace("-","")),n&&e===0&&(t=t.split(n)[0]),t=(t.match(o)||[]).join("").replace(n,".");const s=t.indexOf(".");return s!==-1&&(t=`${t.substring(0,s)}.${t.substring(s+1,t.length).replace(new RegExp(j(n),"g"),"")}`),r&&(t="-"+t),t}getNumberRegex(t,e){const{format:n,decimalScale:o}=this.props,{decimalSeparator:r}=this.getSeparators();return new RegExp("\\d"+(r&&o!==0&&!e&&!n?"|"+j(r):""),t?"g":void 0)}getSeparators(){const{decimalSeparator:t}=this.props;let{thousandSeparator:e}=this.props;return e===!0&&(e=","),{decimalSeparator:t,thousandSeparator:e}}getMaskAtIndex(t){const{mask:e=" "}=this.props;return typeof e=="string"?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(`
          Decimal separator can't be same as thousand separator.
          thousandSeparator: ${n} (thousandSeparator = {true} is same as thousandSeparator = ",")
          decimalSeparator: ${e} (default value for decimalSeparator is .)
       `);if(t&&(t==="string"?t:t.toString()).match(/\d/g))throw new Error(`
          Mask ${t} should not contain numeric character;
        `)}setPatchedCaretPosition(t,e,n){I(t,e),setTimeout(()=>{t.value===n&&I(t,e)},0)}correctCaretPosition(t,e,n){const{prefix:o,suffix:r,format:s}=this.props;if(t==="")return 0;if(e=P(e,0,t.length),!s){const g=t[0]==="-";return P(e,o.length+(g?1:0),t.length-r.length)}if(typeof s=="function"||s[e]==="#"&&w(t[e])||s[e-1]==="#"&&w(t[e-1]))return e;const a=s.indexOf("#"),u=s.lastIndexOf("#");e=P(e,a,u+1);const c=s.substring(e,s.length).indexOf("#");let f=e;const h=e+(c===-1?0:c);for(;f>a&&(s[f]!=="#"||!w(t[f]));)f-=1;return!w(t[h])||n==="left"&&e!==a||e-f<h-e?w(t[f])?f+1:f:h}getCaretPosition(t,e,n){const{format:o}=this.props,r=this.state.value,s=this.getNumberRegex(!0),a=(t.match(s)||[]).join(""),u=(e.match(s)||[]).join("");let c,f;for(c=0,f=0;f<n;f++){const h=t[f]||"",p=e[c]||"";if(!(!h.match(s)&&h!==p)&&!(h==="0"&&p.match(s)&&p!=="0"&&a.length!==u.length)){for(;h!==e[c]&&c<e.length;)c++;c++}}return typeof o=="string"&&!r&&(c=e.length),c=this.correctCaretPosition(e,c),c}removePrefixAndSuffix(t){const{format:e,prefix:n,suffix:o}=this.props;if(!e&&t){const r=t[0]==="-";r&&(t=t.substring(1,t.length)),t=n&&t.indexOf(n)===0?t.substring(n.length,t.length):t;const s=t.lastIndexOf(o);t=o&&s!==-1&&s===t.length-o.length?t.substring(0,s):t,r&&(t="-"+t)}return t}removePatternFormatting(t){const{format:e}=this.props,n=e.split("#").filter(s=>s!=="");let o=0,r="";for(let s=0,a=n.length;s<=a;s++){const u=n[s]||"",c=s===a?t.length:t.indexOf(u,o);if(c===-1){r=t;break}else r+=t.substring(o,c),o=c+u.length}return(r.match(/\d/g)||[]).join("")}removeFormatting(t){const{format:e,removeFormatting:n}=this.props;return t&&(e?typeof e=="string"?t=this.removePatternFormatting(t):typeof n=="function"?t=n(t):t=(t.match(/\d/g)||[]).join(""):(t=this.removePrefixAndSuffix(t),t=this.getFloatString(t)),t)}formatWithPattern(t){const{format:e}=this.props;let n=0;const o=e.split("");for(let r=0,s=e.length;r<s;r++)e[r]==="#"&&(o[r]=t[n]||this.getMaskAtIndex(n),n+=1);return o.join("")}formatAsNumber(t){const{decimalScale:e,fixedDecimalScale:n,prefix:o,suffix:r,allowNegative:s,thousandsGroupStyle:a}=this.props,{thousandSeparator:u,decimalSeparator:c}=this.getSeparators(),f=t.indexOf(".")!==-1||e&&n;let{beforeDecimal:h,afterDecimal:p,addNegation:g}=R(t,s);return e!==void 0&&(p=O(p,e,n)),u&&(h=G(h,u,a)),o&&(h=o+h),r&&(p=p+r),g&&(h="-"+h),t=h+(f&&c||"")+p,t}formatNumString(t=""){const{format:e,allowEmptyFormatting:n}=this.props;let o=t;return t===""&&!n?o="":t==="-"&&!e?o="-":typeof e=="string"?o=this.formatWithPattern(o):typeof e=="function"?o=e(o):o=this.formatAsNumber(o),o}formatValueProp(t){const{format:e,decimalScale:n,fixedDecimalScale:o,allowEmptyFormatting:r}=this.props;let{value:s=t,isNumericString:a}=this.props;const u=!s&&s!==0;return u&&r&&(s=""),u&&!r?"":(typeof s=="number"&&(s=s.toString(),a=!0),s==="Infinity"&&a&&(s=""),a&&!e&&typeof n=="number"&&(s=H(s,n,o)),a?this.formatNumString(s):this.formatInput(s))}formatNegation(t=""){const{allowNegative:e}=this.props,n=new RegExp("(-)"),o=new RegExp("(-)(.)*(-)"),r=n.test(t),s=o.test(t);return t=t.replace(/-/g,""),r&&!s&&e&&(t="-"+t),t}formatInput(t=""){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:o,suffix:r,decimalScale:s,fixedDecimalScale:a}=this.props,{decimalSeparator:u}=this.getSeparators();return!!(typeof n=="string"&&n[t]!=="#"||!n&&(t<o.length||t>=e.length-r.length||s&&a&&e[t]===u))}checkIfFormatGotDeleted(t,e,n){for(let o=t;o<e;o++)if(this.isCharacterAFormat(o,n))return!0;return!1}correctInputValue(t,e,n){const{format:o,allowNegative:r,prefix:s,suffix:a}=this.props,{decimalSeparator:u}=this.getSeparators(),c=this.state.numAsString||"",{selectionStart:f,selectionEnd:h}=this.selectionBeforeInput,{start:p,end:g}=q(e,n);if(!o&&u!=="."&&p===g&&n[f]===".")return n.substr(0,f)+u+n.substr(f+1,n.length);const x=o?0:s.length,d=e.length-(o?0:a.length);if(n.length>e.length||!n.length||p===g||f===0&&h===e.length||f===x&&h===d)return n;if(this.checkIfFormatGotDeleted(p,g,e)&&(n=e),!o){const N=this.removeFormatting(n);let{beforeDecimal:C,afterDecimal:m,addNegation:y}=R(N,r);const D=t<n.indexOf(u)+1;if(N.length<c.length&&D&&C===""&&!parseFloat(m))return y?"-":""}return n}updateValue(t,e){const{formattedValue:n,input:o}=t;let{numAsString:r,caretPos:s}=t;const{onValueChange:a}=this.props,{value:u}=this.state;if(o){if(!s){const c=t.inputValue||o.value,f=E(o);s=this.getCaretPosition(c,n,f)}o.value=n,this.setPatchedCaretPosition(o,s,n)}r===void 0&&(r=this.removeFormatting(n)),n!==u&&this.setState({value:n,numAsString:r},()=>{a(this.getValueObject(n,r))})}onChange(t){t.persist();const e=t.target;let n=e.value;const{state:o,props:r}=this,{isAllowed:s}=r,a=o.value||"",u=E(e);n=this.correctInputValue(u,a,n);let c=this.formatInput(n)||"";const f=this.removeFormatting(c),h=this.getValueObject(c,f);s(h)||(c=a),this.updateValue({formattedValue:c,numAsString:f,inputValue:n,input:e},()=>{r.onChange(t)})}onBlur(t){const{props:e,state:n}=this,{format:o,onBlur:r,allowLeadingZeros:s}=e;let{numAsString:a}=n;const u=n.value;if(this.focusedElm=null,!o){s||(a=Z(a));const c=this.formatNumString(a);if(c!==u){t.persist(),this.updateValue({formattedValue:c,numAsString:a},()=>{r(a)});return}}r(a)}onKeyDown(t){const e=t.target,{key:n}=t,{selectionStart:o,selectionEnd:r,value:s=""}=e;let a;const{decimalScale:u,fixedDecimalScale:c,prefix:f,suffix:h,format:p,onKeyDown:g}=this.props,x=u!==void 0&&c,d=this.getNumberRegex(!1,x),N=new RegExp("-"),C=typeof p=="string";if(this.selectionBeforeInput={selectionStart:o,selectionEnd:r},n==="ArrowLeft"||n==="Backspace"?a=o-1:n==="ArrowRight"?a=o+1:n==="Delete"&&(a=o),a===void 0||o!==r){g(t);return}let m=a;const y=C?p.indexOf("#"):f.length,D=C?p.lastIndexOf("#")+1:s.length-h.length;if(n==="ArrowLeft"||n==="ArrowRight"){const F=n==="ArrowLeft"?"left":"right";m=this.correctCaretPosition(s,a,F)}else if(n==="Delete"&&!d.test(s[a])&&!N.test(s[a]))for(;!d.test(s[m])&&m<D;)m++;else if(n==="Backspace"&&!d.test(s[a])){if(o<=y+1&&s[0]==="-"&&typeof p>"u"){const F=s.substring(1);t.persist(),this.updateValue({formattedValue:F,caretPos:m,input:e})}else if(!N.test(s[a])){for(;!d.test(s[m-1])&&m>y;)m--;m=this.correctCaretPosition(s,m,"left")}}(m!==a||a<y||a>D)&&(t.preventDefault(),this.setPatchedCaretPosition(e,m,s)),t.isUnitTestRun&&this.setPatchedCaretPosition(e,m,s),this.props.onKeyDown(t)}onMouseUp(t){const e=t.target,{selectionStart:n,selectionEnd:o,value:r=""}=e;if(n===o){const s=this.correctCaretPosition(r,n);s!==n&&this.setPatchedCaretPosition(e,s,r)}this.props.onMouseUp(t)}onFocus(t){t.persist(),this.focusedElm=t.target,setTimeout(()=>{const e=t.target,{selectionStart:n,selectionEnd:o,value:r=""}=e,s=this.correctCaretPosition(r,n);s!==n&&!(n===0&&o===r.length)&&this.setPatchedCaretPosition(e,s,r),this.props.onFocus(t)},0)}render(){const{type:t,displayType:e,customInput:n,renderText:o,getInputRef:r}=this.props,{value:s}=this.state,a=W(this.props,T),u=Object.assign({},a,{type:t,value:s,onChange:this.onChange,onKeyDown:this.onKeyDown,onMouseUp:this.onMouseUp,onFocus:this.onFocus,onBlur:this.onBlur});if(e==="text")return o?o(s)||null:S.jsxDEV("span",{...a,ref:r,children:s},void 0,!1,{fileName:"/home/jenkins/agent/workspace/gdnn.gdtsolutions.vn/src/childcomp/numberformat/number-format.jsx",lineNumber:882,columnNumber:9},this);if(n){const c=n;return S.jsxDEV(c,{...u,ref:r},void 0,!1,{fileName:"/home/jenkins/agent/workspace/gdnn.gdtsolutions.vn/src/childcomp/numberformat/number-format.jsx",lineNumber:888,columnNumber:14},this)}return S.jsxDEV("input",{...u,ref:r},void 0,!1,{fileName:"/home/jenkins/agent/workspace/gdnn.gdtsolutions.vn/src/childcomp/numberformat/number-format.jsx",lineNumber:891,columnNumber:12},this)}};V.propTypes=T;V.defaultProps=z;function A(i){const{isDetail:t,value:e,invalid:n,onValueChange:o,onKeyDown:r,bsSize:s="sm",style:a,onBlur:u,onFocus:c,decimalScale:f,thousandSeparator:h,decimalSeparator:p,customInput:g,...x}=i||{};return t?S.jsxDEV("div",{style:{textAlign:"right"},children:e===0||e===null?"":$(e)},void 0,!1,{fileName:"/home/jenkins/agent/workspace/gdnn.gdtsolutions.vn/src/childcomp/numberformat/NumberFormat.jsx",lineNumber:26,columnNumber:12},this):S.jsxDEV(V,{...x,style:{textAlign:"right",...a},value:e,thousandSeparator:".",decimalSeparator:",",onValueChange:o,onBlur:d=>u&&u(d),onKeyDown:r,onFocus:c,customInput:g||M,bsSize:s,decimalScale:f==="0"?0:f||2,invalid:n},void 0,!1,{fileName:"/home/jenkins/agent/workspace/gdnn.gdtsolutions.vn/src/childcomp/numberformat/NumberFormat.jsx",lineNumber:29,columnNumber:7},this)}A.defaultProps={placeholder:"Nhâp..."};A.propTypes={placeholder:l.string};class k extends v.Component{render(){const{value:t,onChange:e,options:n}=this.props,o=t||"";var r="value",s="label";return S.jsxDEV(L,{value:o,onChange:e,options:n,valueRef:r,labelRef:s,placeholder:"Chọn..."},void 0,!1,{fileName:"/home/jenkins/agent/workspace/gdnn.gdtsolutions.vn/src/childcomp/select/SelectCustom.jsx",lineNumber:12,columnNumber:7},this)}}k.propTypes={};k.defaultProps={placeholder:"Chọn..."};export{V as N,k as S,A as a};