'use client';
import{__rest as e}from"tslib";import l,{useState as t,useRef as r}from"react";import{twMerge as o}from"tailwind-merge";import{BaseColors as i}from"../../../lib/constants.js";import{colorClassNames as a}from"../../../lib/colorClassNames.js";import{borderRadius as s,border as n,boxShadow as m}from"../../../lib/shape.js";import{sizing as c}from"../../../lib/sizing.js";import{spacing as d}from"../../../lib/spacing.js";import{fontSize as g,fontWeight as p}from"../../../lib/font.js";import{colorPalette as u,DEFAULT_COLOR as f}from"../../../lib/theme.js";import{getColorClassNames as h,mergeRefs as x,makeClassName as b}from"../../../lib/utils.js";import j from"../../../assets/ExclamationFilledIcon.js";import{hasValue as w,getSelectButtonColors as N}from"../selectUtils.js";const C=b("TextInput"),R=l.forwardRef(((b,R)=>{const{type:y="text",placeholder:E="Type...",icon:v,error:I=!1,errorMessage:T,disabled:B=!1,className:F}=b,L=e(b,["type","placeholder","icon","error","errorMessage","disabled","className"]),[M,k]=t(!1),X=v,z=r(null),O=w(b.value||b.defaultValue),U=e=>{var l,t;!1===e?null===(l=z.current)||void 0===l||l.blur():null===(t=z.current)||void 0===t||t.focus(),k(e)};return l.createElement(l.Fragment,null,l.createElement("div",{className:o(C("root"),"relative w-full flex items-center min-w-[10rem] focus:outline-none focus:ring-2",N(O,B,I),h(i.Blue,u.lightRing).focusRingColor,M&&o("ring-2",h(i.Blue,u.ring).ringColor),s.md.all,n.sm.all,m.sm,F),onClick:()=>{B||U(!0)},onFocus:()=>{U(!0)},onBlur:()=>{U(!1)}},X?l.createElement(X,{className:o(C("icon"),"shrink-0",c.lg.height,c.lg.width,h(f,u.lightText).textColor,d.xl.marginLeft),"aria-hidden":"true"}):null,l.createElement("input",Object.assign({ref:x([R,z]),type:y,className:o(C("input"),"w-full focus:outline-none focus:ring-0",h("transparent").bgColor,X?d.lg.paddingLeft:d.twoXl.paddingLeft,I?d.lg.paddingRight:d.twoXl.paddingRight,d.sm.paddingY,g.sm,p.md,n.none.all,B?"placeholder:text-gray-400":"placeholder:text-gray-500"),placeholder:E,disabled:B},L)),I?l.createElement(j,{className:o(C("errorIcon"),d.xl.marginRight,c.lg.height,c.lg.width,a[i.Rose][u.text].textColor),"aria-hidden":"true"}):null),T?l.createElement("p",{className:o(C("errorMessage"),"text-sm",a[i.Rose][u.text].textColor)},T):null)}));R.displayName="TextInput";export{R as default};
