@overgaming/valiform 0.2.1 → 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.
@@ -36,7 +36,6 @@ declare var __VLS_1: {
36
36
  isDirty: boolean;
37
37
  error: string;
38
38
  errors: string[];
39
- setValue: (value: unknown) => void;
40
39
  validate: () => boolean;
41
40
  reset: () => void;
42
41
  };
@@ -32,7 +32,6 @@ declare var __VLS_8: {
32
32
  isDirty: boolean;
33
33
  error: string;
34
34
  errors: string[];
35
- setValue: (value: unknown) => void;
36
35
  validate: () => boolean;
37
36
  reset: () => void;
38
37
  };
@@ -2,4 +2,40 @@ import type { InjectionKey } from 'vue';
2
2
  import type { FieldContext } from '../types';
3
3
  export declare const fieldContextKey: InjectionKey<FieldContext>;
4
4
  export declare const useFieldContextProvider: (data: FieldContext) => void;
5
- export declare const useFieldContext: (defaultData?: FieldContext | null) => FieldContext | null;
5
+ /**
6
+ * Retrieves the `FieldContext` provided by the nearest `Field` component ancestor.
7
+ *
8
+ * **Three call signatures:**
9
+ *
10
+ * - `useFieldContext()` — no args. Returns `FieldContext` directly (no `!` needed).
11
+ * Throws at runtime if called outside a `Field`. Use this for components that
12
+ * must always be nested inside a `Field` (e.g. `FieldLabel`, `FieldError`).
13
+ *
14
+ * - `useFieldContext(fallback: FieldContext)` — with a fallback object. Returns
15
+ * `FieldContext` directly (no `!` needed). Use this for components that can work
16
+ * both inside and outside a `Field` (e.g. standalone inputs with `v-model`).
17
+ *
18
+ * - `useFieldContext(null)` — explicit null. Returns `FieldContext | null`.
19
+ * Use when you want to handle the absence of context manually.
20
+ *
21
+ * @example
22
+ * // Always inside a Field — throws at runtime if misused:
23
+ * const { labelProps } = useFieldContext();
24
+ *
25
+ * @example
26
+ * // Standalone-capable input — works inside or outside a Field:
27
+ * const model = defineModel<string>({ default: '' });
28
+ * const { inputValue, inputProps } = useFieldContext({ inputValue: model });
29
+ *
30
+ * @example
31
+ * // Manual null-handling:
32
+ * const ctx = useFieldContext(null);
33
+ * if (ctx) { ... }
34
+ *
35
+ * @example
36
+ * // ❌ Wrong — `{}` does not satisfy FieldContext and will cause a type error:
37
+ * const { labelProps } = useFieldContext({});
38
+ */
39
+ export declare function useFieldContext(): FieldContext;
40
+ export declare function useFieldContext(defaultData: null): FieldContext | null;
41
+ export declare function useFieldContext(defaultData: FieldContext): FieldContext;
@@ -33,7 +33,7 @@ export type InputProps = {
33
33
  onBlur: () => void;
34
34
  };
35
35
  export interface FieldContext {
36
- inputValue: WritableComputedRef<unknown>;
36
+ inputValue: WritableComputedRef<unknown> | Ref<unknown>;
37
37
  inputProps: ComputedRef<InputProps>;
38
38
  labelProps: {
39
39
  for: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overgaming/valiform",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Vue 3 form validation library",
5
5
  "keywords": [
6
6
  "form",