@onexapis/cli 1.1.38 → 1.1.40
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/cli.js +384 -380
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +381 -376
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +258 -293
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +255 -289
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +13 -5
- package/package.json +1 -3
- package/templates/default/AUTH_AND_PROFILE.md +167 -0
- package/templates/default/CLAUDE.md +435 -6
- package/templates/default/LAYOUT.md +195 -0
- package/templates/default/bundle-entry.ts +5 -0
- package/templates/default/esbuild.config.js +20 -0
- package/templates/default/hooks/index.ts +26 -0
- package/templates/default/hooks/use-forgot-password-form.ts +90 -0
- package/templates/default/hooks/use-login-form.ts +102 -0
- package/templates/default/hooks/use-profile-form.ts +255 -0
- package/templates/default/hooks/use-register-form.ts +154 -0
- package/templates/default/hooks/use-verify-code-form.ts +224 -0
- package/templates/default/index.ts +21 -1
- package/templates/default/pages/about.ts +2 -2
- package/templates/default/pages/forgot-password.ts +39 -0
- package/templates/default/pages/home.ts +4 -4
- package/templates/default/pages/login.ts +39 -0
- package/templates/default/pages/profile.ts +39 -0
- package/templates/default/pages/register.ts +39 -0
- package/templates/default/pages/showcase.ts +7 -7
- package/templates/default/pages/verify-code.ts +39 -0
- package/templates/default/sections/about/about.schema.ts +1 -1
- package/templates/default/sections/auth-forgot-password/auth-forgot-password-default.tsx +192 -0
- package/templates/default/sections/auth-forgot-password/auth-forgot-password.schema.ts +150 -0
- package/templates/default/sections/auth-forgot-password/index.ts +14 -0
- package/templates/default/sections/auth-login/auth-login-default.tsx +238 -0
- package/templates/default/sections/auth-login/auth-login.schema.ts +171 -0
- package/templates/default/sections/auth-login/index.ts +14 -0
- package/templates/default/sections/auth-register/auth-register-default.tsx +327 -0
- package/templates/default/sections/auth-register/auth-register.schema.ts +188 -0
- package/templates/default/sections/auth-register/index.ts +14 -0
- package/templates/default/sections/auth-verify-code/auth-verify-code-default.tsx +209 -0
- package/templates/default/sections/auth-verify-code/auth-verify-code.schema.ts +150 -0
- package/templates/default/sections/auth-verify-code/index.ts +14 -0
- package/templates/default/sections/cta/cta.schema.ts +1 -1
- package/templates/default/sections/features/features.schema.ts +1 -1
- package/templates/default/sections/footer/footer-default.tsx +214 -0
- package/templates/default/sections/footer/footer.schema.ts +170 -0
- package/templates/default/sections/footer/index.ts +14 -0
- package/templates/default/sections/gallery/gallery.schema.ts +1 -1
- package/templates/default/sections/header/header-default.tsx +322 -0
- package/templates/default/sections/header/header.schema.ts +168 -0
- package/templates/default/sections/header/index.ts +14 -0
- package/templates/default/sections/hero/hero.schema.ts +1 -1
- package/templates/default/sections/profile/index.ts +14 -0
- package/templates/default/sections/profile/profile-default.tsx +522 -0
- package/templates/default/sections/profile/profile.schema.ts +228 -0
- package/templates/default/sections/stats/stats.schema.ts +1 -1
- package/templates/default/sections/testimonials/testimonials.schema.ts +1 -1
- package/templates/default/sections-registry.ts +28 -0
- package/templates/default/theme.layout.ts +71 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* My Simple Theme - Verify Code Page Configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { PageConfig } from "@onexapis/core/types";
|
|
6
|
+
|
|
7
|
+
export const verifyCodePageConfig: Omit<
|
|
8
|
+
PageConfig,
|
|
9
|
+
"id" | "createdAt" | "updatedAt"
|
|
10
|
+
> = {
|
|
11
|
+
title: "Verify Code",
|
|
12
|
+
handle: "verify-code",
|
|
13
|
+
path: "/verify-code",
|
|
14
|
+
type: "auth",
|
|
15
|
+
renderMode: "sections",
|
|
16
|
+
themeId: "my-simple",
|
|
17
|
+
editable: true,
|
|
18
|
+
published: true,
|
|
19
|
+
|
|
20
|
+
seo: {
|
|
21
|
+
title: "Verify Your Account",
|
|
22
|
+
description: "Enter the verification code sent to your email",
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
sections: [
|
|
26
|
+
{
|
|
27
|
+
id: "auth-verify-code-1",
|
|
28
|
+
type: "auth-verify-code",
|
|
29
|
+
template: "default",
|
|
30
|
+
order: 0,
|
|
31
|
+
enabled: true,
|
|
32
|
+
settings: {},
|
|
33
|
+
components: [],
|
|
34
|
+
blocks: [],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default verifyCodePageConfig;
|
|
@@ -56,7 +56,7 @@ const commonSettings: FieldDefinition[] = [
|
|
|
56
56
|
];
|
|
57
57
|
|
|
58
58
|
export const aboutSchema: SectionSchema = {
|
|
59
|
-
type: "
|
|
59
|
+
type: "about",
|
|
60
60
|
name: "Simple About",
|
|
61
61
|
description:
|
|
62
62
|
"About section with badge, heading, subheading, descriptions, divider, and image",
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Forgot Password - Default Template
|
|
3
|
+
* Clean forgot password form with customizable settings
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use client";
|
|
7
|
+
|
|
8
|
+
import type { SectionComponentProps } from "@onexapis/core/types";
|
|
9
|
+
import coreUtils from "@onexapis/core/utils";
|
|
10
|
+
import { useForgotPasswordForm } from "../../hooks/use-forgot-password-form";
|
|
11
|
+
|
|
12
|
+
const { getSectionValues } = coreUtils;
|
|
13
|
+
|
|
14
|
+
export function AuthForgotPasswordDefault({
|
|
15
|
+
section,
|
|
16
|
+
schema,
|
|
17
|
+
isEditing,
|
|
18
|
+
}: SectionComponentProps) {
|
|
19
|
+
const { settings } = getSectionValues(section, schema);
|
|
20
|
+
const {
|
|
21
|
+
heading,
|
|
22
|
+
subheading,
|
|
23
|
+
usernameLabel,
|
|
24
|
+
usernamePlaceholder,
|
|
25
|
+
submitButtonText,
|
|
26
|
+
loadingText,
|
|
27
|
+
backToLoginText,
|
|
28
|
+
loginUrl,
|
|
29
|
+
registerPromptText,
|
|
30
|
+
registerLinkText,
|
|
31
|
+
registerUrl,
|
|
32
|
+
backgroundColor,
|
|
33
|
+
cardBackground,
|
|
34
|
+
primaryColor,
|
|
35
|
+
textColor,
|
|
36
|
+
cardBorderRadius,
|
|
37
|
+
} = settings;
|
|
38
|
+
|
|
39
|
+
const { username, error, isPending, handleUsernameChange, handleSubmit } =
|
|
40
|
+
useForgotPasswordForm();
|
|
41
|
+
|
|
42
|
+
const bgColor = String(backgroundColor || "#F9FAFB");
|
|
43
|
+
const cardBg = String(cardBackground || "#FFFFFF");
|
|
44
|
+
const btnColor = String(primaryColor || "#2563EB");
|
|
45
|
+
const headingColor = String(textColor || "#111827");
|
|
46
|
+
const radiusClass = `rounded-${String(cardBorderRadius || "2xl")}`;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<section
|
|
50
|
+
className="min-h-screen w-full flex items-center justify-center p-4"
|
|
51
|
+
style={{ backgroundColor: bgColor }}
|
|
52
|
+
data-section-id={section.id}
|
|
53
|
+
data-section-type={section.type}
|
|
54
|
+
data-section-template="default"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
className={`w-full max-w-md shadow-lg p-8 ${radiusClass}`}
|
|
58
|
+
style={{ backgroundColor: cardBg }}
|
|
59
|
+
>
|
|
60
|
+
{/* Header */}
|
|
61
|
+
<div className="text-center mb-8">
|
|
62
|
+
<h1 className="text-2xl font-bold" style={{ color: headingColor }}>
|
|
63
|
+
{String(heading)}
|
|
64
|
+
</h1>
|
|
65
|
+
{subheading && (
|
|
66
|
+
<p className="mt-2 text-sm text-gray-500">{String(subheading)}</p>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
{/* Error Message */}
|
|
71
|
+
{error && (
|
|
72
|
+
<div className="mb-4 rounded-lg bg-red-50 border border-red-200 p-3 text-sm text-red-600">
|
|
73
|
+
{error}
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{/* Form */}
|
|
78
|
+
<form onSubmit={handleSubmit} className="space-y-5">
|
|
79
|
+
{/* Username / Email */}
|
|
80
|
+
<div className="flex flex-col gap-1.5">
|
|
81
|
+
<label
|
|
82
|
+
htmlFor="username"
|
|
83
|
+
className="text-sm font-medium text-gray-700"
|
|
84
|
+
>
|
|
85
|
+
{String(usernameLabel)} <span className="text-red-500">*</span>
|
|
86
|
+
</label>
|
|
87
|
+
<input
|
|
88
|
+
id="username"
|
|
89
|
+
name="username"
|
|
90
|
+
type="text"
|
|
91
|
+
value={username}
|
|
92
|
+
onChange={handleUsernameChange}
|
|
93
|
+
placeholder={String(usernamePlaceholder)}
|
|
94
|
+
disabled={isPending || isEditing}
|
|
95
|
+
className="h-11 w-full rounded-lg border border-gray-300 px-4 text-sm text-gray-900 placeholder:text-gray-400 outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:opacity-50"
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
{/* Submit Button */}
|
|
100
|
+
<button
|
|
101
|
+
type="submit"
|
|
102
|
+
disabled={isPending || isEditing}
|
|
103
|
+
className="h-11 w-full rounded-lg text-sm font-medium text-white transition-colors hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"
|
|
104
|
+
style={{ backgroundColor: btnColor }}
|
|
105
|
+
>
|
|
106
|
+
{isPending && (
|
|
107
|
+
<svg
|
|
108
|
+
className="h-4 w-4 animate-spin"
|
|
109
|
+
fill="none"
|
|
110
|
+
viewBox="0 0 24 24"
|
|
111
|
+
>
|
|
112
|
+
<circle
|
|
113
|
+
className="opacity-25"
|
|
114
|
+
cx="12"
|
|
115
|
+
cy="12"
|
|
116
|
+
r="10"
|
|
117
|
+
stroke="currentColor"
|
|
118
|
+
strokeWidth="4"
|
|
119
|
+
/>
|
|
120
|
+
<path
|
|
121
|
+
className="opacity-75"
|
|
122
|
+
fill="currentColor"
|
|
123
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
124
|
+
/>
|
|
125
|
+
</svg>
|
|
126
|
+
)}
|
|
127
|
+
{isPending ? String(loadingText) : String(submitButtonText)}
|
|
128
|
+
</button>
|
|
129
|
+
</form>
|
|
130
|
+
|
|
131
|
+
{/* Back to Login */}
|
|
132
|
+
<div className="mt-6 text-center">
|
|
133
|
+
{isEditing ? (
|
|
134
|
+
<span className="inline-flex items-center gap-2 text-sm text-gray-500">
|
|
135
|
+
<svg
|
|
136
|
+
className="h-4 w-4"
|
|
137
|
+
fill="none"
|
|
138
|
+
viewBox="0 0 24 24"
|
|
139
|
+
stroke="currentColor"
|
|
140
|
+
strokeWidth={2}
|
|
141
|
+
>
|
|
142
|
+
<path d="M10 19l-7-7m0 0l7-7m-7 7h18" />
|
|
143
|
+
</svg>
|
|
144
|
+
{String(backToLoginText)}
|
|
145
|
+
</span>
|
|
146
|
+
) : (
|
|
147
|
+
<a
|
|
148
|
+
href={String(loginUrl)}
|
|
149
|
+
className="inline-flex items-center gap-2 text-sm text-gray-500 hover:text-gray-700 transition-colors"
|
|
150
|
+
>
|
|
151
|
+
<svg
|
|
152
|
+
className="h-4 w-4"
|
|
153
|
+
fill="none"
|
|
154
|
+
viewBox="0 0 24 24"
|
|
155
|
+
stroke="currentColor"
|
|
156
|
+
strokeWidth={2}
|
|
157
|
+
>
|
|
158
|
+
<path d="M10 19l-7-7m0 0l7-7m-7 7h18" />
|
|
159
|
+
</svg>
|
|
160
|
+
{String(backToLoginText)}
|
|
161
|
+
</a>
|
|
162
|
+
)}
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
{/* Register Link */}
|
|
166
|
+
<div className="mt-4 text-center">
|
|
167
|
+
<p className="text-sm text-gray-500">
|
|
168
|
+
{String(registerPromptText)}{" "}
|
|
169
|
+
{isEditing ? (
|
|
170
|
+
<span
|
|
171
|
+
className="font-medium hover:opacity-80"
|
|
172
|
+
style={{ color: btnColor }}
|
|
173
|
+
>
|
|
174
|
+
{String(registerLinkText)}
|
|
175
|
+
</span>
|
|
176
|
+
) : (
|
|
177
|
+
<a
|
|
178
|
+
href={String(registerUrl)}
|
|
179
|
+
className="font-medium hover:opacity-80 transition-colors"
|
|
180
|
+
style={{ color: btnColor }}
|
|
181
|
+
>
|
|
182
|
+
{String(registerLinkText)}
|
|
183
|
+
</a>
|
|
184
|
+
)}
|
|
185
|
+
</p>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
</section>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default AuthForgotPasswordDefault;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Forgot Password Section Schema
|
|
3
|
+
* Forgot password form with editable labels
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SectionSchema, FieldDefinition } from "@onexapis/core/types";
|
|
7
|
+
|
|
8
|
+
const commonSettings: FieldDefinition[] = [
|
|
9
|
+
{
|
|
10
|
+
id: "heading",
|
|
11
|
+
type: "text",
|
|
12
|
+
label: "Heading",
|
|
13
|
+
default: "Forgot Password",
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "subheading",
|
|
18
|
+
type: "text",
|
|
19
|
+
label: "Subheading",
|
|
20
|
+
default: "Enter your email or username to receive a verification code",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "usernameLabel",
|
|
24
|
+
type: "text",
|
|
25
|
+
label: "Email/Username Label",
|
|
26
|
+
default: "Email",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "usernamePlaceholder",
|
|
30
|
+
type: "text",
|
|
31
|
+
label: "Placeholder",
|
|
32
|
+
default: "Enter your email or username",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "submitButtonText",
|
|
36
|
+
type: "text",
|
|
37
|
+
label: "Submit Button Text",
|
|
38
|
+
default: "Send Verification Code",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "loadingText",
|
|
42
|
+
type: "text",
|
|
43
|
+
label: "Loading Text",
|
|
44
|
+
default: "Sending...",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "backToLoginText",
|
|
48
|
+
type: "text",
|
|
49
|
+
label: "Back to Login Text",
|
|
50
|
+
default: "Back to login",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "loginUrl",
|
|
54
|
+
type: "url",
|
|
55
|
+
label: "Login URL",
|
|
56
|
+
default: "/login",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "registerPromptText",
|
|
60
|
+
type: "text",
|
|
61
|
+
label: "Register Prompt Text",
|
|
62
|
+
default: "Don't have an account?",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "registerLinkText",
|
|
66
|
+
type: "text",
|
|
67
|
+
label: "Register Link Text",
|
|
68
|
+
default: "Sign up",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "registerUrl",
|
|
72
|
+
type: "url",
|
|
73
|
+
label: "Register URL",
|
|
74
|
+
default: "/register",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "backgroundColor",
|
|
78
|
+
type: "color",
|
|
79
|
+
label: "Background Color",
|
|
80
|
+
default: "#F9FAFB",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "cardBackground",
|
|
84
|
+
type: "color",
|
|
85
|
+
label: "Card Background",
|
|
86
|
+
default: "#FFFFFF",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "primaryColor",
|
|
90
|
+
type: "color",
|
|
91
|
+
label: "Primary Color (buttons)",
|
|
92
|
+
default: "#2563EB",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "textColor",
|
|
96
|
+
type: "color",
|
|
97
|
+
label: "Heading Text Color",
|
|
98
|
+
default: "#111827",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "cardBorderRadius",
|
|
102
|
+
type: "select",
|
|
103
|
+
label: "Card Border Radius",
|
|
104
|
+
default: "2xl",
|
|
105
|
+
options: [
|
|
106
|
+
{ label: "Small", value: "lg" },
|
|
107
|
+
{ label: "Medium", value: "xl" },
|
|
108
|
+
{ label: "Large", value: "2xl" },
|
|
109
|
+
{ label: "Extra Large", value: "3xl" },
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
export const authForgotPasswordSchema: SectionSchema = {
|
|
115
|
+
type: "auth-forgot-password",
|
|
116
|
+
name: "Auth Forgot Password",
|
|
117
|
+
description: "Forgot password form with email/username input",
|
|
118
|
+
category: "auth",
|
|
119
|
+
icon: "key",
|
|
120
|
+
settings: commonSettings,
|
|
121
|
+
templates: [
|
|
122
|
+
{
|
|
123
|
+
id: "default",
|
|
124
|
+
name: "Default Forgot Password",
|
|
125
|
+
description: "Clean forgot password form",
|
|
126
|
+
isDefault: true,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
defaults: {
|
|
130
|
+
settings: {
|
|
131
|
+
heading: "Forgot Password",
|
|
132
|
+
subheading: "Enter your email or username to receive a verification code",
|
|
133
|
+
usernameLabel: "Email",
|
|
134
|
+
usernamePlaceholder: "Enter your email or username",
|
|
135
|
+
submitButtonText: "Send Verification Code",
|
|
136
|
+
loadingText: "Sending...",
|
|
137
|
+
backToLoginText: "Back to login",
|
|
138
|
+
loginUrl: "/login",
|
|
139
|
+
registerPromptText: "Don't have an account?",
|
|
140
|
+
registerLinkText: "Sign up",
|
|
141
|
+
registerUrl: "/register",
|
|
142
|
+
backgroundColor: "#F9FAFB",
|
|
143
|
+
cardBackground: "#FFFFFF",
|
|
144
|
+
primaryColor: "#2563EB",
|
|
145
|
+
textColor: "#111827",
|
|
146
|
+
cardBorderRadius: "2xl",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
tags: ["auth", "forgot-password", "reset"],
|
|
150
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Forgot Password Section
|
|
3
|
+
* Exports schema and component templates
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SectionComponentProps } from "@onexapis/core/types";
|
|
7
|
+
import { AuthForgotPasswordDefault } from "./auth-forgot-password-default";
|
|
8
|
+
|
|
9
|
+
export const authForgotPasswordComponents: Record<
|
|
10
|
+
string,
|
|
11
|
+
React.ComponentType<SectionComponentProps>
|
|
12
|
+
> = { default: AuthForgotPasswordDefault };
|
|
13
|
+
|
|
14
|
+
export { authForgotPasswordSchema } from "./auth-forgot-password.schema";
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Login - Default Template
|
|
3
|
+
* Clean login form with customizable settings
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use client";
|
|
7
|
+
|
|
8
|
+
import type { SectionComponentProps } from "@onexapis/core/types";
|
|
9
|
+
import coreUtils from "@onexapis/core/utils";
|
|
10
|
+
import { useLoginForm } from "../../hooks/use-login-form";
|
|
11
|
+
|
|
12
|
+
const { getSectionValues } = coreUtils;
|
|
13
|
+
|
|
14
|
+
export function AuthLoginDefault({
|
|
15
|
+
section,
|
|
16
|
+
schema,
|
|
17
|
+
isEditing,
|
|
18
|
+
}: SectionComponentProps) {
|
|
19
|
+
const { settings } = getSectionValues(section, schema);
|
|
20
|
+
const {
|
|
21
|
+
heading,
|
|
22
|
+
subheading,
|
|
23
|
+
usernameLabel,
|
|
24
|
+
usernamePlaceholder,
|
|
25
|
+
passwordLabel,
|
|
26
|
+
passwordPlaceholder,
|
|
27
|
+
submitButtonText,
|
|
28
|
+
loadingText,
|
|
29
|
+
forgotPasswordText,
|
|
30
|
+
forgotPasswordUrl,
|
|
31
|
+
registerPromptText,
|
|
32
|
+
registerLinkText,
|
|
33
|
+
registerUrl,
|
|
34
|
+
backgroundColor,
|
|
35
|
+
cardBackground,
|
|
36
|
+
primaryColor,
|
|
37
|
+
textColor,
|
|
38
|
+
cardBorderRadius,
|
|
39
|
+
} = settings;
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
formData,
|
|
43
|
+
errors,
|
|
44
|
+
showPassword,
|
|
45
|
+
isPending,
|
|
46
|
+
handleInputChange,
|
|
47
|
+
handleSubmit,
|
|
48
|
+
toggleShowPassword,
|
|
49
|
+
} = useLoginForm();
|
|
50
|
+
|
|
51
|
+
const bgColor = String(backgroundColor || "#F9FAFB");
|
|
52
|
+
const cardBg = String(cardBackground || "#FFFFFF");
|
|
53
|
+
const btnColor = String(primaryColor || "#2563EB");
|
|
54
|
+
const headingColor = String(textColor || "#111827");
|
|
55
|
+
const radius = String(cardBorderRadius || "2xl");
|
|
56
|
+
const radiusClass = `rounded-${radius}`;
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<section
|
|
60
|
+
className="min-h-screen w-full flex items-center justify-center p-4"
|
|
61
|
+
style={{ backgroundColor: bgColor }}
|
|
62
|
+
data-section-id={section.id}
|
|
63
|
+
data-section-type={section.type}
|
|
64
|
+
data-section-template="default"
|
|
65
|
+
>
|
|
66
|
+
<div
|
|
67
|
+
className={`w-full max-w-md shadow-lg p-8 ${radiusClass}`}
|
|
68
|
+
style={{ backgroundColor: cardBg }}
|
|
69
|
+
>
|
|
70
|
+
{/* Header */}
|
|
71
|
+
<div className="text-center mb-8">
|
|
72
|
+
<h1 className="text-2xl font-bold" style={{ color: headingColor }}>
|
|
73
|
+
{String(heading)}
|
|
74
|
+
</h1>
|
|
75
|
+
{subheading && (
|
|
76
|
+
<p className="mt-2 text-sm text-gray-500">{String(subheading)}</p>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
{/* Error Message */}
|
|
81
|
+
{errors.form && (
|
|
82
|
+
<div className="mb-4 rounded-lg bg-red-50 border border-red-200 p-3 text-sm text-red-600">
|
|
83
|
+
{errors.form}
|
|
84
|
+
</div>
|
|
85
|
+
)}
|
|
86
|
+
|
|
87
|
+
{/* Form */}
|
|
88
|
+
<form onSubmit={handleSubmit} className="space-y-5">
|
|
89
|
+
{/* Username */}
|
|
90
|
+
<div className="flex flex-col gap-1.5">
|
|
91
|
+
<label
|
|
92
|
+
htmlFor="username"
|
|
93
|
+
className="text-sm font-medium text-gray-700"
|
|
94
|
+
>
|
|
95
|
+
{String(usernameLabel)} <span className="text-red-500">*</span>
|
|
96
|
+
</label>
|
|
97
|
+
<input
|
|
98
|
+
id="username"
|
|
99
|
+
name="username"
|
|
100
|
+
type="text"
|
|
101
|
+
value={formData.username}
|
|
102
|
+
onChange={handleInputChange}
|
|
103
|
+
placeholder={String(usernamePlaceholder)}
|
|
104
|
+
disabled={isPending || isEditing}
|
|
105
|
+
className={`h-11 w-full rounded-lg border px-4 text-sm text-gray-900 placeholder:text-gray-400 outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:opacity-50 ${
|
|
106
|
+
errors.username ? "border-red-400" : "border-gray-300"
|
|
107
|
+
}`}
|
|
108
|
+
/>
|
|
109
|
+
{errors.username && (
|
|
110
|
+
<p className="text-xs text-red-500">{errors.username}</p>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
{/* Password */}
|
|
115
|
+
<div className="flex flex-col gap-1.5">
|
|
116
|
+
<div className="flex items-center justify-between">
|
|
117
|
+
<label
|
|
118
|
+
htmlFor="password"
|
|
119
|
+
className="text-sm font-medium text-gray-700"
|
|
120
|
+
>
|
|
121
|
+
{String(passwordLabel)} <span className="text-red-500">*</span>
|
|
122
|
+
</label>
|
|
123
|
+
{!isEditing && (
|
|
124
|
+
<a
|
|
125
|
+
href={String(forgotPasswordUrl)}
|
|
126
|
+
className="text-xs font-medium hover:opacity-80 transition-colors"
|
|
127
|
+
style={{ color: btnColor }}
|
|
128
|
+
tabIndex={-1}
|
|
129
|
+
>
|
|
130
|
+
{String(forgotPasswordText)}
|
|
131
|
+
</a>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
<div className="relative">
|
|
135
|
+
<input
|
|
136
|
+
id="password"
|
|
137
|
+
name="password"
|
|
138
|
+
type={showPassword ? "text" : "password"}
|
|
139
|
+
value={formData.password}
|
|
140
|
+
onChange={handleInputChange}
|
|
141
|
+
placeholder={String(passwordPlaceholder)}
|
|
142
|
+
disabled={isPending || isEditing}
|
|
143
|
+
className={`h-11 w-full rounded-lg border px-4 pr-10 text-sm text-gray-900 placeholder:text-gray-400 outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:opacity-50 ${
|
|
144
|
+
errors.password ? "border-red-400" : "border-gray-300"
|
|
145
|
+
}`}
|
|
146
|
+
/>
|
|
147
|
+
<button
|
|
148
|
+
type="button"
|
|
149
|
+
onClick={toggleShowPassword}
|
|
150
|
+
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors"
|
|
151
|
+
tabIndex={-1}
|
|
152
|
+
>
|
|
153
|
+
{showPassword ? (
|
|
154
|
+
<svg
|
|
155
|
+
className="h-4 w-4"
|
|
156
|
+
fill="none"
|
|
157
|
+
viewBox="0 0 24 24"
|
|
158
|
+
stroke="currentColor"
|
|
159
|
+
strokeWidth={2}
|
|
160
|
+
>
|
|
161
|
+
<path d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />
|
|
162
|
+
</svg>
|
|
163
|
+
) : (
|
|
164
|
+
<svg
|
|
165
|
+
className="h-4 w-4"
|
|
166
|
+
fill="none"
|
|
167
|
+
viewBox="0 0 24 24"
|
|
168
|
+
stroke="currentColor"
|
|
169
|
+
strokeWidth={2}
|
|
170
|
+
>
|
|
171
|
+
<path d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
172
|
+
<path d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
|
173
|
+
</svg>
|
|
174
|
+
)}
|
|
175
|
+
</button>
|
|
176
|
+
</div>
|
|
177
|
+
{errors.password && (
|
|
178
|
+
<p className="text-xs text-red-500">{errors.password}</p>
|
|
179
|
+
)}
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
{/* Submit Button */}
|
|
183
|
+
<button
|
|
184
|
+
type="submit"
|
|
185
|
+
disabled={isPending || isEditing}
|
|
186
|
+
className="h-11 w-full rounded-lg text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"
|
|
187
|
+
style={{ backgroundColor: btnColor }}
|
|
188
|
+
>
|
|
189
|
+
{isPending && (
|
|
190
|
+
<svg
|
|
191
|
+
className="h-4 w-4 animate-spin"
|
|
192
|
+
fill="none"
|
|
193
|
+
viewBox="0 0 24 24"
|
|
194
|
+
>
|
|
195
|
+
<circle
|
|
196
|
+
className="opacity-25"
|
|
197
|
+
cx="12"
|
|
198
|
+
cy="12"
|
|
199
|
+
r="10"
|
|
200
|
+
stroke="currentColor"
|
|
201
|
+
strokeWidth="4"
|
|
202
|
+
/>
|
|
203
|
+
<path
|
|
204
|
+
className="opacity-75"
|
|
205
|
+
fill="currentColor"
|
|
206
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
207
|
+
/>
|
|
208
|
+
</svg>
|
|
209
|
+
)}
|
|
210
|
+
{isPending ? String(loadingText) : String(submitButtonText)}
|
|
211
|
+
</button>
|
|
212
|
+
</form>
|
|
213
|
+
|
|
214
|
+
{/* Register Link */}
|
|
215
|
+
<div className="mt-6 text-center">
|
|
216
|
+
<p className="text-sm text-gray-500">
|
|
217
|
+
{String(registerPromptText)}{" "}
|
|
218
|
+
{isEditing ? (
|
|
219
|
+
<span className="font-medium" style={{ color: btnColor }}>
|
|
220
|
+
{String(registerLinkText)}
|
|
221
|
+
</span>
|
|
222
|
+
) : (
|
|
223
|
+
<a
|
|
224
|
+
href={String(registerUrl)}
|
|
225
|
+
className="font-medium hover:opacity-80 transition-colors"
|
|
226
|
+
style={{ color: btnColor }}
|
|
227
|
+
>
|
|
228
|
+
{String(registerLinkText)}
|
|
229
|
+
</a>
|
|
230
|
+
)}
|
|
231
|
+
</p>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
</section>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default AuthLoginDefault;
|