Number-Cbiv6mKk.js 1.4 KB

1
  1. import{s as d,f as a,ai as R,bu as k,cb as w,bw as O,dE as S,by as z,z as M,D as P}from"./index-DT8qTvyx.js";var V=function(n){d(r,n);function r(){return n!==null&&n.apply(this,arguments)||this}return r.prototype.render=function(){var t=this.props,b=t.placeholder,v=t.kilobitSeparator,s=t.precision,y=t.prefix,o=t.affix,N=t.suffix,u=t.percent,p=t.unitOptions,h=t.className,x=t.style,F=t.classnames,g=t.translate,i=a.createElement("span",{className:"text-muted"},b),e=R(this.props),l="";if(typeof e=="string"&&p&&p.length){var E=k(p).map(function(f){return f.value});l=E.find(function(f){return e.endsWith(f)})||"",l&&(e=e.replace(l,""))}if(typeof e=="number"||typeof e=="string")if(typeof e=="string"&&s&&(e=w(parseFloat(e))),isNaN(e))i=!1;else if(u){e=parseFloat(e)||0;var m=typeof u=="number"?u:0,_=e*100,c=Math.pow(10,m);e=(Math.round(_*c)/c).toFixed(m)+"%",i=a.createElement("span",null,e)}else typeof e=="number"&&s&&(e=O(S(e),".",s)),v&&(e=z(e,s)),i=a.createElement("span",null,e);return i=i?a.createElement(a.Fragment,null,y,i,l,o??N):a.createElement("span",{className:"text-danger"},g("Number.invalid")),a.createElement("span",{className:F("NumberField",h),style:x},i)},r.defaultProps={placeholder:"-",kilobitSeparator:!0},r}(a.Component),D=function(n){d(r,n);function r(){return n!==null&&n.apply(this,arguments)||this}return r=M([P({type:"number"})],r),r}(V);export{V as NumberField,D as NumberFieldRenderer};