@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.
@@ -0,0 +1,149 @@
1
+ import { GoogleSignIn } from "./GoogleSignIn.js";
2
+ import React, { useState } from "react";
3
+ import { Alert, AlertDescription, Button, Card, CardContent, Input, Label, OrContinueWithSeparator, Separator } from "@wordrhyme/shadcn";
4
+ import { Loader2 } from "lucide-react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+
7
+ //#region src/SignUpForm.tsx
8
+ const MIN_PASSWORD_LENGTH = 6;
9
+ function SignUpForm({ onSignUp, onGoogleSignIn, isLoading, error, onSwitchToSignIn }) {
10
+ const [email, setEmail] = useState("");
11
+ const [password, setPassword] = useState("");
12
+ const [emailError, setEmailError] = useState("");
13
+ const [passwordError, setPasswordError] = 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 validatePassword = (passwordValue) => {
30
+ if (!passwordValue.trim()) {
31
+ setPasswordError("Password is required");
32
+ return false;
33
+ }
34
+ if (passwordValue.length < MIN_PASSWORD_LENGTH) {
35
+ setPasswordError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters long`);
36
+ return false;
37
+ }
38
+ setPasswordError("");
39
+ return true;
40
+ };
41
+ const handleSubmit = (e) => {
42
+ e.preventDefault();
43
+ if (!validateEmail(email)) return;
44
+ if (!validatePassword(password)) return;
45
+ onSignUp(email, password).catch(console.error);
46
+ };
47
+ return /* @__PURE__ */ jsx(Card, {
48
+ className: "mx-auto w-full max-w-md",
49
+ children: /* @__PURE__ */ jsxs(CardContent, {
50
+ className: "p-6",
51
+ children: [
52
+ /* @__PURE__ */ jsx("h2", {
53
+ className: "mb-4 text-center text-2xl font-bold",
54
+ children: "Sign Up"
55
+ }),
56
+ error != null && error.trim() !== "" && /* @__PURE__ */ jsx(Alert, {
57
+ variant: "destructive",
58
+ className: "mb-4",
59
+ children: /* @__PURE__ */ jsx(AlertDescription, { children: error })
60
+ }),
61
+ /* @__PURE__ */ jsxs("form", {
62
+ onSubmit: handleSubmit,
63
+ className: "space-y-4",
64
+ children: [
65
+ /* @__PURE__ */ jsxs("div", {
66
+ className: "space-y-2",
67
+ children: [
68
+ /* @__PURE__ */ jsx(Label, {
69
+ htmlFor: "email",
70
+ children: "Email"
71
+ }),
72
+ /* @__PURE__ */ jsx(Input, {
73
+ id: "email",
74
+ type: "email",
75
+ value: email,
76
+ onChange: (e) => {
77
+ setEmail(e.target.value);
78
+ if (emailError) setEmailError("");
79
+ },
80
+ disabled: isLoading,
81
+ required: true,
82
+ className: emailError ? "border-destructive" : ""
83
+ }),
84
+ emailError && /* @__PURE__ */ jsx("p", {
85
+ className: "text-destructive text-sm",
86
+ children: emailError
87
+ })
88
+ ]
89
+ }),
90
+ /* @__PURE__ */ jsxs("div", {
91
+ className: "space-y-2",
92
+ children: [
93
+ /* @__PURE__ */ jsx(Label, {
94
+ htmlFor: "password",
95
+ children: "Password"
96
+ }),
97
+ /* @__PURE__ */ jsx(Input, {
98
+ id: "password",
99
+ type: "password",
100
+ value: password,
101
+ onChange: (e) => {
102
+ setPassword(e.target.value);
103
+ if (passwordError) setPasswordError("");
104
+ },
105
+ disabled: isLoading,
106
+ required: true,
107
+ className: passwordError ? "border-destructive" : ""
108
+ }),
109
+ passwordError && /* @__PURE__ */ jsx("p", {
110
+ className: "text-destructive text-sm",
111
+ children: passwordError
112
+ })
113
+ ]
114
+ }),
115
+ /* @__PURE__ */ jsxs(Button, {
116
+ type: "submit",
117
+ className: "mt-6 w-full",
118
+ disabled: isLoading,
119
+ children: [isLoading && /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), isLoading ? "Signing Up..." : "Sign Up"]
120
+ })
121
+ ]
122
+ }),
123
+ onGoogleSignIn != null && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(OrContinueWithSeparator, {}), /* @__PURE__ */ jsx(GoogleSignIn, {
124
+ onGoogleSignIn,
125
+ isLoading
126
+ })] }),
127
+ /* @__PURE__ */ jsx(Separator, { className: "my-4" }),
128
+ /* @__PURE__ */ jsx("div", {
129
+ className: "text-center text-sm",
130
+ children: onSwitchToSignIn && /* @__PURE__ */ jsxs("p", { children: [
131
+ "Already have an account?",
132
+ " ",
133
+ /* @__PURE__ */ jsx(Button, {
134
+ variant: "link",
135
+ size: "sm",
136
+ onClick: onSwitchToSignIn,
137
+ disabled: isLoading,
138
+ className: "h-auto p-0",
139
+ children: "Sign in"
140
+ })
141
+ ] })
142
+ })
143
+ ]
144
+ })
145
+ });
146
+ }
147
+
148
+ //#endregion
149
+ export { SignUpForm };
@@ -0,0 +1,25 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ exports.__toESM = __toESM;
package/dist/index.cjs ADDED
@@ -0,0 +1,11 @@
1
+ const require_ResetPasswordForm = require('./ResetPasswordForm.cjs');
2
+ const require_GoogleSignIn = require('./GoogleSignIn.cjs');
3
+ const require_SignInForm = require('./SignInForm.cjs');
4
+ const require_SignUpForm = require('./SignUpForm.cjs');
5
+ const require_AuthForms = require('./AuthForms.cjs');
6
+
7
+ exports.AuthForms = require_AuthForms.AuthForms;
8
+ exports.GoogleSignIn = require_GoogleSignIn.GoogleSignIn;
9
+ exports.ResetPasswordForm = require_ResetPasswordForm.ResetPasswordForm;
10
+ exports.SignInForm = require_SignInForm.SignInForm;
11
+ exports.SignUpForm = require_SignUpForm.SignUpForm;
@@ -0,0 +1,6 @@
1
+ import { AuthForms } from "./AuthForms.cjs";
2
+ import { GoogleSignIn, GoogleSignInProps } from "./GoogleSignIn.cjs";
3
+ import { ResetPasswordForm } from "./ResetPasswordForm.cjs";
4
+ import { SignInForm } from "./SignInForm.cjs";
5
+ import { SignUpForm } from "./SignUpForm.cjs";
6
+ export { AuthForms, GoogleSignIn, GoogleSignInProps, ResetPasswordForm, SignInForm, SignUpForm };
@@ -0,0 +1,6 @@
1
+ import { AuthForms } from "./AuthForms.js";
2
+ import { GoogleSignIn, GoogleSignInProps } from "./GoogleSignIn.js";
3
+ import { ResetPasswordForm } from "./ResetPasswordForm.js";
4
+ import { SignInForm } from "./SignInForm.js";
5
+ import { SignUpForm } from "./SignUpForm.js";
6
+ export { AuthForms, GoogleSignIn, GoogleSignInProps, ResetPasswordForm, SignInForm, SignUpForm };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { ResetPasswordForm } from "./ResetPasswordForm.js";
2
+ import { GoogleSignIn } from "./GoogleSignIn.js";
3
+ import { SignInForm } from "./SignInForm.js";
4
+ import { SignUpForm } from "./SignUpForm.js";
5
+ import { AuthForms } from "./AuthForms.js";
6
+
7
+ export { AuthForms, GoogleSignIn, ResetPasswordForm, SignInForm, SignUpForm };
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@wordrhyme/shadcn-auth",
3
+ "type": "module",
4
+ "version": "1.0.60",
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
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "peerDependencies": {
27
+ "react": ">=18.0.0",
28
+ "react-dom": ">=18.0.0"
29
+ },
30
+ "dependencies": {
31
+ "lucide-react": "0.553.0",
32
+ "@wordrhyme/shadcn": "1.3.2",
33
+ "@wordrhyme/shadcn-ui": "1.32.2"
34
+ },
35
+ "devDependencies": {
36
+ "@storybook/react": "^8.6.18",
37
+ "@types/node": "^22.19.17",
38
+ "@types/react": "^19.2.14",
39
+ "eslint": "^9.39.4",
40
+ "react": "19.2.4",
41
+ "react-dom": "19.2.4",
42
+ "tailwindcss": "^4.2.2",
43
+ "tsdown": "^0.15.12",
44
+ "typescript": "^5.9.3",
45
+ "typescript-eslint": "^8.58.1",
46
+ "@internal/eslint-config": "0.3.0",
47
+ "@internal/tsconfig": "0.1.0",
48
+ "@internal/prettier-config": "0.0.1",
49
+ "@internal/tsdown-config": "0.1.0",
50
+ "@internal/vitest-config": "0.1.0"
51
+ },
52
+ "prettier": "@internal/prettier-config",
53
+ "scripts": {
54
+ "clean": "git clean -xdf .cache .turbo dist",
55
+ "clean:all": "git clean -xdf .cache .turbo dist node_modules",
56
+ "build": "tsdown",
57
+ "build:watch": "tsdown --watch",
58
+ "test": "vitest --run --passWithNoTests",
59
+ "test:watch": "vitest --watch",
60
+ "test:ui": "vitest --ui",
61
+ "test:coverage": "vitest --coverage",
62
+ "typecheck": "tsc --noEmit",
63
+ "lint": "eslint",
64
+ "format": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore"
65
+ },
66
+ "main": "./dist/index.cjs",
67
+ "module": "./dist/index.js",
68
+ "types": "./dist/index.d.ts"
69
+ }