refactor(forms): extract reusable form utilities and components
- Add getFirstValidationError utility for nested FieldErrors extraction - Add mergeWithDefaults utilities (deepMergeWithDefaults, type guards) - Add useValidationErrorHandler hook for toast + tab navigation - Add FormSelect component with Controller integration - Add FormTextarea component with register integration - Refactor AgentTypeForm to use new utilities - Remove verbose debug logging (now handled by hook) - Add comprehensive tests (53 new tests, 100 total) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
30
frontend/src/lib/forms/index.ts
Normal file
30
frontend/src/lib/forms/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Form Utilities and Hooks
|
||||
*
|
||||
* Centralized exports for form-related utilities.
|
||||
*
|
||||
* @module lib/forms
|
||||
*/
|
||||
|
||||
// Utils
|
||||
export { getFirstValidationError, getAllValidationErrors } from './utils/getFirstValidationError';
|
||||
export type { ValidationError } from './utils/getFirstValidationError';
|
||||
|
||||
export {
|
||||
safeValue,
|
||||
isNumber,
|
||||
isString,
|
||||
isBoolean,
|
||||
isArray,
|
||||
isObject,
|
||||
deepMergeWithDefaults,
|
||||
createFormInitializer,
|
||||
} from './utils/mergeWithDefaults';
|
||||
|
||||
// Hooks
|
||||
export { useValidationErrorHandler } from './hooks/useValidationErrorHandler';
|
||||
export type {
|
||||
TabFieldMapping,
|
||||
UseValidationErrorHandlerOptions,
|
||||
UseValidationErrorHandlerReturn,
|
||||
} from './hooks/useValidationErrorHandler';
|
||||
Reference in New Issue
Block a user