react-currency-input-field
Advanced tools
Comparing version 3.3.1 to 3.3.2
@@ -0,1 +1,8 @@ | ||
## [3.3.2](https://github.com/cchanxzy/react-currency-input-field/compare/v3.3.1...v3.3.2) (2021-04-13) | ||
### Bug Fixes | ||
* prevent cursor jumping when press delete key ([#155](https://github.com/cchanxzy/react-currency-input-field/issues/155)) ([242ec90](https://github.com/cchanxzy/react-currency-input-field/commit/242ec908d6eb34b1767b21b21515d5ea25e3c80e)) | ||
## [3.3.1](https://github.com/cchanxzy/react-currency-input-field/compare/v3.3.0...v3.3.1) (2021-03-21) | ||
@@ -2,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
module.exports=function(e){var r={};function t(a){if(r[a])return r[a].exports;var n=r[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=r,t.d=function(e,r,a){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(a,n,function(r){return e[r]}.bind(null,n));return a},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=3)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.escapeRegExp=void 0,r.escapeRegExp=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}},function(e,r,t){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)},n=this&&this.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var a=Array(e),n=0;for(r=0;r<t;r++)for(var i=arguments[r],o=0,u=i.length;o<u;o++,n++)a[n]=i[o];return a};Object.defineProperty(r,"__esModule",{value:!0}),r.formatValue=void 0;var i=t(0),o=t(2);r.formatValue=function(e){var r=e.value,t=e.decimalSeparator,n=e.intlConfig,c=e.decimalScale,f=e.prefix,s=void 0===f?"":f,p=e.suffix,d=void 0===p?"":p;if(""===r||void 0===r)return"";if("-"===r)return"-";var v=new RegExp("^\\d?-"+(s?i.escapeRegExp(s)+"?":"")+"\\d").test(r),g="."!==t?u(r,t,v):r,m=(n?new Intl.NumberFormat(n.locale,n.currency?{style:"currency",currency:n.currency,minimumFractionDigits:c||0,maximumFractionDigits:20}:void 0):new Intl.NumberFormat(void 0,{minimumFractionDigits:c||0,maximumFractionDigits:20})).formatToParts(Number(g)),b=l(m,e),y=o.getSuffix(b,a({},e)),h=r.slice(-1)===t?t:"",S=(g.match(RegExp("\\d+\\.(\\d+)"))||[])[1];return void 0===c&&S&&t&&(b=b.includes(t)?b.replace(RegExp("(\\d+)("+i.escapeRegExp(t)+")(\\d+)","g"),"$1$2"+S):y&&!d?b.replace(y,""+t+S+y):""+b+t+S),d&&h?""+b+h+d:y&&h?b.replace(y,""+h+y):y&&d?b.replace(y,""+h+d):[b,h,d].join("")};var u=function(e,r,t){var a=e;return r&&"."!==r&&(a=a.replace(RegExp(i.escapeRegExp(r),"g"),"."),t&&"-"===r&&(a="-"+a.slice(1))),a},l=function(e,r){var t=r.prefix,a=r.groupSeparator,i=r.decimalSeparator,o=r.decimalScale,u=r.disableGroupSeparators,l=void 0!==u&&u;return e.reduce((function(e,r,u){var c=r.type,f=r.value;return 0===u&&t?"minusSign"===c?[f,t]:"currency"===c?n(e,[t]):[t,f]:"currency"===c?t?e:n(e,[f]):"group"===c?l?e:n(e,[void 0!==a?a:f]):"decimal"===c?void 0!==o&&0===o?e:n(e,[void 0!==i?i:f]):n(e,"fraction"===c?[void 0!==o?f.slice(0,o):f]:[f])}),[""]).join("")}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getSuffix=void 0;var a=t(0);r.getSuffix=function(e,r){var t=r.groupSeparator,n=void 0===t?",":t,i=r.decimalSeparator,o=void 0===i?".":i,u=new RegExp("\\d([^"+a.escapeRegExp(n)+a.escapeRegExp(o)+"0-9]+)"),l=e.match(u);return l?l[1]:void 0}},function(e,r,t){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var n=a(t(4));r.default=n.default;var i=t(1);Object.defineProperty(r,"formatValue",{enumerable:!0,get:function(){return i.formatValue}})},function(e,r,t){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)},n=this&&this.__createBinding||(Object.create?function(e,r,t,a){void 0===a&&(a=t),Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,a){void 0===a&&(a=t),e[a]=r[t]}),i=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.hasOwnProperty.call(e,t)&&n(r,e,t);return i(r,e),r},u=this&&this.__rest||function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]])}return t};Object.defineProperty(r,"__esModule",{value:!0}),r.CurrencyInput=void 0;var l=o(t(5)),c=t(6);r.CurrencyInput=l.forwardRef((function(e,r){var t=e.allowDecimals,n=void 0===t||t,i=e.allowNegativeValue,o=void 0===i||i,f=e.id,s=e.name,p=e.className,d=e.customInput,v=e.decimalsLimit,g=e.defaultValue,m=e.disabled,b=void 0!==m&&m,y=e.maxLength,h=e.value,S=e.onValueChange,x=e.fixedDecimalLength,_=e.placeholder,w=e.decimalScale,O=e.prefix,j=e.suffix,P=e.intlConfig,E=e.step,V=e.min,R=e.max,M=e.disableGroupSeparators,C=void 0!==M&&M,D=e.disableAbbreviations,N=void 0!==D&&D,A=e.decimalSeparator,I=e.groupSeparator,F=e.onChange,L=e.onFocus,T=e.onBlur,k=e.onKeyDown,K=e.onKeyUp,U=u(e,["allowDecimals","allowNegativeValue","id","name","className","customInput","decimalsLimit","defaultValue","disabled","maxLength","value","onValueChange","fixedDecimalLength","placeholder","decimalScale","prefix","suffix","intlConfig","step","min","max","disableGroupSeparators","disableAbbreviations","decimalSeparator","groupSeparator","onChange","onFocus","onBlur","onKeyDown","onKeyUp"]);if(A&&I&&A===I)throw new Error("decimalSeparator cannot be the same as groupSeparator");if(A&&c.isNumber(A))throw new Error("decimalSeparator cannot be a number");if(I&&c.isNumber(I))throw new Error("groupSeparator cannot be a number");var B=l.useMemo((function(){return c.getLocaleConfig(P)}),[P]),G=A||B.decimalSeparator||"",$=I||B.groupSeparator||"",q={decimalSeparator:G,groupSeparator:$,disableGroupSeparators:C,intlConfig:P,prefix:O||B.prefix,suffix:j},z={decimalSeparator:G,groupSeparator:$,allowDecimals:n,decimalsLimit:v||x||2,allowNegativeValue:o,disableAbbreviations:N,prefix:O||B.prefix},H=void 0!==g?c.formatValue(a(a({},q),{decimalScale:w,value:String(g)})):void 0!==h?c.formatValue(a(a({},q),{decimalScale:w,value:String(h)})):"",J=l.useState(H),Q=J[0],W=J[1],X=l.useState(!1),Y=X[0],Z=X[1],ee=l.useState(0),re=ee[0],te=ee[1],ae=r||l.useRef(null),ne=function(e,r){Z(!0);var t=c.cleanValue(a({value:e},z));if(""===t)return S&&S(void 0,s),void W("");if(!(y&&t.replace(/-/g,"").length>y)){if("-"===t||t===G)return S&&S(void 0,s),void W(e);var n=c.formatValue(a({value:t},q));if(null!=r){var i=r+(n.length-e.length)||1;te(i)}W(n),S&&S(t,s)}};l.useEffect((function(){Y&&"-"!==Q&&ae&&"object"==typeof ae&&ae.current&&ae.current.setSelectionRange(re,re)}),[re,ae,Y]);var ie=void 0!==h?c.formatValue(a(a({},q),{decimalScale:Y?void 0:w,value:String(h)})):void 0,oe=a({type:"text",inputMode:"decimal",id:f,name:s,className:p,onChange:function(e){var r=e.target,t=r.value,a=r.selectionStart;ne(t,a),F&&F(e)},onBlur:function(e){var r=e.target.value,t=c.cleanValue(a({value:r},z));if("-"===t||!t)return W(""),void(T&&T(e));var n=c.fixedDecimalValue(t,G,x),i=c.padTrimValue(n,G,void 0!==w?w:x);S&&S(i,s);var o=c.formatValue(a(a({},q),{value:i}));W(o),T&&T(e)},onFocus:function(e){return L&&L(e),Q?Q.length:0},onKeyDown:function(e){var r=e.key;if(E&&("ArrowUp"===r||"ArrowDown"===r)){e.preventDefault(),te(Q.length);var t=parseFloat(void 0!==h?String(h).replace(G,"."):c.cleanValue(a({value:Q},z)))||0,n="ArrowUp"===r?t+E:t-E;if(void 0!==V&&n<V)return;if(void 0!==R&&n>R)return;var i=String(E).includes(G)?Number(String(E).split(G)[1].length):void 0;ne(String(i?n.toFixed(i):n).replace(".",G))}k&&k(e)},onKeyUp:function(e){var r=e.key,t=e.currentTarget.selectionStart;if("ArrowUp"!==r&&"ArrowDown"!==r&&"-"!==Q){var a=c.getSuffix(Q,{groupSeparator:$,decimalSeparator:G});if(a&&t&&t>Q.length-a.length&&ae&&"object"==typeof ae&&ae.current){var n=Q.length-a.length;ae.current.setSelectionRange(n,n)}}K&&K(e)},placeholder:_,disabled:b,value:void 0!==ie&&"-"!==Q&&Q!==G?ie:Q,ref:ae},U);if(d){var ue=d;return l.default.createElement(ue,a({},oe))}return l.default.createElement("input",a({},oe))})),r.CurrencyInput.displayName="CurrencyInput",r.default=r.CurrencyInput},function(e,r){e.exports=require("react")},function(e,r,t){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,r,t,a){void 0===a&&(a=t),Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,a){void 0===a&&(a=t),e[a]=r[t]}),n=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||r.hasOwnProperty(t)||a(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),n(t(7),r),n(t(11),r),n(t(1),r),n(t(12),r),n(t(2),r),n(t(13),r),n(t(14),r)},function(e,r,t){"use strict";var a=this&&this.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var a=Array(e),n=0;for(r=0;r<t;r++)for(var i=arguments[r],o=0,u=i.length;o<u;o++,n++)a[n]=i[o];return a};Object.defineProperty(r,"__esModule",{value:!0}),r.cleanValue=void 0;var n=t(8),i=t(9),o=t(10),u=t(0);r.cleanValue=function(e){var r=e.value,t=e.groupSeparator,l=void 0===t?",":t,c=e.decimalSeparator,f=void 0===c?".":c,s=e.allowDecimals,p=void 0===s||s,d=e.decimalsLimit,v=void 0===d?2:d,g=e.allowNegativeValue,m=void 0===g||g,b=e.disableAbbreviations,y=void 0!==b&&b,h=e.prefix,S=void 0===h?"":h;if("-"===r)return r;var x=y?[]:["k","m","b"],_=new RegExp("((^|\\D)-\\d)|(-"+u.escapeRegExp(S)+")").test(r),w=RegExp("(\\d+)-?"+u.escapeRegExp(S)).exec(r)||[],O=w[0],j=w[1],P=S?O?r.replace(O,"").concat(j):r.replace(S,""):r,E=i.removeSeparators(P,l),V=o.removeInvalidChars(E,a([l,f],x)),R=V;if(!y){if(x.some((function(e){return e===V.toLowerCase()})))return"";var M=n.parseAbbrValue(V,f);M&&(R=String(M))}var C=_&&m?"-":"";if(f&&R.includes(f)){var D=V.split(f),N=D[0],A=D[1],I=v&&A?A.slice(0,v):A;return""+C+N+(p?""+f+I:"")}return""+C+R}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseAbbrValue=r.abbrValue=void 0;var a=t(0);r.abbrValue=function(e,r,t){if(void 0===r&&(r="."),void 0===t&&(t=10),e>999){var a=(""+e).length,n=Math.pow,i=n(10,t);return a-=a%3,(Math.round(e*i/n(10,a))/i+" kMGTPE"[a/3]).replace(".",r)}return String(e)};var n={k:1e3,m:1e6,b:1e9};r.parseAbbrValue=function(e,r){void 0===r&&(r=".");var t=new RegExp("(\\d+("+a.escapeRegExp(r)+"\\d+)?)([kmb])$","i"),i=e.match(t);if(i){var o=i[1],u=i[3],l=n[u.toLowerCase()];return Number(o.replace(r,"."))*l}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.removeSeparators=void 0;var a=t(0);r.removeSeparators=function(e,r){void 0===r&&(r=",");var t=new RegExp(a.escapeRegExp(r),"g");return e.replace(t,"")}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.removeInvalidChars=void 0;var a=t(0);r.removeInvalidChars=function(e,r){var t=a.escapeRegExp(r.join("")),n=new RegExp("[^\\d"+t+"]","gi");return e.replace(n,"")}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.fixedDecimalValue=void 0,r.fixedDecimalValue=function(e,r,t){if(t&&e.length>1){if(e.includes(r)){var a=e.split(r),n=a[0];if((i=a[1]).length>t)return""+n+r+i.slice(0,t)}var i,o=e.length>t?new RegExp("(\\d+)(\\d{"+t+"})"):new RegExp("(\\d)(\\d+)"),u=e.match(o);if(u)return""+(n=u[1])+r+(i=u[2])}return e}},function(e,r,t){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)};Object.defineProperty(r,"__esModule",{value:!0}),r.getLocaleConfig=void 0;var n={currencySymbol:"",groupSeparator:"",decimalSeparator:"",prefix:"",suffix:""};r.getLocaleConfig=function(e){var r=e||{},t=r.locale,i=r.currency;return(t?new Intl.NumberFormat(t,i?{currency:i,style:"currency"}:void 0):new Intl.NumberFormat).formatToParts(1000.1).reduce((function(e,r,t){return"currency"===r.type?a(a({},e),0===t?{currencySymbol:r.value,prefix:r.value}:{currencySymbol:r.value,suffix:r.value}):"group"===r.type?a(a({},e),{groupSeparator:r.value}):"decimal"===r.type?a(a({},e),{decimalSeparator:r.value}):e}),n)}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isNumber=void 0,r.isNumber=function(e){return RegExp(/\d/,"gi").test(e)}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.padTrimValue=void 0,r.padTrimValue=function(e,r,t){if(void 0===r&&(r="."),void 0===t||""===e||void 0===e)return e;if(!e.match(/\d/g))return"";var a=e.split(r),n=a[0],i=a[1];if(0===t)return n;var o=i||"";if(o.length<t)for(;o.length<t;)o+="0";else o=o.slice(0,t);return""+n+r+o}}]); | ||
(()=>{"use strict";var e={660:function(e,r,a){var t=this&&this.__assign||function(){return(t=Object.assign||function(e){for(var r,a=1,t=arguments.length;a<t;a++)for(var i in r=arguments[a])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,r,a,t){void 0===t&&(t=a),Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[a]}})}:function(e,r,a,t){void 0===t&&(t=a),e[t]=r[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&i(r,e,a);return n(r,e),r},u=this&&this.__rest||function(e,r){var a={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(a[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(e);i<t.length;i++)r.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(a[t[i]]=e[t[i]])}return a};Object.defineProperty(r,"__esModule",{value:!0}),r.CurrencyInput=void 0;var l=o(a(297)),c=a(497);r.CurrencyInput=l.forwardRef((function(e,r){var a=e.allowDecimals,i=void 0===a||a,n=e.allowNegativeValue,o=void 0===n||n,p=e.id,d=e.name,f=e.className,v=e.customInput,s=e.decimalsLimit,m=e.defaultValue,g=e.disabled,b=void 0!==g&&g,h=e.maxLength,y=e.value,x=e.onValueChange,S=e.fixedDecimalLength,_=e.placeholder,w=e.decimalScale,O=e.prefix,j=e.suffix,V=e.intlConfig,E=e.step,P=e.min,R=e.max,C=e.disableGroupSeparators,D=void 0!==C&&C,M=e.disableAbbreviations,N=void 0!==M&&M,I=e.decimalSeparator,A=e.groupSeparator,F=e.onChange,L=e.onFocus,T=e.onBlur,k=e.onKeyDown,K=e.onKeyUp,U=u(e,["allowDecimals","allowNegativeValue","id","name","className","customInput","decimalsLimit","defaultValue","disabled","maxLength","value","onValueChange","fixedDecimalLength","placeholder","decimalScale","prefix","suffix","intlConfig","step","min","max","disableGroupSeparators","disableAbbreviations","decimalSeparator","groupSeparator","onChange","onFocus","onBlur","onKeyDown","onKeyUp"]);if(I&&A&&I===A)throw new Error("decimalSeparator cannot be the same as groupSeparator");if(I&&c.isNumber(I))throw new Error("decimalSeparator cannot be a number");if(A&&c.isNumber(A))throw new Error("groupSeparator cannot be a number");var B=l.useMemo((function(){return c.getLocaleConfig(V)}),[V]),G=I||B.decimalSeparator||"",$=A||B.groupSeparator||"",q={decimalSeparator:G,groupSeparator:$,disableGroupSeparators:D,intlConfig:V,prefix:O||B.prefix,suffix:j},z={decimalSeparator:G,groupSeparator:$,allowDecimals:i,decimalsLimit:s||S||2,allowNegativeValue:o,disableAbbreviations:N,prefix:O||B.prefix},H=void 0!==m?c.formatValue(t(t({},q),{decimalScale:w,value:String(m)})):void 0!==y?c.formatValue(t(t({},q),{decimalScale:w,value:String(y)})):"",J=l.useState(H),Q=J[0],W=J[1],X=l.useState(!1),Y=X[0],Z=X[1],ee=l.useState(0),re=ee[0],ae=ee[1],te=r||l.useRef(null),ie=function(e,r){Z(!0);var a=c.cleanValue(t({value:e},z));if(""===a)return x&&x(void 0,d),void W("");if(!(h&&a.replace(/-/g,"").length>h)){if("-"===a||a===G)return x&&x(void 0,d),void W(e);var i=c.formatValue(t({value:a},q));if(null!=r){var n=r+(i.length-e.length)||1;ae(n)}W(i),x&&x(a,d)}};l.useEffect((function(){Y&&"-"!==Q&&te&&"object"==typeof te&&te.current&&te.current.setSelectionRange(re,re)}),[Q,re,te,Y]);var ne=void 0!==y?c.formatValue(t(t({},q),{decimalScale:Y?void 0:w,value:String(y)})):void 0,oe=t({type:"text",inputMode:"decimal",id:p,name:d,className:f,onChange:function(e){var r=e.target,a=r.value,t=r.selectionStart;ie(a,t),F&&F(e)},onBlur:function(e){var r=e.target.value,a=c.cleanValue(t({value:r},z));if("-"===a||!a)return W(""),void(T&&T(e));var i=c.fixedDecimalValue(a,G,S),n=c.padTrimValue(i,G,void 0!==w?w:S);x&&x(n,d);var o=c.formatValue(t(t({},q),{value:n}));W(o),T&&T(e)},onFocus:function(e){return L&&L(e),Q?Q.length:0},onKeyDown:function(e){var r=e.key;if(E&&("ArrowUp"===r||"ArrowDown"===r)){e.preventDefault(),ae(Q.length);var a=parseFloat(void 0!==y?String(y).replace(G,"."):c.cleanValue(t({value:Q},z)))||0,i="ArrowUp"===r?a+E:a-E;if(void 0!==P&&i<P)return;if(void 0!==R&&i>R)return;var n=String(E).includes(G)?Number(String(E).split(G)[1].length):void 0;ie(String(n?i.toFixed(n):i).replace(".",G))}k&&k(e)},onKeyUp:function(e){var r=e.key,a=e.currentTarget.selectionStart;if("ArrowUp"!==r&&"ArrowDown"!==r&&"-"!==Q){var t=c.getSuffix(Q,{groupSeparator:$,decimalSeparator:G});if(t&&a&&a>Q.length-t.length&&te&&"object"==typeof te&&te.current){var i=Q.length-t.length;te.current.setSelectionRange(i,i)}}K&&K(e)},placeholder:_,disabled:b,value:void 0!==ne&&"-"!==Q&&Q!==G?ne:Q,ref:te},U);if(v){var ue=v;return l.default.createElement(ue,t({},oe))}return l.default.createElement("input",t({},oe))})),r.CurrencyInput.displayName="CurrencyInput",r.default=r.CurrencyInput},226:function(e,r,a){var t=this&&this.__spreadArray||function(e,r){for(var a=0,t=r.length,i=e.length;a<t;a++,i++)e[i]=r[a];return e};Object.defineProperty(r,"__esModule",{value:!0}),r.cleanValue=void 0;var i=a(231),n=a(566),o=a(512),u=a(857);r.cleanValue=function(e){var r=e.value,a=e.groupSeparator,l=void 0===a?",":a,c=e.decimalSeparator,p=void 0===c?".":c,d=e.allowDecimals,f=void 0===d||d,v=e.decimalsLimit,s=void 0===v?2:v,m=e.allowNegativeValue,g=void 0===m||m,b=e.disableAbbreviations,h=void 0!==b&&b,y=e.prefix,x=void 0===y?"":y;if("-"===r)return r;var S=h?[]:["k","m","b"],_=new RegExp("((^|\\D)-\\d)|(-"+u.escapeRegExp(x)+")").test(r),w=RegExp("(\\d+)-?"+u.escapeRegExp(x)).exec(r)||[],O=w[0],j=w[1],V=x?O?r.replace(O,"").concat(j):r.replace(x,""):r,E=n.removeSeparators(V,l),P=o.removeInvalidChars(E,t([l,p],S)),R=P;if(!h){if(S.some((function(e){return e===P.toLowerCase()})))return"";var C=i.parseAbbrValue(P,p);C&&(R=String(C))}var D=_&&g?"-":"";if(p&&R.includes(p)){var M=P.split(p),N=M[0],I=M[1],A=s&&I?I.slice(0,s):I;return""+D+N+(f?""+p+A:"")}return""+D+R}},857:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.escapeRegExp=void 0,r.escapeRegExp=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}},806:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.fixedDecimalValue=void 0,r.fixedDecimalValue=function(e,r,a){if(a&&e.length>1){if(e.includes(r)){var t=e.split(r),i=t[0];if((n=t[1]).length>a)return""+i+r+n.slice(0,a)}var n,o=e.length>a?new RegExp("(\\d+)(\\d{"+a+"})"):new RegExp("(\\d)(\\d+)"),u=e.match(o);if(u)return""+(i=u[1])+r+u[2]}return e}},106:function(e,r,a){var t=this&&this.__assign||function(){return(t=Object.assign||function(e){for(var r,a=1,t=arguments.length;a<t;a++)for(var i in r=arguments[a])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)},i=this&&this.__spreadArray||function(e,r){for(var a=0,t=r.length,i=e.length;a<t;a++,i++)e[i]=r[a];return e};Object.defineProperty(r,"__esModule",{value:!0}),r.formatValue=void 0;var n=a(857),o=a(888);r.formatValue=function(e){var r=e.value,a=e.decimalSeparator,i=e.intlConfig,c=e.decimalScale,p=e.prefix,d=void 0===p?"":p,f=e.suffix,v=void 0===f?"":f;if(""===r||void 0===r)return"";if("-"===r)return"-";var s=new RegExp("^\\d?-"+(d?n.escapeRegExp(d)+"?":"")+"\\d").test(r),m="."!==a?u(r,a,s):r,g=(i?new Intl.NumberFormat(i.locale,i.currency?{style:"currency",currency:i.currency,minimumFractionDigits:c||0,maximumFractionDigits:20}:void 0):new Intl.NumberFormat(void 0,{minimumFractionDigits:c||0,maximumFractionDigits:20})).formatToParts(Number(m)),b=l(g,e),h=o.getSuffix(b,t({},e)),y=r.slice(-1)===a?a:"",x=(m.match(RegExp("\\d+\\.(\\d+)"))||[])[1];return void 0===c&&x&&a&&(b=b.includes(a)?b.replace(RegExp("(\\d+)("+n.escapeRegExp(a)+")(\\d+)","g"),"$1$2"+x):h&&!v?b.replace(h,""+a+x+h):""+b+a+x),v&&y?""+b+y+v:h&&y?b.replace(h,""+y+h):h&&v?b.replace(h,""+y+v):[b,y,v].join("")};var u=function(e,r,a){var t=e;return r&&"."!==r&&(t=t.replace(RegExp(n.escapeRegExp(r),"g"),"."),a&&"-"===r&&(t="-"+t.slice(1))),t},l=function(e,r){var a=r.prefix,t=r.groupSeparator,n=r.decimalSeparator,o=r.decimalScale,u=r.disableGroupSeparators,l=void 0!==u&&u;return e.reduce((function(e,r,u){var c=r.type,p=r.value;return 0===u&&a?"minusSign"===c?[p,a]:"currency"===c?i(i([],e),[a]):[a,p]:"currency"===c?a?e:i(i([],e),[p]):"group"===c?l?e:i(i([],e),[void 0!==t?t:p]):"decimal"===c?void 0!==o&&0===o?e:i(i([],e),[void 0!==n?n:p]):i(i([],e),"fraction"===c?[void 0!==o?p.slice(0,o):p]:[p])}),[""]).join("")}},15:function(e,r){var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var r,a=1,t=arguments.length;a<t;a++)for(var i in r=arguments[a])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)};Object.defineProperty(r,"__esModule",{value:!0}),r.getLocaleConfig=void 0;var t={currencySymbol:"",groupSeparator:"",decimalSeparator:"",prefix:"",suffix:""};r.getLocaleConfig=function(e){var r=e||{},i=r.locale,n=r.currency;return(i?new Intl.NumberFormat(i,n?{currency:n,style:"currency"}:void 0):new Intl.NumberFormat).formatToParts(1000.1).reduce((function(e,r,t){return"currency"===r.type?a(a({},e),0===t?{currencySymbol:r.value,prefix:r.value}:{currencySymbol:r.value,suffix:r.value}):"group"===r.type?a(a({},e),{groupSeparator:r.value}):"decimal"===r.type?a(a({},e),{decimalSeparator:r.value}):e}),t)}},888:(e,r,a)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getSuffix=void 0;var t=a(857);r.getSuffix=function(e,r){var a=r.groupSeparator,i=void 0===a?",":a,n=r.decimalSeparator,o=void 0===n?".":n,u=new RegExp("\\d([^"+t.escapeRegExp(i)+t.escapeRegExp(o)+"0-9]+)"),l=e.match(u);return l?l[1]:void 0}},497:function(e,r,a){var t=this&&this.__createBinding||(Object.create?function(e,r,a,t){void 0===t&&(t=a),Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[a]}})}:function(e,r,a,t){void 0===t&&(t=a),e[t]=r[a]}),i=this&&this.__exportStar||function(e,r){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(r,a)||t(r,e,a)};Object.defineProperty(r,"__esModule",{value:!0}),i(a(226),r),i(a(806),r),i(a(106),r),i(a(15),r),i(a(888),r),i(a(435),r),i(a(170),r)},435:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isNumber=void 0,r.isNumber=function(e){return RegExp(/\d/,"gi").test(e)}},170:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.padTrimValue=void 0,r.padTrimValue=function(e,r,a){if(void 0===r&&(r="."),void 0===a||""===e||void 0===e)return e;if(!e.match(/\d/g))return"";var t=e.split(r),i=t[0],n=t[1];if(0===a)return i;var o=n||"";if(o.length<a)for(;o.length<a;)o+="0";else o=o.slice(0,a);return""+i+r+o}},231:(e,r,a)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.parseAbbrValue=r.abbrValue=void 0;var t=a(857);r.abbrValue=function(e,r,a){if(void 0===r&&(r="."),void 0===a&&(a=10),e>999){var t=(""+e).length,i=Math.pow,n=i(10,a);return t-=t%3,(Math.round(e*n/i(10,t))/n+" kMGTPE"[t/3]).replace(".",r)}return String(e)};var i={k:1e3,m:1e6,b:1e9};r.parseAbbrValue=function(e,r){void 0===r&&(r=".");var a=new RegExp("(\\d+("+t.escapeRegExp(r)+"\\d+)?)([kmb])$","i"),n=e.match(a);if(n){var o=n[1],u=n[3],l=i[u.toLowerCase()];return Number(o.replace(r,"."))*l}}},512:(e,r,a)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.removeInvalidChars=void 0;var t=a(857);r.removeInvalidChars=function(e,r){var a=t.escapeRegExp(r.join("")),i=new RegExp("[^\\d"+a+"]","gi");return e.replace(i,"")}},566:(e,r,a)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.removeSeparators=void 0;var t=a(857);r.removeSeparators=function(e,r){void 0===r&&(r=",");var a=new RegExp(t.escapeRegExp(r),"g");return e.replace(a,"")}},22:function(e,r,a){var t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.formatValue=void 0;var i=t(a(660));r.default=i.default;var n=a(106);Object.defineProperty(r,"formatValue",{enumerable:!0,get:function(){return n.formatValue}})},297:e=>{e.exports=require("react")}},r={},a=function a(t){var i=r[t];if(void 0!==i)return i.exports;var n=r[t]={exports:{}};return e[t].call(n.exports,n,n.exports,a),n.exports}(22);module.exports=a})(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-currency-input-field", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"description": "React <input/> component for formatting currency and numbers.", | ||
@@ -13,3 +13,3 @@ "files": [ | ||
"build": "rm -rf dist && tsc && NODE_ENV='production' webpack --config-name=prod --mode=production", | ||
"start": "NODE_ENV='development' webpack-dev-server --config-name=dev --mode=development --hot", | ||
"start": "NODE_ENV='development' webpack serve --config-name=dev --mode=development --hot", | ||
"test": "jest --coverage", | ||
@@ -46,4 +46,4 @@ "test-ci": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --coverage", | ||
"devDependencies": { | ||
"@commitlint/cli": "^9.1.1", | ||
"@commitlint/config-conventional": "^9.1.1", | ||
"@commitlint/cli": "^12.0.1", | ||
"@commitlint/config-conventional": "^12.0.1", | ||
"@semantic-release/changelog": "^5.0.1", | ||
@@ -55,31 +55,31 @@ "@semantic-release/git": "^9.0.0", | ||
"@testing-library/user-event": "^12.7.1", | ||
"@types/jest": "^26.0.9", | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"@typescript-eslint/eslint-plugin": "^3.9.0", | ||
"@typescript-eslint/parser": "^3.9.0", | ||
"@types/jest": "^26.0.21", | ||
"@types/react": "^17.0.3", | ||
"@types/react-dom": "^17.0.3", | ||
"@typescript-eslint/eslint-plugin": "^4.19.0", | ||
"@typescript-eslint/parser": "^4.19.0", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"codecov": "^3.7.2", | ||
"codecov": "^3.8.1", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.6.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.6", | ||
"eslint": "^7.22.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-react": "^7.23.1", | ||
"full-icu": "^1.3.1", | ||
"gh-pages": "^3.1.0", | ||
"html-webpack-plugin": "^4.3.0", | ||
"html-webpack-plugin": "^5.3.1", | ||
"husky": "^4.2.5", | ||
"jest": "^26.4.0", | ||
"lint-staged": "^10.2.11", | ||
"prettier": "^2.0.5", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.4", | ||
"prettier": "^2.2.1", | ||
"react": "^17.0.0", | ||
"react-dom": "17.0.1", | ||
"react-hot-loader": "^4.13.0", | ||
"semantic-release": "^17.1.1", | ||
"source-map-loader": "^1.0.1", | ||
"ts-jest": "^26.5.1", | ||
"typescript": "^3.9.7", | ||
"webpack": "^4.44.1", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0" | ||
"semantic-release": "^17.4.2", | ||
"source-map-loader": "^2.0.1", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^4.2.3", | ||
"webpack": "^5.28.0", | ||
"webpack-cli": "^4.5.0", | ||
"webpack-dev-server": "^3.11.2" | ||
}, | ||
@@ -86,0 +86,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94949
290