@sigep/react 1.0.0 → 1.1.1
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/index.d.mts +434 -2
- package/dist/index.d.ts +434 -2
- package/dist/index.js +1150 -6
- package/dist/index.mjs +1128 -5
- package/package.json +7 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,51 @@
|
|
|
1
|
-
// src/components/
|
|
1
|
+
// src/components/Avatar/index.tsx
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { tv } from "tailwind-variants";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var
|
|
5
|
+
var avatar = tv({
|
|
6
|
+
base: "inline-flex items-center justify-center rounded-full font-medium select-none overflow-hidden",
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
sm: "h-8 w-8 text-xs",
|
|
10
|
+
md: "h-10 w-10 text-sm",
|
|
11
|
+
lg: "h-12 w-12 text-base",
|
|
12
|
+
xl: "h-16 w-16 text-lg"
|
|
13
|
+
},
|
|
14
|
+
variant: {
|
|
15
|
+
primary: "bg-blue-600 text-white",
|
|
16
|
+
secondary: "bg-gray-200 text-gray-700",
|
|
17
|
+
outline: "bg-white text-blue-600 ring-2 ring-blue-600 ring-offset-2"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: "md",
|
|
22
|
+
variant: "primary"
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
function getInitials(name) {
|
|
26
|
+
const parts = name.trim().split(/\s+/);
|
|
27
|
+
if (parts.length === 1) return parts[0].charAt(0).toUpperCase();
|
|
28
|
+
return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
var Avatar = forwardRef(
|
|
31
|
+
({ name, src, alt, size, variant, className, ...props }, ref) => {
|
|
32
|
+
return /* @__PURE__ */ jsx("div", { ref, className: avatar({ size, variant, className }), ...props, children: src ? /* @__PURE__ */ jsx(
|
|
33
|
+
"img",
|
|
34
|
+
{
|
|
35
|
+
src,
|
|
36
|
+
alt: alt || name || "avatar",
|
|
37
|
+
className: "h-full w-full object-cover"
|
|
38
|
+
}
|
|
39
|
+
) : /* @__PURE__ */ jsx("span", { children: name ? getInitials(name) : "?" }) });
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
Avatar.displayName = "Avatar";
|
|
43
|
+
|
|
44
|
+
// src/components/Button/index.tsx
|
|
45
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
46
|
+
import { tv as tv2 } from "tailwind-variants";
|
|
47
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
48
|
+
var button = tv2({
|
|
6
49
|
base: "inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
7
50
|
variants: {
|
|
8
51
|
variant: {
|
|
@@ -22,9 +65,9 @@ var button = tv({
|
|
|
22
65
|
size: "md"
|
|
23
66
|
}
|
|
24
67
|
});
|
|
25
|
-
var Button =
|
|
68
|
+
var Button = forwardRef2(
|
|
26
69
|
({ variant, size, className, ...props }, ref) => {
|
|
27
|
-
return /* @__PURE__ */
|
|
70
|
+
return /* @__PURE__ */ jsx2(
|
|
28
71
|
"button",
|
|
29
72
|
{
|
|
30
73
|
ref,
|
|
@@ -35,7 +78,1087 @@ var Button = forwardRef(
|
|
|
35
78
|
}
|
|
36
79
|
);
|
|
37
80
|
Button.displayName = "Button";
|
|
81
|
+
|
|
82
|
+
// src/components/Card/index.tsx
|
|
83
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
84
|
+
import { tv as tv3 } from "tailwind-variants";
|
|
85
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
86
|
+
var card = tv3({
|
|
87
|
+
base: "rounded-lg bg-white text-gray-900 overflow-hidden",
|
|
88
|
+
variants: {
|
|
89
|
+
variant: {
|
|
90
|
+
elevated: "shadow-md",
|
|
91
|
+
outlined: "border border-gray-200",
|
|
92
|
+
filled: "bg-gray-50"
|
|
93
|
+
},
|
|
94
|
+
padding: {
|
|
95
|
+
none: "",
|
|
96
|
+
sm: "p-3",
|
|
97
|
+
md: "p-5",
|
|
98
|
+
lg: "p-8"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
defaultVariants: {
|
|
102
|
+
variant: "elevated",
|
|
103
|
+
padding: "md"
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
var Card = forwardRef3(
|
|
107
|
+
({ variant, padding, header, footer, className, children, ...props }, ref) => {
|
|
108
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: card({ variant, padding: header || footer ? "none" : padding, className }), ...props, children: [
|
|
109
|
+
header && /* @__PURE__ */ jsx3("div", { className: "border-b border-gray-200 px-5 py-3 font-semibold text-sm", children: header }),
|
|
110
|
+
header || footer ? /* @__PURE__ */ jsx3("div", { className: card({ padding, className: "rounded-none shadow-none border-none bg-transparent" }), children }) : children,
|
|
111
|
+
footer && /* @__PURE__ */ jsx3("div", { className: "border-t border-gray-200 px-5 py-3 text-sm", children: footer })
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
Card.displayName = "Card";
|
|
116
|
+
|
|
117
|
+
// src/components/Modal/index.tsx
|
|
118
|
+
import { forwardRef as forwardRef4, useEffect, useCallback } from "react";
|
|
119
|
+
import { tv as tv4 } from "tailwind-variants";
|
|
120
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
121
|
+
var overlay = tv4({
|
|
122
|
+
base: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 transition-opacity"
|
|
123
|
+
});
|
|
124
|
+
var modal = tv4({
|
|
125
|
+
base: "relative flex flex-col rounded-lg bg-white text-gray-900 shadow-xl overflow-hidden",
|
|
126
|
+
variants: {
|
|
127
|
+
size: {
|
|
128
|
+
sm: "w-[30vw] max-h-[40vh]",
|
|
129
|
+
md: "w-[50vw] max-h-[60vh]",
|
|
130
|
+
lg: "w-[70vw] max-h-[80vh]",
|
|
131
|
+
full: "w-[95vw] max-h-[90vh]"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
defaultVariants: {
|
|
135
|
+
size: "md"
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
var Modal = forwardRef4(
|
|
139
|
+
({ isOpen, onClose, title, footer, size, className, children, ...props }, ref) => {
|
|
140
|
+
const handleKeyDown = useCallback(
|
|
141
|
+
(e) => {
|
|
142
|
+
if (e.key === "Escape") onClose();
|
|
143
|
+
},
|
|
144
|
+
[onClose]
|
|
145
|
+
);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (!isOpen) return;
|
|
148
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
149
|
+
document.body.style.overflow = "hidden";
|
|
150
|
+
return () => {
|
|
151
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
152
|
+
document.body.style.overflow = "";
|
|
153
|
+
};
|
|
154
|
+
}, [isOpen, handleKeyDown]);
|
|
155
|
+
if (!isOpen) return null;
|
|
156
|
+
return /* @__PURE__ */ jsx4("div", { className: overlay(), onClick: onClose, children: /* @__PURE__ */ jsxs2(
|
|
157
|
+
"div",
|
|
158
|
+
{
|
|
159
|
+
ref,
|
|
160
|
+
className: modal({ size, className }),
|
|
161
|
+
onClick: (e) => e.stopPropagation(),
|
|
162
|
+
role: "dialog",
|
|
163
|
+
"aria-modal": "true",
|
|
164
|
+
...props,
|
|
165
|
+
children: [
|
|
166
|
+
title && /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between border-b border-gray-200 bg-gray-50 px-5 py-3", children: [
|
|
167
|
+
/* @__PURE__ */ jsx4("span", { className: "text-sm font-semibold text-gray-900", children: title }),
|
|
168
|
+
/* @__PURE__ */ jsx4(
|
|
169
|
+
"button",
|
|
170
|
+
{
|
|
171
|
+
type: "button",
|
|
172
|
+
className: "inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-500 hover:bg-gray-200 hover:text-gray-700 transition-colors",
|
|
173
|
+
onClick: onClose,
|
|
174
|
+
"aria-label": "Fechar",
|
|
175
|
+
children: "\u2715"
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
] }),
|
|
179
|
+
/* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-y-auto p-5", children }),
|
|
180
|
+
footer && /* @__PURE__ */ jsx4("div", { className: "flex items-center justify-end gap-2 border-t border-gray-200 px-5 py-3", children: footer })
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
) });
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
Modal.displayName = "Modal";
|
|
187
|
+
|
|
188
|
+
// src/components/Tooltip/index.tsx
|
|
189
|
+
import {
|
|
190
|
+
forwardRef as forwardRef5,
|
|
191
|
+
useCallback as useCallback2,
|
|
192
|
+
useEffect as useEffect2,
|
|
193
|
+
useLayoutEffect,
|
|
194
|
+
useRef,
|
|
195
|
+
useState
|
|
196
|
+
} from "react";
|
|
197
|
+
import { createPortal } from "react-dom";
|
|
198
|
+
import { tv as tv5 } from "tailwind-variants";
|
|
199
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
200
|
+
var tooltip = tv5({
|
|
201
|
+
base: "fixed z-[999999] pointer-events-none",
|
|
202
|
+
variants: {
|
|
203
|
+
variant: {
|
|
204
|
+
dark: "",
|
|
205
|
+
light: ""
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
defaultVariants: {
|
|
209
|
+
variant: "dark"
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
var tooltipContent = tv5({
|
|
213
|
+
base: "inline-flex items-center justify-center rounded px-2.5 py-1 text-xs font-medium whitespace-nowrap",
|
|
214
|
+
variants: {
|
|
215
|
+
variant: {
|
|
216
|
+
dark: "bg-gray-900 text-white",
|
|
217
|
+
light: "bg-white text-gray-900 shadow-md border border-gray-200"
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
defaultVariants: {
|
|
221
|
+
variant: "dark"
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
var tooltipArrow = tv5({
|
|
225
|
+
base: "absolute h-1.5 w-1.5 rotate-45",
|
|
226
|
+
variants: {
|
|
227
|
+
variant: {
|
|
228
|
+
dark: "bg-gray-900",
|
|
229
|
+
light: "bg-white border border-gray-200"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
defaultVariants: {
|
|
233
|
+
variant: "dark"
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
var arrowPlacementStyles = {
|
|
237
|
+
top: "bottom-[-3px] left-1/2 -translate-x-1/2",
|
|
238
|
+
bottom: "top-[-3px] left-1/2 -translate-x-1/2",
|
|
239
|
+
left: "right-[-3px] top-1/2 -translate-y-1/2",
|
|
240
|
+
right: "left-[-3px] top-1/2 -translate-y-1/2"
|
|
241
|
+
};
|
|
242
|
+
var Tooltip = forwardRef5(
|
|
243
|
+
({
|
|
244
|
+
content,
|
|
245
|
+
placement = "top",
|
|
246
|
+
offset: offsetPx = 8,
|
|
247
|
+
variant,
|
|
248
|
+
disabled,
|
|
249
|
+
delayShow = 100,
|
|
250
|
+
delayHide = 100,
|
|
251
|
+
children,
|
|
252
|
+
className,
|
|
253
|
+
...props
|
|
254
|
+
}, ref) => {
|
|
255
|
+
const wrapperRef = useRef(null);
|
|
256
|
+
const tipRef = useRef(null);
|
|
257
|
+
const [visible, setVisible] = useState(false);
|
|
258
|
+
const [coords, setCoords] = useState(null);
|
|
259
|
+
const [activePlacement, setActivePlacement] = useState(placement);
|
|
260
|
+
const showTimer = useRef(null);
|
|
261
|
+
const hideTimer = useRef(null);
|
|
262
|
+
function clearTimers() {
|
|
263
|
+
if (showTimer.current !== null) window.clearTimeout(showTimer.current);
|
|
264
|
+
if (hideTimer.current !== null) window.clearTimeout(hideTimer.current);
|
|
265
|
+
showTimer.current = null;
|
|
266
|
+
hideTimer.current = null;
|
|
267
|
+
}
|
|
268
|
+
function scheduleShow() {
|
|
269
|
+
if (disabled) return;
|
|
270
|
+
clearTimers();
|
|
271
|
+
showTimer.current = window.setTimeout(() => setVisible(true), delayShow);
|
|
272
|
+
}
|
|
273
|
+
function scheduleHide() {
|
|
274
|
+
clearTimers();
|
|
275
|
+
hideTimer.current = window.setTimeout(() => setVisible(false), delayHide);
|
|
276
|
+
}
|
|
277
|
+
const computePosition = useCallback2(() => {
|
|
278
|
+
const anchor = wrapperRef.current;
|
|
279
|
+
const tip = tipRef.current;
|
|
280
|
+
if (!anchor || !tip) return;
|
|
281
|
+
const rect = anchor.getBoundingClientRect();
|
|
282
|
+
const tipW = tip.offsetWidth;
|
|
283
|
+
const tipH = tip.offsetHeight;
|
|
284
|
+
const vw = window.innerWidth;
|
|
285
|
+
const vh = window.innerHeight;
|
|
286
|
+
const calc = (p2) => {
|
|
287
|
+
switch (p2) {
|
|
288
|
+
case "top":
|
|
289
|
+
return { top: rect.top - tipH - offsetPx, left: rect.left + rect.width / 2 - tipW / 2 };
|
|
290
|
+
case "bottom":
|
|
291
|
+
return { top: rect.bottom + offsetPx, left: rect.left + rect.width / 2 - tipW / 2 };
|
|
292
|
+
case "left":
|
|
293
|
+
return { top: rect.top + rect.height / 2 - tipH / 2, left: rect.left - tipW - offsetPx };
|
|
294
|
+
case "right":
|
|
295
|
+
return { top: rect.top + rect.height / 2 - tipH / 2, left: rect.right + offsetPx };
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
let pos = calc(placement);
|
|
299
|
+
let p = placement;
|
|
300
|
+
const fits = (c) => c.top >= 0 && c.left >= 0 && c.top + tipH <= vh && c.left + tipW <= vw;
|
|
301
|
+
if (!fits(pos)) {
|
|
302
|
+
const fallbacks = {
|
|
303
|
+
top: ["bottom", "right", "left"],
|
|
304
|
+
bottom: ["top", "right", "left"],
|
|
305
|
+
left: ["right", "top", "bottom"],
|
|
306
|
+
right: ["left", "top", "bottom"]
|
|
307
|
+
};
|
|
308
|
+
for (const candidate of fallbacks[placement]) {
|
|
309
|
+
const c = calc(candidate);
|
|
310
|
+
if (fits(c)) {
|
|
311
|
+
pos = c;
|
|
312
|
+
p = candidate;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
pos.top = Math.max(4, Math.min(vh - tipH - 4, pos.top));
|
|
318
|
+
pos.left = Math.max(4, Math.min(vw - tipW - 4, pos.left));
|
|
319
|
+
setActivePlacement(p);
|
|
320
|
+
setCoords(pos);
|
|
321
|
+
}, [placement, offsetPx]);
|
|
322
|
+
useLayoutEffect(() => {
|
|
323
|
+
if (!visible) return;
|
|
324
|
+
let raf1 = 0;
|
|
325
|
+
let raf2 = 0;
|
|
326
|
+
raf1 = requestAnimationFrame(() => {
|
|
327
|
+
raf2 = requestAnimationFrame(computePosition);
|
|
328
|
+
});
|
|
329
|
+
return () => {
|
|
330
|
+
cancelAnimationFrame(raf1);
|
|
331
|
+
cancelAnimationFrame(raf2);
|
|
332
|
+
};
|
|
333
|
+
}, [visible, computePosition]);
|
|
334
|
+
useEffect2(() => {
|
|
335
|
+
if (!visible) return;
|
|
336
|
+
const handler = () => computePosition();
|
|
337
|
+
window.addEventListener("scroll", handler, true);
|
|
338
|
+
window.addEventListener("resize", handler);
|
|
339
|
+
return () => {
|
|
340
|
+
window.removeEventListener("scroll", handler, true);
|
|
341
|
+
window.removeEventListener("resize", handler);
|
|
342
|
+
};
|
|
343
|
+
}, [visible, computePosition]);
|
|
344
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
345
|
+
/* @__PURE__ */ jsx5(
|
|
346
|
+
"span",
|
|
347
|
+
{
|
|
348
|
+
ref: (el) => {
|
|
349
|
+
wrapperRef.current = el;
|
|
350
|
+
if (typeof ref === "function") ref(el);
|
|
351
|
+
else if (ref) ref.current = el;
|
|
352
|
+
},
|
|
353
|
+
onMouseEnter: scheduleShow,
|
|
354
|
+
onMouseLeave: scheduleHide,
|
|
355
|
+
onFocus: scheduleShow,
|
|
356
|
+
onBlur: scheduleHide,
|
|
357
|
+
style: { display: "contents" },
|
|
358
|
+
className,
|
|
359
|
+
...props,
|
|
360
|
+
children
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
visible && createPortal(
|
|
364
|
+
/* @__PURE__ */ jsxs3(
|
|
365
|
+
"div",
|
|
366
|
+
{
|
|
367
|
+
ref: tipRef,
|
|
368
|
+
role: "tooltip",
|
|
369
|
+
className: tooltip({ variant }),
|
|
370
|
+
style: {
|
|
371
|
+
top: coords?.top ?? -99999,
|
|
372
|
+
left: coords?.left ?? -99999,
|
|
373
|
+
visibility: coords ? "visible" : "hidden"
|
|
374
|
+
},
|
|
375
|
+
children: [
|
|
376
|
+
/* @__PURE__ */ jsx5("div", { className: tooltipContent({ variant }), children: content }),
|
|
377
|
+
/* @__PURE__ */ jsx5("div", { className: `${tooltipArrow({ variant })} ${arrowPlacementStyles[activePlacement]}` })
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
),
|
|
381
|
+
document.body
|
|
382
|
+
)
|
|
383
|
+
] });
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
Tooltip.displayName = "Tooltip";
|
|
387
|
+
|
|
388
|
+
// src/components/Input/InputString.tsx
|
|
389
|
+
import { forwardRef as forwardRef7, useState as useState2 } from "react";
|
|
390
|
+
|
|
391
|
+
// src/components/Input/InputWrapper.tsx
|
|
392
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
393
|
+
import { tv as tv6 } from "tailwind-variants";
|
|
394
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
395
|
+
var wrapper = tv6({
|
|
396
|
+
base: "flex w-full flex-col gap-1"
|
|
397
|
+
});
|
|
398
|
+
var labelStyle = tv6({
|
|
399
|
+
base: "text-xs text-gray-700 flex items-start gap-0.5"
|
|
400
|
+
});
|
|
401
|
+
var containerStyle = tv6({
|
|
402
|
+
base: "flex items-center w-full rounded-md border bg-white transition-colors",
|
|
403
|
+
variants: {
|
|
404
|
+
size: {
|
|
405
|
+
sm: "h-8 text-sm",
|
|
406
|
+
md: "h-9 text-sm",
|
|
407
|
+
lg: "h-10 text-base"
|
|
408
|
+
},
|
|
409
|
+
error: {
|
|
410
|
+
true: "border-red-500 focus-within:border-red-500 focus-within:ring-1 focus-within:ring-red-500",
|
|
411
|
+
false: "border-gray-300 hover:border-gray-400 focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500"
|
|
412
|
+
},
|
|
413
|
+
disabled: {
|
|
414
|
+
true: "opacity-50 cursor-not-allowed bg-gray-50"
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
defaultVariants: {
|
|
418
|
+
size: "md",
|
|
419
|
+
error: false
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
var errorStyle = tv6({
|
|
423
|
+
base: "text-xs text-red-500 mt-0.5"
|
|
424
|
+
});
|
|
425
|
+
var InputWrapper = forwardRef6(
|
|
426
|
+
({ label, error, errorMessage, required, disabled, size, children, className, classContainer, htmlFor }, ref) => {
|
|
427
|
+
return /* @__PURE__ */ jsxs4("div", { ref, className: wrapper({ className }), children: [
|
|
428
|
+
label && /* @__PURE__ */ jsxs4("label", { htmlFor, className: labelStyle(), children: [
|
|
429
|
+
/* @__PURE__ */ jsx6("span", { children: label }),
|
|
430
|
+
required && /* @__PURE__ */ jsx6("span", { className: "text-red-500 text-[10px] leading-none mt-0.5", children: "*" })
|
|
431
|
+
] }),
|
|
432
|
+
/* @__PURE__ */ jsx6("div", { className: containerStyle({ size, error: !!error, disabled: !!disabled, className: classContainer }), children }),
|
|
433
|
+
error && errorMessage && /* @__PURE__ */ jsx6("span", { className: errorStyle(), children: errorMessage })
|
|
434
|
+
] });
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
InputWrapper.displayName = "InputWrapper";
|
|
438
|
+
|
|
439
|
+
// src/components/Input/InputString.tsx
|
|
440
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
441
|
+
var InputString = forwardRef7(
|
|
442
|
+
({
|
|
443
|
+
label,
|
|
444
|
+
error,
|
|
445
|
+
errorMessage,
|
|
446
|
+
required,
|
|
447
|
+
size,
|
|
448
|
+
showClearButton = true,
|
|
449
|
+
leftIcon,
|
|
450
|
+
rightIcon,
|
|
451
|
+
classContainer,
|
|
452
|
+
classInput,
|
|
453
|
+
value,
|
|
454
|
+
onChange,
|
|
455
|
+
disabled,
|
|
456
|
+
name,
|
|
457
|
+
...props
|
|
458
|
+
}, ref) => {
|
|
459
|
+
const [hovered, setHovered] = useState2(false);
|
|
460
|
+
return /* @__PURE__ */ jsx7(
|
|
461
|
+
"div",
|
|
462
|
+
{
|
|
463
|
+
onMouseEnter: () => setHovered(true),
|
|
464
|
+
onMouseLeave: () => setHovered(false),
|
|
465
|
+
className: "w-full",
|
|
466
|
+
children: /* @__PURE__ */ jsxs5(
|
|
467
|
+
InputWrapper,
|
|
468
|
+
{
|
|
469
|
+
label,
|
|
470
|
+
error,
|
|
471
|
+
errorMessage,
|
|
472
|
+
required,
|
|
473
|
+
disabled,
|
|
474
|
+
size,
|
|
475
|
+
classContainer,
|
|
476
|
+
htmlFor: name,
|
|
477
|
+
children: [
|
|
478
|
+
leftIcon && /* @__PURE__ */ jsx7("span", { className: "pl-2.5 text-gray-400", children: leftIcon }),
|
|
479
|
+
/* @__PURE__ */ jsx7(
|
|
480
|
+
"input",
|
|
481
|
+
{
|
|
482
|
+
ref,
|
|
483
|
+
id: name,
|
|
484
|
+
name,
|
|
485
|
+
type: "text",
|
|
486
|
+
value: value ?? "",
|
|
487
|
+
onChange: (e) => onChange?.(e.target.value),
|
|
488
|
+
disabled,
|
|
489
|
+
"aria-invalid": !!error,
|
|
490
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
491
|
+
...props
|
|
492
|
+
}
|
|
493
|
+
),
|
|
494
|
+
showClearButton && hovered && value && !disabled && !required && /* @__PURE__ */ jsx7(
|
|
495
|
+
"button",
|
|
496
|
+
{
|
|
497
|
+
type: "button",
|
|
498
|
+
tabIndex: -1,
|
|
499
|
+
"aria-label": "Limpar campo",
|
|
500
|
+
className: "px-2 text-gray-400 hover:text-gray-600",
|
|
501
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
502
|
+
onClick: () => onChange?.(""),
|
|
503
|
+
children: /* @__PURE__ */ jsxs5(
|
|
504
|
+
"svg",
|
|
505
|
+
{
|
|
506
|
+
width: "14",
|
|
507
|
+
height: "14",
|
|
508
|
+
viewBox: "0 0 24 24",
|
|
509
|
+
fill: "none",
|
|
510
|
+
stroke: "currentColor",
|
|
511
|
+
strokeWidth: "2",
|
|
512
|
+
strokeLinecap: "round",
|
|
513
|
+
strokeLinejoin: "round",
|
|
514
|
+
children: [
|
|
515
|
+
/* @__PURE__ */ jsx7("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
516
|
+
/* @__PURE__ */ jsx7("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
}
|
|
521
|
+
),
|
|
522
|
+
rightIcon && /* @__PURE__ */ jsx7("span", { className: "pr-2.5 text-gray-400", children: rightIcon })
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
);
|
|
530
|
+
InputString.displayName = "InputString";
|
|
531
|
+
|
|
532
|
+
// src/components/Input/InputEmail.tsx
|
|
533
|
+
import { forwardRef as forwardRef8 } from "react";
|
|
534
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
535
|
+
var InputEmail = forwardRef8(
|
|
536
|
+
({ label, error, errorMessage, required, size, leftIcon, rightIcon, classContainer, classInput, value, onChange, disabled, name, ...props }, ref) => {
|
|
537
|
+
return /* @__PURE__ */ jsxs6(
|
|
538
|
+
InputWrapper,
|
|
539
|
+
{
|
|
540
|
+
label,
|
|
541
|
+
error,
|
|
542
|
+
errorMessage,
|
|
543
|
+
required,
|
|
544
|
+
disabled,
|
|
545
|
+
size,
|
|
546
|
+
classContainer,
|
|
547
|
+
htmlFor: name,
|
|
548
|
+
children: [
|
|
549
|
+
leftIcon && /* @__PURE__ */ jsx8("span", { className: "pl-2.5 text-gray-400", children: leftIcon }),
|
|
550
|
+
/* @__PURE__ */ jsx8(
|
|
551
|
+
"input",
|
|
552
|
+
{
|
|
553
|
+
ref,
|
|
554
|
+
id: name,
|
|
555
|
+
name,
|
|
556
|
+
type: "email",
|
|
557
|
+
autoComplete: "email",
|
|
558
|
+
value: value ?? "",
|
|
559
|
+
onChange: (e) => onChange?.(e.target.value),
|
|
560
|
+
disabled,
|
|
561
|
+
"aria-invalid": !!error,
|
|
562
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
563
|
+
...props
|
|
564
|
+
}
|
|
565
|
+
),
|
|
566
|
+
rightIcon && /* @__PURE__ */ jsx8("span", { className: "pr-2.5 text-gray-400", children: rightIcon })
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
);
|
|
572
|
+
InputEmail.displayName = "InputEmail";
|
|
573
|
+
|
|
574
|
+
// src/components/Input/InputPassword.tsx
|
|
575
|
+
import { forwardRef as forwardRef9, useState as useState3 } from "react";
|
|
576
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
577
|
+
var EyeIcon = () => /* @__PURE__ */ jsxs7("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
578
|
+
/* @__PURE__ */ jsx9("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
579
|
+
/* @__PURE__ */ jsx9("circle", { cx: "12", cy: "12", r: "3" })
|
|
580
|
+
] });
|
|
581
|
+
var EyeOffIcon = () => /* @__PURE__ */ jsxs7("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
582
|
+
/* @__PURE__ */ jsx9("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
583
|
+
/* @__PURE__ */ jsx9("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
584
|
+
] });
|
|
585
|
+
var InputPassword = forwardRef9(
|
|
586
|
+
({ label, error, errorMessage, required, size, classContainer, classInput, value, onChange, disabled, name, ...props }, ref) => {
|
|
587
|
+
const [visible, setVisible] = useState3(false);
|
|
588
|
+
return /* @__PURE__ */ jsxs7(
|
|
589
|
+
InputWrapper,
|
|
590
|
+
{
|
|
591
|
+
label,
|
|
592
|
+
error,
|
|
593
|
+
errorMessage,
|
|
594
|
+
required,
|
|
595
|
+
disabled,
|
|
596
|
+
size,
|
|
597
|
+
classContainer,
|
|
598
|
+
htmlFor: name,
|
|
599
|
+
children: [
|
|
600
|
+
/* @__PURE__ */ jsx9(
|
|
601
|
+
"input",
|
|
602
|
+
{
|
|
603
|
+
ref,
|
|
604
|
+
id: name,
|
|
605
|
+
name,
|
|
606
|
+
type: visible ? "text" : "password",
|
|
607
|
+
autoComplete: "current-password",
|
|
608
|
+
value: value ?? "",
|
|
609
|
+
onChange: (e) => onChange?.(e.target.value),
|
|
610
|
+
disabled,
|
|
611
|
+
"aria-invalid": !!error,
|
|
612
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
613
|
+
...props
|
|
614
|
+
}
|
|
615
|
+
),
|
|
616
|
+
/* @__PURE__ */ jsx9(
|
|
617
|
+
"button",
|
|
618
|
+
{
|
|
619
|
+
type: "button",
|
|
620
|
+
tabIndex: -1,
|
|
621
|
+
"aria-label": visible ? "Ocultar senha" : "Mostrar senha",
|
|
622
|
+
className: "px-2.5 text-gray-400 hover:text-gray-600",
|
|
623
|
+
onClick: () => setVisible(!visible),
|
|
624
|
+
children: visible ? /* @__PURE__ */ jsx9(EyeOffIcon, {}) : /* @__PURE__ */ jsx9(EyeIcon, {})
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
InputPassword.displayName = "InputPassword";
|
|
633
|
+
|
|
634
|
+
// src/components/Input/InputNumber.tsx
|
|
635
|
+
import { forwardRef as forwardRef10 } from "react";
|
|
636
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
637
|
+
var allowedKeys = ["Backspace", "Delete", "Tab", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"];
|
|
638
|
+
var InputNumber = forwardRef10(
|
|
639
|
+
({ label, error, errorMessage, required, size, leftIcon, rightIcon, classContainer, classInput, value, onChange, disabled, name, min = 0, max, ...props }, ref) => {
|
|
640
|
+
function handleKeyDown(e) {
|
|
641
|
+
if (e.ctrlKey || e.metaKey) return;
|
|
642
|
+
if (allowedKeys.includes(e.key)) return;
|
|
643
|
+
if (!/^[0-9]$/.test(e.key)) {
|
|
644
|
+
e.preventDefault();
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
function handleChange(raw) {
|
|
648
|
+
if (raw === "") {
|
|
649
|
+
onChange?.(void 0);
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const num = Number(raw);
|
|
653
|
+
if (isNaN(num)) return;
|
|
654
|
+
if (min !== void 0 && num < min) return;
|
|
655
|
+
if (max !== void 0 && num > max) return;
|
|
656
|
+
onChange?.(num);
|
|
657
|
+
}
|
|
658
|
+
return /* @__PURE__ */ jsxs8(
|
|
659
|
+
InputWrapper,
|
|
660
|
+
{
|
|
661
|
+
label,
|
|
662
|
+
error,
|
|
663
|
+
errorMessage,
|
|
664
|
+
required,
|
|
665
|
+
disabled,
|
|
666
|
+
size,
|
|
667
|
+
classContainer,
|
|
668
|
+
htmlFor: name,
|
|
669
|
+
children: [
|
|
670
|
+
leftIcon && /* @__PURE__ */ jsx10("span", { className: "pl-2.5 text-gray-400", children: leftIcon }),
|
|
671
|
+
/* @__PURE__ */ jsx10(
|
|
672
|
+
"input",
|
|
673
|
+
{
|
|
674
|
+
ref,
|
|
675
|
+
id: name,
|
|
676
|
+
name,
|
|
677
|
+
type: "text",
|
|
678
|
+
inputMode: "numeric",
|
|
679
|
+
value: value ?? "",
|
|
680
|
+
onChange: (e) => handleChange(e.target.value),
|
|
681
|
+
onKeyDown: handleKeyDown,
|
|
682
|
+
disabled,
|
|
683
|
+
"aria-invalid": !!error,
|
|
684
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
685
|
+
...props
|
|
686
|
+
}
|
|
687
|
+
),
|
|
688
|
+
rightIcon && /* @__PURE__ */ jsx10("span", { className: "pr-2.5 text-gray-400", children: rightIcon })
|
|
689
|
+
]
|
|
690
|
+
}
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
);
|
|
694
|
+
InputNumber.displayName = "InputNumber";
|
|
695
|
+
|
|
696
|
+
// src/components/Input/InputCPF.tsx
|
|
697
|
+
import { forwardRef as forwardRef11 } from "react";
|
|
698
|
+
|
|
699
|
+
// src/components/Input/masks.ts
|
|
700
|
+
function maskCPF(value) {
|
|
701
|
+
const digits = value.replace(/\D/g, "").slice(0, 11);
|
|
702
|
+
return digits.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
|
703
|
+
}
|
|
704
|
+
function maskCNPJ(value) {
|
|
705
|
+
const digits = value.replace(/\D/g, "").slice(0, 14);
|
|
706
|
+
return digits.replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1/$2").replace(/(\d{4})(\d{1,2})$/, "$1-$2");
|
|
707
|
+
}
|
|
708
|
+
function maskPhone(value) {
|
|
709
|
+
const digits = value.replace(/\D/g, "").slice(0, 11);
|
|
710
|
+
if (digits.length <= 10) {
|
|
711
|
+
return digits.replace(/(\d{2})(\d)/, "($1) $2").replace(/(\d{4})(\d)/, "$1-$2");
|
|
712
|
+
}
|
|
713
|
+
return digits.replace(/(\d{2})(\d)/, "($1) $2").replace(/(\d{5})(\d)/, "$1-$2");
|
|
714
|
+
}
|
|
715
|
+
function maskCEP(value) {
|
|
716
|
+
const digits = value.replace(/\D/g, "").slice(0, 8);
|
|
717
|
+
return digits.replace(/(\d{5})(\d)/, "$1-$2");
|
|
718
|
+
}
|
|
719
|
+
function unmask(value) {
|
|
720
|
+
return value.replace(/\D/g, "");
|
|
721
|
+
}
|
|
722
|
+
function maskCurrency(value, prefix = "R$ ", decimalScale = 2) {
|
|
723
|
+
return prefix + value.toFixed(decimalScale).replace(".", ",").replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
724
|
+
}
|
|
725
|
+
function unmaskCurrency(value) {
|
|
726
|
+
const cleaned = value.replace(/[^\d,-]/g, "").replace(",", ".");
|
|
727
|
+
return parseFloat(cleaned) || 0;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// src/components/Input/InputCPF.tsx
|
|
731
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
732
|
+
var InputCPF = forwardRef11(
|
|
733
|
+
({ label, error, errorMessage, required, size, classContainer, classInput, value, onChange, disabled, name, ...props }, ref) => {
|
|
734
|
+
function handleChange(raw) {
|
|
735
|
+
const digits = unmask(raw);
|
|
736
|
+
onChange?.(digits);
|
|
737
|
+
}
|
|
738
|
+
return /* @__PURE__ */ jsx11(
|
|
739
|
+
InputWrapper,
|
|
740
|
+
{
|
|
741
|
+
label,
|
|
742
|
+
error,
|
|
743
|
+
errorMessage,
|
|
744
|
+
required,
|
|
745
|
+
disabled,
|
|
746
|
+
size,
|
|
747
|
+
classContainer,
|
|
748
|
+
htmlFor: name,
|
|
749
|
+
children: /* @__PURE__ */ jsx11(
|
|
750
|
+
"input",
|
|
751
|
+
{
|
|
752
|
+
ref,
|
|
753
|
+
id: name,
|
|
754
|
+
name,
|
|
755
|
+
type: "text",
|
|
756
|
+
inputMode: "numeric",
|
|
757
|
+
maxLength: 14,
|
|
758
|
+
placeholder: "000.000.000-00",
|
|
759
|
+
value: value ? maskCPF(value) : "",
|
|
760
|
+
onChange: (e) => handleChange(e.target.value),
|
|
761
|
+
disabled,
|
|
762
|
+
"aria-invalid": !!error,
|
|
763
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
764
|
+
...props
|
|
765
|
+
}
|
|
766
|
+
)
|
|
767
|
+
}
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
);
|
|
771
|
+
InputCPF.displayName = "InputCPF";
|
|
772
|
+
|
|
773
|
+
// src/components/Input/InputCNPJ.tsx
|
|
774
|
+
import { forwardRef as forwardRef12 } from "react";
|
|
775
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
776
|
+
var InputCNPJ = forwardRef12(
|
|
777
|
+
({ label, error, errorMessage, required, size, classContainer, classInput, value, onChange, disabled, name, ...props }, ref) => {
|
|
778
|
+
function handleChange(raw) {
|
|
779
|
+
const digits = unmask(raw);
|
|
780
|
+
onChange?.(digits);
|
|
781
|
+
}
|
|
782
|
+
return /* @__PURE__ */ jsx12(
|
|
783
|
+
InputWrapper,
|
|
784
|
+
{
|
|
785
|
+
label,
|
|
786
|
+
error,
|
|
787
|
+
errorMessage,
|
|
788
|
+
required,
|
|
789
|
+
disabled,
|
|
790
|
+
size,
|
|
791
|
+
classContainer,
|
|
792
|
+
htmlFor: name,
|
|
793
|
+
children: /* @__PURE__ */ jsx12(
|
|
794
|
+
"input",
|
|
795
|
+
{
|
|
796
|
+
ref,
|
|
797
|
+
id: name,
|
|
798
|
+
name,
|
|
799
|
+
type: "text",
|
|
800
|
+
inputMode: "numeric",
|
|
801
|
+
maxLength: 18,
|
|
802
|
+
placeholder: "00.000.000/0000-00",
|
|
803
|
+
value: value ? maskCNPJ(value) : "",
|
|
804
|
+
onChange: (e) => handleChange(e.target.value),
|
|
805
|
+
disabled,
|
|
806
|
+
"aria-invalid": !!error,
|
|
807
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
808
|
+
...props
|
|
809
|
+
}
|
|
810
|
+
)
|
|
811
|
+
}
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
InputCNPJ.displayName = "InputCNPJ";
|
|
816
|
+
|
|
817
|
+
// src/components/Input/InputPhone.tsx
|
|
818
|
+
import { forwardRef as forwardRef13 } from "react";
|
|
819
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
820
|
+
var InputPhone = forwardRef13(
|
|
821
|
+
({ label, error, errorMessage, required, size, classContainer, classInput, value, onChange, disabled, name, ...props }, ref) => {
|
|
822
|
+
function handleChange(raw) {
|
|
823
|
+
const digits = unmask(raw);
|
|
824
|
+
onChange?.(digits);
|
|
825
|
+
}
|
|
826
|
+
return /* @__PURE__ */ jsx13(
|
|
827
|
+
InputWrapper,
|
|
828
|
+
{
|
|
829
|
+
label,
|
|
830
|
+
error,
|
|
831
|
+
errorMessage,
|
|
832
|
+
required,
|
|
833
|
+
disabled,
|
|
834
|
+
size,
|
|
835
|
+
classContainer,
|
|
836
|
+
htmlFor: name,
|
|
837
|
+
children: /* @__PURE__ */ jsx13(
|
|
838
|
+
"input",
|
|
839
|
+
{
|
|
840
|
+
ref,
|
|
841
|
+
id: name,
|
|
842
|
+
name,
|
|
843
|
+
type: "tel",
|
|
844
|
+
inputMode: "numeric",
|
|
845
|
+
maxLength: 15,
|
|
846
|
+
placeholder: "(00) 00000-0000",
|
|
847
|
+
value: value ? maskPhone(value) : "",
|
|
848
|
+
onChange: (e) => handleChange(e.target.value),
|
|
849
|
+
disabled,
|
|
850
|
+
"aria-invalid": !!error,
|
|
851
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
852
|
+
...props
|
|
853
|
+
}
|
|
854
|
+
)
|
|
855
|
+
}
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
);
|
|
859
|
+
InputPhone.displayName = "InputPhone";
|
|
860
|
+
|
|
861
|
+
// src/components/Input/InputCurrency.tsx
|
|
862
|
+
import { forwardRef as forwardRef14 } from "react";
|
|
863
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
864
|
+
function formatCurrency(value, prefix, decimalScale) {
|
|
865
|
+
const fixed = Math.abs(value).toFixed(decimalScale);
|
|
866
|
+
const [intPart, decPart] = fixed.split(".");
|
|
867
|
+
const formatted = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
868
|
+
const sign = value < 0 ? "-" : "";
|
|
869
|
+
return `${sign}${prefix}${formatted},${decPart}`;
|
|
870
|
+
}
|
|
871
|
+
var InputCurrency = forwardRef14(
|
|
872
|
+
({ label, error, errorMessage, required, size, classContainer, classInput, value, onChange, disabled, name, prefix = "R$ ", decimalScale = 2, allowNegative = false, ...props }, ref) => {
|
|
873
|
+
function handleChange(e) {
|
|
874
|
+
const raw = e.target.value;
|
|
875
|
+
const num = unmaskCurrency(raw);
|
|
876
|
+
if (!allowNegative && num < 0) return;
|
|
877
|
+
onChange?.(isNaN(num) ? void 0 : num);
|
|
878
|
+
}
|
|
879
|
+
const displayValue = value !== void 0 && value !== null ? formatCurrency(value, prefix, decimalScale) : "";
|
|
880
|
+
return /* @__PURE__ */ jsx14(
|
|
881
|
+
InputWrapper,
|
|
882
|
+
{
|
|
883
|
+
label,
|
|
884
|
+
error,
|
|
885
|
+
errorMessage,
|
|
886
|
+
required,
|
|
887
|
+
disabled,
|
|
888
|
+
size,
|
|
889
|
+
classContainer,
|
|
890
|
+
htmlFor: name,
|
|
891
|
+
children: /* @__PURE__ */ jsx14(
|
|
892
|
+
"input",
|
|
893
|
+
{
|
|
894
|
+
ref,
|
|
895
|
+
id: name,
|
|
896
|
+
name,
|
|
897
|
+
type: "text",
|
|
898
|
+
inputMode: "decimal",
|
|
899
|
+
value: displayValue,
|
|
900
|
+
onChange: handleChange,
|
|
901
|
+
disabled,
|
|
902
|
+
"aria-invalid": !!error,
|
|
903
|
+
placeholder: `${prefix}0,${"0".repeat(decimalScale)}`,
|
|
904
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
905
|
+
...props
|
|
906
|
+
}
|
|
907
|
+
)
|
|
908
|
+
}
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
);
|
|
912
|
+
InputCurrency.displayName = "InputCurrency";
|
|
913
|
+
|
|
914
|
+
// src/components/Input/InputCep.tsx
|
|
915
|
+
import { forwardRef as forwardRef15 } from "react";
|
|
916
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
917
|
+
var InputCep = forwardRef15(
|
|
918
|
+
({ label, error, errorMessage, required, size, classContainer, classInput, value, onChange, disabled, name, ...props }, ref) => {
|
|
919
|
+
function handleChange(raw) {
|
|
920
|
+
const digits = unmask(raw);
|
|
921
|
+
onChange?.(digits);
|
|
922
|
+
}
|
|
923
|
+
return /* @__PURE__ */ jsx15(
|
|
924
|
+
InputWrapper,
|
|
925
|
+
{
|
|
926
|
+
label,
|
|
927
|
+
error,
|
|
928
|
+
errorMessage,
|
|
929
|
+
required,
|
|
930
|
+
disabled,
|
|
931
|
+
size,
|
|
932
|
+
classContainer,
|
|
933
|
+
htmlFor: name,
|
|
934
|
+
children: /* @__PURE__ */ jsx15(
|
|
935
|
+
"input",
|
|
936
|
+
{
|
|
937
|
+
ref,
|
|
938
|
+
id: name,
|
|
939
|
+
name,
|
|
940
|
+
type: "text",
|
|
941
|
+
inputMode: "numeric",
|
|
942
|
+
autoComplete: "postal-code",
|
|
943
|
+
maxLength: 9,
|
|
944
|
+
placeholder: "00000-000",
|
|
945
|
+
value: value ? maskCEP(value) : "",
|
|
946
|
+
onChange: (e) => handleChange(e.target.value),
|
|
947
|
+
disabled,
|
|
948
|
+
"aria-invalid": !!error,
|
|
949
|
+
className: `flex-1 min-w-0 h-full bg-transparent px-2.5 outline-none text-gray-900 placeholder:text-gray-400 disabled:cursor-not-allowed ${classInput ?? ""}`,
|
|
950
|
+
...props
|
|
951
|
+
}
|
|
952
|
+
)
|
|
953
|
+
}
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
);
|
|
957
|
+
InputCep.displayName = "InputCep";
|
|
958
|
+
|
|
959
|
+
// src/components/Input/InputCheckbox.tsx
|
|
960
|
+
import { forwardRef as forwardRef16 } from "react";
|
|
961
|
+
import { tv as tv7 } from "tailwind-variants";
|
|
962
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
963
|
+
var checkboxContainer = tv7({
|
|
964
|
+
base: "inline-flex items-center justify-center w-[18px] h-[18px] rounded border cursor-pointer transition-colors",
|
|
965
|
+
variants: {
|
|
966
|
+
checked: {
|
|
967
|
+
true: "bg-blue-600 border-blue-600",
|
|
968
|
+
false: "bg-white border-gray-300 hover:border-blue-500 hover:bg-blue-50"
|
|
969
|
+
},
|
|
970
|
+
disabled: {
|
|
971
|
+
true: "opacity-50 cursor-not-allowed"
|
|
972
|
+
},
|
|
973
|
+
error: {
|
|
974
|
+
true: "border-red-500"
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
defaultVariants: {
|
|
978
|
+
checked: false
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
var CheckIcon = () => /* @__PURE__ */ jsx16("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx16("polyline", { points: "20 6 9 17 4 12" }) });
|
|
982
|
+
var IndeterminateIcon = () => /* @__PURE__ */ jsx16("div", { className: "w-2 h-2 rounded-sm bg-gray-300" });
|
|
983
|
+
var InputCheckbox = forwardRef16(
|
|
984
|
+
({ label, checked = false, indeterminate = false, onChange, disabled, error, labelPosition = "right", className, name, required }, ref) => {
|
|
985
|
+
function handleClick() {
|
|
986
|
+
if (disabled) return;
|
|
987
|
+
onChange?.(!checked);
|
|
988
|
+
}
|
|
989
|
+
const box = /* @__PURE__ */ jsxs9(
|
|
990
|
+
"button",
|
|
991
|
+
{
|
|
992
|
+
ref,
|
|
993
|
+
type: "button",
|
|
994
|
+
role: "checkbox",
|
|
995
|
+
id: name,
|
|
996
|
+
"aria-checked": indeterminate ? "mixed" : checked,
|
|
997
|
+
"aria-required": required,
|
|
998
|
+
className: checkboxContainer({ checked: checked || indeterminate, disabled: !!disabled, error: !!error }),
|
|
999
|
+
onClick: handleClick,
|
|
1000
|
+
disabled,
|
|
1001
|
+
children: [
|
|
1002
|
+
checked && !indeterminate && /* @__PURE__ */ jsx16(CheckIcon, {}),
|
|
1003
|
+
indeterminate && /* @__PURE__ */ jsx16(IndeterminateIcon, {})
|
|
1004
|
+
]
|
|
1005
|
+
}
|
|
1006
|
+
);
|
|
1007
|
+
if (!label) return /* @__PURE__ */ jsx16("div", { className, children: box });
|
|
1008
|
+
return /* @__PURE__ */ jsxs9("div", { className: `flex items-center gap-2 ${className ?? ""}`, children: [
|
|
1009
|
+
labelPosition === "left" && /* @__PURE__ */ jsx16("label", { htmlFor: name, className: "text-sm text-gray-700 cursor-pointer select-none", children: label }),
|
|
1010
|
+
box,
|
|
1011
|
+
labelPosition === "right" && /* @__PURE__ */ jsx16("label", { htmlFor: name, className: "text-sm text-gray-700 cursor-pointer select-none", children: label }),
|
|
1012
|
+
required && /* @__PURE__ */ jsx16("span", { className: "text-red-500 text-[10px]", children: "*" })
|
|
1013
|
+
] });
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
InputCheckbox.displayName = "InputCheckbox";
|
|
1017
|
+
|
|
1018
|
+
// src/components/Input/InputRadio.tsx
|
|
1019
|
+
import { forwardRef as forwardRef17 } from "react";
|
|
1020
|
+
import { tv as tv8 } from "tailwind-variants";
|
|
1021
|
+
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1022
|
+
var radioButton = tv8({
|
|
1023
|
+
base: "inline-flex items-center justify-center w-[18px] h-[18px] rounded-full border cursor-pointer transition-colors",
|
|
1024
|
+
variants: {
|
|
1025
|
+
selected: {
|
|
1026
|
+
true: "border-blue-600",
|
|
1027
|
+
false: "border-gray-300 hover:border-blue-500 hover:bg-blue-50"
|
|
1028
|
+
},
|
|
1029
|
+
disabled: {
|
|
1030
|
+
true: "opacity-50 cursor-not-allowed"
|
|
1031
|
+
},
|
|
1032
|
+
error: {
|
|
1033
|
+
true: "border-red-500"
|
|
1034
|
+
}
|
|
1035
|
+
},
|
|
1036
|
+
defaultVariants: {
|
|
1037
|
+
selected: false
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
var InputRadio = forwardRef17(
|
|
1041
|
+
({ label, options, value, onChange, disabled, error, required, name, className, direction = "horizontal" }, ref) => {
|
|
1042
|
+
return /* @__PURE__ */ jsxs10("div", { ref, className: `flex w-full flex-col gap-1 ${className ?? ""}`, children: [
|
|
1043
|
+
label && /* @__PURE__ */ jsxs10("span", { className: "text-xs text-gray-700 flex items-start gap-0.5", children: [
|
|
1044
|
+
/* @__PURE__ */ jsx17("span", { children: label }),
|
|
1045
|
+
required && /* @__PURE__ */ jsx17("span", { className: "text-red-500 text-[10px] leading-none mt-0.5", children: "*" })
|
|
1046
|
+
] }),
|
|
1047
|
+
/* @__PURE__ */ jsx17(
|
|
1048
|
+
"div",
|
|
1049
|
+
{
|
|
1050
|
+
role: "radiogroup",
|
|
1051
|
+
"aria-label": label,
|
|
1052
|
+
className: `flex gap-3 ${direction === "vertical" ? "flex-col" : "items-center"}`,
|
|
1053
|
+
children: options.map((option) => {
|
|
1054
|
+
const isSelected = value === option.value;
|
|
1055
|
+
const isDisabled = disabled || option.disabled;
|
|
1056
|
+
return /* @__PURE__ */ jsxs10(
|
|
1057
|
+
"label",
|
|
1058
|
+
{
|
|
1059
|
+
className: `flex items-center gap-2 cursor-pointer select-none ${isDisabled ? "opacity-50 cursor-not-allowed" : ""}`,
|
|
1060
|
+
children: [
|
|
1061
|
+
/* @__PURE__ */ jsx17(
|
|
1062
|
+
"button",
|
|
1063
|
+
{
|
|
1064
|
+
type: "button",
|
|
1065
|
+
role: "radio",
|
|
1066
|
+
"aria-checked": isSelected,
|
|
1067
|
+
className: radioButton({ selected: isSelected, disabled: !!isDisabled, error: !!error }),
|
|
1068
|
+
onClick: () => !isDisabled && onChange?.(option.value),
|
|
1069
|
+
disabled: isDisabled,
|
|
1070
|
+
children: isSelected && /* @__PURE__ */ jsx17("div", { className: "w-[10px] h-[10px] rounded-full bg-blue-600" })
|
|
1071
|
+
}
|
|
1072
|
+
),
|
|
1073
|
+
/* @__PURE__ */ jsx17("span", { className: "text-sm text-gray-700", children: option.label })
|
|
1074
|
+
]
|
|
1075
|
+
},
|
|
1076
|
+
String(option.value)
|
|
1077
|
+
);
|
|
1078
|
+
})
|
|
1079
|
+
}
|
|
1080
|
+
),
|
|
1081
|
+
error && /* @__PURE__ */ jsx17("span", { className: "text-xs text-red-500 mt-0.5", children: "Selecione uma op\xE7\xE3o" })
|
|
1082
|
+
] });
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
1085
|
+
InputRadio.displayName = "InputRadio";
|
|
1086
|
+
|
|
1087
|
+
// src/components/Input/Textarea.tsx
|
|
1088
|
+
import { forwardRef as forwardRef18 } from "react";
|
|
1089
|
+
import { tv as tv9 } from "tailwind-variants";
|
|
1090
|
+
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1091
|
+
var textareaStyle = tv9({
|
|
1092
|
+
base: "w-full rounded-md border bg-white px-2.5 py-2 text-sm text-gray-900 outline-none placeholder:text-gray-400 resize-vertical transition-colors",
|
|
1093
|
+
variants: {
|
|
1094
|
+
error: {
|
|
1095
|
+
true: "border-red-500 focus:border-red-500 focus:ring-1 focus:ring-red-500",
|
|
1096
|
+
false: "border-gray-300 hover:border-gray-400 focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
|
|
1097
|
+
},
|
|
1098
|
+
disabled: {
|
|
1099
|
+
true: "opacity-50 cursor-not-allowed bg-gray-50"
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1102
|
+
defaultVariants: {
|
|
1103
|
+
error: false
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
var Textarea = forwardRef18(
|
|
1107
|
+
({ label, error, errorMessage, required, size, classInput, value, onChange, disabled, name, rows = 4, ...props }, ref) => {
|
|
1108
|
+
return /* @__PURE__ */ jsxs11("div", { className: "flex w-full flex-col gap-1", children: [
|
|
1109
|
+
label && /* @__PURE__ */ jsxs11("label", { htmlFor: name, className: "text-xs text-gray-700 flex items-start gap-0.5", children: [
|
|
1110
|
+
/* @__PURE__ */ jsx18("span", { children: label }),
|
|
1111
|
+
required && /* @__PURE__ */ jsx18("span", { className: "text-red-500 text-[10px] leading-none mt-0.5", children: "*" })
|
|
1112
|
+
] }),
|
|
1113
|
+
/* @__PURE__ */ jsx18(
|
|
1114
|
+
"textarea",
|
|
1115
|
+
{
|
|
1116
|
+
ref,
|
|
1117
|
+
id: name,
|
|
1118
|
+
name,
|
|
1119
|
+
rows,
|
|
1120
|
+
value: value ?? "",
|
|
1121
|
+
onChange: (e) => onChange?.(e.target.value),
|
|
1122
|
+
disabled,
|
|
1123
|
+
"aria-invalid": !!error,
|
|
1124
|
+
className: textareaStyle({ error: !!error, disabled: !!disabled, className: classInput }),
|
|
1125
|
+
...props
|
|
1126
|
+
}
|
|
1127
|
+
),
|
|
1128
|
+
error && errorMessage && /* @__PURE__ */ jsx18("span", { className: "text-xs text-red-500 mt-0.5", children: errorMessage })
|
|
1129
|
+
] });
|
|
1130
|
+
}
|
|
1131
|
+
);
|
|
1132
|
+
Textarea.displayName = "Textarea";
|
|
38
1133
|
export {
|
|
1134
|
+
Avatar,
|
|
39
1135
|
Button,
|
|
40
|
-
|
|
1136
|
+
Card,
|
|
1137
|
+
InputCNPJ,
|
|
1138
|
+
InputCPF,
|
|
1139
|
+
InputCep,
|
|
1140
|
+
InputCheckbox,
|
|
1141
|
+
InputCurrency,
|
|
1142
|
+
InputEmail,
|
|
1143
|
+
InputNumber,
|
|
1144
|
+
InputPassword,
|
|
1145
|
+
InputPhone,
|
|
1146
|
+
InputRadio,
|
|
1147
|
+
InputString,
|
|
1148
|
+
InputWrapper,
|
|
1149
|
+
Modal,
|
|
1150
|
+
Textarea,
|
|
1151
|
+
Tooltip,
|
|
1152
|
+
avatar,
|
|
1153
|
+
button,
|
|
1154
|
+
card,
|
|
1155
|
+
maskCEP,
|
|
1156
|
+
maskCNPJ,
|
|
1157
|
+
maskCPF,
|
|
1158
|
+
maskCurrency,
|
|
1159
|
+
maskPhone,
|
|
1160
|
+
modal,
|
|
1161
|
+
tooltip,
|
|
1162
|
+
unmask,
|
|
1163
|
+
unmaskCurrency
|
|
41
1164
|
};
|