# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.0] - 2026-05-26

### Added

- New schema helpers exported from `./schema`: `extractDefaultValuesAsync`, field-type predicates (`isChoiceField`, `isTextField`, `isNumericField`, `isDateField`, `isContainerField`, `isArrayField`, `isDynamicField`, `isConditionalField`), schema composition (`mergeSchemas`, `extendSection`, `pickFields`, `omitFields`, `flattenSchema`), and `applyServerErrors`.
- New exported types: `SectionRendererProps`, `GridRendererProps`, `FieldWrapperProps`, `ValidationRuleObject`, `PatternRuleObject`.
- Conditional package exports add `module-sync` condition for better React Server Components / sync-import interop.

### Changed

- `main` / `module` fields removed from `package.json` in favor of pure conditional `exports`.

## [1.3.0] - 2026-02-27

### Added

- New form primitives and schema-driven helpers for broader form composition use cases.
- Additional coverage for the latest public API surface.

### Changed

- Updated package metadata and compatibility requirements for React Hook Form `^7.55.0`.
- Aligned publish artifacts and entrypoint packaging for the current release.

## [1.2.2] - 2026-02-26

### Fixed

- **`useFormKit` referential stability** — Return value now preserves the original `useForm` object identity across re-renders using `Object.assign` instead of object spread. Previously, spreading `{...form, generatorProps}` created a new object every render, which caused infinite loops when the form was used in `useEffect` dependency arrays (e.g., `form.reset()` in effects triggered re-renders → new object → effect fires again)
- **`generatorProps` memoized** — The `generatorProps` object returned by `useFormKit` is now wrapped in `useMemo`, preventing unnecessary re-renders of `<FormGenerator />` when unrelated props change

### Added

- **Referential stability test** — New test case verifying that `useFormKit` return value and its methods (`reset`, `setValue`, `handleSubmit`) maintain referential identity across re-renders

## [1.1.0] - 2026-02-24

### Added

- **`useFormKit` hook** — Convenience hook that combines schema default extraction with react-hook-form setup. Returns all `useForm` methods plus ready-to-spread `generatorProps` for minimal boilerplate form setup
- **`extractDefaultValues(schema)`** — Server-safe utility that walks a schema and extracts all `defaultValue` fields into a flat object, respecting `nameSpace` prefixes and group `itemFields`
- **`buildValidationRules(field)`** — Server-safe utility that generates react-hook-form validation rules from a field's `required`, `min`, `max`, `minLength`, `maxLength`, and `pattern` props with auto-generated error messages
- **`ref` prop on FormGenerator** — React 19 ref-as-prop support (no `forwardRef` needed). Pass a ref to get access to the root `<div>` element
- **`fieldState` runtime data** — `FieldComponentProps` now receives real `fieldState` with `invalid`, `isDirty`, `isTouched`, `isValidating`, and `error` from react-hook-form (previously always `undefined`)
- **Server entry exports** — `extractDefaultValues` and `buildValidationRules` added to `@classytic/formkit/server`
- New type exports: `UseFormKitOptions`, `UseFormKitReturn`

### Fixed

- **Nested path DSL conditions** — `evaluateRule` now correctly resolves both flat keys (`"address.city"` as literal key from `DynamicFieldWrapper`) and nested objects (`{ address: { city: "NYC" } }`)
- **`useFormState` scoped per-field** — Added `name` parameter to prevent unnecessary re-renders across unrelated fields
- Removed `process.env.NODE_ENV` guard from missing-control warning — now always warns

### Changed

- Requires React Hook Form `^7.54.0` (was `^7.53.2`)

## [1.0.3] - 2024-12-04

### Changed

- **Complete TypeScript Migration**: Rewrote entire codebase with strict TypeScript
- **Improved Type Definitions**: Added comprehensive type exports for better DX
- **Modern Build System**: Updated tsup configuration for better tree-shaking
- **Enhanced Types**: Added `FieldOption`, `FieldOptionGroup`, `DefineField` utility types
- **Better Error Messages**: Improved development warnings with actionable messages

### Added

- New type exports: `FieldOption`, `FieldOptionGroup`, `DefineField`, `SchemaFieldNames`, `InferSchemaValues`
- Subcomponent exports: `SectionRenderer`, `GridRenderer`, `FieldWrapper`
- Hook exports: `useFieldComponent`, `useLayoutComponent`
- Support for `gap` property in sections
- Support for `collapsible` and `defaultCollapsed` section properties
- `FormElement` type for consistent JSX return types
- `ClassValue` re-export from utils

### Fixed

- Package exports configuration for proper ESM/CJS interop
- TypeScript strict mode compatibility
- Proper peer dependency declarations

## [1.0.2] - 2024-12-03

### Added

- Initial public release
- FormGenerator component
- FormSystemProvider context
- Schema-driven form generation
- Variant support for components
- Conditional field rendering

## [1.0.1] - 2024-12-02

### Fixed

- Package configuration fixes

## [1.0.0] - 2024-12-01

### Added

- Initial release
