export type InitialErrors =
// WARN: This should't be an array
| Iterable<readonly [FieldPath, string[]]>;
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 {
uiOptionsRegistry: UiOptionsRegistry;
valueRef: Ref<FormValue>;
export interface ValidatorFactoryOptions {
idBuilder: FormIdBuilder;
uiOptionsRegistry: UiOptionsRegistry;
* This is a getter that can be used to access the Merger lazily.
merger: () => FormMerger;
export interface MergerFactoryOptions {
uiOptionsRegistry: UiOptionsRegistry;
// from '@sjsf/form/lib/svelte.svelte'
export type Bind<T> = [get: () => T, set: (v: T) => void];
export type Creatable<Result, Options> =
| ((options: Options) => Result)
export interface FormOptions<T> extends UiOptionsRegistryOption {
translation: Translation;
resolver: (ctx: FormState<T>) => ResolveFieldType;
idBuilder: Creatable<FormIdBuilder, IdBuilderFactoryOptions>;
validator: Creatable<Validator, ValidatorFactoryOptions>;
merger: Creatable<FormMerger, MergerFactoryOptions>;
* @default DEFAULT_ID_PREFIX
extraUiOptions?: ExtraUiOptions;
fieldsValidationMode?: FieldsValidationMode;
initialValue?: DeepPartial<T>;
initialErrors?: InitialErrors;
submissionCombinator?: TasksCombinator<
submissionDelayedMs?: number;
submissionTimeoutMs?: number;
fieldsValidationDebounceMs?: number;
fieldsValidationCombinator?: TasksCombinator<
fieldsValidationDelayedMs?: number;
fieldsValidationTimeoutMs?: number;
* Will be called when the form is submitted and form data
* 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;
* Will be called when the form is submitted and form data
result: FailureValidationResult,
* Form submission error handler
* Will be called when the submission fails by a different reasons:
* - submission is cancelled
* - error during validation
onSubmissionFailure?: (state: FailedTask<unknown>, e: SubmitEvent) => void;
* Field validation error handler
onFieldsValidationFailure?: (
state: FailedTask<unknown>,
* 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;