@teamnovu/kit-vue-forms 0.2.17 → 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.3.0] - 2026-05-19
9
+
10
+ ### Added
11
+
12
+ - `setInitialData` now accepts an options argument:
13
+ - `{ replace: true }` replaces the subtree wholesale instead of deep-merging with the external `initialData`.
14
+ - `{ scope: 'subtree' }` anchors the new baseline only for the targeted path and its descendants, so ancestors keep reading the external `initialData` and stay dirty when the override changes the tree shape (e.g. a new array item). `scope: 'tree'` (default) preserves the previous global-baseline behavior.
15
+ - `useFieldArray` now exposes `pushPristine(item)` — like `push`, but anchors the new index's subtree as its own baseline so the new item's subfields start non-dirty while the array field itself stays dirty.
16
+
17
+ ### Changed
18
+
19
+ - Initial-data resolution moved from a per-field local baseline into a form-level override layer (`useInitialDataOverride`). Overrides set via `setInitialData` on a parent path now propagate down to subfields, deep-merging with the external `initialData` by default.
20
+ - `form.reset()` rebuilds `data` from the merged tree (external `initialData` + active overrides), so prior `setInitialData` calls survive a reset and act as the new programmatic baseline.
21
+ - Reassigning the external `initialData` ref passed to `useForm` clears all active overrides.
22
+ - Calling `setInitialData` on a path drops any existing override on that path or below before applying the new one.
23
+
24
+ ## [0.2.18] - 2025-03-03
25
+
26
+ ### Fixed
27
+
28
+ - Correctly pass `validationState` to subForm creation instead of `formOptions`
29
+ - Fix build error through type on `FormFieldWrapper`
30
+
31
+ ## [0.2.17] - 2025-01-22
32
+
33
+ ### Fixed
34
+
35
+ - `keepValuesOnUnmount` was `false` instead of `true` by default
36
+
37
+ ## [0.1.27] - 2025-01-22
38
+
39
+ ### Fixed
40
+
41
+ - `keepValuesOnUnmount` was `false` instead of `true` by default
@@ -19,7 +19,10 @@ declare const _default: <TData extends object, TPath extends Paths<TData>, TData
19
19
  touched: boolean;
20
20
  dirty: boolean;
21
21
  setData: (newData: PickProps<TData, TPath>) => void;
22
- setInitialData: (newData: PickProps<TData, TPath>) => void;
22
+ setInitialData: (newData: PickProps<TData, TPath>, options?: {
23
+ replace?: boolean;
24
+ scope?: "tree" | "subtree";
25
+ }) => void;
23
26
  onBlur: () => void;
24
27
  onFocus: () => void;
25
28
  reset: () => void;
@@ -12,9 +12,7 @@ declare const _default: <TData extends FormDataDefault, TPath extends Paths<TDat
12
12
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & FormFieldWrapperProps<TData, TPath, TComponent, TDataOut> & Partial<{}>> & PublicProps;
13
13
  expose(exposed: ShallowUnwrapRef<{}>): void;
14
14
  attrs: any;
15
- slots: Partial<Record<number, (_: any) => any>> & {
16
- default?(_: {}): any;
17
- };
15
+ slots: Readonly<Record<string, (props: any) => any>> & Record<string, (props: any) => any>;
18
16
  emit: {};
19
17
  }>) => VNode & {
20
18
  __ctx?: Awaited<typeof __VLS_setup>;
@@ -3,6 +3,7 @@ import { MaybeRef, ComputedRef } from 'vue';
3
3
  import { FieldsTuple, FormDataDefault, FormField } from '../types/form';
4
4
  import { Paths, PickProps } from '../types/util';
5
5
  import { UseFieldOptions } from './useField';
6
+ import { InitialDataOverride } from './useInitialDataOverride';
6
7
  import { ValidationState } from './useValidation';
7
8
  export type ResolvedFormField<T, K extends Paths<T>> = FormField<PickProps<T, K>, K>;
8
9
  export type DefineFieldOptions<F, K extends string> = Pick<UseFieldOptions<F, K>, 'path'> & {
@@ -21,7 +22,7 @@ interface FieldRegistryOptions {
21
22
  onChange?: <T>(path: string, value: T) => Awaitable<void>;
22
23
  onRegistered?: <T>(path: string, value: T) => Awaitable<void>;
23
24
  }
24
- export declare function useFieldRegistry<T extends FormDataDefault, TOut = T>(formState: FormState<T>, validationState: ValidationState<T, TOut>, fieldRegistryOptions?: FieldRegistryOptions): {
25
+ export declare function useFieldRegistry<T extends FormDataDefault, TOut = T>(formState: FormState<T>, validationState: ValidationState<T, TOut>, initialDataOverride: InitialDataOverride<T>, fieldRegistryOptions?: FieldRegistryOptions): {
25
26
  fields: ComputedRef<FieldsTuple<T>>;
26
27
  getField: <P extends Paths<T>>(path: P) => ResolvedFormField<T, P>;
27
28
  registerField: <K extends Paths<T>>(field: ResolvedFormField<T, K>) => void;
@@ -0,0 +1,13 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { FormDataDefault } from '../types/form';
3
+ export type InitialDataOverrideScope = 'tree' | 'subtree';
4
+ export interface InitialDataOverrideSetOptions {
5
+ replace?: boolean;
6
+ scope?: InitialDataOverrideScope;
7
+ }
8
+ export interface InitialDataOverride<T extends FormDataDefault> {
9
+ effectiveInitialData: ComputedRef<T>;
10
+ resolveAt: (path: string) => unknown;
11
+ set: (path: string, value: unknown, options?: InitialDataOverrideSetOptions) => void;
12
+ }
13
+ export declare function useInitialDataOverride<T extends FormDataDefault>(initialData: Ref<T> | ComputedRef<T>): InitialDataOverride<T>;
@@ -1,6 +1,6 @@
1
1
  import { Form, FormDataDefault } from '../types/form';
2
2
  import { EntityPaths, PickEntity } from '../types/util';
3
- import { UseFormOptions } from './useForm';
3
+ import { ValidationState } from './useValidation';
4
4
  export interface SubformOptions<_T extends FormDataDefault> {
5
5
  }
6
- export declare function createSubformInterface<T extends FormDataDefault, K extends EntityPaths<T>, TOut = T>(mainForm: Form<T, TOut>, path: K, formOptions?: UseFormOptions<T, TOut>, _options?: SubformOptions<PickEntity<T, K>>): Form<PickEntity<T, K>, PickEntity<TOut, K>>;
6
+ export declare function createSubformInterface<T extends FormDataDefault, K extends EntityPaths<T>, TOut = T>(mainForm: Form<T, TOut>, path: K, validationState: ValidationState<T, TOut>, _options?: SubformOptions<PickEntity<T, K>>): Form<PickEntity<T, K>, PickEntity<TOut, K>>;