@onexapis/cli 1.1.34 → 1.1.37

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.
Files changed (45) hide show
  1. package/dist/cli.js +5 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +5 -1
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/preview/preview-app.tsx +13 -5
  6. package/package.json +1 -1
  7. package/templates/default/AUTH_AND_PROFILE.md +167 -0
  8. package/templates/default/CLAUDE.md +78 -24
  9. package/templates/default/LAYOUT.md +195 -0
  10. package/templates/default/bundle-entry.ts +5 -0
  11. package/templates/default/hooks/index.ts +26 -0
  12. package/templates/default/hooks/use-forgot-password-form.ts +90 -0
  13. package/templates/default/hooks/use-login-form.ts +102 -0
  14. package/templates/default/hooks/use-profile-form.ts +255 -0
  15. package/templates/default/hooks/use-register-form.ts +154 -0
  16. package/templates/default/hooks/use-verify-code-form.ts +224 -0
  17. package/templates/default/index.ts +21 -1
  18. package/templates/default/pages/forgot-password.ts +41 -0
  19. package/templates/default/pages/login.ts +41 -0
  20. package/templates/default/pages/profile.ts +39 -0
  21. package/templates/default/pages/register.ts +41 -0
  22. package/templates/default/pages/verify-code.ts +41 -0
  23. package/templates/default/sections/auth-forgot-password/auth-forgot-password-default.tsx +192 -0
  24. package/templates/default/sections/auth-forgot-password/auth-forgot-password.schema.ts +150 -0
  25. package/templates/default/sections/auth-forgot-password/index.ts +14 -0
  26. package/templates/default/sections/auth-login/auth-login-default.tsx +238 -0
  27. package/templates/default/sections/auth-login/auth-login.schema.ts +171 -0
  28. package/templates/default/sections/auth-login/index.ts +14 -0
  29. package/templates/default/sections/auth-register/auth-register-default.tsx +327 -0
  30. package/templates/default/sections/auth-register/auth-register.schema.ts +188 -0
  31. package/templates/default/sections/auth-register/index.ts +14 -0
  32. package/templates/default/sections/auth-verify-code/auth-verify-code-default.tsx +209 -0
  33. package/templates/default/sections/auth-verify-code/auth-verify-code.schema.ts +150 -0
  34. package/templates/default/sections/auth-verify-code/index.ts +14 -0
  35. package/templates/default/sections/footer/footer-default.tsx +214 -0
  36. package/templates/default/sections/footer/footer.schema.ts +170 -0
  37. package/templates/default/sections/footer/index.ts +14 -0
  38. package/templates/default/sections/header/header-default.tsx +322 -0
  39. package/templates/default/sections/header/header.schema.ts +168 -0
  40. package/templates/default/sections/header/index.ts +14 -0
  41. package/templates/default/sections/profile/index.ts +14 -0
  42. package/templates/default/sections/profile/profile-default.tsx +522 -0
  43. package/templates/default/sections/profile/profile.schema.ts +228 -0
  44. package/templates/default/sections-registry.ts +28 -0
  45. package/templates/default/theme.layout.ts +53 -2
@@ -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: "my-simple-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;
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Auth Login Section Schema
3
+ * Login form with editable labels and settings
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: "Sign In",
14
+ required: true,
15
+ },
16
+ {
17
+ id: "subheading",
18
+ type: "text",
19
+ label: "Subheading",
20
+ default: "Sign in to manage your orders and enjoy exclusive offers",
21
+ },
22
+ {
23
+ id: "usernameLabel",
24
+ type: "text",
25
+ label: "Username Label",
26
+ default: "Username",
27
+ },
28
+ {
29
+ id: "usernamePlaceholder",
30
+ type: "text",
31
+ label: "Username Placeholder",
32
+ default: "Enter your username or email",
33
+ },
34
+ {
35
+ id: "passwordLabel",
36
+ type: "text",
37
+ label: "Password Label",
38
+ default: "Password",
39
+ },
40
+ {
41
+ id: "passwordPlaceholder",
42
+ type: "text",
43
+ label: "Password Placeholder",
44
+ default: "Enter your password",
45
+ },
46
+ {
47
+ id: "submitButtonText",
48
+ type: "text",
49
+ label: "Submit Button Text",
50
+ default: "Sign In",
51
+ },
52
+ {
53
+ id: "loadingText",
54
+ type: "text",
55
+ label: "Loading Text",
56
+ default: "Signing in...",
57
+ },
58
+ {
59
+ id: "forgotPasswordText",
60
+ type: "text",
61
+ label: "Forgot Password Text",
62
+ default: "Forgot password?",
63
+ },
64
+ {
65
+ id: "forgotPasswordUrl",
66
+ type: "url",
67
+ label: "Forgot Password URL",
68
+ default: "/forgot-password",
69
+ },
70
+ {
71
+ id: "registerPromptText",
72
+ type: "text",
73
+ label: "Register Prompt Text",
74
+ default: "Don't have an account?",
75
+ },
76
+ {
77
+ id: "registerLinkText",
78
+ type: "text",
79
+ label: "Register Link Text",
80
+ default: "Sign up",
81
+ },
82
+ {
83
+ id: "registerUrl",
84
+ type: "url",
85
+ label: "Register URL",
86
+ default: "/register",
87
+ },
88
+ {
89
+ id: "successRedirectUrl",
90
+ type: "url",
91
+ label: "Redirect URL after login",
92
+ default: "/",
93
+ },
94
+ {
95
+ id: "backgroundColor",
96
+ type: "color",
97
+ label: "Background Color",
98
+ default: "#F9FAFB",
99
+ },
100
+ {
101
+ id: "cardBackground",
102
+ type: "color",
103
+ label: "Card Background",
104
+ default: "#FFFFFF",
105
+ },
106
+ {
107
+ id: "primaryColor",
108
+ type: "color",
109
+ label: "Primary Color (buttons)",
110
+ default: "#2563EB",
111
+ },
112
+ {
113
+ id: "textColor",
114
+ type: "color",
115
+ label: "Heading Text Color",
116
+ default: "#111827",
117
+ },
118
+ {
119
+ id: "cardBorderRadius",
120
+ type: "select",
121
+ label: "Card Border Radius",
122
+ default: "2xl",
123
+ options: [
124
+ { label: "Small", value: "lg" },
125
+ { label: "Medium", value: "xl" },
126
+ { label: "Large", value: "2xl" },
127
+ { label: "Extra Large", value: "3xl" },
128
+ ],
129
+ },
130
+ ];
131
+
132
+ export const authLoginSchema: SectionSchema = {
133
+ type: "my-simple-auth-login",
134
+ name: "Auth Login",
135
+ description: "Login form with username and password",
136
+ category: "auth",
137
+ icon: "log-in",
138
+ settings: commonSettings,
139
+ templates: [
140
+ {
141
+ id: "default",
142
+ name: "Default Login",
143
+ description: "Clean login form with customizable labels",
144
+ isDefault: true,
145
+ },
146
+ ],
147
+ defaults: {
148
+ settings: {
149
+ heading: "Sign In",
150
+ subheading: "Sign in to manage your orders and enjoy exclusive offers",
151
+ usernameLabel: "Username",
152
+ usernamePlaceholder: "Enter your username or email",
153
+ passwordLabel: "Password",
154
+ passwordPlaceholder: "Enter your password",
155
+ submitButtonText: "Sign In",
156
+ loadingText: "Signing in...",
157
+ forgotPasswordText: "Forgot password?",
158
+ forgotPasswordUrl: "/forgot-password",
159
+ registerPromptText: "Don't have an account?",
160
+ registerLinkText: "Sign up",
161
+ registerUrl: "/register",
162
+ successRedirectUrl: "/",
163
+ backgroundColor: "#F9FAFB",
164
+ cardBackground: "#FFFFFF",
165
+ primaryColor: "#2563EB",
166
+ textColor: "#111827",
167
+ cardBorderRadius: "2xl",
168
+ },
169
+ },
170
+ tags: ["auth", "login", "sign-in"],
171
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Auth Login Section
3
+ * Exports schema and component templates
4
+ */
5
+
6
+ import type { SectionComponentProps } from "@onexapis/core/types";
7
+ import { AuthLoginDefault } from "./auth-login-default";
8
+
9
+ export const authLoginComponents: Record<
10
+ string,
11
+ React.ComponentType<SectionComponentProps>
12
+ > = { default: AuthLoginDefault };
13
+
14
+ export { authLoginSchema } from "./auth-login.schema";