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