@bikdotai/bik-component-library 0.0.169 → 0.0.170
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("../button/Button.js"),i=require("./Input-helper.js"),r=require("../TypographyStyle.js"),l=require("../../assets/icons/errorInfo.svg.js"),s=require("./context/InputStyleProvider.js"),a=require("./Input.styled.js");const o=o=>{var u,c,d,v;const{placeholder:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("../button/Button.js"),i=require("./Input-helper.js"),r=require("../TypographyStyle.js"),l=require("../../assets/icons/errorInfo.svg.js"),s=require("./context/InputStyleProvider.js"),a=require("./Input.styled.js");const o=o=>{var u,c,d,v,h;const{placeholder:x,leftIcon:p,rightIcon:f,labelText:j,maxCharLimit:g,isRequired:y,hintText:I,type:b,state:C,validate:m,variant:S,button:E,suffixText:O,prefixText:q,onChangeText:w,value:F,noErrorHint:H,reset:T,rangeValidation:k}=Object.assign({maxCharLimit:0,type:"text",variant:"default"},o),B=null==p?void 0:p.icon,A=null==f?void 0:f.icon,[R,z]=t.useState(!1),[L,M]=t.useState(!1),[D,P]=t.useState(),K="small"===S?"18px":"22px",W=t.useContext(s.InputStyleContext),[_,N]=t.useState(),V=t.useRef();t.useEffect((()=>{N(F)}),[F]),t.useEffect((()=>{var e;V.current&&(null===(e=o.onReferenceInit)||void 0===e||e.call(o,V.current))}),[V]),t.useEffect((()=>{T&&N("")}),[T]),t.useEffect((()=>{var e;M(!!o.isActive),o.isActive&&(null===(e=V.current)||void 0===e||e.focus())}),[o.isActive]),t.useEffect((()=>{P(o.errorMessage)}),[o.errorMessage]),t.useEffect((()=>{var e;z(!1),("invalid"===o.state||D)&&z(!0),"active"===o.state&&(null===(e=V.current)||void 0===e||e.focus())}),[o.state,D]),t.useEffect((()=>{z(!!D)}),[D]);const G=function(e){if(i.isFunction(e)){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];e(...n)}},J=e=>{const t=g||("zip"===b?6:60);w(F||"",e),![8].includes(e.which)&&t>0&&e.target.value.length===t&&e.preventDefault()},Q=e=>{const t=e.target.value;w(t,e),N(t);const n=m||i.validateInput;if(!n||!i.isFunction(n))return;const[r,l]=n(t,b,k);z(!r),P(l)},U=()=>{var t;return e.jsxs(e.Fragment,{children:["multiline"!==b&&e.jsx("input",{id:o.id,style:null!==(t=null==W?void 0:W.input)&&void 0!==t?t:{},ref:V,type:["phonenumber","zip","number"].includes(b)?"number":b,value:_,onFocus:()=>(M(!0),void G(o.onFocus)),onBlur:e=>(e=>{var t;M(!1),G(null===(t=o.onBlur)||void 0===t?void 0:t.call(o,e))})(e),placeholder:x||"Enter here",onChange:Q,onKeyDown:e=>J(e)}),"multiline"===b&&e.jsx("textarea",{value:_,ref:V,onFocus:()=>M(!0),onBlur:()=>M(!1),placeholder:x||"Enter here",onChange:Q,onKeyDown:e=>J(e)})]})};return e.jsxs(a.RootContainer,Object.assign({width:o.width,height:o.height,state:C,type:b,style:null!==(u=null==W?void 0:W.RootContainer)&&void 0!==u?u:{}},{children:[!H&&(!!I||!!D)&&e.jsxs(a.InputFooter,Object.assign({invalid:!!D},{children:[!!D&&e.jsx(l.default,{width:16,height:16}),D||I]})),e.jsxs(a.InputWrapper,Object.assign({variant:S,state:C,width:o.width,isActive:"active"===C||L,isInvalid:R,style:null!==(c=null==W?void 0:W.InputWrapper)&&void 0!==c?c:{}},{children:[!!B&&e.jsx(a.IconHolder,Object.assign({variant:S,iconSize:K,onClick:()=>G(null==p?void 0:p.callback),isLeft:!0,style:null!==(d=null==W?void 0:W.IconHolder)&&void 0!==d?d:{}},{children:e.jsx(B,{})})),!!q&&e.jsx(a.PrefixHolder,Object.assign({variant:S},{children:q})),"default"===S&&e.jsx(a.InputContainer,{children:U()}),"small"===S&&e.jsx(a.InputContainerSmall,{children:U()}),!!A&&e.jsx(a.IconHolder,Object.assign({variant:S,iconSize:K,onClick:()=>G(null==f?void 0:f.callback),isLeft:!1},{children:e.jsx(A,{})})),!!O&&e.jsx(a.SuffixHolder,Object.assign({variant:S},{children:O})),E&&E.text&&e.jsx(n.Button,{buttonText:E.text,onClick:()=>G(null==E?void 0:E.onClick)})]})),(!!j||!!g)&&e.jsxs(a.InputHeader,Object.assign({invalid:R},{children:[e.jsxs(r.BodySecondary,{children:[j,y?e.jsx("span",{children:"*"}):""]}),g>0&&e.jsxs(a.MaxCharStyle,{children:[null!==(h=null===(v=o.value)||void 0===v?void 0:v.length)&&void 0!==h?h:0,"/",g]})]}))]}))};o.displayName="Input",exports.Input=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{useState as i,useContext as l,useRef as r,useEffect as o}from"react";import{Button as a}from"../button/Button.js";import{isFunction as c,validateInput as s}from"./Input-helper.js";import{BodySecondary as u}from"../TypographyStyle.js";import d from"../../assets/icons/errorInfo.svg.js";import{InputStyleContext as v}from"./context/InputStyleProvider.js";import{RootContainer as h,InputFooter as p,InputWrapper as m,IconHolder as f,PrefixHolder as g,InputContainer as x,InputContainerSmall as b,SuffixHolder as y,InputHeader as j,MaxCharStyle as I}from"./Input.styled.js";const C=C=>{var w,O,T,k;const{placeholder:
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{useState as i,useContext as l,useRef as r,useEffect as o}from"react";import{Button as a}from"../button/Button.js";import{isFunction as c,validateInput as s}from"./Input-helper.js";import{BodySecondary as u}from"../TypographyStyle.js";import d from"../../assets/icons/errorInfo.svg.js";import{InputStyleContext as v}from"./context/InputStyleProvider.js";import{RootContainer as h,InputFooter as p,InputWrapper as m,IconHolder as f,PrefixHolder as g,InputContainer as x,InputContainerSmall as b,SuffixHolder as y,InputHeader as j,MaxCharStyle as I}from"./Input.styled.js";const C=C=>{var w,O,T,k,A;const{placeholder:z,leftIcon:B,rightIcon:L,labelText:S,maxCharLimit:D,isRequired:E,hintText:F,type:R,state:H,validate:K,variant:M,button:q,suffixText:N,prefixText:P,onChangeText:V,value:W,noErrorHint:G,reset:J,rangeValidation:Q}=Object.assign({maxCharLimit:0,type:"text",variant:"default"},C),U=null==B?void 0:B.icon,X=null==L?void 0:L.icon,[Y,Z]=i(!1),[$,_]=i(!1),[ee,te]=i(),ne="small"===M?"18px":"22px",ie=l(v),[le,re]=i(),oe=r();o((()=>{re(W)}),[W]),o((()=>{var e;oe.current&&(null===(e=C.onReferenceInit)||void 0===e||e.call(C,oe.current))}),[oe]),o((()=>{J&&re("")}),[J]),o((()=>{var e;_(!!C.isActive),C.isActive&&(null===(e=oe.current)||void 0===e||e.focus())}),[C.isActive]),o((()=>{te(C.errorMessage)}),[C.errorMessage]),o((()=>{var e;Z(!1),("invalid"===C.state||ee)&&Z(!0),"active"===C.state&&(null===(e=oe.current)||void 0===e||e.focus())}),[C.state,ee]),o((()=>{Z(!!ee)}),[ee]);const ae=function(e){if(c(e)){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];e(...n)}},ce=e=>{const t=D||("zip"===R?6:60);V(W||"",e),![8].includes(e.which)&&t>0&&e.target.value.length===t&&e.preventDefault()},se=e=>{const t=e.target.value;V(t,e),re(t);const n=K||s;if(!n||!c(n))return;const[i,l]=n(t,R,Q);Z(!i),te(l)},ue=()=>{var i;return e(n,{children:["multiline"!==R&&t("input",{id:C.id,style:null!==(i=null==ie?void 0:ie.input)&&void 0!==i?i:{},ref:oe,type:["phonenumber","zip","number"].includes(R)?"number":R,value:le,onFocus:()=>(_(!0),void ae(C.onFocus)),onBlur:e=>(e=>{var t;_(!1),ae(null===(t=C.onBlur)||void 0===t?void 0:t.call(C,e))})(e),placeholder:z||"Enter here",onChange:se,onKeyDown:e=>ce(e)}),"multiline"===R&&t("textarea",{value:le,ref:oe,onFocus:()=>_(!0),onBlur:()=>_(!1),placeholder:z||"Enter here",onChange:se,onKeyDown:e=>ce(e)})]})};return e(h,Object.assign({width:C.width,height:C.height,state:H,type:R,style:null!==(w=null==ie?void 0:ie.RootContainer)&&void 0!==w?w:{}},{children:[!G&&(!!F||!!ee)&&e(p,Object.assign({invalid:!!ee},{children:[!!ee&&t(d,{width:16,height:16}),ee||F]})),e(m,Object.assign({variant:M,state:H,width:C.width,isActive:"active"===H||$,isInvalid:Y,style:null!==(O=null==ie?void 0:ie.InputWrapper)&&void 0!==O?O:{}},{children:[!!U&&t(f,Object.assign({variant:M,iconSize:ne,onClick:()=>ae(null==B?void 0:B.callback),isLeft:!0,style:null!==(T=null==ie?void 0:ie.IconHolder)&&void 0!==T?T:{}},{children:t(U,{})})),!!P&&t(g,Object.assign({variant:M},{children:P})),"default"===M&&t(x,{children:ue()}),"small"===M&&t(b,{children:ue()}),!!X&&t(f,Object.assign({variant:M,iconSize:ne,onClick:()=>ae(null==L?void 0:L.callback),isLeft:!1},{children:t(X,{})})),!!N&&t(y,Object.assign({variant:M},{children:N})),q&&q.text&&t(a,{buttonText:q.text,onClick:()=>ae(null==q?void 0:q.onClick)})]})),(!!S||!!D)&&e(j,Object.assign({invalid:Y},{children:[e(u,{children:[S,E?t("span",{children:"*"}):""]}),D>0&&e(I,{children:[null!==(A=null===(k=C.value)||void 0===k?void 0:k.length)&&void 0!==A?A:0,"/",D]})]}))]}))};C.displayName="Input";export{C as Input};
|