4.4 KiB
4.4 KiB
Tasks: enterprise-react-admin-forms
Change ID: enterprise-react-admin-forms
Package: @suaveplan/react-admin-forms
Target path: react/forms/react-admin-forms
Prerequisite packages on Verdaccio: @suaveplan/error, @suaveplan/api-schemas, @suaveplan/react-forms, @suaveplan/react-translate, @suaveplan/react-ui
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Scaffold
- Create directory tree per proposal layout.
- Write
package.jsonat0.1.0with"sideEffects": false, exports map. - Dependencies:
@suaveplan/error workspace:^,@suaveplan/api-schemas workspace:^,@suaveplan/react-forms workspace:^,@suaveplan/react-translate workspace:^,@suaveplan/react-ui workspace:^,@hookform/resolvers catalog:forms,lucide-react catalog:ui,react-hook-form catalog:forms,zod catalog:forms,@opentelemetry/api catalog:observability,tslib catalog:build. - Write
tsconfig.json,vitest.config.ts, scripts.
2. Error codes
- Define
AdminFormErrorextendingSuaveplanError; codes:ADMIN_FORM_SUBMIT_FAILED,ADMIN_FORM_VALIDATION_FAILED,ADMIN_FORM_STORAGE_FAILED,ADMIN_FORM_CONTEXT_MISSING.
3. Core
AdminFormsProvider
- Context providing shared
formStorage,apiClient,translatorto all admin forms. useAdminFormsContext()throwsAdminFormError(ADMIN_FORM_CONTEXT_MISSING)outside provider.- Write test + md.
formStorage
createFormStorage(adapter: 'localStorage' | 'sessionStorage' | 'indexeddb')—save(key, values),load(key),clear(key).- Throws
AdminFormError(ADMIN_FORM_STORAGE_FAILED)on I/O error. - Write test (in-memory adapter for tests) + md.
4. Accessible* shared components (13)
For each (AccessibleInput, AccessibleButton, AccessibleFieldset, AccessibleTab, AccessibleCheckbox, AccessibleSelect, AccessibleProgress, AccessibleStatusMessage, AccessibleErrorMessage, AccessibleLabel, AccessibleRequiredIndicator, AccessibleForm, AccessibleBadge):
- Implement with proper ARIA attributes;
useTranslationfor any copy. - Write test (renders, aria attributes present) + md.
5. Domain forms (30 forms)
For each form:
- Implement form component + Zod schema. Uses real
@suaveplan/react-translate(no mocks). - Write
.test.tsx— render, valid submit, invalid submit shows errors.{ timeout: 5000 }. - Write
.stories.tsx— default, validation-errors, loading, playground. - Write
.md.
Priority order (auth first, then content, then others):
- Auth (8): Login, Register, ResetPassword, ChangePassword, Session, UpdateProfile, UserManagement, AccountLinking.
- Content (3): EventLogging, MessageModeration, PostModeration.
- Finance (1): BankAccount.
- Notifications (3): DeviceToken, NotificationConfig, PushNotification.
- Payment (2): PaymentIntent, Refund.
- Security (2): RoleManagement, SiteSecurity.
- Events (2): Event, Rsvp.
- Subscription (1), Tenant (1), Users (3: Friend, Group, UserSettings).
- Vault (2): Vault, VaultItem.
- Store (1): Product.
6. Integration and E2E
tests/integration.test.tsx—LoginFormwith real@suaveplan/react-translateprovider; fill + submit →onSubmitcalled with correct data; fill invalid → errors shown.e2e/auth-forms.spec.ts— Playwright: renderLoginForm, fill email + password, submit →onSubmitcalled. RenderRegisterForm, fill all fields, submit. RenderResetPasswordForm, enter email, submit.
7. Verify and publish
bunx turbo lint typecheck test --filter=@suaveplan/react-admin-forms— green.bunx turbo test:coverage --filter=@suaveplan/react-admin-forms— 100%.bun scripts/publish.ts --package @suaveplan/react-admin-forms.- Archive change folder.