rharuow-ds 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rharuow-ds.cjs.js +22 -1
- package/dist/rharuow-ds.es.js +1125 -769
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/rharuow-ds.cjs.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("react"),V=require("react-hook-form");function ie(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const e=ie(Z);function ee(t){var r,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var h=t.length;for(r=0;r<h;r++)t[r]&&(n=ee(t[r]))&&(s&&(s+=" "),s+=n)}else for(n in t)t[n]&&(s&&(s+=" "),s+=n);return s}function ue(){for(var t,r,n=0,s="",h=arguments.length;n<h;n++)(t=arguments[n])&&(r=ee(t))&&(s&&(s+=" "),s+=r);return s}function o(...t){return ue(...t)}const de=({children:t,variant:r="default",className:n="",...s})=>{const h="px-4 py-2 rounded font-medium transition",S={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 Z.createElement("button",{className:o(h,S[r],n),...s},t)},te=e.forwardRef(({name:t,className:r,type:n="text",label:s,onFocus:h,onBlur:S,Icon:y,iconClassName:M,iconAction:v,containerClassName:p,...w},i)=>{const[k,m]=e.useState(!1),[u,f]=e.useState(!1),E=V.useFormContext(),b=E?.control,a=E?.register,g=b&&t?V.useWatch({control:b,name:t}):void 0,O=w.value??g??"",N=E?.formState?.errors?.[t]?.message,W=k||!!O,F=n==="password"?u?"text":"password":n,d=()=>e.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("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"})),z=()=>e.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("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"})),l=()=>{f(!u)};return e.createElement("div",{className:o("relative",p)},e.createElement("input",{id:w.id||t,type:F,className:o("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",n==="password"||y?"pr-12":"",r),onFocus:C=>{m(!0),h&&h(C)},...E&&t?(()=>{const C=a(t),I=C.onBlur;return{...C,ref:R=>{typeof i=="function"?i(R):i&&(i.current=R),C.ref&&C.ref(R)},onBlur:R=>{m(!1),S&&S(R),I&&I(R)}}})():{ref:i,onBlur:C=>{m(!1),S&&S(C)}},...w}),s&&e.createElement("label",{htmlFor:w.id||t,className:o("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",W?"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")},s),n==="password"&&e.createElement("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:l,"aria-label":u?"Esconder senha":"Mostrar senha",tabIndex:-1},u?e.createElement(z,null):e.createElement(d,null)),y&&n!=="password"&&e.createElement("div",{className:o("absolute top-1/2 right-3 -translate-y-1/2 text-gray-400 cursor-pointer hover:text-[var(--primary,#2563eb)] transition-colors duration-200",M),onClick:v},e.createElement(y,null)),N&&e.createElement("span",{className:"text-red-500 text-xs mt-1 block"},N))});te.displayName="Input";const ae=e.forwardRef(({name:t,label:r,options:n,className:s,containerClassName:h,isClearable:S,onFocus:y,onBlur:M,...v},p)=>{const[w,i]=e.useState(!1),[k,m]=e.useState(!1),u=e.useRef(null),f=V.useFormContext(),E=f?.control,b=E&&t?V.useWatch({control:E,name:t}):void 0,a=v.value??b??"",g=f?.formState?.errors?.[t]?.message,O=w||!!a;e.useEffect(()=>{const d=z=>{u.current&&!u.current.contains(z.target)&&(m(!1),i(!1))};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[]);const N=()=>{m(d=>!d),i(!0)},W=d=>{i(!0),y&&y(d)},F=d=>{M&&M(d)};return e.createElement("div",{className:o("relative",h),ref:u},e.createElement("div",{id:v.id||t,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":k,className:o("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",s),onClick:N,onFocus:W,onBlur:F,ref:p},e.createElement("span",{className:o("block truncate",!a&&"text-gray-400")},n.find(d=>d.value===a)?.label||!r&&"Selecione..."),S&&a&&e.createElement("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:d=>{if(d.stopPropagation(),f&&t&&f.setValue(t,""),v.onChange){const z={target:{value:""}};v.onChange(z)}m(!1),i(!1)}},"✕")),r&&e.createElement("label",{htmlFor:v.id||t,className:o("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",O?"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")},r),e.createElement("div",{className:o("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:n.length>3?"auto":"hidden"}},n.map(d=>e.createElement("div",{key:d.value,className:o("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm",a===d.value&&"bg-blue-100"),onMouseDown:()=>{if(f&&t&&f.setValue(t,d.value),v.onChange){const z={target:{value:d.value}};v.onChange(z)}i(!0)}},d.label))),g&&e.createElement("span",{className:"text-red-500 text-xs mt-1 block"},g))});ae.displayName="Select";const re=e.forwardRef(({name:t,className:r,label:n,onFocus:s,onBlur:h,Icon:S,iconClassName:y,iconAction:M,containerClassName:v,rows:p=4,...w},i)=>{const[k,m]=e.useState(!1),u=V.useFormContext(),f=u?.control,E=u?.register,b=f&&t?V.useWatch({control:f,name:t}):void 0,a=w.value??b??"",g=u?.formState?.errors?.[t]?.message,O=k||!!a;return e.createElement("div",{className:o("relative",v)},e.createElement("textarea",{id:w.id||t,rows:p,className:o("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",S?"pr-12":"",r),onFocus:N=>{m(!0),s&&s(N)},...u&&t?(()=>{const N=E(t),W=N.onBlur;return{...N,ref:F=>{typeof i=="function"?i(F):i&&(i.current=F),N.ref&&N.ref(F)},onBlur:F=>{m(!1),h&&h(F),W&&W(F)}}})():{ref:i,onBlur:N=>{m(!1),h&&h(N)}},...w}),n&&e.createElement("label",{htmlFor:w.id||t,className:o("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",O?"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")},n),S&&e.createElement("div",{className:o("absolute top-3 right-3 text-gray-400 cursor-pointer hover:text-[var(--primary,#2563eb)] transition-colors duration-200",y),onClick:M},e.createElement(S,null)),g&&e.createElement("span",{className:"text-red-500 text-xs mt-1 block"},g))});re.displayName="Textarea";const ne=e.forwardRef(({name:t,label:r,loadOptions:n,className:s,containerClassName:h,isClearable:S,defaultOptions:y=!1,loadingMessage:M="Carregando...",noOptionsMessage:v="Nenhuma opção encontrada",searchable:p=!1,debounceMs:w=300,onFocus:i,onBlur:k,...m},u)=>{const[f,E]=e.useState(!1),[b,a]=e.useState(!1),[g,O]=e.useState([]),[N,W]=e.useState(!1),[F,d]=e.useState(""),[z,l]=e.useState(""),C=e.useRef(null),I=e.useRef(null),R=V.useFormContext(),A=R?.control,D=A&&t?V.useWatch({control:A,name:t}):void 0,P=m.value??D??"",L=R?.formState?.errors?.[t]?.message,H=f||!!P;e.useEffect(()=>{const x=setTimeout(()=>{l(F)},w);return()=>clearTimeout(x)},[F,w]),e.useEffect(()=>{(b||y&&g.length===0)&&Y(p?z:void 0)},[z,b]),e.useEffect(()=>{y===!0?Y():Array.isArray(y)&&O(y)},[]);const Y=async x=>{try{W(!0);const B=await n(x);O(B)}catch(B){console.error("Error loading options:",B),O([])}finally{W(!1)}};e.useEffect(()=>{const x=B=>{C.current&&!C.current.contains(B.target)&&(a(!1),E(!1),d(""))};return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const G=()=>{b||(a(!0),E(!0),p&&I.current&&setTimeout(()=>I.current?.focus(),0))},_=x=>{E(!0),i&&i(x)},j=x=>{k&&k(x)},q=x=>{d(x.target.value)},J=x=>{if(R&&t&&R.setValue(t,x),m.onChange){const B={target:{value:x}};m.onChange(B)}a(!1),E(!1),d("")},Q=x=>{if(x.stopPropagation(),R&&t&&R.setValue(t,""),m.onChange){const B={target:{value:""}};m.onChange(B)}a(!1),E(!1),d("")},$=g.find(x=>x.value===P),U=p&&b?F:$?.label||"";return e.createElement("div",{className:o("relative",h),ref:C},e.createElement("div",{id:m.id||t,tabIndex:p?-1:0,role:"button","aria-haspopup":"listbox","aria-expanded":b,className:o("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",s),onClick:G,onFocus:p?void 0:_,onBlur:p?void 0:j,ref:u},p?e.createElement("input",{ref:I,type:"text",value:U,onChange:q,onFocus:_,onBlur:j,placeholder:r?"":"Selecione...",className:o("w-full bg-transparent border-none outline-none text-sm",!P&&!F&&"text-gray-400")}):e.createElement("span",{className:o("block truncate",!P&&"text-gray-400")},$?.label||!r&&"Selecione..."),N&&e.createElement("div",{className:"absolute right-8 top-1/2 -translate-y-1/2"},e.createElement("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--primary,#2563eb)]"})),S&&P&&!N&&e.createElement("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:Q},"✕")),r&&e.createElement("label",{htmlFor:m.id||t,className:o("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",H?"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")},r),e.createElement("div",{className:o("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",b?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:b?"9.5rem":"0",overflowY:g.length>3?"auto":"hidden"}},N?e.createElement("div",{className:"px-3 py-2 text-sm text-gray-500 text-center"},M):g.length===0?e.createElement("div",{className:"px-3 py-2 text-sm text-gray-500 text-center"},v):g.map(x=>e.createElement("div",{key:x.value,className:o("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm",P===x.value&&"bg-blue-100"),onMouseDown:()=>J(x.value)},x.label))),L&&e.createElement("span",{className:"text-red-500 text-xs mt-1 block"},L))});ne.displayName="AsyncSelect";const oe=e.forwardRef(({name:t,label:r,options:n,className:s,containerClassName:h,isClearable:S,onFocus:y,onBlur:M,...v},p)=>{const[w,i]=e.useState(!1),[k,m]=e.useState(!1),u=e.useRef(null),f=V.useFormContext(),E=f?.control,b=E&&t?V.useWatch({control:E,name:t}):void 0,a=v.value??b??[],g=f?.formState?.errors?.[t]?.message,O=w||a&&a.length>0;e.useEffect(()=>{const l=C=>{u.current&&!u.current.contains(C.target)&&(m(!1),i(!1))};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[]);const N=()=>{m(l=>!l),i(!0)},W=l=>{i(!0),y&&y(l)},F=l=>{M&&M(l)},d=l=>{let C;a.includes(l)?C=a.filter(I=>I!==l):C=[...a,l],f&&t&&f.setValue(t,C),v.onChange&&v.onChange?.({target:{value:C}}),i(!0)},z=l=>{l.stopPropagation(),f&&t&&f.setValue(t,[]),v.onChange&&v.onChange?.({target:{value:[]}}),m(!1),i(!1)};return e.createElement("div",{className:o("relative",h),ref:u},e.createElement("div",{id:v.id||t,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":k,className:o("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",s),onClick:N,onFocus:W,onBlur:F,ref:p},e.createElement("div",{className:"flex flex-nowrap gap-1 items-center min-h-[1.5rem] w-full overflow-x-auto",style:{scrollbarWidth:"none"}},a&&a.length>0?n.filter(l=>a.includes(l.value)).map(l=>e.createElement("span",{key:l.value,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"}},e.createElement("span",{className:"truncate",title:l.label},l.label),e.createElement("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 ${l.label}`,tabIndex:-1,onClick:C=>{C.stopPropagation();const I=a.filter(R=>R!==l.value);f&&t&&f.setValue(t,I),v.onChange&&v.onChange({target:{value:I}})}},e.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M3 3L9 9M9 3L3 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}))))):!r&&e.createElement("span",{className:"text-gray-400 text-sm"},"Selecione...")),S&&a&&a.length>0&&e.createElement("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:z},"✕")),r&&e.createElement("label",{htmlFor:v.id||t,className:o("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",O?"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")},r),e.createElement("div",{className:o("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:n.length>3?"auto":"hidden"}},n.map(l=>e.createElement("div",{key:l.value,className:o("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm flex items-center gap-2",a.includes(l.value)&&"bg-blue-100 font-semibold"),onMouseDown:()=>d(l.value)},e.createElement("input",{type:"checkbox",checked:a.includes(l.value),readOnly:!0,className:"accent-blue-500"}),l.label))),g&&e.createElement("span",{className:"text-red-500 text-xs mt-1 block"},g))});oe.displayName="MultiSelect";const le=e.forwardRef(({name:t,label:r,loadOptions:n,className:s,containerClassName:h,isClearable:S,defaultOptions:y=!1,loadingMessage:M="Carregando...",noOptionsMessage:v="Nenhuma opção encontrada",searchable:p=!1,debounceMs:w=300,maxSelectedDisplay:i=3,onFocus:k,onBlur:m,...u},f)=>{const[E,b]=e.useState(!1),[a,g]=e.useState(!1),[O,N]=e.useState([]),[W,F]=e.useState(!1),[d,z]=e.useState(""),[l,C]=e.useState(""),I=e.useRef(null),R=e.useRef(null),A=V.useFormContext(),D=A?.control,P=D&&t?V.useWatch({control:D,name:t}):void 0,L=u.value??P??[],H=A?.formState?.errors?.[t]?.message,Y=E||L&&L.length>0;e.useEffect(()=>{const c=setTimeout(()=>{C(d)},w);return()=>clearTimeout(c)},[d,w]),e.useEffect(()=>{(a||y&&O.length===0)&&G(p?l:void 0)},[l,a]),e.useEffect(()=>{y===!0?G():Array.isArray(y)&&N(y)},[]);const G=async c=>{try{F(!0);const T=await n(c);N(T)}catch(T){console.error("Error loading options:",T),N([])}finally{F(!1)}};e.useEffect(()=>{const c=T=>{I.current&&!I.current.contains(T.target)&&(g(!1),b(!1),z(""))};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]);const _=()=>{a||(g(!0),b(!0),p&&R.current&&setTimeout(()=>R.current?.focus(),0))},j=c=>{b(!0),k&&k(c)},q=c=>{m&&m(c)},J=c=>{z(c.target.value)},Q=c=>{let T;L.includes(c)?T=L.filter(K=>K!==c):T=[...L,c],A&&t&&A.setValue(t,T),u.onChange&&u.onChange({target:{value:T}}),b(!0)},$=(c,T)=>{T.stopPropagation();const K=L.filter(ce=>ce!==c);A&&t&&A.setValue(t,K),u.onChange&&u.onChange({target:{value:K}})},U=c=>{c.stopPropagation(),A&&t&&A.setValue(t,[]),u.onChange&&u.onChange({target:{value:[]}}),g(!1),b(!1),z("")},x=O.filter(c=>L.includes(c.value)),B=x.slice(0,i),X=x.length-i;return e.createElement("div",{className:o("relative",h),ref:I},e.createElement("div",{id:u.id||t,tabIndex:p?-1:0,role:"button","aria-haspopup":"listbox","aria-expanded":a,className:o("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",s),onClick:_,onFocus:p?void 0:j,onBlur:p?void 0:q,ref:f},e.createElement("div",{className:"flex flex-wrap gap-1 items-center min-h-[1.5rem] w-full"},B.map(c=>e.createElement("span",{key:c.value,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"}},e.createElement("span",{className:"truncate",title:c.label},c.label),e.createElement("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 ${c.label}`,tabIndex:-1,onClick:T=>$(c.value,T)},e.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M3 3L9 9M9 3L3 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}))))),X>0&&e.createElement("span",{className:"flex items-center border border-gray-200 bg-gray-100 text-gray-600 rounded-2xl px-3 py-1 text-xs"},"+",X," mais"),p?e.createElement("input",{ref:R,type:"text",value:d,onChange:J,onFocus:j,onBlur:q,placeholder:L.length===0&&!r?"Selecione...":"",className:"flex-1 min-w-[120px] bg-transparent border-none outline-none text-sm"}):L.length===0&&!r&&e.createElement("span",{className:"text-gray-400 text-sm"},"Selecione...")),W&&e.createElement("div",{className:"absolute right-8 top-1/2 -translate-y-1/2"},e.createElement("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--primary,#2563eb)]"})),S&&L&&L.length>0&&!W&&e.createElement("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:U},"✕")),r&&e.createElement("label",{htmlFor:u.id||t,className:o("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",Y?"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")},r),e.createElement("div",{className:o("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",a?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:a?"9.5rem":"0",overflowY:O.length>3?"auto":"hidden"}},W?e.createElement("div",{className:"px-3 py-2 text-sm text-gray-500 text-center"},M):O.length===0?e.createElement("div",{className:"px-3 py-2 text-sm text-gray-500 text-center"},v):O.map(c=>e.createElement("div",{key:c.value,className:o("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm flex items-center gap-2",L.includes(c.value)&&"bg-blue-100 font-semibold"),onMouseDown:()=>Q(c.value)},e.createElement("input",{type:"checkbox",checked:L.includes(c.value),readOnly:!0,className:"accent-blue-500"}),c.label))),H&&e.createElement("span",{className:"text-red-500 text-xs mt-1 block"},H))});le.displayName="MultiAsyncSelect";const me={sm:"h-10 text-sm px-3",md:"h-12 text-base px-4",lg:"h-16 text-lg px-6"},se=e.forwardRef(({name:t,label:r,options:n,className:s,containerClassName:h,optionClassName:S,direction:y="row",size:M="md",onFocus:v,onBlur:p,...w},i)=>{const k=V.useFormContext(),m=k?.control,u=m&&t?V.useWatch({control:m,name:t}):void 0,f=w.value??u??"",E=k?.formState?.errors?.[t]?.message,b=a=>{k&&t&&k.setValue(t,a),w.onChange&&w.onChange({target:{value:a}})};return e.createElement("div",{className:o("relative",h),ref:i},r&&e.createElement("label",{htmlFor:t,className:o("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")},r),e.createElement("div",{className:o("flex gap-2 w-full pt-6",y==="row"?"flex-row":"flex-col",s),"aria-label":r,tabIndex:-1,onFocus:v,onBlur:p},n.map(a=>e.createElement("button",{key:a.value,type:"button",className:o("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)]",me[M],f===a.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",S),"aria-pressed":f===a.value,"data-selected":f===a.value,tabIndex:0,onClick:()=>b(a.value),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),b(a.value))}},a.icon&&e.createElement("span",{className:"mr-2 text-lg flex items-center"},a.icon),e.createElement("span",{className:"truncate font-medium"},a.label)))),E&&e.createElement("span",{className:"text-red-500 text-xs mt-1 block"},E))});se.displayName="RadioGroup";exports.AsyncSelect=ne;exports.Button=de;exports.Input=te;exports.MultiAsyncSelect=le;exports.MultiSelect=oe;exports.RadioGroup=se;exports.Select=ae;exports.Textarea=re;
|
|
1
|
+
"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={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/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={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/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:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%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;
|