VoidField
The VoidField model returned by createVoidField.
The main public model properties are listed below. Assigning to writable properties directly will trigger @silver-formily/reactive and update the UI.
Properties
| Property | Description | Type | Readonly | Default |
|---|---|---|---|---|
| initialized | Whether the field has been initialized | Boolean | No | true |
| 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 | undefined |
| description | Field description | Any (determined by the generic TextType) | No | undefined |
| data | Extended field data | Object | No | undefined |
| content | Field content | any | No | undefined |
| decoratorContent 1.1.0 | Decorator slot content | any | No | undefined |
| decorator | Field decorator | Any[] | No | [undefined, {}] |
| component | Field component | Any[] | No | [undefined, {}] |
| parent | Parent field | GeneralField | Yes | undefined |
| 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
initialized
During VoidField construction, this state is first set to false. After field location, state initialization, and reactive bindings are ready, the constructor immediately calls onInit(), which sets it to true and emits the onFieldInit lifecycle. Therefore, a field returned by form.createVoidField() already has initialized === true.
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
}setDecoratorContent 1.1.0
Description
Sets decorator content. The Vue binding reactively renders it as decorator slot content.
Signature
interface setDecoratorContent {
(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 | RegExp): 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 {
(forceClear?: boolean): 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<Component extends JSXComponent, ComponentProps = any>
= | [Component]
| [Component, ComponentProps]
| boolean
| any[]Field components are runtime configuration slots, usually passed as a [component, props] tuple. Boolean values and other array shapes may also be interpreted by an upper-layer adapter.
FieldDecorator
type FieldDecorator<Decorator extends JSXComponent, DecoratorProps = any>
= | [Decorator]
| [Decorator, DecoratorProps]
| boolean
| any[]Field decorators use the same runtime storage shape as FieldComponent.
FieldReaction
type FieldReaction = (field: GeneralField) => voidFieldDisplayTypes
type FieldDisplayTypes = 'none' | 'hidden' | 'visible' | ({} & string)FieldPatternTypes
type FieldPatternTypes
= | 'editable'
| 'readOnly'
| 'disabled'
| 'readPretty'
| ({} & string)GeneralField
type GeneralField = Field | VoidField | ArrayField | ObjectFieldField reference: Field
ArrayField reference: ArrayField
ObjectField reference: ObjectField
IVoidFieldState
interface IVoidFieldState {
selfDisplay?: FieldDisplayTypes
selfPattern?: FieldPatternTypes
content?: any
decoratorContent?: 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