UNPKG

@react-form-builder/core

Version:

React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required

125 lines (124 loc) 3.68 kB
import { makeObservable as l, observable as i } from "mobx"; import { customActionsToActionsValues as e } from "../features/form-viewer/CustomActions.js"; import { nameObservable as s } from "../utils/observableNaming.js"; class t { /** * The metadata of the form viewer components. */ view; /** * The initial form data. */ initialData = {}; /** * The set of metadata of validation rules, grouped by the type of value being validated. */ validators; /** * The set of functions that validate the form data. */ formValidators; /** * The function to localize the properties of a component. */ localizer; /** * Custom actions for the form viewer. */ actions; /** * The full language code passed in the FormViewer properties, e.g. 'en-US'. */ propsLanguage; /** * The default error wrapper used when errorType is not specified in the form. */ errorWrapper; /** * If true, the form is read-only. */ readOnly; /** * If true, the form is disabled. */ disabled; /** * If true, all validation errors will be displayed. */ showAllValidationErrors; /** * The arbitrary internal context. */ context; /** * The initial user-defined state. */ initialState = {}; /** * The arbitrary user context passed via props. * This value is not observable and is intended to be non-reactive. */ userContext; /** * The localization engine provided via FormViewer props. */ localizationEngine; /** * Constructs a new FormViewerPropsStore from the given FormViewerProps. * @param formViewerProps the FormViewer props. * @returns the FormViewerPropsStore. */ constructor(a) { this.applyProps(a), this.view = a.view, l(this, { view: i.ref, initialData: i.deep, initialState: i.deep, userContext: i.deep, validators: i.ref, formValidators: i.ref, localizer: i.ref, actions: i.ref, propsLanguage: i.ref, errorWrapper: i.ref, disabled: i.ref, readOnly: i.ref, showAllValidationErrors: i.ref, context: i.ref, localizationEngine: i.ref }, { name: s("FormViewerPropsStore") }); } /** * Applies the given FormViewerProps. * @param formViewerProps the properties to apply. */ applyProps(a) { this.view = a.view, this.initialData = a.initialData ?? {}, this.initialState = a.initialState ?? {}, this.userContext = a.userContext, this.validators = a.validators, this.formValidators = a.formValidators, this.localizer = a.localize, this.actions = e(a.actions), this.propsLanguage = a.language, this.errorWrapper = a.errorWrapper, this.readOnly = a.readOnly, this.disabled = a.disabled, this.showAllValidationErrors = a.showAllValidationErrors, this.context = a.context, this.localizationEngine = a.localizationEngine; } /** * Returns the clone of the FormViewerPropsStore object. * @returns the clone of the FormViewerPropsStore object. */ clone() { return new t({ view: this.view, initialData: this.initialData, initialState: this.initialState, userContext: this.userContext, validators: this.validators, formValidators: this.formValidators, localize: this.localizer, actions: this.actions, language: this.propsLanguage, errorWrapper: this.errorWrapper, readOnly: this.readOnly, disabled: this.disabled, showAllValidationErrors: this.showAllValidationErrors, context: this.context, localizationEngine: this.localizationEngine }); } } export { t as FormViewerPropsStore }; //# sourceMappingURL=FormViewerPropsStore.js.map