@bikdotai/bik-component-library 0.0.88 → 0.0.89
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.
- package/dist/cjs/components/input/Input.d.ts +6 -2
- package/dist/cjs/components/input/Input.js +1 -1
- package/dist/cjs/components/searchBar/searchBar.d.ts +1 -0
- package/dist/cjs/components/stepper/WorkingStepper.d.ts +1 -0
- package/dist/esm/components/input/Input.d.ts +6 -2
- package/dist/esm/components/input/Input.js +1 -1
- package/dist/esm/components/searchBar/searchBar.d.ts +1 -0
- package/dist/esm/components/stepper/WorkingStepper.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export type InputVariant = 'default' | 'small';
|
|
3
3
|
export type InputStateI = 'invalid' | 'active' | 'read-only' | 'disabled' | 'none';
|
|
4
4
|
export type InputTypeI = 'number' | 'email' | 'text' | 'multiline';
|
|
@@ -40,5 +40,9 @@ export interface InputProps {
|
|
|
40
40
|
onFocus?: () => void;
|
|
41
41
|
isActive?: boolean;
|
|
42
42
|
id?: string;
|
|
43
|
+
onReferenceInit?: (element: HTMLInputElement | HTMLTextAreaElement) => void;
|
|
43
44
|
}
|
|
44
|
-
export declare const Input:
|
|
45
|
+
export declare const Input: {
|
|
46
|
+
(props: InputProps): JSX.Element;
|
|
47
|
+
displayName: string;
|
|
48
|
+
};
|
|
@@ -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("../TypographyStyle.js"),r=require("../../assets/icons/errorInfo.svg.js"),l=require("./context/InputStyleProvider.js"),s=require("./Input.styled.js");const a=e=>e&&"function"==typeof e,o=
|
|
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("../TypographyStyle.js"),r=require("../../assets/icons/errorInfo.svg.js"),l=require("./context/InputStyleProvider.js"),s=require("./Input.styled.js");const a=e=>e&&"function"==typeof e,o=o=>{var u,c,d,v;const{placeholder:x,leftIcon:h,rightIcon:f,labelText:j,maxCharLimit:p,isRequired:g,hintText:y,type:I,state:b,validate:C,variant:S,button:m,suffixText:E,prefixText:O,onChangeText:w,value:q,noErrorHint:H,reset:T}=Object.assign({maxCharLimit:0,type:"text",variant:"default"},o),k=null==h?void 0:h.icon,B=null==f?void 0:f.icon,[A,F]=t.useState(!1),[R,L]=t.useState(!1),[M,D]=t.useState(),P="small"===S?"18px":"22px",z=t.useContext(l.InputStyleContext),[K,W]=t.useState(),_=t.useRef();t.useEffect((()=>{W(q)}),[q]),t.useEffect((()=>{var e;_.current&&(null===(e=o.onReferenceInit)||void 0===e||e.call(o,_.current))}),[_]),t.useEffect((()=>{T&&W("")}),[T]),t.useEffect((()=>{var e;L(!!o.isActive),o.isActive&&(null===(e=_.current)||void 0===e||e.focus())}),[o.isActive]),t.useEffect((()=>{D(o.errorMessage)}),[o.errorMessage]),t.useEffect((()=>{var e;F(!1),("invalid"===o.state||M)&&F(!0),"active"===o.state&&(null===(e=_.current)||void 0===e||e.focus())}),[o.state,M]),t.useEffect((()=>{F(!!M)}),[M]);const N=function(e){if(a(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)}},G=e=>{const t=p||125;w(q||"",e),![8].includes(e.which)&&t>0&&e.target.value.length===t&&e.preventDefault()},J=e=>{const t=e.target.value;if(w(t,e),W(t),!C||!a(C))return;const[n,i]=C(t);F(!n),D(i)},Q=()=>{var t;return e.jsxs(e.Fragment,{children:["multiline"!==I&&e.jsx("input",{id:o.id,style:null!==(t=null==z?void 0:z.input)&&void 0!==t?t:{},ref:_,type:I,value:K,onFocus:()=>(L(!0),void N(o.onFocus)),onBlur:e=>(e=>{var t;L(!1),N(null===(t=o.onBlur)||void 0===t?void 0:t.call(o,e))})(e),placeholder:x||"Enter here",onChange:J,onKeyDown:e=>G(e)}),"multiline"===I&&e.jsx("textarea",{value:K,ref:_,onFocus:()=>L(!0),onBlur:()=>L(!1),placeholder:x||"Enter here",onChange:J,onKeyDown:e=>G(e)})]})};return e.jsxs(s.RootContainer,Object.assign({width:o.width,height:o.height,state:b,type:I,style:null!==(u=null==z?void 0:z.RootContainer)&&void 0!==u?u:{}},{children:[!H&&(!!y||!!M)&&e.jsxs(s.InputFooter,Object.assign({invalid:!!M},{children:[!!M&&e.jsx(r.default,{width:16,height:16}),M||y]})),e.jsxs(s.InputWrapper,Object.assign({variant:S,state:b,width:o.width,isActive:"active"===b||R,isInvalid:A,style:null!==(c=null==z?void 0:z.InputWrapper)&&void 0!==c?c:{}},{children:[!!k&&e.jsx(s.IconHolder,Object.assign({variant:S,iconSize:P,onClick:()=>N(null==h?void 0:h.callback),isLeft:!0,style:null!==(d=null==z?void 0:z.IconHolder)&&void 0!==d?d:{}},{children:e.jsx(k,{})})),!!O&&e.jsx(s.PrefixHolder,Object.assign({variant:S},{children:O})),"default"===S&&e.jsx(s.InputContainer,{children:Q()}),"small"===S&&e.jsx(s.InputContainerSmall,{children:Q()}),!!B&&e.jsx(s.IconHolder,Object.assign({variant:S,iconSize:P,onClick:()=>N(null==f?void 0:f.callback),isLeft:!1},{children:e.jsx(B,{})})),!!E&&e.jsx(s.SuffixHolder,Object.assign({variant:S},{children:E})),m&&m.text&&e.jsx(n.Button,{buttonText:m.text,onClick:()=>N(null==m?void 0:m.onClick)})]})),(!!j||!!p)&&"default"===S&&e.jsxs(s.InputHeader,Object.assign({invalid:A},{children:[e.jsxs(i.BodySecondary,{children:[j,g?e.jsx("span",{children:"*"}):""]}),p>0&&e.jsxs(s.MaxCharStyle,{children:[null===(v=o.value)||void 0===v?void 0:v.length,"/",p]})]}))]}))};o.displayName="Input",exports.Input=o;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export type InputVariant = 'default' | 'small';
|
|
3
3
|
export type InputStateI = 'invalid' | 'active' | 'read-only' | 'disabled' | 'none';
|
|
4
4
|
export type InputTypeI = 'number' | 'email' | 'text' | 'multiline';
|
|
@@ -40,5 +40,9 @@ export interface InputProps {
|
|
|
40
40
|
onFocus?: () => void;
|
|
41
41
|
isActive?: boolean;
|
|
42
42
|
id?: string;
|
|
43
|
+
onReferenceInit?: (element: HTMLInputElement | HTMLTextAreaElement) => void;
|
|
43
44
|
}
|
|
44
|
-
export declare const Input:
|
|
45
|
+
export declare const Input: {
|
|
46
|
+
(props: InputProps): JSX.Element;
|
|
47
|
+
displayName: string;
|
|
48
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as
|
|
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{BodySecondary as c}from"../TypographyStyle.js";import s from"../../assets/icons/errorInfo.svg.js";import{InputStyleContext as u}from"./context/InputStyleProvider.js";import{RootContainer as d,InputFooter as v,InputWrapper as h,IconHolder as p,PrefixHolder as f,InputContainer as g,InputContainerSmall as m,SuffixHolder as x,InputHeader as y,MaxCharStyle as b}from"./Input.styled.js";const j=e=>e&&"function"==typeof e,C=C=>{var I,w,O,T;const{placeholder:k,leftIcon:A,rightIcon:B,labelText:L,maxCharLimit:S,isRequired:D,hintText:E,type:F,state:R,validate:z,variant:H,button:K,suffixText:M,prefixText:q,onChangeText:N,value:P,noErrorHint:W,reset:G}=Object.assign({maxCharLimit:0,type:"text",variant:"default"},C),J=null==A?void 0:A.icon,Q=null==B?void 0:B.icon,[U,V]=i(!1),[X,Y]=i(!1),[Z,$]=i(),_="small"===H?"18px":"22px",ee=l(u),[te,ne]=i(),ie=r();o((()=>{ne(P)}),[P]),o((()=>{var e;ie.current&&(null===(e=C.onReferenceInit)||void 0===e||e.call(C,ie.current))}),[ie]),o((()=>{G&&ne("")}),[G]),o((()=>{var e;Y(!!C.isActive),C.isActive&&(null===(e=ie.current)||void 0===e||e.focus())}),[C.isActive]),o((()=>{$(C.errorMessage)}),[C.errorMessage]),o((()=>{var e;V(!1),("invalid"===C.state||Z)&&V(!0),"active"===C.state&&(null===(e=ie.current)||void 0===e||e.focus())}),[C.state,Z]),o((()=>{V(!!Z)}),[Z]);const le=function(e){if(j(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)}},re=e=>{const t=S||125;N(P||"",e),![8].includes(e.which)&&t>0&&e.target.value.length===t&&e.preventDefault()},oe=e=>{const t=e.target.value;if(N(t,e),ne(t),!z||!j(z))return;const[n,i]=z(t);V(!n),$(i)},ae=()=>{var i;return e(n,{children:["multiline"!==F&&t("input",{id:C.id,style:null!==(i=null==ee?void 0:ee.input)&&void 0!==i?i:{},ref:ie,type:F,value:te,onFocus:()=>(Y(!0),void le(C.onFocus)),onBlur:e=>(e=>{var t;Y(!1),le(null===(t=C.onBlur)||void 0===t?void 0:t.call(C,e))})(e),placeholder:k||"Enter here",onChange:oe,onKeyDown:e=>re(e)}),"multiline"===F&&t("textarea",{value:te,ref:ie,onFocus:()=>Y(!0),onBlur:()=>Y(!1),placeholder:k||"Enter here",onChange:oe,onKeyDown:e=>re(e)})]})};return e(d,Object.assign({width:C.width,height:C.height,state:R,type:F,style:null!==(I=null==ee?void 0:ee.RootContainer)&&void 0!==I?I:{}},{children:[!W&&(!!E||!!Z)&&e(v,Object.assign({invalid:!!Z},{children:[!!Z&&t(s,{width:16,height:16}),Z||E]})),e(h,Object.assign({variant:H,state:R,width:C.width,isActive:"active"===R||X,isInvalid:U,style:null!==(w=null==ee?void 0:ee.InputWrapper)&&void 0!==w?w:{}},{children:[!!J&&t(p,Object.assign({variant:H,iconSize:_,onClick:()=>le(null==A?void 0:A.callback),isLeft:!0,style:null!==(O=null==ee?void 0:ee.IconHolder)&&void 0!==O?O:{}},{children:t(J,{})})),!!q&&t(f,Object.assign({variant:H},{children:q})),"default"===H&&t(g,{children:ae()}),"small"===H&&t(m,{children:ae()}),!!Q&&t(p,Object.assign({variant:H,iconSize:_,onClick:()=>le(null==B?void 0:B.callback),isLeft:!1},{children:t(Q,{})})),!!M&&t(x,Object.assign({variant:H},{children:M})),K&&K.text&&t(a,{buttonText:K.text,onClick:()=>le(null==K?void 0:K.onClick)})]})),(!!L||!!S)&&"default"===H&&e(y,Object.assign({invalid:U},{children:[e(c,{children:[L,D?t("span",{children:"*"}):""]}),S>0&&e(b,{children:[null===(T=C.value)||void 0===T?void 0:T.length,"/",S]})]}))]}))};C.displayName="Input";export{C as Input};
|