Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IKomoBase<T>

The base API interface used by form field elements and form submit, reset handlers.

Type parameters

Hierarchy

  • IKomoBase

Index

Properties

defaults

defaults: MutableRefObject<T>

React MutableRefObject of default model values.

errors

errors: MutableRefObject<ErrorModel<T>>

React MutableRefObject of errors.

fields

fields: MutableRefObject<Set<IRegisteredElement<T>>>

React MutableRefObject of registered elements.

hasInit

hasInit: MutableRefObject<boolean>

React MutableRefObject indicating if form/Komo is mounted.

model

model: MutableRefObject<T>

React MutableRefObject of active model values.

mounted

mounted: MutableRefObject<boolean>

React MutableRefObject indicating if form/Komo is mounted.

options

options: IOptions<T>

Komo initialization options.

schemaAst

schemaAst: MutableRefObject<ISchemaAst>

React MutableRefObject of native validation AST schema configurations.

state

state: IFormState<T>

Object containing active state of the form.

submitCount

submitCount: MutableRefObject<number>

React MutableRefObject indicating the form submission count.

submitted

submitted: MutableRefObject<boolean>

React MutableRefObject indicating if form has submitted.

submitting

submitting: MutableRefObject<boolean>

React MutableRefObject indicating if form is submitting.

unregistered

unregistered: MutableRefObject<string[]>

List of unregistered element names.

validator

validator: IValidator<T>

The normalized validation interface used to validate model and model paths.

Methods

clearDirty

  • clearDirty(): void
  • Clears all dirty field/elements.

    Returns void

clearError

  • clearError(): void
  • Clears all errors from error model.

    Returns void

clearTouched

  • clearTouched(): void
  • Clears all touched field/elements.

    Returns void

getDefault

  • getDefault(path?: string): any
  • Gets the default value at a given model path or all default model values.

    Parameters

    • Optional path: string

      the path to get the default for.

    Returns any

getElement

  • Finds field by element used here for normalization.

    Parameters

    Returns IRegisteredElement<T>

  • Finds a field/element by name or path.

    Parameters

    • nameOrPath: string

      the name or path used to lookup element.

    • asGroup: boolean

      when true will return all matching names such as in a radio group.

    Returns IRegisteredElement<T>[]

  • Finds a field/element by name or path.

    Parameters

    • nameOrPath: string

      the name or path used to lookup element.

    Returns IRegisteredElement<T>

getModel

  • getModel(path: string): any
  • getModel(clean?: boolean): T
  • Gets the model value at the specified path.

    Parameters

    • path: string

      the path to get model at.

    Returns any

  • Gets the entire model.

    Parameters

    • Optional clean: boolean

    Returns T

getRegistered

  • getRegistered(asPath?: boolean): KeyOf<T>[]
  • getRegistered(): KeyOf<T>[]
  • Gets the registered paths.

    Parameters

    • Optional asPath: boolean

      when true registered paths are returned.

    Returns KeyOf<T>[]

  • Gets the registered names.

    Returns KeyOf<T>[]

hasModel

  • hasModel(path: string): any
  • Checks if model contains prop at path.

    Parameters

    • path: string

      the path to check if exists.

    Returns any

initSchema

  • initSchema(): T
  • Initializes and normalizes the schema.

    Returns T

isDirty

  • isDirty(name?: KeyOf<T>): boolean
  • Checks if field/element is dirty.

    Parameters

    • Optional name: KeyOf<T>

      the name of the form field/element.

    Returns boolean

isDirtyCompared

  • isDirtyCompared(name: KeyOf<T>, value?: any, defautlValue?: any): boolean
  • Compares value to default value return if has changed and is dirty.

    Parameters

    • name: KeyOf<T>

      a form element name.

    • Optional value: any

      the value to be compared to default.

    • Optional defautlValue: any

      the default data in model.

    Returns boolean

isTouched

  • isTouched(name?: KeyOf<T>): boolean
  • Checks if field/element is touched.

    Parameters

    • Optional name: KeyOf<T>

      the name of the form field/element.

    Returns boolean

isValidatable

  • isValidatable(): boolean
  • Indicates if form supports validation.

    Returns boolean

isValidateBlur

  • Inspect element and checks if validation blur is enabled.

    Parameters

    Returns boolean

  • Inspect element and checks if validation change is enabled looking up by field name.

    Parameters

    • name: KeyOf<T>

      the element name to be looked up.

    Returns boolean

isValidateChange

  • Inspect element and checks if validation change is enabled.

    Parameters

    Returns boolean

  • Inspect element and checks if validation change is enabled looking up by field name.

    Parameters

    • name: KeyOf<T>

      the element name to be looked up.

    Returns boolean

removeDirty

  • removeDirty(name: KeyOf<T>): boolean
  • Removes form field/element as dirty.

    Parameters

    Returns boolean

removeError

  • removeError(name: KeyOf<T>): boolean
  • Removes error for the specified field/element by name.

    Parameters

    • name: KeyOf<T>

      the name of the field/element to remove error for.

    Returns boolean

removeTouched

  • removeTouched(name: KeyOf<T>): void
  • Removes form field/element as touched.

    Parameters

    Returns void

render

  • render(status?: string): void
  • Triggers rerendering of the form.

    Parameters

    • Optional status: string

      the status state calling the render.

    Returns void

setDefault

  • setDefault(path: string, value: any): void
  • setDefault(model: T, extend?: boolean): void
  • Sets the default value at the specified. path.

    Parameters

    • path: string

      the path to be set.

    • value: any

      the value to be set at path.

    Returns void

  • Sets the default model.

    Parameters

    • model: T

      the model complete model to be set.

    • Optional extend: boolean

      whether to merge/extend with existing model.

    Returns void

setDirty

  • setDirty(name: KeyOf<T>): void
  • Sets form field/element as dirty.

    Parameters

    • name: KeyOf<T>

      the name of the form field/element.

    Returns void

setError

  • Sets field/element error.

    Parameters

    • name: KeyOf<T>

      the field/element name to set error for.

    • value: any

      the error value to be set.

    Returns ErrorModel<T>

  • Sets complete error model.

    Parameters

    • errors: ErrorModel<T>

      the error model to be set.

    • Optional extend: boolean

      whether to extend/merge with existing errors.

    Returns ErrorModel<T>

setModel

  • setModel(path: string, value: any): void
  • setModel(model: T, extend?: boolean): void
  • Sets model value at the specified path.

    Parameters

    • path: string

      the path to set value at.

    • value: any

      the value to be sat at path.

    Returns void

  • Sets the complete model.

    Parameters

    • model: T

      the model to be set.

    • Optional extend: boolean

      when true extends/merges with existing model.

    Returns void

setTouched

  • setTouched(name: KeyOf<T>): void
  • Sets form field/element as touched.

    Parameters

    • name: KeyOf<T>

      the name of the form field/element.

    Returns void

syncDefaults

  • syncDefaults(defaults: T, isReinit?: boolean): void
  • Updaetes default values from synchronizing with model and elements.

    Parameters

    • defaults: T

      the defaults to sync.

    • Optional isReinit: boolean

      indicates defaults are reinitializing.

    Returns void

unregister

  • Unregisters an element by instance.

    Parameters

    Returns void

  • Unregisters an element by name or path.

    Parameters

    • name: KeyOf<T>

      the element name to lookup to be unregistered.

    Returns void

validateModel

  • Validates the specified model.

    Parameters

    • Optional options: ValidateOptions

      the yup validation options if any to pass.

    Returns PromiseStrict<T, ErrorModel<T>>

validateModelAt

  • Validates model for the specified element.

    Parameters

    • element: IRegisteredElement<T>

      the element to be validated.

    • Optional options: ValidateOptions

      the yup validation options if any to pass.

    Returns PromiseStrict<Partial<T>, Partial<ErrorModel<T>>>

  • Validates model for the specified element.

    Parameters

    • name: KeyOf<T>

      the name of the element to lookup and validate.

    • Optional options: ValidateOptions

      the yup validation options if any to pass.

    Returns PromiseStrict<Partial<T>, Partial<ErrorModel<T>>>

Generated using TypeDoc