import type { Attachment } from "svelte/attachments"; import type { DeepPartial } from "../lib/types.js"; import type { SchedulerYield } from "../lib/scheduler.js"; import { type Bind, type Ref } from "../lib/svelte.svelte.js"; import { type TasksCombinator, type FailedTask } from "../lib/task.svelte.js"; import { type Schema, type Validator } from "../core/index.js"; import { type ValidationError, type ValidationResult, type FailureValidationResult, type FormValidator } from "./validator.js"; import { type Translation } from "./translation.js"; import { type ExtraUiOptions, type UiOptionsRegistry, type UiSchemaRoot } from "./ui-schema.js"; import type { Icons } from "./icons.js"; import type { FieldsValidationMode } from "./validation.js"; import type { FormMerger } from "./merger.js"; import { type FieldPath, type FormIdBuilder } from "./id.js"; import type { Config } from "./config.js"; import type { Theme } from "./components.js"; import { type Creatable, type FormValue, type KeyedArraysMap, type Update } from "./model.js"; import type { ResolveFieldType } from "./fields.js"; import { type FormState } from "./state/index.js"; export declare const DEFAULT_FIELDS_VALIDATION_DEBOUNCE_MS = 300; export type InitialErrors = ValidationError[] | Iterable; declare const UI_OPTIONS_REGISTRY_KEY = "uiOptionsRegistry"; export type UiOptionsRegistryOption = keyof UiOptionsRegistry extends never ? { [UI_OPTIONS_REGISTRY_KEY]?: UiOptionsRegistry; } : { [UI_OPTIONS_REGISTRY_KEY]: UiOptionsRegistry; }; export interface IdBuilderFactoryOptions { idPrefix: string; schema: Schema; uiSchema: UiSchemaRoot; uiOptionsRegistry: UiOptionsRegistry; validator: Validator; merger: FormMerger; valueRef: Ref; } export interface ValidatorFactoryOptions { schema: Schema; uiSchema: UiSchemaRoot; uiOptionsRegistry: UiOptionsRegistry; /** * This is a getter that can be used to access the Merger lazily. */ merger: () => FormMerger; } export interface MergerFactoryOptions { validator: Validator; schema: Schema; uiSchema: UiSchemaRoot; uiOptionsRegistry: UiOptionsRegistry; } export interface FormOptions extends UiOptionsRegistryOption { schema: Schema; theme: Theme; translation: Translation; resolver: (ctx: FormState) => ResolveFieldType; idBuilder: Creatable; validator: Creatable, ValidatorFactoryOptions>; merger: Creatable; /** * @default DEFAULT_ID_PREFIX */ idPrefix?: string; icons?: Icons; uiSchema?: UiSchemaRoot; extraUiOptions?: ExtraUiOptions; /** * Enabling this option can reduce the number of irrelevant validation errors * (for example, when using `dependencies` keyword) by providing the validator * with a trimmed JSON Schema. * * However, this makes the schema reference unstable, which leads to cache misses * when using validators that rely on `WeakMap`-based memoization. * If this is a concern for your use case, use a validator with hash-based memoization instead. * * @deprecated If you need this kind of functionality, use the `retrieveSchema` function from `@sjsf/form/core` in your validator extension. */ validateByRetrievedSchema?: boolean; fieldsValidationMode?: FieldsValidationMode; disabled?: boolean; initialValue?: DeepPartial; value?: Bind; initialErrors?: InitialErrors; /** * @default waitPrevious */ submissionCombinator?: TasksCombinator<[ event: SubmitEvent ], ValidationResult, unknown>; /** * @default 500 */ submissionDelayedMs?: number; /** * @default 8000 */ submissionTimeoutMs?: number; /** * @default 300 */ fieldsValidationDebounceMs?: number; /** * @default abortPrevious */ fieldsValidationCombinator?: TasksCombinator<[ Config, FormValue ], Update, unknown>; /** * @default 500 */ fieldsValidationDelayedMs?: number; /** * @default 8000 */ fieldsValidationTimeoutMs?: number; /** * Submit handler * * Will be called when the form is submitted and form data * snapshot is valid * * Note that we rely on `validator.validateFormData` to check that the * `formData is T`. So make sure you provide a `T` type that * matches the validator check result. */ onSubmit?: (value: T, e: SubmitEvent) => void; /** * Submit error handler * * Will be called when the form is submitted and form data * snapshot is not valid */ onSubmitError?: (result: FailureValidationResult, e: SubmitEvent, form: FormState) => void; /** * Form submission error handler * * Will be called when the submission fails by a different reasons: * - submission is cancelled * - error during validation * - validation timeout */ onSubmissionFailure?: (state: FailedTask, e: SubmitEvent) => void; /** * Field validation error handler */ onFieldsValidationFailure?: (state: FailedTask, config: Config, value: FormValue) => void; /** * Reset handler * * Will be called when the form is reset. * * The event will be `undefined` if `reset` is called manually without passing an event. */ onReset?: (e?: Event) => void; schedulerYield?: SchedulerYield; keyedArraysMap?: KeyedArraysMap; } export declare function createForm(options: FormOptions): FormState; export declare function handlers(form: FormState): Attachment; export {};