vibes-plug 1.0.0 → 2.5.0
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/.github/workflows/publish.yml +20 -0
- package/AGENTS.md +66 -0
- package/BLUEPRINT.md +152 -60
- package/CHANGELOG.md +50 -0
- package/README.md +346 -194
- package/package.json +25 -25
- package/plugin.json +1 -1
- package/skills/ai-cost-token-optimizer/SKILL.md +52 -0
- package/skills/ai-llm-integration-expert/SKILL.md +180 -162
- package/skills/api-design-expert/SKILL.md +314 -310
- package/skills/app-analyzer-optimizer/SKILL.md +193 -189
- package/skills/apple-ecosystem-expert/SKILL.md +142 -0
- package/skills/async-queue-temporal-expert/SKILL.md +54 -0
- package/skills/authentication-identity-expert/SKILL.md +251 -20
- package/skills/auto-doc-updater/SKILL.md +214 -204
- package/skills/autonomous-chaos-monkey/SKILL.md +63 -0
- package/skills/autonomous-red-teamer/SKILL.md +59 -0
- package/skills/autonomous-swarm-director/SKILL.md +69 -0
- package/skills/autonomous-tdd-debugger/SKILL.md +65 -0
- package/skills/bootstrap-to-modern/SKILL.md +90 -86
- package/skills/brainstorming/SKILL.md +373 -353
- package/skills/browser-automation-expert/SKILL.md +46 -0
- package/skills/ci-cd-devops-architect/SKILL.md +72 -45
- package/skills/cloud-hosting-expert/SKILL.md +244 -244
- package/skills/coderabbit/SKILL.md +192 -192
- package/skills/cron-scheduler-expert/SKILL.md +298 -0
- package/skills/data-telemetry-expert/SKILL.md +213 -213
- package/skills/database-orm-expert/SKILL.md +294 -294
- package/skills/dependency-upgrade-migrator/SKILL.md +295 -0
- package/skills/design-system-architect/SKILL.md +27 -10
- package/skills/doku-mcp-server/SKILL.md +251 -0
- package/skills/doku-payment-gateway/SKILL.md +227 -0
- package/skills/e2e-testing-expert/SKILL.md +315 -315
- package/skills/edge-serverless-db-expert/SKILL.md +43 -0
- package/skills/email-notification-expert/SKILL.md +362 -0
- package/skills/error-resilience-expert/SKILL.md +480 -0
- package/skills/event-driven-architect/SKILL.md +81 -81
- package/skills/feature-flag-analytics-expert/SKILL.md +46 -0
- package/skills/file-upload-media-expert/SKILL.md +431 -0
- package/skills/form-validation-expert/SKILL.md +401 -0
- package/skills/fullstack-expert/SKILL.md +202 -202
- package/skills/fullstack-expert/references/api_design_guide.md +466 -466
- package/skills/fullstack-expert/references/multi_language_backend.md +528 -528
- package/skills/fullstack-expert/scripts/api_contract_validator.py +253 -253
- package/skills/fullstack-expert/scripts/architecture_analyzer.py +326 -326
- package/skills/gemini-agent-booster/SKILL.md +135 -135
- package/skills/global-a11y-i18n-expert/SKILL.md +81 -81
- package/skills/glsl-shader-expert/SKILL.md +101 -0
- package/skills/go-programming-expert/SKILL.md +295 -295
- package/skills/graphql-apollo-expert/SKILL.md +108 -0
- package/skills/hig/SKILL.md +188 -188
- package/skills/hyper-context-synthesizer/SKILL.md +55 -0
- package/skills/js-backend-expert/SKILL.md +34 -9
- package/skills/legacy-code-translator/SKILL.md +65 -0
- package/skills/llm-cost-arbitrage-router/SKILL.md +59 -0
- package/skills/logging-error-tracking-expert/SKILL.md +338 -0
- package/skills/mcp-client-orchestrator/SKILL.md +70 -0
- package/skills/mcp-server-architect/SKILL.md +194 -194
- package/skills/micro-frontend-architect/SKILL.md +106 -0
- package/skills/mobile-expo-expert/SKILL.md +186 -186
- package/skills/mobile-push-notification-expert/SKILL.md +51 -0
- package/skills/monday-design-aesthetic/SKILL.md +67 -67
- package/skills/monorepo-architect/SKILL.md +227 -227
- package/skills/mpa-orchestrator/SKILL.md +101 -101
- package/skills/multi-agent-orchestration/SKILL.md +234 -234
- package/skills/multiple-entry-points/SKILL.md +55 -55
- package/skills/mvc-expert/SKILL.md +231 -231
- package/skills/payment-gateway-expert/SKILL.md +45 -45
- package/skills/performance-web-vitals/SKILL.md +332 -332
- package/skills/post-quantum-crypto-migrator/SKILL.md +57 -0
- package/skills/prd-architect/SKILL.md +201 -191
- package/skills/proactive-background-watcher/SKILL.md +62 -0
- package/skills/production-ready-hardener/PRODUCTION_READINESS_REPORT.md +67 -0
- package/skills/production-ready-hardener/SKILL.md +173 -186
- package/skills/production-ready-hardener/references/production_checklist.md +161 -161
- package/skills/production-ready-hardener/scripts/production_readiness_scanner.py +881 -875
- package/skills/project-context-mapper/SKILL.md +79 -0
- package/skills/python-programming-expert/SKILL.md +263 -132
- package/skills/rate-limit-abuse-prevention/SKILL.md +371 -0
- package/skills/realtime-collaboration-expert/SKILL.md +45 -45
- package/skills/rust-programming-expert/SKILL.md +235 -235
- package/skills/saas-billing/SKILL.md +377 -377
- package/skills/saas-multi-tenant/SKILL.md +251 -237
- package/skills/saas-mvp-launcher/SKILL.md +10 -0
- package/skills/saas-transformer/SKILL.md +187 -144
- package/skills/saas-transformer/references/billing_integration_guide.md +401 -401
- package/skills/saas-transformer/references/feature_gating_patterns.md +137 -137
- package/skills/saas-transformer/references/saas_transformation_checklist.md +121 -121
- package/skills/saas-transformer/scripts/saas_transformation_scanner.py +39 -29
- package/skills/scalability-clean-code/SKILL.md +229 -229
- package/skills/self-evolving-memory-graph/SKILL.md +75 -0
- package/skills/self-healing-cloud-orchestrator/SKILL.md +57 -0
- package/skills/senior-frontend/SKILL.md +161 -161
- package/skills/senior-fullstack/SKILL.md +167 -167
- package/skills/seo/SKILL.md +235 -225
- package/skills/seo-geo/SKILL.md +188 -188
- package/skills/session-context-loader/SKILL.md +77 -0
- package/skills/session-handoff-resume/SKILL.md +158 -158
- package/skills/skill_baru/SKILL.md +172 -147
- package/skills/spa-orchestrator/SKILL.md +288 -288
- package/skills/state-management-expert/SKILL.md +272 -272
- package/skills/supabase-security-expert/SKILL.md +243 -243
- package/skills/tailwind-expert/SKILL.md +188 -188
- package/skills/tanstack-query-expert/SKILL.md +199 -199
- package/skills/token-saver/SKILL.md +119 -111
- package/skills/typescript-expert/SKILL.md +324 -279
- package/skills/ui-components-expert/SKILL.md +263 -46
- package/skills/ui-ux-pro-max/SKILL.md +202 -201
- package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
- package/skills/ui_ux_expert/SKILL.md +17 -6
- package/skills/vector-db-rag-expert/SKILL.md +52 -0
- package/skills/vibe-code-gardener/SKILL.md +181 -173
- package/skills/visual-qa-vision-agent/SKILL.md +65 -0
- package/skills/vue-frontend-expert/SKILL.md +126 -0
- package/skills/web-3d-graphics-expert/SKILL.md +131 -0
- package/skills/web-game-engine-expert/SKILL.md +96 -0
- package/skills/web-scraper/SKILL.md +207 -205
- package/skills/website-design-cloner/SKILL.md +174 -0
- package/skills/webxr-ar-vr-expert/SKILL.md +117 -0
- package/skills/zero-to-prod-orchestrator/SKILL.md +206 -180
- package/skills/zero-trust-secret-vault/SKILL.md +40 -0
- package/vibes-swarm-demo.gif +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: form-validation-expert
|
|
3
|
+
description: "Expert guide for complex form handling with React Hook Form, server-side validation (useActionState + Zod), multi-step wizards, and accessible form patterns / Panduan ahli penanganan formulir kompleks dengan React Hook Form, validasi server-side, wizard multi-langkah, dan pola formulir aksesibel."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Form & Validation Expert (2026 Edition)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Description
|
|
17
|
+
Production-grade guide for building robust, accessible, and user-friendly forms. Covers **React Hook Form v7+** with Zod/Valibot resolvers, **server-side validation** with `useActionState` + Zod, **multi-step form wizards**, **dynamic forms** from JSON Schema, **autofill-friendly patterns**, **optimistic form submission** with `useOptimistic`, **Conform** (progressive enhancement), and **form accessibility** (ARIA, error announcements).
|
|
18
|
+
|
|
19
|
+
### Trigger Conditions
|
|
20
|
+
Activate this skill when:
|
|
21
|
+
- Building forms with client-side validation (React Hook Form, Zod, Valibot).
|
|
22
|
+
- Implementing server-side form validation with React 19 Server Actions.
|
|
23
|
+
- Creating multi-step form wizards with state persistence.
|
|
24
|
+
- Building dynamic forms generated from schema definitions.
|
|
25
|
+
- Making forms accessible (ARIA attributes, error announcements).
|
|
26
|
+
- Implementing file upload forms with drag-and-drop.
|
|
27
|
+
- Optimizing forms for autofill and mobile usability.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### Form Library Selection Guide
|
|
32
|
+
|
|
33
|
+
| Library | Best For | Key Strength |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| **React Hook Form + Zod** | Most React apps | Performance (uncontrolled), rich ecosystem |
|
|
36
|
+
| **Conform** | Progressive enhancement, RSC | Works without JS, native validation |
|
|
37
|
+
| **Formik** | Legacy projects | Mature, large community (declining) |
|
|
38
|
+
| **TanStack Form** | Complex, headless forms | Framework-agnostic, type-safe |
|
|
39
|
+
|
|
40
|
+
**Recommendation**: Use **React Hook Form + Zod** for most projects. Use **Conform** for Next.js Server Actions with progressive enhancement.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### 1. React Hook Form + Zod (Client-Side)
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// components/signup-form.tsx
|
|
48
|
+
'use client';
|
|
49
|
+
|
|
50
|
+
import { useForm } from 'react-hook-form';
|
|
51
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
52
|
+
import { z } from 'zod';
|
|
53
|
+
|
|
54
|
+
const signupSchema = z.object({
|
|
55
|
+
name: z.string().min(2, 'Name must be at least 2 characters'),
|
|
56
|
+
email: z.string().email('Please enter a valid email'),
|
|
57
|
+
password: z.string()
|
|
58
|
+
.min(8, 'Password must be at least 8 characters')
|
|
59
|
+
.regex(/[A-Z]/, 'Must contain an uppercase letter')
|
|
60
|
+
.regex(/[0-9]/, 'Must contain a number'),
|
|
61
|
+
confirmPassword: z.string(),
|
|
62
|
+
}).refine(data => data.password === data.confirmPassword, {
|
|
63
|
+
message: 'Passwords do not match',
|
|
64
|
+
path: ['confirmPassword'],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
type SignupFormData = z.infer<typeof signupSchema>;
|
|
68
|
+
|
|
69
|
+
export function SignupForm() {
|
|
70
|
+
const {
|
|
71
|
+
register,
|
|
72
|
+
handleSubmit,
|
|
73
|
+
formState: { errors, isSubmitting },
|
|
74
|
+
} = useForm<SignupFormData>({
|
|
75
|
+
resolver: zodResolver(signupSchema),
|
|
76
|
+
mode: 'onBlur', // Validate on blur for better UX
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const onSubmit = async (data: SignupFormData) => {
|
|
80
|
+
const res = await fetch('/api/auth/signup', {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
headers: { 'Content-Type': 'application/json' },
|
|
83
|
+
body: JSON.stringify(data),
|
|
84
|
+
});
|
|
85
|
+
if (!res.ok) throw new Error('Signup failed');
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<form onSubmit={handleSubmit(onSubmit)} noValidate>
|
|
90
|
+
<div>
|
|
91
|
+
<label htmlFor="name">Name</label>
|
|
92
|
+
<input
|
|
93
|
+
id="name"
|
|
94
|
+
{...register('name')}
|
|
95
|
+
aria-invalid={!!errors.name}
|
|
96
|
+
aria-describedby={errors.name ? 'name-error' : undefined}
|
|
97
|
+
autoComplete="name"
|
|
98
|
+
/>
|
|
99
|
+
{errors.name && <p id="name-error" role="alert">{errors.name.message}</p>}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<div>
|
|
103
|
+
<label htmlFor="email">Email</label>
|
|
104
|
+
<input
|
|
105
|
+
id="email"
|
|
106
|
+
type="email"
|
|
107
|
+
{...register('email')}
|
|
108
|
+
aria-invalid={!!errors.email}
|
|
109
|
+
aria-describedby={errors.email ? 'email-error' : undefined}
|
|
110
|
+
autoComplete="email"
|
|
111
|
+
/>
|
|
112
|
+
{errors.email && <p id="email-error" role="alert">{errors.email.message}</p>}
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div>
|
|
116
|
+
<label htmlFor="password">Password</label>
|
|
117
|
+
<input
|
|
118
|
+
id="password"
|
|
119
|
+
type="password"
|
|
120
|
+
{...register('password')}
|
|
121
|
+
aria-invalid={!!errors.password}
|
|
122
|
+
aria-describedby={errors.password ? 'password-error' : undefined}
|
|
123
|
+
autoComplete="new-password"
|
|
124
|
+
/>
|
|
125
|
+
{errors.password && <p id="password-error" role="alert">{errors.password.message}</p>}
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<div>
|
|
129
|
+
<label htmlFor="confirmPassword">Confirm Password</label>
|
|
130
|
+
<input
|
|
131
|
+
id="confirmPassword"
|
|
132
|
+
type="password"
|
|
133
|
+
{...register('confirmPassword')}
|
|
134
|
+
aria-invalid={!!errors.confirmPassword}
|
|
135
|
+
aria-describedby={errors.confirmPassword ? 'confirm-error' : undefined}
|
|
136
|
+
autoComplete="new-password"
|
|
137
|
+
/>
|
|
138
|
+
{errors.confirmPassword && <p id="confirm-error" role="alert">{errors.confirmPassword.message}</p>}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<button type="submit" disabled={isSubmitting}>
|
|
142
|
+
{isSubmitting ? 'Creating account...' : 'Sign Up'}
|
|
143
|
+
</button>
|
|
144
|
+
</form>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### 2. Server Actions + useActionState (React 19 / Next.js 15)
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// actions/signup.ts
|
|
155
|
+
'use server';
|
|
156
|
+
|
|
157
|
+
import { z } from 'zod';
|
|
158
|
+
|
|
159
|
+
const signupSchema = z.object({
|
|
160
|
+
name: z.string().min(2),
|
|
161
|
+
email: z.string().email(),
|
|
162
|
+
password: z.string().min(8),
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export type SignupState = {
|
|
166
|
+
errors?: Record<string, string[]>;
|
|
167
|
+
message?: string;
|
|
168
|
+
success?: boolean;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export async function signupAction(
|
|
172
|
+
prevState: SignupState,
|
|
173
|
+
formData: FormData,
|
|
174
|
+
): Promise<SignupState> {
|
|
175
|
+
const parsed = signupSchema.safeParse({
|
|
176
|
+
name: formData.get('name'),
|
|
177
|
+
email: formData.get('email'),
|
|
178
|
+
password: formData.get('password'),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
if (!parsed.success) {
|
|
182
|
+
return {
|
|
183
|
+
errors: parsed.error.flatten().fieldErrors as Record<string, string[]>,
|
|
184
|
+
message: 'Please fix the errors below.',
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Check if email already exists
|
|
189
|
+
const existing = await db.query.users.findFirst({
|
|
190
|
+
where: eq(users.email, parsed.data.email),
|
|
191
|
+
});
|
|
192
|
+
if (existing) {
|
|
193
|
+
return { errors: { email: ['This email is already registered'] } };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Create user
|
|
197
|
+
await createUser(parsed.data);
|
|
198
|
+
return { success: true, message: 'Account created!' };
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
// components/signup-form-server.tsx
|
|
204
|
+
'use client';
|
|
205
|
+
|
|
206
|
+
import { useActionState } from 'react';
|
|
207
|
+
import { signupAction, type SignupState } from '@/actions/signup';
|
|
208
|
+
|
|
209
|
+
export function SignupFormServer() {
|
|
210
|
+
const [state, formAction, isPending] = useActionState<SignupState, FormData>(
|
|
211
|
+
signupAction,
|
|
212
|
+
{},
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<form action={formAction}>
|
|
217
|
+
{state.message && (
|
|
218
|
+
<div role="alert" className={state.success ? 'success' : 'error'}>
|
|
219
|
+
{state.message}
|
|
220
|
+
</div>
|
|
221
|
+
)}
|
|
222
|
+
|
|
223
|
+
<div>
|
|
224
|
+
<label htmlFor="name">Name</label>
|
|
225
|
+
<input id="name" name="name" required autoComplete="name" />
|
|
226
|
+
{state.errors?.name && <p role="alert">{state.errors.name[0]}</p>}
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<div>
|
|
230
|
+
<label htmlFor="email">Email</label>
|
|
231
|
+
<input id="email" name="email" type="email" required autoComplete="email" />
|
|
232
|
+
{state.errors?.email && <p role="alert">{state.errors.email[0]}</p>}
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div>
|
|
236
|
+
<label htmlFor="password">Password</label>
|
|
237
|
+
<input id="password" name="password" type="password" required minLength={8} autoComplete="new-password" />
|
|
238
|
+
{state.errors?.password && <p role="alert">{state.errors.password[0]}</p>}
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<button type="submit" disabled={isPending}>
|
|
242
|
+
{isPending ? 'Creating...' : 'Sign Up'}
|
|
243
|
+
</button>
|
|
244
|
+
</form>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### 3. Multi-Step Form Wizard
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
// components/multi-step-form.tsx
|
|
255
|
+
'use client';
|
|
256
|
+
|
|
257
|
+
import { useState, useCallback } from 'react';
|
|
258
|
+
import { useForm, FormProvider, type UseFormReturn } from 'react-hook-form';
|
|
259
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
260
|
+
import { z } from 'zod';
|
|
261
|
+
|
|
262
|
+
// Step schemas
|
|
263
|
+
const step1Schema = z.object({
|
|
264
|
+
companyName: z.string().min(1, 'Required'),
|
|
265
|
+
industry: z.string().min(1, 'Required'),
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const step2Schema = z.object({
|
|
269
|
+
contactName: z.string().min(1, 'Required'),
|
|
270
|
+
contactEmail: z.string().email(),
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const step3Schema = z.object({
|
|
274
|
+
plan: z.enum(['starter', 'pro', 'enterprise']),
|
|
275
|
+
billingCycle: z.enum(['monthly', 'annual']),
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
const fullSchema = step1Schema.merge(step2Schema).merge(step3Schema);
|
|
279
|
+
type FormData = z.infer<typeof fullSchema>;
|
|
280
|
+
|
|
281
|
+
const STEP_SCHEMAS = [step1Schema, step2Schema, step3Schema] as const;
|
|
282
|
+
const STEP_TITLES = ['Company Info', 'Contact Details', 'Choose Plan'] as const;
|
|
283
|
+
|
|
284
|
+
export function MultiStepForm() {
|
|
285
|
+
const [currentStep, setCurrentStep] = useState(0);
|
|
286
|
+
const methods = useForm<FormData>({
|
|
287
|
+
resolver: zodResolver(fullSchema),
|
|
288
|
+
mode: 'onChange',
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const goNext = useCallback(async () => {
|
|
292
|
+
const schema = STEP_SCHEMAS[currentStep];
|
|
293
|
+
const fields = Object.keys(schema.shape) as (keyof FormData)[];
|
|
294
|
+
const isValid = await methods.trigger(fields);
|
|
295
|
+
if (isValid) setCurrentStep(s => Math.min(s + 1, STEP_SCHEMAS.length - 1));
|
|
296
|
+
}, [currentStep, methods]);
|
|
297
|
+
|
|
298
|
+
const goBack = useCallback(() => {
|
|
299
|
+
setCurrentStep(s => Math.max(s - 1, 0));
|
|
300
|
+
}, []);
|
|
301
|
+
|
|
302
|
+
const onSubmit = async (data: FormData) => {
|
|
303
|
+
await fetch('/api/onboarding', {
|
|
304
|
+
method: 'POST',
|
|
305
|
+
body: JSON.stringify(data),
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<FormProvider {...methods}>
|
|
311
|
+
{/* Progress indicator */}
|
|
312
|
+
<nav aria-label="Form progress">
|
|
313
|
+
<ol className="step-progress">
|
|
314
|
+
{STEP_TITLES.map((title, i) => (
|
|
315
|
+
<li key={i} className={i === currentStep ? 'active' : i < currentStep ? 'completed' : ''}>
|
|
316
|
+
{title}
|
|
317
|
+
</li>
|
|
318
|
+
))}
|
|
319
|
+
</ol>
|
|
320
|
+
</nav>
|
|
321
|
+
|
|
322
|
+
<form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
323
|
+
{currentStep === 0 && <Step1 />}
|
|
324
|
+
{currentStep === 1 && <Step2 />}
|
|
325
|
+
{currentStep === 2 && <Step3 />}
|
|
326
|
+
|
|
327
|
+
<div className="button-group">
|
|
328
|
+
{currentStep > 0 && <button type="button" onClick={goBack}>Back</button>}
|
|
329
|
+
{currentStep < STEP_SCHEMAS.length - 1
|
|
330
|
+
? <button type="button" onClick={goNext}>Next</button>
|
|
331
|
+
: <button type="submit">Submit</button>
|
|
332
|
+
}
|
|
333
|
+
</div>
|
|
334
|
+
</form>
|
|
335
|
+
</FormProvider>
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
### 4. Form Accessibility Checklist
|
|
343
|
+
|
|
344
|
+
| Requirement | Implementation |
|
|
345
|
+
|---|---|
|
|
346
|
+
| **Labels** | Every input has a visible `<label>` with `htmlFor` matching input `id` |
|
|
347
|
+
| **Error identification** | `aria-invalid="true"` on invalid fields |
|
|
348
|
+
| **Error description** | `aria-describedby` pointing to error message element |
|
|
349
|
+
| **Error announcement** | Error messages use `role="alert"` for screen readers |
|
|
350
|
+
| **Required fields** | Use `aria-required="true"` or native `required` attribute |
|
|
351
|
+
| **Autofill** | Correct `autoComplete` values (`name`, `email`, `new-password`) |
|
|
352
|
+
| **Focus management** | Focus moves to first error on submit failure |
|
|
353
|
+
| **Submit state** | Button shows loading state and is disabled during submission |
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
### Common Pitfalls to Avoid
|
|
358
|
+
|
|
359
|
+
| Anti-Pattern | Problem | Correct Approach |
|
|
360
|
+
|---|---|---|
|
|
361
|
+
| Validating only on submit | Late error discovery, poor UX | Validate `onBlur` or `onChange` |
|
|
362
|
+
| Client-side validation only | Can be bypassed | Always validate server-side too |
|
|
363
|
+
| No `autoComplete` attributes | Misses browser autofill | Add correct `autoComplete` values |
|
|
364
|
+
| Generic error messages | "Invalid field" doesn't help | Specific: "Must be at least 8 characters" |
|
|
365
|
+
| Resetting form on error | User loses all input | Preserve input, highlight errors |
|
|
366
|
+
| No loading state on submit | User clicks multiple times | Disable button + show spinner |
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
### Integration with Other Skills
|
|
371
|
+
|
|
372
|
+
- `senior-frontend` — React 19 form patterns, useActionState, useOptimistic
|
|
373
|
+
- `global-a11y-i18n-expert` — WCAG 2.2 form accessibility requirements
|
|
374
|
+
- `ui-components-expert` — Input control primitives, form field components
|
|
375
|
+
- `authentication-identity-expert` — Login/signup form patterns
|
|
376
|
+
- `error-resilience-expert` — Form submission error handling and retry
|
|
377
|
+
- `tailwind-expert` — Form styling with Tailwind CSS v4
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
<a name="bahasa-indonesia"></a>
|
|
382
|
+
## Bahasa Indonesia
|
|
383
|
+
|
|
384
|
+
### Deskripsi
|
|
385
|
+
Panduan tingkat produksi untuk membangun formulir yang kuat, aksesibel, dan ramah pengguna. Mencakup **React Hook Form v7+** dengan Zod/Valibot resolver, **validasi server-side** dengan `useActionState` + Zod, **wizard formulir multi-langkah**, **formulir dinamis** dari JSON Schema, **pola autofill-friendly**, **optimistic form submission**, **Conform** (progressive enhancement), dan **aksesibilitas formulir** (ARIA, pengumuman error).
|
|
386
|
+
|
|
387
|
+
### Kondisi Pemicu
|
|
388
|
+
Aktifkan skill ini ketika:
|
|
389
|
+
- Membangun formulir dengan validasi client-side (React Hook Form, Zod, Valibot).
|
|
390
|
+
- Mengimplementasikan validasi formulir server-side dengan React 19 Server Actions.
|
|
391
|
+
- Membuat wizard formulir multi-langkah dengan persistensi state.
|
|
392
|
+
- Membangun formulir dinamis dari definisi skema.
|
|
393
|
+
- Membuat formulir yang aksesibel (atribut ARIA, pengumuman error).
|
|
394
|
+
|
|
395
|
+
### Integrasi dengan Skill Lain
|
|
396
|
+
|
|
397
|
+
- `senior-frontend` — Pola formulir React 19, useActionState, useOptimistic
|
|
398
|
+
- `global-a11y-i18n-expert` — Persyaratan aksesibilitas formulir WCAG 2.2
|
|
399
|
+
- `ui-components-expert` — Primitif kontrol input, komponen field formulir
|
|
400
|
+
- `authentication-identity-expert` — Pola formulir login/signup
|
|
401
|
+
- `error-resilience-expert` — Penanganan error submission formulir dan retry
|