This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Nuxt module that integrates @formwerk/core with @nuxt/ui to provide enhanced form components with validation and state management. The module wraps Nuxt UI's form components with formwerk's composables to enable advanced form handling features like field-level validation, blur/touch/dirty tracking, and event-driven validation strategies.
Key Dependencies:
@formwerk/core: Form management library (peer dependency)@nuxt/ui: Nuxt UI library (peer dependency)@vueuse/core: Vue composition utilities for event bus
The module follows the standard Nuxt module pattern with components auto-registered with a configurable prefix (default: UE).
src/
├── module.ts # Module entry point, registers components
└── runtime/
└── components/
├── Field.vue # Wraps UFormField with formwerk validation
├── Form.vue # Provides form context and event coordination
├── Group.vue # Groups related form fields
└── Repeater.vue # Repeatable field groups (dynamic arrays)
Form Component (src/runtime/components/Form.vue):
- Creates formwerk form context via
useFormContext() - Manages two event buses:
formwerkBus: Custom bus for formwerk-specific events (touched, blur, dirty)NuxtUiFormBus: Nuxt UI's native form event bus
- Tracks field state in reactive Sets (dirtyFields, touchedFields, blurredFields)
- Provides form options via injection keys (validateOn strategy, disabled state)
Field Component (src/runtime/components/Field.vue):
- Uses
useCustomControlfrom formwerk for field registration and validation - Injects form context (formBus, formwerkBus, formwerkOptions)
- Bridges between Nuxt UI form events and formwerk state management
- Supports configurable validation triggers (blur, etc.)
- Exposes
setValueandfieldValueto slot content
Group Component (src/runtime/components/Group.vue):
- Simple wrapper using
useFormGroupfrom formwerk - Groups related fields for nested validation
Repeater Component (src/runtime/components/Repeater.vue):
- Uses
useFormRepeaterfrom formwerk for dynamic array fields - Exposes
Iterationcomponent for proper formwerk state tracking - Provides
repeatermethods:add,remove,move,swap,insert - Supports
uiprop for styling:root,leading,wrapper,item,trailing - Slots:
leading,wrapper(for custom containers like drag-drop),default,trailing - The
wrapperslot receives theIterationcomponent to enable custom rendering while preserving formwerk's internal state
The module uses typed injection keys for form context sharing:
formwerkOptionsInjectionKey: Form configuration (validateOn, disabled)formwerkBusInjectionKey: Custom event bus for form eventsformBusInjectionKey: Nuxt UI form event bus (from @nuxt/ui)formOptionsInjectionKey: Nuxt UI form options (from @nuxt/ui)
# Install dependencies
pnpm install
# Prepare development (build stub + prepare playground)
pnpm dev:prepare
# Start development server with playground
pnpm dev
# Build playground
pnpm dev:build
# Run linter (uses oxlint with type-aware checking)
pnpm lint
# Fix linting issues
pnpm lint:fix
# Format code (uses oxfmt)
pnpm format
# Check formatting
pnpm format:check
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Type check both module and playground
pnpm test:types
# Build module for production
pnpm prepack
# Release (lint, test, build, changelog, publish, push tags)
pnpm releaseTests use Vitest with @nuxt/test-utils for E2E SSR testing. Test fixtures are located in test/fixtures/basic/.
The basic test verifies SSR rendering works correctly with the module installed.
Users configure the module in their nuxt.config.ts:
export default defineNuxtConfig({
modules: ["nuxt-ui-formwerk"],
uiElements: {
prefix: "UE", // Customizes component prefix (default: 'UE')
},
})The module checks for required peer dependencies (@nuxt/ui) at setup time and logs errors if missing.
- Linter: ESLint with @nuxt/eslint-config and Prettier
- Formatter: Prettier
- Type Checker: vue-tsc
- Test Framework: Vitest with @nuxt/test-utils
- Build Tool: @nuxt/module-builder
- Package Manager: pnpm 10.26.2
- Components are auto-imported, so users don't need explicit imports
- The module requires both
@nuxt/uiand@formwerk/coreas peer dependencies - Event coordination between Nuxt UI's form system and formwerk is critical - changes to event handling should preserve both systems' expectations
- The module also has
motion-v/nuxtand@nuxtjs/color-modeas module dependencies (auto-installed)