import { S as Schema, M as MessageWithArgs, E as ErrorMessage, F as FieldProps, O as ObjectSchema, a as FormBaseSchema, b as SchemaValueType, c as SubmitHandler, d as FormRendererProps, V as ValueUpdater, e as StringSchema, P as PrimitiveSchema, f as FieldChangeEvent, B as BitiformsExtras, T as Texts } from './ObjectField-B8JYe9kc.js'; export { A as AddButtonProps, g as ArrayField, h as ArrayFieldContainerProps, i as ArrayFieldItemProps, j as ArrayFieldProps, k as ArraySchema, l as ArraySchemaErrors, m as ArraySchemaValue, n as BooleanSchema, o as Errors, p as ExactSchemaType, q as FormConfig, r as FormConfigProvider, s as FormConfigProviderProps, t as FormRendererContext, u as FormStep, v as FormValuesContext, I as InferSchemaType, w as IntegerSchema, N as NullSchema, x as NumberSchema, y as ObjectField, z as ObjectFieldProps, C as ObjectSchemaErrors, D as ObjectSchemaValue, R as RenderItemProps, G as RevealErrorsContext, H as SchemaExtensions, J as SchemaType, K as SubmissionState, U as UpdateFn, L as UpdateValuesContext, Q as ValidSchemaKeys, W as assertIsObjectSchema, X as defineSchema, Y as isArraySchema, Z as isBooleanSchema, _ as isIntegerSchema, $ as isNullSchema, a0 as isNumberSchema, a1 as isObjectSchema, a2 as isStringSchema, a3 as useFormConfig, a4 as useFormRenderer, a5 as useFormValues, a6 as useRevealErrors, a7 as useUpdateValues } from './ObjectField-B8JYe9kc.js'; import * as react from 'react'; import { ComponentType, ReactNode, EventHandler, SyntheticEvent, Dispatch, SetStateAction } from 'react'; declare function attachMetadataSchemaModifier(options?: { [key: string]: any; }): SchemaModifier; type SchemaModifier = (subschema: Schema, path: string[]) => Schema; declare function modifySchema(schema: T, fn: SchemaModifier): T; declare function modifySchema(schema: T, path: string[], fn: SchemaModifier): Schema; /** * Traverse an Errors data structure and figure out * if it has any errors. * * Errors is the type of structure you get from calling * one of the validation functions. */ declare function hasErrors(errors: unknown): boolean; /** * Refine the specific type of an error message * * Error messages are either simple strings or an object containing * a string with placeholders and values to fill those placeholders. * * @param Errors errors * @returns boolean */ declare function isMessageWithArgs(errors: any): errors is MessageWithArgs; /** * Convert a ErrorMessage structure to a string */ declare function joinErrors(errors: ErrorMessage[], texts?: { [key: string]: string; }): string; type Props = FieldProps; declare const Field: (props: Props) => react.JSX.Element; interface FormProps { /** * Name of the form. This should be globally unique * on a page like any HTML form. */ name?: string; /** * An object containing initial values for the form. * This may for example be data from sessionStorage. * * If it changes before any value in the form is changed, the form starts * over with the new values. This lets values that load after the first * render, like data from storage, fill the form. */ initialValues?: Partial> | null | undefined; /** * The base JSON Schema schema of the form. * * The form form accepts a limited subset * of JSON Schema Draft-07 * * @see https://json-schema.org/draft-07/json-schema-release-notes.html */ schema: T | T[]; /** * The submit handler of the form. * * To signal a failed submission (e.g. rejected by the server or isValid=false) * you should either `throw` an error or `return false` from this handler. * * Note that *you must explicitly* handle the `isValid` flag provided to this * handler correctly: * * ```tsx * if (!isValid) { * throw new SubmissionError() * } * ``` */ onSubmit?: SubmitHandler; /** * A callback that is called whenever a form value changes. * This can be used to save data in sessionStorage. */ onFormValuesChanged?: (values: SchemaValueType) => void; /** * The form renderer React component. */ component?: ComponentType>; /** * Form render-callback. * Can be used instead of `component`, and will take presedence if both are given. */ render?: (props: FormRendererProps) => ReactNode; /** * Simple react element. */ element?: ReactNode; /** * Mark the form as disabled * * Change handlers will not do anything in this mode. */ disabled?: boolean; } declare class SubmissionError extends Error { errors: T; constructor(errors: T); } declare function useForm({ name: customName, initialValues, schema, disabled, onSubmit, onFormValuesChanged, }: Omit, 'component' | 'render'>): readonly [FormRendererProps, { readonly revealAllErrors: boolean; readonly values: SchemaValueType; readonly updateValues: ValueUpdater; }]; declare function Form({ render, component, element, ...props }: FormProps): react.JSX.Element; interface FormDebuggerProps { data: { [key: string]: any; }; renderTab?: (data: { [key: string]: any; }) => ReactNode; } declare function FormDebugger({ data: tabs, renderTab }: FormDebuggerProps): react.JSX.Element; type SelectOption = [string, string]; interface EnumerationOptions { values: SelectOption[]; fromSchemaValue: (schemaValue: any) => any; toSchemaValue: (inputValue: any) => any; } declare function getEnumValueAndLabel(schema: StringSchema): [string, string][]; /** * A helper for building different widgets that enumerates * values such as Select and Radio Groups. */ declare function useEnumeration(schema: Schema): EnumerationOptions; /** * Returns props you can add to a `
` to automatically persist * values in `sessionStorage` and survive page refreshes. * * Saved values are read after the first render, so a server render and the * first render in the browser are the same. */ declare function useFormStorage(key: string, storage?: Storage, debounceMs?: number): { initialValues: Partial>; onFormValuesChanged: (values: SchemaValueType) => void; }; type ToValue = (x: any) => SchemaValueType; declare function useSchemaWidget(props: FieldProps, toValue?: ToValue): { onBlur: () => void; onChange: (e: FieldChangeEvent>) => void; error: string | undefined; schema: TSchema; $bitiforms: BitiformsExtras; id: string; name: string; value: SchemaValueType; disabled: boolean | undefined; }; declare function orderProperties(properties: string[], order: string[] | null | undefined): string[]; declare function invariant(condition: any, message?: string): asserts condition; type OnNext = (e: { preventDefault: () => void; canContinue: boolean; }) => void; type OnPrev = (e: { preventDefault: () => void; }) => void; type RenderStep = ReactNode | ((props: { setSubmitCount: Dispatch>; canContinue: boolean; }) => ReactNode); interface WizardStepProps { hideNextNavigation?: boolean; hidePrevNavigation?: boolean; canContinue?: boolean; onNext?: OnNext; onPrev?: OnPrev; children: RenderStep; } interface StepRouteProps extends Omit { onNext: EventHandler>; texts: Texts; path: string; renderNavigation?: RenderNavigation; } interface WizardNavigationProps extends Pick { submitCount: number; } declare function WizardNavigation({ hideNextNavigation, hidePrevNavigation, canContinue, submitCount, onPrev, texts, }: WizardNavigationProps): react.JSX.Element | null; type RenderNavigation = (props: WizardNavigationProps) => ReactNode; interface BaseWizardProps { onSubmit: EventHandler>; onNext?: OnNext; onPrev?: OnPrev; children?: ReactNode; currentStep: string; changeStep: (to: string) => void; renderNavigation?: RenderNavigation; } interface WizardProps extends Omit { initialStep?: string; } declare function Wizard({ initialStep, ...props }: WizardProps): react.JSX.Element; declare namespace Wizard { var Step: ({}: WizardStepProps) => null; var Header: typeof WizardHeader; } declare function BaseWizard({ currentStep, changeStep, children, onNext: onNextFromProps, onPrev: onPrevFromProps, onSubmit, renderNavigation, }: BaseWizardProps): react.JSX.Element | null; declare const WizardStep: ({}: WizardStepProps) => null; interface WizardHeaderProps { children?: ReactNode; } declare function WizardHeader({ children }: WizardHeaderProps): react.JSX.Element; /** * Exposes the progress as computed from the internal state of a ``. */ declare function useWizardProgress(): { total: number; current: number; progress: number; }; export { BaseWizard, BitiformsExtras, ErrorMessage, Field, FieldChangeEvent, FieldProps, Form, FormBaseSchema, FormDebugger, FormRendererProps, MessageWithArgs, ObjectSchema, PrimitiveSchema, Schema, SchemaValueType, StringSchema, SubmissionError, SubmitHandler, Texts, ValueUpdater, Wizard, WizardHeader, WizardNavigation, WizardStep, attachMetadataSchemaModifier, getEnumValueAndLabel, hasErrors, invariant, isMessageWithArgs, joinErrors, modifySchema, orderProperties, useEnumeration, useForm, useFormStorage, useSchemaWidget, useWizardProgress }; export type { BaseWizardProps, EnumerationOptions, FormDebuggerProps, FormProps, SchemaModifier, WizardHeaderProps, WizardNavigationProps, WizardProps, WizardStepProps };