@insforge/react 0.1.1 → 0.1.2
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/atoms.d.mts +366 -0
- package/dist/atoms.d.ts +366 -0
- package/dist/atoms.js +689 -0
- package/dist/atoms.js.map +1 -0
- package/dist/atoms.mjs +674 -0
- package/dist/atoms.mjs.map +1 -0
- package/dist/forms.d.mts +185 -0
- package/dist/forms.d.ts +185 -0
- package/dist/forms.js +987 -0
- package/dist/forms.js.map +1 -0
- package/dist/forms.mjs +981 -0
- package/dist/forms.mjs.map +1 -0
- package/dist/index-C9pisdfX.d.mts +404 -0
- package/dist/index-C9pisdfX.d.ts +404 -0
- package/dist/index.d.mts +6 -941
- package/dist/index.d.ts +6 -941
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -14
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/atoms.mjs
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
4
|
+
import { AlertTriangle, Check, EyeOff, Eye, Loader2, CircleCheck } from 'lucide-react';
|
|
5
|
+
import { useState, useRef } from 'react';
|
|
6
|
+
|
|
7
|
+
function AuthBranding() {
|
|
8
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-[#FAFAFA] px-2 py-4 flex flex-row justify-center items-center gap-1", children: [
|
|
9
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-black font-manrope", children: "Secured by" }),
|
|
10
|
+
/* @__PURE__ */ jsx("a", { href: "https://insforge.dev", target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxs("svg", { width: "83", height: "20", viewBox: "0 0 83 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
11
|
+
/* @__PURE__ */ jsx(
|
|
12
|
+
"path",
|
|
13
|
+
{
|
|
14
|
+
d: "M2.16783 8.46797C1.9334 8.23325 1.9334 7.85269 2.16783 7.61797L8.11049 1.66797L16.6 1.66797L6.41259 11.868C6.17815 12.1027 5.79807 12.1027 5.56363 11.868L2.16783 8.46797Z",
|
|
15
|
+
fill: "url(#paint0_linear_2976_9475)"
|
|
16
|
+
}
|
|
17
|
+
),
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
"path",
|
|
20
|
+
{
|
|
21
|
+
d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
|
|
22
|
+
fill: "url(#paint1_linear_2976_9475)"
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
"path",
|
|
27
|
+
{
|
|
28
|
+
d: "M67.5439 6.48828C68.2894 6.48828 68.9145 6.67064 69.418 7.03516C69.5229 7.10943 69.6214 7.1907 69.7158 7.27637V6.70703H71.248V14.959C71.248 15.1583 71.2381 15.3485 71.2188 15.5283C71.2042 15.7129 71.1774 15.8925 71.1387 16.0674C71.0225 16.5776 70.7998 16.9957 70.4707 17.3213C70.1415 17.6518 69.7321 17.8972 69.2432 18.0576C68.7592 18.2179 68.2222 18.2988 67.6318 18.2988C67.1962 18.2988 66.7768 18.2308 66.375 18.0947C65.9782 17.9587 65.6202 17.7614 65.3008 17.5039C64.9813 17.2512 64.7199 16.9446 64.5166 16.585L66.1289 15.7832C66.2789 16.0698 66.4888 16.2819 66.7598 16.418C67.0356 16.5589 67.3289 16.6289 67.6387 16.6289C68.0016 16.6289 68.3258 16.5628 68.6113 16.4316C68.8969 16.3053 69.1176 16.116 69.2725 15.8633C69.4321 15.6155 69.5077 15.3047 69.498 14.9307V14.1797C69.4665 14.2037 69.4359 14.229 69.4033 14.252C68.8855 14.6164 68.2441 14.7988 67.4795 14.7988C66.7582 14.7988 66.1281 14.6165 65.5908 14.252C65.0537 13.8875 64.637 13.3915 64.3418 12.7646C64.0467 12.1378 63.8994 11.4307 63.8994 10.6436C63.8994 9.84651 64.0465 9.13673 64.3418 8.51465C64.6419 7.88768 65.0663 7.39481 65.6133 7.03516C66.1601 6.67077 66.8036 6.48836 67.5439 6.48828ZM37.5 6.48828C38.1099 6.48828 38.6496 6.58294 39.1191 6.77246C39.5935 6.96201 39.9762 7.2321 40.2666 7.58203C40.5569 7.93184 40.7359 8.34227 40.8037 8.81348L39.0176 9.13477C38.974 8.79951 38.8218 8.53424 38.5605 8.33984C38.304 8.14547 37.96 8.03605 37.5293 8.01172C37.1178 7.98742 36.7859 8.05051 36.5342 8.20117C36.2825 8.34698 36.1562 8.55398 36.1562 8.82129C36.1563 8.97184 36.208 9.10017 36.3096 9.20703C36.4112 9.31394 36.614 9.42141 36.9189 9.52832C37.2288 9.63524 37.6889 9.76635 38.2988 9.92188C38.9232 10.0823 39.4222 10.2666 39.7949 10.4756C40.1722 10.6796 40.4428 10.9254 40.6074 11.2119C40.7768 11.4987 40.8623 11.8466 40.8623 12.2549C40.8623 13.047 40.574 13.6691 39.998 14.1211C39.4268 14.5731 38.6348 14.7988 37.623 14.7988C36.6551 14.7988 35.8687 14.5799 35.2637 14.1426C34.6587 13.7052 34.2909 13.0908 34.1602 12.2988L35.9463 12.0215C36.0383 12.4102 36.2411 12.7169 36.5557 12.9404C36.8703 13.164 37.2678 13.2754 37.7471 13.2754C38.1681 13.2754 38.4922 13.1926 38.7197 13.0273C38.9521 12.8572 39.0684 12.6266 39.0684 12.335C39.0684 12.1552 39.0245 12.0122 38.9375 11.9053C38.8552 11.7935 38.6713 11.686 38.3857 11.584C38.1001 11.4819 37.6618 11.3528 37.0713 11.1973C36.4131 11.0223 35.8901 10.8359 35.5029 10.6367C35.1158 10.4327 34.8374 10.192 34.668 9.91504C34.4985 9.63801 34.4141 9.30188 34.4141 8.9082C34.4141 8.41746 34.5423 7.98943 34.7988 7.625C35.0553 7.26073 35.4135 6.98146 35.873 6.78711C36.3329 6.58784 36.8755 6.48828 37.5 6.48828ZM53.3047 6.48828C54.0937 6.48828 54.7815 6.66572 55.3672 7.02051C55.9527 7.37528 56.4072 7.86634 56.7314 8.49316C57.0558 9.11525 57.2187 9.83193 57.2188 10.6436C57.2188 11.46 57.0537 12.1817 56.7246 12.8086C56.4003 13.4307 55.9451 13.9196 55.3594 14.2744C54.7737 14.6242 54.0888 14.7988 53.3047 14.7988C52.5205 14.7988 51.8357 14.6214 51.25 14.2666C50.6643 13.9118 50.2091 13.4238 49.8848 12.8018C49.5653 12.1748 49.4053 11.4552 49.4053 10.6436C49.4053 9.81735 49.5703 9.09279 49.8994 8.4707C50.2286 7.8488 50.6859 7.36255 51.2715 7.0127C51.8572 6.66281 52.5351 6.48828 53.3047 6.48828ZM76.7471 6.48828C77.5603 6.48828 78.25 6.68053 78.8164 7.06445C79.3876 7.44351 79.812 7.97991 80.0879 8.6748C80.3638 9.36976 80.4672 10.189 80.3994 11.1318H74.7256C74.7843 11.6972 74.949 12.1516 75.2227 12.4951C75.5711 12.9325 76.0792 13.1513 76.7471 13.1514C77.1779 13.1514 77.5486 13.0567 77.8584 12.8672C78.173 12.6728 78.4146 12.3928 78.584 12.0283L80.3125 12.5537C80.0124 13.2633 79.5473 13.8153 78.918 14.209C78.2936 14.6025 77.6036 14.7988 76.8486 14.7988C76.0549 14.7988 75.358 14.6263 74.7578 14.2812C74.1576 13.9362 73.6875 13.458 73.3486 12.8457C73.0147 12.2334 72.8477 11.5284 72.8477 10.7314C72.8477 9.87126 73.0127 9.12495 73.3418 8.49316C73.671 7.85651 74.1282 7.36263 74.7139 7.0127C75.2995 6.6628 75.9775 6.48832 76.7471 6.48828ZM23.3301 14.5801H21.5801V4.08203H23.3301V14.5801ZM29.6152 6.48047C30.1959 6.48052 30.6753 6.5781 31.0527 6.77246C31.4301 6.96681 31.7305 7.21443 31.9531 7.51562C32.1758 7.81695 32.3398 8.13831 32.4463 8.47852C32.5528 8.81873 32.6213 9.14205 32.6504 9.44824C32.6843 9.74946 32.7012 9.99508 32.7012 10.1846V14.5801H30.9287V10.7891C30.9287 10.5413 30.9118 10.2669 30.8779 9.96582C30.844 9.66449 30.7645 9.37469 30.6387 9.09766C30.5177 8.81592 30.3337 8.58503 30.0869 8.40527C29.8449 8.22551 29.5157 8.13579 29.0996 8.13574C28.8769 8.13574 28.6563 8.17221 28.4385 8.24512C28.2206 8.31802 28.0219 8.4442 27.8428 8.62402C27.6685 8.79899 27.5284 9.04249 27.4219 9.35352C27.3154 9.65965 27.2617 10.0532 27.2617 10.5342V14.5801H25.4902V6.70703H27.0518V7.58301C27.2521 7.34675 27.486 7.14172 27.7559 6.96973C28.2593 6.64409 28.8794 6.48047 29.6152 6.48047ZM48.748 5.83887H44.2021V8.45605H47.876V10.2061H44.2021V14.5801H42.4521V4.08203H48.748V5.83887ZM62.5137 6.67773C62.7606 6.65829 63.001 6.66815 63.2334 6.70703V8.34766C63.001 8.27961 62.7317 8.25695 62.4268 8.28125C62.1267 8.30557 61.8553 8.39134 61.6133 8.53711C61.3715 8.66829 61.1733 8.83606 61.0186 9.04004C60.8686 9.24404 60.7572 9.47701 60.6846 9.73926C60.612 9.99685 60.5752 10.2768 60.5752 10.5781V14.5801H58.8184V6.70703H60.3652V7.96582C60.4243 7.85986 60.4888 7.75824 60.5605 7.66211C60.7251 7.4434 60.9219 7.26302 61.1494 7.12207C61.3429 6.99098 61.5559 6.88926 61.7881 6.81641C62.0251 6.73869 62.267 6.69235 62.5137 6.67773ZM67.8057 8.0625C67.3362 8.06252 66.9485 8.17982 66.6436 8.41309C66.3389 8.64144 66.1139 8.95232 65.9688 9.3457C65.8235 9.7345 65.751 10.1673 65.751 10.6436C65.751 11.1247 65.8215 11.5624 65.9619 11.9561C66.1071 12.3447 66.3269 12.6535 66.6221 12.8818C66.9174 13.1103 67.293 13.2246 67.748 13.2246C68.2174 13.2246 68.5953 13.1171 68.8809 12.9033C69.1711 12.6846 69.3811 12.3808 69.5117 11.9922C69.6473 11.6034 69.7158 11.1539 69.7158 10.6436C69.7158 10.1284 69.6473 9.67886 69.5117 9.29492C69.381 8.90617 69.1753 8.60445 68.8945 8.39062C68.6138 8.17213 68.2508 8.0625 67.8057 8.0625ZM53.3047 8.13574C52.8351 8.13574 52.4475 8.24222 52.1426 8.45605C51.8425 8.66504 51.6198 8.95977 51.4746 9.33887C51.3295 9.71303 51.2568 10.148 51.2568 10.6436C51.2568 11.4066 51.4288 12.0168 51.7725 12.4736C52.121 12.9256 52.6318 13.1514 53.3047 13.1514C54.0017 13.1514 54.5196 12.9177 54.8584 12.4512C55.1971 11.9846 55.3672 11.3822 55.3672 10.6436C55.3672 9.8807 55.1951 9.27324 54.8516 8.82129C54.5079 8.36444 53.9921 8.13575 53.3047 8.13574ZM76.8203 8.02637C76.1039 8.02637 75.5712 8.25013 75.2227 8.69727C74.9987 8.98144 74.8476 9.35094 74.7676 9.80566H78.6221C78.5589 9.29301 78.4236 8.89686 78.2139 8.61719C77.9186 8.22359 77.4543 8.02645 76.8203 8.02637Z",
|
|
29
|
+
fill: "black"
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
33
|
+
/* @__PURE__ */ jsxs(
|
|
34
|
+
"linearGradient",
|
|
35
|
+
{
|
|
36
|
+
id: "paint0_linear_2976_9475",
|
|
37
|
+
x1: "1.85883",
|
|
38
|
+
y1: "1.92425",
|
|
39
|
+
x2: "24.3072",
|
|
40
|
+
y2: "9.64016",
|
|
41
|
+
gradientUnits: "userSpaceOnUse",
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ jsx("stop", {}),
|
|
44
|
+
/* @__PURE__ */ jsx("stop", { offset: "1", stopOpacity: "0.4" })
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ jsxs(
|
|
49
|
+
"linearGradient",
|
|
50
|
+
{
|
|
51
|
+
id: "paint1_linear_2976_9475",
|
|
52
|
+
x1: "25.6475",
|
|
53
|
+
y1: "8.65468",
|
|
54
|
+
x2: "10.7901",
|
|
55
|
+
y2: "8.65468",
|
|
56
|
+
gradientUnits: "userSpaceOnUse",
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsx("stop", {}),
|
|
59
|
+
/* @__PURE__ */ jsx("stop", { offset: "1", stopOpacity: "0.4" })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] })
|
|
64
|
+
] }) })
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
function cn(...inputs) {
|
|
68
|
+
return twMerge(clsx(inputs));
|
|
69
|
+
}
|
|
70
|
+
function AuthContainer({ children, appearance = {} }) {
|
|
71
|
+
return /* @__PURE__ */ jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: cn(
|
|
75
|
+
"w-full max-w-[400px] rounded-xl overflow-hidden shadow-lg",
|
|
76
|
+
appearance.containerClassName
|
|
77
|
+
),
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx("div", { className: cn(
|
|
80
|
+
"bg-white p-6 flex flex-col justify-center items-stretch gap-6",
|
|
81
|
+
appearance.cardClassName
|
|
82
|
+
), children }),
|
|
83
|
+
/* @__PURE__ */ jsx(AuthBranding, {})
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
function AuthHeader({
|
|
89
|
+
title,
|
|
90
|
+
subtitle,
|
|
91
|
+
appearance = {}
|
|
92
|
+
}) {
|
|
93
|
+
return /* @__PURE__ */ jsxs("div", { className: cn(
|
|
94
|
+
"flex flex-col justify-start items-start gap-2",
|
|
95
|
+
appearance.containerClassName
|
|
96
|
+
), children: [
|
|
97
|
+
/* @__PURE__ */ jsx("h1", { className: cn(
|
|
98
|
+
"text-2xl font-semibold text-black leading-8",
|
|
99
|
+
appearance.titleClassName
|
|
100
|
+
), children: title }),
|
|
101
|
+
subtitle && /* @__PURE__ */ jsx("p", { className: cn(
|
|
102
|
+
"text-sm font-normal text-[#828282] leading-6",
|
|
103
|
+
appearance.subtitleClassName
|
|
104
|
+
), children: subtitle })
|
|
105
|
+
] });
|
|
106
|
+
}
|
|
107
|
+
function AuthErrorBanner({ error, className }) {
|
|
108
|
+
if (!error) return null;
|
|
109
|
+
return /* @__PURE__ */ jsxs(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
className: cn(
|
|
113
|
+
"flex items-center gap-2 mb-4 pl-3 py-2 pr-2 bg-red-50 border-2 border-red-600 rounded",
|
|
114
|
+
className
|
|
115
|
+
),
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ jsx(AlertTriangle, { className: "w-6 h-6 text-red-500 flex-shrink-0" }),
|
|
118
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-red-600 flex-1", children: error })
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
function AuthFormField({
|
|
124
|
+
label,
|
|
125
|
+
id,
|
|
126
|
+
appearance = {},
|
|
127
|
+
...props
|
|
128
|
+
}) {
|
|
129
|
+
return /* @__PURE__ */ jsxs("div", { className: cn(
|
|
130
|
+
"flex flex-col justify-center items-stretch gap-1",
|
|
131
|
+
appearance.containerClassName
|
|
132
|
+
), children: [
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
"label",
|
|
135
|
+
{
|
|
136
|
+
htmlFor: id,
|
|
137
|
+
className: cn(
|
|
138
|
+
"text-sm font-normal text-black leading-6",
|
|
139
|
+
appearance.labelClassName
|
|
140
|
+
),
|
|
141
|
+
children: label
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
"input",
|
|
146
|
+
{
|
|
147
|
+
id,
|
|
148
|
+
className: cn(
|
|
149
|
+
"w-full flex items-center gap-2 self-stretch",
|
|
150
|
+
"pl-3 pr-2 py-2 rounded-sm border border-[#D4D4D4] bg-white",
|
|
151
|
+
"text-sm font-normal leading-5",
|
|
152
|
+
"placeholder:text-[#A3A3A3] placeholder:font-sm placeholder:font-normal",
|
|
153
|
+
"focus:outline-none focus:border-black",
|
|
154
|
+
appearance.inputClassName
|
|
155
|
+
),
|
|
156
|
+
...props
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
function AuthPasswordStrengthIndicator({
|
|
162
|
+
password,
|
|
163
|
+
config,
|
|
164
|
+
appearance = {}
|
|
165
|
+
}) {
|
|
166
|
+
const requirements = createRequirements(config);
|
|
167
|
+
return /* @__PURE__ */ jsx(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
className: cn("mt-3 flex flex-col gap-3", appearance.containerClassName),
|
|
171
|
+
children: requirements.map((req) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
172
|
+
/* @__PURE__ */ jsx(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: cn(
|
|
176
|
+
"flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",
|
|
177
|
+
req.test(password) ? "bg-[#059669] border-transparent" : "border-neutral-400 bg-white"
|
|
178
|
+
),
|
|
179
|
+
children: req.test(password) && /* @__PURE__ */ jsx(Check, { className: "w-3 h-3 text-white" })
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
"span",
|
|
184
|
+
{
|
|
185
|
+
className: cn(
|
|
186
|
+
"text-sm font-normal leading-5 text-[#525252]",
|
|
187
|
+
appearance.requirementClassName
|
|
188
|
+
),
|
|
189
|
+
children: req.label
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] }, req.label))
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
function createRequirements(config) {
|
|
197
|
+
const requirements = [];
|
|
198
|
+
const minLength = config.passwordMinLength;
|
|
199
|
+
const requireUppercase = config.requireUppercase;
|
|
200
|
+
const requireLowercase = config.requireLowercase;
|
|
201
|
+
const requireNumber = config.requireNumber;
|
|
202
|
+
const requireSpecialChar = config.requireSpecialChar;
|
|
203
|
+
if (requireUppercase) {
|
|
204
|
+
requirements.push({
|
|
205
|
+
label: "At least 1 Uppercase letter",
|
|
206
|
+
test: (pwd) => /[A-Z]/.test(pwd)
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (requireLowercase) {
|
|
210
|
+
requirements.push({
|
|
211
|
+
label: "At least 1 Lowercase letter",
|
|
212
|
+
test: (pwd) => /[a-z]/.test(pwd)
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (requireNumber) {
|
|
216
|
+
requirements.push({
|
|
217
|
+
label: "At least 1 Number",
|
|
218
|
+
test: (pwd) => /\d/.test(pwd)
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (requireSpecialChar) {
|
|
222
|
+
requirements.push({
|
|
223
|
+
label: "Special character (e.g. !?<>@#$%)",
|
|
224
|
+
test: (pwd) => /[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/.test(pwd)
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
requirements.push({
|
|
228
|
+
label: `${minLength} characters or more`,
|
|
229
|
+
test: (pwd) => pwd.length >= minLength
|
|
230
|
+
});
|
|
231
|
+
return requirements;
|
|
232
|
+
}
|
|
233
|
+
function validatePasswordStrength(password, config) {
|
|
234
|
+
if (!password) return false;
|
|
235
|
+
const requirements = createRequirements(config);
|
|
236
|
+
return requirements.every((req) => req.test(password));
|
|
237
|
+
}
|
|
238
|
+
function AuthPasswordField({
|
|
239
|
+
label,
|
|
240
|
+
id,
|
|
241
|
+
showStrengthIndicator = false,
|
|
242
|
+
emailAuthConfig,
|
|
243
|
+
forgotPasswordLink,
|
|
244
|
+
value,
|
|
245
|
+
appearance = {},
|
|
246
|
+
onFocus,
|
|
247
|
+
...props
|
|
248
|
+
}) {
|
|
249
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
250
|
+
const [showStrength, setShowStrength] = useState(false);
|
|
251
|
+
const handleFocus = (e) => {
|
|
252
|
+
if (showStrengthIndicator) {
|
|
253
|
+
setShowStrength(true);
|
|
254
|
+
}
|
|
255
|
+
onFocus?.(e);
|
|
256
|
+
};
|
|
257
|
+
return /* @__PURE__ */ jsxs(
|
|
258
|
+
"div",
|
|
259
|
+
{
|
|
260
|
+
className: cn(
|
|
261
|
+
"flex flex-col justify-center items-stretch gap-1",
|
|
262
|
+
appearance.containerClassName
|
|
263
|
+
),
|
|
264
|
+
children: [
|
|
265
|
+
(label || forgotPasswordLink) && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
266
|
+
/* @__PURE__ */ jsx(
|
|
267
|
+
"label",
|
|
268
|
+
{
|
|
269
|
+
htmlFor: id,
|
|
270
|
+
className: cn(
|
|
271
|
+
"text-sm font-normal text-black leading-6",
|
|
272
|
+
appearance.labelClassName
|
|
273
|
+
),
|
|
274
|
+
children: label
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
forgotPasswordLink && /* @__PURE__ */ jsx(
|
|
278
|
+
"a",
|
|
279
|
+
{
|
|
280
|
+
href: forgotPasswordLink.href,
|
|
281
|
+
className: "text-right text-sm font-normal text-[#737373] leading-6",
|
|
282
|
+
children: forgotPasswordLink.text || "Forget Password?"
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
] }),
|
|
286
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
287
|
+
/* @__PURE__ */ jsx(
|
|
288
|
+
"input",
|
|
289
|
+
{
|
|
290
|
+
id,
|
|
291
|
+
type: showPassword ? "text" : "password",
|
|
292
|
+
className: cn(
|
|
293
|
+
"w-full flex items-center gap-2 self-stretch",
|
|
294
|
+
"pl-3 py-2 pr-8 rounded border border-[#D4D4D4] bg-white",
|
|
295
|
+
"text-sm font-normal leading-5",
|
|
296
|
+
"placeholder:text-[#A3A3A3] placeholder:font-sm placeholder:font-normal",
|
|
297
|
+
"focus:outline-none focus:border-black",
|
|
298
|
+
appearance.inputClassName
|
|
299
|
+
),
|
|
300
|
+
value,
|
|
301
|
+
onFocus: handleFocus,
|
|
302
|
+
...props
|
|
303
|
+
}
|
|
304
|
+
),
|
|
305
|
+
/* @__PURE__ */ jsx(
|
|
306
|
+
"button",
|
|
307
|
+
{
|
|
308
|
+
type: "button",
|
|
309
|
+
onClick: () => setShowPassword(!showPassword),
|
|
310
|
+
className: "absolute right-2 top-1/2 -translate-y-1/2 bg-transparent border-none text-[#A6A6A6] cursor-pointer transition-colors hover:text-gray-600 flex items-center justify-center",
|
|
311
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
312
|
+
children: showPassword ? /* @__PURE__ */ jsx(EyeOff, { size: 20 }) : /* @__PURE__ */ jsx(Eye, { size: 20 })
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
] }),
|
|
316
|
+
showStrengthIndicator && showStrength && /* @__PURE__ */ jsx(
|
|
317
|
+
AuthPasswordStrengthIndicator,
|
|
318
|
+
{
|
|
319
|
+
password: String(value || ""),
|
|
320
|
+
config: emailAuthConfig
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
function AuthSubmitButton({
|
|
328
|
+
children,
|
|
329
|
+
isLoading = false,
|
|
330
|
+
confirmed = false,
|
|
331
|
+
disabled = false,
|
|
332
|
+
className
|
|
333
|
+
}) {
|
|
334
|
+
return /* @__PURE__ */ jsxs(
|
|
335
|
+
"button",
|
|
336
|
+
{
|
|
337
|
+
type: "submit",
|
|
338
|
+
className: cn(
|
|
339
|
+
"rounded-sm bg-black w-full flex mt-4 px-4 py-2",
|
|
340
|
+
"justify-center items-center gap-2.5 self-stretch",
|
|
341
|
+
"text-white font-semibold font-manrope text-base leading-normal",
|
|
342
|
+
"border-none cursor-pointer transition-colors",
|
|
343
|
+
"hover:bg-gray-800",
|
|
344
|
+
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
345
|
+
className
|
|
346
|
+
),
|
|
347
|
+
disabled: disabled || isLoading || confirmed,
|
|
348
|
+
children: [
|
|
349
|
+
isLoading && /* @__PURE__ */ jsx(Loader2, { className: "w-5 h-5 animate-spin", size: 20 }),
|
|
350
|
+
confirmed && /* @__PURE__ */ jsx(CircleCheck, { className: "w-5 h-5", size: 20 }),
|
|
351
|
+
children
|
|
352
|
+
]
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
function AuthLink({ text, linkText, href, appearance = {} }) {
|
|
357
|
+
return /* @__PURE__ */ jsxs("p", { className: cn(
|
|
358
|
+
"text-center text-sm font-normal text-[#828282] leading-6",
|
|
359
|
+
appearance.containerClassName
|
|
360
|
+
), children: [
|
|
361
|
+
text,
|
|
362
|
+
" ",
|
|
363
|
+
/* @__PURE__ */ jsx(
|
|
364
|
+
"a",
|
|
365
|
+
{
|
|
366
|
+
href,
|
|
367
|
+
className: cn(
|
|
368
|
+
"text-sm font-medium text-black leading-6",
|
|
369
|
+
appearance.linkClassName
|
|
370
|
+
),
|
|
371
|
+
children: linkText
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
] });
|
|
375
|
+
}
|
|
376
|
+
function AuthDivider({ text = "or", className }) {
|
|
377
|
+
return /* @__PURE__ */ jsx("div", { className: cn(
|
|
378
|
+
"flex justify-center items-center gap-6 self-stretch",
|
|
379
|
+
"before:content-[''] before:flex-1 before:h-px before:bg-[#E5E5E5]",
|
|
380
|
+
"after:content-[''] after:flex-1 after:h-px after:bg-[#E5E5E5]",
|
|
381
|
+
className
|
|
382
|
+
), children: /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold font-manrope text-[#A3A3A3] leading-normal", children: text }) });
|
|
383
|
+
}
|
|
384
|
+
var oauthProviders = {
|
|
385
|
+
google: {
|
|
386
|
+
name: "Google",
|
|
387
|
+
svg: /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
388
|
+
/* @__PURE__ */ jsx(
|
|
389
|
+
"path",
|
|
390
|
+
{
|
|
391
|
+
d: "M17.64 9.20443C17.64 8.56625 17.5827 7.95262 17.4764 7.36353H9V10.8449H13.8436C13.635 11.9699 13.0009 12.9231 12.0477 13.5613V15.8194H14.9564C16.6582 14.2526 17.64 11.9453 17.64 9.20443Z",
|
|
392
|
+
fill: "#4285F4"
|
|
393
|
+
}
|
|
394
|
+
),
|
|
395
|
+
/* @__PURE__ */ jsx(
|
|
396
|
+
"path",
|
|
397
|
+
{
|
|
398
|
+
d: "M8.99976 18C11.4298 18 13.467 17.1941 14.9561 15.8195L12.0475 13.5613C11.2416 14.1013 10.2107 14.4204 8.99976 14.4204C6.65567 14.4204 4.67158 12.8372 3.96385 10.71H0.957031V13.0418C2.43794 15.9831 5.48158 18 8.99976 18Z",
|
|
399
|
+
fill: "#34A853"
|
|
400
|
+
}
|
|
401
|
+
),
|
|
402
|
+
/* @__PURE__ */ jsx(
|
|
403
|
+
"path",
|
|
404
|
+
{
|
|
405
|
+
d: "M3.96409 10.7098C3.78409 10.1698 3.68182 9.59301 3.68182 8.99983C3.68182 8.40664 3.78409 7.82983 3.96409 7.28983V4.95801H0.957273C0.347727 6.17301 0 7.54755 0 8.99983C0 10.4521 0.347727 11.8266 0.957273 13.0416L3.96409 10.7098Z",
|
|
406
|
+
fill: "#FBBC05"
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
/* @__PURE__ */ jsx(
|
|
410
|
+
"path",
|
|
411
|
+
{
|
|
412
|
+
d: "M8.99976 3.57955C10.3211 3.57955 11.5075 4.03364 12.4402 4.92545L15.0216 2.34409C13.4629 0.891818 11.4257 0 8.99976 0C5.48158 0 2.43794 2.01682 0.957031 4.95818L3.96385 7.29C4.67158 5.16273 6.65567 3.57955 8.99976 3.57955Z",
|
|
413
|
+
fill: "#EA4335"
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
] }),
|
|
417
|
+
className: "hover:bg-blue-50"
|
|
418
|
+
},
|
|
419
|
+
github: {
|
|
420
|
+
name: "GitHub",
|
|
421
|
+
svg: /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx(
|
|
422
|
+
"path",
|
|
423
|
+
{
|
|
424
|
+
fillRule: "evenodd",
|
|
425
|
+
clipRule: "evenodd",
|
|
426
|
+
d: "M9 0C4.0275 0 0 4.13211 0 9.22838C0 13.3065 2.5785 16.7648 6.15375 17.9841C6.60375 18.0709 6.76875 17.7853 6.76875 17.5403C6.76875 17.3212 6.76125 16.7405 6.7575 15.9712C4.254 16.5277 3.726 14.7332 3.726 14.7332C3.3165 13.6681 2.72475 13.3832 2.72475 13.3832C1.9095 12.8111 2.78775 12.8229 2.78775 12.8229C3.6915 12.887 4.16625 13.7737 4.16625 13.7737C4.96875 15.1847 6.273 14.777 6.7875 14.5414C6.8685 13.9443 7.10025 13.5381 7.3575 13.3073C5.35875 13.0764 3.258 12.2829 3.258 8.74868C3.258 7.74377 3.60675 6.92392 4.18425 6.28123C4.083 6.04805 3.77925 5.10916 4.263 3.83423C4.263 3.83423 5.01675 3.58633 6.738 4.78364C7.458 4.57864 8.223 4.47614 8.988 4.47177C9.753 4.47614 10.518 4.57864 11.238 4.78364C12.948 3.58633 13.7017 3.83423 13.7017 3.83423C14.1855 5.10916 13.8818 6.04805 13.7917 6.28123C14.3655 6.92392 14.7142 7.74377 14.7142 8.74868C14.7142 12.2923 12.6105 13.0725 10.608 13.2995C10.923 13.5765 11.2155 14.1423 11.2155 15.0071C11.2155 16.242 11.205 17.2344 11.205 17.5341C11.205 17.7759 11.3625 18.0647 11.823 17.9723C15.4237 16.7609 18 13.3002 18 9.22838C18 4.13211 13.9703 0 9 0Z",
|
|
427
|
+
fill: "currentColor"
|
|
428
|
+
}
|
|
429
|
+
) }),
|
|
430
|
+
className: "hover:bg-gray-50"
|
|
431
|
+
},
|
|
432
|
+
discord: {
|
|
433
|
+
name: "Discord",
|
|
434
|
+
svg: /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 127.14 96.36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx(
|
|
435
|
+
"path",
|
|
436
|
+
{
|
|
437
|
+
d: "M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z",
|
|
438
|
+
fill: "#5865F2"
|
|
439
|
+
}
|
|
440
|
+
) }),
|
|
441
|
+
className: "hover:bg-indigo-50"
|
|
442
|
+
},
|
|
443
|
+
apple: {
|
|
444
|
+
name: "Apple",
|
|
445
|
+
svg: /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 18 22", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx(
|
|
446
|
+
"path",
|
|
447
|
+
{
|
|
448
|
+
d: "M17.769 16.867c-.343.78-.507 1.129-1.014 1.82-.701.961-1.691 2.156-2.917 2.166-1.088.01-1.378-.706-2.87-.697-1.491.008-1.807.708-2.896.697-1.226-.01-2.156-1.09-2.858-2.051C2.66 16.005 1.51 11.58 3.104 8.62c1.12-2.08 2.892-3.397 4.557-3.407 1.343-.009 2.19.708 3.297.708 1.077 0 1.734-.71 3.287-.71 1.172 0 2.781.955 3.799 2.594-3.338 1.832-2.794 6.604.725 8.062zM12.268.695c.856 1.11.72 2.15.694 2.635-.923-.068-2.04-.638-2.68-1.43C9.474.76 9.35-.301 9.402-.8c.977.03 2.04.633 2.866 1.495z",
|
|
449
|
+
fill: "currentColor"
|
|
450
|
+
}
|
|
451
|
+
) }),
|
|
452
|
+
className: "hover:bg-gray-50"
|
|
453
|
+
},
|
|
454
|
+
microsoft: {
|
|
455
|
+
name: "Microsoft",
|
|
456
|
+
svg: /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 23 23", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
457
|
+
/* @__PURE__ */ jsx("path", { d: "M0 0h11v11H0z", fill: "#F25022" }),
|
|
458
|
+
/* @__PURE__ */ jsx("path", { d: "M12 0h11v11H12z", fill: "#7FBA00" }),
|
|
459
|
+
/* @__PURE__ */ jsx("path", { d: "M0 12h11v11H0z", fill: "#00A4EF" }),
|
|
460
|
+
/* @__PURE__ */ jsx("path", { d: "M12 12h11v11H12z", fill: "#FFB900" })
|
|
461
|
+
] }),
|
|
462
|
+
className: "hover:bg-blue-50"
|
|
463
|
+
},
|
|
464
|
+
facebook: {
|
|
465
|
+
name: "Facebook",
|
|
466
|
+
svg: /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx(
|
|
467
|
+
"path",
|
|
468
|
+
{
|
|
469
|
+
d: "M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z",
|
|
470
|
+
fill: "#1877F2"
|
|
471
|
+
}
|
|
472
|
+
) }),
|
|
473
|
+
className: "hover:bg-blue-50"
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
function getProviderConfig(provider) {
|
|
477
|
+
return oauthProviders[provider] || null;
|
|
478
|
+
}
|
|
479
|
+
function AuthOAuthButton({
|
|
480
|
+
provider,
|
|
481
|
+
onClick,
|
|
482
|
+
disabled,
|
|
483
|
+
loading,
|
|
484
|
+
displayMode = "full",
|
|
485
|
+
style,
|
|
486
|
+
className
|
|
487
|
+
}) {
|
|
488
|
+
const config = getProviderConfig(provider);
|
|
489
|
+
if (!config) {
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
const getButtonText = () => {
|
|
493
|
+
if (loading) return "Authenticating...";
|
|
494
|
+
if (displayMode === "full") return `Continue with ${config.name}`;
|
|
495
|
+
if (displayMode === "short") return config.name;
|
|
496
|
+
return "";
|
|
497
|
+
};
|
|
498
|
+
return /* @__PURE__ */ jsxs(
|
|
499
|
+
"button",
|
|
500
|
+
{
|
|
501
|
+
type: "button",
|
|
502
|
+
onClick: () => onClick(provider),
|
|
503
|
+
className: cn(
|
|
504
|
+
"flex w-full h-9 px-3 py-2",
|
|
505
|
+
"flex-row justify-center items-center gap-3",
|
|
506
|
+
"rounded-md border border-[#E4E4E7] bg-white",
|
|
507
|
+
"shadow-[0_1px_2px_0_rgba(0,0,0,0.10)]",
|
|
508
|
+
"text-[#09090B] text-center text-sm font-medium leading-5",
|
|
509
|
+
"cursor-pointer transition-all duration-200",
|
|
510
|
+
"hover:bg-[#f9fafb] hover:border-[#9ca3af]",
|
|
511
|
+
"disabled:opacity-60 disabled:cursor-not-allowed",
|
|
512
|
+
displayMode === "full" && "justify-center",
|
|
513
|
+
displayMode === "short" && "justify-center px-2 gap-2",
|
|
514
|
+
displayMode === "icon" && "justify-center gap-0",
|
|
515
|
+
className
|
|
516
|
+
),
|
|
517
|
+
disabled: disabled || loading,
|
|
518
|
+
style,
|
|
519
|
+
children: [
|
|
520
|
+
loading ? /* @__PURE__ */ jsx(Loader2, { className: "w-[18px] h-[18px] animate-spin", size: 18 }) : /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center flex-shrink-0", children: config.svg }),
|
|
521
|
+
getButtonText() && /* @__PURE__ */ jsx("span", { children: getButtonText() })
|
|
522
|
+
]
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
function AuthOAuthProviders({
|
|
527
|
+
providers,
|
|
528
|
+
onClick,
|
|
529
|
+
disabled,
|
|
530
|
+
loading,
|
|
531
|
+
appearance = {}
|
|
532
|
+
}) {
|
|
533
|
+
if (!providers || providers.length === 0) {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
const count = providers.length;
|
|
537
|
+
const getDisplayMode = () => {
|
|
538
|
+
if (count === 1) return "full";
|
|
539
|
+
if (count === 2 || count === 4) return "short";
|
|
540
|
+
return "icon";
|
|
541
|
+
};
|
|
542
|
+
const getGridColumnStyle = (index) => {
|
|
543
|
+
if (count === 1) {
|
|
544
|
+
return { gridColumn: "span 6" };
|
|
545
|
+
}
|
|
546
|
+
if (count === 2) {
|
|
547
|
+
return { gridColumn: "span 3" };
|
|
548
|
+
}
|
|
549
|
+
if (count === 3) {
|
|
550
|
+
return { gridColumn: "span 2 / span 2" };
|
|
551
|
+
}
|
|
552
|
+
if (count === 4) {
|
|
553
|
+
return { gridColumn: "span 3" };
|
|
554
|
+
}
|
|
555
|
+
const totalRows = Math.ceil(count / 3);
|
|
556
|
+
const lastRowStartIndex = (totalRows - 1) * 3;
|
|
557
|
+
const isInLastRow = index >= lastRowStartIndex;
|
|
558
|
+
if (!isInLastRow) {
|
|
559
|
+
return { gridColumn: "span 2 / span 2" };
|
|
560
|
+
}
|
|
561
|
+
const positionInLastRow = index - lastRowStartIndex;
|
|
562
|
+
const itemsInLastRow = count - lastRowStartIndex;
|
|
563
|
+
if (itemsInLastRow === 1) {
|
|
564
|
+
return { gridColumn: "3 / 5" };
|
|
565
|
+
} else if (itemsInLastRow === 2) {
|
|
566
|
+
if (positionInLastRow === 0) {
|
|
567
|
+
return { gridColumn: "2 / 4" };
|
|
568
|
+
} else {
|
|
569
|
+
return { gridColumn: "4 / 6" };
|
|
570
|
+
}
|
|
571
|
+
} else {
|
|
572
|
+
return { gridColumn: "span 2 / span 2" };
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
return /* @__PURE__ */ jsx("div", { className: cn(
|
|
576
|
+
"grid gap-3 w-full grid-cols-6",
|
|
577
|
+
appearance.containerClassName
|
|
578
|
+
), children: providers.map((provider, index) => /* @__PURE__ */ jsx(
|
|
579
|
+
AuthOAuthButton,
|
|
580
|
+
{
|
|
581
|
+
provider,
|
|
582
|
+
onClick,
|
|
583
|
+
disabled,
|
|
584
|
+
loading: loading === provider,
|
|
585
|
+
displayMode: getDisplayMode(),
|
|
586
|
+
style: getGridColumnStyle(index),
|
|
587
|
+
className: appearance.buttonClassName
|
|
588
|
+
},
|
|
589
|
+
provider
|
|
590
|
+
)) });
|
|
591
|
+
}
|
|
592
|
+
function AuthVerificationCodeInput({
|
|
593
|
+
length = 6,
|
|
594
|
+
value,
|
|
595
|
+
email,
|
|
596
|
+
onChange,
|
|
597
|
+
disabled = false,
|
|
598
|
+
appearance = {}
|
|
599
|
+
}) {
|
|
600
|
+
const inputRefs = useRef([]);
|
|
601
|
+
const handleChange = (index, digit) => {
|
|
602
|
+
if (digit.length > 1) return;
|
|
603
|
+
if (digit && !/^\d$/.test(digit)) return;
|
|
604
|
+
const newValue = value.split("");
|
|
605
|
+
newValue[index] = digit;
|
|
606
|
+
const updatedValue = newValue.join("");
|
|
607
|
+
onChange(updatedValue);
|
|
608
|
+
if (digit && index < length - 1) {
|
|
609
|
+
inputRefs.current[index + 1]?.focus();
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
const handleKeyDown = (index, e) => {
|
|
613
|
+
if (e.key === "Backspace") {
|
|
614
|
+
if (!value[index] && index > 0) {
|
|
615
|
+
inputRefs.current[index - 1]?.focus();
|
|
616
|
+
} else {
|
|
617
|
+
handleChange(index, "");
|
|
618
|
+
}
|
|
619
|
+
} else if (e.key === "ArrowLeft" && index > 0) {
|
|
620
|
+
inputRefs.current[index - 1]?.focus();
|
|
621
|
+
} else if (e.key === "ArrowRight" && index < length - 1) {
|
|
622
|
+
inputRefs.current[index + 1]?.focus();
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
const handlePaste = (e) => {
|
|
626
|
+
e.preventDefault();
|
|
627
|
+
const pastedData = e.clipboardData.getData("text/plain").trim();
|
|
628
|
+
if (/^\d+$/.test(pastedData) && pastedData.length === length) {
|
|
629
|
+
onChange(pastedData);
|
|
630
|
+
inputRefs.current[length - 1]?.focus();
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
return /* @__PURE__ */ jsxs("div", { className: cn(
|
|
634
|
+
"flex flex-col justify-center items-center gap-6",
|
|
635
|
+
appearance.containerClassName
|
|
636
|
+
), children: [
|
|
637
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm font-normal text-[#525252] leading-5", children: [
|
|
638
|
+
"We've sent a verification code to your inbox at",
|
|
639
|
+
" ",
|
|
640
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold text-black leading-5", children: email }),
|
|
641
|
+
". Enter it below to proceed."
|
|
642
|
+
] }),
|
|
643
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-row gap-3 justify-center items-center", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsx(
|
|
644
|
+
"input",
|
|
645
|
+
{
|
|
646
|
+
ref: (el) => {
|
|
647
|
+
inputRefs.current[index] = el;
|
|
648
|
+
},
|
|
649
|
+
type: "text",
|
|
650
|
+
inputMode: "numeric",
|
|
651
|
+
maxLength: 1,
|
|
652
|
+
value: value[index] || "",
|
|
653
|
+
onChange: (e) => handleChange(index, e.target.value),
|
|
654
|
+
onKeyDown: (e) => handleKeyDown(index, e),
|
|
655
|
+
onPaste: handlePaste,
|
|
656
|
+
disabled,
|
|
657
|
+
className: cn(
|
|
658
|
+
"w-full h-12 px-3 py-2 rounded border border-[#E0E0E0] bg-white",
|
|
659
|
+
"text-center text-base font-semibold leading-5 text-black",
|
|
660
|
+
"transition-all duration-200 outline-none",
|
|
661
|
+
"focus:border-black focus:shadow-[0_0_0_2px_rgba(0,0,0,0.1)]",
|
|
662
|
+
"disabled:bg-[#F5F5F5] disabled:cursor-not-allowed disabled:opacity-60",
|
|
663
|
+
appearance.inputClassName
|
|
664
|
+
),
|
|
665
|
+
autoComplete: "one-time-code"
|
|
666
|
+
},
|
|
667
|
+
index
|
|
668
|
+
)) })
|
|
669
|
+
] });
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export { AuthBranding, AuthContainer, AuthDivider, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput, validatePasswordStrength };
|
|
673
|
+
//# sourceMappingURL=atoms.mjs.map
|
|
674
|
+
//# sourceMappingURL=atoms.mjs.map
|