VoidField
The VoidField model returned by createVoidField.
All model properties are listed below. If a property is writable, assigning to it directly will trigger @formily/reactive and update the UI.
Properties
| Property | Description | Type | Readonly | Default |
|---|---|---|---|---|
| initialized | Whether the field has been initialized | Boolean | No | false |
| mounted | Whether the field has been mounted | Boolean | No | false |
| unmounted | Whether the field has been unmounted | Boolean | No | false |
| address | Field node path | FormPath | Yes | |
| path | Field data path | FormPath | Yes | |
| title | Field title | Any (determined by the generic TextType) | No | "" |
| description | Field description | Any (determined by the generic TextType) | No | "" |
| data | Extended field data | Object | No | null |
| content | Field content | any | No | null |
| decorator | Field decorator | Any[] | No | null |
| component | Field component | Any[] | No | null |
| parent | Parent field | GeneralField | Yes | null |
| display | Field display state | FieldDisplayTypes | No | "visible" |
| pattern | Field interaction mode | FieldPatternTypes | No | "editable" |
| hidden | Whether the field is hidden | Boolean | No | false |
| visible | Whether the field is visible | Boolean | No | true |
| disabled | Whether the field is disabled | Boolean | No | false |
| readOnly | Whether the field is read-only | Boolean | No | false |
| readPretty | Whether the field is in read-pretty mode | Boolean | No | false |
| editable | Whether the field is editable | Boolean | No | true |
| indexes | Numeric index collection | Number[] | Yes | - |
| index | Numeric index | Number | Yes | - |
Detailed Explanations
hidden
When true, display is hidden; when false, display is visible.
visible
When true, display is visible; when false, display is none.
Methods
setTitle
Description
Sets the field title.
Signature
interface setTitle {
(title?: any): void
}setDescription
Description
Sets the field description.
Signature
interface setDescription {
(title?: any): void
}setDisplay
Description
Sets the field display state.
Signature
interface setDisplay {
(display?: FieldDisplayTypes): void
}FieldDisplayTypes reference: FieldDisplayTypes
setPattern
Description
Sets the field interaction mode.
Signature
interface setPattern {
(pattern?: FieldPatternTypes): void
}FieldPatternTypes reference: FieldPatternTypes
setComponent
Description
Sets the field component.
Signature
interface setComponent {
(component?: FieldComponent, props?: any): void
}FieldComponent reference: FieldComponent
setComponentProps
Description
Sets the field component props.
Signature
interface setComponentProps {
(props?: any): void
}setDecorator
Description
Sets the field decorator.
Signature
interface setDecorator {
(decorator?: FieldDecorator, props?: any): void
}FieldDecorator reference: FieldDecorator
setDecoratorProps
Description
Sets the field decorator props.
Signature
interface setDecoratorProps {
(props?: any): void
}setState
Description
Sets field state.
Signature
interface setState {
(state: IVoidFieldState): void
(callback: (state: IVoidFieldState) => void): void
}IVoidFieldState reference: IVoidFieldState
getState
Description
Gets field state.
Signature
interface getState<T> {
(): IVoidFieldState
(callback: (state: IVoidFieldState) => T): T
}IVoidFieldState reference: IVoidFieldState
setData
Description
Sets the data value.
Signature
interface setData {
(data: any): void
}setContent
Description
Sets the content value.
Signature
interface setContent {
(content: any): void
}onInit
Description
Triggers field initialization. Usually there is no need to call it manually.
Signature
interface onInit {
(): void
}onMount
Description
Triggers field mount.
Signature
interface onMount {
(): void
}onUnmount
Description
Triggers field unmount.
Signature
interface onUnmount {
(): void
}query
Description
Queries fields. You can query neighboring fields relative to the current field.
Signature
interface query {
(pattern: FormPathPattern): Query
}For the FormPathPattern API, see FormPath.
For the Query object API, see Query.
dispose
Description
Disposes the observer. Usually there is no need to call it manually.
Signature
interface dispose {
(): void
}destroy
Description
Disposes the observer and removes the field model.
Signature
interface destroy {
(): void
}match
Description
Matches the field by path.
Signature
interface match {
(pattern: FormPathPattern): boolean
}For the FormPathPattern API, see FormPath.
inject
Description
Injects executable methods into the field model.
Signature
interface inject {
(actions: Record<string, (...args: any[]) => any>): void
}invoke
Description
Calls an executable method that was injected into the field model via inject.
Signature
interface invoke {
(name: string, ...args: any[]): any
}Types
TextType
type TextType = anyAt the core layer, VoidField does not independently constrain the message types for title and description. Instead, it delegates them upward through the generic TextType.
FieldComponent
type FieldComponent = string | JSXComponentConstructorField component. In frameworks that support JSX, FieldComponent is best stored as a direct JSX component reference. Otherwise, it can store a component identifier string and be dispatched during rendering.
FieldDecorator
type FieldDecorator = string | JSXComponentConstructorField decorator. In frameworks that support JSX, FieldDecorator is best stored as a direct JSX component reference. Otherwise, it can store a component identifier string and be dispatched during rendering.
FieldReaction
type FieldReaction = (field: GeneralField) => voidFieldDisplayTypes
type FieldDisplayTypes = 'none' | 'hidden' | 'visible'FieldPatternTypes
type FieldPatternTypes = 'editable' | 'disabled' | 'readOnly' | 'readPretty'GeneralField
type GeneralField = Field | VoidField | ArrayField | ObjectFieldField reference: Field
ArrayField reference: ArrayField
ObjectField reference: ObjectField
IVoidFieldState
interface IVoidFieldState {
selfDisplay?: FieldDisplayTypes
selfPattern?: FieldPatternTypes
content?: any
data?: any
decoratorType?: any
decoratorProps?: Record<string, any>
componentType?: any
componentProps?: Record<string, any>
designable?: boolean
hidden?: boolean
visible?: boolean
editable?: boolean
readOnly?: boolean
disabled?: boolean
readPretty?: boolean
title?: any
description?: any
initialized?: boolean
mounted?: boolean
unmounted?: boolean
decorator?: FieldDecorator
component?: FieldComponent
display?: FieldDisplayTypes
pattern?: FieldPatternTypes
index?: number
indexes?: number[]
}IGeneralFieldState
type IGeneralFieldState = IVoidFieldState & IFieldStateIFieldState reference: IFieldState