@ilokesto/form 2.0.2 → 2.0.3
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/README.ko.md +2 -0
- package/README.md +2 -0
- package/dist/{FormInput-DuT7QFe-.d.ts → FormInput-BpDWf4hF.d.ts} +3 -0
- package/dist/chunk-M7Y4OJPP.js +2166 -0
- package/dist/chunk-M7Y4OJPP.js.map +1 -0
- package/dist/{chunk-JK644RR7.js → chunk-WO5TIXCR.js} +3 -3
- package/dist/chunk-WO5TIXCR.js.map +1 -0
- package/dist/index.d.ts +194 -23
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +104 -2
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/solid/index.d.ts +103 -2
- package/dist/solid/index.js +2 -2
- package/dist/solid/index.js.map +1 -1
- package/dist/svelte/index.d.ts +75 -2
- package/dist/svelte/index.js +2 -2
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/index.d.ts +103 -2
- package/dist/vue/index.js +2 -2
- package/dist/vue/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/chunk-4F4SAGQ5.js +0 -1465
- package/dist/chunk-4F4SAGQ5.js.map +0 -1
- package/dist/chunk-JK644RR7.js.map +0 -1
package/dist/vue/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vue/RegisterBinding.ts","../../src/vue/useFieldSchemaRegistration.ts","../../src/vue/useFormSnapshot.ts","../../src/vue/useField.ts","../../src/vue/useFormState.ts","../../src/vue/useRegister.ts","../../src/vue/useForm.ts"],"names":["getCurrentScope","onScopeDispose"],"mappings":";;;;;AAKO,SAAS,mBAAA,CACd,IAAA,EACA,OAAA,EACA,QAAA,EACA,OAAA,EACsC;AACtC,EAAA,MAAM,OAAA,GAAU,gBAAA,CAAiB,IAAA,EAAM,OAAA,EAAS,UAAU,OAAO,CAAA;AACjE,EAAA,MAAM,KAAA,GAAQ;AAA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import { createDomBinding, type FieldEventTarget, type RegisterOptions, fieldPathToDomName } from '../adapters/dom';\nimport type { VueRegisterElement, VueRegisterPropsForElement } from './types';\n\n/** Vue v-bind용 binding props를 생성한다. */\nexport function createRegisterProps<TValues, TElement extends VueRegisterElement>(\n form: Form<TValues>,\n options: RegisterOptions,\n getField: () => Readonly<FieldState>,\n domName: string,\n): VueRegisterPropsForElement<TElement> {\n const binding = createDomBinding(form, options, getField, domName);\n const props = {\n name: binding.name,\n type: binding.type,\n get value() {\n return binding.value;\n },\n get checked() {\n return binding.checked;\n },\n onInput: (event: Event) => {\n binding.input(event.currentTarget as FieldEventTarget);\n },\n onChange: (event: Event) => {\n binding.change(event.currentTarget as FieldEventTarget);\n },\n onBlur: () => {\n binding.blur();\n },\n onFocus: () => {\n binding.focus();\n },\n };\n\n return props as unknown as VueRegisterPropsForElement<TElement>;\n}\n\nexport { fieldPathToDomName };\n","import { getCurrentScope, onScopeDispose } from 'vue';\nimport type { Form } from '../core/index';\nimport type { RegisterOptions } from './types';\n\n/** field-local schema를 현재 effect scope lifecycle에 맞춰 등록한다. */\nexport function useFieldSchemaRegistrations<TValues>(form: Form<TValues>, options: readonly RegisterOptions[]): void {\n const cleanups = options.flatMap(option => {\n if (!option.schema) {\n return [];\n }\n\n return [form.registerFieldSchema(option.name, { schema: option.schema, schemaOptions: option.schemaOptions })];\n });\n\n if (cleanups.length === 0) {\n return;\n }\n\n if (getCurrentScope()) {\n onScopeDispose(() => {\n cleanups.forEach(cleanup => cleanup());\n });\n }\n}\n","import { getCurrentScope, onScopeDispose, shallowRef, type ShallowRef } from 'vue';\nimport type { Form, FormState } from '../core/index';\n\n/** core form snapshot을 Vue shallowRef로 연결한다. */\nexport function useFormSnapshot<TValues>(form: Form<TValues>): ShallowRef<Readonly<FormState<TValues>>> {\n const snapshot = shallowRef(form.getState()) as ShallowRef<Readonly<FormState<TValues>>>;\n const unsubscribe = form.subscribe(() => {\n snapshot.value = form.getState();\n });\n\n if (getCurrentScope()) {\n onScopeDispose(unsubscribe);\n }\n\n return snapshot;\n}\n","import type { Form } from '../core/index';\nimport { getFieldState } from '../adapters/dom';\nimport { createRegisterProps, fieldPathToDomName } from './RegisterBinding';\nimport type { RegisterOptions, VueFieldReturn, VueRegisterElement, VueRegisterPropsForElement } from './types';\nimport { useFieldSchemaRegistrations } from './useFieldSchemaRegistration';\nimport { useFormSnapshot } from './useFormSnapshot';\n\n/** 한 field의 binding, value, meta, setter를 함께 반환한다. */\nexport function useFieldWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement>(form: Form<TValues>, options: RegisterOptions): VueFieldReturn<VueRegisterPropsForElement<TElement>> {\n useFieldSchemaRegistrations(form, [options]);\n\n const snapshot = useFormSnapshot(form);\n const getField = () => getFieldState(form, snapshot.value, options.name);\n const props = createRegisterProps<TValues, TElement>(form, options, getField, fieldPathToDomName(options.name));\n\n return {\n props,\n get value() {\n return getField().value;\n },\n setValue(value: unknown) {\n form.setValue(options.name, value, { source: 'program' });\n },\n get errors() {\n return [...getField().errors];\n },\n get dirty() {\n return getField().dirty;\n },\n get touched() {\n return getField().touched;\n },\n };\n}\n","import type { Form } from '../core/index';\nimport { createFormStateSummary } from '../adapters/FormStateSummary';\nimport type { VueFormStateReturn } from './types';\nimport { useFormSnapshot } from './useFormSnapshot';\n\n/** form 전체 상태에서 Vue UI가 자주 쓰는 aggregate state를 반환한다. */\nexport function useFormStateWithForm<TValues>(form: Form<TValues>): VueFormStateReturn<TValues> {\n const snapshot = useFormSnapshot(form);\n const getSummary = () => createFormStateSummary(snapshot.value);\n\n return {\n get state() {\n return snapshot.value;\n },\n get errors() {\n return getSummary().errors;\n },\n get dirtyFields() {\n return getSummary().dirtyFields;\n },\n get touchedFields() {\n return getSummary().touchedFields;\n },\n get focusedField() {\n return getSummary().focusedField;\n },\n get isDirty() {\n return getSummary().isDirty;\n },\n get isValid() {\n return getSummary().isValid;\n },\n get isSubmitting() {\n return getSummary().isSubmitting;\n },\n get isSubmitted() {\n return getSummary().isSubmitted;\n },\n get isSubmitSuccessful() {\n return getSummary().isSubmitSuccessful;\n },\n get submitCount() {\n return getSummary().submitCount;\n },\n };\n}\n","import type { Form } from '../core/index';\nimport { getFieldState } from '../adapters/dom';\nimport { createRegisterProps, fieldPathToDomName } from './RegisterBinding';\nimport type { RegisterOptions, VueRegisterElement, VueRegisterPropsForElement, VueRegisterPropsList } from './types';\nimport { useFieldSchemaRegistrations } from './useFieldSchemaRegistration';\nimport { useFormSnapshot } from './useFormSnapshot';\n\nexport function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement>(form: Form<TValues>, options: RegisterOptions): VueRegisterPropsForElement<TElement>;\nexport function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(form: Form<TValues>, options: TOptions): VueRegisterPropsList<TElement, TOptions>;\nexport function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(form: Form<TValues>, ...options: TOptions): VueRegisterPropsList<TElement, TOptions>;\nexport function useRegisterWithForm<TValues>(form: Form<TValues>, first: RegisterOptions | readonly RegisterOptions[], ...rest: readonly RegisterOptions[]): VueRegisterPropsForElement<VueRegisterElement> | VueRegisterPropsForElement<VueRegisterElement>[];\n\n/** 단일 또는 여러 field의 Vue binding props를 만든다. */\nexport function useRegisterWithForm<TValues>(\n form: Form<TValues>,\n first: RegisterOptions | readonly RegisterOptions[],\n ...rest: readonly RegisterOptions[]\n): VueRegisterPropsForElement<VueRegisterElement> | VueRegisterPropsForElement<VueRegisterElement>[] {\n const shouldReturnList = Array.isArray(first) || rest.length > 0;\n const options = normalizeRegisterOptions(first, rest);\n\n useFieldSchemaRegistrations(form, options);\n\n const snapshot = useFormSnapshot(form);\n const bindings = options.map(option => createRegisterProps(\n form,\n option,\n () => getFieldState(form, snapshot.value, option.name),\n fieldPathToDomName(option.name),\n ));\n\n return shouldReturnList ? bindings : bindings[0];\n}\n\nfunction normalizeRegisterOptions(first: RegisterOptions | readonly RegisterOptions[], rest: readonly RegisterOptions[]): readonly RegisterOptions[] {\n if (Array.isArray(first)) {\n return first as readonly RegisterOptions[];\n }\n\n if (rest.length > 0) {\n return [first as RegisterOptions, ...rest];\n }\n\n return [first as RegisterOptions];\n}\n","import { getCurrentScope, toValue, watch } from 'vue';\nimport type { MaybeRefOrGetter } from 'vue';\n\nimport { createSubmitHandler } from '../adapters/dom';\nimport { createExternalValuesSynchronizer, createFormFromOptions, isFormInstance } from '../adapters/FormInput';\nimport type { Form, ResetOptions } from '../core/index';\nimport type { RegisterOptions, VueForm, VueFormOptions } from './types';\nimport { useFieldWithForm } from './useField';\nimport { useFormStateWithForm } from './useFormState';\nimport { useRegisterWithForm } from './useRegister';\n\n/** Vue composable surface를 core Form 인스턴스에 바인딩한다. */\nexport function useForm<TValues>(form: Form<TValues>): VueForm<TValues>;\nexport function useForm<TValues>(options: VueFormOptions<TValues>): VueForm<TValues>;\nexport function useForm<TValues>(input: Form<TValues> | VueFormOptions<TValues>): VueForm<TValues> {\n const isForm = isFormInstance(input);\n if (!isForm && input.values !== undefined && getCurrentScope() === undefined) {\n throw new TypeError('Reactive Vue form options require an active effect scope');\n }\n\n let form: Form<TValues>;\n let values: MaybeRefOrGetter<TValues | undefined> | undefined;\n let resetOptions: ResetOptions | undefined;\n\n if (isForm) {\n form = input;\n values = undefined;\n resetOptions = undefined;\n } else {\n const {\n values: reactiveValues,\n resetOptions: reactiveResetOptions,\n ...createOptions\n } = input;\n\n form = createFormFromOptions(createOptions);\n values = reactiveValues;\n resetOptions = reactiveResetOptions;\n }\n\n if (values !== undefined) {\n const synchronizeValues = createExternalValuesSynchronizer(form);\n\n synchronizeValues(toValue(values), resetOptions);\n\n watch(\n () => toValue(values),\n nextValues => {\n synchronizeValues(nextValues, resetOptions);\n },\n );\n }\n\n const useRegister = ((first: RegisterOptions | readonly RegisterOptions[], ...rest: readonly RegisterOptions[]) => useRegisterWithForm(form, first, ...rest)) as VueForm<TValues>['useRegister'];\n const useField = ((options: RegisterOptions) => useFieldWithForm(form, options)) as VueForm<TValues>['useField'];\n const useFormState = (): ReturnType<VueForm<TValues>['useFormState']> => useFormStateWithForm(form);\n const handleSubmit = ((onValid, onInvalid) => createSubmitHandler(form, onValid, onInvalid)) as VueForm<TValues>['handleSubmit'];\n\n return { form, useRegister, useField, useFormState, handleSubmit };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/vue/RegisterBinding.ts","../../src/vue/useFieldSchemaRegistration.ts","../../src/vue/useFormSnapshot.ts","../../src/vue/useField.ts","../../src/vue/useFormState.ts","../../src/vue/useRegister.ts","../../src/vue/useForm.ts"],"names":["getCurrentScope","onScopeDispose"],"mappings":";;;;;AA8CO,SAAS,mBAAA,CACd,IAAA,EACA,OAAA,EACA,QAAA,EACA,OAAA,EACsC;AACtC,EAAA,MAAM,OAAA,GAAU,gBAAA,CAAiB,IAAA,EAAM,OAAA,EAAS,UAAU,OAAO,CAAA;AACjE,EAAA,MAAM,KAAA,GAAQ;AAAA,IACZ,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,OAAA,CAAQ,KAAA;AAAA,IACjB,CAAA;AAAA,IACA,IAAI,OAAA,GAAU;AACZ,MAAA,OAAO,OAAA,CAAQ,OAAA;AAAA,IACjB,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,KAAA,KAAiB;AACzB,MAAA,OAAA,CAAQ,KAAA,CAAM,MAAM,aAAiC,CAAA;AAAA,IACvD,CAAA;AAAA,IACA,QAAA,EAAU,CAAC,KAAA,KAAiB;AAC1B,MAAA,OAAA,CAAQ,MAAA,CAAO,MAAM,aAAiC,CAAA;AAAA,IACxD,CAAA;AAAA,IACA,QAAQ,MAAM;AACZ,MAAA,OAAA,CAAQ,IAAA,EAAK;AAAA,IACf,CAAA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AY,CAAA;AAE/C,IAAA,KAAA;AAAA,MACE,MAAM,QAAQ,MAAM,CAAA;AAAA,MACpB,CAAA,UAAA,KAAc;AACZ,QAAA,iBAAA,CAAkB,YAAY,YAAY,CAAA;AAAA,MAC5C;AAAA,KACF;AAAA,EACF;AAEA,EAAA,MAAM,WAAA,IAAe,CAAC,KAAA,EAAA,GAAwD,IAAA,KAAqC,oBAAoB,IAAA,EAAM,KAAA,EAAO,GAAG,IAAI,CAAA,CAAA;AAC3J,EAAA,MAAM,QAAA,IAAY,CAAC,OAAA,KAA6B,gBAAA,CAAiB,MAAM,OAAO,CAAA,CAAA;AAC9E,EAAA,MAAM,YAAA,GAAe,MAAoD,oBAAA,CAAqB,IAAI,CAAA;AAClG,EAAA,MAAM,gBAAgB,CAAC,OAAA,EAAS,cAAc,mBAAA,CAAoB,IAAA,EAAM,SAAS,SAAS,CAAA,CAAA;AAE1F,EAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,QAAA,EAAU,cAAc,YAAA,EAAa;AACnE","file":"index.js","sourcesContent":["import type { FieldState, Form } from '../core/index';\nimport { createDomBinding, type FieldEventTarget, type RegisterOptions, fieldPathToDomName } from '../adapters/dom';\nimport type { VueRegisterElement, VueRegisterPropsForElement } from './types';\n\n/**\n * @description Create framework-specific DOM bindings that forward value, checked, change, blur, and focus behavior to the core form.\n * @param {Form<TValues>} form - Core form instance shared by all bound helpers.\n * @param {() => Readonly<FormState<TValues>>} form.getState - Read the current immutable form snapshot.\n * @param {(listener: () => void) => () => void} form.subscribe - Subscribe to state changes and return an unsubscribe callback.\n * @param {(path: FieldPathInput, options: FieldSchemaOptions) => () => void} form.registerFieldSchema - Register an overriding field-local validator and return its guarded cleanup.\n * @param {(path: FieldPathInput) => Readonly<FieldState>} form.getFieldState - Read field metadata, using a default snapshot for an unknown field.\n * @param {(path: FieldPathInput) => unknown} form.getValue - Read the current value of one field.\n * @param {() => TValues} form.getValues - Reconstruct nested values from fields and array containers.\n * @param {(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void} form.setValue - Write a field with configurable user or program origin and optional immediate validation.\n * @param {(path: FieldPathInput) => Promise<boolean>} form.blur - Clear focus, mark touched, and run configured blur validation.\n * @param {(path: FieldPathInput) => void} form.focus - Record focus for the selected field.\n * @param {(path: FieldPathInput, errors: readonly FormError[]) => void} form.setErrors - Replace all errors for the selected field.\n * @param {(...paths: FieldPathInput[]) => void} form.clearErrors - Clear selected fields, or all field errors when no paths are supplied.\n * @param {(...paths: FieldPathInput[]) => Promise<boolean>} form.trigger - Run manual validation for selected paths or the entire form.\n * @param {(path: FieldPathInput) => FormArray} form.array - Return commands that keep array values, keys, and child metadata aligned.\n * @param {(values?: TValues | undefined, options?: ResetOptions) => void} form.reset - Reinitialize from default or replacement values with optional preservation flags.\n * @param {<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>} form.submit - Queue validation and dispatch the valid or invalid callback.\n * @param {RegisterOptions} options - Field schema and DOM binding options.\n * @param {FieldPathInput} options.name - Literal field name or tuple path; strings are not split on dots.\n * @param {StandardSchemaV1<unknown, unknown> | undefined} [options.schema] - Standard Schema validator; a field-local schema takes precedence over the form schema.\n * @param {StandardSchemaV1.Props<unknown, unknown>} [options.schema.~standard] - Standard Schema version, vendor, type metadata, and validation entry point.\n * @param {1} [options.schema.~standard.version] - Standard Schema major version, which must be 1.\n * @param {string} [options.schema.~standard.vendor] - Name of the schema library implementation.\n * @param {StandardSchemaV1.Types<unknown, unknown> | undefined} [options.schema.~standard.types] - Optional compile-time input and output metadata.\n * @param {unknown} [options.schema.~standard.types.input] - Schema input type metadata.\n * @param {unknown} [options.schema.~standard.types.output] - Schema output type metadata.\n * @param {(value: unknown, options?: StandardSchemaV1.Options | undefined) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>} [options.schema.~standard.validate] - Validate unknown input and return accepted values or issues, synchronously or asynchronously.\n * @param {StandardSchemaV1.Options | undefined} [options.schemaOptions] - Options forwarded to the Standard Schema validator.\n * @param {Record<string, unknown> | undefined} [options.schemaOptions.libraryOptions] - Library-specific validation options; keys are defined by the schema library.\n * @param {string | undefined} [options.type] - Input kind; checkbox and radio use checked semantics, otherwise defaults to text.\n * @param {unknown} [options.value] - Explicit option value used by checkbox and radio bindings.\n * @param {unknown} [options.checkedValue] - Value written by a checked checkbox; omitted for a boolean checkbox.\n * @param {unknown} [options.uncheckedValue] - Value written by an unchecked checkbox; defaults to false.\n * @param {() => Readonly<FieldState>} getField - Read the latest field snapshot when a binding is accessed.\n * @param {string} domName - Name string assigned to the DOM control.\n * @returns {VueRegisterPropsForElement<TElement>} Binding properties suitable for the selected framework and element type.\n * @example\n * ```ts\n * createRegisterProps(form, { name: \"email\" }, () => form.getFieldState(\"email\"), \"email\");\n * ```\n */\nexport function createRegisterProps<TValues, TElement extends VueRegisterElement>(\n form: Form<TValues>,\n options: RegisterOptions,\n getField: () => Readonly<FieldState>,\n domName: string,\n): VueRegisterPropsForElement<TElement> {\n const binding = createDomBinding(form, options, getField, domName);\n const props = {\n name: binding.name,\n type: binding.type,\n get value() {\n return binding.value;\n },\n get checked() {\n return binding.checked;\n },\n onInput: (event: Event) => {\n binding.input(event.currentTarget as FieldEventTarget);\n },\n onChange: (event: Event) => {\n binding.change(event.currentTarget as FieldEventTarget);\n },\n onBlur: () => {\n binding.blur();\n },\n onFocus: () => {\n binding.focus();\n },\n };\n\n return props as unknown as VueRegisterPropsForElement<TElement>;\n}\n\nexport { fieldPathToDomName };\n","import { getCurrentScope, onScopeDispose } from 'vue';\nimport type { Form } from '../core/index';\nimport type { RegisterOptions } from './types';\n\n/**\n * @description Register field-local schemas together and release them with the framework lifecycle.\n * @param {Form<TValues>} form - Core form instance shared by all bound helpers.\n * @param {() => Readonly<FormState<TValues>>} form.getState - Read the current immutable form snapshot.\n * @param {(listener: () => void) => () => void} form.subscribe - Subscribe to state changes and return an unsubscribe callback.\n * @param {(path: FieldPathInput, options: FieldSchemaOptions) => () => void} form.registerFieldSchema - Register an overriding field-local validator and return its guarded cleanup.\n * @param {(path: FieldPathInput) => Readonly<FieldState>} form.getFieldState - Read field metadata, using a default snapshot for an unknown field.\n * @param {(path: FieldPathInput) => unknown} form.getValue - Read the current value of one field.\n * @param {() => TValues} form.getValues - Reconstruct nested values from fields and array containers.\n * @param {(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void} form.setValue - Write a field with configurable user or program origin and optional immediate validation.\n * @param {(path: FieldPathInput) => Promise<boolean>} form.blur - Clear focus, mark touched, and run configured blur validation.\n * @param {(path: FieldPathInput) => void} form.focus - Record focus for the selected field.\n * @param {(path: FieldPathInput, errors: readonly FormError[]) => void} form.setErrors - Replace all errors for the selected field.\n * @param {(...paths: FieldPathInput[]) => void} form.clearErrors - Clear selected fields, or all field errors when no paths are supplied.\n * @param {(...paths: FieldPathInput[]) => Promise<boolean>} form.trigger - Run manual validation for selected paths or the entire form.\n * @param {(path: FieldPathInput) => FormArray} form.array - Return commands that keep array values, keys, and child metadata aligned.\n * @param {(values?: TValues | undefined, options?: ResetOptions) => void} form.reset - Reinitialize from default or replacement values with optional preservation flags.\n * @param {<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>} form.submit - Queue validation and dispatch the valid or invalid callback.\n * @param {readonly RegisterOptions[]} options - Field schema and DOM binding options.\n * @example\n * ```ts\n * useFieldSchemaRegistrations(form, [{ name: \"email\", schema }]);\n * ```\n */\nexport function useFieldSchemaRegistrations<TValues>(form: Form<TValues>, options: readonly RegisterOptions[]): void {\n const cleanups = options.flatMap(option => {\n if (!option.schema) {\n return [];\n }\n\n return [form.registerFieldSchema(option.name, { schema: option.schema, schemaOptions: option.schemaOptions })];\n });\n\n if (cleanups.length === 0) {\n return;\n }\n\n if (getCurrentScope()) {\n onScopeDispose(() => {\n cleanups.forEach(cleanup => cleanup());\n });\n }\n}\n","import { getCurrentScope, onScopeDispose, shallowRef, type ShallowRef } from 'vue';\nimport type { Form, FormState } from '../core/index';\n\n/**\n * @description Subscribe the framework view to core form snapshots and release the subscription through its lifecycle.\n * @param {Form<TValues>} form - Core form instance shared by all bound helpers.\n * @param {() => Readonly<FormState<TValues>>} form.getState - Read the current immutable form snapshot.\n * @param {(listener: () => void) => () => void} form.subscribe - Subscribe to state changes and return an unsubscribe callback.\n * @param {(path: FieldPathInput, options: FieldSchemaOptions) => () => void} form.registerFieldSchema - Register an overriding field-local validator and return its guarded cleanup.\n * @param {(path: FieldPathInput) => Readonly<FieldState>} form.getFieldState - Read field metadata, using a default snapshot for an unknown field.\n * @param {(path: FieldPathInput) => unknown} form.getValue - Read the current value of one field.\n * @param {() => TValues} form.getValues - Reconstruct nested values from fields and array containers.\n * @param {(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void} form.setValue - Write a field with configurable user or program origin and optional immediate validation.\n * @param {(path: FieldPathInput) => Promise<boolean>} form.blur - Clear focus, mark touched, and run configured blur validation.\n * @param {(path: FieldPathInput) => void} form.focus - Record focus for the selected field.\n * @param {(path: FieldPathInput, errors: readonly FormError[]) => void} form.setErrors - Replace all errors for the selected field.\n * @param {(...paths: FieldPathInput[]) => void} form.clearErrors - Clear selected fields, or all field errors when no paths are supplied.\n * @param {(...paths: FieldPathInput[]) => Promise<boolean>} form.trigger - Run manual validation for selected paths or the entire form.\n * @param {(path: FieldPathInput) => FormArray} form.array - Return commands that keep array values, keys, and child metadata aligned.\n * @param {(values?: TValues | undefined, options?: ResetOptions) => void} form.reset - Reinitialize from default or replacement values with optional preservation flags.\n * @param {<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>} form.submit - Queue validation and dispatch the valid or invalid callback.\n * @returns {ShallowRef<Readonly<FormState<TValues>>>} Framework subscription to current immutable snapshots.\n * @example\n * ```ts\n * useFormSnapshot(form);\n * ```\n */\nexport function useFormSnapshot<TValues>(form: Form<TValues>): ShallowRef<Readonly<FormState<TValues>>> {\n const snapshot = shallowRef(form.getState()) as ShallowRef<Readonly<FormState<TValues>>>;\n const unsubscribe = form.subscribe(() => {\n snapshot.value = form.getState();\n });\n\n if (getCurrentScope()) {\n onScopeDispose(unsubscribe);\n }\n\n return snapshot;\n}\n","import type { Form } from '../core/index';\nimport { getFieldState } from '../adapters/dom';\nimport { createRegisterProps, fieldPathToDomName } from './RegisterBinding';\nimport type { RegisterOptions, VueFieldReturn, VueRegisterElement, VueRegisterPropsForElement } from './types';\nimport { useFieldSchemaRegistrations } from './useFieldSchemaRegistration';\nimport { useFormSnapshot } from './useFormSnapshot';\n\n/**\n * @description Bind one field to its framework view, exposing reactive bindings, copied errors, metadata, and a programmatic setter.\n * @param {Form<TValues>} form - Core form instance shared by all bound helpers.\n * @param {() => Readonly<FormState<TValues>>} form.getState - Read the current immutable form snapshot.\n * @param {(listener: () => void) => () => void} form.subscribe - Subscribe to state changes and return an unsubscribe callback.\n * @param {(path: FieldPathInput, options: FieldSchemaOptions) => () => void} form.registerFieldSchema - Register an overriding field-local validator and return its guarded cleanup.\n * @param {(path: FieldPathInput) => Readonly<FieldState>} form.getFieldState - Read field metadata, using a default snapshot for an unknown field.\n * @param {(path: FieldPathInput) => unknown} form.getValue - Read the current value of one field.\n * @param {() => TValues} form.getValues - Reconstruct nested values from fields and array containers.\n * @param {(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void} form.setValue - Write a field with configurable user or program origin and optional immediate validation.\n * @param {(path: FieldPathInput) => Promise<boolean>} form.blur - Clear focus, mark touched, and run configured blur validation.\n * @param {(path: FieldPathInput) => void} form.focus - Record focus for the selected field.\n * @param {(path: FieldPathInput, errors: readonly FormError[]) => void} form.setErrors - Replace all errors for the selected field.\n * @param {(...paths: FieldPathInput[]) => void} form.clearErrors - Clear selected fields, or all field errors when no paths are supplied.\n * @param {(...paths: FieldPathInput[]) => Promise<boolean>} form.trigger - Run manual validation for selected paths or the entire form.\n * @param {(path: FieldPathInput) => FormArray} form.array - Return commands that keep array values, keys, and child metadata aligned.\n * @param {(values?: TValues | undefined, options?: ResetOptions) => void} form.reset - Reinitialize from default or replacement values with optional preservation flags.\n * @param {<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>} form.submit - Queue validation and dispatch the valid or invalid callback.\n * @param {RegisterOptions} options - Field schema and DOM binding options.\n * @param {FieldPathInput} options.name - Literal field name or tuple path; strings are not split on dots.\n * @param {StandardSchemaV1<unknown, unknown> | undefined} [options.schema] - Standard Schema validator; a field-local schema takes precedence over the form schema.\n * @param {StandardSchemaV1.Props<unknown, unknown>} [options.schema.~standard] - Standard Schema version, vendor, type metadata, and validation entry point.\n * @param {1} [options.schema.~standard.version] - Standard Schema major version, which must be 1.\n * @param {string} [options.schema.~standard.vendor] - Name of the schema library implementation.\n * @param {StandardSchemaV1.Types<unknown, unknown> | undefined} [options.schema.~standard.types] - Optional compile-time input and output metadata.\n * @param {unknown} [options.schema.~standard.types.input] - Schema input type metadata.\n * @param {unknown} [options.schema.~standard.types.output] - Schema output type metadata.\n * @param {(value: unknown, options?: StandardSchemaV1.Options | undefined) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>} [options.schema.~standard.validate] - Validate unknown input and return accepted values or issues, synchronously or asynchronously.\n * @param {StandardSchemaV1.Options | undefined} [options.schemaOptions] - Options forwarded to the Standard Schema validator.\n * @param {Record<string, unknown> | undefined} [options.schemaOptions.libraryOptions] - Library-specific validation options; keys are defined by the schema library.\n * @param {string | undefined} [options.type] - Input kind; checkbox and radio use checked semantics, otherwise defaults to text.\n * @param {unknown} [options.value] - Explicit option value used by checkbox and radio bindings.\n * @param {unknown} [options.checkedValue] - Value written by a checked checkbox; omitted for a boolean checkbox.\n * @param {unknown} [options.uncheckedValue] - Value written by an unchecked checkbox; defaults to false.\n * @returns {VueFieldReturn<VueRegisterPropsForElement<TElement>>} Reactive field bindings, value, copied errors, flags, and programmatic setter.\n * - props `VueRegisterPropsForElement<TElement>` - Binding properties to spread onto the matching DOM control.\n * - value `unknown` - Current field value.\n * - setValue `(value: unknown) => void` - Replace the field value as a programmatic write.\n * - errors `FormError[]` - Current validation errors for the field.\n * - dirty `boolean` - Whether the current value differs from its default by Object.is.\n * - touched `boolean` - Whether the field has blurred at least once.\n * @example\n * ```ts\n * useFieldWithForm(form, { name: \"email\", schema });\n * ```\n */\nexport function useFieldWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement>(form: Form<TValues>, options: RegisterOptions): VueFieldReturn<VueRegisterPropsForElement<TElement>> {\n useFieldSchemaRegistrations(form, [options]);\n\n const snapshot = useFormSnapshot(form);\n const getField = () => getFieldState(form, snapshot.value, options.name);\n const props = createRegisterProps<TValues, TElement>(form, options, getField, fieldPathToDomName(options.name));\n\n return {\n props,\n get value() {\n return getField().value;\n },\n setValue(value: unknown) {\n form.setValue(options.name, value, { source: 'program' });\n },\n get errors() {\n return [...getField().errors];\n },\n get dirty() {\n return getField().dirty;\n },\n get touched() {\n return getField().touched;\n },\n };\n}\n","import type { Form } from '../core/index';\nimport { createFormStateSummary } from '../adapters/FormStateSummary';\nimport type { VueFormStateReturn } from './types';\nimport { useFormSnapshot } from './useFormSnapshot';\n\n/**\n * @description Subscribe to form-wide aggregates derived from the current core snapshot.\n * @param {Form<TValues>} form - Core form instance shared by all bound helpers.\n * @param {() => Readonly<FormState<TValues>>} form.getState - Read the current immutable form snapshot.\n * @param {(listener: () => void) => () => void} form.subscribe - Subscribe to state changes and return an unsubscribe callback.\n * @param {(path: FieldPathInput, options: FieldSchemaOptions) => () => void} form.registerFieldSchema - Register an overriding field-local validator and return its guarded cleanup.\n * @param {(path: FieldPathInput) => Readonly<FieldState>} form.getFieldState - Read field metadata, using a default snapshot for an unknown field.\n * @param {(path: FieldPathInput) => unknown} form.getValue - Read the current value of one field.\n * @param {() => TValues} form.getValues - Reconstruct nested values from fields and array containers.\n * @param {(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void} form.setValue - Write a field with configurable user or program origin and optional immediate validation.\n * @param {(path: FieldPathInput) => Promise<boolean>} form.blur - Clear focus, mark touched, and run configured blur validation.\n * @param {(path: FieldPathInput) => void} form.focus - Record focus for the selected field.\n * @param {(path: FieldPathInput, errors: readonly FormError[]) => void} form.setErrors - Replace all errors for the selected field.\n * @param {(...paths: FieldPathInput[]) => void} form.clearErrors - Clear selected fields, or all field errors when no paths are supplied.\n * @param {(...paths: FieldPathInput[]) => Promise<boolean>} form.trigger - Run manual validation for selected paths or the entire form.\n * @param {(path: FieldPathInput) => FormArray} form.array - Return commands that keep array values, keys, and child metadata aligned.\n * @param {(values?: TValues | undefined, options?: ResetOptions) => void} form.reset - Reinitialize from default or replacement values with optional preservation flags.\n * @param {<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>} form.submit - Queue validation and dispatch the valid or invalid callback.\n * @returns {VueFormStateReturn<TValues>} Reactive form-wide aggregates and submission flags.\n * - state `Readonly<FormState<TValues>>` - Current immutable form snapshot.\n * : state.defaultValues `TValues` - Initial values and the baseline used for dirty checks and reset.\n * : state.fields `Record<string, FieldState<unknown>>` - Field snapshots indexed by normalized path keys.\n * : state.submitCount `number` - Number of submission attempts started by the form.\n * : state.isSubmitting `boolean` - Whether queued validation or a submit callback is still pending.\n * : state.isSubmitted `boolean` - Whether a submission has completed at least once.\n * : state.isSubmitSuccessful `boolean` - Whether the latest completed submission reached a successful valid callback.\n * : state.arrayKeys `ArrayKeys` - Stable rendering keys indexed by array path.\n * - errors `Record<string, FormError[]>` - Nonempty validation error lists indexed by normalized field path.\n * - dirtyFields `Record<string, true>` - Normalized paths whose fields are dirty.\n * - touchedFields `Record<string, true>` - Normalized paths whose fields are touched.\n * - focusedField `string | null` - First focused field in entry order, or null; not necessarily the last focused field.\n * - isDirty `boolean` - Whether at least one field is dirty.\n * - isValid `boolean` - Whether no field currently has recorded errors.\n * - isSubmitting `boolean` - Whether queued validation or a submit callback is still pending.\n * - isSubmitted `boolean` - Whether a submission has completed at least once.\n * - isSubmitSuccessful `boolean` - Whether the latest completed submission reached a successful valid callback.\n * - submitCount `number` - Number of submission attempts started by the form.\n * @example\n * ```ts\n * useFormStateWithForm(form);\n * ```\n */\nexport function useFormStateWithForm<TValues>(form: Form<TValues>): VueFormStateReturn<TValues> {\n const snapshot = useFormSnapshot(form);\n const getSummary = () => createFormStateSummary(snapshot.value);\n\n return {\n get state() {\n return snapshot.value;\n },\n get errors() {\n return getSummary().errors;\n },\n get dirtyFields() {\n return getSummary().dirtyFields;\n },\n get touchedFields() {\n return getSummary().touchedFields;\n },\n get focusedField() {\n return getSummary().focusedField;\n },\n get isDirty() {\n return getSummary().isDirty;\n },\n get isValid() {\n return getSummary().isValid;\n },\n get isSubmitting() {\n return getSummary().isSubmitting;\n },\n get isSubmitted() {\n return getSummary().isSubmitted;\n },\n get isSubmitSuccessful() {\n return getSummary().isSubmitSuccessful;\n },\n get submitCount() {\n return getSummary().submitCount;\n },\n };\n}\n","import type { Form } from '../core/index';\nimport { getFieldState } from '../adapters/dom';\nimport { createRegisterProps, fieldPathToDomName } from './RegisterBinding';\nimport type { RegisterOptions, VueRegisterElement, VueRegisterPropsForElement, VueRegisterPropsList } from './types';\nimport { useFieldSchemaRegistrations } from './useFieldSchemaRegistration';\nimport { useFormSnapshot } from './useFormSnapshot';\n\n/**\n * @description Create a single binding or ordered binding list for single, array, or variadic registration options.\n * @param {Form<TValues>} form - Core form instance shared by all bound helpers.\n * @param {() => Readonly<FormState<TValues>>} form.getState - Read the current immutable form snapshot.\n * @param {(listener: () => void) => () => void} form.subscribe - Subscribe to state changes and return an unsubscribe callback.\n * @param {(path: FieldPathInput, options: FieldSchemaOptions) => () => void} form.registerFieldSchema - Register an overriding field-local validator and return its guarded cleanup.\n * @param {(path: FieldPathInput) => Readonly<FieldState>} form.getFieldState - Read field metadata, using a default snapshot for an unknown field.\n * @param {(path: FieldPathInput) => unknown} form.getValue - Read the current value of one field.\n * @param {() => TValues} form.getValues - Reconstruct nested values from fields and array containers.\n * @param {(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void} form.setValue - Write a field with configurable user or program origin and optional immediate validation.\n * @param {(path: FieldPathInput) => Promise<boolean>} form.blur - Clear focus, mark touched, and run configured blur validation.\n * @param {(path: FieldPathInput) => void} form.focus - Record focus for the selected field.\n * @param {(path: FieldPathInput, errors: readonly FormError[]) => void} form.setErrors - Replace all errors for the selected field.\n * @param {(...paths: FieldPathInput[]) => void} form.clearErrors - Clear selected fields, or all field errors when no paths are supplied.\n * @param {(...paths: FieldPathInput[]) => Promise<boolean>} form.trigger - Run manual validation for selected paths or the entire form.\n * @param {(path: FieldPathInput) => FormArray} form.array - Return commands that keep array values, keys, and child metadata aligned.\n * @param {(values?: TValues | undefined, options?: ResetOptions) => void} form.reset - Reinitialize from default or replacement values with optional preservation flags.\n * @param {<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>} form.submit - Queue validation and dispatch the valid or invalid callback.\n * @param {RegisterOptions | TOptions} options - Single registration options or an ordered list; variadic calls use the same options order.\n * @param {FieldPathInput} options.name - Literal field name or tuple path; strings are not split on dots.\n * @param {StandardSchemaV1<unknown, unknown> | undefined} [options.schema] - Standard Schema validator; a field-local schema takes precedence over the form schema.\n * @param {StandardSchemaV1.Props<unknown, unknown>} [options.schema.~standard] - Standard Schema version, vendor, type metadata, and validation entry point.\n * @param {1} [options.schema.~standard.version] - Standard Schema major version, which must be 1.\n * @param {string} [options.schema.~standard.vendor] - Name of the schema library implementation.\n * @param {StandardSchemaV1.Types<unknown, unknown> | undefined} [options.schema.~standard.types] - Optional compile-time input and output metadata.\n * @param {unknown} [options.schema.~standard.types.input] - Schema input type metadata.\n * @param {unknown} [options.schema.~standard.types.output] - Schema output type metadata.\n * @param {(value: unknown, options?: StandardSchemaV1.Options | undefined) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>} [options.schema.~standard.validate] - Validate unknown input and return accepted values or issues, synchronously or asynchronously.\n * @param {StandardSchemaV1.Options | undefined} [options.schemaOptions] - Options forwarded to the Standard Schema validator.\n * @param {Record<string, unknown> | undefined} [options.schemaOptions.libraryOptions] - Library-specific validation options; keys are defined by the schema library.\n * @param {string | undefined} [options.type] - Input kind; checkbox and radio use checked semantics, otherwise defaults to text.\n * @param {unknown} [options.value] - Explicit option value used by checkbox and radio bindings.\n * @param {unknown} [options.checkedValue] - Value written by a checked checkbox; omitted for a boolean checkbox.\n * @param {unknown} [options.uncheckedValue] - Value written by an unchecked checkbox; defaults to false.\n * @param {RegisterOptions | readonly RegisterOptions[]} first - First single registration or ordered registration list.\n * @param {FieldPathInput} first.name - Literal field name or tuple path; strings are not split on dots.\n * @param {StandardSchemaV1<unknown, unknown> | undefined} [first.schema] - Standard Schema validator; a field-local schema takes precedence over the form schema.\n * @param {StandardSchemaV1.Props<unknown, unknown>} [first.schema.~standard] - Standard Schema version, vendor, type metadata, and validation entry point.\n * @param {1} [first.schema.~standard.version] - Standard Schema major version, which must be 1.\n * @param {string} [first.schema.~standard.vendor] - Name of the schema library implementation.\n * @param {StandardSchemaV1.Types<unknown, unknown> | undefined} [first.schema.~standard.types] - Optional compile-time input and output metadata.\n * @param {unknown} [first.schema.~standard.types.input] - Schema input type metadata.\n * @param {unknown} [first.schema.~standard.types.output] - Schema output type metadata.\n * @param {(value: unknown, options?: StandardSchemaV1.Options | undefined) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>} [first.schema.~standard.validate] - Validate unknown input and return accepted values or issues, synchronously or asynchronously.\n * @param {StandardSchemaV1.Options | undefined} [first.schemaOptions] - Options forwarded to the Standard Schema validator.\n * @param {Record<string, unknown> | undefined} [first.schemaOptions.libraryOptions] - Library-specific validation options; keys are defined by the schema library.\n * @param {string | undefined} [first.type] - Input kind; checkbox and radio use checked semantics, otherwise defaults to text.\n * @param {unknown} [first.value] - Explicit option value used by checkbox and radio bindings.\n * @param {unknown} [first.checkedValue] - Value written by a checked checkbox; omitted for a boolean checkbox.\n * @param {unknown} [first.uncheckedValue] - Value written by an unchecked checkbox; defaults to false.\n * @param {readonly RegisterOptions[]} rest - Additional registration options for variadic binding creation.\n * @returns {VueRegisterPropsForElement<TElement> | VueRegisterPropsList<TElement, TOptions> | VueRegisterPropsForElement<VueRegisterElement> | VueRegisterPropsForElement<VueRegisterElement>[]} One binding for a single options object, otherwise bindings in supplied order.\n * - onInput `(event: Event) => void` - Forward text input events into the form.\n * - onChange `(event: Event) => void` - Forward change events, including checked and selection state, into the form.\n * - onBlur `(event: FocusEvent) => void` - Clear focus and mark the field touched.\n * - onFocus `(event: FocusEvent) => void` - Record focus for this field.\n * - name `string` - DOM name string; tuple paths are JSON-serialized.\n * - value `DomValue | undefined | unknown | string | number | string[] | undefined | string | number | undefined` - Current field value.\n * - checked `boolean | undefined` - Whether this checkbox or radio represents the current field value.\n * - type `string` - Input kind; checkbox and radio use checked semantics, otherwise defaults to text.\n * @example\n * ```ts\n * const email = useRegisterWithForm(form, { name: \"email\" });\n * const fields = useRegisterWithForm(form, [{ name: \"email\" }, { name: \"name\" }]);\n * ```\n */\nexport function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement>(form: Form<TValues>, options: RegisterOptions): VueRegisterPropsForElement<TElement>;\nexport function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(form: Form<TValues>, options: TOptions): VueRegisterPropsList<TElement, TOptions>;\nexport function useRegisterWithForm<TValues, TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(form: Form<TValues>, ...options: TOptions): VueRegisterPropsList<TElement, TOptions>;\nexport function useRegisterWithForm<TValues>(form: Form<TValues>, first: RegisterOptions | readonly RegisterOptions[], ...rest: readonly RegisterOptions[]): VueRegisterPropsForElement<VueRegisterElement> | VueRegisterPropsForElement<VueRegisterElement>[];\n\nexport function useRegisterWithForm<TValues>(\n form: Form<TValues>,\n first: RegisterOptions | readonly RegisterOptions[],\n ...rest: readonly RegisterOptions[]\n): VueRegisterPropsForElement<VueRegisterElement> | VueRegisterPropsForElement<VueRegisterElement>[] {\n const shouldReturnList = Array.isArray(first) || rest.length > 0;\n const options = normalizeRegisterOptions(first, rest);\n\n useFieldSchemaRegistrations(form, options);\n\n const snapshot = useFormSnapshot(form);\n const bindings = options.map(option => createRegisterProps(\n form,\n option,\n () => getFieldState(form, snapshot.value, option.name),\n fieldPathToDomName(option.name),\n ));\n\n return shouldReturnList ? bindings : bindings[0];\n}\n\nfunction normalizeRegisterOptions(first: RegisterOptions | readonly RegisterOptions[], rest: readonly RegisterOptions[]): readonly RegisterOptions[] {\n if (Array.isArray(first)) {\n return first as readonly RegisterOptions[];\n }\n\n if (rest.length > 0) {\n return [first as RegisterOptions, ...rest];\n }\n\n return [first as RegisterOptions];\n}\n","import { getCurrentScope, toValue, watch } from 'vue';\nimport type { MaybeRefOrGetter } from 'vue';\n\nimport { createSubmitHandler } from '../adapters/dom';\nimport { createExternalValuesSynchronizer, createFormFromOptions, isFormInstance } from '../adapters/FormInput';\nimport type { Form, ResetOptions } from '../core/index';\nimport type { RegisterOptions, VueForm, VueFormOptions } from './types';\nimport { useFieldWithForm } from './useField';\nimport { useFormStateWithForm } from './useFormState';\nimport { useRegisterWithForm } from './useRegister';\n\n/**\n * @description Bind framework helpers to an existing form or create one from options; defined external-value reference changes reset it.\n * @param {Form<TValues>} form - Core form instance shared by all bound helpers.\n * @param {() => Readonly<FormState<TValues>>} form.getState - Read the current immutable form snapshot.\n * @param {(listener: () => void) => () => void} form.subscribe - Subscribe to state changes and return an unsubscribe callback.\n * @param {(path: FieldPathInput, options: FieldSchemaOptions) => () => void} form.registerFieldSchema - Register an overriding field-local validator and return its guarded cleanup.\n * @param {(path: FieldPathInput) => Readonly<FieldState>} form.getFieldState - Read field metadata, using a default snapshot for an unknown field.\n * @param {(path: FieldPathInput) => unknown} form.getValue - Read the current value of one field.\n * @param {() => TValues} form.getValues - Reconstruct nested values from fields and array containers.\n * @param {(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void} form.setValue - Write a field with configurable user or program origin and optional immediate validation.\n * @param {(path: FieldPathInput) => Promise<boolean>} form.blur - Clear focus, mark touched, and run configured blur validation.\n * @param {(path: FieldPathInput) => void} form.focus - Record focus for the selected field.\n * @param {(path: FieldPathInput, errors: readonly FormError[]) => void} form.setErrors - Replace all errors for the selected field.\n * @param {(...paths: FieldPathInput[]) => void} form.clearErrors - Clear selected fields, or all field errors when no paths are supplied.\n * @param {(...paths: FieldPathInput[]) => Promise<boolean>} form.trigger - Run manual validation for selected paths or the entire form.\n * @param {(path: FieldPathInput) => FormArray} form.array - Return commands that keep array values, keys, and child metadata aligned.\n * @param {(values?: TValues | undefined, options?: ResetOptions) => void} form.reset - Reinitialize from default or replacement values with optional preservation flags.\n * @param {<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>} form.submit - Queue validation and dispatch the valid or invalid callback.\n * @param {VueFormOptions<TValues>} options - Default values, optional form schema, and automatic validation triggers.\n * @param {TValues} options.defaultValues - Initial values and the baseline used for dirty checks and reset.\n * @param {StandardSchemaV1<unknown, TValues> | undefined} [options.schema] - Standard Schema validator; a field-local schema takes precedence over the form schema.\n * @param {StandardSchemaV1.Props<unknown, TValues>} [options.schema.~standard] - Standard Schema version, vendor, type metadata, and validation entry point.\n * @param {1} [options.schema.~standard.version] - Standard Schema major version, which must be 1.\n * @param {string} [options.schema.~standard.vendor] - Name of the schema library implementation.\n * @param {StandardSchemaV1.Types<unknown, TValues> | undefined} [options.schema.~standard.types] - Optional compile-time input and output metadata.\n * @param {unknown} [options.schema.~standard.types.input] - Schema input type metadata.\n * @param {TValues} [options.schema.~standard.types.output] - Schema output type metadata.\n * @param {(value: unknown, options?: StandardSchemaV1.Options | undefined) => StandardSchemaV1.Result<TValues> | Promise<StandardSchemaV1.Result<TValues>>} [options.schema.~standard.validate] - Validate unknown input and return accepted values or issues, synchronously or asynchronously.\n * @param {StandardSchemaV1.Options | undefined} [options.schemaOptions] - Options forwarded to the Standard Schema validator.\n * @param {Record<string, unknown> | undefined} [options.schemaOptions.libraryOptions] - Library-specific validation options; keys are defined by the schema library.\n * @param {readonly ValidationTrigger[] | undefined} [options.validateOn] - Triggers that run automatic validation; defaults to submit.\n * @param {MaybeRefOrGetter<TValues | undefined>} [options.values] - Replacement values; defined reference changes reset the form.\n * @param {ResetOptions | undefined} [options.resetOptions] - State preservation policy for external-value resets.\n * @param {boolean | undefined} [options.resetOptions.keepDirtyValues] - Preserve current values and modified flags of dirty fields.\n * @param {boolean | undefined} [options.resetOptions.keepErrors] - Preserve errors on surviving field paths.\n * @param {boolean | undefined} [options.resetOptions.keepTouched] - Preserve touched flags on surviving field paths.\n * @param {boolean | undefined} [options.resetOptions.keepSubmitState] - Preserve submission counters and lifecycle flags.\n * @returns {VueForm<TValues>} Core form and bound framework helpers sharing its state and lifecycle.\n * - form `Form<TValues>` - Core form instance shared by all bound helpers.\n * : form.getState `() => Readonly<FormState<TValues>>` - Read the current immutable form snapshot.\n * : form.subscribe `(listener: () => void) => () => void` - Subscribe to state changes and return an unsubscribe callback.\n * : form.registerFieldSchema `(path: FieldPathInput, options: FieldSchemaOptions) => () => void` - Register an overriding field-local validator and return its guarded cleanup.\n * : form.getFieldState `(path: FieldPathInput) => Readonly<FieldState>` - Read field metadata, using a default snapshot for an unknown field.\n * : form.getValue `(path: FieldPathInput) => unknown` - Read the current value of one field.\n * : form.getValues `() => TValues` - Reconstruct nested values from fields and array containers.\n * : form.setValue `(path: FieldPathInput, value: unknown, options?: SetValueOptions) => void` - Write a field with configurable user or program origin and optional immediate validation.\n * : form.blur `(path: FieldPathInput) => Promise<boolean>` - Clear focus, mark touched, and run configured blur validation.\n * : form.focus `(path: FieldPathInput) => void` - Record focus for the selected field.\n * : form.setErrors `(path: FieldPathInput, errors: readonly FormError[]) => void` - Replace all errors for the selected field.\n * : form.clearErrors `(...paths: FieldPathInput[]) => void` - Clear selected fields, or all field errors when no paths are supplied.\n * : form.trigger `(...paths: FieldPathInput[]) => Promise<boolean>` - Run manual validation for selected paths or the entire form.\n * : form.array `(path: FieldPathInput) => FormArray` - Return commands that keep array values, keys, and child metadata aligned.\n * : form.reset `(values?: TValues | undefined, options?: ResetOptions) => void` - Reinitialize from default or replacement values with optional preservation flags.\n * : form.submit `<TResult>(onValid: (values: TValues) => TResult | Promise<TResult>, onInvalid?: (fields: Readonly<Record<PathKey, FieldState>>) => void) => Promise<TResult | undefined>` - Queue validation and dispatch the valid or invalid callback.\n * - useRegister `{ <TElement extends VueRegisterElement = HTMLInputElement>(options: RegisterOptions): VueRegisterPropsForElement<TElement>; <TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(options: TOptions): VueRegisterPropsList<TElement, TOptions>; <TElement extends VueRegisterElement = HTMLInputElement, TOptions extends readonly RegisterOptions[] = readonly RegisterOptions[]>(...options: TOptions): VueRegisterPropsList<TElement, TOptions>; }` - Create one binding or an ordered list from single, array, or variadic options.\n * - useField `<TElement extends VueRegisterElement = HTMLInputElement>(options: RegisterOptions) => VueFieldReturn<VueRegisterPropsForElement<TElement>>` - Create field bindings, reactive value and metadata, and a setter.\n * - useFormState `() => VueFormStateReturn<TValues>` - Subscribe to form-wide errors and lifecycle aggregates.\n * - handleSubmit `<TResult>(onValid: SubmitValidHandler<TValues, TResult>, onInvalid?: SubmitInvalidHandler) => SubmitHandler<Event, TResult>` - Create an event handler that prevents default submission before validating.\n * @example\n * ```ts\n * const { form, handleSubmit } = useForm({ defaultValues: { email: \"\" } });\n * ```\n */\nexport function useForm<TValues>(form: Form<TValues>): VueForm<TValues>;\nexport function useForm<TValues>(options: VueFormOptions<TValues>): VueForm<TValues>;\nexport function useForm<TValues>(input: Form<TValues> | VueFormOptions<TValues>): VueForm<TValues> {\n const isForm = isFormInstance(input);\n if (!isForm && input.values !== undefined && getCurrentScope() === undefined) {\n throw new TypeError('Reactive Vue form options require an active effect scope');\n }\n\n let form: Form<TValues>;\n let values: MaybeRefOrGetter<TValues | undefined> | undefined;\n let resetOptions: ResetOptions | undefined;\n\n if (isForm) {\n form = input;\n values = undefined;\n resetOptions = undefined;\n } else {\n const {\n values: reactiveValues,\n resetOptions: reactiveResetOptions,\n ...createOptions\n } = input;\n\n form = createFormFromOptions(createOptions);\n values = reactiveValues;\n resetOptions = reactiveResetOptions;\n }\n\n if (values !== undefined) {\n const synchronizeValues = createExternalValuesSynchronizer(form);\n\n synchronizeValues(toValue(values), resetOptions);\n\n watch(\n () => toValue(values),\n nextValues => {\n synchronizeValues(nextValues, resetOptions);\n },\n );\n }\n\n const useRegister = ((first: RegisterOptions | readonly RegisterOptions[], ...rest: readonly RegisterOptions[]) => useRegisterWithForm(form, first, ...rest)) as VueForm<TValues>['useRegister'];\n const useField = ((options: RegisterOptions) => useFieldWithForm(form, options)) as VueForm<TValues>['useField'];\n const useFormState = (): ReturnType<VueForm<TValues>['useFormState']> => useFormStateWithForm(form);\n const handleSubmit = ((onValid, onInvalid) => createSubmitHandler(form, onValid, onInvalid)) as VueForm<TValues>['handleSubmit'];\n\n return { form, useRegister, useField, useFormState, handleSubmit };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ilokesto/form",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=24.22.1"
|
|
6
6
|
},
|
|
@@ -101,7 +101,8 @@
|
|
|
101
101
|
"typecheck": "tsc --noEmit",
|
|
102
102
|
"test": "pnpm build && pnpm test:unit && pnpm test:tooling && pnpm test:pack && pnpm examples:build && pnpm examples:typecheck",
|
|
103
103
|
"test:unit": "vitest run tests/unit --maxWorkers=2",
|
|
104
|
-
"
|
|
104
|
+
"lint:jsdoc": "node scripts/check-jsdoc.mjs",
|
|
105
|
+
"test:tooling": "pnpm lint:jsdoc && node --test --test-concurrency=1 tests/tooling/*.test.mjs",
|
|
105
106
|
"release:verify": "node scripts/release-verify.mjs",
|
|
106
107
|
"changeset": "changeset",
|
|
107
108
|
"changeset:status": "changeset status",
|