@snowball-tech/fractal
Version:
Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS
3 lines • 3.86 kB
JavaScript
'use client';
import{a as t}from"./chunk-PF45VKUC.js";import{f as H}from"./chunk-2FP3EMO2.js";import{a as c}from"./chunk-HTOKQYVM.js";import{b as e}from"./chunk-CMFNILWJ.js";import{a,b as B}from"./chunk-XYM7TA65.js";import{Label as Q}from"@radix-ui/react-label";import{forwardRef as Y,useId as Z}from"react";import O from"react-textarea-autosize";import p from"lodash/fp/isEmpty";import o from"lodash/fp/isFunction";import V from"lodash/fp/isNil";import W from"lodash/fp/omit";import{jsx as s,jsxs as T}from"react/jsx-runtime";var I=Y(({autoFocus:z=!1,defaultValue:F,description:N,disabled:r=!1,error:h,fullWidth:_=!1,icon:n,iconButtonLabel:S,iconDisabled:E,id:G,label:L,maxRows:M,minRows:A=1,name:U,onChange:P,onHeightChange:R,onIconClick:d,placeholder:X,readOnly:m=!1,required:u=!1,selectOnFocus:j=!0,success:x,value:C,...f},D)=>{let q=Z(),g=(G??q)||q,w=!p(h),l=w||h===!0,b=!p(x),y=(b||x===!0)&&!l,J=i=>{o(P)&&P(i,i.target.value)},K=i=>{o(f.onFocus)&&f.onFocus(i),j&&i.target&&i.target.select()},$=r;o(d)&&($=V(E)?r:E);let v=!r&&!m,k=!!n;return T("div",{className:B(`${e}-${t}`,"flex w-full max-w-full flex-col gap-1 text-dark",`${e}-${t}--${v?"":"not-"}writable`,r?`${e}-${t}--disabled`:"",m&&!r?"cursor-default":"",_?`${e}-${t}--full-width`:"sm:w-fit",l?`${e}-${t}--with-error`:"",m?`${e}-${t}--readonly`:"",u?`${e}-${t}--required`:"",y?`${e}-${t}--with-success`:"",n?`${e}-${t}--with-icon`:"",o(d)&&n?`${e}-${t}--with-action`:"",f.className),children:[p(L)?!1:s(Q,{asChild:!0,className:a(`${e}-${t}__label`,u?`${e}-${t}__label--required after:text-feedback-danger-50 after:content-required`:""),htmlFor:g,children:s(c,{element:"label",children:L})}),T(c,{className:a(`${e}-${t}__wrapper`,"relative w-full",_?"":"sm:w-fit"),element:"div",children:[s(O,{autoFocus:z,className:a(`${e}-${t}__input`,"box-border min-h-6 w-full max-w-full resize-none rounded-sm border-1 px-2 py-[calc(theme(spacing.1)+theme(spacing.half)+theme(spacing.quarter))] text-left leading-[inherit] outline-none transition-border-color duration-300 ease-out placeholder:text-placeholder focus:cursor-text",v?`${e}-${t}__input--writable bg-white hover:border-normal hover:shadow-hover focus:border-primary focus:shadow-primary [&:is([data-state="open"])]:bg-primary [&:is([data-state="open"])]:shadow-primary`:`${e}-${t}__input--not-writable border-disabled bg-disabled-light`,r?`${e}-${t}__input--disabled cursor-not-allowed text-disabled`:"text-dark",m&&!r?`${e}-${t}__input--readonly cursor-default`:"",_?`${e}-${t}__input--fullWidth`:"sm:w-unset",l?`${e}-${t}__input--with-error border-error shadow-error`:"",y?`${e}-${t}__input--with-success border-success shadow-success`:"",v&&!l&&!y?"border-normal":"",u?`${e}-${t}--required`:"",k?"pr-6":""),disabled:r,...F===void 0?{}:{defaultValue:F},id:g,ref:D,...M===void 0?{}:{maxRows:M},...A===void 0?{}:{minRows:A},name:U||g,placeholder:X,readOnly:m,required:u,value:C,onChange:J,onFocus:K,...o(R)?{onHeightChange:R}:{},...W(["className","onFocus"],f)}),k&&T("div",{className:"absolute bottom-one-and-half right-half",children:[o(d)&&s(H,{className:a(`${e}-${t}__action`,"mb-half mr-one-and-half text-grey-50",$?`${e}-${t}__action--disabled cursor-not-allowed !text-grey-70`:"hover:!text-dark"),disabled:$,icon:n,iconOnly:!0,label:S,variant:"text",onClick:d}),!o(d)&&s("div",{className:a(`${e}-${t}__icon`,"mr-one-and-half text-grey-50",$||r?`${e}-${t}__icon--disabled cursor-not-allowed !text-grey-70`:""),children:n})]})]}),!p(N)&&!w&&!b&&s(c,{className:a(`${e}-${t}__description`,"cursor-default text-dark"),element:"div",variant:"caption-median",children:N}),(w||b)&&s(c,{className:a(`${e}-${t}__message ${e}-${t}__message--${l?"error":"success"}`,"cursor-default text-dark"),element:"div",variant:"caption-median",children:l?h:x})]})});I.displayName="Textarea";var ue=I;export{I as a,ue as b};
//# sourceMappingURL=chunk-44YJ4Z2G.js.map