@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.cjs
CHANGED
|
@@ -1,37 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __objRest = (source, exclude) => {
|
|
24
|
-
var target = {};
|
|
25
|
-
for (var prop in source)
|
|
26
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
-
target[prop] = source[prop];
|
|
28
|
-
if (source != null && __getOwnPropSymbols)
|
|
29
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
-
target[prop] = source[prop];
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
};
|
|
35
6
|
var __export = (target, all) => {
|
|
36
7
|
for (var name in all)
|
|
37
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -58,11 +29,20 @@ __export(index_exports, {
|
|
|
58
29
|
Heading: () => Heading,
|
|
59
30
|
Input: () => Input,
|
|
60
31
|
Link: () => Link,
|
|
32
|
+
Loading: () => Loading,
|
|
33
|
+
Modal: () => Modal,
|
|
61
34
|
MultiStep: () => MultiStep,
|
|
62
35
|
RadioGroup: () => RadioGroup,
|
|
36
|
+
Skeleton: () => Skeleton,
|
|
63
37
|
Text: () => Text,
|
|
64
38
|
TextArea: () => TextArea,
|
|
65
|
-
TextInput: () => TextInput
|
|
39
|
+
TextInput: () => TextInput,
|
|
40
|
+
Toast: () => Toast,
|
|
41
|
+
ToastContainer: () => ToastContainer,
|
|
42
|
+
ToastProvider: () => ToastProvider,
|
|
43
|
+
Toggle: () => Toggle,
|
|
44
|
+
toastService: () => toastService,
|
|
45
|
+
useToast: () => useToast
|
|
66
46
|
});
|
|
67
47
|
module.exports = __toCommonJS(index_exports);
|
|
68
48
|
|
|
@@ -94,7 +74,6 @@ var createClassGroupUtils = (config) => {
|
|
|
94
74
|
};
|
|
95
75
|
};
|
|
96
76
|
var getGroupRecursive = (classParts, classPartObject) => {
|
|
97
|
-
var _a;
|
|
98
77
|
if (classParts.length === 0) {
|
|
99
78
|
return classPartObject.classGroupId;
|
|
100
79
|
}
|
|
@@ -108,15 +87,15 @@ var getGroupRecursive = (classParts, classPartObject) => {
|
|
|
108
87
|
return void 0;
|
|
109
88
|
}
|
|
110
89
|
const classRest = classParts.join(CLASS_PART_SEPARATOR);
|
|
111
|
-
return
|
|
90
|
+
return classPartObject.validators.find(({
|
|
112
91
|
validator
|
|
113
|
-
}) => validator(classRest))
|
|
92
|
+
}) => validator(classRest))?.classGroupId;
|
|
114
93
|
};
|
|
115
94
|
var arbitraryPropertyRegex = /^\[(.+)\]$/;
|
|
116
95
|
var getGroupIdForArbitraryProperty = (className) => {
|
|
117
96
|
if (arbitraryPropertyRegex.test(className)) {
|
|
118
97
|
const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
|
|
119
|
-
const property = arbitraryPropertyClassName
|
|
98
|
+
const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(":"));
|
|
120
99
|
if (property) {
|
|
121
100
|
return "arbitrary.." + property;
|
|
122
101
|
}
|
|
@@ -301,10 +280,11 @@ var sortModifiers = (modifiers) => {
|
|
|
301
280
|
sortedModifiers.push(...unsortedModifiers.sort());
|
|
302
281
|
return sortedModifiers;
|
|
303
282
|
};
|
|
304
|
-
var createConfigUtils = (config) =>
|
|
283
|
+
var createConfigUtils = (config) => ({
|
|
305
284
|
cache: createLruCache(config.cacheSize),
|
|
306
|
-
parseClassName: createParseClassName(config)
|
|
307
|
-
|
|
285
|
+
parseClassName: createParseClassName(config),
|
|
286
|
+
...createClassGroupUtils(config)
|
|
287
|
+
});
|
|
308
288
|
var SPLIT_CLASSES_REGEX = /\s+/;
|
|
309
289
|
var mergeClassList = (classList, configUtils) => {
|
|
310
290
|
const {
|
|
@@ -2528,50 +2508,97 @@ var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
|
2528
2508
|
|
|
2529
2509
|
// src/components/Card/index.tsx
|
|
2530
2510
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2531
|
-
var Card = (
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2511
|
+
var Card = ({
|
|
2512
|
+
className,
|
|
2513
|
+
selected = false,
|
|
2514
|
+
direction = "row",
|
|
2515
|
+
size = "medium",
|
|
2516
|
+
disabled = false,
|
|
2517
|
+
image,
|
|
2518
|
+
imageSize = "100px",
|
|
2519
|
+
imageAlt = "",
|
|
2520
|
+
title,
|
|
2521
|
+
content,
|
|
2522
|
+
onClick,
|
|
2523
|
+
footer,
|
|
2524
|
+
hoverable = true,
|
|
2525
|
+
...rest
|
|
2526
|
+
}) => {
|
|
2527
|
+
const handleClick = () => {
|
|
2528
|
+
if (!disabled && onClick) {
|
|
2529
|
+
onClick();
|
|
2530
|
+
}
|
|
2531
|
+
};
|
|
2532
|
+
const cardSizeClasses = {
|
|
2533
|
+
small: "max-w-xs p-3",
|
|
2534
|
+
medium: "max-w-md p-4",
|
|
2535
|
+
large: "max-w-lg p-5",
|
|
2536
|
+
full: "w-full p-5"
|
|
2537
|
+
};
|
|
2549
2538
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2550
2539
|
"div",
|
|
2551
2540
|
{
|
|
2552
2541
|
className: twMerge(
|
|
2553
|
-
"flex items-center
|
|
2554
|
-
"
|
|
2555
|
-
size
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2542
|
+
"flex items-center rounded-lg bg-neutral border border-neutral-500 text-neutral-1000 transition-all duration-200",
|
|
2543
|
+
direction === "col" ? "flex-col" : "flex-row",
|
|
2544
|
+
cardSizeClasses[size],
|
|
2545
|
+
hoverable && !disabled && "hover:shadow-md hover:shadow-neutral-500",
|
|
2546
|
+
selected && "border-2 border-orange-500",
|
|
2547
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
2548
|
+
onClick && !disabled && "cursor-pointer",
|
|
2560
2549
|
className
|
|
2561
2550
|
),
|
|
2562
|
-
onClick,
|
|
2551
|
+
onClick: handleClick,
|
|
2552
|
+
role: onClick && !disabled ? "button" : void 0,
|
|
2553
|
+
tabIndex: onClick && !disabled ? 0 : void 0,
|
|
2554
|
+
onKeyDown: (e) => {
|
|
2555
|
+
if ((e.key === "Enter" || e.key === " ") && onClick && !disabled) {
|
|
2556
|
+
e.preventDefault();
|
|
2557
|
+
onClick();
|
|
2558
|
+
}
|
|
2559
|
+
},
|
|
2560
|
+
"aria-disabled": disabled,
|
|
2561
|
+
...rest,
|
|
2563
2562
|
children: [
|
|
2564
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2563
|
+
image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2564
|
+
"div",
|
|
2565
|
+
{
|
|
2566
|
+
className: twMerge(
|
|
2567
|
+
"flex-shrink-0",
|
|
2568
|
+
direction === "row" ? "mr-4" : "mb-4",
|
|
2569
|
+
size === "small" && direction === "row" ? "mr-3" : "",
|
|
2570
|
+
size === "small" && direction === "col" ? "mb-3" : ""
|
|
2571
|
+
),
|
|
2572
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2573
|
+
"img",
|
|
2574
|
+
{
|
|
2575
|
+
src: image,
|
|
2576
|
+
alt: imageAlt,
|
|
2577
|
+
width: imageSize,
|
|
2578
|
+
height: "auto",
|
|
2579
|
+
className: "rounded object-cover"
|
|
2580
|
+
}
|
|
2581
|
+
)
|
|
2582
|
+
}
|
|
2583
|
+
),
|
|
2565
2584
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2566
|
-
"
|
|
2585
|
+
"div",
|
|
2567
2586
|
{
|
|
2568
2587
|
className: twMerge(
|
|
2569
|
-
|
|
2570
|
-
"
|
|
2588
|
+
"flex flex-col",
|
|
2589
|
+
direction === "col" && "text-center w-full",
|
|
2590
|
+
direction === "row" && "flex-1"
|
|
2571
2591
|
),
|
|
2572
2592
|
children: [
|
|
2573
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("
|
|
2574
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("
|
|
2593
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "text-xl font-bold font-default leading-tight mb-2", children: title }),
|
|
2594
|
+
content && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: twMerge(
|
|
2595
|
+
"text-base",
|
|
2596
|
+
direction === "col" ? "text-center" : "text-left"
|
|
2597
|
+
), children: content }),
|
|
2598
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: twMerge(
|
|
2599
|
+
"mt-4 pt-3 border-t border-neutral-300",
|
|
2600
|
+
direction === "col" ? "text-center" : "text-left"
|
|
2601
|
+
), children: footer })
|
|
2575
2602
|
]
|
|
2576
2603
|
}
|
|
2577
2604
|
)
|
|
@@ -2579,72 +2606,130 @@ var Card = (_a) => {
|
|
|
2579
2606
|
}
|
|
2580
2607
|
);
|
|
2581
2608
|
};
|
|
2609
|
+
Card.displayName = "Card";
|
|
2582
2610
|
|
|
2583
2611
|
// src/components/Button/index.tsx
|
|
2612
|
+
var import_react = require("react");
|
|
2584
2613
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2585
|
-
var Button = (
|
|
2586
|
-
|
|
2614
|
+
var Button = (0, import_react.forwardRef)(
|
|
2615
|
+
({
|
|
2587
2616
|
className,
|
|
2588
2617
|
variant = "primary",
|
|
2589
2618
|
size = "md",
|
|
2590
|
-
disabled,
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2619
|
+
disabled = false,
|
|
2620
|
+
loading = false,
|
|
2621
|
+
startIcon,
|
|
2622
|
+
endIcon,
|
|
2623
|
+
fullWidth = false,
|
|
2624
|
+
onClick,
|
|
2625
|
+
children,
|
|
2626
|
+
...rest
|
|
2627
|
+
}, ref) => {
|
|
2628
|
+
const sizeClasses = {
|
|
2629
|
+
xs: "px-3 py-1 text-xs",
|
|
2630
|
+
sm: "px-5 py-1.5 text-sm",
|
|
2631
|
+
md: "px-6 py-2 text-md",
|
|
2632
|
+
lg: "px-8 py-3 text-lg"
|
|
2633
|
+
};
|
|
2634
|
+
const variantClasses = {
|
|
2635
|
+
primary: "bg-orange-500 text-neutral hover:bg-orange-700 focus:ring-orange-500",
|
|
2636
|
+
secondary: "bg-neutral text-orange-500 border border-orange-500 hover:text-neutral hover:bg-orange-500 focus:ring-orange-500",
|
|
2637
|
+
outline: "bg-transparent text-orange-500 border border-orange-500 hover:bg-orange-50 focus:ring-orange-500",
|
|
2638
|
+
ghost: "bg-transparent text-orange-500 hover:bg-orange-50 focus:ring-orange-500",
|
|
2639
|
+
link: "bg-transparent text-orange-500 hover:underline p-0 h-auto shadow-none focus:ring-0"
|
|
2640
|
+
};
|
|
2641
|
+
const handleClick = (e) => {
|
|
2642
|
+
if (loading || disabled) return;
|
|
2643
|
+
onClick?.(e);
|
|
2644
|
+
};
|
|
2645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2646
|
+
"button",
|
|
2647
|
+
{
|
|
2648
|
+
ref,
|
|
2649
|
+
className: twMerge(
|
|
2650
|
+
"relative font-medium rounded-sm transition-all duration-200",
|
|
2651
|
+
"focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-opacity-50",
|
|
2652
|
+
variantClasses[variant],
|
|
2653
|
+
sizeClasses[size],
|
|
2654
|
+
fullWidth ? "w-full" : "max-w-[180px]",
|
|
2655
|
+
"inline-flex items-center justify-center gap-2",
|
|
2656
|
+
(disabled || loading) && "opacity-50 cursor-not-allowed hover:shadow-none hover:bg-opacity-100",
|
|
2657
|
+
className
|
|
2658
|
+
),
|
|
2659
|
+
onClick: handleClick,
|
|
2660
|
+
disabled: disabled || loading,
|
|
2661
|
+
...rest,
|
|
2662
|
+
children: [
|
|
2663
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2664
|
+
"svg",
|
|
2665
|
+
{
|
|
2666
|
+
className: "animate-spin h-5 w-5",
|
|
2667
|
+
viewBox: "0 0 24 24",
|
|
2668
|
+
fill: "none",
|
|
2669
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2670
|
+
children: [
|
|
2671
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2672
|
+
"circle",
|
|
2673
|
+
{
|
|
2674
|
+
className: "opacity-25",
|
|
2675
|
+
cx: "12",
|
|
2676
|
+
cy: "12",
|
|
2677
|
+
r: "10",
|
|
2678
|
+
stroke: "currentColor",
|
|
2679
|
+
strokeWidth: "4"
|
|
2680
|
+
}
|
|
2681
|
+
),
|
|
2682
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2683
|
+
"path",
|
|
2684
|
+
{
|
|
2685
|
+
className: "opacity-75",
|
|
2686
|
+
fill: "currentColor",
|
|
2687
|
+
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"
|
|
2688
|
+
}
|
|
2689
|
+
)
|
|
2690
|
+
]
|
|
2691
|
+
}
|
|
2692
|
+
) }),
|
|
2693
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: loading ? "invisible" : "flex items-center gap-2", children: [
|
|
2694
|
+
startIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mr-1", children: startIcon }),
|
|
2695
|
+
children,
|
|
2696
|
+
endIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ml-1", children: endIcon })
|
|
2697
|
+
] })
|
|
2698
|
+
]
|
|
2699
|
+
}
|
|
2700
|
+
);
|
|
2701
|
+
}
|
|
2702
|
+
);
|
|
2703
|
+
Button.displayName = "Button";
|
|
2615
2704
|
|
|
2616
2705
|
// src/components/Link/index.tsx
|
|
2617
2706
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2618
|
-
var Link = (
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
"className",
|
|
2627
|
-
"disabled",
|
|
2628
|
-
"url",
|
|
2629
|
-
"newPage",
|
|
2630
|
-
"onClick"
|
|
2631
|
-
]);
|
|
2707
|
+
var Link = ({
|
|
2708
|
+
className,
|
|
2709
|
+
disabled,
|
|
2710
|
+
url,
|
|
2711
|
+
newPage = true,
|
|
2712
|
+
onClick,
|
|
2713
|
+
...rest
|
|
2714
|
+
}) => {
|
|
2632
2715
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2633
2716
|
"a",
|
|
2634
|
-
|
|
2717
|
+
{
|
|
2635
2718
|
className: twMerge(
|
|
2636
2719
|
"text-blue-800 font-bold",
|
|
2637
2720
|
typeof rest.children !== "string" && "px-4",
|
|
2638
2721
|
disabled === true && "opacity-50 cursor-not-allowed",
|
|
2639
2722
|
className
|
|
2640
2723
|
),
|
|
2641
|
-
href: url
|
|
2642
|
-
|
|
2724
|
+
href: url,
|
|
2725
|
+
...newPage && { target: "_blank", rel: "noopener noreferrer" },
|
|
2726
|
+
...rest
|
|
2727
|
+
}
|
|
2643
2728
|
);
|
|
2644
2729
|
};
|
|
2645
2730
|
|
|
2646
2731
|
// src/components/RadioGroup/index.tsx
|
|
2647
|
-
var
|
|
2732
|
+
var import_react2 = require("react");
|
|
2648
2733
|
var import_fi = require("react-icons/fi");
|
|
2649
2734
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2650
2735
|
var RadioGroup = ({
|
|
@@ -2656,7 +2741,7 @@ var RadioGroup = ({
|
|
|
2656
2741
|
required = false,
|
|
2657
2742
|
className
|
|
2658
2743
|
}) => {
|
|
2659
|
-
const [selectedOption, setSelectedOption] = (0,
|
|
2744
|
+
const [selectedOption, setSelectedOption] = (0, import_react2.useState)("");
|
|
2660
2745
|
const handleOptionChange = (value) => {
|
|
2661
2746
|
setSelectedOption(value);
|
|
2662
2747
|
};
|
|
@@ -2695,11 +2780,11 @@ var RadioGroup = ({
|
|
|
2695
2780
|
};
|
|
2696
2781
|
|
|
2697
2782
|
// src/components/Checkbox/index.tsx
|
|
2698
|
-
var
|
|
2783
|
+
var import_react3 = require("react");
|
|
2699
2784
|
var import_fi2 = require("react-icons/fi");
|
|
2700
2785
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2701
2786
|
var Checkbox = ({ className, required, disabled }) => {
|
|
2702
|
-
const [selected, setSelected] = (0,
|
|
2787
|
+
const [selected, setSelected] = (0, import_react3.useState)(false);
|
|
2703
2788
|
const handleCheckboxChange = (value) => {
|
|
2704
2789
|
setSelected(!value);
|
|
2705
2790
|
};
|
|
@@ -2734,211 +2819,324 @@ var Checkbox = ({ className, required, disabled }) => {
|
|
|
2734
2819
|
};
|
|
2735
2820
|
|
|
2736
2821
|
// src/components/Input/index.tsx
|
|
2737
|
-
var
|
|
2822
|
+
var import_react4 = require("react");
|
|
2738
2823
|
var import_fi3 = require("react-icons/fi");
|
|
2739
|
-
|
|
2740
|
-
// src/components/Shared/masks.tsx
|
|
2741
|
-
var masks = {
|
|
2742
|
-
password: [/^(?=.*[!@#$%^&*])/, /(?=.*[0-9])/, /.{8,}$/],
|
|
2743
|
-
date: [/\d/, /\d/, "/", /\d/, /\d/, "/", /\d/, /\d/, /\d/, /\d/],
|
|
2744
|
-
cpf: [
|
|
2745
|
-
/\d/,
|
|
2746
|
-
/\d/,
|
|
2747
|
-
/\d/,
|
|
2748
|
-
".",
|
|
2749
|
-
/\d/,
|
|
2750
|
-
/\d/,
|
|
2751
|
-
/\d/,
|
|
2752
|
-
".",
|
|
2753
|
-
/\d/,
|
|
2754
|
-
/\d/,
|
|
2755
|
-
/\d/,
|
|
2756
|
-
"-",
|
|
2757
|
-
/\d/,
|
|
2758
|
-
/\d/
|
|
2759
|
-
],
|
|
2760
|
-
cnpj: [
|
|
2761
|
-
/\d/,
|
|
2762
|
-
/\d/,
|
|
2763
|
-
".",
|
|
2764
|
-
/\d/,
|
|
2765
|
-
/\d/,
|
|
2766
|
-
/\d/,
|
|
2767
|
-
".",
|
|
2768
|
-
/\d/,
|
|
2769
|
-
/\d/,
|
|
2770
|
-
/\d/,
|
|
2771
|
-
"/",
|
|
2772
|
-
/\d/,
|
|
2773
|
-
/\d/,
|
|
2774
|
-
/\d/,
|
|
2775
|
-
/\d/,
|
|
2776
|
-
"-",
|
|
2777
|
-
/\d/,
|
|
2778
|
-
/\d/
|
|
2779
|
-
],
|
|
2780
|
-
cep: [/\d/, /\d/, /\d/, /\d/, /\d/, "-", /\d/, /\d/, /\d/],
|
|
2781
|
-
phone: [
|
|
2782
|
-
"(",
|
|
2783
|
-
/[1-9]/,
|
|
2784
|
-
/[1-9]/,
|
|
2785
|
-
")",
|
|
2786
|
-
" ",
|
|
2787
|
-
/\d/,
|
|
2788
|
-
/\d/,
|
|
2789
|
-
/\d/,
|
|
2790
|
-
/\d/,
|
|
2791
|
-
/\d/,
|
|
2792
|
-
"-",
|
|
2793
|
-
/\d/,
|
|
2794
|
-
/\d/,
|
|
2795
|
-
/\d/,
|
|
2796
|
-
/\d/
|
|
2797
|
-
]
|
|
2798
|
-
};
|
|
2799
|
-
var masks_default = masks;
|
|
2800
|
-
|
|
2801
|
-
// src/components/Input/index.tsx
|
|
2802
2824
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2803
|
-
var
|
|
2804
|
-
(
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2825
|
+
var passwordMask = {
|
|
2826
|
+
password: [/^(?=.*[!@#$%^&*])/, /(?=.*[0-9])/, /.{8,}$/]
|
|
2827
|
+
};
|
|
2828
|
+
var phoneFormats = {
|
|
2829
|
+
"BR": { countryCode: "+55", format: "($1) $2-$3" },
|
|
2830
|
+
"US": { countryCode: "+1", format: "($1) $2-$3" },
|
|
2831
|
+
"UK": { countryCode: "+44", format: "$1 $2 $3" },
|
|
2832
|
+
"DE": { countryCode: "+49", format: "$1 $2 $3" },
|
|
2833
|
+
"FR": { countryCode: "+33", format: "$1 $2 $3 $4" }
|
|
2834
|
+
// Add more countries as needed
|
|
2835
|
+
};
|
|
2836
|
+
var Input = (0, import_react4.forwardRef)(
|
|
2837
|
+
({
|
|
2838
|
+
className,
|
|
2839
|
+
disabled,
|
|
2840
|
+
placeholder,
|
|
2841
|
+
value,
|
|
2842
|
+
validated,
|
|
2843
|
+
error,
|
|
2844
|
+
required,
|
|
2845
|
+
type,
|
|
2846
|
+
onClick,
|
|
2847
|
+
errorMessage,
|
|
2848
|
+
onChange: externalOnChange,
|
|
2849
|
+
label,
|
|
2850
|
+
helperText,
|
|
2851
|
+
id,
|
|
2852
|
+
countryCode = "BR",
|
|
2853
|
+
// Default to Brazil
|
|
2854
|
+
...rest
|
|
2855
|
+
}, ref) => {
|
|
2856
|
+
const [selected, setSelected] = (0, import_react4.useState)(false);
|
|
2857
|
+
const [inputValue, setInputValue] = (0, import_react4.useState)(value || "");
|
|
2858
|
+
const [passwordValidation, setPasswordValidation] = (0, import_react4.useState)({
|
|
2859
|
+
hasEightCharacters: false,
|
|
2860
|
+
hasSpecialCharacters: false,
|
|
2861
|
+
hasNumber: false
|
|
2862
|
+
});
|
|
2863
|
+
const [isValid, setIsValid] = (0, import_react4.useState)(false);
|
|
2831
2864
|
const handleFocus = () => {
|
|
2832
|
-
setSelected(
|
|
2865
|
+
setSelected(true);
|
|
2833
2866
|
};
|
|
2834
2867
|
const handleBlur = () => {
|
|
2835
2868
|
setSelected(false);
|
|
2869
|
+
validateInput(inputValue || "");
|
|
2870
|
+
};
|
|
2871
|
+
const applyMask = (value2, type2) => {
|
|
2872
|
+
let result = value2;
|
|
2873
|
+
switch (type2) {
|
|
2874
|
+
case "date":
|
|
2875
|
+
result = value2.replace(/\D/g, "");
|
|
2876
|
+
if (result.length > 8) result = result.substring(0, 8);
|
|
2877
|
+
if (result.length > 4) result = result.replace(/(\d{2})(\d{2})(\d+)/, "$1/$2/$3");
|
|
2878
|
+
else if (result.length > 2) result = result.replace(/(\d{2})(\d+)/, "$1/$2");
|
|
2879
|
+
break;
|
|
2880
|
+
case "cpf":
|
|
2881
|
+
result = value2.replace(/\D/g, "");
|
|
2882
|
+
if (result.length > 11) result = result.substring(0, 11);
|
|
2883
|
+
if (result.length > 9) result = result.replace(/(\d{3})(\d{3})(\d{3})(\d+)/, "$1.$2.$3-$4");
|
|
2884
|
+
else if (result.length > 6) result = result.replace(/(\d{3})(\d{3})(\d+)/, "$1.$2.$3");
|
|
2885
|
+
else if (result.length > 3) result = result.replace(/(\d{3})(\d+)/, "$1.$2");
|
|
2886
|
+
break;
|
|
2887
|
+
case "cnpj":
|
|
2888
|
+
result = value2.replace(/\D/g, "");
|
|
2889
|
+
if (result.length > 14) result = result.substring(0, 14);
|
|
2890
|
+
if (result.length > 12)
|
|
2891
|
+
result = result.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d+)/, "$1.$2.$3/$4-$5");
|
|
2892
|
+
else if (result.length > 8)
|
|
2893
|
+
result = result.replace(/(\d{2})(\d{3})(\d{3})(\d+)/, "$1.$2.$3/$4");
|
|
2894
|
+
else if (result.length > 5)
|
|
2895
|
+
result = result.replace(/(\d{2})(\d{3})(\d+)/, "$1.$2.$3");
|
|
2896
|
+
else if (result.length > 2)
|
|
2897
|
+
result = result.replace(/(\d{2})(\d+)/, "$1.$2");
|
|
2898
|
+
break;
|
|
2899
|
+
case "cep":
|
|
2900
|
+
result = value2.replace(/\D/g, "");
|
|
2901
|
+
if (result.length > 8) result = result.substring(0, 8);
|
|
2902
|
+
if (result.length > 5) result = result.replace(/(\d{5})(\d+)/, "$1-$2");
|
|
2903
|
+
break;
|
|
2904
|
+
case "phone":
|
|
2905
|
+
result = applyPhoneMask(value2, countryCode);
|
|
2906
|
+
break;
|
|
2907
|
+
case "email":
|
|
2908
|
+
result = value2.trim();
|
|
2909
|
+
break;
|
|
2910
|
+
default:
|
|
2911
|
+
break;
|
|
2912
|
+
}
|
|
2913
|
+
return result;
|
|
2914
|
+
};
|
|
2915
|
+
const applyPhoneMask = (value2, countryCode2) => {
|
|
2916
|
+
let digits = value2.replace(/\D/g, "");
|
|
2917
|
+
const format = phoneFormats[countryCode2] || phoneFormats["BR"];
|
|
2918
|
+
switch (countryCode2) {
|
|
2919
|
+
case "BR":
|
|
2920
|
+
if (digits.length > 11) digits = digits.substring(0, 11);
|
|
2921
|
+
if (digits.length > 10)
|
|
2922
|
+
return digits.replace(/(\d{2})(\d{5})(\d+)/, "($1) $2-$3");
|
|
2923
|
+
else if (digits.length > 6)
|
|
2924
|
+
return digits.replace(/(\d{2})(\d{4})(\d+)/, "($1) $2-$3");
|
|
2925
|
+
else if (digits.length > 2)
|
|
2926
|
+
return digits.replace(/(\d{2})(\d+)/, "($1) $2");
|
|
2927
|
+
return digits;
|
|
2928
|
+
case "US":
|
|
2929
|
+
if (digits.length > 10) digits = digits.substring(0, 10);
|
|
2930
|
+
if (digits.length > 6)
|
|
2931
|
+
return digits.replace(/(\d{3})(\d{3})(\d+)/, "($1) $2-$3");
|
|
2932
|
+
else if (digits.length > 3)
|
|
2933
|
+
return digits.replace(/(\d{3})(\d+)/, "($1) $2");
|
|
2934
|
+
return digits;
|
|
2935
|
+
case "UK":
|
|
2936
|
+
if (digits.length > 10) digits = digits.substring(0, 10);
|
|
2937
|
+
if (digits.length > 7)
|
|
2938
|
+
return digits.replace(/(\d{3})(\d{3})(\d+)/, "$1 $2 $3");
|
|
2939
|
+
else if (digits.length > 3)
|
|
2940
|
+
return digits.replace(/(\d{3})(\d+)/, "$1 $2");
|
|
2941
|
+
return digits;
|
|
2942
|
+
default:
|
|
2943
|
+
if (digits.length > 10) digits = digits.substring(0, 10);
|
|
2944
|
+
if (digits.length > 6)
|
|
2945
|
+
return digits.replace(/(\d{3})(\d{3})(\d+)/, "$1 $2 $3");
|
|
2946
|
+
else if (digits.length > 3)
|
|
2947
|
+
return digits.replace(/(\d{3})(\d+)/, "$1 $2");
|
|
2948
|
+
return digits;
|
|
2949
|
+
}
|
|
2950
|
+
};
|
|
2951
|
+
const validateInput = (value2) => {
|
|
2952
|
+
if (!value2) return false;
|
|
2953
|
+
let valid = false;
|
|
2954
|
+
switch (type) {
|
|
2955
|
+
case "password":
|
|
2956
|
+
valid = passwordValidation.hasEightCharacters && passwordValidation.hasSpecialCharacters && passwordValidation.hasNumber;
|
|
2957
|
+
break;
|
|
2958
|
+
case "date":
|
|
2959
|
+
valid = /^\d{2}\/\d{2}\/\d{4}$/.test(value2);
|
|
2960
|
+
break;
|
|
2961
|
+
case "cpf":
|
|
2962
|
+
valid = /^\d{3}\.\d{3}\.\d{3}-\d{2}$/.test(value2);
|
|
2963
|
+
break;
|
|
2964
|
+
case "cnpj":
|
|
2965
|
+
valid = /^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/.test(value2);
|
|
2966
|
+
break;
|
|
2967
|
+
case "cep":
|
|
2968
|
+
valid = /^\d{5}-\d{3}$/.test(value2);
|
|
2969
|
+
break;
|
|
2970
|
+
case "phone":
|
|
2971
|
+
if (countryCode === "BR") {
|
|
2972
|
+
valid = /^\(\d{2}\) \d{5}-\d{4}$/.test(value2) || /^\(\d{2}\) \d{4}-\d{4}$/.test(value2);
|
|
2973
|
+
} else if (countryCode === "US") {
|
|
2974
|
+
valid = /^\(\d{3}\) \d{3}-\d{4}$/.test(value2);
|
|
2975
|
+
} else {
|
|
2976
|
+
valid = /^[\d\s()-]{8,}$/.test(value2);
|
|
2977
|
+
}
|
|
2978
|
+
break;
|
|
2979
|
+
case "email":
|
|
2980
|
+
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);
|
|
2981
|
+
break;
|
|
2982
|
+
default:
|
|
2983
|
+
valid = value2.length > 0;
|
|
2984
|
+
break;
|
|
2985
|
+
}
|
|
2986
|
+
setIsValid(valid);
|
|
2987
|
+
return valid;
|
|
2836
2988
|
};
|
|
2837
2989
|
const handleInput = (event) => {
|
|
2838
|
-
|
|
2839
|
-
|
|
2990
|
+
let newValue = event.currentTarget.value;
|
|
2991
|
+
if (["date", "cpf", "phone", "cnpj", "cep", "email"].includes(type)) {
|
|
2992
|
+
newValue = applyMask(newValue, type);
|
|
2993
|
+
}
|
|
2994
|
+
const newEvent = {
|
|
2995
|
+
...event,
|
|
2996
|
+
currentTarget: {
|
|
2997
|
+
...event.currentTarget,
|
|
2998
|
+
value: newValue
|
|
2999
|
+
},
|
|
3000
|
+
target: {
|
|
3001
|
+
...event.target,
|
|
3002
|
+
value: newValue
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
setInputValue(newValue);
|
|
3006
|
+
if (type === "password") {
|
|
3007
|
+
checkPassword(newValue);
|
|
3008
|
+
} else {
|
|
3009
|
+
validateInput(newValue);
|
|
3010
|
+
}
|
|
3011
|
+
externalOnChange?.(newEvent);
|
|
2840
3012
|
};
|
|
2841
|
-
(0,
|
|
2842
|
-
setInputValue(value);
|
|
2843
|
-
|
|
3013
|
+
(0, import_react4.useEffect)(() => {
|
|
3014
|
+
setInputValue(value || "");
|
|
3015
|
+
if (value && type === "password") {
|
|
3016
|
+
checkPassword(value);
|
|
3017
|
+
} else if (value) {
|
|
3018
|
+
validateInput(value);
|
|
3019
|
+
}
|
|
3020
|
+
}, [value, type]);
|
|
2844
3021
|
const checkPassword = (value2) => {
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
3022
|
+
const validationResult = {
|
|
3023
|
+
hasEightCharacters: value2?.match(passwordMask.password[2]) !== null,
|
|
3024
|
+
hasSpecialCharacters: value2?.match(passwordMask.password[0]) !== null,
|
|
3025
|
+
hasNumber: value2?.match(passwordMask.password[1]) !== null
|
|
3026
|
+
};
|
|
3027
|
+
setPasswordValidation(validationResult);
|
|
3028
|
+
setIsValid(
|
|
3029
|
+
validationResult.hasEightCharacters && validationResult.hasSpecialCharacters && validationResult.hasNumber
|
|
3030
|
+
);
|
|
2848
3031
|
};
|
|
2849
|
-
|
|
2850
|
-
|
|
3032
|
+
const getInputType = () => {
|
|
3033
|
+
switch (type) {
|
|
3034
|
+
case "password":
|
|
3035
|
+
return "password";
|
|
3036
|
+
case "email":
|
|
3037
|
+
return "email";
|
|
3038
|
+
case "date":
|
|
3039
|
+
case "cpf":
|
|
3040
|
+
case "phone":
|
|
3041
|
+
case "cnpj":
|
|
3042
|
+
case "cep":
|
|
3043
|
+
return "text";
|
|
3044
|
+
default:
|
|
3045
|
+
return "text";
|
|
3046
|
+
}
|
|
3047
|
+
};
|
|
3048
|
+
const renderPhonePrefix = () => {
|
|
3049
|
+
if (type !== "phone") return null;
|
|
3050
|
+
const format = phoneFormats[countryCode] || phoneFormats["BR"];
|
|
3051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "absolute left-2 top-2.5 text-gray-500", children: format.countryCode });
|
|
3052
|
+
};
|
|
3053
|
+
const inputClasses = twMerge(
|
|
3054
|
+
"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",
|
|
3055
|
+
className,
|
|
3056
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
3057
|
+
selected && "border-2 border-orange-500",
|
|
3058
|
+
validated && isValid && "border-2 border-green-900",
|
|
3059
|
+
error && "border-2 border-red-900",
|
|
3060
|
+
type === "phone" && "pl-10"
|
|
3061
|
+
);
|
|
3062
|
+
const renderPasswordValidation = () => {
|
|
3063
|
+
if (type !== "password") return null;
|
|
3064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("ul", { className: "py-1 text-sm", role: "list", children: [
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "flex items-center px-2", role: "listitem", children: [
|
|
3066
|
+
passwordValidation.hasEightCharacters ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiCheck, { className: "text-green-500" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiX, { className: "text-red-500" }),
|
|
3067
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "px-1", children: "Pelo menos 8 caracteres" })
|
|
3068
|
+
] }),
|
|
3069
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "flex items-center px-2", role: "listitem", children: [
|
|
3070
|
+
passwordValidation.hasSpecialCharacters ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiCheck, { className: "text-green-500" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiX, { className: "text-red-500" }),
|
|
3071
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "px-1", children: "Pelo menos 1 s\xEDmbolo (@, !, $, etc)" })
|
|
3072
|
+
] }),
|
|
3073
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "flex items-center px-2", role: "listitem", children: [
|
|
3074
|
+
passwordValidation.hasNumber ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiCheck, { className: "text-green-500" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiX, { className: "text-red-500" }),
|
|
3075
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "px-1", children: "Deve conter 1 n\xFAmero" })
|
|
3076
|
+
] })
|
|
3077
|
+
] });
|
|
3078
|
+
};
|
|
3079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full", children: [
|
|
3080
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3081
|
+
"label",
|
|
3082
|
+
{
|
|
3083
|
+
htmlFor: id,
|
|
3084
|
+
className: "block text-sm font-medium text-gray-700 mb-1",
|
|
3085
|
+
children: [
|
|
3086
|
+
label,
|
|
3087
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
3088
|
+
]
|
|
3089
|
+
}
|
|
3090
|
+
),
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative", children: [
|
|
3092
|
+
renderPhonePrefix(),
|
|
2851
3093
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2852
3094
|
"input",
|
|
2853
|
-
|
|
2854
|
-
type,
|
|
3095
|
+
{
|
|
3096
|
+
type: getInputType(),
|
|
2855
3097
|
required,
|
|
3098
|
+
disabled,
|
|
2856
3099
|
ref,
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
className,
|
|
2860
|
-
disabled === true && "opacity-50 cursor-not-allowed",
|
|
2861
|
-
selected === true && "border-2 border-orange-500",
|
|
2862
|
-
validated === true && "border-2 border-green-900",
|
|
2863
|
-
error === true && "border-2 border-red-900"
|
|
2864
|
-
),
|
|
3100
|
+
id,
|
|
3101
|
+
className: inputClasses,
|
|
2865
3102
|
onClick,
|
|
2866
3103
|
onFocus: handleFocus,
|
|
2867
3104
|
onChange: handleInput,
|
|
2868
3105
|
onBlur: handleBlur,
|
|
2869
3106
|
placeholder,
|
|
2870
|
-
value: inputValue
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "px-1", children: "Pelo menos 1 s\xEDmbolo (@, !, $, etc)" })
|
|
2881
|
-
] }),
|
|
2882
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "flex items-center px-2", children: [
|
|
2883
|
-
hasNumber ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiCheck, {}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_fi3.FiX, {}),
|
|
2884
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "px-1", children: "Deve conter 1 n\xFAmero" })
|
|
2885
|
-
] })
|
|
2886
|
-
] })
|
|
2887
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2888
|
-
"input",
|
|
2889
|
-
__spreadValues({
|
|
2890
|
-
type,
|
|
2891
|
-
required,
|
|
2892
|
-
ref,
|
|
2893
|
-
className: twMerge(
|
|
2894
|
-
"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",
|
|
2895
|
-
className,
|
|
2896
|
-
disabled === true && "opacity-50 cursor-not-allowed",
|
|
2897
|
-
selected === true && "border-2 border-orange-500",
|
|
2898
|
-
error === true && "border-2 border-red-900"
|
|
2899
|
-
),
|
|
2900
|
-
onClick,
|
|
2901
|
-
onFocus: handleFocus,
|
|
2902
|
-
onChange: handleInput,
|
|
2903
|
-
onBlur: handleBlur,
|
|
2904
|
-
placeholder,
|
|
2905
|
-
value: inputValue
|
|
2906
|
-
}, rest)
|
|
2907
|
-
),
|
|
2908
|
-
error === true && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: rest.id, className: "text-red-900", children: "Campo inv\xE1lido." })
|
|
3107
|
+
value: inputValue,
|
|
3108
|
+
"aria-invalid": error,
|
|
3109
|
+
"aria-describedby": error ? `${id}-error` : helperText ? `${id}-helper` : void 0,
|
|
3110
|
+
...rest
|
|
3111
|
+
}
|
|
3112
|
+
)
|
|
3113
|
+
] }),
|
|
3114
|
+
renderPasswordValidation(),
|
|
3115
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { id: `${id}-error`, className: "mt-1 text-sm text-red-900", role: "alert", children: errorMessage || "Invalid field." }),
|
|
3116
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { id: `${id}-helper`, className: "mt-1 text-sm text-gray-500", children: helperText })
|
|
2909
3117
|
] });
|
|
2910
3118
|
}
|
|
2911
3119
|
);
|
|
2912
3120
|
Input.displayName = "Input";
|
|
2913
3121
|
|
|
2914
3122
|
// src/components/TextInput/index.tsx
|
|
2915
|
-
var
|
|
3123
|
+
var import_react5 = require("react");
|
|
2916
3124
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2917
|
-
var TextInput = (0,
|
|
2918
|
-
(
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
"value",
|
|
2933
|
-
"prefix",
|
|
2934
|
-
"placeholder",
|
|
2935
|
-
"error",
|
|
2936
|
-
"type",
|
|
2937
|
-
"variant",
|
|
2938
|
-
"onClick"
|
|
2939
|
-
]);
|
|
2940
|
-
const [selected, setSelected] = (0, import_react4.useState)(false);
|
|
2941
|
-
const [inputValue, setInputValue] = (0, import_react4.useState)(value);
|
|
3125
|
+
var TextInput = (0, import_react5.forwardRef)(
|
|
3126
|
+
({
|
|
3127
|
+
className,
|
|
3128
|
+
disabled,
|
|
3129
|
+
value,
|
|
3130
|
+
prefix,
|
|
3131
|
+
placeholder,
|
|
3132
|
+
error,
|
|
3133
|
+
type = "text",
|
|
3134
|
+
variant = "primary",
|
|
3135
|
+
onClick,
|
|
3136
|
+
...rest
|
|
3137
|
+
}, ref) => {
|
|
3138
|
+
const [selected, setSelected] = (0, import_react5.useState)(false);
|
|
3139
|
+
const [inputValue, setInputValue] = (0, import_react5.useState)(value);
|
|
2942
3140
|
const handleFocus = () => {
|
|
2943
3141
|
setSelected(!selected);
|
|
2944
3142
|
};
|
|
@@ -2948,7 +3146,7 @@ var TextInput = (0, import_react4.forwardRef)(
|
|
|
2948
3146
|
const handleInput = (event) => {
|
|
2949
3147
|
setInputValue(event.currentTarget.value);
|
|
2950
3148
|
};
|
|
2951
|
-
(0,
|
|
3149
|
+
(0, import_react5.useEffect)(() => {
|
|
2952
3150
|
setInputValue(value);
|
|
2953
3151
|
}, [value]);
|
|
2954
3152
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
@@ -2966,7 +3164,7 @@ var TextInput = (0, import_react4.forwardRef)(
|
|
|
2966
3164
|
!!prefix && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-neutral-500 sm:text-sm", children: prefix }),
|
|
2967
3165
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2968
3166
|
"input",
|
|
2969
|
-
|
|
3167
|
+
{
|
|
2970
3168
|
type,
|
|
2971
3169
|
required: rest.required,
|
|
2972
3170
|
onClick,
|
|
@@ -2983,8 +3181,9 @@ var TextInput = (0, import_react4.forwardRef)(
|
|
|
2983
3181
|
disabled === true && "cursor-not-allowed",
|
|
2984
3182
|
variant === "secondary" && "bg-neutral-800 text-neutral",
|
|
2985
3183
|
className
|
|
2986
|
-
)
|
|
2987
|
-
|
|
3184
|
+
),
|
|
3185
|
+
...rest
|
|
3186
|
+
}
|
|
2988
3187
|
)
|
|
2989
3188
|
]
|
|
2990
3189
|
}
|
|
@@ -2994,32 +3193,22 @@ var TextInput = (0, import_react4.forwardRef)(
|
|
|
2994
3193
|
TextInput.displayName = "TextInput";
|
|
2995
3194
|
|
|
2996
3195
|
// src/components/TextArea/index.tsx
|
|
2997
|
-
var
|
|
3196
|
+
var import_react6 = require("react");
|
|
2998
3197
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2999
|
-
var TextArea = (
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
"reference",
|
|
3014
|
-
"value",
|
|
3015
|
-
"error",
|
|
3016
|
-
"required",
|
|
3017
|
-
"placeholder",
|
|
3018
|
-
"resize",
|
|
3019
|
-
"onClick"
|
|
3020
|
-
]);
|
|
3021
|
-
const [selected, setSelected] = (0, import_react5.useState)(false);
|
|
3022
|
-
const [inputValue, setInputValue] = (0, import_react5.useState)(value);
|
|
3198
|
+
var TextArea = ({
|
|
3199
|
+
className,
|
|
3200
|
+
disabled,
|
|
3201
|
+
reference,
|
|
3202
|
+
value,
|
|
3203
|
+
error,
|
|
3204
|
+
required,
|
|
3205
|
+
placeholder,
|
|
3206
|
+
resize,
|
|
3207
|
+
onClick,
|
|
3208
|
+
...rest
|
|
3209
|
+
}) => {
|
|
3210
|
+
const [selected, setSelected] = (0, import_react6.useState)(false);
|
|
3211
|
+
const [inputValue, setInputValue] = (0, import_react6.useState)(value);
|
|
3023
3212
|
const handleFocus = () => {
|
|
3024
3213
|
setSelected(!selected);
|
|
3025
3214
|
};
|
|
@@ -3029,12 +3218,12 @@ var TextArea = (_a) => {
|
|
|
3029
3218
|
const handleInput = (event) => {
|
|
3030
3219
|
setInputValue(event.currentTarget.value);
|
|
3031
3220
|
};
|
|
3032
|
-
(0,
|
|
3221
|
+
(0, import_react6.useEffect)(() => {
|
|
3033
3222
|
setInputValue(value);
|
|
3034
3223
|
}, [value]);
|
|
3035
3224
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3036
3225
|
"textarea",
|
|
3037
|
-
|
|
3226
|
+
{
|
|
3038
3227
|
required,
|
|
3039
3228
|
ref: reference,
|
|
3040
3229
|
disabled,
|
|
@@ -3052,27 +3241,22 @@ var TextArea = (_a) => {
|
|
|
3052
3241
|
onChange: handleInput,
|
|
3053
3242
|
onBlur: handleBlur,
|
|
3054
3243
|
placeholder,
|
|
3055
|
-
value: inputValue
|
|
3056
|
-
|
|
3244
|
+
value: inputValue,
|
|
3245
|
+
...rest
|
|
3246
|
+
}
|
|
3057
3247
|
);
|
|
3058
3248
|
};
|
|
3059
3249
|
|
|
3060
3250
|
// src/components/Text/index.tsx
|
|
3061
3251
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3062
|
-
var Text = (
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
"children",
|
|
3071
|
-
"color",
|
|
3072
|
-
"size",
|
|
3073
|
-
"tag",
|
|
3074
|
-
"className"
|
|
3075
|
-
]);
|
|
3252
|
+
var Text = ({
|
|
3253
|
+
children,
|
|
3254
|
+
color = "neutral-800",
|
|
3255
|
+
size = "md",
|
|
3256
|
+
tag = "p",
|
|
3257
|
+
className,
|
|
3258
|
+
...rest
|
|
3259
|
+
}) => {
|
|
3076
3260
|
const fontSize = {
|
|
3077
3261
|
xxs: "text-xxs",
|
|
3078
3262
|
xs: "text-xs",
|
|
@@ -3090,7 +3274,7 @@ var Text = (_a) => {
|
|
|
3090
3274
|
"9xl": "text-9xl"
|
|
3091
3275
|
}[size];
|
|
3092
3276
|
const Tag = tag;
|
|
3093
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Tag,
|
|
3277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Tag, { ...rest, className: twMerge(`text-${color} ${fontSize}`, className), children });
|
|
3094
3278
|
};
|
|
3095
3279
|
|
|
3096
3280
|
// src/components/Heading/index.tsx
|
|
@@ -3145,39 +3329,33 @@ var Box = ({
|
|
|
3145
3329
|
|
|
3146
3330
|
// src/components/Form/index.tsx
|
|
3147
3331
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3148
|
-
var Form = (
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
"className",
|
|
3156
|
-
"children",
|
|
3157
|
-
"variant",
|
|
3158
|
-
"orientation"
|
|
3159
|
-
]);
|
|
3332
|
+
var Form = ({
|
|
3333
|
+
className,
|
|
3334
|
+
children,
|
|
3335
|
+
variant = "secondary",
|
|
3336
|
+
orientation = "row",
|
|
3337
|
+
...rest
|
|
3338
|
+
}) => {
|
|
3160
3339
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3161
3340
|
"form",
|
|
3162
|
-
|
|
3341
|
+
{
|
|
3163
3342
|
className: twMerge(
|
|
3164
3343
|
"flex flex-row gap-2 p-6 rounded-md border-2",
|
|
3165
3344
|
variant === "primary" && "text-neutral-800 bg-neutral-200 border-neutral-300",
|
|
3166
3345
|
variant === "secondary" && "text-neutral-200 bg-neutral-600 border-neutral-800",
|
|
3167
3346
|
orientation === "col" && "flex-col",
|
|
3168
3347
|
className
|
|
3169
|
-
)
|
|
3170
|
-
|
|
3348
|
+
),
|
|
3349
|
+
...rest,
|
|
3171
3350
|
children
|
|
3172
|
-
}
|
|
3351
|
+
}
|
|
3173
3352
|
);
|
|
3174
3353
|
};
|
|
3175
3354
|
|
|
3176
3355
|
// src/components/Avatar/index.tsx
|
|
3177
3356
|
var import_fa = require("react-icons/fa");
|
|
3178
3357
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3179
|
-
var Avatar = (
|
|
3180
|
-
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
3358
|
+
var Avatar = ({ className, ...rest }) => {
|
|
3181
3359
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3182
3360
|
"div",
|
|
3183
3361
|
{
|
|
@@ -3187,7 +3365,7 @@ var Avatar = (_a) => {
|
|
|
3187
3365
|
bg-neutral-600 justify-center`,
|
|
3188
3366
|
className
|
|
3189
3367
|
),
|
|
3190
|
-
children: rest.src ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img",
|
|
3368
|
+
children: rest.src ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img", { className: "w-full h-full object-cover rounded-full", ...rest }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_fa.FaUser, { color: "#FFFFFF", size: 24 })
|
|
3191
3369
|
}
|
|
3192
3370
|
);
|
|
3193
3371
|
};
|
|
@@ -3212,6 +3390,474 @@ var MultiStep = ({ className, size, currentStep }) => {
|
|
|
3212
3390
|
}) })
|
|
3213
3391
|
] });
|
|
3214
3392
|
};
|
|
3393
|
+
|
|
3394
|
+
// src/components/Toggle/index.tsx
|
|
3395
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3396
|
+
var Toggle = ({
|
|
3397
|
+
className,
|
|
3398
|
+
disabled,
|
|
3399
|
+
active,
|
|
3400
|
+
label,
|
|
3401
|
+
setActive,
|
|
3402
|
+
size = "md",
|
|
3403
|
+
hideLabel = false,
|
|
3404
|
+
id,
|
|
3405
|
+
...rest
|
|
3406
|
+
}) => {
|
|
3407
|
+
const toggleId = id || `toggle-${Math.random().toString(36).substring(2, 9)}`;
|
|
3408
|
+
const sizeClasses = {
|
|
3409
|
+
sm: {
|
|
3410
|
+
toggle: "h-5 w-9",
|
|
3411
|
+
knob: "h-3 w-3",
|
|
3412
|
+
translate: active ? "translate-x-5" : "translate-x-1"
|
|
3413
|
+
},
|
|
3414
|
+
md: {
|
|
3415
|
+
toggle: "h-6 w-11",
|
|
3416
|
+
knob: "h-4 w-4",
|
|
3417
|
+
translate: active ? "translate-x-6" : "translate-x-1"
|
|
3418
|
+
},
|
|
3419
|
+
lg: {
|
|
3420
|
+
toggle: "h-7 w-14",
|
|
3421
|
+
knob: "h-5 w-5",
|
|
3422
|
+
translate: active ? "translate-x-8" : "translate-x-1"
|
|
3423
|
+
}
|
|
3424
|
+
};
|
|
3425
|
+
const selectedSize = sizeClasses[size];
|
|
3426
|
+
const handleKeyDown = (e) => {
|
|
3427
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3428
|
+
e.preventDefault();
|
|
3429
|
+
if (!disabled) {
|
|
3430
|
+
setActive(!active);
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
};
|
|
3434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3435
|
+
"div",
|
|
3436
|
+
{
|
|
3437
|
+
className: twMerge("flex items-center gap-3", className),
|
|
3438
|
+
...rest,
|
|
3439
|
+
children: [
|
|
3440
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3441
|
+
"button",
|
|
3442
|
+
{
|
|
3443
|
+
type: "button",
|
|
3444
|
+
role: "switch",
|
|
3445
|
+
"aria-checked": active,
|
|
3446
|
+
"aria-labelledby": hideLabel ? void 0 : `${toggleId}-label`,
|
|
3447
|
+
"aria-label": hideLabel ? label : void 0,
|
|
3448
|
+
id: toggleId,
|
|
3449
|
+
disabled,
|
|
3450
|
+
onClick: () => setActive(!active),
|
|
3451
|
+
onKeyDown: handleKeyDown,
|
|
3452
|
+
className: twMerge(`
|
|
3453
|
+
relative inline-flex items-center rounded-full
|
|
3454
|
+
${selectedSize.toggle}
|
|
3455
|
+
${active ? "bg-blue-600" : "bg-gray-300 dark:bg-gray-600"}
|
|
3456
|
+
${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
3457
|
+
transition-colors duration-300 ease-in-out
|
|
3458
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2
|
|
3459
|
+
`),
|
|
3460
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: `
|
|
3461
|
+
inline-block transform rounded-full bg-white shadow-md
|
|
3462
|
+
${selectedSize.knob}
|
|
3463
|
+
${selectedSize.translate}
|
|
3464
|
+
transition-transform duration-300 ease-in-out
|
|
3465
|
+
` })
|
|
3466
|
+
}
|
|
3467
|
+
),
|
|
3468
|
+
!hideLabel && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3469
|
+
"label",
|
|
3470
|
+
{
|
|
3471
|
+
id: `${toggleId}-label`,
|
|
3472
|
+
htmlFor: toggleId,
|
|
3473
|
+
className: `text-sm font-medium text-gray-700 dark:text-gray-300 ${disabled ? "opacity-50" : ""}`,
|
|
3474
|
+
children: label
|
|
3475
|
+
}
|
|
3476
|
+
)
|
|
3477
|
+
]
|
|
3478
|
+
}
|
|
3479
|
+
);
|
|
3480
|
+
};
|
|
3481
|
+
|
|
3482
|
+
// src/components/Skeleton/index.tsx
|
|
3483
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3484
|
+
var Skeleton = ({
|
|
3485
|
+
width = "full",
|
|
3486
|
+
height = "16",
|
|
3487
|
+
rounded = false,
|
|
3488
|
+
circle = false,
|
|
3489
|
+
animate = true,
|
|
3490
|
+
className
|
|
3491
|
+
}) => {
|
|
3492
|
+
const widthClass = typeof width === "string" ? width.includes("px") || width.includes("%") || width.includes("rem") || width.includes("em") ? `w-[${width}]` : `w-${width}` : `w-[${width}px]`;
|
|
3493
|
+
const heightClass = typeof height === "string" ? height.includes("px") || height.includes("%") || height.includes("rem") || height.includes("em") ? `h-[${height}]` : `h-${height}` : `h-[${height}px]`;
|
|
3494
|
+
const safeWidthClass = widthClass.includes("[") ? "w-full" : widthClass;
|
|
3495
|
+
const safeHeightClass = heightClass.includes("[") ? "h-16" : heightClass;
|
|
3496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3497
|
+
"div",
|
|
3498
|
+
{
|
|
3499
|
+
className: twMerge(
|
|
3500
|
+
"bg-gray-200",
|
|
3501
|
+
safeWidthClass,
|
|
3502
|
+
safeHeightClass,
|
|
3503
|
+
rounded && !circle && "rounded-md",
|
|
3504
|
+
circle && "rounded-full",
|
|
3505
|
+
animate && "animate-pulse",
|
|
3506
|
+
className
|
|
3507
|
+
),
|
|
3508
|
+
"aria-hidden": "true"
|
|
3509
|
+
}
|
|
3510
|
+
);
|
|
3511
|
+
};
|
|
3512
|
+
Skeleton.displayName = "Skeleton";
|
|
3513
|
+
|
|
3514
|
+
// src/components/Loading/index.tsx
|
|
3515
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3516
|
+
var Loading = ({
|
|
3517
|
+
size = "md",
|
|
3518
|
+
color = "primary",
|
|
3519
|
+
withText = false,
|
|
3520
|
+
text = "Loading...",
|
|
3521
|
+
centered = false,
|
|
3522
|
+
className
|
|
3523
|
+
}) => {
|
|
3524
|
+
const sizeClasses = {
|
|
3525
|
+
xs: "h-4 w-4",
|
|
3526
|
+
sm: "h-6 w-6",
|
|
3527
|
+
md: "h-8 w-8",
|
|
3528
|
+
lg: "h-12 w-12"
|
|
3529
|
+
};
|
|
3530
|
+
const colorClasses = {
|
|
3531
|
+
primary: "text-orange-500",
|
|
3532
|
+
secondary: "text-neutral",
|
|
3533
|
+
white: "text-white",
|
|
3534
|
+
black: "text-black",
|
|
3535
|
+
gray: "text-gray-400"
|
|
3536
|
+
};
|
|
3537
|
+
const textSizeClasses = {
|
|
3538
|
+
xs: "text-xs",
|
|
3539
|
+
sm: "text-sm",
|
|
3540
|
+
md: "text-base",
|
|
3541
|
+
lg: "text-lg"
|
|
3542
|
+
};
|
|
3543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3544
|
+
"div",
|
|
3545
|
+
{
|
|
3546
|
+
className: twMerge(
|
|
3547
|
+
"inline-flex items-center",
|
|
3548
|
+
centered && "justify-center",
|
|
3549
|
+
className
|
|
3550
|
+
),
|
|
3551
|
+
role: "status",
|
|
3552
|
+
children: [
|
|
3553
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3554
|
+
"svg",
|
|
3555
|
+
{
|
|
3556
|
+
className: twMerge(
|
|
3557
|
+
"animate-spin",
|
|
3558
|
+
sizeClasses[size],
|
|
3559
|
+
colorClasses[color]
|
|
3560
|
+
),
|
|
3561
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3562
|
+
fill: "none",
|
|
3563
|
+
viewBox: "0 0 24 24",
|
|
3564
|
+
children: [
|
|
3565
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3566
|
+
"circle",
|
|
3567
|
+
{
|
|
3568
|
+
className: "opacity-25",
|
|
3569
|
+
cx: "12",
|
|
3570
|
+
cy: "12",
|
|
3571
|
+
r: "10",
|
|
3572
|
+
stroke: "currentColor",
|
|
3573
|
+
strokeWidth: "4"
|
|
3574
|
+
}
|
|
3575
|
+
),
|
|
3576
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3577
|
+
"path",
|
|
3578
|
+
{
|
|
3579
|
+
className: "opacity-75",
|
|
3580
|
+
fill: "currentColor",
|
|
3581
|
+
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"
|
|
3582
|
+
}
|
|
3583
|
+
)
|
|
3584
|
+
]
|
|
3585
|
+
}
|
|
3586
|
+
),
|
|
3587
|
+
withText && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: twMerge(
|
|
3588
|
+
"ml-3",
|
|
3589
|
+
textSizeClasses[size],
|
|
3590
|
+
colorClasses[color]
|
|
3591
|
+
), children: text }),
|
|
3592
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "sr-only", children: "Loading" })
|
|
3593
|
+
]
|
|
3594
|
+
}
|
|
3595
|
+
);
|
|
3596
|
+
};
|
|
3597
|
+
Loading.displayName = "Loading";
|
|
3598
|
+
|
|
3599
|
+
// src/components/Modal/index.tsx
|
|
3600
|
+
var import_react7 = require("react");
|
|
3601
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3602
|
+
var Modal = ({
|
|
3603
|
+
className,
|
|
3604
|
+
isOpen,
|
|
3605
|
+
onClose,
|
|
3606
|
+
title,
|
|
3607
|
+
size = "md",
|
|
3608
|
+
children,
|
|
3609
|
+
showCloseButton = true,
|
|
3610
|
+
closeOnOutsideClick = true,
|
|
3611
|
+
closeOnEsc = true,
|
|
3612
|
+
footer,
|
|
3613
|
+
...rest
|
|
3614
|
+
}) => {
|
|
3615
|
+
const modalRef = (0, import_react7.useRef)(null);
|
|
3616
|
+
const portalRoot = (0, import_react7.useRef)(null);
|
|
3617
|
+
const [mounted, setMounted] = (0, import_react7.useState)(false);
|
|
3618
|
+
(0, import_react7.useEffect)(() => {
|
|
3619
|
+
portalRoot.current = document.createElement("div");
|
|
3620
|
+
portalRoot.current.id = "bloom-ui-portal-root";
|
|
3621
|
+
document.body.appendChild(portalRoot.current);
|
|
3622
|
+
setMounted(true);
|
|
3623
|
+
return () => {
|
|
3624
|
+
portalRoot.current?.remove();
|
|
3625
|
+
document.body.style.overflow = "";
|
|
3626
|
+
};
|
|
3627
|
+
}, []);
|
|
3628
|
+
(0, import_react7.useEffect)(() => {
|
|
3629
|
+
if (isOpen) {
|
|
3630
|
+
document.body.style.overflow = "hidden";
|
|
3631
|
+
} else {
|
|
3632
|
+
document.body.style.overflow = "";
|
|
3633
|
+
}
|
|
3634
|
+
}, [isOpen]);
|
|
3635
|
+
(0, import_react7.useEffect)(() => {
|
|
3636
|
+
const handleKeyDown = (e) => {
|
|
3637
|
+
if (isOpen && closeOnEsc && e.key === "Escape") onClose();
|
|
3638
|
+
};
|
|
3639
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
3640
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
3641
|
+
}, [isOpen, onClose, closeOnEsc]);
|
|
3642
|
+
const handleBackdropClick = (e) => {
|
|
3643
|
+
if (closeOnOutsideClick && modalRef.current && !modalRef.current.contains(e.target)) {
|
|
3644
|
+
onClose();
|
|
3645
|
+
}
|
|
3646
|
+
};
|
|
3647
|
+
const sizeClasses = {
|
|
3648
|
+
sm: "max-w-sm",
|
|
3649
|
+
md: "max-w-md",
|
|
3650
|
+
lg: "max-w-lg",
|
|
3651
|
+
xl: "max-w-xl"
|
|
3652
|
+
};
|
|
3653
|
+
if (!isOpen || !mounted || !portalRoot.current) return null;
|
|
3654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3655
|
+
"div",
|
|
3656
|
+
{
|
|
3657
|
+
className: "fixed inset-0 z-50 flex items-center justify-center p-4 bg-black bg-opacity-50 transition-opacity duration-300",
|
|
3658
|
+
onClick: handleBackdropClick,
|
|
3659
|
+
"aria-modal": "true",
|
|
3660
|
+
role: "dialog",
|
|
3661
|
+
...rest,
|
|
3662
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
3663
|
+
"div",
|
|
3664
|
+
{
|
|
3665
|
+
ref: modalRef,
|
|
3666
|
+
className: twMerge(
|
|
3667
|
+
`relative bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full
|
|
3668
|
+
${sizeClasses[size]} opacity-100 scale-100
|
|
3669
|
+
transition-all duration-300 ease-in-out`,
|
|
3670
|
+
className
|
|
3671
|
+
),
|
|
3672
|
+
children: [
|
|
3673
|
+
(title || showCloseButton) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700", children: [
|
|
3674
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100", children: title }),
|
|
3675
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3676
|
+
"button",
|
|
3677
|
+
{
|
|
3678
|
+
type: "button",
|
|
3679
|
+
"aria-label": "Close modal",
|
|
3680
|
+
onClick: onClose,
|
|
3681
|
+
className: "p-1 text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 rounded-full",
|
|
3682
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("svg", { className: "h-5 w-5", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("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" }) })
|
|
3683
|
+
}
|
|
3684
|
+
)
|
|
3685
|
+
] }),
|
|
3686
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-6 py-4 max-h-[70vh] overflow-y-auto", children }),
|
|
3687
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-6 py-4 border-t border-gray-200 dark:border-gray-700", children: footer })
|
|
3688
|
+
]
|
|
3689
|
+
}
|
|
3690
|
+
)
|
|
3691
|
+
}
|
|
3692
|
+
);
|
|
3693
|
+
};
|
|
3694
|
+
|
|
3695
|
+
// src/components/Toast/index.tsx
|
|
3696
|
+
var import_react8 = require("react");
|
|
3697
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3698
|
+
var ToastService = class _ToastService {
|
|
3699
|
+
constructor() {
|
|
3700
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
3701
|
+
this.toasts = [];
|
|
3702
|
+
}
|
|
3703
|
+
static getInstance() {
|
|
3704
|
+
if (!_ToastService.instance) {
|
|
3705
|
+
_ToastService.instance = new _ToastService();
|
|
3706
|
+
}
|
|
3707
|
+
return _ToastService.instance;
|
|
3708
|
+
}
|
|
3709
|
+
subscribe(listener) {
|
|
3710
|
+
this.listeners.add(listener);
|
|
3711
|
+
return () => {
|
|
3712
|
+
this.listeners.delete(listener);
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3715
|
+
notify() {
|
|
3716
|
+
this.listeners.forEach((listener) => listener([...this.toasts]));
|
|
3717
|
+
}
|
|
3718
|
+
showToast(toast) {
|
|
3719
|
+
const id = `toast-${Date.now()}`;
|
|
3720
|
+
this.toasts.push({
|
|
3721
|
+
...toast,
|
|
3722
|
+
id,
|
|
3723
|
+
onDismiss: (toastId) => this.hideToast(toastId)
|
|
3724
|
+
});
|
|
3725
|
+
this.notify();
|
|
3726
|
+
return id;
|
|
3727
|
+
}
|
|
3728
|
+
hideToast(id) {
|
|
3729
|
+
this.toasts = this.toasts.filter((toast) => toast.id !== id);
|
|
3730
|
+
this.notify();
|
|
3731
|
+
}
|
|
3732
|
+
clearToasts() {
|
|
3733
|
+
this.toasts = [];
|
|
3734
|
+
this.notify();
|
|
3735
|
+
}
|
|
3736
|
+
getToasts() {
|
|
3737
|
+
return [...this.toasts];
|
|
3738
|
+
}
|
|
3739
|
+
};
|
|
3740
|
+
var toastService = ToastService.getInstance();
|
|
3741
|
+
var Toast = ({
|
|
3742
|
+
id,
|
|
3743
|
+
message,
|
|
3744
|
+
title,
|
|
3745
|
+
variant = "info",
|
|
3746
|
+
duration = 5e3,
|
|
3747
|
+
showCloseButton = true,
|
|
3748
|
+
onDismiss,
|
|
3749
|
+
className
|
|
3750
|
+
}) => {
|
|
3751
|
+
const [isRemoving, setIsRemoving] = (0, import_react8.useState)(false);
|
|
3752
|
+
const timerRef = (0, import_react8.useRef)();
|
|
3753
|
+
const handleDismiss = () => {
|
|
3754
|
+
setIsRemoving(true);
|
|
3755
|
+
setTimeout(() => onDismiss?.(id), 300);
|
|
3756
|
+
};
|
|
3757
|
+
(0, import_react8.useEffect)(() => {
|
|
3758
|
+
if (duration > 0) {
|
|
3759
|
+
timerRef.current = window.setTimeout(handleDismiss, duration);
|
|
3760
|
+
}
|
|
3761
|
+
return () => window.clearTimeout(timerRef.current);
|
|
3762
|
+
}, [duration]);
|
|
3763
|
+
const variantStyles = {
|
|
3764
|
+
success: "bg-green-100 border-green-500 text-green-800",
|
|
3765
|
+
error: "bg-red-100 border-red-500 text-red-800",
|
|
3766
|
+
warning: "bg-yellow-100 border-yellow-500 text-yellow-800",
|
|
3767
|
+
info: "bg-blue-100 border-blue-500 text-blue-800"
|
|
3768
|
+
};
|
|
3769
|
+
const icons = {
|
|
3770
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("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" }) }),
|
|
3771
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("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" }) }),
|
|
3772
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("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" }) }),
|
|
3773
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { className: "w-5 h-5", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("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" }) })
|
|
3774
|
+
};
|
|
3775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
3776
|
+
"div",
|
|
3777
|
+
{
|
|
3778
|
+
className: twMerge(
|
|
3779
|
+
"flex items-start p-4 mb-3 w-full max-w-xs rounded-md shadow-md border-l-4 transform transition-all duration-300",
|
|
3780
|
+
variantStyles[variant],
|
|
3781
|
+
isRemoving ? "translate-x-full opacity-0" : "translate-x-0 opacity-100",
|
|
3782
|
+
className
|
|
3783
|
+
),
|
|
3784
|
+
role: "alert",
|
|
3785
|
+
children: [
|
|
3786
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `flex-shrink-0 mr-3 text-${variant}-500`, children: icons[variant] }),
|
|
3787
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex-1", children: [
|
|
3788
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h3", { className: "font-medium text-sm", children: title }),
|
|
3789
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "text-sm", children: message })
|
|
3790
|
+
] }),
|
|
3791
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3792
|
+
"button",
|
|
3793
|
+
{
|
|
3794
|
+
type: "button",
|
|
3795
|
+
className: "ml-3 text-gray-400 hover:text-gray-900",
|
|
3796
|
+
onClick: handleDismiss,
|
|
3797
|
+
"aria-label": "Close",
|
|
3798
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M6 18L18 6M6 6l12 12" }) })
|
|
3799
|
+
}
|
|
3800
|
+
)
|
|
3801
|
+
]
|
|
3802
|
+
}
|
|
3803
|
+
);
|
|
3804
|
+
};
|
|
3805
|
+
var ToastContainer = ({
|
|
3806
|
+
position = "top-right",
|
|
3807
|
+
className
|
|
3808
|
+
}) => {
|
|
3809
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
3810
|
+
const [isMounted, setIsMounted] = (0, import_react8.useState)(false);
|
|
3811
|
+
const [toasts, setToasts] = (0, import_react8.useState)([]);
|
|
3812
|
+
(0, import_react8.useEffect)(() => {
|
|
3813
|
+
const container = document.createElement("div");
|
|
3814
|
+
container.id = "toast-root";
|
|
3815
|
+
container.className = "fixed z-50 p-4";
|
|
3816
|
+
document.body.appendChild(container);
|
|
3817
|
+
containerRef.current = container;
|
|
3818
|
+
setIsMounted(true);
|
|
3819
|
+
const unsubscribe = toastService.subscribe(setToasts);
|
|
3820
|
+
return () => {
|
|
3821
|
+
unsubscribe();
|
|
3822
|
+
container.remove();
|
|
3823
|
+
};
|
|
3824
|
+
}, []);
|
|
3825
|
+
const positionClasses = {
|
|
3826
|
+
"top-right": "top-0 right-0",
|
|
3827
|
+
"top-left": "top-0 left-0",
|
|
3828
|
+
"bottom-right": "bottom-0 right-0",
|
|
3829
|
+
"bottom-left": "bottom-0 left-0",
|
|
3830
|
+
"top-center": "top-0 left-1/2 -translate-x-1/2",
|
|
3831
|
+
"bottom-center": "bottom-0 left-1/2 -translate-x-1/2"
|
|
3832
|
+
};
|
|
3833
|
+
if (!isMounted || !containerRef.current) return null;
|
|
3834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3835
|
+
"div",
|
|
3836
|
+
{
|
|
3837
|
+
className: twMerge(
|
|
3838
|
+
"fixed z-50 p-4 flex flex-col items-end",
|
|
3839
|
+
positionClasses[position],
|
|
3840
|
+
className
|
|
3841
|
+
),
|
|
3842
|
+
children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Toast, { ...toast }, toast.id))
|
|
3843
|
+
}
|
|
3844
|
+
);
|
|
3845
|
+
};
|
|
3846
|
+
var useToast = () => {
|
|
3847
|
+
return {
|
|
3848
|
+
showToast: (toast) => toastService.showToast(toast),
|
|
3849
|
+
hideToast: (id) => toastService.hideToast(id),
|
|
3850
|
+
clearToasts: () => toastService.clearToasts()
|
|
3851
|
+
};
|
|
3852
|
+
};
|
|
3853
|
+
var ToastProvider = ({ position = "top-right", children }) => {
|
|
3854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
3855
|
+
children,
|
|
3856
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ToastContainer, { position })
|
|
3857
|
+
] });
|
|
3858
|
+
};
|
|
3859
|
+
Toast.displayName = "Toast";
|
|
3860
|
+
ToastContainer.displayName = "ToastContainer";
|
|
3215
3861
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3216
3862
|
0 && (module.exports = {
|
|
3217
3863
|
Avatar,
|
|
@@ -3223,9 +3869,18 @@ var MultiStep = ({ className, size, currentStep }) => {
|
|
|
3223
3869
|
Heading,
|
|
3224
3870
|
Input,
|
|
3225
3871
|
Link,
|
|
3872
|
+
Loading,
|
|
3873
|
+
Modal,
|
|
3226
3874
|
MultiStep,
|
|
3227
3875
|
RadioGroup,
|
|
3876
|
+
Skeleton,
|
|
3228
3877
|
Text,
|
|
3229
3878
|
TextArea,
|
|
3230
|
-
TextInput
|
|
3879
|
+
TextInput,
|
|
3880
|
+
Toast,
|
|
3881
|
+
ToastContainer,
|
|
3882
|
+
ToastProvider,
|
|
3883
|
+
Toggle,
|
|
3884
|
+
toastService,
|
|
3885
|
+
useToast
|
|
3231
3886
|
});
|