rharuow-ds 1.0.13 → 1.0.15
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/README.md +65 -23
- package/dist/rharuow-ds.cjs.js +4 -4
- package/dist/rharuow-ds.es.js +581 -502
- package/dist/styles.css +1 -1
- package/dist/types/src/components/Textarea.d.ts +13 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/stories/Textarea.stories.d.ts +8 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -62,20 +62,29 @@ npm install react-hook-form
|
|
|
62
62
|
2. **Use os componentes normalmente**
|
|
63
63
|
|
|
64
64
|
```tsx
|
|
65
|
-
import {
|
|
65
|
+
import {
|
|
66
|
+
Button,
|
|
67
|
+
Input,
|
|
68
|
+
Textarea,
|
|
69
|
+
Select,
|
|
70
|
+
AsyncSelect,
|
|
71
|
+
MultiSelect,
|
|
72
|
+
RadioGroup,
|
|
73
|
+
} from "rharuow-ds";
|
|
66
74
|
|
|
67
75
|
function App() {
|
|
68
76
|
return (
|
|
69
77
|
<div>
|
|
70
78
|
<Input label="E-mail" name="email" type="email" />
|
|
71
79
|
<Input label="Senha" name="password" type="password" />
|
|
72
|
-
<
|
|
73
|
-
|
|
80
|
+
<Textarea label="Comentários" name="comments" rows={4} />
|
|
81
|
+
<Select
|
|
82
|
+
label="País"
|
|
74
83
|
name="country"
|
|
75
84
|
options={[
|
|
76
85
|
{ label: "Brasil", value: "br" },
|
|
77
|
-
{ label: "Estados Unidos", value: "us" }
|
|
78
|
-
]}
|
|
86
|
+
{ label: "Estados Unidos", value: "us" },
|
|
87
|
+
]}
|
|
79
88
|
/>
|
|
80
89
|
<RadioGroup
|
|
81
90
|
label="Tamanho"
|
|
@@ -83,7 +92,7 @@ npm install react-hook-form
|
|
|
83
92
|
options={[
|
|
84
93
|
{ label: "Pequeno", value: "sm" },
|
|
85
94
|
{ label: "Médio", value: "md" },
|
|
86
|
-
{ label: "Grande", value: "lg" }
|
|
95
|
+
{ label: "Grande", value: "lg" },
|
|
87
96
|
]}
|
|
88
97
|
/>
|
|
89
98
|
<Button variant="default">Enviar</Button>
|
|
@@ -96,7 +105,14 @@ npm install react-hook-form
|
|
|
96
105
|
|
|
97
106
|
```tsx
|
|
98
107
|
import { useForm, FormProvider } from "react-hook-form";
|
|
99
|
-
import {
|
|
108
|
+
import {
|
|
109
|
+
Input,
|
|
110
|
+
Textarea,
|
|
111
|
+
Select,
|
|
112
|
+
AsyncSelect,
|
|
113
|
+
MultiAsyncSelect,
|
|
114
|
+
RadioGroup,
|
|
115
|
+
} from "rharuow-ds";
|
|
100
116
|
|
|
101
117
|
function FormExample() {
|
|
102
118
|
const methods = useForm();
|
|
@@ -108,11 +124,11 @@ npm install react-hook-form
|
|
|
108
124
|
{ label: "Argentina", value: "ar" },
|
|
109
125
|
{ label: "Estados Unidos", value: "us" },
|
|
110
126
|
{ label: "Chile", value: "cl" },
|
|
111
|
-
{ label: "Peru", value: "pe" }
|
|
127
|
+
{ label: "Peru", value: "pe" },
|
|
112
128
|
];
|
|
113
|
-
|
|
129
|
+
|
|
114
130
|
if (!search) return countries;
|
|
115
|
-
return countries.filter(c =>
|
|
131
|
+
return countries.filter((c) =>
|
|
116
132
|
c.label.toLowerCase().includes(search.toLowerCase())
|
|
117
133
|
);
|
|
118
134
|
};
|
|
@@ -123,15 +139,16 @@ npm install react-hook-form
|
|
|
123
139
|
<Input label="Nome" name="name" />
|
|
124
140
|
<Input label="E-mail" name="email" type="email" />
|
|
125
141
|
<Input label="Senha" name="password" type="password" />
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
142
|
+
<Textarea label="Observações" name="notes" rows={3} />
|
|
143
|
+
|
|
144
|
+
<AsyncSelect
|
|
145
|
+
label="País"
|
|
129
146
|
name="country"
|
|
130
147
|
loadOptions={loadCountries}
|
|
131
148
|
searchable
|
|
132
149
|
isClearable
|
|
133
150
|
/>
|
|
134
|
-
|
|
151
|
+
|
|
135
152
|
<MultiAsyncSelect
|
|
136
153
|
label="Países favoritos"
|
|
137
154
|
name="favoriteCountries"
|
|
@@ -140,17 +157,17 @@ npm install react-hook-form
|
|
|
140
157
|
isClearable
|
|
141
158
|
maxVisibleItems={2}
|
|
142
159
|
/>
|
|
143
|
-
|
|
160
|
+
|
|
144
161
|
<RadioGroup
|
|
145
162
|
label="Tamanho"
|
|
146
163
|
name="size"
|
|
147
164
|
options={[
|
|
148
165
|
{ label: "Pequeno", value: "sm" },
|
|
149
166
|
{ label: "Médio", value: "md" },
|
|
150
|
-
{ label: "Grande", value: "lg" }
|
|
167
|
+
{ label: "Grande", value: "lg" },
|
|
151
168
|
]}
|
|
152
169
|
/>
|
|
153
|
-
|
|
170
|
+
|
|
154
171
|
<Button type="submit">Enviar</Button>
|
|
155
172
|
</form>
|
|
156
173
|
</FormProvider>
|
|
@@ -163,10 +180,13 @@ npm install react-hook-form
|
|
|
163
180
|
## Componentes Disponíveis
|
|
164
181
|
|
|
165
182
|
### 🎯 **Button**
|
|
183
|
+
|
|
166
184
|
Botão customizável com diferentes variantes e tamanhos.
|
|
167
185
|
|
|
168
186
|
### 📝 **Input**
|
|
187
|
+
|
|
169
188
|
Campo de texto versátil com label flutuante e integração com React Hook Form:
|
|
189
|
+
|
|
170
190
|
- ✅ Label flutuante animada
|
|
171
191
|
- ✅ Suporte a múltiplos tipos (text, email, password, number, tel, url)
|
|
172
192
|
- ✅ Funcionalidade de password com botão mostrar/ocultar
|
|
@@ -174,11 +194,26 @@ Campo de texto versátil com label flutuante e integração com React Hook Form:
|
|
|
174
194
|
- ✅ Estados de erro integrados
|
|
175
195
|
- ✅ Totalmente acessível (ARIA)
|
|
176
196
|
|
|
177
|
-
###
|
|
197
|
+
### � **Textarea**
|
|
198
|
+
|
|
199
|
+
Campo de texto multilinha com as mesmas funcionalidades do Input:
|
|
200
|
+
|
|
201
|
+
- ✅ Label flutuante animada
|
|
202
|
+
- ✅ Altura ajustável (propriedade `rows`)
|
|
203
|
+
- ✅ Redimensionamento vertical permitido
|
|
204
|
+
- ✅ Ícones customizados opcionais
|
|
205
|
+
- ✅ Estados de erro integrados
|
|
206
|
+
- ✅ Integração completa com React Hook Form
|
|
207
|
+
- ✅ Mesma consistência visual do Input
|
|
208
|
+
|
|
209
|
+
### �📋 **Select**
|
|
210
|
+
|
|
178
211
|
Seletor customizado com opções estáticas e suporte a busca.
|
|
179
212
|
|
|
180
213
|
### 🔄 **AsyncSelect**
|
|
214
|
+
|
|
181
215
|
Seletor com carregamento assíncrono de opções:
|
|
216
|
+
|
|
182
217
|
- ✅ Carregamento de dados via API
|
|
183
218
|
- ✅ Busca em tempo real (searchable)
|
|
184
219
|
- ✅ Debounce configurável
|
|
@@ -186,10 +221,13 @@ Seletor com carregamento assíncrono de opções:
|
|
|
186
221
|
- ✅ Integração completa com React Hook Form
|
|
187
222
|
|
|
188
223
|
### 🎛️ **MultiSelect**
|
|
224
|
+
|
|
189
225
|
Seletor múltiplo para escolha de várias opções.
|
|
190
226
|
|
|
191
227
|
### 🔄🎛️ **MultiAsyncSelect**
|
|
228
|
+
|
|
192
229
|
Seletor múltiplo com carregamento assíncrono:
|
|
230
|
+
|
|
193
231
|
- ✅ Todas as funcionalidades do AsyncSelect
|
|
194
232
|
- ✅ Seleção múltipla com tags visuais
|
|
195
233
|
- ✅ Remoção individual de itens selecionados
|
|
@@ -197,7 +235,9 @@ Seletor múltiplo com carregamento assíncrono:
|
|
|
197
235
|
- ✅ Contador de itens extras (+X mais)
|
|
198
236
|
|
|
199
237
|
### 🎯 **RadioGroup**
|
|
238
|
+
|
|
200
239
|
Radio buttons modernos e criativos:
|
|
240
|
+
|
|
201
241
|
- ✅ Design de botões estilizados (não radio tradicional)
|
|
202
242
|
- ✅ Ícones customizados opcionais
|
|
203
243
|
- ✅ Layout horizontal ou vertical
|
|
@@ -214,11 +254,11 @@ O rharuow-ds utiliza **CSS Variables** para permitir customização fácil do te
|
|
|
214
254
|
|
|
215
255
|
```css
|
|
216
256
|
:root {
|
|
217
|
-
--primary: #2563eb;
|
|
218
|
-
--primary-hover: #dbeafe;
|
|
219
|
-
--primary-text: #fff;
|
|
220
|
-
--input-bg: #fff;
|
|
221
|
-
--input-text: #222;
|
|
257
|
+
--primary: #2563eb; /* Cor primária principal */
|
|
258
|
+
--primary-hover: #dbeafe; /* Cor para hover/background */
|
|
259
|
+
--primary-text: #fff; /* Cor do texto em backgrounds primários */
|
|
260
|
+
--input-bg: #fff; /* Background dos inputs */
|
|
261
|
+
--input-text: #222; /* Cor do texto dos inputs */
|
|
222
262
|
}
|
|
223
263
|
```
|
|
224
264
|
|
|
@@ -250,12 +290,14 @@ O rharuow-ds utiliza **CSS Variables** para permitir customização fácil do te
|
|
|
250
290
|
### No Storybook
|
|
251
291
|
|
|
252
292
|
Na documentação do Storybook, você pode testar diferentes temas usando os controles na toolbar:
|
|
293
|
+
|
|
253
294
|
- 🎨 **Primary Color**: Muda a cor principal
|
|
254
295
|
- 🌈 **Primary Hover**: Muda a cor de hover/background
|
|
255
296
|
|
|
256
297
|
---
|
|
257
298
|
|
|
258
299
|
## 🛠️ Desenvolvimento
|
|
300
|
+
|
|
259
301
|
- ✅ Ícones customizados opcionais
|
|
260
302
|
- ✅ Três tamanhos: sm, md, lg
|
|
261
303
|
- ✅ Layout horizontal ou vertical
|
package/dist/rharuow-ds.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ce=require("react"),
|
|
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
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var oe;function
|
|
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
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var le;function
|
|
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
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,P,O,X,O),K[O+P]=!0)}if(O=null,w!==void 0&&(o(w),O=""+w),R(s)&&(o(s.key),O=""+s.key),"key"in s){w={};for(var Z in s)Z!=="key"&&(w[Z]=s[Z])}else w=s;return O&&I(w,typeof e=="function"?e.displayName||e.name||"Unknown":e),S(e,O,B,q,v(),w,G,ee)}function j(e){typeof e=="object"&&e!==null&&e.$$typeof===N&&e._store&&(e._store.validated=1)}var g=ce,N=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),T=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),z=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,x=Object.prototype.hasOwnProperty,n=Array.isArray,l=console.createTask?console.createTask:function(){return null};g={"react-stack-bottom-frame":function(e){return e()}};var Y,_={},L=g["react-stack-bottom-frame"].bind(g,C)(),Q=l(u(C)),K={};re.Fragment=d,re.jsx=function(e,s,w,P,q){var B=1e4>z.recentlyCreatedOwnerStacks++;return A(e,s,w,!1,P,q,B?Error("react-stack-top-frame"):L,B?l(u(e)):Q)},re.jsxs=function(e,s,w,P,q){var B=1e4>z.recentlyCreatedOwnerStacks++;return A(e,s,w,!0,P,q,B?Error("react-stack-top-frame"):L,B?l(u(e)):Q)}}()),re}var ie;function we(){return ie||(ie=1,process.env.NODE_ENV==="production"?ae.exports=pe():ae.exports=ye()),ae.exports}var r=we();function ue(t){var a,o,u="";if(typeof t=="string"||typeof t=="number")u+=t;else if(typeof t=="object")if(Array.isArray(t)){var v=t.length;for(a=0;a<v;a++)t[a]&&(o=ue(t[a]))&&(u&&(u+=" "),u+=o)}else for(o in t)t[o]&&(u&&(u+=" "),u+=o);return u}function je(){for(var t,a,o=0,u="",v=arguments.length;o<v;o++)(t=arguments[o])&&(a=ue(t))&&(u&&(u+=" "),u+=a);return u}function h(...t){return je(...t)}const Ne=({children:t,variant:a="default",className:o="",...u})=>{const v="px-4 py-2 rounded font-medium transition",C={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:h(v,C[a],o),...u,children:t})},de=i.forwardRef(({name:t,className:a,type:o="text",label:u,onFocus:v,onBlur:C,Icon:R,iconClassName:I,iconAction:b,containerClassName:S,...A},j)=>{var z,x,n;const[g,N]=i.useState(!1),[E,d]=i.useState(!1),p=H.useFormContext(),k=p==null?void 0:p.control,c=p==null?void 0:p.register,T=k&&t?H.useWatch({control:k,name:t}):void 0,F=A.value??T??"",y=(n=(x=(z=p==null?void 0:p.formState)==null?void 0:z.errors)==null?void 0:x[t])==null?void 0:n.message,M=g||!!F,V=o==="password"?E?"text":"password":o,W=()=>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"})}),D=()=>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"})}),$=()=>{d(!E)};return r.jsxs("div",{className:h("relative",S),children:[r.jsx("input",{id:A.id||t,type:V,className:h("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",o==="password"||R?"pr-12":"",a),onFocus:l=>{N(!0),v&&v(l)},...p&&t?(()=>{const l=c(t),Y=l.onBlur;return{...l,ref:_=>{typeof j=="function"?j(_):j&&(j.current=_),l.ref&&l.ref(_)},onBlur:_=>{N(!1),C&&C(_),Y&&Y(_)}}})():{ref:j,onBlur:l=>{N(!1),C&&C(l)}},...A}),u&&r.jsx("label",{htmlFor:A.id||t,className:h("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",M?"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:u}),o==="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:$,"aria-label":E?"Esconder senha":"Mostrar senha",tabIndex:-1,children:E?r.jsx(D,{}):r.jsx(W,{})}),R&&o!=="password"&&r.jsx("div",{className:h("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:b,children:r.jsx(R,{})}),y&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:y})]})});de.displayName="Input";const fe=i.forwardRef(({name:t,label:a,options:o,className:u,containerClassName:v,isClearable:C,onFocus:R,onBlur:I,...b},S)=>{var W,D,$,z;const[A,j]=i.useState(!1),[g,N]=i.useState(!1),E=i.useRef(null),d=H.useFormContext(),p=d==null?void 0:d.control,k=p&&t?H.useWatch({control:p,name:t}):void 0,c=b.value??k??"",T=($=(D=(W=d==null?void 0:d.formState)==null?void 0:W.errors)==null?void 0:D[t])==null?void 0:$.message,F=A||!!c;i.useEffect(()=>{const x=n=>{E.current&&!E.current.contains(n.target)&&(N(!1),j(!1))};return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const y=()=>{N(x=>!x),j(!0)},M=x=>{j(!0),R&&R(x)},V=x=>{I&&I(x)};return r.jsxs("div",{className:h("relative",v),ref:E,children:[r.jsxs("div",{id:b.id||t,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":g,className:h("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",u),onClick:y,onFocus:M,onBlur:V,ref:S,children:[r.jsx("span",{className:h("block truncate",!c&&"text-gray-400"),children:((z=o.find(x=>x.value===c))==null?void 0:z.label)||!a&&"Selecione..."}),C&&c&&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:x=>{if(x.stopPropagation(),d&&t&&d.setValue(t,""),b.onChange){const n={target:{value:""}};b.onChange(n)}N(!1),j(!1)},children:"✕"})]}),a&&r.jsx("label",{htmlFor:b.id||t,className:h("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",F?"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:a}),r.jsx("div",{className:h("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",g?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:g?"9.5rem":"0",overflowY:o.length>3?"auto":"hidden"},children:o.map(x=>r.jsx("div",{className:h("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm",c===x.value&&"bg-blue-100"),onMouseDown:()=>{if(d&&t&&d.setValue(t,x.value),b.onChange){const n={target:{value:x.value}};b.onChange(n)}j(!0)},children:x.label},x.value))}),T&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:T})]})});fe.displayName="Select";const xe=i.forwardRef(({name:t,label:a,loadOptions:o,className:u,containerClassName:v,isClearable:C,defaultOptions:R=!1,loadingMessage:I="Carregando...",noOptionsMessage:b="Nenhuma opção encontrada",searchable:S=!1,debounceMs:A=300,onFocus:j,onBlur:g,...N},E)=>{var O,X,Z;const[d,p]=i.useState(!1),[k,c]=i.useState(!1),[T,F]=i.useState([]),[y,M]=i.useState(!1),[V,W]=i.useState(""),[D,$]=i.useState(""),z=i.useRef(null),x=i.useRef(null),n=H.useFormContext(),l=n==null?void 0:n.control,Y=l&&t?H.useWatch({control:l,name:t}):void 0,_=N.value??Y??"",L=(Z=(X=(O=n==null?void 0:n.formState)==null?void 0:O.errors)==null?void 0:X[t])==null?void 0:Z.message,Q=d||!!_;i.useEffect(()=>{const m=setTimeout(()=>{$(V)},A);return()=>clearTimeout(m)},[V,A]),i.useEffect(()=>{(k||R&&T.length===0)&&K(S?D:void 0)},[D,k]),i.useEffect(()=>{R===!0?K():Array.isArray(R)&&F(R)},[]);const K=async m=>{try{M(!0);const J=await o(m);F(J)}catch(J){console.error("Error loading options:",J),F([])}finally{M(!1)}};i.useEffect(()=>{const m=J=>{z.current&&!z.current.contains(J.target)&&(c(!1),p(!1),W(""))};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]);const e=()=>{k||(c(!0),p(!0),S&&x.current&&setTimeout(()=>{var m;return(m=x.current)==null?void 0:m.focus()},0))},s=m=>{p(!0),j&&j(m)},w=m=>{g&&g(m)},P=m=>{W(m.target.value)},q=m=>{if(n&&t&&n.setValue(t,m),N.onChange){const J={target:{value:m}};N.onChange(J)}c(!1),p(!1),W("")},B=m=>{if(m.stopPropagation(),n&&t&&n.setValue(t,""),N.onChange){const J={target:{value:""}};N.onChange(J)}c(!1),p(!1),W("")},G=T.find(m=>m.value===_),ee=S&&k?V:(G==null?void 0:G.label)||"";return r.jsxs("div",{className:h("relative",v),ref:z,children:[r.jsxs("div",{id:N.id||t,tabIndex:S?-1:0,role:"button","aria-haspopup":"listbox","aria-expanded":k,className:h("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",u),onClick:e,onFocus:S?void 0:s,onBlur:S?void 0:w,ref:E,children:[S?r.jsx("input",{ref:x,type:"text",value:ee,onChange:P,onFocus:s,onBlur:w,placeholder:a?"":"Selecione...",className:h("w-full bg-transparent border-none outline-none text-sm",!_&&!V&&"text-gray-400")}):r.jsx("span",{className:h("block truncate",!_&&"text-gray-400"),children:(G==null?void 0:G.label)||!a&&"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)]"})}),C&&_&&!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:B,children:"✕"})]}),a&&r.jsx("label",{htmlFor:N.id||t,className:h("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:a}),r.jsx("div",{className:h("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:T.length>3?"auto":"hidden"},children:y?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:I}):T.length===0?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:b}):T.map(m=>r.jsx("div",{className:h("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm",_===m.value&&"bg-blue-100"),onMouseDown:()=>q(m.value),children:m.label},m.value))}),L&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:L})]})});xe.displayName="AsyncSelect";const me=i.forwardRef(({name:t,label:a,options:o,className:u,containerClassName:v,isClearable:C,onFocus:R,onBlur:I,...b},S)=>{var $,z,x;const[A,j]=i.useState(!1),[g,N]=i.useState(!1),E=i.useRef(null),d=H.useFormContext(),p=d==null?void 0:d.control,k=p&&t?H.useWatch({control:p,name:t}):void 0,c=b.value??k??[],T=(x=(z=($=d==null?void 0:d.formState)==null?void 0:$.errors)==null?void 0:z[t])==null?void 0:x.message,F=A||c&&c.length>0;i.useEffect(()=>{const n=l=>{E.current&&!E.current.contains(l.target)&&(N(!1),j(!1))};return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[]);const y=()=>{N(n=>!n),j(!0)},M=n=>{j(!0),R&&R(n)},V=n=>{I&&I(n)},W=n=>{var Y;let l;c.includes(n)?l=c.filter(_=>_!==n):l=[...c,n],d&&t&&d.setValue(t,l),b.onChange&&((Y=b.onChange)==null||Y.call(b,{target:{value:l}})),j(!0)},D=n=>{var l;n.stopPropagation(),d&&t&&d.setValue(t,[]),b.onChange&&((l=b.onChange)==null||l.call(b,{target:{value:[]}})),N(!1),j(!1)};return r.jsxs("div",{className:h("relative",v),ref:E,children:[r.jsxs("div",{id:b.id||t,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":g,className:h("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",u),onClick:y,onFocus:M,onBlur:V,ref:S,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:c&&c.length>0?o.filter(n=>c.includes(n.value)).map(n=>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:n.label,children:n.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 ${n.label}`,tabIndex:-1,onClick:l=>{l.stopPropagation();const Y=c.filter(_=>_!==n.value);d&&t&&d.setValue(t,Y),b.onChange&&b.onChange({target:{value:Y}})},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"})})})]},n.value)):!a&&r.jsx("span",{className:"text-gray-400 text-sm",children:"Selecione..."})}),C&&c&&c.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:D,children:"✕"})]}),a&&r.jsx("label",{htmlFor:b.id||t,className:h("absolute left-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",F?"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:a}),r.jsx("div",{className:h("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",g?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:g?"9.5rem":"0",overflowY:o.length>3?"auto":"hidden"},children:o.map(n=>r.jsxs("div",{className:h("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm flex items-center gap-2",c.includes(n.value)&&"bg-blue-100 font-semibold"),onMouseDown:()=>W(n.value),children:[r.jsx("input",{type:"checkbox",checked:c.includes(n.value),readOnly:!0,className:"accent-blue-500"}),n.label]},n.value))}),T&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:T})]})});me.displayName="MultiSelect";const he=i.forwardRef(({name:t,label:a,loadOptions:o,className:u,containerClassName:v,isClearable:C,defaultOptions:R=!1,loadingMessage:I="Carregando...",noOptionsMessage:b="Nenhuma opção encontrada",searchable:S=!1,debounceMs:A=300,maxSelectedDisplay:j=3,onFocus:g,onBlur:N,...E},d)=>{var m,J,se;const[p,k]=i.useState(!1),[c,T]=i.useState(!1),[F,y]=i.useState([]),[M,V]=i.useState(!1),[W,D]=i.useState(""),[$,z]=i.useState(""),x=i.useRef(null),n=i.useRef(null),l=H.useFormContext(),Y=l==null?void 0:l.control,_=Y&&t?H.useWatch({control:Y,name:t}):void 0,L=E.value??_??[],Q=(se=(J=(m=l==null?void 0:l.formState)==null?void 0:m.errors)==null?void 0:J[t])==null?void 0:se.message,K=p||L&&L.length>0;i.useEffect(()=>{const f=setTimeout(()=>{z(W)},A);return()=>clearTimeout(f)},[W,A]),i.useEffect(()=>{(c||R&&F.length===0)&&e(S?$:void 0)},[$,c]),i.useEffect(()=>{R===!0?e():Array.isArray(R)&&y(R)},[]);const e=async f=>{try{V(!0);const U=await o(f);y(U)}catch(U){console.error("Error loading options:",U),y([])}finally{V(!1)}};i.useEffect(()=>{const f=U=>{x.current&&!x.current.contains(U.target)&&(T(!1),k(!1),D(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]);const s=()=>{c||(T(!0),k(!0),S&&n.current&&setTimeout(()=>{var f;return(f=n.current)==null?void 0:f.focus()},0))},w=f=>{k(!0),g&&g(f)},P=f=>{N&&N(f)},q=f=>{D(f.target.value)},B=f=>{let U;L.includes(f)?U=L.filter(ne=>ne!==f):U=[...L,f],l&&t&&l.setValue(t,U),E.onChange&&E.onChange({target:{value:U}}),k(!0)},G=(f,U)=>{U.stopPropagation();const ne=L.filter(ve=>ve!==f);l&&t&&l.setValue(t,ne),E.onChange&&E.onChange({target:{value:ne}})},ee=f=>{f.stopPropagation(),l&&t&&l.setValue(t,[]),E.onChange&&E.onChange({target:{value:[]}}),T(!1),k(!1),D("")},O=F.filter(f=>L.includes(f.value)),X=O.slice(0,j),Z=O.length-j;return r.jsxs("div",{className:h("relative",v),ref:x,children:[r.jsxs("div",{id:E.id||t,tabIndex:S?-1:0,role:"button","aria-haspopup":"listbox","aria-expanded":c,className:h("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",u),onClick:s,onFocus:S?void 0:w,onBlur:S?void 0:P,ref:d,children:[r.jsxs("div",{className:"flex flex-wrap gap-1 items-center min-h-[1.5rem] w-full",children:[X.map(f=>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:f.label,children:f.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 ${f.label}`,tabIndex:-1,onClick:U=>G(f.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"})})})]},f.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"]}),S?r.jsx("input",{ref:n,type:"text",value:W,onChange:q,onFocus:w,onBlur:P,placeholder:L.length===0&&!a?"Selecione...":"",className:"flex-1 min-w-[120px] bg-transparent border-none outline-none text-sm"}):L.length===0&&!a&&r.jsx("span",{className:"text-gray-400 text-sm",children:"Selecione..."})]}),M&&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)]"})}),C&&L&&L.length>0&&!M&&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:"✕"})]}),a&&r.jsx("label",{htmlFor:E.id||t,className:h("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:a}),r.jsx("div",{className:h("absolute left-0 w-full mt-1 rounded-md shadow-lg bg-white z-20 transition-all duration-200 overflow-hidden",c?"border border-[var(--primary,#2563eb)] max-h-36 opacity-100 scale-100":"max-h-0 opacity-0 scale-95 pointer-events-none"),style:{maxHeight:c?"9.5rem":"0",overflowY:F.length>3?"auto":"hidden"},children:M?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:I}):F.length===0?r.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center",children:b}):F.map(f=>r.jsxs("div",{className:h("px-3 py-2 cursor-pointer hover:bg-blue-50 text-sm flex items-center gap-2",L.includes(f.value)&&"bg-blue-100 font-semibold"),onMouseDown:()=>B(f.value),children:[r.jsx("input",{type:"checkbox",checked:L.includes(f.value),readOnly:!0,className:"accent-blue-500"}),f.label]},f.value))}),Q&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:Q})]})});he.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"},be=i.forwardRef(({name:t,label:a,options:o,className:u,containerClassName:v,optionClassName:C,direction:R="row",size:I="md",onFocus:b,onBlur:S,...A},j)=>{var c,T,F;const g=H.useFormContext(),N=g==null?void 0:g.control,E=N&&t?H.useWatch({control:N,name:t}):void 0,d=A.value??E??"",p=(F=(T=(c=g==null?void 0:g.formState)==null?void 0:c.errors)==null?void 0:T[t])==null?void 0:F.message,k=y=>{g&&t&&g.setValue(t,y),A.onChange&&A.onChange({target:{value:y}})};return r.jsxs("div",{className:h("relative",v),ref:j,children:[a&&r.jsx("label",{htmlFor:t,className:h("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:a}),r.jsx("div",{className:h("flex gap-2 w-full pt-6",R==="row"?"flex-row":"flex-col",u),"aria-label":a,tabIndex:-1,onFocus:b,onBlur:S,children:o.map(y=>r.jsxs("button",{type:"button",className:h("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],d===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",C),"aria-pressed":d===y.value,"data-selected":d===y.value,tabIndex:0,onClick:()=>k(y.value),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.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))}),p&&r.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:p})]})});be.displayName="RadioGroup";exports.AsyncSelect=xe;exports.Button=Ne;exports.Input=de;exports.MultiAsyncSelect=he;exports.MultiSelect=me;exports.RadioGroup=be;exports.Select=fe;
|
|
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;
|