@pixpilot/shadcn-auth 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/index-2dT71M3Z.d.cts +79 -0
- package/dist/index-BJiTaBmJ.d.ts +79 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +1 -0
- package/package.json +70 -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,79 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/AuthForms.d.ts
|
|
5
|
+
interface AuthFormsProps {
|
|
6
|
+
handleSignIn: (email: string, password: string) => Promise<void>;
|
|
7
|
+
handleSignUp: (email: string, password: string) => Promise<void>;
|
|
8
|
+
handleResetPassword: (email: string) => Promise<void>;
|
|
9
|
+
authLoadingState: {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
};
|
|
12
|
+
authErrorData?: {
|
|
13
|
+
error: string;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
declare function AuthForms({
|
|
17
|
+
handleSignIn,
|
|
18
|
+
handleSignUp,
|
|
19
|
+
handleResetPassword,
|
|
20
|
+
authLoadingState,
|
|
21
|
+
authErrorData
|
|
22
|
+
}: AuthFormsProps): react_jsx_runtime0.JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/GoogleSignIn.d.ts
|
|
25
|
+
interface GoogleSignInProps {
|
|
26
|
+
onGoogleSignIn: () => Promise<void>;
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const GoogleSignIn: React.FC<GoogleSignInProps>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/ResetPasswordForm.d.ts
|
|
32
|
+
interface ResetPasswordFormProps {
|
|
33
|
+
onResetPassword: (email: string) => Promise<void>;
|
|
34
|
+
isLoading: boolean;
|
|
35
|
+
error: string | null;
|
|
36
|
+
onSwitchToSignIn?: () => void;
|
|
37
|
+
}
|
|
38
|
+
declare function ResetPasswordForm({
|
|
39
|
+
onResetPassword,
|
|
40
|
+
isLoading,
|
|
41
|
+
error,
|
|
42
|
+
onSwitchToSignIn
|
|
43
|
+
}: ResetPasswordFormProps): react_jsx_runtime0.JSX.Element;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/SignInForm.d.ts
|
|
46
|
+
interface SignInFormProps {
|
|
47
|
+
onSignIn: (email: string, password: string) => Promise<void>;
|
|
48
|
+
onGoogleSignIn?: () => Promise<void>;
|
|
49
|
+
isLoading: boolean;
|
|
50
|
+
error: string | null;
|
|
51
|
+
onSwitchToSignUp?: () => void;
|
|
52
|
+
onSwitchToReset?: () => void;
|
|
53
|
+
}
|
|
54
|
+
declare function SignInForm({
|
|
55
|
+
onSignIn,
|
|
56
|
+
onGoogleSignIn,
|
|
57
|
+
isLoading,
|
|
58
|
+
error,
|
|
59
|
+
onSwitchToSignUp,
|
|
60
|
+
onSwitchToReset
|
|
61
|
+
}: SignInFormProps): react_jsx_runtime0.JSX.Element;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/SignUpForm.d.ts
|
|
64
|
+
interface SignUpFormProps {
|
|
65
|
+
onSignUp: (email: string, password: string) => Promise<void>;
|
|
66
|
+
onGoogleSignIn?: () => Promise<void>;
|
|
67
|
+
isLoading: boolean;
|
|
68
|
+
error: string | null;
|
|
69
|
+
onSwitchToSignIn?: () => void;
|
|
70
|
+
}
|
|
71
|
+
declare function SignUpForm({
|
|
72
|
+
onSignUp,
|
|
73
|
+
onGoogleSignIn,
|
|
74
|
+
isLoading,
|
|
75
|
+
error,
|
|
76
|
+
onSwitchToSignIn
|
|
77
|
+
}: SignUpFormProps): react_jsx_runtime0.JSX.Element;
|
|
78
|
+
//#endregion
|
|
79
|
+
export { AuthForms, GoogleSignIn, GoogleSignInProps, ResetPasswordForm, SignInForm, SignUpForm };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/AuthForms.d.ts
|
|
5
|
+
interface AuthFormsProps {
|
|
6
|
+
handleSignIn: (email: string, password: string) => Promise<void>;
|
|
7
|
+
handleSignUp: (email: string, password: string) => Promise<void>;
|
|
8
|
+
handleResetPassword: (email: string) => Promise<void>;
|
|
9
|
+
authLoadingState: {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
};
|
|
12
|
+
authErrorData?: {
|
|
13
|
+
error: string;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
declare function AuthForms({
|
|
17
|
+
handleSignIn,
|
|
18
|
+
handleSignUp,
|
|
19
|
+
handleResetPassword,
|
|
20
|
+
authLoadingState,
|
|
21
|
+
authErrorData
|
|
22
|
+
}: AuthFormsProps): react_jsx_runtime0.JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/GoogleSignIn.d.ts
|
|
25
|
+
interface GoogleSignInProps {
|
|
26
|
+
onGoogleSignIn: () => Promise<void>;
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const GoogleSignIn: React.FC<GoogleSignInProps>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/ResetPasswordForm.d.ts
|
|
32
|
+
interface ResetPasswordFormProps {
|
|
33
|
+
onResetPassword: (email: string) => Promise<void>;
|
|
34
|
+
isLoading: boolean;
|
|
35
|
+
error: string | null;
|
|
36
|
+
onSwitchToSignIn?: () => void;
|
|
37
|
+
}
|
|
38
|
+
declare function ResetPasswordForm({
|
|
39
|
+
onResetPassword,
|
|
40
|
+
isLoading,
|
|
41
|
+
error,
|
|
42
|
+
onSwitchToSignIn
|
|
43
|
+
}: ResetPasswordFormProps): react_jsx_runtime0.JSX.Element;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/SignInForm.d.ts
|
|
46
|
+
interface SignInFormProps {
|
|
47
|
+
onSignIn: (email: string, password: string) => Promise<void>;
|
|
48
|
+
onGoogleSignIn?: () => Promise<void>;
|
|
49
|
+
isLoading: boolean;
|
|
50
|
+
error: string | null;
|
|
51
|
+
onSwitchToSignUp?: () => void;
|
|
52
|
+
onSwitchToReset?: () => void;
|
|
53
|
+
}
|
|
54
|
+
declare function SignInForm({
|
|
55
|
+
onSignIn,
|
|
56
|
+
onGoogleSignIn,
|
|
57
|
+
isLoading,
|
|
58
|
+
error,
|
|
59
|
+
onSwitchToSignUp,
|
|
60
|
+
onSwitchToReset
|
|
61
|
+
}: SignInFormProps): react_jsx_runtime0.JSX.Element;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/SignUpForm.d.ts
|
|
64
|
+
interface SignUpFormProps {
|
|
65
|
+
onSignUp: (email: string, password: string) => Promise<void>;
|
|
66
|
+
onGoogleSignIn?: () => Promise<void>;
|
|
67
|
+
isLoading: boolean;
|
|
68
|
+
error: string | null;
|
|
69
|
+
onSwitchToSignIn?: () => void;
|
|
70
|
+
}
|
|
71
|
+
declare function SignUpForm({
|
|
72
|
+
onSignUp,
|
|
73
|
+
onGoogleSignIn,
|
|
74
|
+
isLoading,
|
|
75
|
+
error,
|
|
76
|
+
onSwitchToSignIn
|
|
77
|
+
}: SignUpFormProps): react_jsx_runtime0.JSX.Element;
|
|
78
|
+
//#endregion
|
|
79
|
+
export { AuthForms, GoogleSignIn, GoogleSignInProps, ResetPasswordForm, SignInForm, SignUpForm };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`@pixpilot/shadcn`),u=require(`@pixpilot/shadcn-ui`),d=require(`lucide-react`),f=require(`react/jsx-runtime`);function p({onResetPassword:e,isLoading:t,error:n,onSwitchToSignIn:r}){let[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(``),p=e=>{if(!e.trim())return s(`Email is required`),!1;let t=document.createElement(`input`);return t.type=`email`,t.value=e,t.validity.valid?(s(``),!0):(s(`Please enter a valid email address`),!1)};return(0,f.jsx)(l.Card,{className:`mx-auto w-full max-w-md`,children:(0,f.jsxs)(l.CardContent,{className:`p-6`,children:[(0,f.jsx)(`h2`,{className:`mb-4 text-center text-2xl font-bold`,children:`Reset Password`}),n!=null&&n.trim()!==``&&(0,f.jsx)(u.Alert,{variant:`error`,description:n}),(0,f.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),p(i)&&e(i).catch(console.error)},className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(l.Label,{htmlFor:`email`,children:`Email`}),(0,f.jsx)(l.Input,{id:`email`,type:`email`,value:i,onChange:e=>{a(e.target.value),o&&s(``)},disabled:t,required:!0}),o&&(0,f.jsx)(`p`,{className:`text-destructive text-sm`,children:o})]}),(0,f.jsxs)(l.Button,{type:`submit`,className:`mt-6 w-full`,disabled:t,children:[t&&(0,f.jsx)(d.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),t?`Sending Reset Email...`:`Send Reset Email`]})]}),(0,f.jsx)(`div`,{className:`mt-4 text-center`,children:r&&(0,f.jsx)(`p`,{className:`text-sm`,children:(0,f.jsx)(l.Button,{variant:`link`,size:`sm`,onClick:r,disabled:t,className:`min-w-0 p-0 font-medium`,children:`Back to sign in`})})})]})})}const m=({onGoogleSignIn:e,isLoading:t})=>(0,f.jsxs)(u.Button,{type:`button`,variant:`outline`,className:`w-full`,disabled:t,onClick:()=>{e().catch(console.error)},children:[(0,f.jsxs)(`svg`,{className:`mr-2 h-4 w-4`,viewBox:`0 0 24 24`,children:[(0,f.jsx)(`path`,{fill:`currentColor`,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`}),(0,f.jsx)(`path`,{fill:`currentColor`,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`}),(0,f.jsx)(`path`,{fill:`currentColor`,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`}),(0,f.jsx)(`path`,{fill:`currentColor`,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`})]}),`Sign in with Google`]});m.displayName=`GoogleSignIn`;const h=6;function g({onSignIn:e,onGoogleSignIn:t,isLoading:n,error:r,onSwitchToSignUp:i,onSwitchToReset:a}){let[o,s]=(0,c.useState)(``),[u,p]=(0,c.useState)(``),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(``),y=e=>{if(!e.trim())return g(`Email is required`),!1;let t=document.createElement(`input`);return t.type=`email`,t.value=e,t.validity.valid?(g(``),!0):(g(`Please enter a valid email address`),!1)},b=e=>e.trim()?e.length<6?(v(`Password must be at least 6 characters long`),!1):(v(``),!0):(v(`Password is required`),!1);return(0,f.jsx)(l.Card,{className:`mx-auto w-full max-w-md`,children:(0,f.jsxs)(l.CardContent,{className:`p-6`,children:[(0,f.jsx)(`h2`,{className:`mb-4 text-center text-2xl font-bold`,children:`Sign In`}),r!=null&&r.trim()!==``&&(0,f.jsx)(l.Alert,{variant:`destructive`,className:`mb-4`,children:(0,f.jsx)(l.AlertDescription,{children:r})}),(0,f.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),y(o)&&b(u)&&e(o,u).catch(console.error)},className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(l.Label,{htmlFor:`email`,children:`Email`}),(0,f.jsx)(l.Input,{id:`email`,type:`email`,value:o,onChange:e=>{s(e.target.value),h&&g(``)},disabled:n,required:!0,className:h?`border-destructive`:``}),h&&(0,f.jsx)(`p`,{className:`text-destructive text-sm`,children:h})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(l.Label,{htmlFor:`password`,children:`Password`}),(0,f.jsx)(l.Input,{id:`password`,type:`password`,value:u,onChange:e=>{p(e.target.value),_&&v(``)},disabled:n,required:!0,className:_?`border-destructive`:``}),_&&(0,f.jsx)(`p`,{className:`text-destructive text-sm`,children:_})]}),(0,f.jsxs)(l.Button,{type:`submit`,className:`mt-6 w-full`,disabled:n,children:[n&&(0,f.jsx)(d.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),n?`Signing In...`:`Sign In`]})]}),t!=null&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(l.OrContinueWithSeparator,{}),(0,f.jsx)(m,{onGoogleSignIn:t,isLoading:n})]}),(0,f.jsx)(l.Separator,{className:`my-4`}),(0,f.jsxs)(`div`,{className:`space-y-2 text-center text-sm`,children:[i&&(0,f.jsxs)(`p`,{children:[`Don't have an account?`,` `,(0,f.jsx)(l.Button,{variant:`link`,size:`sm`,onClick:i,disabled:n,className:`h-auto p-0`,children:`Sign up`})]}),a&&(0,f.jsx)(`p`,{children:(0,f.jsx)(l.Button,{variant:`link`,size:`sm`,onClick:a,disabled:n,className:`h-auto p-0`,children:`Forgot your password?`})})]})]})})}const _=6;function v({onSignUp:e,onGoogleSignIn:t,isLoading:n,error:r,onSwitchToSignIn:i}){let[a,o]=(0,c.useState)(``),[s,u]=(0,c.useState)(``),[p,h]=(0,c.useState)(``),[g,_]=(0,c.useState)(``),v=e=>{if(!e.trim())return h(`Email is required`),!1;let t=document.createElement(`input`);return t.type=`email`,t.value=e,t.validity.valid?(h(``),!0):(h(`Please enter a valid email address`),!1)},y=e=>e.trim()?e.length<6?(_(`Password must be at least 6 characters long`),!1):(_(``),!0):(_(`Password is required`),!1);return(0,f.jsx)(l.Card,{className:`mx-auto w-full max-w-md`,children:(0,f.jsxs)(l.CardContent,{className:`p-6`,children:[(0,f.jsx)(`h2`,{className:`mb-4 text-center text-2xl font-bold`,children:`Sign Up`}),r!=null&&r.trim()!==``&&(0,f.jsx)(l.Alert,{variant:`destructive`,className:`mb-4`,children:(0,f.jsx)(l.AlertDescription,{children:r})}),(0,f.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),v(a)&&y(s)&&e(a,s).catch(console.error)},className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(l.Label,{htmlFor:`email`,children:`Email`}),(0,f.jsx)(l.Input,{id:`email`,type:`email`,value:a,onChange:e=>{o(e.target.value),p&&h(``)},disabled:n,required:!0,className:p?`border-destructive`:``}),p&&(0,f.jsx)(`p`,{className:`text-destructive text-sm`,children:p})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(l.Label,{htmlFor:`password`,children:`Password`}),(0,f.jsx)(l.Input,{id:`password`,type:`password`,value:s,onChange:e=>{u(e.target.value),g&&_(``)},disabled:n,required:!0,className:g?`border-destructive`:``}),g&&(0,f.jsx)(`p`,{className:`text-destructive text-sm`,children:g})]}),(0,f.jsxs)(l.Button,{type:`submit`,className:`mt-6 w-full`,disabled:n,children:[n&&(0,f.jsx)(d.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),n?`Signing Up...`:`Sign Up`]})]}),t!=null&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(l.OrContinueWithSeparator,{}),(0,f.jsx)(m,{onGoogleSignIn:t,isLoading:n})]}),(0,f.jsx)(l.Separator,{className:`my-4`}),(0,f.jsx)(`div`,{className:`text-center text-sm`,children:i&&(0,f.jsxs)(`p`,{children:[`Already have an account?`,` `,(0,f.jsx)(l.Button,{variant:`link`,size:`sm`,onClick:i,disabled:n,className:`h-auto p-0`,children:`Sign in`})]})})]})})}function y({handleSignIn:e,handleSignUp:t,handleResetPassword:n,authLoadingState:r,authErrorData:i}){let[a,o]=(0,c.useState)(`signin`);return(0,f.jsx)(`div`,{className:`flex min-h-screen items-center justify-center p-4`,children:(0,f.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,f.jsx)(`h1`,{className:`mb-6 text-center text-3xl font-bold`,children:`Job Hunter`}),a===`signin`&&(0,f.jsx)(g,{onSignIn:e,isLoading:r.isLoading,error:i?.error??null,onSwitchToSignUp:()=>o(`signup`),onSwitchToReset:()=>o(`reset`)}),a===`signup`&&(0,f.jsx)(v,{onSignUp:t,isLoading:r.isLoading,error:i?.error??null,onSwitchToSignIn:()=>o(`signin`)}),a===`reset`&&(0,f.jsx)(p,{onResetPassword:n,isLoading:r.isLoading,error:i?.error??null,onSwitchToSignIn:()=>o(`signin`)})]})})}exports.AuthForms=y,exports.GoogleSignIn=m,exports.ResetPasswordForm=p,exports.SignInForm=g,exports.SignUpForm=v;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{useState as t}from"react";import{Alert as n,AlertDescription as r,Button as i,Card as a,CardContent as o,Input as s,Label as c,OrContinueWithSeparator as l,Separator as u}from"@pixpilot/shadcn";import{Alert as d,Button as f}from"@pixpilot/shadcn-ui";import{Loader2 as p}from"lucide-react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";function _({onResetPassword:e,isLoading:n,error:r,onSwitchToSignIn:l}){let[u,f]=t(``),[m,_]=t(``),v=e=>{if(!e.trim())return _(`Email is required`),!1;let t=document.createElement(`input`);return t.type=`email`,t.value=e,t.validity.valid?(_(``),!0):(_(`Please enter a valid email address`),!1)};return h(a,{className:`mx-auto w-full max-w-md`,children:g(o,{className:`p-6`,children:[h(`h2`,{className:`mb-4 text-center text-2xl font-bold`,children:`Reset Password`}),r!=null&&r.trim()!==``&&h(d,{variant:`error`,description:r}),g(`form`,{onSubmit:t=>{t.preventDefault(),v(u)&&e(u).catch(console.error)},className:`space-y-4`,children:[g(`div`,{className:`space-y-2`,children:[h(c,{htmlFor:`email`,children:`Email`}),h(s,{id:`email`,type:`email`,value:u,onChange:e=>{f(e.target.value),m&&_(``)},disabled:n,required:!0}),m&&h(`p`,{className:`text-destructive text-sm`,children:m})]}),g(i,{type:`submit`,className:`mt-6 w-full`,disabled:n,children:[n&&h(p,{className:`mr-2 h-4 w-4 animate-spin`}),n?`Sending Reset Email...`:`Send Reset Email`]})]}),h(`div`,{className:`mt-4 text-center`,children:l&&h(`p`,{className:`text-sm`,children:h(i,{variant:`link`,size:`sm`,onClick:l,disabled:n,className:`min-w-0 p-0 font-medium`,children:`Back to sign in`})})})]})})}const v=({onGoogleSignIn:e,isLoading:t})=>g(f,{type:`button`,variant:`outline`,className:`w-full`,disabled:t,onClick:()=>{e().catch(console.error)},children:[g(`svg`,{className:`mr-2 h-4 w-4`,viewBox:`0 0 24 24`,children:[h(`path`,{fill:`currentColor`,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`}),h(`path`,{fill:`currentColor`,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`}),h(`path`,{fill:`currentColor`,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`}),h(`path`,{fill:`currentColor`,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`})]}),`Sign in with Google`]});v.displayName=`GoogleSignIn`;function y({onSignIn:e,onGoogleSignIn:d,isLoading:f,error:_,onSwitchToSignUp:y,onSwitchToReset:b}){let[x,S]=t(``),[C,w]=t(``),[T,E]=t(``),[D,O]=t(``),k=e=>{if(!e.trim())return E(`Email is required`),!1;let t=document.createElement(`input`);return t.type=`email`,t.value=e,t.validity.valid?(E(``),!0):(E(`Please enter a valid email address`),!1)},A=e=>e.trim()?e.length<6?(O(`Password must be at least 6 characters long`),!1):(O(``),!0):(O(`Password is required`),!1);return h(a,{className:`mx-auto w-full max-w-md`,children:g(o,{className:`p-6`,children:[h(`h2`,{className:`mb-4 text-center text-2xl font-bold`,children:`Sign In`}),_!=null&&_.trim()!==``&&h(n,{variant:`destructive`,className:`mb-4`,children:h(r,{children:_})}),g(`form`,{onSubmit:t=>{t.preventDefault(),k(x)&&A(C)&&e(x,C).catch(console.error)},className:`space-y-4`,children:[g(`div`,{className:`space-y-2`,children:[h(c,{htmlFor:`email`,children:`Email`}),h(s,{id:`email`,type:`email`,value:x,onChange:e=>{S(e.target.value),T&&E(``)},disabled:f,required:!0,className:T?`border-destructive`:``}),T&&h(`p`,{className:`text-destructive text-sm`,children:T})]}),g(`div`,{className:`space-y-2`,children:[h(c,{htmlFor:`password`,children:`Password`}),h(s,{id:`password`,type:`password`,value:C,onChange:e=>{w(e.target.value),D&&O(``)},disabled:f,required:!0,className:D?`border-destructive`:``}),D&&h(`p`,{className:`text-destructive text-sm`,children:D})]}),g(i,{type:`submit`,className:`mt-6 w-full`,disabled:f,children:[f&&h(p,{className:`mr-2 h-4 w-4 animate-spin`}),f?`Signing In...`:`Sign In`]})]}),d!=null&&g(m,{children:[h(l,{}),h(v,{onGoogleSignIn:d,isLoading:f})]}),h(u,{className:`my-4`}),g(`div`,{className:`space-y-2 text-center text-sm`,children:[y&&g(`p`,{children:[`Don't have an account?`,` `,h(i,{variant:`link`,size:`sm`,onClick:y,disabled:f,className:`h-auto p-0`,children:`Sign up`})]}),b&&h(`p`,{children:h(i,{variant:`link`,size:`sm`,onClick:b,disabled:f,className:`h-auto p-0`,children:`Forgot your password?`})})]})]})})}function b({onSignUp:e,onGoogleSignIn:d,isLoading:f,error:_,onSwitchToSignIn:y}){let[b,x]=t(``),[S,C]=t(``),[w,T]=t(``),[E,D]=t(``),O=e=>{if(!e.trim())return T(`Email is required`),!1;let t=document.createElement(`input`);return t.type=`email`,t.value=e,t.validity.valid?(T(``),!0):(T(`Please enter a valid email address`),!1)},k=e=>e.trim()?e.length<6?(D(`Password must be at least 6 characters long`),!1):(D(``),!0):(D(`Password is required`),!1);return h(a,{className:`mx-auto w-full max-w-md`,children:g(o,{className:`p-6`,children:[h(`h2`,{className:`mb-4 text-center text-2xl font-bold`,children:`Sign Up`}),_!=null&&_.trim()!==``&&h(n,{variant:`destructive`,className:`mb-4`,children:h(r,{children:_})}),g(`form`,{onSubmit:t=>{t.preventDefault(),O(b)&&k(S)&&e(b,S).catch(console.error)},className:`space-y-4`,children:[g(`div`,{className:`space-y-2`,children:[h(c,{htmlFor:`email`,children:`Email`}),h(s,{id:`email`,type:`email`,value:b,onChange:e=>{x(e.target.value),w&&T(``)},disabled:f,required:!0,className:w?`border-destructive`:``}),w&&h(`p`,{className:`text-destructive text-sm`,children:w})]}),g(`div`,{className:`space-y-2`,children:[h(c,{htmlFor:`password`,children:`Password`}),h(s,{id:`password`,type:`password`,value:S,onChange:e=>{C(e.target.value),E&&D(``)},disabled:f,required:!0,className:E?`border-destructive`:``}),E&&h(`p`,{className:`text-destructive text-sm`,children:E})]}),g(i,{type:`submit`,className:`mt-6 w-full`,disabled:f,children:[f&&h(p,{className:`mr-2 h-4 w-4 animate-spin`}),f?`Signing Up...`:`Sign Up`]})]}),d!=null&&g(m,{children:[h(l,{}),h(v,{onGoogleSignIn:d,isLoading:f})]}),h(u,{className:`my-4`}),h(`div`,{className:`text-center text-sm`,children:y&&g(`p`,{children:[`Already have an account?`,` `,h(i,{variant:`link`,size:`sm`,onClick:y,disabled:f,className:`h-auto p-0`,children:`Sign in`})]})})]})})}function x({handleSignIn:e,handleSignUp:n,handleResetPassword:r,authLoadingState:i,authErrorData:a}){let[o,s]=t(`signin`);return h(`div`,{className:`flex min-h-screen items-center justify-center p-4`,children:g(`div`,{className:`w-full max-w-md`,children:[h(`h1`,{className:`mb-6 text-center text-3xl font-bold`,children:`Job Hunter`}),o===`signin`&&h(y,{onSignIn:e,isLoading:i.isLoading,error:a?.error??null,onSwitchToSignUp:()=>s(`signup`),onSwitchToReset:()=>s(`reset`)}),o===`signup`&&h(b,{onSignUp:n,isLoading:i.isLoading,error:a?.error??null,onSwitchToSignIn:()=>s(`signin`)}),o===`reset`&&h(_,{onResetPassword:r,isLoading:i.isLoading,error:a?.error??null,onSwitchToSignIn:()=>s(`signin`)})]})})}export{x as AuthForms,v as GoogleSignIn,_ as ResetPasswordForm,y as SignInForm,b as SignUpForm};
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pixpilot/shadcn-auth",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "Authentication forms and components built with shadcn/ui.",
|
|
6
|
+
"author": "m.doaie <m.doaie@hotmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/pixpilot/shadcn-components.git",
|
|
11
|
+
"directory": "packages/shadcn-auth"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": ">=18.0.0",
|
|
29
|
+
"react-dom": ">=18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"lucide-react": "0.553.0",
|
|
33
|
+
"@pixpilot/shadcn": "0.1.0",
|
|
34
|
+
"@pixpilot/shadcn-ui": "0.0.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@storybook/react": "^8.5.3",
|
|
38
|
+
"@types/node": "^22.18.11",
|
|
39
|
+
"@types/react": "^19.2.2",
|
|
40
|
+
"eslint": "^9.38.0",
|
|
41
|
+
"react": "19.2.0",
|
|
42
|
+
"react-dom": "19.2.0",
|
|
43
|
+
"tailwindcss": "^4.1.17",
|
|
44
|
+
"tsdown": "^0.15.8",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"typescript-eslint": "^8.46.3",
|
|
47
|
+
"@internal/eslint-config": "0.3.0",
|
|
48
|
+
"@internal/prettier-config": "0.0.1",
|
|
49
|
+
"@internal/tsconfig": "0.1.0",
|
|
50
|
+
"@internal/tsdown-config": "0.1.0",
|
|
51
|
+
"@internal/vitest-config": "0.1.0"
|
|
52
|
+
},
|
|
53
|
+
"prettier": "@internal/prettier-config",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"clean": "git clean -xdf .cache .turbo dist",
|
|
56
|
+
"clean:all": "git clean -xdf .cache .turbo dist node_modules",
|
|
57
|
+
"build": "tsdown",
|
|
58
|
+
"build:watch": "tsdown --watch",
|
|
59
|
+
"test": "vitest --run --passWithNoTests",
|
|
60
|
+
"test:watch": "vitest --watch",
|
|
61
|
+
"test:ui": "vitest --ui",
|
|
62
|
+
"test:coverage": "vitest --coverage",
|
|
63
|
+
"typecheck": "tsc --noEmit",
|
|
64
|
+
"lint": "eslint",
|
|
65
|
+
"format": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore"
|
|
66
|
+
},
|
|
67
|
+
"main": "./dist/index.cjs",
|
|
68
|
+
"module": "./dist/index.js",
|
|
69
|
+
"types": "./dist/index.d.ts"
|
|
70
|
+
}
|