CheckboxField
Source: Form.ts:515
Checkbox field component
Constructors
new CheckboxField(props: CheckboxFieldProps): CheckboxField
Parameters
props(CheckboxFieldProps) — Initial component props
Returns
CheckboxField
Hierarchy
FormFieldCheckboxField
Properties
_internalState: FormFieldState
Inherited from _internalState
Component internal state
_props: CheckboxFieldProps
Inherited from _props
Component props
children: Component<ComponentProps, object>[]
Inherited from children
Child components
Default: []
instanceId: string
Inherited from instanceId
Unique component instance ID
parent: Component<ComponentProps, object>
Inherited from parent
Parent component reference
Accessors
get hasErrors(): boolean
Inherited from hasErrors
Whether the field has validation errors
get internalState(): Readonly<S>
Inherited from internalState
Gets the internal component state
get isDirty(): boolean
Inherited from isDirty
Whether the field has been modified
get isTouched(): boolean
Inherited from isTouched
Whether the field has been touched
get props(): Readonly<P>
Inherited from props
Gets the current props
get state(): ComponentState
Inherited from state
Gets the current component lifecycle state
Methods
addChild(child: Component): void
Inherited from addChild
Adds a child component
Parameters
child(Component) — Child component to add
Returns
void
checkRule(rule: ValidationRule, value: boolean): boolean
Inherited from checkRule
Checks a single validation rule
Parameters
rule(ValidationRule) — Rule to checkvalue(boolean) — Value to validate
Returns
boolean— True if rule passes
emit<T>(type: string, data?: T): void
Inherited from emit
Emits an event
Type Parameters
T— Event data type
Parameters
type(string) — Event typedata(T, optional) — Event data
Returns
void
Example
this.emit('valueChange', { oldValue: 1, newValue: 2 })findChildById(
id: string,
): Component<ComponentProps, object> | undefined
Inherited from findChildById
Finds a child component by ID
Parameters
id(string) — Component ID to find
Returns
Component<ComponentProps, object> | undefined— Found component or undefined
formatValue(value: boolean): string
Inherited from formatValue
Formats the value for display
Parameters
value(boolean) — Value to format
Returns
string— Formatted string
getDefaultValue(): boolean
Overrides getDefaultValue
Gets the default value for this field type
Returns
boolean— Default value
getInitialState(): FormFieldState
Inherited from getInitialState
Gets the initial state
Returns
FormFieldState— Initial field state
getValue(): boolean
Inherited from getValue
Gets the current field value
Returns
boolean— Current value
handleBlur(): void
Inherited from handleBlur
Handles field blur
Returns
void
handleChange(rawValue: unknown): void
Inherited from handleChange
Handles input change event
Parameters
rawValue(unknown) — Raw input value
Returns
void
handleFocus(): void
Inherited from handleFocus
Handles field focus
Returns
void
isEmpty(value: boolean): boolean
Overrides isEmpty
Checks if a value is empty
Parameters
value(boolean) — Value to check
Returns
boolean— True if empty
mount(): void
Inherited from mount
Mounts the component
Returns
void
off(event: string, handler: ComponentEventHandler): void
Inherited from off
Removes an event listener
Parameters
event(string) — Event typehandler(ComponentEventHandler) — Event handler to remove
Returns
void
on<
T,
>(
event: string,
handler: ComponentEventHandler<T>,
): () => void
Inherited from on
Adds an event listener
Type Parameters
T— Event data type
Parameters
event(string) — Event typehandler(ComponentEventHandler<T>) — Event handler
Returns
() => void— Function to remove the listener
Example
const off = button.on('click', (event) => {
console.log('Button clicked!', event.data)
})
// Later: remove listener
off()onBeforeMount(): void
Inherited from onBeforeMount
Called before component mounts
Returns
void
onBeforeUnmount(): void
Inherited from onBeforeUnmount
Called before component unmounts
Returns
void
onBeforeUpdate(
_prevProps: ComponentProps,
_nextProps: ComponentProps,
): void
Inherited from onBeforeUpdate
Called before component updates
Parameters
_prevProps(ComponentProps)_nextProps(ComponentProps)
Returns
void
onError(_error: Error): void
Inherited from onError
Called when an error occurs in the component
Parameters
_error(Error)
Returns
void
onMounted(): void
Inherited from onMounted
Called after component mounts
Returns
void
onStateChange(
_prevState: FormFieldState,
_newState: FormFieldState,
): void
Inherited from onStateChange
Called when internal state changes
Parameters
_prevState(FormFieldState)_newState(FormFieldState)
Returns
void
onUnmounted(): void
Inherited from onUnmounted
Called after component unmounts
Returns
void
onUpdated(_prevProps: ComponentProps): void
Inherited from onUpdated
Called after component updates
Parameters
_prevProps(ComponentProps)
Returns
void
parseValue(rawValue: unknown): boolean
Overrides parseValue
Parses raw input value to the field's value type
Parameters
rawValue(unknown) — Raw input value
Returns
boolean— Parsed value
removeChild(child: Component): boolean
Inherited from removeChild
Removes a child component
Parameters
child(Component) — Child component to remove
Returns
boolean— True if child was removed
render(): string
Overrides render
Renders the component
Returns
string— Rendered output
reset(): void
Inherited from reset
Resets the field to its default state
Returns
void
setProps(nextProps: Partial<P>): void
Inherited from setProps
Updates component props
Parameters
nextProps(Partial<P>) — New props
Returns
void
setState(updates: Partial<S>): void
Inherited from setState
Updates the internal state
Parameters
updates(Partial<S>) — Partial state updates
Returns
void
Example
this.setState({ count: this.internalState.count + 1 })setValue(value: boolean, options: { validate?: boolean }): void
Inherited from setValue
Sets the field value
Parameters
value(boolean) — New valueoptions({ validate?: boolean }, default: "{}") — Set options
Properties
validate(boolean, optional)
Returns
void
unmount(): void
Inherited from unmount
Unmounts the component
Returns
void
update(): void
Inherited from update
Updates the component
Returns
void
validate(): ValidationResult
Inherited from validate
Validates the current field value
Returns
ValidationResult— Validation result
Example
const result = field.validate()
if (!result.valid) {
console.log('Errors:', result.errors)
}