rharuow-ds
Version:
Modern React Design System with 8 components: Button, Input (with password support), Textarea, Select, AsyncSelect, MultiSelect, MultiAsyncSelect, and RadioGroup. Full React Hook Form integration, Tailwind CSS styling, and CSS Variables for theme customiz
23 lines (22 loc) • 30.8 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ce=require("react"),q=require("react-hook-form");function pe(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const l=pe(ce);var ne={exports:{}},te={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var oe;function ye(){if(oe)return te;oe=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(i,h,j){var E=null;if(j!==void 0&&(E=""+j),h.key!==void 0&&(E=""+h.key),"key"in h){j={};for(var I in h)I!=="key"&&(j[I]=h[I])}else j=h;return h=j.ref,{$$typeof:e,type:i,key:E,ref:h!==void 0?h:null,props:j}}return te.Fragment=n,te.jsx=s,te.jsxs=s,te}var re={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var le;function we(){return le||(le=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===M?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case c:return"Fragment";case k:return"Profiler";case C:return"StrictMode";case y:return"Suspense";case L:return"SuspenseList";case V:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case f:return"Portal";case O:return(t.displayName||"Context")+".Provider";case u:return(t._context.displayName||"Context")+".Consumer";case A:var o=t.render;return t=t.displayName,t||(t=o.displayName||o.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Y:return o=t.displayName||null,o!==null?o:e(t.type)||"Memo";case S:o=t._payload,t=t._init;try{return e(t(o))}catch{}}return null}function n(t){return""+t}function s(t){try{n(t);var o=!1}catch{o=!0}if(o){o=console;var R=o.error,W=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return R.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",W),n(t)}}function i(t){if(t===c)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===S)return"<...>";try{var o=e(t);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function h(){var t=D.A;return t===null?null:t.getOwner()}function j(){return Error("react-stack-top-frame")}function E(t){if(b.call(t,"key")){var o=Object.getOwnPropertyDescriptor(t,"key").get;if(o&&o.isReactWarning)return!1}return t.key!==void 0}function I(t,o){function R(){B||(B=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",o))}R.isReactWarning=!0,Object.defineProperty(t,"key",{get:R,configurable:!0})}function g(){var t=e(this.type);return P[t]||(P[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function T(t,o,R,W,G,$,J,ee){return R=$.ref,t={$$typeof:p,type:t,key:o,props:$,_owner:G},(R!==void 0?R:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:g}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function _(t,o,R,W,G,$,J,ee){var F=o.children;if(F!==void 0)if(W)if(a(F)){for(W=0;W<F.length;W++)v(F[W]);Object.freeze&&Object.freeze(F)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else v(F);if(b.call(o,"key")){F=e(t);var X=Object.keys(o).filter(function(w){return w!=="key"});W=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",K[F+W]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,W,F,X,F),K[F+W]=!0)}if(F=null,R!==void 0&&(s(R),F=""+R),E(o)&&(s(o.key),F=""+o.key),"key"in o){R={};for(var Z in o)Z!=="key"&&(R[Z]=o[Z])}else R=o;return F&&I(R,typeof t=="function"?t.displayName||t.name||"Unknown":t),T(t,F,$,G,h(),R,J,ee)}function v(t){typeof t=="object"&&t!==null&&t.$$typeof===p&&t._store&&(t._store.validated=1)}var N=ce,p=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),O=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),D=N.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,a=Array.isArray,d=console.createTask?console.createTask:function(){return null};N={"react-stack-bottom-frame":function(t){return t()}};var B,P={},z=N["react-stack-bottom-frame"].bind(N,j)(),Q=d(i(j)),K={};re.Fragment=c,re.jsx=function(t,o,R,W,G){var $=1e4>D.recentlyCreatedOwnerStacks++;return _(t,o,R,!1,W,G,$?Error("react-stack-top-frame"):z,$?d(i(t)):Q)},re.jsxs=function(t,o,R,W,G){var $=1e4>D.recentlyCreatedOwnerStacks++;return _(t,o,R,!0,W,G,$?Error("react-stack-top-frame"):z,$?d(i(t)):Q)}}()),re}var ie;function je(){return ie||(ie=1,process.env.NODE_ENV==="production"?ne.exports=ye():ne.exports=we()),ne.exports}var r=je();function ue(e){var n,s,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var h=e.length;for(n=0;n<h;n++)e[n]&&(s=ue(e[n]))&&(i&&(i+=" "),i+=s)}else for(s in e)e[s]&&(i&&(i+=" "),i+=s);return i}function Ne(){for(var e,n,s=0,i="",h=arguments.length;s<h;s++)(e=arguments[s])&&(n=ue(e))&&(i&&(i+=" "),i+=n);return i}function m(...e){return Ne(...e)}const Ce=({children:e,variant:n="default",className:s="",...i})=>{const h="px-4 py-2 rounded font-medium transition",j={default:"bg-[var(--primary,#2563eb)] text-[var(--primary-text,#fff)] hover:bg-[var(--primary-hover,#1d4ed8)]",outline:"border border-[var(--primary,#2563eb)] text-[var(--primary,#2563eb)] bg-white hover:bg-[var(--primary-hover,#e0e7ff)]",secondary:"bg-[var(--secondary,#fbbf24)] text-[var(--secondary-text,#222)] hover:bg-[var(--secondary-hover,#f59e42)]"};return r.jsx("button",{className:m(h,j[n],s),...i,children:e})},de=l.forwardRef(({name:e,className:n,type:s="text",label:i,onFocus:h,onBlur:j,Icon:E,iconClassName:I,iconAction:g,containerClassName:T,..._},v)=>{var D,b,a;const[N,p]=l.useState(!1),[f,c]=l.useState(!1),C=q.useFormContext(),k=C==null?void 0:C.control,u=C==null?void 0:C.register,O=k&&e?q.useWatch({control:k,name:e}):void 0,A=_.value??O??"",y=(a=(b=(D=C==null?void 0:C.formState)==null?void 0:D.errors)==null?void 0:b[e])==null?void 0:a.message,L=N||!!A,Y=s==="password"?f?"text":"password":s,S=()=>r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z",fill:"currentColor"})}),V=()=>r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z",fill:"currentColor"})}),M=()=>{c(!f)};return r.jsxs("div",{className:m("relative",T),children:[r.jsx("input",{id:_.id||e,type:Y,className:m("peer flex h-12 w-full border border-[var(--primary,#2563eb)] rounded-md bg-[var(--input-bg,#fff)] text-[var(--input-text,#222)] px-3 pt-6 pb-2 text-sm placeholder-transparent transition focus:outline-none focus:border-[var(--primary,#2563eb)] disabled:cursor-not-allowed disabled:opacity-50",s==="password"||E?"pr-12":"",n),onFocus:d=>{p(!0),h&&h(d)},...C&&e?(()=>{const d=u(e),B=d.onBlur;return{...d,ref:P=>{typeof v=="function"?v(P):v&&(v.current=P),d.ref&&d.ref(P)},onBlur:P=>{p(!1),j&&j(P),B&&B(P)}}})():{ref:v,onBlur:d=>{p(!1),j&&j(d)}},..._}),i&&r.jsx("label",{htmlFor:_.id||e,className:m("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",L?"top-0 scale-90 -translate-y-1 text-xs text-[var(--primary,#2563eb)] p-1 rounded-full bg-white":"top-3 scale-100 translate-y-0.5"),children:i}),s==="password"&&r.jsx("button",{type:"button",className:"absolute top-1/2 right-3 -translate-y-1/2 text-gray-400 hover:text-[var(--primary,#2563eb)] transition-colors duration-200 focus:outline-none focus:text-[var(--primary,#2563eb)]",onClick:M,"aria-label":f?"Esconder senha":"Mostrar senha",tabIndex:-1,children:f?r.jsx(V,{}):r.jsx(S,{})}),E&&s!=="password"&&r.jsx("div",{className:m("absolute top-1/2 right-3 -translate-y-1/2 text-gray-400 cursor-pointer hover:text-[var(--primary,#2563eb)] transition-colors duration-200",I),onClick:g,children:r.jsx(E,{})}),y&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:y})]})});de.displayName="Input";const fe=l.forwardRef(({name:e,label:n,options:s,className:i,containerClassName:h,isClearable:j,onFocus:E,onBlur:I,...g},T)=>{var S,V,M,D;const[_,v]=l.useState(!1),[N,p]=l.useState(!1),f=l.useRef(null),c=q.useFormContext(),C=c==null?void 0:c.control,k=C&&e?q.useWatch({control:C,name:e}):void 0,u=g.value??k??"",O=(M=(V=(S=c==null?void 0:c.formState)==null?void 0:S.errors)==null?void 0:V[e])==null?void 0:M.message,A=_||!!u;l.useEffect(()=>{const b=a=>{f.current&&!f.current.contains(a.target)&&(p(!1),v(!1))};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b)}},[]);const y=()=>{p(b=>!b),v(!0)},L=b=>{v(!0),E&&E(b)},Y=b=>{I&&I(b)};return r.jsxs("div",{className:m("relative",h),ref:f,children:[r.jsxs("div",{id:g.id||e,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":N,className:m("peer flex items-center h-12 w-full border border-[var(--primary,#2563eb)] rounded-md bg-[var(--input-bg,#fff)] text-[var(--input-text,#222)] px-3 py-3 text-sm transition focus:outline-none focus:border-[var(--primary,#2563eb)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",i),onClick:y,onFocus:L,onBlur:Y,ref:T,children:[r.jsx("span",{className:m("block truncate",!u&&"text-gray-400"),children:((D=s.find(b=>b.value===u))==null?void 0:D.label)||!n&&"Selecione..."}),j&&u&&r.jsx("button",{type:"button",tabIndex:-1,"aria-label":"Limpar seleção",className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",onClick:b=>{if(b.stopPropagation(),c&&e&&c.setValue(e,""),g.onChange){const a={target:{value:""}};g.onChange(a)}p(!1),v(!1)},children:"✕"})]}),n&&r.jsx("label",{htmlFor:g.id||e,className:m("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",A?"top-0 scale-90 -translate-y-1 text-xs text-[var(--primary,#2563eb)] p-1 rounded-full bg-white":"top-3 scale-100 translate-y-0.5"),children:n}),r.jsx("div",{className:m("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",N?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:N?"9.5rem":"0",overflowY:s.length>3?"auto":"hidden"},children:s.map(b=>r.jsx("div",{className:m("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm",u===b.value&&"bg-blue-100"),onMouseDown:()=>{if(c&&e&&c.setValue(e,b.value),g.onChange){const a={target:{value:b.value}};g.onChange(a)}v(!0)},children:b.label},b.value))}),O&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:O})]})});fe.displayName="Select";const xe=l.forwardRef(({name:e,className:n,label:s,onFocus:i,onBlur:h,Icon:j,iconClassName:E,iconAction:I,containerClassName:g,rows:T=4,..._},v)=>{var y,L,Y;const[N,p]=l.useState(!1),f=q.useFormContext(),c=f==null?void 0:f.control,C=f==null?void 0:f.register,k=c&&e?q.useWatch({control:c,name:e}):void 0,u=_.value??k??"",O=(Y=(L=(y=f==null?void 0:f.formState)==null?void 0:y.errors)==null?void 0:L[e])==null?void 0:Y.message,A=N||!!u;return r.jsxs("div",{className:m("relative",g),children:[r.jsx("textarea",{id:_.id||e,rows:T,className:m("peer flex min-h-[80px] w-full border border-[var(--primary,#2563eb)] rounded-md bg-[var(--input-bg,#fff)] text-[var(--input-text,#222)] px-3 pt-6 pb-2 text-sm placeholder-transparent transition focus:outline-none focus:border-[var(--primary,#2563eb)] disabled:cursor-not-allowed disabled:opacity-50 resize-vertical",j?"pr-12":"",n),onFocus:S=>{p(!0),i&&i(S)},...f&&e?(()=>{const S=C(e),V=S.onBlur;return{...S,ref:M=>{typeof v=="function"?v(M):v&&(v.current=M),S.ref&&S.ref(M)},onBlur:M=>{p(!1),h&&h(M),V&&V(M)}}})():{ref:v,onBlur:S=>{p(!1),h&&h(S)}},..._}),s&&r.jsx("label",{htmlFor:_.id||e,className:m("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",A?"top-0 scale-90 -translate-y-1 text-xs text-[var(--primary,#2563eb)] p-1 rounded-full bg-white":"top-3 scale-100 translate-y-0.5"),children:s}),j&&r.jsx("div",{className:m("absolute top-3 right-3 text-gray-400 cursor-pointer hover:text-[var(--primary,#2563eb)] transition-colors duration-200",E),onClick:I,children:r.jsx(j,{})}),O&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:O})]})});xe.displayName="Textarea";const me=l.forwardRef(({name:e,label:n,loadOptions:s,className:i,containerClassName:h,isClearable:j,defaultOptions:E=!1,loadingMessage:I="Carregando...",noOptionsMessage:g="Nenhuma opção encontrada",searchable:T=!1,debounceMs:_=300,onFocus:v,onBlur:N,...p},f)=>{var F,X,Z;const[c,C]=l.useState(!1),[k,u]=l.useState(!1),[O,A]=l.useState([]),[y,L]=l.useState(!1),[Y,S]=l.useState(""),[V,M]=l.useState(""),D=l.useRef(null),b=l.useRef(null),a=q.useFormContext(),d=a==null?void 0:a.control,B=d&&e?q.useWatch({control:d,name:e}):void 0,P=p.value??B??"",z=(Z=(X=(F=a==null?void 0:a.formState)==null?void 0:F.errors)==null?void 0:X[e])==null?void 0:Z.message,Q=c||!!P;l.useEffect(()=>{const w=setTimeout(()=>{M(Y)},_);return()=>clearTimeout(w)},[Y,_]),l.useEffect(()=>{(k||E&&O.length===0)&&K(T?V:void 0)},[V,k]),l.useEffect(()=>{E===!0?K():Array.isArray(E)&&A(E)},[]);const K=async w=>{try{L(!0);const H=await s(w);A(H)}catch(H){console.error("Error loading options:",H),A([])}finally{L(!1)}};l.useEffect(()=>{const w=H=>{D.current&&!D.current.contains(H.target)&&(u(!1),C(!1),S(""))};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[]);const t=()=>{k||(u(!0),C(!0),T&&b.current&&setTimeout(()=>{var w;return(w=b.current)==null?void 0:w.focus()},0))},o=w=>{C(!0),v&&v(w)},R=w=>{N&&N(w)},W=w=>{S(w.target.value)},G=w=>{if(a&&e&&a.setValue(e,w),p.onChange){const H={target:{value:w}};p.onChange(H)}u(!1),C(!1),S("")},$=w=>{if(w.stopPropagation(),a&&e&&a.setValue(e,""),p.onChange){const H={target:{value:""}};p.onChange(H)}u(!1),C(!1),S("")},J=O.find(w=>w.value===P),ee=T&&k?Y:(J==null?void 0:J.label)||"";return r.jsxs("div",{className:m("relative",h),ref:D,children:[r.jsxs("div",{id:p.id||e,tabIndex:T?-1:0,role:"button","aria-haspopup":"listbox","aria-expanded":k,className:m("peer flex items-center h-12 w-full border border-[var(--primary,#2563eb)] rounded-md bg-[var(--input-bg,#fff)] text-[var(--input-text,#222)] px-3 py-3 text-sm transition focus:outline-none focus:border-[var(--primary,#2563eb)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",i),onClick:t,onFocus:T?void 0:o,onBlur:T?void 0:R,ref:f,children:[T?r.jsx("input",{ref:b,type:"text",value:ee,onChange:W,onFocus:o,onBlur:R,placeholder:n?"":"Selecione...",className:m("w-full bg-transparent border-none outline-none text-sm",!P&&!Y&&"text-gray-400")}):r.jsx("span",{className:m("block truncate",!P&&"text-gray-400"),children:(J==null?void 0:J.label)||!n&&"Selecione..."}),y&&r.jsx("div",{className:"absolute right-8 top-1/2 -translate-y-1/2",children:r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--primary,#2563eb)]"})}),j&&P&&!y&&r.jsx("button",{type:"button",tabIndex:-1,"aria-label":"Limpar seleção",className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",onClick:$,children:"✕"})]}),n&&r.jsx("label",{htmlFor:p.id||e,className:m("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",Q?"top-0 scale-90 -translate-y-1 text-xs text-[var(--primary,#2563eb)] p-1 rounded-full bg-white":"top-3 scale-100 translate-y-0.5"),children:n}),r.jsx("div",{className:m("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",k?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:k?"9.5rem":"0",overflowY:O.length>3?"auto":"hidden"},children:y?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:I}):O.length===0?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:g}):O.map(w=>r.jsx("div",{className:m("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm",P===w.value&&"bg-blue-100"),onMouseDown:()=>G(w.value),children:w.label},w.value))}),z&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:z})]})});me.displayName="AsyncSelect";const he=l.forwardRef(({name:e,label:n,options:s,className:i,containerClassName:h,isClearable:j,onFocus:E,onBlur:I,...g},T)=>{var M,D,b;const[_,v]=l.useState(!1),[N,p]=l.useState(!1),f=l.useRef(null),c=q.useFormContext(),C=c==null?void 0:c.control,k=C&&e?q.useWatch({control:C,name:e}):void 0,u=g.value??k??[],O=(b=(D=(M=c==null?void 0:c.formState)==null?void 0:M.errors)==null?void 0:D[e])==null?void 0:b.message,A=_||u&&u.length>0;l.useEffect(()=>{const a=d=>{f.current&&!f.current.contains(d.target)&&(p(!1),v(!1))};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a)}},[]);const y=()=>{p(a=>!a),v(!0)},L=a=>{v(!0),E&&E(a)},Y=a=>{I&&I(a)},S=a=>{var B;let d;u.includes(a)?d=u.filter(P=>P!==a):d=[...u,a],c&&e&&c.setValue(e,d),g.onChange&&((B=g.onChange)==null||B.call(g,{target:{value:d}})),v(!0)},V=a=>{var d;a.stopPropagation(),c&&e&&c.setValue(e,[]),g.onChange&&((d=g.onChange)==null||d.call(g,{target:{value:[]}})),p(!1),v(!1)};return r.jsxs("div",{className:m("relative",h),ref:f,children:[r.jsxs("div",{id:g.id||e,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":N,className:m("peer flex items-center h-12 w-full border border-[var(--primary,#2563eb)] rounded-md bg-[var(--input-bg,#fff)] text-[var(--input-text,#222)] px-3 py-3 text-sm transition focus:outline-none focus:border-[var(--primary,#2563eb)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",i),onClick:y,onFocus:L,onBlur:Y,ref:T,children:[r.jsx("div",{className:"flex flex-nowrap gap-1 items-center min-h-[1.5rem] w-full overflow-x-auto",style:{scrollbarWidth:"none"},children:u&&u.length>0?s.filter(a=>u.includes(a.value)).map(a=>r.jsxs("span",{className:"flex items-center border border-blue-200 bg-blue-50 text-blue-700 rounded-2xl px-3 py-1 text-xs shadow-sm mr-1 gap-2",style:{maxWidth:"140px"},children:[r.jsx("span",{className:"truncate",title:a.label,children:a.label}),r.jsx("button",{type:"button",className:"ml-1 text-[var(--primary,#2563eb)] hover:text-red-500 focus:outline-none w-4 h-4 flex items-center justify-center rounded-full transition-colors duration-150","aria-label":`Remover ${a.label}`,tabIndex:-1,onClick:d=>{d.stopPropagation();const B=u.filter(P=>P!==a.value);c&&e&&c.setValue(e,B),g.onChange&&g.onChange({target:{value:B}})},children:r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M3 3L9 9M9 3L3 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]},a.value)):!n&&r.jsx("span",{className:"text-gray-400 text-sm",children:"Selecione..."})}),j&&u&&u.length>0&&r.jsx("button",{type:"button",tabIndex:-1,"aria-label":"Limpar seleção",className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",onClick:V,children:"✕"})]}),n&&r.jsx("label",{htmlFor:g.id||e,className:m("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",A?"top-0 scale-90 -translate-y-1 text-xs text-[var(--primary,#2563eb)] p-1 rounded-full bg-white":"top-3 scale-100 translate-y-0.5"),children:n}),r.jsx("div",{className:m("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",N?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:N?"9.5rem":"0",overflowY:s.length>3?"auto":"hidden"},children:s.map(a=>r.jsxs("div",{className:m("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm flex items-center gap-2",u.includes(a.value)&&"bg-blue-100 font-semibold"),onMouseDown:()=>S(a.value),children:[r.jsx("input",{type:"checkbox",checked:u.includes(a.value),readOnly:!0,className:"accent-blue-500"}),a.label]},a.value))}),O&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:O})]})});he.displayName="MultiSelect";const be=l.forwardRef(({name:e,label:n,loadOptions:s,className:i,containerClassName:h,isClearable:j,defaultOptions:E=!1,loadingMessage:I="Carregando...",noOptionsMessage:g="Nenhuma opção encontrada",searchable:T=!1,debounceMs:_=300,maxSelectedDisplay:v=3,onFocus:N,onBlur:p,...f},c)=>{var w,H,se;const[C,k]=l.useState(!1),[u,O]=l.useState(!1),[A,y]=l.useState([]),[L,Y]=l.useState(!1),[S,V]=l.useState(""),[M,D]=l.useState(""),b=l.useRef(null),a=l.useRef(null),d=q.useFormContext(),B=d==null?void 0:d.control,P=B&&e?q.useWatch({control:B,name:e}):void 0,z=f.value??P??[],Q=(se=(H=(w=d==null?void 0:d.formState)==null?void 0:w.errors)==null?void 0:H[e])==null?void 0:se.message,K=C||z&&z.length>0;l.useEffect(()=>{const x=setTimeout(()=>{D(S)},_);return()=>clearTimeout(x)},[S,_]),l.useEffect(()=>{(u||E&&A.length===0)&&t(T?M:void 0)},[M,u]),l.useEffect(()=>{E===!0?t():Array.isArray(E)&&y(E)},[]);const t=async x=>{try{Y(!0);const U=await s(x);y(U)}catch(U){console.error("Error loading options:",U),y([])}finally{Y(!1)}};l.useEffect(()=>{const x=U=>{b.current&&!b.current.contains(U.target)&&(O(!1),k(!1),V(""))};return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const o=()=>{u||(O(!0),k(!0),T&&a.current&&setTimeout(()=>{var x;return(x=a.current)==null?void 0:x.focus()},0))},R=x=>{k(!0),N&&N(x)},W=x=>{p&&p(x)},G=x=>{V(x.target.value)},$=x=>{let U;z.includes(x)?U=z.filter(ae=>ae!==x):U=[...z,x],d&&e&&d.setValue(e,U),f.onChange&&f.onChange({target:{value:U}}),k(!0)},J=(x,U)=>{U.stopPropagation();const ae=z.filter(ge=>ge!==x);d&&e&&d.setValue(e,ae),f.onChange&&f.onChange({target:{value:ae}})},ee=x=>{x.stopPropagation(),d&&e&&d.setValue(e,[]),f.onChange&&f.onChange({target:{value:[]}}),O(!1),k(!1),V("")},F=A.filter(x=>z.includes(x.value)),X=F.slice(0,v),Z=F.length-v;return r.jsxs("div",{className:m("relative",h),ref:b,children:[r.jsxs("div",{id:f.id||e,tabIndex:T?-1:0,role:"button","aria-haspopup":"listbox","aria-expanded":u,className:m("peer flex items-center min-h-12 w-full border border-[var(--primary,#2563eb)] rounded-md bg-[var(--input-bg,#fff)] text-[var(--input-text,#222)] px-3 py-2 text-sm transition focus:outline-none focus:border-[var(--primary,#2563eb)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",i),onClick:o,onFocus:T?void 0:R,onBlur:T?void 0:W,ref:c,children:[r.jsxs("div",{className:"flex flex-wrap gap-1 items-center min-h-[1.5rem] w-full",children:[X.map(x=>r.jsxs("span",{className:"flex items-center border border-blue-200 bg-blue-50 text-blue-700 rounded-2xl px-3 py-1 text-xs shadow-sm gap-2",style:{maxWidth:"140px"},children:[r.jsx("span",{className:"truncate",title:x.label,children:x.label}),r.jsx("button",{type:"button",className:"ml-1 text-[var(--primary,#2563eb)] hover:text-red-500 focus:outline-none w-4 h-4 flex items-center justify-center rounded-full transition-colors duration-150","aria-label":`Remover ${x.label}`,tabIndex:-1,onClick:U=>J(x.value,U),children:r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{d:"M3 3L9 9M9 3L3 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]},x.value)),Z>0&&r.jsxs("span",{className:"flex items-center border border-gray-200 bg-gray-100 text-gray-600 rounded-2xl px-3 py-1 text-xs",children:["+",Z," mais"]}),T?r.jsx("input",{ref:a,type:"text",value:S,onChange:G,onFocus:R,onBlur:W,placeholder:z.length===0&&!n?"Selecione...":"",className:"flex-1 min-w-[120px] bg-transparent border-none outline-none text-sm"}):z.length===0&&!n&&r.jsx("span",{className:"text-gray-400 text-sm",children:"Selecione..."})]}),L&&r.jsx("div",{className:"absolute right-8 top-1/2 -translate-y-1/2",children:r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--primary,#2563eb)]"})}),j&&z&&z.length>0&&!L&&r.jsx("button",{type:"button",tabIndex:-1,"aria-label":"Limpar seleção",className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",onClick:ee,children:"✕"})]}),n&&r.jsx("label",{htmlFor:f.id||e,className:m("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",K?"top-0 scale-90 -translate-y-1 text-xs text-[var(--primary,#2563eb)] p-1 rounded-full bg-white":"top-3 scale-100 translate-y-0.5"),children:n}),r.jsx("div",{className:m("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",u?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:u?"9.5rem":"0",overflowY:A.length>3?"auto":"hidden"},children:L?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:I}):A.length===0?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:g}):A.map(x=>r.jsxs("div",{className:m("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm flex items-center gap-2",z.includes(x.value)&&"bg-blue-100 font-semibold"),onMouseDown:()=>$(x.value),children:[r.jsx("input",{type:"checkbox",checked:z.includes(x.value),readOnly:!0,className:"accent-blue-500"}),x.label]},x.value))}),Q&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:Q})]})});be.displayName="MultiAsyncSelect";const Ee={sm:"h-10 text-sm px-3",md:"h-12 text-base px-4",lg:"h-16 text-lg px-6"},ve=l.forwardRef(({name:e,label:n,options:s,className:i,containerClassName:h,optionClassName:j,direction:E="row",size:I="md",onFocus:g,onBlur:T,..._},v)=>{var u,O,A;const N=q.useFormContext(),p=N==null?void 0:N.control,f=p&&e?q.useWatch({control:p,name:e}):void 0,c=_.value??f??"",C=(A=(O=(u=N==null?void 0:N.formState)==null?void 0:u.errors)==null?void 0:O[e])==null?void 0:A.message,k=y=>{N&&e&&N.setValue(e,y),_.onChange&&_.onChange({target:{value:y}})};return r.jsxs("div",{className:m("relative",h),ref:v,children:[n&&r.jsx("label",{htmlFor:e,className:m("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm transition-all duration-200","top-0 scale-90 -translate-y-1 text-xs text-[var(--primary,#2563eb)] p-1 rounded-full bg-white"),children:n}),r.jsx("div",{className:m("flex gap-2 w-full pt-6",E==="row"?"flex-row":"flex-col",i),"aria-label":n,tabIndex:-1,onFocus:g,onBlur:T,children:s.map(y=>r.jsxs("button",{type:"button",className:m("relative flex items-center justify-center border rounded-lg transition-all duration-200 shadow-sm px-4 focus:outline-none focus:ring-2 focus:ring-[var(--primary-hover,#dbeafe)]",Ee[I],c===y.value?"border-[var(--primary,#2563eb)] bg-[var(--primary-hover,#dbeafe)] text-[var(--primary,#2563eb)] ring-2 ring-[var(--primary-hover,#dbeafe)] shadow-md transform scale-[1.02]":"border-gray-200 bg-white text-gray-600 hover:border-[var(--primary,#2563eb)] hover:bg-[var(--primary-hover,#dbeafe)] hover:text-[var(--primary,#2563eb)] hover:shadow-md",j),"aria-pressed":c===y.value,"data-selected":c===y.value,tabIndex:0,onClick:()=>k(y.value),onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),k(y.value))},children:[y.icon&&r.jsx("span",{className:"mr-2 text-lg flex items-center",children:y.icon}),r.jsx("span",{className:"truncate font-medium",children:y.label})]},y.value))}),C&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:C})]})});ve.displayName="RadioGroup";exports.AsyncSelect=me;exports.Button=Ce;exports.Input=de;exports.MultiAsyncSelect=be;exports.MultiSelect=he;exports.RadioGroup=ve;exports.Select=fe;exports.Textarea=xe;