Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Class: Store

@react-form-builder/core.Store

The form viewer settings. Internal use only.

Implements

Constructors

constructor

new Store(formViewerPropsStore, parentStore?, parentComponentStore?)

Creates form viewer settings.

Parameters

NameTypeDescription
formViewerPropsStoreFormViewerPropsStorethe form viewer store settings.
parentStore?Storethe form viewer settings, used in templates.
parentComponentStore?ComponentStorethe parent component settings.

Properties

eventSubject

Readonly eventSubject: Subject<ActionEventArgs>

The Subject for submitting form events.


form

form: Form

The form.

Implementation of

IStore.form


formViewerPropsStore

formViewerPropsStore: FormViewerPropsStore

the form viewer store settings.


parentComponentStore

Optional Readonly parentComponentStore: ComponentStore

the parent component settings.


parentStore

Optional Readonly parentStore: Store

the form viewer settings, used in templates.


selectedLanguage

Optional selectedLanguage: Language

The currently selected language.


viewMode

viewMode: ViewMode = 'desktop'

Current display resolution type.

Accessors

commonActions

get commonActions(): ActionValues

Returns

ActionValues

the Record with the common actions.


displayedLanguage

get displayedLanguage(): Language

Returns

Language

the current display language.


formData

get formData(): ComponentData

Returns

ComponentData

the IFormData with all the form data.

Implementation of

IFormViewer.formData


initialDataSlice

get initialDataSlice(): undefined | Record<string, unknown>

Returns

undefined | Record<string, unknown>

the slice of the initial data in accordance with the Store hierarchy. Internal use only.

Implementation of

IStore.initialDataSlice

Methods

applyPersistedForm

applyPersistedForm(persistedForm): void

Populates the value of this store with the values of the saved form.

Parameters

NameTypeDescription
persistedFormPersistedFormsaved form value.

Returns

void


applyStringForm

applyStringForm(text): void

Populates the value of this store with the values of the saved form.

Parameters

NameTypeDescription
textstringsaved form value.

Returns

void


clear

clear(): void

Clears the form in Form Viewer.

Returns

void


createComponentData

createComponentData(componentStore, deferFieldCalculation?, model?): ComponentData

Creates the element for the component tree.

Parameters

NameTypeDefault valueDescription
componentStoreComponentStoreundefinedthe component settings.
deferFieldCalculationbooleanfalseif true, then the calculated field must be explicitly initialized.
model?Model<any>undefinedthe component's metadata.

Returns

ComponentData

the element for the component tree.


dispose

dispose(): void

Correctly clears allocated resources, the function must be called when destroying an instance of the class.

Returns

void

Implementation of

IStore.dispose


findAction

findAction(actionData): ActionDefinition

Searches for an action, returns definition for the found action.

Throws

Error, if action was not found.

Parameters

NameTypeDescription
actionDataActionDatathe action's data.

Returns

ActionDefinition

the action definition.


getAction

getAction(name, type): ActionDefinition

Returns an action by the specified action name and action type.

Parameters

NameTypeDescription
namestringthe action name.
typeActionTypethe action type.

Returns

ActionDefinition

the action.


getModel

getModel(type): Model<Record<string, any>> | Model<InternalErrorProps>

Returns model for the specified type.

Parameters

NameTypeDescription
typestringthe component type.

Returns

Model<Record<string, any>> | Model<InternalErrorProps>

the model for the specified type.


getValidationRules

getValidationRules(type): FormViewerValidationRules

Returns the object with validators for the specified value type.

Parameters

NameTypeDescription
typekeyof SchemaTypeMapthe value type.

Returns

FormViewerValidationRules

the object with validators for the specified value type.


loadForm

loadForm(getForm?, formName?): void

Loads a form by form name and sets that form in the form viewer.

Parameters

NameTypeDescription
getForm?(name?: string) => string | Promise<string>the function that loads the form.
formName?stringthe form name.

Returns

void


localizeComponent

localizeComponent(type, componentStore): Record<string, any>

Localizes a component store based on the given localization type. If a custom localizer is available, it will be used.

Parameters

NameTypeDescription
typestringthe type of localization.
componentStoreComponentStorethe component settings.

Returns

Record<string, any>

the Record with the localized properties.


localizeErrorMessages

localizeErrorMessages(componentStore, validationResults?): undefined | string

Localizes validator error messages.

Parameters

NameTypeDescription
componentStoreComponentStorethe component settings.
validationResults?ValidationResult[]the validation results.

Returns

undefined | string

the localized error messages joined by space, or undefined if validationResults is undefined.

Implementation of

IStore.localizeErrorMessages


reduceScreen

reduceScreen<T>(callback, initialValue): T

Performs the callback function on each element of the component tree, accumulates the return values.

Type parameters

NameDescription
Tthe return value type.

Parameters

NameTypeDescription
callback(accumulator: T, current: ComponentData) => Tthe function that calculates the value for the accumulator.
initialValueTthe initial value for the accumulator.

Returns

T

the accumulated value.

Implementation of

IStore.reduceScreen