@koaris/bloom-ui 1.2.2 → 1.2.4
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.cjs +1018 -363
- package/dist/index.d.cts +133 -24
- package/dist/index.d.ts +133 -24
- package/dist/index.mjs +1005 -362
- package/package.json +1 -1
- package/tailwind.css +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
1
|
// ../../node_modules/tailwind-merge/dist/bundle-mjs.mjs
|
|
34
2
|
var CLASS_PART_SEPARATOR = "-";
|
|
35
3
|
var createClassGroupUtils = (config) => {
|
|
@@ -58,7 +26,6 @@ var createClassGroupUtils = (config) => {
|
|
|
58
26
|
};
|
|
59
27
|
};
|
|
60
28
|
var getGroupRecursive = (classParts, classPartObject) => {
|
|
61
|
-
var _a;
|
|
62
29
|
if (classParts.length === 0) {
|
|
63
30
|
return classPartObject.classGroupId;
|
|
64
31
|
}
|
|
@@ -72,15 +39,15 @@ var getGroupRecursive = (classParts, classPartObject) => {
|
|
|
72
39
|
return void 0;
|
|
73
40
|
}
|
|
74
41
|
const classRest = classParts.join(CLASS_PART_SEPARATOR);
|
|
75
|
-
return
|
|
42
|
+
return classPartObject.validators.find(({
|
|
76
43
|
validator
|
|
77
|
-
}) => validator(classRest))
|
|
44
|
+
}) => validator(classRest))?.classGroupId;
|
|
78
45
|
};
|
|
79
46
|
var arbitraryPropertyRegex = /^\[(.+)\]$/;
|
|
80
47
|
var getGroupIdForArbitraryProperty = (className) => {
|
|
81
48
|
if (arbitraryPropertyRegex.test(className)) {
|
|
82
49
|
const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
|
|
83
|
-
const property = arbitraryPropertyClassName
|
|
50
|
+
const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(":"));
|
|
84
51
|
if (property) {
|
|
85
52
|
return "arbitrary.." + property;
|
|
86
53
|
}
|
|
@@ -265,10 +232,11 @@ var sortModifiers = (modifiers) => {
|
|
|
265
232
|
sortedModifiers.push(...unsortedModifiers.sort());
|
|
266
233
|
return sortedModifiers;
|
|
267
234
|
};
|
|
268
|
-
var createConfigUtils = (config) =>
|
|
235
|
+
var createConfigUtils = (config) => ({
|
|
269
236
|
cache: createLruCache(config.cacheSize),
|
|
270
|
-
parseClassName: createParseClassName(config)
|
|
271
|
-
|
|
237
|
+
parseClassName: createParseClassName(config),
|
|
238
|
+
...createClassGroupUtils(config)
|
|
239
|
+
});
|
|
272
240
|
var SPLIT_CLASSES_REGEX = /\s+/;
|
|
273
241
|
var mergeClassList = (classList, configUtils) => {
|
|
274
242
|
const {
|
|
@@ -2492,50 +2460,97 @@ var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
|
2492
2460
|
|
|
2493
2461
|
// src/components/Card/index.tsx
|
|
2494
2462
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2495
|
-
var Card = (
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2463
|
+
var Card = ({
|
|
2464
|
+
className,
|
|
2465
|
+
selected = false,
|
|
2466
|
+
direction = "row",
|
|
2467
|
+
size = "medium",
|
|
2468
|
+
disabled = false,
|
|
2469
|
+
image,
|
|
2470
|
+
imageSize = "100px",
|
|
2471
|
+
imageAlt = "",
|
|
2472
|
+
title,
|
|
2473
|
+
content,
|
|
2474
|
+
onClick,
|
|
2475
|
+
footer,
|
|
2476
|
+
hoverable = true,
|
|
2477
|
+
...rest
|
|
2478
|
+
}) => {
|
|
2479
|
+
const handleClick = () => {
|
|
2480
|
+
if (!disabled && onClick) {
|
|
2481
|
+
onClick();
|
|
2482
|
+
}
|
|
2483
|
+
};
|
|
2484
|
+
const cardSizeClasses = {
|
|
2485
|
+
small: "max-w-xs p-3",
|
|
2486
|
+
medium: "max-w-md p-4",
|
|
2487
|
+
large: "max-w-lg p-5",
|
|
2488
|
+
full: "w-full p-5"
|
|
2489
|
+
};
|
|
2513
2490
|
return /* @__PURE__ */ jsxs(
|
|
2514
2491
|
"div",
|
|
2515
2492
|
{
|
|
2516
2493
|
className: twMerge(
|
|
2517
|
-
"flex items-center
|
|
2518
|
-
"
|
|
2519
|
-
size
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2494
|
+
"flex items-center rounded-lg bg-neutral border border-neutral-500 text-neutral-1000 transition-all duration-200",
|
|
2495
|
+
direction === "col" ? "flex-col" : "flex-row",
|
|
2496
|
+
cardSizeClasses[size],
|
|
2497
|
+
hoverable && !disabled && "hover:shadow-md hover:shadow-neutral-500",
|
|
2498
|
+
selected && "border-2 border-orange-500",
|
|
2499
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
2500
|
+
onClick && !disabled && "cursor-pointer",
|
|
2524
2501
|
className
|
|
2525
2502
|
),
|
|
2526
|
-
onClick,
|
|
2503
|
+
onClick: handleClick,
|
|
2504
|
+
role: onClick && !disabled ? "button" : void 0,
|
|
2505
|
+
tabIndex: onClick && !disabled ? 0 : void 0,
|
|
2506
|
+
onKeyDown: (e) => {
|
|
2507
|
+
if ((e.key === "Enter" || e.key === " ") && onClick && !disabled) {
|
|
2508
|
+
e.preventDefault();
|
|
2509
|
+
onClick();
|
|
2510
|
+
}
|
|
2511
|
+
},
|
|
2512
|
+
"aria-disabled": disabled,
|
|
2513
|
+
...rest,
|
|
2527
2514
|
children: [
|
|
2528
|
-
/* @__PURE__ */ jsx(
|
|
2515
|
+
image && /* @__PURE__ */ jsx(
|
|
2516
|
+
"div",
|
|
2517
|
+
{
|
|
2518
|
+
className: twMerge(
|
|
2519
|
+
"flex-shrink-0",
|
|
2520
|
+
direction === "row" ? "mr-4" : "mb-4",
|
|
2521
|
+
size === "small" && direction === "row" ? "mr-3" : "",
|
|
2522
|
+
size === "small" && direction === "col" ? "mb-3" : ""
|
|
2523
|
+
),
|
|
2524
|
+
children: /* @__PURE__ */ jsx(
|
|
2525
|
+
"img",
|
|
2526
|
+
{
|
|
2527
|
+
src: image,
|
|
2528
|
+
alt: imageAlt,
|
|
2529
|
+
width: imageSize,
|
|
2530
|
+
height: "auto",
|
|
2531
|
+
className: "rounded object-cover"
|
|
2532
|
+
}
|
|
2533
|
+
)
|
|
2534
|
+
}
|
|
2535
|
+
),
|
|
2529
2536
|
/* @__PURE__ */ jsxs(
|
|
2530
|
-
"
|
|
2537
|
+
"div",
|
|
2531
2538
|
{
|
|
2532
2539
|
className: twMerge(
|
|
2533
|
-
|
|
2534
|
-
"
|
|
2540
|
+
"flex flex-col",
|
|
2541
|
+
direction === "col" && "text-center w-full",
|
|
2542
|
+
direction === "row" && "flex-1"
|
|
2535
2543
|
),
|
|
2536
2544
|
children: [
|
|
2537
|
-
/* @__PURE__ */ jsx("
|
|
2538
|
-
/* @__PURE__ */ jsx("
|
|
2545
|
+
title && /* @__PURE__ */ jsx("h3", { className: "text-xl font-bold font-default leading-tight mb-2", children: title }),
|
|
2546
|
+
content && /* @__PURE__ */ jsx("div", { className: twMerge(
|
|
2547
|
+
"text-base",
|
|
2548
|
+
direction === "col" ? "text-center" : "text-left"
|
|
2549
|
+
), children: content }),
|
|
2550
|
+
footer && /* @__PURE__ */ jsx("div", { className: twMerge(
|
|
2551
|
+
"mt-4 pt-3 border-t border-neutral-300",
|
|
2552
|
+
direction === "col" ? "text-center" : "text-left"
|
|
2553
|
+
), children: footer })
|
|
2539
2554
|
]
|
|
2540
2555
|
}
|
|
2541
2556
|
)
|
|
@@ -2543,74 +2558,132 @@ var Card = (_a) => {
|
|
|
2543
2558
|
}
|
|
2544
2559
|
);
|
|
2545
2560
|
};
|
|
2561
|
+
Card.displayName = "Card";
|
|
2546
2562
|
|
|
2547
2563
|
// src/components/Button/index.tsx
|
|
2548
|
-
import {
|
|
2549
|
-
|
|
2550
|
-
|
|
2564
|
+
import { forwardRef } from "react";
|
|
2565
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2566
|
+
var Button = forwardRef(
|
|
2567
|
+
({
|
|
2551
2568
|
className,
|
|
2552
2569
|
variant = "primary",
|
|
2553
2570
|
size = "md",
|
|
2554
|
-
disabled,
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2571
|
+
disabled = false,
|
|
2572
|
+
loading = false,
|
|
2573
|
+
startIcon,
|
|
2574
|
+
endIcon,
|
|
2575
|
+
fullWidth = false,
|
|
2576
|
+
onClick,
|
|
2577
|
+
children,
|
|
2578
|
+
...rest
|
|
2579
|
+
}, ref) => {
|
|
2580
|
+
const sizeClasses = {
|
|
2581
|
+
xs: "px-3 py-1 text-xs",
|
|
2582
|
+
sm: "px-5 py-1.5 text-sm",
|
|
2583
|
+
md: "px-6 py-2 text-md",
|
|
2584
|
+
lg: "px-8 py-3 text-lg"
|
|
2585
|
+
};
|
|
2586
|
+
const variantClasses = {
|
|
2587
|
+
primary: "bg-orange-500 text-neutral hover:bg-orange-700 focus:ring-orange-500",
|
|
2588
|
+
secondary: "bg-neutral text-orange-500 border border-orange-500 hover:text-neutral hover:bg-orange-500 focus:ring-orange-500",
|
|
2589
|
+
outline: "bg-transparent text-orange-500 border border-orange-500 hover:bg-orange-50 focus:ring-orange-500",
|
|
2590
|
+
ghost: "bg-transparent text-orange-500 hover:bg-orange-50 focus:ring-orange-500",
|
|
2591
|
+
link: "bg-transparent text-orange-500 hover:underline p-0 h-auto shadow-none focus:ring-0"
|
|
2592
|
+
};
|
|
2593
|
+
const handleClick = (e) => {
|
|
2594
|
+
if (loading || disabled) return;
|
|
2595
|
+
onClick?.(e);
|
|
2596
|
+
};
|
|
2597
|
+
return /* @__PURE__ */ jsxs2(
|
|
2598
|
+
"button",
|
|
2599
|
+
{
|
|
2600
|
+
ref,
|
|
2601
|
+
className: twMerge(
|
|
2602
|
+
"relative font-medium rounded-sm transition-all duration-200",
|
|
2603
|
+
"focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-opacity-50",
|
|
2604
|
+
variantClasses[variant],
|
|
2605
|
+
sizeClasses[size],
|
|
2606
|
+
fullWidth ? "w-full" : "max-w-[180px]",
|
|
2607
|
+
"inline-flex items-center justify-center gap-2",
|
|
2608
|
+
(disabled || loading) && "opacity-50 cursor-not-allowed hover:shadow-none hover:bg-opacity-100",
|
|
2609
|
+
className
|
|
2610
|
+
),
|
|
2611
|
+
onClick: handleClick,
|
|
2612
|
+
disabled: disabled || loading,
|
|
2613
|
+
...rest,
|
|
2614
|
+
children: [
|
|
2615
|
+
loading && /* @__PURE__ */ jsx2("span", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxs2(
|
|
2616
|
+
"svg",
|
|
2617
|
+
{
|
|
2618
|
+
className: "animate-spin h-5 w-5",
|
|
2619
|
+
viewBox: "0 0 24 24",
|
|
2620
|
+
fill: "none",
|
|
2621
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2622
|
+
children: [
|
|
2623
|
+
/* @__PURE__ */ jsx2(
|
|
2624
|
+
"circle",
|
|
2625
|
+
{
|
|
2626
|
+
className: "opacity-25",
|
|
2627
|
+
cx: "12",
|
|
2628
|
+
cy: "12",
|
|
2629
|
+
r: "10",
|
|
2630
|
+
stroke: "currentColor",
|
|
2631
|
+
strokeWidth: "4"
|
|
2632
|
+
}
|
|
2633
|
+
),
|
|
2634
|
+
/* @__PURE__ */ jsx2(
|
|
2635
|
+
"path",
|
|
2636
|
+
{
|
|
2637
|
+
className: "opacity-75",
|
|
2638
|
+
fill: "currentColor",
|
|
2639
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
2640
|
+
}
|
|
2641
|
+
)
|
|
2642
|
+
]
|
|
2643
|
+
}
|
|
2644
|
+
) }),
|
|
2645
|
+
/* @__PURE__ */ jsxs2("span", { className: loading ? "invisible" : "flex items-center gap-2", children: [
|
|
2646
|
+
startIcon && /* @__PURE__ */ jsx2("span", { className: "mr-1", children: startIcon }),
|
|
2647
|
+
children,
|
|
2648
|
+
endIcon && /* @__PURE__ */ jsx2("span", { className: "ml-1", children: endIcon })
|
|
2649
|
+
] })
|
|
2650
|
+
]
|
|
2651
|
+
}
|
|
2652
|
+
);
|
|
2653
|
+
}
|
|
2654
|
+
);
|
|
2655
|
+
Button.displayName = "Button";
|
|
2579
2656
|
|
|
2580
2657
|
// src/components/Link/index.tsx
|
|
2581
2658
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
2582
|
-
var Link = (
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
"className",
|
|
2591
|
-
"disabled",
|
|
2592
|
-
"url",
|
|
2593
|
-
"newPage",
|
|
2594
|
-
"onClick"
|
|
2595
|
-
]);
|
|
2659
|
+
var Link = ({
|
|
2660
|
+
className,
|
|
2661
|
+
disabled,
|
|
2662
|
+
url,
|
|
2663
|
+
newPage = true,
|
|
2664
|
+
onClick,
|
|
2665
|
+
...rest
|
|
2666
|
+
}) => {
|
|
2596
2667
|
return /* @__PURE__ */ jsx3(
|
|
2597
2668
|
"a",
|
|
2598
|
-
|
|
2669
|
+
{
|
|
2599
2670
|
className: twMerge(
|
|
2600
2671
|
"text-blue-800 font-bold",
|
|
2601
2672
|
typeof rest.children !== "string" && "px-4",
|
|
2602
2673
|
disabled === true && "opacity-50 cursor-not-allowed",
|
|
2603
2674
|
className
|
|
2604
2675
|
),
|
|
2605
|
-
href: url
|
|
2606
|
-
|
|
2676
|
+
href: url,
|
|
2677
|
+
...newPage && { target: "_blank", rel: "noopener noreferrer" },
|
|
2678
|
+
...rest
|
|
2679
|
+
}
|
|
2607
2680
|
);
|
|
2608
2681
|
};
|
|
2609
2682
|
|
|
2610
2683
|
// src/components/RadioGroup/index.tsx
|
|
2611
2684
|
import { useState } from "react";
|
|
2612
2685
|
import { FiCheck } from "react-icons/fi";
|
|
2613
|
-
import { jsx as jsx4, jsxs as
|
|
2686
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2614
2687
|
var RadioGroup = ({
|
|
2615
2688
|
disabled,
|
|
2616
2689
|
options = [
|
|
@@ -2624,8 +2697,8 @@ var RadioGroup = ({
|
|
|
2624
2697
|
const handleOptionChange = (value) => {
|
|
2625
2698
|
setSelectedOption(value);
|
|
2626
2699
|
};
|
|
2627
|
-
return /* @__PURE__ */ jsx4("div", { className: "flex flex-col ", children: options.map((option) => /* @__PURE__ */
|
|
2628
|
-
/* @__PURE__ */
|
|
2700
|
+
return /* @__PURE__ */ jsx4("div", { className: "flex flex-col ", children: options.map((option) => /* @__PURE__ */ jsxs3("div", { className: "flex py-2 items-center", children: [
|
|
2701
|
+
/* @__PURE__ */ jsxs3(
|
|
2629
2702
|
"label",
|
|
2630
2703
|
{
|
|
2631
2704
|
htmlFor: `radio${option.id}`,
|
|
@@ -2661,13 +2734,13 @@ var RadioGroup = ({
|
|
|
2661
2734
|
// src/components/Checkbox/index.tsx
|
|
2662
2735
|
import { useState as useState2 } from "react";
|
|
2663
2736
|
import { FiCheck as FiCheck2 } from "react-icons/fi";
|
|
2664
|
-
import { jsx as jsx5, jsxs as
|
|
2737
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2665
2738
|
var Checkbox = ({ className, required, disabled }) => {
|
|
2666
2739
|
const [selected, setSelected] = useState2(false);
|
|
2667
2740
|
const handleCheckboxChange = (value) => {
|
|
2668
2741
|
setSelected(!value);
|
|
2669
2742
|
};
|
|
2670
|
-
return /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center", children: /* @__PURE__ */
|
|
2743
|
+
return /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxs4(
|
|
2671
2744
|
"label",
|
|
2672
2745
|
{
|
|
2673
2746
|
className: twMerge(
|
|
@@ -2701,179 +2774,302 @@ var Checkbox = ({ className, required, disabled }) => {
|
|
|
2701
2774
|
import {
|
|
2702
2775
|
useEffect,
|
|
2703
2776
|
useState as useState3,
|
|
2704
|
-
forwardRef
|
|
2777
|
+
forwardRef as forwardRef2
|
|
2705
2778
|
} from "react";
|
|
2706
2779
|
import { FiCheck as FiCheck3, FiX } from "react-icons/fi";
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
password: [/^(?=.*[!@#$%^&*])/, /(?=.*[0-9])/, /.{8,}$/],
|
|
2711
|
-
date: [/\d/, /\d/, "/", /\d/, /\d/, "/", /\d/, /\d/, /\d/, /\d/],
|
|
2712
|
-
cpf: [
|
|
2713
|
-
/\d/,
|
|
2714
|
-
/\d/,
|
|
2715
|
-
/\d/,
|
|
2716
|
-
".",
|
|
2717
|
-
/\d/,
|
|
2718
|
-
/\d/,
|
|
2719
|
-
/\d/,
|
|
2720
|
-
".",
|
|
2721
|
-
/\d/,
|
|
2722
|
-
/\d/,
|
|
2723
|
-
/\d/,
|
|
2724
|
-
"-",
|
|
2725
|
-
/\d/,
|
|
2726
|
-
/\d/
|
|
2727
|
-
],
|
|
2728
|
-
cnpj: [
|
|
2729
|
-
/\d/,
|
|
2730
|
-
/\d/,
|
|
2731
|
-
".",
|
|
2732
|
-
/\d/,
|
|
2733
|
-
/\d/,
|
|
2734
|
-
/\d/,
|
|
2735
|
-
".",
|
|
2736
|
-
/\d/,
|
|
2737
|
-
/\d/,
|
|
2738
|
-
/\d/,
|
|
2739
|
-
"/",
|
|
2740
|
-
/\d/,
|
|
2741
|
-
/\d/,
|
|
2742
|
-
/\d/,
|
|
2743
|
-
/\d/,
|
|
2744
|
-
"-",
|
|
2745
|
-
/\d/,
|
|
2746
|
-
/\d/
|
|
2747
|
-
],
|
|
2748
|
-
cep: [/\d/, /\d/, /\d/, /\d/, /\d/, "-", /\d/, /\d/, /\d/],
|
|
2749
|
-
phone: [
|
|
2750
|
-
"(",
|
|
2751
|
-
/[1-9]/,
|
|
2752
|
-
/[1-9]/,
|
|
2753
|
-
")",
|
|
2754
|
-
" ",
|
|
2755
|
-
/\d/,
|
|
2756
|
-
/\d/,
|
|
2757
|
-
/\d/,
|
|
2758
|
-
/\d/,
|
|
2759
|
-
/\d/,
|
|
2760
|
-
"-",
|
|
2761
|
-
/\d/,
|
|
2762
|
-
/\d/,
|
|
2763
|
-
/\d/,
|
|
2764
|
-
/\d/
|
|
2765
|
-
]
|
|
2780
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2781
|
+
var passwordMask = {
|
|
2782
|
+
password: [/^(?=.*[!@#$%^&*])/, /(?=.*[0-9])/, /.{8,}$/]
|
|
2766
2783
|
};
|
|
2767
|
-
var
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2784
|
+
var phoneFormats = {
|
|
2785
|
+
"BR": { countryCode: "+55", format: "($1) $2-$3" },
|
|
2786
|
+
"US": { countryCode: "+1", format: "($1) $2-$3" },
|
|
2787
|
+
"UK": { countryCode: "+44", format: "$1 $2 $3" },
|
|
2788
|
+
"DE": { countryCode: "+49", format: "$1 $2 $3" },
|
|
2789
|
+
"FR": { countryCode: "+33", format: "$1 $2 $3 $4" }
|
|
2790
|
+
// Add more countries as needed
|
|
2791
|
+
};
|
|
2792
|
+
var Input = forwardRef2(
|
|
2793
|
+
({
|
|
2794
|
+
className,
|
|
2795
|
+
disabled,
|
|
2796
|
+
placeholder,
|
|
2797
|
+
value,
|
|
2798
|
+
validated,
|
|
2799
|
+
error,
|
|
2800
|
+
required,
|
|
2801
|
+
type,
|
|
2802
|
+
onClick,
|
|
2803
|
+
errorMessage,
|
|
2804
|
+
onChange: externalOnChange,
|
|
2805
|
+
label,
|
|
2806
|
+
helperText,
|
|
2807
|
+
id,
|
|
2808
|
+
countryCode = "BR",
|
|
2809
|
+
// Default to Brazil
|
|
2810
|
+
...rest
|
|
2811
|
+
}, ref) => {
|
|
2794
2812
|
const [selected, setSelected] = useState3(false);
|
|
2795
|
-
const [inputValue, setInputValue] = useState3(value);
|
|
2796
|
-
const [
|
|
2797
|
-
|
|
2798
|
-
|
|
2813
|
+
const [inputValue, setInputValue] = useState3(value || "");
|
|
2814
|
+
const [passwordValidation, setPasswordValidation] = useState3({
|
|
2815
|
+
hasEightCharacters: false,
|
|
2816
|
+
hasSpecialCharacters: false,
|
|
2817
|
+
hasNumber: false
|
|
2818
|
+
});
|
|
2819
|
+
const [isValid, setIsValid] = useState3(false);
|
|
2799
2820
|
const handleFocus = () => {
|
|
2800
|
-
setSelected(
|
|
2821
|
+
setSelected(true);
|
|
2801
2822
|
};
|
|
2802
2823
|
const handleBlur = () => {
|
|
2803
2824
|
setSelected(false);
|
|
2825
|
+
validateInput(inputValue || "");
|
|
2826
|
+
};
|
|
2827
|
+
const applyMask = (value2, type2) => {
|
|
2828
|
+
let result = value2;
|
|
2829
|
+
switch (type2) {
|
|
2830
|
+
case "date":
|
|
2831
|
+
result = value2.replace(/\D/g, "");
|
|
2832
|
+
if (result.length > 8) result = result.substring(0, 8);
|
|
2833
|
+
if (result.length > 4) result = result.replace(/(\d{2})(\d{2})(\d+)/, "$1/$2/$3");
|
|
2834
|
+
else if (result.length > 2) result = result.replace(/(\d{2})(\d+)/, "$1/$2");
|
|
2835
|
+
break;
|
|
2836
|
+
case "cpf":
|
|
2837
|
+
result = value2.replace(/\D/g, "");
|
|
2838
|
+
if (result.length > 11) result = result.substring(0, 11);
|
|
2839
|
+
if (result.length > 9) result = result.replace(/(\d{3})(\d{3})(\d{3})(\d+)/, "$1.$2.$3-$4");
|
|
2840
|
+
else if (result.length > 6) result = result.replace(/(\d{3})(\d{3})(\d+)/, "$1.$2.$3");
|
|
2841
|
+
else if (result.length > 3) result = result.replace(/(\d{3})(\d+)/, "$1.$2");
|
|
2842
|
+
break;
|
|
2843
|
+
case "cnpj":
|
|
2844
|
+
result = value2.replace(/\D/g, "");
|
|
2845
|
+
if (result.length > 14) result = result.substring(0, 14);
|
|
2846
|
+
if (result.length > 12)
|
|
2847
|
+
result = result.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d+)/, "$1.$2.$3/$4-$5");
|
|
2848
|
+
else if (result.length > 8)
|
|
2849
|
+
result = result.replace(/(\d{2})(\d{3})(\d{3})(\d+)/, "$1.$2.$3/$4");
|
|
2850
|
+
else if (result.length > 5)
|
|
2851
|
+
result = result.replace(/(\d{2})(\d{3})(\d+)/, "$1.$2.$3");
|
|
2852
|
+
else if (result.length > 2)
|
|
2853
|
+
result = result.replace(/(\d{2})(\d+)/, "$1.$2");
|
|
2854
|
+
break;
|
|
2855
|
+
case "cep":
|
|
2856
|
+
result = value2.replace(/\D/g, "");
|
|
2857
|
+
if (result.length > 8) result = result.substring(0, 8);
|
|
2858
|
+
if (result.length > 5) result = result.replace(/(\d{5})(\d+)/, "$1-$2");
|
|
2859
|
+
break;
|
|
2860
|
+
case "phone":
|
|
2861
|
+
result = applyPhoneMask(value2, countryCode);
|
|
2862
|
+
break;
|
|
2863
|
+
case "email":
|
|
2864
|
+
result = value2.trim();
|
|
2865
|
+
break;
|
|
2866
|
+
default:
|
|
2867
|
+
break;
|
|
2868
|
+
}
|
|
2869
|
+
return result;
|
|
2870
|
+
};
|
|
2871
|
+
const applyPhoneMask = (value2, countryCode2) => {
|
|
2872
|
+
let digits = value2.replace(/\D/g, "");
|
|
2873
|
+
const format = phoneFormats[countryCode2] || phoneFormats["BR"];
|
|
2874
|
+
switch (countryCode2) {
|
|
2875
|
+
case "BR":
|
|
2876
|
+
if (digits.length > 11) digits = digits.substring(0, 11);
|
|
2877
|
+
if (digits.length > 10)
|
|
2878
|
+
return digits.replace(/(\d{2})(\d{5})(\d+)/, "($1) $2-$3");
|
|
2879
|
+
else if (digits.length > 6)
|
|
2880
|
+
return digits.replace(/(\d{2})(\d{4})(\d+)/, "($1) $2-$3");
|
|
2881
|
+
else if (digits.length > 2)
|
|
2882
|
+
return digits.replace(/(\d{2})(\d+)/, "($1) $2");
|
|
2883
|
+
return digits;
|
|
2884
|
+
case "US":
|
|
2885
|
+
if (digits.length > 10) digits = digits.substring(0, 10);
|
|
2886
|
+
if (digits.length > 6)
|
|
2887
|
+
return digits.replace(/(\d{3})(\d{3})(\d+)/, "($1) $2-$3");
|
|
2888
|
+
else if (digits.length > 3)
|
|
2889
|
+
return digits.replace(/(\d{3})(\d+)/, "($1) $2");
|
|
2890
|
+
return digits;
|
|
2891
|
+
case "UK":
|
|
2892
|
+
if (digits.length > 10) digits = digits.substring(0, 10);
|
|
2893
|
+
if (digits.length > 7)
|
|
2894
|
+
return digits.replace(/(\d{3})(\d{3})(\d+)/, "$1 $2 $3");
|
|
2895
|
+
else if (digits.length > 3)
|
|
2896
|
+
return digits.replace(/(\d{3})(\d+)/, "$1 $2");
|
|
2897
|
+
return digits;
|
|
2898
|
+
default:
|
|
2899
|
+
if (digits.length > 10) digits = digits.substring(0, 10);
|
|
2900
|
+
if (digits.length > 6)
|
|
2901
|
+
return digits.replace(/(\d{3})(\d{3})(\d+)/, "$1 $2 $3");
|
|
2902
|
+
else if (digits.length > 3)
|
|
2903
|
+
return digits.replace(/(\d{3})(\d+)/, "$1 $2");
|
|
2904
|
+
return digits;
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
const validateInput = (value2) => {
|
|
2908
|
+
if (!value2) return false;
|
|
2909
|
+
let valid = false;
|
|
2910
|
+
switch (type) {
|
|
2911
|
+
case "password":
|
|
2912
|
+
valid = passwordValidation.hasEightCharacters && passwordValidation.hasSpecialCharacters && passwordValidation.hasNumber;
|
|
2913
|
+
break;
|
|
2914
|
+
case "date":
|
|
2915
|
+
valid = /^\d{2}\/\d{2}\/\d{4}$/.test(value2);
|
|
2916
|
+
break;
|
|
2917
|
+
case "cpf":
|
|
2918
|
+
valid = /^\d{3}\.\d{3}\.\d{3}-\d{2}$/.test(value2);
|
|
2919
|
+
break;
|
|
2920
|
+
case "cnpj":
|
|
2921
|
+
valid = /^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/.test(value2);
|
|
2922
|
+
break;
|
|
2923
|
+
case "cep":
|
|
2924
|
+
valid = /^\d{5}-\d{3}$/.test(value2);
|
|
2925
|
+
break;
|
|
2926
|
+
case "phone":
|
|
2927
|
+
if (countryCode === "BR") {
|
|
2928
|
+
valid = /^\(\d{2}\) \d{5}-\d{4}$/.test(value2) || /^\(\d{2}\) \d{4}-\d{4}$/.test(value2);
|
|
2929
|
+
} else if (countryCode === "US") {
|
|
2930
|
+
valid = /^\(\d{3}\) \d{3}-\d{4}$/.test(value2);
|
|
2931
|
+
} else {
|
|
2932
|
+
valid = /^[\d\s()-]{8,}$/.test(value2);
|
|
2933
|
+
}
|
|
2934
|
+
break;
|
|
2935
|
+
case "email":
|
|
2936
|
+
valid = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value2);
|
|
2937
|
+
break;
|
|
2938
|
+
default:
|
|
2939
|
+
valid = value2.length > 0;
|
|
2940
|
+
break;
|
|
2941
|
+
}
|
|
2942
|
+
setIsValid(valid);
|
|
2943
|
+
return valid;
|
|
2804
2944
|
};
|
|
2805
2945
|
const handleInput = (event) => {
|
|
2806
|
-
|
|
2807
|
-
|
|
2946
|
+
let newValue = event.currentTarget.value;
|
|
2947
|
+
if (["date", "cpf", "phone", "cnpj", "cep", "email"].includes(type)) {
|
|
2948
|
+
newValue = applyMask(newValue, type);
|
|
2949
|
+
}
|
|
2950
|
+
const newEvent = {
|
|
2951
|
+
...event,
|
|
2952
|
+
currentTarget: {
|
|
2953
|
+
...event.currentTarget,
|
|
2954
|
+
value: newValue
|
|
2955
|
+
},
|
|
2956
|
+
target: {
|
|
2957
|
+
...event.target,
|
|
2958
|
+
value: newValue
|
|
2959
|
+
}
|
|
2960
|
+
};
|
|
2961
|
+
setInputValue(newValue);
|
|
2962
|
+
if (type === "password") {
|
|
2963
|
+
checkPassword(newValue);
|
|
2964
|
+
} else {
|
|
2965
|
+
validateInput(newValue);
|
|
2966
|
+
}
|
|
2967
|
+
externalOnChange?.(newEvent);
|
|
2808
2968
|
};
|
|
2809
2969
|
useEffect(() => {
|
|
2810
|
-
setInputValue(value);
|
|
2811
|
-
|
|
2970
|
+
setInputValue(value || "");
|
|
2971
|
+
if (value && type === "password") {
|
|
2972
|
+
checkPassword(value);
|
|
2973
|
+
} else if (value) {
|
|
2974
|
+
validateInput(value);
|
|
2975
|
+
}
|
|
2976
|
+
}, [value, type]);
|
|
2812
2977
|
const checkPassword = (value2) => {
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2978
|
+
const validationResult = {
|
|
2979
|
+
hasEightCharacters: value2?.match(passwordMask.password[2]) !== null,
|
|
2980
|
+
hasSpecialCharacters: value2?.match(passwordMask.password[0]) !== null,
|
|
2981
|
+
hasNumber: value2?.match(passwordMask.password[1]) !== null
|
|
2982
|
+
};
|
|
2983
|
+
setPasswordValidation(validationResult);
|
|
2984
|
+
setIsValid(
|
|
2985
|
+
validationResult.hasEightCharacters && validationResult.hasSpecialCharacters && validationResult.hasNumber
|
|
2986
|
+
);
|
|
2816
2987
|
};
|
|
2817
|
-
|
|
2818
|
-
|
|
2988
|
+
const getInputType = () => {
|
|
2989
|
+
switch (type) {
|
|
2990
|
+
case "password":
|
|
2991
|
+
return "password";
|
|
2992
|
+
case "email":
|
|
2993
|
+
return "email";
|
|
2994
|
+
case "date":
|
|
2995
|
+
case "cpf":
|
|
2996
|
+
case "phone":
|
|
2997
|
+
case "cnpj":
|
|
2998
|
+
case "cep":
|
|
2999
|
+
return "text";
|
|
3000
|
+
default:
|
|
3001
|
+
return "text";
|
|
3002
|
+
}
|
|
3003
|
+
};
|
|
3004
|
+
const renderPhonePrefix = () => {
|
|
3005
|
+
if (type !== "phone") return null;
|
|
3006
|
+
const format = phoneFormats[countryCode] || phoneFormats["BR"];
|
|
3007
|
+
return /* @__PURE__ */ jsx6("span", { className: "absolute left-2 top-2.5 text-gray-500", children: format.countryCode });
|
|
3008
|
+
};
|
|
3009
|
+
const inputClasses = twMerge(
|
|
3010
|
+
"flex items-center justify-center border-2 border-neutral rounded-sm w-full px-3 py-2 text-md hover:shadow-md hover:shadow-neutral-500 focus:outline-none transition-all duration-200",
|
|
3011
|
+
className,
|
|
3012
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
3013
|
+
selected && "border-2 border-orange-500",
|
|
3014
|
+
validated && isValid && "border-2 border-green-900",
|
|
3015
|
+
error && "border-2 border-red-900",
|
|
3016
|
+
type === "phone" && "pl-10"
|
|
3017
|
+
);
|
|
3018
|
+
const renderPasswordValidation = () => {
|
|
3019
|
+
if (type !== "password") return null;
|
|
3020
|
+
return /* @__PURE__ */ jsxs5("ul", { className: "py-1 text-sm", role: "list", children: [
|
|
3021
|
+
/* @__PURE__ */ jsxs5("li", { className: "flex items-center px-2", role: "listitem", children: [
|
|
3022
|
+
passwordValidation.hasEightCharacters ? /* @__PURE__ */ jsx6(FiCheck3, { className: "text-green-500" }) : /* @__PURE__ */ jsx6(FiX, { className: "text-red-500" }),
|
|
3023
|
+
/* @__PURE__ */ jsx6("span", { className: "px-1", children: "Pelo menos 8 caracteres" })
|
|
3024
|
+
] }),
|
|
3025
|
+
/* @__PURE__ */ jsxs5("li", { className: "flex items-center px-2", role: "listitem", children: [
|
|
3026
|
+
passwordValidation.hasSpecialCharacters ? /* @__PURE__ */ jsx6(FiCheck3, { className: "text-green-500" }) : /* @__PURE__ */ jsx6(FiX, { className: "text-red-500" }),
|
|
3027
|
+
/* @__PURE__ */ jsx6("span", { className: "px-1", children: "Pelo menos 1 s\xEDmbolo (@, !, $, etc)" })
|
|
3028
|
+
] }),
|
|
3029
|
+
/* @__PURE__ */ jsxs5("li", { className: "flex items-center px-2", role: "listitem", children: [
|
|
3030
|
+
passwordValidation.hasNumber ? /* @__PURE__ */ jsx6(FiCheck3, { className: "text-green-500" }) : /* @__PURE__ */ jsx6(FiX, { className: "text-red-500" }),
|
|
3031
|
+
/* @__PURE__ */ jsx6("span", { className: "px-1", children: "Deve conter 1 n\xFAmero" })
|
|
3032
|
+
] })
|
|
3033
|
+
] });
|
|
3034
|
+
};
|
|
3035
|
+
return /* @__PURE__ */ jsxs5("div", { className: "w-full", children: [
|
|
3036
|
+
label && /* @__PURE__ */ jsxs5(
|
|
3037
|
+
"label",
|
|
3038
|
+
{
|
|
3039
|
+
htmlFor: id,
|
|
3040
|
+
className: "block text-sm font-medium text-gray-700 mb-1",
|
|
3041
|
+
children: [
|
|
3042
|
+
label,
|
|
3043
|
+
required && /* @__PURE__ */ jsx6("span", { className: "text-red-500 ml-1", children: "*" })
|
|
3044
|
+
]
|
|
3045
|
+
}
|
|
3046
|
+
),
|
|
3047
|
+
/* @__PURE__ */ jsxs5("div", { className: "relative", children: [
|
|
3048
|
+
renderPhonePrefix(),
|
|
2819
3049
|
/* @__PURE__ */ jsx6(
|
|
2820
3050
|
"input",
|
|
2821
|
-
|
|
2822
|
-
type,
|
|
3051
|
+
{
|
|
3052
|
+
type: getInputType(),
|
|
2823
3053
|
required,
|
|
3054
|
+
disabled,
|
|
2824
3055
|
ref,
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
className,
|
|
2828
|
-
disabled === true && "opacity-50 cursor-not-allowed",
|
|
2829
|
-
selected === true && "border-2 border-orange-500",
|
|
2830
|
-
validated === true && "border-2 border-green-900",
|
|
2831
|
-
error === true && "border-2 border-red-900"
|
|
2832
|
-
),
|
|
3056
|
+
id,
|
|
3057
|
+
className: inputClasses,
|
|
2833
3058
|
onClick,
|
|
2834
3059
|
onFocus: handleFocus,
|
|
2835
3060
|
onChange: handleInput,
|
|
2836
3061
|
onBlur: handleBlur,
|
|
2837
3062
|
placeholder,
|
|
2838
|
-
value: inputValue
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
/* @__PURE__ */ jsx6("span", { className: "px-1", children: "Pelo menos 1 s\xEDmbolo (@, !, $, etc)" })
|
|
2849
|
-
] }),
|
|
2850
|
-
/* @__PURE__ */ jsxs4("li", { className: "flex items-center px-2", children: [
|
|
2851
|
-
hasNumber ? /* @__PURE__ */ jsx6(FiCheck3, {}) : /* @__PURE__ */ jsx6(FiX, {}),
|
|
2852
|
-
/* @__PURE__ */ jsx6("span", { className: "px-1", children: "Deve conter 1 n\xFAmero" })
|
|
2853
|
-
] })
|
|
2854
|
-
] })
|
|
2855
|
-
] }) : /* @__PURE__ */ jsx6(
|
|
2856
|
-
"input",
|
|
2857
|
-
__spreadValues({
|
|
2858
|
-
type,
|
|
2859
|
-
required,
|
|
2860
|
-
ref,
|
|
2861
|
-
className: twMerge(
|
|
2862
|
-
"flex items-center justify-center border-2 border-neutral rounded-sm w-full px-3 py-2 text-md hover:shadow-md hover:shadow-neutral-500 focus:outline-none",
|
|
2863
|
-
className,
|
|
2864
|
-
disabled === true && "opacity-50 cursor-not-allowed",
|
|
2865
|
-
selected === true && "border-2 border-orange-500",
|
|
2866
|
-
error === true && "border-2 border-red-900"
|
|
2867
|
-
),
|
|
2868
|
-
onClick,
|
|
2869
|
-
onFocus: handleFocus,
|
|
2870
|
-
onChange: handleInput,
|
|
2871
|
-
onBlur: handleBlur,
|
|
2872
|
-
placeholder,
|
|
2873
|
-
value: inputValue
|
|
2874
|
-
}, rest)
|
|
2875
|
-
),
|
|
2876
|
-
error === true && /* @__PURE__ */ jsx6("label", { htmlFor: rest.id, className: "text-red-900", children: "Campo inv\xE1lido." })
|
|
3063
|
+
value: inputValue,
|
|
3064
|
+
"aria-invalid": error,
|
|
3065
|
+
"aria-describedby": error ? `${id}-error` : helperText ? `${id}-helper` : void 0,
|
|
3066
|
+
...rest
|
|
3067
|
+
}
|
|
3068
|
+
)
|
|
3069
|
+
] }),
|
|
3070
|
+
renderPasswordValidation(),
|
|
3071
|
+
error && /* @__PURE__ */ jsx6("p", { id: `${id}-error`, className: "mt-1 text-sm text-red-900", role: "alert", children: errorMessage || "Invalid field." }),
|
|
3072
|
+
helperText && !error && /* @__PURE__ */ jsx6("p", { id: `${id}-helper`, className: "mt-1 text-sm text-gray-500", children: helperText })
|
|
2877
3073
|
] });
|
|
2878
3074
|
}
|
|
2879
3075
|
);
|
|
@@ -2883,32 +3079,22 @@ Input.displayName = "Input";
|
|
|
2883
3079
|
import {
|
|
2884
3080
|
useEffect as useEffect2,
|
|
2885
3081
|
useState as useState4,
|
|
2886
|
-
forwardRef as
|
|
3082
|
+
forwardRef as forwardRef3
|
|
2887
3083
|
} from "react";
|
|
2888
|
-
import { jsx as jsx7, jsxs as
|
|
2889
|
-
var TextInput =
|
|
2890
|
-
(
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
"className",
|
|
2903
|
-
"disabled",
|
|
2904
|
-
"value",
|
|
2905
|
-
"prefix",
|
|
2906
|
-
"placeholder",
|
|
2907
|
-
"error",
|
|
2908
|
-
"type",
|
|
2909
|
-
"variant",
|
|
2910
|
-
"onClick"
|
|
2911
|
-
]);
|
|
3084
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3085
|
+
var TextInput = forwardRef3(
|
|
3086
|
+
({
|
|
3087
|
+
className,
|
|
3088
|
+
disabled,
|
|
3089
|
+
value,
|
|
3090
|
+
prefix,
|
|
3091
|
+
placeholder,
|
|
3092
|
+
error,
|
|
3093
|
+
type = "text",
|
|
3094
|
+
variant = "primary",
|
|
3095
|
+
onClick,
|
|
3096
|
+
...rest
|
|
3097
|
+
}, ref) => {
|
|
2912
3098
|
const [selected, setSelected] = useState4(false);
|
|
2913
3099
|
const [inputValue, setInputValue] = useState4(value);
|
|
2914
3100
|
const handleFocus = () => {
|
|
@@ -2923,7 +3109,7 @@ var TextInput = forwardRef2(
|
|
|
2923
3109
|
useEffect2(() => {
|
|
2924
3110
|
setInputValue(value);
|
|
2925
3111
|
}, [value]);
|
|
2926
|
-
return /* @__PURE__ */
|
|
3112
|
+
return /* @__PURE__ */ jsxs6(
|
|
2927
3113
|
"div",
|
|
2928
3114
|
{
|
|
2929
3115
|
className: twMerge(
|
|
@@ -2938,7 +3124,7 @@ var TextInput = forwardRef2(
|
|
|
2938
3124
|
!!prefix && /* @__PURE__ */ jsx7("span", { className: "text-neutral-500 sm:text-sm", children: prefix }),
|
|
2939
3125
|
/* @__PURE__ */ jsx7(
|
|
2940
3126
|
"input",
|
|
2941
|
-
|
|
3127
|
+
{
|
|
2942
3128
|
type,
|
|
2943
3129
|
required: rest.required,
|
|
2944
3130
|
onClick,
|
|
@@ -2955,8 +3141,9 @@ var TextInput = forwardRef2(
|
|
|
2955
3141
|
disabled === true && "cursor-not-allowed",
|
|
2956
3142
|
variant === "secondary" && "bg-neutral-800 text-neutral",
|
|
2957
3143
|
className
|
|
2958
|
-
)
|
|
2959
|
-
|
|
3144
|
+
),
|
|
3145
|
+
...rest
|
|
3146
|
+
}
|
|
2960
3147
|
)
|
|
2961
3148
|
]
|
|
2962
3149
|
}
|
|
@@ -2971,28 +3158,18 @@ import {
|
|
|
2971
3158
|
useState as useState5
|
|
2972
3159
|
} from "react";
|
|
2973
3160
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
2974
|
-
var TextArea = (
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
"className",
|
|
2987
|
-
"disabled",
|
|
2988
|
-
"reference",
|
|
2989
|
-
"value",
|
|
2990
|
-
"error",
|
|
2991
|
-
"required",
|
|
2992
|
-
"placeholder",
|
|
2993
|
-
"resize",
|
|
2994
|
-
"onClick"
|
|
2995
|
-
]);
|
|
3161
|
+
var TextArea = ({
|
|
3162
|
+
className,
|
|
3163
|
+
disabled,
|
|
3164
|
+
reference,
|
|
3165
|
+
value,
|
|
3166
|
+
error,
|
|
3167
|
+
required,
|
|
3168
|
+
placeholder,
|
|
3169
|
+
resize,
|
|
3170
|
+
onClick,
|
|
3171
|
+
...rest
|
|
3172
|
+
}) => {
|
|
2996
3173
|
const [selected, setSelected] = useState5(false);
|
|
2997
3174
|
const [inputValue, setInputValue] = useState5(value);
|
|
2998
3175
|
const handleFocus = () => {
|
|
@@ -3009,7 +3186,7 @@ var TextArea = (_a) => {
|
|
|
3009
3186
|
}, [value]);
|
|
3010
3187
|
return /* @__PURE__ */ jsx8(
|
|
3011
3188
|
"textarea",
|
|
3012
|
-
|
|
3189
|
+
{
|
|
3013
3190
|
required,
|
|
3014
3191
|
ref: reference,
|
|
3015
3192
|
disabled,
|
|
@@ -3027,27 +3204,22 @@ var TextArea = (_a) => {
|
|
|
3027
3204
|
onChange: handleInput,
|
|
3028
3205
|
onBlur: handleBlur,
|
|
3029
3206
|
placeholder,
|
|
3030
|
-
value: inputValue
|
|
3031
|
-
|
|
3207
|
+
value: inputValue,
|
|
3208
|
+
...rest
|
|
3209
|
+
}
|
|
3032
3210
|
);
|
|
3033
3211
|
};
|
|
3034
3212
|
|
|
3035
3213
|
// src/components/Text/index.tsx
|
|
3036
3214
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
3037
|
-
var Text = (
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
"children",
|
|
3046
|
-
"color",
|
|
3047
|
-
"size",
|
|
3048
|
-
"tag",
|
|
3049
|
-
"className"
|
|
3050
|
-
]);
|
|
3215
|
+
var Text = ({
|
|
3216
|
+
children,
|
|
3217
|
+
color = "neutral-800",
|
|
3218
|
+
size = "md",
|
|
3219
|
+
tag = "p",
|
|
3220
|
+
className,
|
|
3221
|
+
...rest
|
|
3222
|
+
}) => {
|
|
3051
3223
|
const fontSize = {
|
|
3052
3224
|
xxs: "text-xxs",
|
|
3053
3225
|
xs: "text-xs",
|
|
@@ -3065,7 +3237,7 @@ var Text = (_a) => {
|
|
|
3065
3237
|
"9xl": "text-9xl"
|
|
3066
3238
|
}[size];
|
|
3067
3239
|
const Tag = tag;
|
|
3068
|
-
return /* @__PURE__ */ jsx9(Tag,
|
|
3240
|
+
return /* @__PURE__ */ jsx9(Tag, { ...rest, className: twMerge(`text-${color} ${fontSize}`, className), children });
|
|
3069
3241
|
};
|
|
3070
3242
|
|
|
3071
3243
|
// src/components/Heading/index.tsx
|
|
@@ -3120,39 +3292,33 @@ var Box = ({
|
|
|
3120
3292
|
|
|
3121
3293
|
// src/components/Form/index.tsx
|
|
3122
3294
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
3123
|
-
var Form = (
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
"className",
|
|
3131
|
-
"children",
|
|
3132
|
-
"variant",
|
|
3133
|
-
"orientation"
|
|
3134
|
-
]);
|
|
3295
|
+
var Form = ({
|
|
3296
|
+
className,
|
|
3297
|
+
children,
|
|
3298
|
+
variant = "secondary",
|
|
3299
|
+
orientation = "row",
|
|
3300
|
+
...rest
|
|
3301
|
+
}) => {
|
|
3135
3302
|
return /* @__PURE__ */ jsx12(
|
|
3136
3303
|
"form",
|
|
3137
|
-
|
|
3304
|
+
{
|
|
3138
3305
|
className: twMerge(
|
|
3139
3306
|
"flex flex-row gap-2 p-6 rounded-md border-2",
|
|
3140
3307
|
variant === "primary" && "text-neutral-800 bg-neutral-200 border-neutral-300",
|
|
3141
3308
|
variant === "secondary" && "text-neutral-200 bg-neutral-600 border-neutral-800",
|
|
3142
3309
|
orientation === "col" && "flex-col",
|
|
3143
3310
|
className
|
|
3144
|
-
)
|
|
3145
|
-
|
|
3311
|
+
),
|
|
3312
|
+
...rest,
|
|
3146
3313
|
children
|
|
3147
|
-
}
|
|
3314
|
+
}
|
|
3148
3315
|
);
|
|
3149
3316
|
};
|
|
3150
3317
|
|
|
3151
3318
|
// src/components/Avatar/index.tsx
|
|
3152
3319
|
import { FaUser } from "react-icons/fa";
|
|
3153
3320
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
3154
|
-
var Avatar = (
|
|
3155
|
-
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
3321
|
+
var Avatar = ({ className, ...rest }) => {
|
|
3156
3322
|
return /* @__PURE__ */ jsx13(
|
|
3157
3323
|
"div",
|
|
3158
3324
|
{
|
|
@@ -3162,15 +3328,15 @@ var Avatar = (_a) => {
|
|
|
3162
3328
|
bg-neutral-600 justify-center`,
|
|
3163
3329
|
className
|
|
3164
3330
|
),
|
|
3165
|
-
children: rest.src ? /* @__PURE__ */ jsx13("img",
|
|
3331
|
+
children: rest.src ? /* @__PURE__ */ jsx13("img", { className: "w-full h-full object-cover rounded-full", ...rest }) : /* @__PURE__ */ jsx13(FaUser, { color: "#FFFFFF", size: 24 })
|
|
3166
3332
|
}
|
|
3167
3333
|
);
|
|
3168
3334
|
};
|
|
3169
3335
|
|
|
3170
3336
|
// src/components/MultiStep/index.tsx
|
|
3171
|
-
import { jsx as jsx14, jsxs as
|
|
3337
|
+
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3172
3338
|
var MultiStep = ({ className, size, currentStep }) => {
|
|
3173
|
-
return /* @__PURE__ */
|
|
3339
|
+
return /* @__PURE__ */ jsxs7("div", { className: "w-full", children: [
|
|
3174
3340
|
/* @__PURE__ */ jsx14(Text, { tag: "label", color: "neutral-100", size: "xs", children: `Passo ${currentStep} de ${size}` }),
|
|
3175
3341
|
/* @__PURE__ */ jsx14("div", { className: `grid gap-2 grid-cols-${size} grid-flow-col mt-1`, children: Array.from(Array(size).keys()).map((_, index) => {
|
|
3176
3342
|
return /* @__PURE__ */ jsx14(
|
|
@@ -3187,6 +3353,474 @@ var MultiStep = ({ className, size, currentStep }) => {
|
|
|
3187
3353
|
}) })
|
|
3188
3354
|
] });
|
|
3189
3355
|
};
|
|
3356
|
+
|
|
3357
|
+
// src/components/Toggle/index.tsx
|
|
3358
|
+
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3359
|
+
var Toggle = ({
|
|
3360
|
+
className,
|
|
3361
|
+
disabled,
|
|
3362
|
+
active,
|
|
3363
|
+
label,
|
|
3364
|
+
setActive,
|
|
3365
|
+
size = "md",
|
|
3366
|
+
hideLabel = false,
|
|
3367
|
+
id,
|
|
3368
|
+
...rest
|
|
3369
|
+
}) => {
|
|
3370
|
+
const toggleId = id || `toggle-${Math.random().toString(36).substring(2, 9)}`;
|
|
3371
|
+
const sizeClasses = {
|
|
3372
|
+
sm: {
|
|
3373
|
+
toggle: "h-5 w-9",
|
|
3374
|
+
knob: "h-3 w-3",
|
|
3375
|
+
translate: active ? "translate-x-5" : "translate-x-1"
|
|
3376
|
+
},
|
|
3377
|
+
md: {
|
|
3378
|
+
toggle: "h-6 w-11",
|
|
3379
|
+
knob: "h-4 w-4",
|
|
3380
|
+
translate: active ? "translate-x-6" : "translate-x-1"
|
|
3381
|
+
},
|
|
3382
|
+
lg: {
|
|
3383
|
+
toggle: "h-7 w-14",
|
|
3384
|
+
knob: "h-5 w-5",
|
|
3385
|
+
translate: active ? "translate-x-8" : "translate-x-1"
|
|
3386
|
+
}
|
|
3387
|
+
};
|
|
3388
|
+
const selectedSize = sizeClasses[size];
|
|
3389
|
+
const handleKeyDown = (e) => {
|
|
3390
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3391
|
+
e.preventDefault();
|
|
3392
|
+
if (!disabled) {
|
|
3393
|
+
setActive(!active);
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
};
|
|
3397
|
+
return /* @__PURE__ */ jsxs8(
|
|
3398
|
+
"div",
|
|
3399
|
+
{
|
|
3400
|
+
className: twMerge("flex items-center gap-3", className),
|
|
3401
|
+
...rest,
|
|
3402
|
+
children: [
|
|
3403
|
+
/* @__PURE__ */ jsx15(
|
|
3404
|
+
"button",
|
|
3405
|
+
{
|
|
3406
|
+
type: "button",
|
|
3407
|
+
role: "switch",
|
|
3408
|
+
"aria-checked": active,
|
|
3409
|
+
"aria-labelledby": hideLabel ? void 0 : `${toggleId}-label`,
|
|
3410
|
+
"aria-label": hideLabel ? label : void 0,
|
|
3411
|
+
id: toggleId,
|
|
3412
|
+
disabled,
|
|
3413
|
+
onClick: () => setActive(!active),
|
|
3414
|
+
onKeyDown: handleKeyDown,
|
|
3415
|
+
className: twMerge(`
|
|
3416
|
+
relative inline-flex items-center rounded-full
|
|
3417
|
+
${selectedSize.toggle}
|
|
3418
|
+
${active ? "bg-blue-600" : "bg-gray-300 dark:bg-gray-600"}
|
|
3419
|
+
${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
3420
|
+
transition-colors duration-300 ease-in-out
|
|
3421
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2
|
|
3422
|
+
`),
|
|
3423
|
+
children: /* @__PURE__ */ jsx15("span", { className: `
|
|
3424
|
+
inline-block transform rounded-full bg-white shadow-md
|
|
3425
|
+
${selectedSize.knob}
|
|
3426
|
+
${selectedSize.translate}
|
|
3427
|
+
transition-transform duration-300 ease-in-out
|
|
3428
|
+
` })
|
|
3429
|
+
}
|
|
3430
|
+
),
|
|
3431
|
+
!hideLabel && /* @__PURE__ */ jsx15(
|
|
3432
|
+
"label",
|
|
3433
|
+
{
|
|
3434
|
+
id: `${toggleId}-label`,
|
|
3435
|
+
htmlFor: toggleId,
|
|
3436
|
+
className: `text-sm font-medium text-gray-700 dark:text-gray-300 ${disabled ? "opacity-50" : ""}`,
|
|
3437
|
+
children: label
|
|
3438
|
+
}
|
|
3439
|
+
)
|
|
3440
|
+
]
|
|
3441
|
+
}
|
|
3442
|
+
);
|
|
3443
|
+
};
|
|
3444
|
+
|
|
3445
|
+
// src/components/Skeleton/index.tsx
|
|
3446
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
3447
|
+
var Skeleton = ({
|
|
3448
|
+
width = "full",
|
|
3449
|
+
height = "16",
|
|
3450
|
+
rounded = false,
|
|
3451
|
+
circle = false,
|
|
3452
|
+
animate = true,
|
|
3453
|
+
className
|
|
3454
|
+
}) => {
|
|
3455
|
+
const widthClass = typeof width === "string" ? width.includes("px") || width.includes("%") || width.includes("rem") || width.includes("em") ? `w-[${width}]` : `w-${width}` : `w-[${width}px]`;
|
|
3456
|
+
const heightClass = typeof height === "string" ? height.includes("px") || height.includes("%") || height.includes("rem") || height.includes("em") ? `h-[${height}]` : `h-${height}` : `h-[${height}px]`;
|
|
3457
|
+
const safeWidthClass = widthClass.includes("[") ? "w-full" : widthClass;
|
|
3458
|
+
const safeHeightClass = heightClass.includes("[") ? "h-16" : heightClass;
|
|
3459
|
+
return /* @__PURE__ */ jsx16(
|
|
3460
|
+
"div",
|
|
3461
|
+
{
|
|
3462
|
+
className: twMerge(
|
|
3463
|
+
"bg-gray-200",
|
|
3464
|
+
safeWidthClass,
|
|
3465
|
+
safeHeightClass,
|
|
3466
|
+
rounded && !circle && "rounded-md",
|
|
3467
|
+
circle && "rounded-full",
|
|
3468
|
+
animate && "animate-pulse",
|
|
3469
|
+
className
|
|
3470
|
+
),
|
|
3471
|
+
"aria-hidden": "true"
|
|
3472
|
+
}
|
|
3473
|
+
);
|
|
3474
|
+
};
|
|
3475
|
+
Skeleton.displayName = "Skeleton";
|
|
3476
|
+
|
|
3477
|
+
// src/components/Loading/index.tsx
|
|
3478
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3479
|
+
var Loading = ({
|
|
3480
|
+
size = "md",
|
|
3481
|
+
color = "primary",
|
|
3482
|
+
withText = false,
|
|
3483
|
+
text = "Loading...",
|
|
3484
|
+
centered = false,
|
|
3485
|
+
className
|
|
3486
|
+
}) => {
|
|
3487
|
+
const sizeClasses = {
|
|
3488
|
+
xs: "h-4 w-4",
|
|
3489
|
+
sm: "h-6 w-6",
|
|
3490
|
+
md: "h-8 w-8",
|
|
3491
|
+
lg: "h-12 w-12"
|
|
3492
|
+
};
|
|
3493
|
+
const colorClasses = {
|
|
3494
|
+
primary: "text-orange-500",
|
|
3495
|
+
secondary: "text-neutral",
|
|
3496
|
+
white: "text-white",
|
|
3497
|
+
black: "text-black",
|
|
3498
|
+
gray: "text-gray-400"
|
|
3499
|
+
};
|
|
3500
|
+
const textSizeClasses = {
|
|
3501
|
+
xs: "text-xs",
|
|
3502
|
+
sm: "text-sm",
|
|
3503
|
+
md: "text-base",
|
|
3504
|
+
lg: "text-lg"
|
|
3505
|
+
};
|
|
3506
|
+
return /* @__PURE__ */ jsxs9(
|
|
3507
|
+
"div",
|
|
3508
|
+
{
|
|
3509
|
+
className: twMerge(
|
|
3510
|
+
"inline-flex items-center",
|
|
3511
|
+
centered && "justify-center",
|
|
3512
|
+
className
|
|
3513
|
+
),
|
|
3514
|
+
role: "status",
|
|
3515
|
+
children: [
|
|
3516
|
+
/* @__PURE__ */ jsxs9(
|
|
3517
|
+
"svg",
|
|
3518
|
+
{
|
|
3519
|
+
className: twMerge(
|
|
3520
|
+
"animate-spin",
|
|
3521
|
+
sizeClasses[size],
|
|
3522
|
+
colorClasses[color]
|
|
3523
|
+
),
|
|
3524
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3525
|
+
fill: "none",
|
|
3526
|
+
viewBox: "0 0 24 24",
|
|
3527
|
+
children: [
|
|
3528
|
+
/* @__PURE__ */ jsx17(
|
|
3529
|
+
"circle",
|
|
3530
|
+
{
|
|
3531
|
+
className: "opacity-25",
|
|
3532
|
+
cx: "12",
|
|
3533
|
+
cy: "12",
|
|
3534
|
+
r: "10",
|
|
3535
|
+
stroke: "currentColor",
|
|
3536
|
+
strokeWidth: "4"
|
|
3537
|
+
}
|
|
3538
|
+
),
|
|
3539
|
+
/* @__PURE__ */ jsx17(
|
|
3540
|
+
"path",
|
|
3541
|
+
{
|
|
3542
|
+
className: "opacity-75",
|
|
3543
|
+
fill: "currentColor",
|
|
3544
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
3545
|
+
}
|
|
3546
|
+
)
|
|
3547
|
+
]
|
|
3548
|
+
}
|
|
3549
|
+
),
|
|
3550
|
+
withText && /* @__PURE__ */ jsx17("span", { className: twMerge(
|
|
3551
|
+
"ml-3",
|
|
3552
|
+
textSizeClasses[size],
|
|
3553
|
+
colorClasses[color]
|
|
3554
|
+
), children: text }),
|
|
3555
|
+
/* @__PURE__ */ jsx17("span", { className: "sr-only", children: "Loading" })
|
|
3556
|
+
]
|
|
3557
|
+
}
|
|
3558
|
+
);
|
|
3559
|
+
};
|
|
3560
|
+
Loading.displayName = "Loading";
|
|
3561
|
+
|
|
3562
|
+
// src/components/Modal/index.tsx
|
|
3563
|
+
import { useEffect as useEffect4, useState as useState6, useRef } from "react";
|
|
3564
|
+
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3565
|
+
var Modal = ({
|
|
3566
|
+
className,
|
|
3567
|
+
isOpen,
|
|
3568
|
+
onClose,
|
|
3569
|
+
title,
|
|
3570
|
+
size = "md",
|
|
3571
|
+
children,
|
|
3572
|
+
showCloseButton = true,
|
|
3573
|
+
closeOnOutsideClick = true,
|
|
3574
|
+
closeOnEsc = true,
|
|
3575
|
+
footer,
|
|
3576
|
+
...rest
|
|
3577
|
+
}) => {
|
|
3578
|
+
const modalRef = useRef(null);
|
|
3579
|
+
const portalRoot = useRef(null);
|
|
3580
|
+
const [mounted, setMounted] = useState6(false);
|
|
3581
|
+
useEffect4(() => {
|
|
3582
|
+
portalRoot.current = document.createElement("div");
|
|
3583
|
+
portalRoot.current.id = "bloom-ui-portal-root";
|
|
3584
|
+
document.body.appendChild(portalRoot.current);
|
|
3585
|
+
setMounted(true);
|
|
3586
|
+
return () => {
|
|
3587
|
+
portalRoot.current?.remove();
|
|
3588
|
+
document.body.style.overflow = "";
|
|
3589
|
+
};
|
|
3590
|
+
}, []);
|
|
3591
|
+
useEffect4(() => {
|
|
3592
|
+
if (isOpen) {
|
|
3593
|
+
document.body.style.overflow = "hidden";
|
|
3594
|
+
} else {
|
|
3595
|
+
document.body.style.overflow = "";
|
|
3596
|
+
}
|
|
3597
|
+
}, [isOpen]);
|
|
3598
|
+
useEffect4(() => {
|
|
3599
|
+
const handleKeyDown = (e) => {
|
|
3600
|
+
if (isOpen && closeOnEsc && e.key === "Escape") onClose();
|
|
3601
|
+
};
|
|
3602
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
3603
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
3604
|
+
}, [isOpen, onClose, closeOnEsc]);
|
|
3605
|
+
const handleBackdropClick = (e) => {
|
|
3606
|
+
if (closeOnOutsideClick && modalRef.current && !modalRef.current.contains(e.target)) {
|
|
3607
|
+
onClose();
|
|
3608
|
+
}
|
|
3609
|
+
};
|
|
3610
|
+
const sizeClasses = {
|
|
3611
|
+
sm: "max-w-sm",
|
|
3612
|
+
md: "max-w-md",
|
|
3613
|
+
lg: "max-w-lg",
|
|
3614
|
+
xl: "max-w-xl"
|
|
3615
|
+
};
|
|
3616
|
+
if (!isOpen || !mounted || !portalRoot.current) return null;
|
|
3617
|
+
return /* @__PURE__ */ jsx18(
|
|
3618
|
+
"div",
|
|
3619
|
+
{
|
|
3620
|
+
className: "fixed inset-0 z-50 flex items-center justify-center p-4 bg-black bg-opacity-50 transition-opacity duration-300",
|
|
3621
|
+
onClick: handleBackdropClick,
|
|
3622
|
+
"aria-modal": "true",
|
|
3623
|
+
role: "dialog",
|
|
3624
|
+
...rest,
|
|
3625
|
+
children: /* @__PURE__ */ jsxs10(
|
|
3626
|
+
"div",
|
|
3627
|
+
{
|
|
3628
|
+
ref: modalRef,
|
|
3629
|
+
className: twMerge(
|
|
3630
|
+
`relative bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full
|
|
3631
|
+
${sizeClasses[size]} opacity-100 scale-100
|
|
3632
|
+
transition-all duration-300 ease-in-out`,
|
|
3633
|
+
className
|
|
3634
|
+
),
|
|
3635
|
+
children: [
|
|
3636
|
+
(title || showCloseButton) && /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700", children: [
|
|
3637
|
+
title && /* @__PURE__ */ jsx18("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100", children: title }),
|
|
3638
|
+
showCloseButton && /* @__PURE__ */ jsx18(
|
|
3639
|
+
"button",
|
|
3640
|
+
{
|
|
3641
|
+
type: "button",
|
|
3642
|
+
"aria-label": "Close modal",
|
|
3643
|
+
onClick: onClose,
|
|
3644
|
+
className: "p-1 text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 rounded-full",
|
|
3645
|
+
children: /* @__PURE__ */ jsx18("svg", { className: "h-5 w-5", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx18("path", { fillRule: "evenodd", d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z", clipRule: "evenodd" }) })
|
|
3646
|
+
}
|
|
3647
|
+
)
|
|
3648
|
+
] }),
|
|
3649
|
+
/* @__PURE__ */ jsx18("div", { className: "px-6 py-4 max-h-[70vh] overflow-y-auto", children }),
|
|
3650
|
+
footer && /* @__PURE__ */ jsx18("div", { className: "px-6 py-4 border-t border-gray-200 dark:border-gray-700", children: footer })
|
|
3651
|
+
]
|
|
3652
|
+
}
|
|
3653
|
+
)
|
|
3654
|
+
}
|
|
3655
|
+
);
|
|
3656
|
+
};
|
|
3657
|
+
|
|
3658
|
+
// src/components/Toast/index.tsx
|
|
3659
|
+
import { useEffect as useEffect5, useState as useState7, useRef as useRef2 } from "react";
|
|
3660
|
+
import { Fragment, jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3661
|
+
var ToastService = class _ToastService {
|
|
3662
|
+
constructor() {
|
|
3663
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
3664
|
+
this.toasts = [];
|
|
3665
|
+
}
|
|
3666
|
+
static getInstance() {
|
|
3667
|
+
if (!_ToastService.instance) {
|
|
3668
|
+
_ToastService.instance = new _ToastService();
|
|
3669
|
+
}
|
|
3670
|
+
return _ToastService.instance;
|
|
3671
|
+
}
|
|
3672
|
+
subscribe(listener) {
|
|
3673
|
+
this.listeners.add(listener);
|
|
3674
|
+
return () => {
|
|
3675
|
+
this.listeners.delete(listener);
|
|
3676
|
+
};
|
|
3677
|
+
}
|
|
3678
|
+
notify() {
|
|
3679
|
+
this.listeners.forEach((listener) => listener([...this.toasts]));
|
|
3680
|
+
}
|
|
3681
|
+
showToast(toast) {
|
|
3682
|
+
const id = `toast-${Date.now()}`;
|
|
3683
|
+
this.toasts.push({
|
|
3684
|
+
...toast,
|
|
3685
|
+
id,
|
|
3686
|
+
onDismiss: (toastId) => this.hideToast(toastId)
|
|
3687
|
+
});
|
|
3688
|
+
this.notify();
|
|
3689
|
+
return id;
|
|
3690
|
+
}
|
|
3691
|
+
hideToast(id) {
|
|
3692
|
+
this.toasts = this.toasts.filter((toast) => toast.id !== id);
|
|
3693
|
+
this.notify();
|
|
3694
|
+
}
|
|
3695
|
+
clearToasts() {
|
|
3696
|
+
this.toasts = [];
|
|
3697
|
+
this.notify();
|
|
3698
|
+
}
|
|
3699
|
+
getToasts() {
|
|
3700
|
+
return [...this.toasts];
|
|
3701
|
+
}
|
|
3702
|
+
};
|
|
3703
|
+
var toastService = ToastService.getInstance();
|
|
3704
|
+
var Toast = ({
|
|
3705
|
+
id,
|
|
3706
|
+
message,
|
|
3707
|
+
title,
|
|
3708
|
+
variant = "info",
|
|
3709
|
+
duration = 5e3,
|
|
3710
|
+
showCloseButton = true,
|
|
3711
|
+
onDismiss,
|
|
3712
|
+
className
|
|
3713
|
+
}) => {
|
|
3714
|
+
const [isRemoving, setIsRemoving] = useState7(false);
|
|
3715
|
+
const timerRef = useRef2();
|
|
3716
|
+
const handleDismiss = () => {
|
|
3717
|
+
setIsRemoving(true);
|
|
3718
|
+
setTimeout(() => onDismiss?.(id), 300);
|
|
3719
|
+
};
|
|
3720
|
+
useEffect5(() => {
|
|
3721
|
+
if (duration > 0) {
|
|
3722
|
+
timerRef.current = window.setTimeout(handleDismiss, duration);
|
|
3723
|
+
}
|
|
3724
|
+
return () => window.clearTimeout(timerRef.current);
|
|
3725
|
+
}, [duration]);
|
|
3726
|
+
const variantStyles = {
|
|
3727
|
+
success: "bg-green-100 border-green-500 text-green-800",
|
|
3728
|
+
error: "bg-red-100 border-red-500 text-red-800",
|
|
3729
|
+
warning: "bg-yellow-100 border-yellow-500 text-yellow-800",
|
|
3730
|
+
info: "bg-blue-100 border-blue-500 text-blue-800"
|
|
3731
|
+
};
|
|
3732
|
+
const icons = {
|
|
3733
|
+
success: /* @__PURE__ */ jsx19("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx19("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z", clipRule: "evenodd" }) }),
|
|
3734
|
+
error: /* @__PURE__ */ jsx19("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx19("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z", clipRule: "evenodd" }) }),
|
|
3735
|
+
warning: /* @__PURE__ */ jsx19("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx19("path", { fillRule: "evenodd", d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) }),
|
|
3736
|
+
info: /* @__PURE__ */ jsx19("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx19("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) })
|
|
3737
|
+
};
|
|
3738
|
+
return /* @__PURE__ */ jsxs11(
|
|
3739
|
+
"div",
|
|
3740
|
+
{
|
|
3741
|
+
className: twMerge(
|
|
3742
|
+
"flex items-start p-4 mb-3 w-full max-w-xs rounded-md shadow-md border-l-4 transform transition-all duration-300",
|
|
3743
|
+
variantStyles[variant],
|
|
3744
|
+
isRemoving ? "translate-x-full opacity-0" : "translate-x-0 opacity-100",
|
|
3745
|
+
className
|
|
3746
|
+
),
|
|
3747
|
+
role: "alert",
|
|
3748
|
+
children: [
|
|
3749
|
+
/* @__PURE__ */ jsx19("div", { className: `flex-shrink-0 mr-3 text-${variant}-500`, children: icons[variant] }),
|
|
3750
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex-1", children: [
|
|
3751
|
+
title && /* @__PURE__ */ jsx19("h3", { className: "font-medium text-sm", children: title }),
|
|
3752
|
+
/* @__PURE__ */ jsx19("div", { className: "text-sm", children: message })
|
|
3753
|
+
] }),
|
|
3754
|
+
showCloseButton && /* @__PURE__ */ jsx19(
|
|
3755
|
+
"button",
|
|
3756
|
+
{
|
|
3757
|
+
type: "button",
|
|
3758
|
+
className: "ml-3 text-gray-400 hover:text-gray-900",
|
|
3759
|
+
onClick: handleDismiss,
|
|
3760
|
+
"aria-label": "Close",
|
|
3761
|
+
children: /* @__PURE__ */ jsx19("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx19("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M6 18L18 6M6 6l12 12" }) })
|
|
3762
|
+
}
|
|
3763
|
+
)
|
|
3764
|
+
]
|
|
3765
|
+
}
|
|
3766
|
+
);
|
|
3767
|
+
};
|
|
3768
|
+
var ToastContainer = ({
|
|
3769
|
+
position = "top-right",
|
|
3770
|
+
className
|
|
3771
|
+
}) => {
|
|
3772
|
+
const containerRef = useRef2(null);
|
|
3773
|
+
const [isMounted, setIsMounted] = useState7(false);
|
|
3774
|
+
const [toasts, setToasts] = useState7([]);
|
|
3775
|
+
useEffect5(() => {
|
|
3776
|
+
const container = document.createElement("div");
|
|
3777
|
+
container.id = "toast-root";
|
|
3778
|
+
container.className = "fixed z-50 p-4";
|
|
3779
|
+
document.body.appendChild(container);
|
|
3780
|
+
containerRef.current = container;
|
|
3781
|
+
setIsMounted(true);
|
|
3782
|
+
const unsubscribe = toastService.subscribe(setToasts);
|
|
3783
|
+
return () => {
|
|
3784
|
+
unsubscribe();
|
|
3785
|
+
container.remove();
|
|
3786
|
+
};
|
|
3787
|
+
}, []);
|
|
3788
|
+
const positionClasses = {
|
|
3789
|
+
"top-right": "top-0 right-0",
|
|
3790
|
+
"top-left": "top-0 left-0",
|
|
3791
|
+
"bottom-right": "bottom-0 right-0",
|
|
3792
|
+
"bottom-left": "bottom-0 left-0",
|
|
3793
|
+
"top-center": "top-0 left-1/2 -translate-x-1/2",
|
|
3794
|
+
"bottom-center": "bottom-0 left-1/2 -translate-x-1/2"
|
|
3795
|
+
};
|
|
3796
|
+
if (!isMounted || !containerRef.current) return null;
|
|
3797
|
+
return /* @__PURE__ */ jsx19(
|
|
3798
|
+
"div",
|
|
3799
|
+
{
|
|
3800
|
+
className: twMerge(
|
|
3801
|
+
"fixed z-50 p-4 flex flex-col items-end",
|
|
3802
|
+
positionClasses[position],
|
|
3803
|
+
className
|
|
3804
|
+
),
|
|
3805
|
+
children: toasts.map((toast) => /* @__PURE__ */ jsx19(Toast, { ...toast }, toast.id))
|
|
3806
|
+
}
|
|
3807
|
+
);
|
|
3808
|
+
};
|
|
3809
|
+
var useToast = () => {
|
|
3810
|
+
return {
|
|
3811
|
+
showToast: (toast) => toastService.showToast(toast),
|
|
3812
|
+
hideToast: (id) => toastService.hideToast(id),
|
|
3813
|
+
clearToasts: () => toastService.clearToasts()
|
|
3814
|
+
};
|
|
3815
|
+
};
|
|
3816
|
+
var ToastProvider = ({ position = "top-right", children }) => {
|
|
3817
|
+
return /* @__PURE__ */ jsxs11(Fragment, { children: [
|
|
3818
|
+
children,
|
|
3819
|
+
/* @__PURE__ */ jsx19(ToastContainer, { position })
|
|
3820
|
+
] });
|
|
3821
|
+
};
|
|
3822
|
+
Toast.displayName = "Toast";
|
|
3823
|
+
ToastContainer.displayName = "ToastContainer";
|
|
3190
3824
|
export {
|
|
3191
3825
|
Avatar,
|
|
3192
3826
|
Box,
|
|
@@ -3197,9 +3831,18 @@ export {
|
|
|
3197
3831
|
Heading,
|
|
3198
3832
|
Input,
|
|
3199
3833
|
Link,
|
|
3834
|
+
Loading,
|
|
3835
|
+
Modal,
|
|
3200
3836
|
MultiStep,
|
|
3201
3837
|
RadioGroup,
|
|
3838
|
+
Skeleton,
|
|
3202
3839
|
Text,
|
|
3203
3840
|
TextArea,
|
|
3204
|
-
TextInput
|
|
3841
|
+
TextInput,
|
|
3842
|
+
Toast,
|
|
3843
|
+
ToastContainer,
|
|
3844
|
+
ToastProvider,
|
|
3845
|
+
Toggle,
|
|
3846
|
+
toastService,
|
|
3847
|
+
useToast
|
|
3205
3848
|
};
|