Package @reatom/form
@reatom/form
Interfaces
BaseFormOptions
Defined in: form/reatomForm.ts:174
Extended by
Properties
keepErrorDuringValidating?
optionalkeepErrorDuringValidating:boolean
Defined in: form/reatomForm.ts:190
Defines the default reset behavior of the validation state during async validation for all fields.
Default
falsekeepErrorOnChange?
optionalkeepErrorOnChange:boolean
Defined in: form/reatomForm.ts:199
Defines the default reset behavior of the validation state on field change for all fields. Useful if the validation is triggered on blur or submit only.
Default
!validateOnChangename?
optionalname:string
Defined in: form/reatomForm.ts:175
resetOnSubmit?
optionalresetOnSubmit:boolean
Defined in: form/reatomForm.ts:182
Should reset the state after success submit?
Default
falsevalidateOnBlur?
optionalvalidateOnBlur:boolean
Defined in: form/reatomForm.ts:215
Defines if the validation should be triggered on the field blur by default for all fields.
Default
falsevalidateOnChange?
optionalvalidateOnChange:boolean
Defined in: form/reatomForm.ts:207
Defines if the validation should be triggered with every field change by default for all fields.
Default
falseFieldAtom()<State, Value>
Defined in: form/reatomField.ts:103
Base changeable state container.
Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.
Extends
FieldLikeAtom<State>
Type Parameters
State
State = any
The type of state stored in the atom
Value
Value = State
FieldAtom(…
params):State
Defined in: form/reatomField.ts:103
Base changeable state container.
Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.
Parameters
params
…[]
Parameters to pass to the atom
Returns
State
The atom’s payload (typically its current state)
Properties
__reatom
__reatom:
AtomMeta
Defined in: core/atom.ts:106
Reference to the atom’s internal metadata.
Inherited from
__reatomField
__reatomField:
true
Defined in: form/reatomField.ts:100
Inherited from
actions
Defined in: core/atom.ts:86
Bind methods to the atom to extend its functionality.
Deprecated
Use extend instead
Inherited from
change
change:
Action<[Value],Value>
Defined in: form/reatomField.ts:109
Action for handling field changes, accepts the “value” parameter and
applies it to toState option.
disabled
disabled:
BooleanAtom
Defined in: form/reatomField.ts:127
Atom that defines if the field is disabled
elementRef
elementRef:
Atom<undefined|FieldElementRef>
Defined in: form/reatomField.ts:130
Atom with the reference to the field element.
extend
Defined in: core/atom.ts:92
Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.
Inherited from
focus
focus:
FocusAtom
Defined in: form/reatomField.ts:112
Atom of an object with all related focus statuses.
initState
initState:
Atom<State>
Defined in: form/reatomField.ts:115
The initial state of the atom.
options
options:
RecordAtom<{keepErrorDuringValidating:undefined|boolean;keepErrorOnChange:undefined|boolean;shouldValidate:undefined|boolean;validateOnBlur:undefined|boolean;validateOnChange:undefined|boolean; }>
Defined in: form/reatomField.ts:132
reset
reset:
Action<[] | [State],void>
Defined in: form/reatomField.ts:118
Action to reset the state, the value, the validation, and the focus.
subscribe()
subscribe: (
cb?) =>Unsubscribe
Defined in: core/atom.ts:103
Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.
Parameters
cb?
(state) => any
Callback function that receives the atom’s state when it changes
Returns
An unsubscribe function that removes the subscription when called
Inherited from
validation
validation:
ValidationAtom
Defined in: form/reatomField.ts:121
Atom of an object with all related validation statuses.
value
value:
Atom<Value>
Defined in: form/reatomField.ts:124
Writable atom with the “value” data, computed by the fromState option
Methods
set()
Call Signature
set(
update):State
Defined in: core/atom.ts:127
Update the atom’s state using a function that receives the previous state
Parameters
update
(state) => State
Function that takes the current state and returns a new state
Returns
State
The new state value
Inherited from
Call Signature
set(…
params):State
Defined in: core/atom.ts:135
Set the atom’s state to a new value
Parameters
params
…[State]
Returns
State
The new state value
Inherited from
FieldElementRef
Defined in: form/reatomField.ts:95
Properties
focus()
focus: (
options?) =>void
Defined in: form/reatomField.ts:96
Parameters
options?
preventScroll?
boolean
Returns
void
FieldError<Meta>
Defined in: form/reatomField.ts:57
Extends
FieldErrorBody<Meta>
Extended by
Type Parameters
Meta
Meta = any
Properties
message
message:
string
Defined in: form/reatomField.ts:47
The message of the error useful for a user.
Inherited from
meta?
optionalmeta:Rec<Meta>
Defined in: form/reatomField.ts:52
The record with arbitrary information about the error like minimum chars, upper bound of a number, etc.
Inherited from
source
source:
FieldErrorSource
Defined in: form/reatomField.ts:62
The type of an error source. The value will be validation if the error
occurred due to the validate function.
FieldErrorBody<Meta>
Defined in: form/reatomField.ts:45
Extended by
Type Parameters
Meta
Meta = any
Properties
message
message:
string
Defined in: form/reatomField.ts:47
The message of the error useful for a user.
meta?
optionalmeta:Rec<Meta>
Defined in: form/reatomField.ts:52
The record with arbitrary information about the error like minimum chars, upper bound of a number, etc.
FieldFocus
Defined in: form/reatomField.ts:34
Properties
active
active:
boolean
Defined in: form/reatomField.ts:36
The field is focused.
dirty
dirty:
boolean
Defined in: form/reatomField.ts:39
The field state is not equal to the initial state.
touched
touched:
boolean
Defined in: form/reatomField.ts:42
The field has ever gained and lost focus.
FieldLikeAtom()<State>
Defined in: form/reatomField.ts:99
Base changeable state container.
Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.
Extends
Atom<State>
Extended by
Type Parameters
State
State = any
The type of state stored in the atom
FieldLikeAtom(…
params):State
Defined in: form/reatomField.ts:99
Base changeable state container.
Atom is the core primitive for storing and updating mutable state in Reatom. It can be called to retrieve its current state or update it with a new value or update function.
Parameters
params
…[]
Parameters to pass to the atom
Returns
State
The atom’s payload (typically its current state)
Properties
__reatom
__reatom:
AtomMeta
Defined in: core/atom.ts:106
Reference to the atom’s internal metadata.
Inherited from
__reatomField
__reatomField:
true
Defined in: form/reatomField.ts:100
actions
actions:
Actions<FieldLikeAtom<State>>
Defined in: core/atom.ts:86
Bind methods to the atom to extend its functionality.
Deprecated
Use extend instead
Inherited from
extend
extend:
Extend<FieldLikeAtom<State>>
Defined in: core/atom.ts:92
Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.
Inherited from
subscribe()
subscribe: (
cb?) =>Unsubscribe
Defined in: core/atom.ts:103
Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.
Parameters
cb?
(state) => any
Callback function that receives the atom’s state when it changes
Returns
An unsubscribe function that removes the subscription when called
Inherited from
Methods
set()
Call Signature
set(
update):State
Defined in: core/atom.ts:127
Update the atom’s state using a function that receives the previous state
Parameters
update
(state) => State
Function that takes the current state and returns a new state
Returns
State
The new state value
Inherited from
Call Signature
set(…
params):State
Defined in: core/atom.ts:135
Set the atom’s state to a new value
Parameters
params
…[State]
Returns
State
The new state value
Inherited from
FieldOptions<State, Value>
Defined in: form/reatomField.ts:185
Extended by
Type Parameters
State
State = any
Value
Value = State
Properties
disabled?
optionaldisabled:boolean
Defined in: form/reatomField.ts:223
Defines if the field is disabled by default.
Default
falseelementRef?
optionalelementRef:FieldElementRef
Defined in: form/reatomField.ts:226
Defines a default element reference accosiated with the field.
filter()?
optionalfilter: (newValue,prevValue) =>boolean
Defined in: form/reatomField.ts:191
The callback to filter “value” changes (from the ‘change’ action). It
should return ‘false’ to skip the update. By default, it always returns
true.
Parameters
newValue
Value
prevValue
Value
Returns
boolean
fromState()?
optionalfromState: (state,self) =>Value
Defined in: form/reatomField.ts:197
The callback to compute the “value” data from the “state” data. By default, it returns the “state” data without any transformations.
Parameters
state
State
self
FieldAtom<State, Value>
Returns
Value
isDirty()?
optionalisDirty: (newValue,prevValue) =>boolean
Defined in: form/reatomField.ts:203
The callback used to determine whether the “value” has changed. By default,
it utilizes isDeepEqual from reatom/utils.
Parameters
newValue
Value
prevValue
Value
Returns
boolean
keepErrorDuringValidating?
optionalkeepErrorDuringValidating:boolean
Defined in: form/reatomField.ts:233
Defines the reset behavior of the validation state during async validation.
Default
falsekeepErrorOnChange?
optionalkeepErrorOnChange:boolean
Defined in: form/reatomField.ts:241
Defines the reset behavior of the validation state on field change. Useful if the validation is triggered on blur or submit only.
Default
!validateOnChangename?
optionalname:string
Defined in: form/reatomField.ts:206
The name of the field and all related atoms and actions.
toState()?
optionaltoState: (value,self) =>State
Defined in: form/reatomField.ts:213
The callback to transform the “state” data from the “value” data from the
change action. By default, it returns the “value” data without any
transformations.
Parameters
value
Value
self
FieldAtom<State, Value>
Returns
State
validate?
optionalvalidate:FieldValidateOption<State,Value> |StandardSchemaV1<State,State>
Defined in: form/reatomField.ts:216
The callback to validate the field.
validateOnBlur?
optionalvalidateOnBlur:boolean
Defined in: form/reatomField.ts:255
Defines if the validation should be triggered on the field blur.
Default
falsevalidateOnChange?
optionalvalidateOnChange:boolean
Defined in: form/reatomField.ts:248
Defines if the validation should be triggered with every field change.
Default
falseFieldSet()<T>
Defined in: form/reatomFieldSet.ts:72
Derived state container.
A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.
Extends
Type Parameters
T
T extends FormInitState
The type of derived state
FieldSet(…
params):Deatomize
Defined in: form/reatomFieldSet.ts:72
Derived state container.
A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.
Parameters
params
…[]
Parameters to pass to the atom
Returns
The atom’s payload (typically its current state)
Properties
__reatom
__reatom:
AtomMeta
Defined in: core/atom.ts:106
Reference to the atom’s internal metadata.
Inherited from
ValidationlessFieldSet.__reatom
actions
Defined in: core/atom.ts:86
Bind methods to the atom to extend its functionality.
Deprecated
Use extend instead
Inherited from
ValidationlessFieldSet.actions
extend
Defined in: core/atom.ts:92
Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.
Inherited from
fieldArraysList
fieldArraysList:
Computed<FormFieldArrayAtom[]>
Defined in: form/reatomFieldSet.ts:49
Computed list of all the field arrays from the fields tree
Inherited from
ValidationlessFieldSet.fieldArraysList
fields
fields:
FormFields<T>
Defined in: form/reatomFieldSet.ts:43
Fields from the init state
Inherited from
fieldsList
Defined in: form/reatomFieldSet.ts:46
Computed list of all the fields from the fields tree
Inherited from
ValidationlessFieldSet.fieldsList
fieldsState
fieldsState:
Computed<Deatomize<FormFields<T>>>
Defined in: form/reatomFieldSet.ts:57
Atom with the state of the fieldset, computed from all the fields in
fieldsList
Deprecated
Use target atom instead
Inherited from
ValidationlessFieldSet.fieldsState
focus
focus:
Computed<FieldFocus>
Defined in: form/reatomFieldSet.ts:63
Atom with focus state of the fieldset, computed from all the fields in
fieldsList
Inherited from
init
init:
Action<[DeepPartial<Deatomize<FormFields<T>>,unknown[]>],void>
Defined in: form/reatomFieldSet.ts:66
Action to set initial values for each field or field array in the fieldset
Inherited from
reset
reset:
Action<[DeepPartial<Deatomize<FormFields<T>>,unknown[]>],void>
Defined in: form/reatomFieldSet.ts:69
Action to reset the state, the value, the validation, and the focus states.
Inherited from
set
set:
unknown
Defined in: core/atom.ts:79
Inherited from
subscribe()
subscribe: (
cb?) =>Unsubscribe
Defined in: core/atom.ts:103
Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.
Parameters
cb?
(state) => any
Callback function that receives the atom’s state when it changes
Returns
An unsubscribe function that removes the subscription when called
Inherited from
ValidationlessFieldSet.subscribe
validation
validation:
Computed<FieldSetValidation> &object
Defined in: form/reatomFieldSet.ts:78
Atom with validation state of the fieldset, computed from all the fields in
fieldsList
Type declaration
trigger
trigger:
Action<[],FieldSetValidation> &AbortExt
Action to trigger fieldset validation.
FieldSetFieldError
Defined in: form/reatomFieldSet.ts:25
Extends
Properties
field
field:
FieldAtom
Defined in: form/reatomFieldSet.ts:26
message
message:
string
Defined in: form/reatomField.ts:47
The message of the error useful for a user.
Inherited from
meta?
optionalmeta:Rec<any>
Defined in: form/reatomField.ts:52
The record with arbitrary information about the error like minimum chars, upper bound of a number, etc.
Inherited from
source
source:
FieldErrorSource
Defined in: form/reatomField.ts:62
The type of an error source. The value will be validation if the error
occurred due to the validate function.
Inherited from
FieldSetValidation
Defined in: form/reatomFieldSet.ts:29
Properties
errors
errors:
FieldSetFieldError[]
Defined in: form/reatomFieldSet.ts:31
The list of field validation errors.
triggered
triggered:
boolean
Defined in: form/reatomFieldSet.ts:34
The validation actuality status.
validating
validating:
undefined|Promise<{errors:FieldSetFieldError[]; }>
Defined in: form/reatomFieldSet.ts:37
The field async validation status
FieldValidation
Defined in: form/reatomField.ts:65
Properties
error
error:
undefined|string
Defined in: form/reatomField.ts:67
Message of the first validation error, computed from errors atom
triggered
triggered:
boolean
Defined in: form/reatomField.ts:70
The validation actuality status.
validating
validating:
undefined|Promise<{errors:FieldError<any>[]; }>
Defined in: form/reatomField.ts:73
The field async validation status.
FocusAtom()
Defined in: form/reatomField.ts:76
Base atom interface for other userspace implementations. This is the core interface that all atom-like objects implement, providing the foundation for Reatom’s reactivity system.
Extends
FocusAtom(…
params):FieldFocus
Defined in: form/reatomField.ts:76
Base atom interface for other userspace implementations. This is the core interface that all atom-like objects implement, providing the foundation for Reatom’s reactivity system.
Parameters
params
…any[]
Parameters to pass to the atom
Returns
The atom’s payload (typically its current state)
Properties
__reatom
__reatom:
AtomMeta
Defined in: core/atom.ts:106
Reference to the atom’s internal metadata.
Inherited from
actions
Defined in: core/atom.ts:86
Bind methods to the atom to extend its functionality.
Deprecated
Use extend instead
Inherited from
extend
Defined in: core/atom.ts:92
Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.
Inherited from
in
in:
Action<[],FieldFocus>
Defined in: form/reatomField.ts:78
Action for handling field focus.
out
out:
Action<[],FieldFocus>
Defined in: form/reatomField.ts:81
Action for handling field blur.
set
set:
unknown
Defined in: core/atom.ts:79
Inherited from
subscribe()
subscribe: (
cb?) =>Unsubscribe
Defined in: core/atom.ts:103
Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.
Parameters
cb?
(state) => any
Callback function that receives the atom’s state when it changes
Returns
An unsubscribe function that removes the subscription when called
Inherited from
Form()<T, SchemaState, SubmitReturn, SubmitParams>
Defined in: form/reatomForm.ts:133
Derived state container.
A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.
Extends
Type Parameters
T
T extends FormInitState = FormInitState
The type of derived state
SchemaState
SchemaState = any
SubmitReturn
SubmitReturn = void
SubmitParams
SubmitParams extends any[] = []
Form(…
params):Deatomize
Defined in: form/reatomForm.ts:133
Derived state container.
A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.
Parameters
params
…[]
Parameters to pass to the atom
Returns
The atom’s payload (typically its current state)
Properties
__reatom
__reatom:
AtomMeta
Defined in: core/atom.ts:106
Reference to the atom’s internal metadata.
Inherited from
ValidationlessFieldSet.__reatom
actions
actions:
Actions<Form<T,SchemaState,SubmitReturn,SubmitParams>>
Defined in: core/atom.ts:86
Bind methods to the atom to extend its functionality.
Deprecated
Use extend instead
Inherited from
ValidationlessFieldSet.actions
extend
extend:
Extend<Form<T,SchemaState,SubmitReturn,SubmitParams>>
Defined in: core/atom.ts:92
Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.
Inherited from
fieldArraysList
fieldArraysList:
Computed<FormFieldArrayAtom[]>
Defined in: form/reatomFieldSet.ts:49
Computed list of all the field arrays from the fields tree
Inherited from
ValidationlessFieldSet.fieldArraysList
fields
fields:
FormFields<T>
Defined in: form/reatomFieldSet.ts:43
Fields from the init state
Inherited from
fieldsList
Defined in: form/reatomFieldSet.ts:46
Computed list of all the fields from the fields tree
Inherited from
ValidationlessFieldSet.fieldsList
fieldsState
fieldsState:
Computed<Deatomize<FormFields<T>>>
Defined in: form/reatomFieldSet.ts:57
Atom with the state of the fieldset, computed from all the fields in
fieldsList
Deprecated
Use target atom instead
Inherited from
ValidationlessFieldSet.fieldsState
focus
focus:
Computed<FieldFocus>
Defined in: form/reatomFieldSet.ts:63
Atom with focus state of the fieldset, computed from all the fields in
fieldsList
Inherited from
init
init:
Action<[DeepPartial<Deatomize<FormFields<T>>,unknown[]>],void>
Defined in: form/reatomFieldSet.ts:66
Action to set initial values for each field or field array in the fieldset
Inherited from
reset
reset:
Action<[DeepPartial<Deatomize<FormFields<T>>,unknown[]>],void>
Defined in: form/reatomFieldSet.ts:69
Action to reset the state, the value, the validation, and the focus states.
Inherited from
set
set:
unknown
Defined in: core/atom.ts:79
Inherited from
submit
submit:
SubmitAction<SubmitReturn,SubmitParams>
Defined in: form/reatomForm.ts:168
Submit async handler. It checks the validation of all the fields in
fieldsList, calls the form’s validate options handler, and then the
onSubmit options handler. Check the additional options properties of
async action: https://reatom.dev/handbook/async/.
submitted
submitted:
Computed<boolean>
Defined in: form/reatomForm.ts:171
Atom with submitted state of the form
subscribe()
subscribe: (
cb?) =>Unsubscribe
Defined in: core/atom.ts:103
Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.
Parameters
cb?
(state) => any
Callback function that receives the atom’s state when it changes
Returns
An unsubscribe function that removes the subscription when called
Inherited from
ValidationlessFieldSet.subscribe
validation
validation:
Computed<FieldSetValidation> &object&undefinedextendsSchemaState?object:object
Defined in: form/reatomForm.ts:143
Atom with validation state of the form, computed from all the fields in
fieldsList
Type declaration
trigger
trigger:
Action<[],Promise<undefinedextendsSchemaState?Deatomize<FormFields<T>> :SchemaState>> &AsyncExt<[],any,undefined|Error> &AbortExt
Action to trigger form validation.
FormFieldOptions<State, Value>
Defined in: form/reatomForm.ts:46
Extends
FieldOptions<State,Value>
Type Parameters
State
State = any
Value
Value = State
Properties
disabled?
optionaldisabled:boolean
Defined in: form/reatomField.ts:223
Defines if the field is disabled by default.
Default
falseInherited from
elementRef?
optionalelementRef:FieldElementRef
Defined in: form/reatomField.ts:226
Defines a default element reference accosiated with the field.
Inherited from
filter()?
optionalfilter: (newValue,prevValue) =>boolean
Defined in: form/reatomField.ts:191
The callback to filter “value” changes (from the ‘change’ action). It
should return ‘false’ to skip the update. By default, it always returns
true.
Parameters
newValue
Value
prevValue
Value
Returns
boolean
Inherited from
fromState()?
optionalfromState: (state,self) =>Value
Defined in: form/reatomField.ts:197
The callback to compute the “value” data from the “state” data. By default, it returns the “state” data without any transformations.
Parameters
state
State
self
FieldAtom<State, Value>
Returns
Value
Inherited from
initState
initState:
State
Defined in: form/reatomForm.ts:48
isDirty()?
optionalisDirty: (newValue,prevValue) =>boolean
Defined in: form/reatomField.ts:203
The callback used to determine whether the “value” has changed. By default,
it utilizes isDeepEqual from reatom/utils.
Parameters
newValue
Value
prevValue
Value
Returns
boolean
Inherited from
keepErrorDuringValidating?
optionalkeepErrorDuringValidating:boolean
Defined in: form/reatomField.ts:233
Defines the reset behavior of the validation state during async validation.
Default
falseInherited from
FieldOptions.keepErrorDuringValidating
keepErrorOnChange?
optionalkeepErrorOnChange:boolean
Defined in: form/reatomField.ts:241
Defines the reset behavior of the validation state on field change. Useful if the validation is triggered on blur or submit only.
Default
!validateOnChangeInherited from
FieldOptions.keepErrorOnChange
name?
optionalname:string
Defined in: form/reatomField.ts:206
The name of the field and all related atoms and actions.
Inherited from
toState()?
optionaltoState: (value,self) =>State
Defined in: form/reatomField.ts:213
The callback to transform the “state” data from the “value” data from the
change action. By default, it returns the “value” data without any
transformations.
Parameters
value
Value
self
FieldAtom<State, Value>
Returns
State
Inherited from
validate?
optionalvalidate:FieldValidateOption<State,Value> |StandardSchemaV1<State,State>
Defined in: form/reatomField.ts:216
The callback to validate the field.
Inherited from
validateOnBlur?
optionalvalidateOnBlur:boolean
Defined in: form/reatomField.ts:255
Defines if the validation should be triggered on the field blur.
Default
falseInherited from
validateOnChange?
optionalvalidateOnChange:boolean
Defined in: form/reatomField.ts:248
Defines if the validation should be triggered with every field change.
Default
falseInherited from
FormOptionsWithoutSchema<T, SubmitReturn, SubmitParams>
Defined in: form/reatomForm.ts:250
Extends
Type Parameters
T
T extends FormInitState
SubmitReturn
SubmitReturn
SubmitParams
SubmitParams extends any[]
Properties
keepErrorDuringValidating?
optionalkeepErrorDuringValidating:boolean
Defined in: form/reatomForm.ts:190
Defines the default reset behavior of the validation state during async validation for all fields.
Default
falseInherited from
BaseFormOptions.keepErrorDuringValidating
keepErrorOnChange?
optionalkeepErrorOnChange:boolean
Defined in: form/reatomForm.ts:199
Defines the default reset behavior of the validation state on field change for all fields. Useful if the validation is triggered on blur or submit only.
Default
!validateOnChangeInherited from
BaseFormOptions.keepErrorOnChange
name?
optionalname:string
Defined in: form/reatomForm.ts:175
Inherited from
onSubmit()?
optionalonSubmit: (state, …params) =>SubmitReturn|Promise<SubmitReturn>
Defined in: form/reatomForm.ts:259
The callback to process valid form data, typed according to the raw form state
Parameters
state
Deatomize<FormFields<T>>
params
…SubmitParams
Returns
SubmitReturn | Promise<SubmitReturn>
resetOnSubmit?
optionalresetOnSubmit:boolean
Defined in: form/reatomForm.ts:182
Should reset the state after success submit?
Default
falseInherited from
schema?
optionalschema:undefined
Defined in: form/reatomForm.ts:279
Schema is explicitly disallowed or undefined in this variant
validate()?
optionalvalidate: (state) =>any
Defined in: form/reatomForm.ts:270
The callback to validate form fields before submit, typed according to the raw form state
Parameters
state
Deatomize<FormFields<T>>
Returns
any
Deprecated
Renamed to validateBeforeSubmit
validateBeforeSubmit()?
optionalvalidateBeforeSubmit: (state) =>any
Defined in: form/reatomForm.ts:276
The callback to validate form fields before submit, typed according to the raw form state
Parameters
state
Deatomize<FormFields<T>>
Returns
any
validateOnBlur?
optionalvalidateOnBlur:boolean
Defined in: form/reatomForm.ts:215
Defines if the validation should be triggered on the field blur by default for all fields.
Default
falseInherited from
BaseFormOptions.validateOnBlur
validateOnChange?
optionalvalidateOnChange:boolean
Defined in: form/reatomForm.ts:207
Defines if the validation should be triggered with every field change by default for all fields.
Default
falseInherited from
BaseFormOptions.validateOnChange
FormOptionsWithSchema<State, SubmitReturn, SubmitParams>
Defined in: form/reatomForm.ts:218
Extends
Type Parameters
State
State
SubmitReturn
SubmitReturn
SubmitParams
SubmitParams extends any[]
Properties
keepErrorDuringValidating?
optionalkeepErrorDuringValidating:boolean
Defined in: form/reatomForm.ts:190
Defines the default reset behavior of the validation state during async validation for all fields.
Default
falseInherited from
BaseFormOptions.keepErrorDuringValidating
keepErrorOnChange?
optionalkeepErrorOnChange:boolean
Defined in: form/reatomForm.ts:199
Defines the default reset behavior of the validation state on field change for all fields. Useful if the validation is triggered on blur or submit only.
Default
!validateOnChangeInherited from
BaseFormOptions.keepErrorOnChange
name?
optionalname:string
Defined in: form/reatomForm.ts:175
Inherited from
onSubmit()?
optionalonSubmit: (state, …params) =>SubmitReturn|Promise<SubmitReturn>
Defined in: form/reatomForm.ts:224
The callback to process valid form data, typed according to the schema
Parameters
state
State
params
…SubmitParams
Returns
SubmitReturn | Promise<SubmitReturn>
resetOnSubmit?
optionalresetOnSubmit:boolean
Defined in: form/reatomForm.ts:182
Should reset the state after success submit?
Default
falseInherited from
schema
schema:
StandardSchemaV1<unknown,State>
Defined in: form/reatomForm.ts:247
The schema which supports StandardSchemaV1 specification to validate form fields.
validate()?
optionalvalidate: (state) =>any
Defined in: form/reatomForm.ts:235
The callback to validate form fields before submit, typed according to the schema
Parameters
state
State
Returns
any
Deprecated
Renamed to validateBeforeSubmit
validateBeforeSubmit()?
optionalvalidateBeforeSubmit: (state) =>any
Defined in: form/reatomForm.ts:241
The callback to validate form fields before submit, typed according to the schema
Parameters
state
State
Returns
any
validateOnBlur?
optionalvalidateOnBlur:boolean
Defined in: form/reatomForm.ts:215
Defines if the validation should be triggered on the field blur by default for all fields.
Default
falseInherited from
BaseFormOptions.validateOnBlur
validateOnChange?
optionalvalidateOnChange:boolean
Defined in: form/reatomForm.ts:207
Defines if the validation should be triggered with every field change by default for all fields.
Default
falseInherited from
BaseFormOptions.validateOnChange
ValidationAtom()
Defined in: form/reatomField.ts:84
Base atom interface for other userspace implementations. This is the core interface that all atom-like objects implement, providing the foundation for Reatom’s reactivity system.
Extends
ValidationAtom(…
params):FieldValidation
Defined in: form/reatomField.ts:84
Base atom interface for other userspace implementations. This is the core interface that all atom-like objects implement, providing the foundation for Reatom’s reactivity system.
Parameters
params
…any[]
Parameters to pass to the atom
Returns
The atom’s payload (typically its current state)
Properties
__reatom
__reatom:
AtomMeta
Defined in: core/atom.ts:106
Reference to the atom’s internal metadata.
Inherited from
actions
actions:
Actions<ValidationAtom>
Defined in: core/atom.ts:86
Bind methods to the atom to extend its functionality.
Deprecated
Use extend instead
Inherited from
clearErrors
clearErrors:
Action<FieldErrorSource[],FieldValidation>
Defined in: form/reatomField.ts:92
Action to clear all errors by passed sources.
errors
errors:
ArrayAtom<FieldError<any>>
Defined in: form/reatomField.ts:89
Full list of all errors related to the field
extend
extend:
Extend<ValidationAtom>
Defined in: core/atom.ts:92
Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.
Inherited from
set
set:
unknown
Defined in: core/atom.ts:79
Inherited from
subscribe()
subscribe: (
cb?) =>Unsubscribe
Defined in: core/atom.ts:103
Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.
Parameters
cb?
(state) => any
Callback function that receives the atom’s state when it changes
Returns
An unsubscribe function that removes the subscription when called
Inherited from
trigger
trigger:
Action<[],FieldValidation> &AbortExt
Defined in: form/reatomField.ts:86
Action to trigger field validation.
ValidationlessFieldSet()<T>
Defined in: form/reatomFieldSet.ts:40
Derived state container.
A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.
Extends
Extended by
Type Parameters
T
T extends FormInitState
The type of derived state
ValidationlessFieldSet(…
params):Deatomize
Defined in: form/reatomFieldSet.ts:40
Derived state container.
A computed atom automatically tracks dependencies and recalculates only when those dependencies change. The calculation is performed lazily, only when the computed value is read AND subscribed to.
Parameters
params
…[]
Parameters to pass to the atom
Returns
The atom’s payload (typically its current state)
Properties
__reatom
__reatom:
AtomMeta
Defined in: core/atom.ts:106
Reference to the atom’s internal metadata.
Inherited from
actions
actions:
Actions<ValidationlessFieldSet<T>>
Defined in: core/atom.ts:86
Bind methods to the atom to extend its functionality.
Deprecated
Use extend instead
Inherited from
extend
extend:
Extend<ValidationlessFieldSet<T>>
Defined in: core/atom.ts:92
Extension system to add capabilities to atoms. Allows adding middleware, methods, or other functionality to modify atom behavior.
Inherited from
fieldArraysList
fieldArraysList:
Computed<FormFieldArrayAtom[]>
Defined in: form/reatomFieldSet.ts:49
Computed list of all the field arrays from the fields tree
fields
fields:
FormFields<T>
Defined in: form/reatomFieldSet.ts:43
Fields from the init state
fieldsList
Defined in: form/reatomFieldSet.ts:46
Computed list of all the fields from the fields tree
fieldsState
fieldsState:
Computed<Deatomize<FormFields<T>>>
Defined in: form/reatomFieldSet.ts:57
Atom with the state of the fieldset, computed from all the fields in
fieldsList
Deprecated
Use target atom instead
focus
focus:
Computed<FieldFocus>
Defined in: form/reatomFieldSet.ts:63
Atom with focus state of the fieldset, computed from all the fields in
fieldsList
init
init:
Action<[DeepPartial<Deatomize<FormFields<T>>,unknown[]>],void>
Defined in: form/reatomFieldSet.ts:66
Action to set initial values for each field or field array in the fieldset
reset
reset:
Action<[DeepPartial<Deatomize<FormFields<T>>,unknown[]>],void>
Defined in: form/reatomFieldSet.ts:69
Action to reset the state, the value, the validation, and the focus states.
set
set:
unknown
Defined in: core/atom.ts:79
Inherited from
subscribe()
subscribe: (
cb?) =>Unsubscribe
Defined in: core/atom.ts:103
Subscribe to state changes, with the first call happening immediately. When a subscriber is added, the callback is immediately invoked with the current state. After that, it’s called whenever the atom’s state changes.
Parameters
cb?
(state) => any
Callback function that receives the atom’s state when it changes
Returns
An unsubscribe function that removes the subscription when called
Inherited from
Type Aliases
ArrayFieldItem<T>
ArrayFieldItem<
T> =TextendsLinkedListLikeAtom<infer _Node> ?AtomState<T["array"]>[number] :never
Defined in: form/reatomForm.ts:419
Type Parameters
T
T
DeepPartial<T, Skip>
DeepPartial<
T,Skip> ={ [K in keyof T]?: T[K] extends Skip ? T[K] : T[K] extends Rec ? DeepPartial<T[K], Skip> : T[K] }
Defined in: form/reatomForm.ts:117
Type Parameters
T
T
Skip
Skip = never
FieldErrorSource
FieldErrorSource =
"validation"|string&object
Defined in: form/reatomField.ts:55
FieldValidateOption()<State, Value>
FieldValidateOption<
State,Value> = (meta) =>FieldValidateOptionResult<State> |Promise<FieldValidateOptionResult<State>>
Defined in: form/reatomField.ts:167
Type Parameters
State
State = any
Value
Value = State
Parameters
meta
focus
state
State
validation
value
Value
Returns
FieldValidateOptionResult<State> | Promise<FieldValidateOptionResult<State>>
FieldValidateOptionResult<State>
FieldValidateOptionResult<
State> =string|string[] |FieldErrorBody|FieldErrorBody[] |StandardSchemaV1<State> |void|undefined
Defined in: form/reatomField.ts:176
Type Parameters
State
State = any
FormFieldArrayAtom<Param, Node>
FormFieldArrayAtom<
Param,Node> =LinkedListAtom<[ExtractFieldArray<Param>],FormFieldElement<Node>> &object
Defined in: form/reatomForm.ts:77
Type declaration
initState
initState:
Atom<LinkedList<LLNode<FormFieldElement<Node>>>>
reset
reset:
Action<[],AtomState<FormFieldArrayAtom<Param,Node>>>
Type Parameters
Param
Param = any
Node
Node extends FormInitStateElement = FormInitStateElement
FormFieldElement<T>
FormFieldElement<
T> =TextendsFieldLikeAtom?T:TextendsDate?FieldAtom<T> :Textends infer Item[] ?ItemextendsFormInitStateElement?FormFieldArrayAtom<Item,Item> :never:TextendsFormFieldArray<infer Param, infer Node> ?FormFieldArrayAtom<Param,Node> :TextendsFieldOptions&object?TextendsFieldOptions<State,State> ?FieldAtom<State> :TextendsFieldOptions<State, infer Value> ?FieldAtom<State,Value> :objectextendsT?FieldAtom<State,State> :never:TextendsRec<unknown> ?{ [K in keyof T]: FormFieldElement<T[K]> }:FieldAtom<T>
Defined in: form/reatomForm.ts:85
Type Parameters
T
T extends FormInitStateElement | unknown = FormInitStateElement
FormFields<T>
FormFields<
T> ={ [K in keyof T]: FormFieldElement<T[K]> }
Defined in: form/reatomForm.ts:109
Type Parameters
T
T extends FormInitState = FormInitState
FormInitState
FormInitState =
object
Defined in: form/reatomForm.ts:67
Index Signature
[key: string]: FormInitStateElement | FormInitState
FormPartialState<T>
FormPartialState<
T> =DeepPartial<FormState<T>,unknown[]>
Defined in: form/reatomForm.ts:124
Type Parameters
T
T extends FormInitState = FormInitState
FormState<T>
FormState<
T> =Deatomize<FormFields<T>>
Defined in: form/reatomForm.ts:113
Type Parameters
T
T extends FormInitState = FormInitState
SubmitAction<Return, Params>
SubmitAction<
Return,Params> =Action<Params,Promise<Return>> &AsyncDataExt<Params,Return,Return|undefined,Error|undefined>
Defined in: form/reatomForm.ts:127
Type Parameters
Return
Return
Params
Params extends any[]
Variables
fieldInitFocus
constfieldInitFocus:FieldFocus
Defined in: form/reatomField.ts:258
fieldInitValidation
constfieldInitValidation:FieldValidation
Defined in: form/reatomField.ts:264
fieldInitValidationLess
constfieldInitValidationLess:FieldValidation
Defined in: form/reatomField.ts:270
Functions
experimental_fieldArray()
Call Signature
experimental_fieldArray<
Param>(initState):FormFieldArray<Param,Param>
Defined in: form/reatomForm.ts:369
Type Parameters
Param
Param extends FormInitStateElement
Parameters
initState
Param[]
Returns
FormFieldArray<Param, Param>
Call Signature
experimental_fieldArray<
Param,Node>(create):FormFieldArray<Param,Node>
Defined in: form/reatomForm.ts:373
Type Parameters
Param
Param
Node
Node extends FormInitStateElement = FormInitStateElement
Parameters
create
(params, name) => Node
Returns
FormFieldArray<Param, Node>
Call Signature
experimental_fieldArray<
Param,Node>(options):FormFieldArray<Param,Node>
Defined in: form/reatomForm.ts:378
Type Parameters
Param
Param
Node
Node extends FormInitStateElement = FormInitStateElement
Parameters
options
create
(param, name) => Node
initState?
Param[]
Returns
FormFieldArray<Param, Node>
isFieldAtom()
isFieldAtom(
thing):thing is FieldLikeAtom<any>
Defined in: form/reatomField.ts:641
Parameters
thing
any
Returns
thing is FieldLikeAtom<any>
reatomField()
Call Signature
reatomField<
State>(_initState,options?):FieldAtom<State,State>
Defined in: form/reatomField.ts:276
Type Parameters
State
State
Parameters
_initState
State
options?
string | FieldOptions<State, State>
Returns
FieldAtom<State, State>
Call Signature
reatomField<
State,Value>(_initState,options?):FieldAtom<State,Value>
Defined in: form/reatomField.ts:281
Type Parameters
State
State
Value
Value
Parameters
_initState
State
options?
string | FieldOptions<State, Value>
Returns
FieldAtom<State, Value>
Call Signature
reatomField<
State,A,Value>(_initState,options,stateAtom):A&FieldAtom<State,Value>
Defined in: form/reatomField.ts:286
Type Parameters
State
State
A
A extends Atom<State, [State]>
Value
Value = State
Parameters
_initState
State
options
string | FieldOptions<State, Value>
stateAtom
A
Returns
A & FieldAtom<State, Value>
reatomFieldSet()
reatomFieldSet<
T>(fields,name):FieldSet<T>
Defined in: form/reatomFieldSet.ts:84
Type Parameters
T
T extends FormInitState
Parameters
fields
FormFields<T>
name
string = ...
Returns
FieldSet<T>
reatomForm()
Call Signature
reatomForm<
T,SchemaState,SubmitReturn,SubmitParams>(initState,optionsWithSchema):Form<T,SchemaState,SubmitReturn,SubmitParams>
Defined in: form/reatomForm.ts:452
Type Parameters
T
T extends FormInitState
SchemaState
SchemaState
SubmitReturn
SubmitReturn
SubmitParams
SubmitParams extends any[]
Parameters
initState
T | (name) => T
optionsWithSchema
FormOptionsWithSchema<SchemaState, SubmitReturn, SubmitParams>
Returns
Form<T, SchemaState, SubmitReturn, SubmitParams>
Call Signature
reatomForm<
T,SubmitReturn,SubmitParams>(initState,options?):Form<T,undefined,SubmitReturn,SubmitParams>
Defined in: form/reatomForm.ts:466
Type Parameters
T
T extends FormInitState
SubmitReturn
SubmitReturn
SubmitParams
SubmitParams extends any[]
Parameters
initState
T | (name) => T
options?
FormOptionsWithoutSchema<T, SubmitReturn, SubmitParams>
Returns
Form<T, undefined, SubmitReturn, SubmitParams>
Call Signature
reatomForm<
T>(initState,name?):Form<T,undefined,void, []>
Defined in: form/reatomForm.ts:475
Type Parameters
T
T extends FormInitState
Parameters
initState
T | (name) => T
name?
string
Returns
Form<T, undefined, void, []>
withField()
Call Signature
withField<
T>(options?): (anAtom) =>T&FieldAtom<AtomState<T>,AtomState<T>>
Defined in: form/reatomField.ts:626
Type Parameters
T
T extends Atom<any, [any]>
Parameters
options?
Omit<FieldOptions<AtomState<T>, AtomState<T>>, "name">
Returns
Parameters
anAtom
T
Returns
T & FieldAtom<AtomState<T>, AtomState<T>>
Call Signature
withField<
T,Value>(options?): (anAtom) =>T&FieldAtom<AtomState<T>,Value>
Defined in: form/reatomField.ts:630
Type Parameters
T
T extends Atom<any, [any]>
Value
Value
Parameters
options?
Omit<FieldOptions<AtomState<T>, Value>, "name">
Returns
Parameters
anAtom
T