UNPKG

@snowball-tech/fractal

Version:

Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS

3 lines 4.07 kB
'use client'; import{a as t}from"./chunk-PF45VKUC.js";import{e as S}from"./chunk-WJB4GYBF.js";import{c as I}from"./chunk-LYTTDLE2.js";import{a as f}from"./chunk-AOLTZ2WJ.js";import{b as e}from"./chunk-CMFNILWJ.js";import{a as o,b as H}from"./chunk-XYM7TA65.js";import{Label as W}from"@radix-ui/react-label";import{forwardRef as ee,useId as te}from"react";import ae from"react-textarea-autosize";import T from"lodash/fp/isError";import s from"lodash/fp/isFunction";import re from"lodash/fp/isNil";import z from"lodash/fp/isString";import oe from"lodash/fp/omit";import{jsx as i,jsxs as F}from"react/jsx-runtime";var G=ee(({autoFocus:U=!1,defaultValue:N,description:E,disabled:a=!1,error:r,fullWidth:x=!1,icon:d,iconButtonLabel:X,iconDisabled:L,id:j,label:l,labelElement:C,maxRows:M,minRows:A=1,name:D,onChange:P,onHeightChange:B,onIconClick:u,placeholder:J,readOnly:c=!1,required:p=!1,selectOnFocus:K=!0,success:$,value:Q,...h},Y)=>{let R=te(),g=(j??R)||R,Z=T(r)?r.message:r,w=r!==!0&&!!Z,b=$!==!0&&!!$,n=w||r===!0||T(r),y=(b||$===!0)&&!n,O=m=>{s(P)&&P(m,m.target.value)},V=m=>{s(h.onFocus)&&h.onFocus(m),K&&m.target&&m.target.select()},_=a;s(u)&&(_=re(L)?a:L);let v=!a&&!c,q=!!d,k=z(l)?l:I(l);return F("div",{className:H(`${e}-${t}`,"flex w-full max-w-full flex-col gap-1 text-dark",`${e}-${t}--${v?"":"not-"}writable`,a?`${e}-${t}--disabled`:"",c&&!a?"cursor-default":"",x?`${e}-${t}--full-width`:"sm:w-fit",n?`${e}-${t}--with-error`:"",c?`${e}-${t}--readonly`:"",p?`${e}-${t}--required`:"",y?`${e}-${t}--with-success`:"",d?`${e}-${t}--with-icon`:"",s(u)&&d?`${e}-${t}--with-action`:"",h.className),children:[l?i(W,{asChild:!0,className:o(`${e}-${t}__label`,p?`${e}-${t}__label--required after:text-feedback-danger-50 after:content-required`:""),htmlFor:g,children:i(f,{element:C||(z(l)?"label":"div"),children:l})}):!1,F(f,{className:o(`${e}-${t}__wrapper`,"relative w-full",x?"":"sm:w-fit"),element:"div",children:[i(ae,{"aria-label":k,autoFocus:U,className:o(`${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`,a?`${e}-${t}__input--disabled cursor-not-allowed text-disabled`:"text-dark",c&&!a?`${e}-${t}__input--readonly cursor-default`:"",x?`${e}-${t}__input--fullWidth`:"sm:w-unset",n?`${e}-${t}__input--with-error border-error shadow-error`:"",y?`${e}-${t}__input--with-success border-success shadow-success`:"",v&&!n&&!y?"border-normal":"",p?`${e}-${t}--required`:"",q?"pr-6":""),disabled:a,title:k,...N===void 0?{}:{defaultValue:N},id:g,ref:Y,...M===void 0?{}:{maxRows:M},...A===void 0?{}:{minRows:A},name:D||g,placeholder:J,readOnly:c,required:p,value:Q,onChange:O,onFocus:V,...s(B)?{onHeightChange:B}:{},...oe(["className","onFocus"],h)}),q&&F("div",{className:"absolute bottom-one-and-half right-half",children:[s(u)&&i(S,{className:o(`${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:d,iconOnly:!0,label:X,variant:"text",onClick:u}),!s(u)&&i("div",{className:o(`${e}-${t}__icon`,"mr-one-and-half text-grey-50",_||a?`${e}-${t}__icon--disabled cursor-not-allowed !text-grey-70`:""),children:d})]})]}),E&&!w&&!b&&i(f,{className:o(`${e}-${t}__description`,"cursor-default text-dark"),element:"div",variant:"caption-median",children:E}),(w||b)&&i(f,{className:o(`${e}-${t}__message ${e}-${t}__message--${n?"error":"success"}`,"cursor-default text-dark"),element:"div",variant:"caption-median",children:n?T(r)?r.message:r:$})]})});G.displayName="Textarea";var ge=G;export{G as a,ge as b}; //# sourceMappingURL=chunk-UABYD3KH.js.map