@wordrhyme/shadcn-auth 1.0.60
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/AuthForms.cjs +47 -0
- package/dist/AuthForms.d.cts +23 -0
- package/dist/AuthForms.d.ts +23 -0
- package/dist/AuthForms.js +44 -0
- package/dist/GoogleSignIn.cjs +46 -0
- package/dist/GoogleSignIn.d.cts +10 -0
- package/dist/GoogleSignIn.d.ts +10 -0
- package/dist/GoogleSignIn.js +42 -0
- package/dist/ResetPasswordForm.cjs +106 -0
- package/dist/ResetPasswordForm.d.cts +17 -0
- package/dist/ResetPasswordForm.d.ts +17 -0
- package/dist/ResetPasswordForm.js +100 -0
- package/dist/SignInForm.cjs +164 -0
- package/dist/SignInForm.d.cts +21 -0
- package/dist/SignInForm.d.ts +21 -0
- package/dist/SignInForm.js +159 -0
- package/dist/SignUpForm.cjs +154 -0
- package/dist/SignUpForm.d.cts +19 -0
- package/dist/SignUpForm.d.ts +19 -0
- package/dist/SignUpForm.js +149 -0
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 pixpilot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_ResetPasswordForm = require('./ResetPasswordForm.cjs');
|
|
3
|
+
const require_SignInForm = require('./SignInForm.cjs');
|
|
4
|
+
const require_SignUpForm = require('./SignUpForm.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
9
|
+
|
|
10
|
+
//#region src/AuthForms.tsx
|
|
11
|
+
function AuthForms({ handleSignIn, handleSignUp, handleResetPassword, authLoadingState, authErrorData }) {
|
|
12
|
+
const [authMode, setAuthMode] = (0, react.useState)("signin");
|
|
13
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14
|
+
className: "flex min-h-screen items-center justify-center p-4",
|
|
15
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
16
|
+
className: "w-full max-w-md",
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
19
|
+
className: "mb-6 text-center text-3xl font-bold",
|
|
20
|
+
children: "Job Hunter"
|
|
21
|
+
}),
|
|
22
|
+
authMode === "signin" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SignInForm.SignInForm, {
|
|
23
|
+
onSignIn: handleSignIn,
|
|
24
|
+
isLoading: authLoadingState.isLoading,
|
|
25
|
+
error: authErrorData?.error ?? null,
|
|
26
|
+
onSwitchToSignUp: () => setAuthMode("signup"),
|
|
27
|
+
onSwitchToReset: () => setAuthMode("reset")
|
|
28
|
+
}),
|
|
29
|
+
authMode === "signup" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SignUpForm.SignUpForm, {
|
|
30
|
+
onSignUp: handleSignUp,
|
|
31
|
+
isLoading: authLoadingState.isLoading,
|
|
32
|
+
error: authErrorData?.error ?? null,
|
|
33
|
+
onSwitchToSignIn: () => setAuthMode("signin")
|
|
34
|
+
}),
|
|
35
|
+
authMode === "reset" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ResetPasswordForm.ResetPasswordForm, {
|
|
36
|
+
onResetPassword: handleResetPassword,
|
|
37
|
+
isLoading: authLoadingState.isLoading,
|
|
38
|
+
error: authErrorData?.error ?? null,
|
|
39
|
+
onSwitchToSignIn: () => setAuthMode("signin")
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.AuthForms = AuthForms;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/AuthForms.d.ts
|
|
4
|
+
interface AuthFormsProps {
|
|
5
|
+
handleSignIn: (email: string, password: string) => Promise<void>;
|
|
6
|
+
handleSignUp: (email: string, password: string) => Promise<void>;
|
|
7
|
+
handleResetPassword: (email: string) => Promise<void>;
|
|
8
|
+
authLoadingState: {
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
};
|
|
11
|
+
authErrorData?: {
|
|
12
|
+
error: string;
|
|
13
|
+
} | null;
|
|
14
|
+
}
|
|
15
|
+
declare function AuthForms({
|
|
16
|
+
handleSignIn,
|
|
17
|
+
handleSignUp,
|
|
18
|
+
handleResetPassword,
|
|
19
|
+
authLoadingState,
|
|
20
|
+
authErrorData
|
|
21
|
+
}: AuthFormsProps): react_jsx_runtime2.JSX.Element;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { AuthForms };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/AuthForms.d.ts
|
|
4
|
+
interface AuthFormsProps {
|
|
5
|
+
handleSignIn: (email: string, password: string) => Promise<void>;
|
|
6
|
+
handleSignUp: (email: string, password: string) => Promise<void>;
|
|
7
|
+
handleResetPassword: (email: string) => Promise<void>;
|
|
8
|
+
authLoadingState: {
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
};
|
|
11
|
+
authErrorData?: {
|
|
12
|
+
error: string;
|
|
13
|
+
} | null;
|
|
14
|
+
}
|
|
15
|
+
declare function AuthForms({
|
|
16
|
+
handleSignIn,
|
|
17
|
+
handleSignUp,
|
|
18
|
+
handleResetPassword,
|
|
19
|
+
authLoadingState,
|
|
20
|
+
authErrorData
|
|
21
|
+
}: AuthFormsProps): react_jsx_runtime1.JSX.Element;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { AuthForms };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ResetPasswordForm } from "./ResetPasswordForm.js";
|
|
2
|
+
import { SignInForm } from "./SignInForm.js";
|
|
3
|
+
import { SignUpForm } from "./SignUpForm.js";
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/AuthForms.tsx
|
|
8
|
+
function AuthForms({ handleSignIn, handleSignUp, handleResetPassword, authLoadingState, authErrorData }) {
|
|
9
|
+
const [authMode, setAuthMode] = useState("signin");
|
|
10
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: "flex min-h-screen items-center justify-center p-4",
|
|
12
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
13
|
+
className: "w-full max-w-md",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx("h1", {
|
|
16
|
+
className: "mb-6 text-center text-3xl font-bold",
|
|
17
|
+
children: "Job Hunter"
|
|
18
|
+
}),
|
|
19
|
+
authMode === "signin" && /* @__PURE__ */ jsx(SignInForm, {
|
|
20
|
+
onSignIn: handleSignIn,
|
|
21
|
+
isLoading: authLoadingState.isLoading,
|
|
22
|
+
error: authErrorData?.error ?? null,
|
|
23
|
+
onSwitchToSignUp: () => setAuthMode("signup"),
|
|
24
|
+
onSwitchToReset: () => setAuthMode("reset")
|
|
25
|
+
}),
|
|
26
|
+
authMode === "signup" && /* @__PURE__ */ jsx(SignUpForm, {
|
|
27
|
+
onSignUp: handleSignUp,
|
|
28
|
+
isLoading: authLoadingState.isLoading,
|
|
29
|
+
error: authErrorData?.error ?? null,
|
|
30
|
+
onSwitchToSignIn: () => setAuthMode("signin")
|
|
31
|
+
}),
|
|
32
|
+
authMode === "reset" && /* @__PURE__ */ jsx(ResetPasswordForm, {
|
|
33
|
+
onResetPassword: handleResetPassword,
|
|
34
|
+
isLoading: authLoadingState.isLoading,
|
|
35
|
+
error: authErrorData?.error ?? null,
|
|
36
|
+
onSwitchToSignIn: () => setAuthMode("signin")
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { AuthForms };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
4
|
+
let __wordrhyme_shadcn_ui = require("@wordrhyme/shadcn-ui");
|
|
5
|
+
__wordrhyme_shadcn_ui = require_rolldown_runtime.__toESM(__wordrhyme_shadcn_ui);
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
8
|
+
|
|
9
|
+
//#region src/GoogleSignIn.tsx
|
|
10
|
+
const GoogleSignIn = ({ onGoogleSignIn, isLoading }) => {
|
|
11
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn_ui.Button, {
|
|
12
|
+
type: "button",
|
|
13
|
+
variant: "outline",
|
|
14
|
+
className: "w-full",
|
|
15
|
+
disabled: isLoading,
|
|
16
|
+
onClick: () => {
|
|
17
|
+
onGoogleSignIn().catch(console.error);
|
|
18
|
+
},
|
|
19
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
20
|
+
className: "mr-2 h-4 w-4",
|
|
21
|
+
viewBox: "0 0 24 24",
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
24
|
+
fill: "currentColor",
|
|
25
|
+
d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
28
|
+
fill: "currentColor",
|
|
29
|
+
d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
32
|
+
fill: "currentColor",
|
|
33
|
+
d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
36
|
+
fill: "currentColor",
|
|
37
|
+
d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
}), "Sign in with Google"]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
GoogleSignIn.displayName = "GoogleSignIn";
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.GoogleSignIn = GoogleSignIn;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/GoogleSignIn.d.ts
|
|
4
|
+
interface GoogleSignInProps {
|
|
5
|
+
onGoogleSignIn: () => Promise<void>;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const GoogleSignIn: React.FC<GoogleSignInProps>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { GoogleSignIn, GoogleSignInProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/GoogleSignIn.d.ts
|
|
4
|
+
interface GoogleSignInProps {
|
|
5
|
+
onGoogleSignIn: () => Promise<void>;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const GoogleSignIn: React.FC<GoogleSignInProps>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { GoogleSignIn, GoogleSignInProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "@wordrhyme/shadcn-ui";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/GoogleSignIn.tsx
|
|
6
|
+
const GoogleSignIn = ({ onGoogleSignIn, isLoading }) => {
|
|
7
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
8
|
+
type: "button",
|
|
9
|
+
variant: "outline",
|
|
10
|
+
className: "w-full",
|
|
11
|
+
disabled: isLoading,
|
|
12
|
+
onClick: () => {
|
|
13
|
+
onGoogleSignIn().catch(console.error);
|
|
14
|
+
},
|
|
15
|
+
children: [/* @__PURE__ */ jsxs("svg", {
|
|
16
|
+
className: "mr-2 h-4 w-4",
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ jsx("path", {
|
|
20
|
+
fill: "currentColor",
|
|
21
|
+
d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
22
|
+
}),
|
|
23
|
+
/* @__PURE__ */ jsx("path", {
|
|
24
|
+
fill: "currentColor",
|
|
25
|
+
d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsx("path", {
|
|
28
|
+
fill: "currentColor",
|
|
29
|
+
d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ jsx("path", {
|
|
32
|
+
fill: "currentColor",
|
|
33
|
+
d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
}), "Sign in with Google"]
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
GoogleSignIn.displayName = "GoogleSignIn";
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { GoogleSignIn };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
7
|
+
let __wordrhyme_shadcn = require("@wordrhyme/shadcn");
|
|
8
|
+
__wordrhyme_shadcn = require_rolldown_runtime.__toESM(__wordrhyme_shadcn);
|
|
9
|
+
let __wordrhyme_shadcn_ui = require("@wordrhyme/shadcn-ui");
|
|
10
|
+
__wordrhyme_shadcn_ui = require_rolldown_runtime.__toESM(__wordrhyme_shadcn_ui);
|
|
11
|
+
let lucide_react = require("lucide-react");
|
|
12
|
+
lucide_react = require_rolldown_runtime.__toESM(lucide_react);
|
|
13
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
15
|
+
|
|
16
|
+
//#region src/ResetPasswordForm.tsx
|
|
17
|
+
function ResetPasswordForm({ onResetPassword, isLoading, error, onSwitchToSignIn }) {
|
|
18
|
+
const [email, setEmail] = (0, react.useState)("");
|
|
19
|
+
const [emailError, setEmailError] = (0, react.useState)("");
|
|
20
|
+
const validateEmail = (emailValue) => {
|
|
21
|
+
if (!emailValue.trim()) {
|
|
22
|
+
setEmailError("Email is required");
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const input = document.createElement("input");
|
|
26
|
+
input.type = "email";
|
|
27
|
+
input.value = emailValue;
|
|
28
|
+
if (!input.validity.valid) {
|
|
29
|
+
setEmailError("Please enter a valid email address");
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
setEmailError("");
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
const handleSubmit = (e) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
if (!validateEmail(email)) return;
|
|
38
|
+
onResetPassword(email).catch(console.error);
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Card, {
|
|
41
|
+
className: "mx-auto w-full max-w-md",
|
|
42
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.CardContent, {
|
|
43
|
+
className: "p-6",
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
46
|
+
className: "mb-4 text-center text-2xl font-bold",
|
|
47
|
+
children: "Reset Password"
|
|
48
|
+
}),
|
|
49
|
+
error != null && error.trim() !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn_ui.Alert, {
|
|
50
|
+
variant: "error",
|
|
51
|
+
description: error
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
54
|
+
onSubmit: handleSubmit,
|
|
55
|
+
className: "space-y-4",
|
|
56
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
57
|
+
className: "space-y-2",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Label, {
|
|
60
|
+
htmlFor: "email",
|
|
61
|
+
children: "Email"
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Input, {
|
|
64
|
+
id: "email",
|
|
65
|
+
type: "email",
|
|
66
|
+
value: email,
|
|
67
|
+
onChange: (e) => {
|
|
68
|
+
setEmail(e.target.value);
|
|
69
|
+
if (emailError) setEmailError("");
|
|
70
|
+
},
|
|
71
|
+
disabled: isLoading,
|
|
72
|
+
required: true
|
|
73
|
+
}),
|
|
74
|
+
emailError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
75
|
+
className: "text-destructive text-sm",
|
|
76
|
+
children: emailError
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.Button, {
|
|
80
|
+
type: "submit",
|
|
81
|
+
className: "mt-6 w-full",
|
|
82
|
+
disabled: isLoading,
|
|
83
|
+
children: [isLoading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), isLoading ? "Sending Reset Email..." : "Send Reset Email"]
|
|
84
|
+
})]
|
|
85
|
+
}),
|
|
86
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
87
|
+
className: "mt-4 text-center",
|
|
88
|
+
children: onSwitchToSignIn && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
89
|
+
className: "text-sm",
|
|
90
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
|
|
91
|
+
variant: "link",
|
|
92
|
+
size: "sm",
|
|
93
|
+
onClick: onSwitchToSignIn,
|
|
94
|
+
disabled: isLoading,
|
|
95
|
+
className: "min-w-0 p-0 font-medium",
|
|
96
|
+
children: "Back to sign in"
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
exports.ResetPasswordForm = ResetPasswordForm;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/ResetPasswordForm.d.ts
|
|
4
|
+
interface ResetPasswordFormProps {
|
|
5
|
+
onResetPassword: (email: string) => Promise<void>;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
error: string | null;
|
|
8
|
+
onSwitchToSignIn?: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare function ResetPasswordForm({
|
|
11
|
+
onResetPassword,
|
|
12
|
+
isLoading,
|
|
13
|
+
error,
|
|
14
|
+
onSwitchToSignIn
|
|
15
|
+
}: ResetPasswordFormProps): react_jsx_runtime0.JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ResetPasswordForm };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/ResetPasswordForm.d.ts
|
|
4
|
+
interface ResetPasswordFormProps {
|
|
5
|
+
onResetPassword: (email: string) => Promise<void>;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
error: string | null;
|
|
8
|
+
onSwitchToSignIn?: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare function ResetPasswordForm({
|
|
11
|
+
onResetPassword,
|
|
12
|
+
isLoading,
|
|
13
|
+
error,
|
|
14
|
+
onSwitchToSignIn
|
|
15
|
+
}: ResetPasswordFormProps): react_jsx_runtime2.JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ResetPasswordForm };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
import { Button, Card, CardContent, Input, Label } from "@wordrhyme/shadcn";
|
|
6
|
+
import { Alert as Alert$1 } from "@wordrhyme/shadcn-ui";
|
|
7
|
+
import { Loader2 } from "lucide-react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/ResetPasswordForm.tsx
|
|
11
|
+
function ResetPasswordForm({ onResetPassword, isLoading, error, onSwitchToSignIn }) {
|
|
12
|
+
const [email, setEmail] = useState("");
|
|
13
|
+
const [emailError, setEmailError] = useState("");
|
|
14
|
+
const validateEmail = (emailValue) => {
|
|
15
|
+
if (!emailValue.trim()) {
|
|
16
|
+
setEmailError("Email is required");
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const input = document.createElement("input");
|
|
20
|
+
input.type = "email";
|
|
21
|
+
input.value = emailValue;
|
|
22
|
+
if (!input.validity.valid) {
|
|
23
|
+
setEmailError("Please enter a valid email address");
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
setEmailError("");
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
const handleSubmit = (e) => {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
if (!validateEmail(email)) return;
|
|
32
|
+
onResetPassword(email).catch(console.error);
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ jsx(Card, {
|
|
35
|
+
className: "mx-auto w-full max-w-md",
|
|
36
|
+
children: /* @__PURE__ */ jsxs(CardContent, {
|
|
37
|
+
className: "p-6",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx("h2", {
|
|
40
|
+
className: "mb-4 text-center text-2xl font-bold",
|
|
41
|
+
children: "Reset Password"
|
|
42
|
+
}),
|
|
43
|
+
error != null && error.trim() !== "" && /* @__PURE__ */ jsx(Alert$1, {
|
|
44
|
+
variant: "error",
|
|
45
|
+
description: error
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ jsxs("form", {
|
|
48
|
+
onSubmit: handleSubmit,
|
|
49
|
+
className: "space-y-4",
|
|
50
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
51
|
+
className: "space-y-2",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx(Label, {
|
|
54
|
+
htmlFor: "email",
|
|
55
|
+
children: "Email"
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsx(Input, {
|
|
58
|
+
id: "email",
|
|
59
|
+
type: "email",
|
|
60
|
+
value: email,
|
|
61
|
+
onChange: (e) => {
|
|
62
|
+
setEmail(e.target.value);
|
|
63
|
+
if (emailError) setEmailError("");
|
|
64
|
+
},
|
|
65
|
+
disabled: isLoading,
|
|
66
|
+
required: true
|
|
67
|
+
}),
|
|
68
|
+
emailError && /* @__PURE__ */ jsx("p", {
|
|
69
|
+
className: "text-destructive text-sm",
|
|
70
|
+
children: emailError
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
74
|
+
type: "submit",
|
|
75
|
+
className: "mt-6 w-full",
|
|
76
|
+
disabled: isLoading,
|
|
77
|
+
children: [isLoading && /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), isLoading ? "Sending Reset Email..." : "Send Reset Email"]
|
|
78
|
+
})]
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx("div", {
|
|
81
|
+
className: "mt-4 text-center",
|
|
82
|
+
children: onSwitchToSignIn && /* @__PURE__ */ jsx("p", {
|
|
83
|
+
className: "text-sm",
|
|
84
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
85
|
+
variant: "link",
|
|
86
|
+
size: "sm",
|
|
87
|
+
onClick: onSwitchToSignIn,
|
|
88
|
+
disabled: isLoading,
|
|
89
|
+
className: "min-w-0 p-0 font-medium",
|
|
90
|
+
children: "Back to sign in"
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { ResetPasswordForm };
|