@instincthub/react-ui 0.1.47 → 0.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,jsx as r}from"react/jsx-runtime";import{useState as i,useEffect as n}from"react";var t=function(t){var l=t.id,
|
|
1
|
+
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,jsx as r}from"react/jsx-runtime";import{useState as i,useEffect as n}from"react";var t=function(t){var l=t.id,u=t.name,o=t.label,c=t.value,s=t.onChange,d=t.disabled,p=void 0!==d&&d,m=t.readOnly,v=void 0!==m&&m,h=t.placeholder,f=void 0===h?"0.00":h,b=t.min,g=t.max,y=t.required,N=void 0!==y&&y,x=t.currencySymbol,F=void 0===x?"₦":x,q=t.error,B=t.className,O=void 0===B?"":B,S=t.plainDisplay,$=void 0!==S&&S,_=i(!1),j=e(_,2),C=j[0],w=j[1],A=i(""),D=e(A,2),H=D[0],M=D[1],P=i(0),T=e(P,2),W=T[0],k=T[1],z=function(e){if(""===e||null==e)return"";var a,r="";if("string"==typeof e){var i=e.split(".");i.length>1&&(r="."+i[1]),a=parseFloat(e.replace(/,/g,""))}else a=e;if(isNaN(a))return"";var n=a.toString().split(".")[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");if("string"==typeof e&&r)return n+r;if("number"==typeof e){var t=a.toString(),l=t.indexOf(".");return n+(-1!==l?t.substring(l):"")}return n};n(function(){if(null!=c&&""!==c){k(Number(c));var e=z(c);M(e)}else M("")},[c]);if($){var E=z(c||0);return a("p",{className:"ihub-amount-plain ".concat(O||""),children:[F,E||"0.00"]})}var G=""!==H,I="ihub-wrapper".concat(G||C?" ihub-value":"").concat(q?" ihub-is_invalid":"").concat(O?" ".concat(O):"");return a("div",{className:I,children:[r("input",{type:"hidden",name:u,value:W}),a("div",{className:"ihub-amount-input-container",children:[r("span",{className:"ihub-currency-symbol ".concat(G||C?"":"ihub-ghost"),children:F}),r("input",{id:l||u,type:"text",value:H,onChange:function(e){var a=e.target.value;if(/^[\d,.]*$/.test(a)){var r=a.replace(/,/g,"");if(/^[0-9]*\.?[0-9]*$/.test(r)){var i=""===r?0:parseFloat(r);if(i!==W){var n=a;a.endsWith(".")||a.match(/\.\d*$/)||(n=z(r)),M(n),k(i),s&&s(i,u)}}}},onFocus:function(){w(!0)},onBlur:function(){if(w(!1),H){var e=function(e){return e?parseFloat(e.replace(/,/g,"")):0}(H),a=z(e.toFixed(2));M(a),s&&s(e,u)}},disabled:p,readOnly:v,placeholder:G||C?f:"",className:"ihub-input ihub-amount-input",required:N,min:b,max:g,inputMode:"decimal"}),a("label",{htmlFor:l||u,className:"ihub-text-label",children:[o,N&&r("span",{className:"ihub-required",children:"*"})]})]}),q&&r("p",{className:"ihub-error-message",children:q})]})};export{t as default};
|
|
2
2
|
//# sourceMappingURL=InputAmount.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as
|
|
1
|
+
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{useState as a,useRef as n,useEffect as t}from"react";var o=function(o){var l=o.id,c=o.name,u=o.label,d=o.placeholder,s=o.min,b=o.max,m=o.step,v=void 0===m?1:m,h=o.defaultValue,p=o.value,f=o.required,g=void 0!==f&&f,N=o.disabled,F=void 0!==N&&N,S=o.readOnly,y=void 0!==S&&S,x=o.onChange,C=o.onBlur,q=o.className,B=void 0===q?"":q,j=o.error,k=o.note,O=void 0!==p?p.toString():void 0!==h?h.toString():"",_=a(O),w=e(_,2),A=w[0],D=w[1],H=a(!1),I=e(H,2),P=I[0],T=I[1],V=a(""!==O),$=e(V,2),z=$[0],E=$[1],G=n(!1);t(function(){G.current?G.current=!1:void 0!==p?(D(p.toString()),E(!0)):void 0!==h&&(D(h.toString()),E(!0))},[p,h]);var J="ihub-wrapper ".concat(z||P?"ihub-value":""," ").concat(j?"ihub-error":""," ").concat(B);return r("div",{className:"ihub-mb-2 "+J,children:[r("div",{className:"ihub-number-input-container",children:[i("input",{id:l||c,name:c,type:"text",className:"ihub-input ihub-number-input",value:A,onChange:function(e){var r=e.target.value;if((""===r||/^-?\d*\.?\d*$/.test(r))&&(D(r),E(""!==r),x)){G.current=!0;var i=""===r?null:parseFloat(r);x(i)}},onFocus:function(){T(!0)},onBlur:function(e){if(T(!1),""!==A){var r=parseFloat(A);void 0!==s&&r<s?(r=s,D(s.toString())):void 0!==b&&r>b&&(r=b,D(b.toString())),x&&x(r)}C&&C(e)},placeholder:d,disabled:F,readOnly:y,required:g,"aria-invalid":!!j,"aria-describedby":j?"".concat(c,"-error"):void 0}),r("label",{htmlFor:l||c,className:"ihub-text-label",children:[u,g&&i("span",{className:"ihub-required",children:"*"})]}),r("div",{className:"ihub-number-controls",children:[i("button",{type:"button",className:"ihub-number-increment",onClick:function(){if(!F&&!y){var e=(""===A?0:parseFloat(A))+v;void 0!==b&&e>b&&(e=b),D(e.toString()),E(!0),x&&(G.current=!0,x(e))}},disabled:F||y||void 0!==b&&""!==A&&parseFloat(A)>=b,"aria-label":"Increment",children:i("span",{className:"ihub-control-icon",children:"+"})}),i("button",{type:"button",className:"ihub-number-decrement",onClick:function(){if(!F&&!y){var e=(""===A?0:parseFloat(A))-v;void 0!==s&&e<s&&(e=s),D(e.toString()),E(!0),x&&(G.current=!0,x(e))}},disabled:F||y||void 0!==s&&""!==A&&parseFloat(A)<=s,"aria-label":"Decrement",children:i("span",{className:"ihub-control-icon",children:"-"})})]})]}),j&&i("div",{className:"ihub-error-message",id:"".concat(c,"-error"),children:j}),k&&i("p",{className:"ihub-input-notes",id:"".concat(c,"-note"),children:k})]})};export{o as default};
|
|
2
2
|
//# sourceMappingURL=InputNumber.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,objectSpread2 as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as
|
|
1
|
+
import{slicedToArray as e,objectSpread2 as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as l}from"react/jsx-runtime";import{useState as r,useEffect as t}from"react";var n=function(n){var o=n.label,d=n.name,c=n.value,u=void 0===c?"":c,s=n.placeholder,h=void 0===s?"":s,m=n.required,p=void 0!==m&&m,v=n.type,b=void 0===v?"text":v,f=n.maxLength,x=n.disabled,N=void 0!==x&&x,g=n.readOnly,y=void 0!==g&&g,_=n.className,j=void 0===_?"":_,q=n.textTransform,B=n.error,L=n.onChange,T=n.onBlur,C=n.helperText,O=n.note,w=n.id,A=n.activeLabel,F=void 0!==A&&A,H=r(null!=u?u:""),P=e(H,2),S=P[0],k=P[1],z=r(F||!!u),D=e(z,2),E=D[0],G=D[1];t(function(){k(null!=u?u:""),G(F||!!u)},[u,F]);var I={};return q&&(I["data-text-transform"]=q),i("div",a(a({className:"ihub-wrapper ".concat(E?"ihub-value":""," ").concat(B?"ihub-is_invalid":""," ").concat(h?"ihub-has-placeholder":""," ").concat(j)},I),{},{children:[l("input",{type:b,id:w||d,name:d,value:S,className:"ihub-input",placeholder:h,required:p,maxLength:f,disabled:N,readOnly:y,onChange:function(e){G(!!e.target.value),k(e.target.value),L&&L(e)},onBlur:T}),i("label",{htmlFor:w||d,className:"ihub-text-label",children:[o,p&&l("span",{className:"ihub-required",children:"*"})]}),C&&!B&&l("p",{className:"ihub-notes",children:C}),B&&l("p",{className:"ihub-notes ihub-is_invalid",children:B}),O&&l("p",{className:"ihub-input-notes",id:"".concat(w,"-note"),children:O})]}))};export{n as default};
|
|
2
2
|
//# sourceMappingURL=InputText.js.map
|