@bothub-chat/ui
Version:
Bothub UI Components
2 lines (1 loc) • 1.4 kB
JavaScript
import{__rest as e}from"tslib";import{jsxs as r,jsx as l}from"react/jsx-runtime";import{useState as o,useCallback as s}from"react";import{TextAreaFieldStyled as t,TextAreaFieldLabel as n,TextAreaFieldBlock as i,TextAreaFieldTextArea as d,TextAreaFieldSkeleton as a,TextAreaFieldErrorText as c}from"./styled.js";import{Skeleton as u}from"../skeleton/index.js";const b=b=>{var{className:m,label:f,fullWidth:$=!1,error:h,disabled:g=!1,skeleton:k=!1,glow:p,onFocus:j,onBlur:x,renderTextAreaBlock:B}=b,w=e(b,["className","label","fullWidth","error","disabled","skeleton","glow","onFocus","onBlur","renderTextAreaBlock"]);const[F,y]=o(!1),N=s(e=>{y(!0),null==j||j(e)},[j]),O=s(e=>{y(!1),null==x||x(e)},[x]);return r(t,{$fullWidth:$,$disabled:g,className:m,children:[f&&k&&l(n,{children:l(u,{width:100})}),"string"==typeof f&&!k&&l(n,{children:f}),"string"!=typeof f&&!k&&f,!k&&(B?B({focus:F,error:!!h,disabled:g,skeleton:!1,textarea:Object.assign(Object.assign({},w),{disabled:g,onFocus:N,onBlur:O})}):l(i,{$focus:F,$error:!!h,$disabled:g,$skeleton:!1,$glow:p,children:l(d,Object.assign({},w,{disabled:g,onFocus:N,onBlur:O}))})),k&&l(i,{$focus:!1,$error:!1,$disabled:!1,$skeleton:!0,children:l(a,{})}),h&&l(c,{children:h})]})};export{b as TextAreaField,i as TextAreaFieldBlock,c as TextAreaFieldErrorText,n as TextAreaFieldLabel,a as TextAreaFieldSkeleton,t as TextAreaFieldStyled,d as TextAreaFieldTextArea};