/** * Webform class for rendering forms with full component support. * @property {import('./Form.js').FormOptions} options - The options for this Webform instance. */ declare class Webform extends NestedDataComponent { /** * Creates a new Form instance. * @param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance. * @param {import('Form').FormOptions} [options] - The options to create a new form instance. */ constructor(elementOrOptions?: HTMLElement | object | import('Form').FormOptions, options?: import("Form").FormOptions | undefined); _src: string; _loading: boolean; _form: {}; draftEnabled: boolean; savingDraft: boolean; triggerSaveDraft: any; set nosubmit(value: any); get nosubmit(): any; /** * Determines if the form has tried to be submitted, error or not. * @type {boolean} */ submitted: boolean; /** * Determines if the form is being submitted at the moment. * @type {boolean} */ submitting: boolean; /** * The Formio instance for this form. * @type {Formio} */ formio: Formio; /** * The loader HTML element. * @type {HTMLElement} */ loader: HTMLElement; /** * The alert HTML element * @type {HTMLElement} */ alert: HTMLElement; /** * Promise that is triggered when the submission is done loading. * @type {Promise} */ onSubmission: Promise; /** * Determines if this submission is explicitly set. * @type {boolean} */ submissionSet: boolean; /** * Promise that executes when the form is ready and rendered. * @type {Promise} * @example * import Webform from '@formio/js/Webform'; * let form = new Webform(document.getElementById('formio')); * form.formReady.then(() => { * console.log('The form is ready!'); * }); * form.src = 'https://examples.form.io/example'; */ formReady: Promise; /** * Called when the formReady state of this form has been resolved. * @type {Function} */ formReadyResolve: Function; /** * Called when this form could not load and is rejected. * @type {Function} */ formReadyReject: Function; /** * Promise that executes when the submission is ready and rendered. * @type {Promise} * @example * import Webform from '@formio/js/Webform'; * let form = new Webform(document.getElementById('formio')); * form.submissionReady.then(() => { * console.log('The submission is ready!'); * }); * form.src = 'https://examples.form.io/example/submission/234234234234234243'; */ submissionReady: Promise; /** * Called when the formReady state of this form has been resolved. * @type {Function} */ submissionReadyResolve: Function; /** * Called when this form could not load and is rejected. * @type {Function} */ submissionReadyReject: Function; shortcuts: any[]; /** * Sets the language for this form. * @param {string} lang - The language to use (e.g. 'en', 'sp', etc.) */ set language(lang: string); get language(): string; root: this; localRoot: this; get emptyValue(): null; get shadowRoot(): any; /** * Add a language for translations * @param {string} code - The language code for the language being added. * @param {object} lang - The language translations. * @param {boolean} [active] - If this language should be set as the active language. */ addLanguage(code: string, lang: object, active?: boolean | undefined): void; keyboardCatchableElement(element: any): boolean; executeShortcuts: (event: any) => void; addShortcut(element: any, shortcut: any): void; removeShortcut(element: any, shortcut: any): void; /** * Set the Form source, which is typically the Form.io embed URL. * @param {string} value - The value of the form embed url. * @example * import Webform from '@formio/js/Webform'; * let form = new Webform(document.getElementById('formio')); * form.formReady.then(() => { * console.log('The form is formReady!'); * }); * form.src = 'https://examples.form.io/example'; */ set src(value: string); /** * Get the embed source of the form. * @returns {string} - The source of the form. */ get src(): string; /** * Loads the submission if applicable. * @returns {Promise} - The promise that is triggered when the submission is loaded. */ loadSubmission(): Promise; loadingSubmission: boolean | undefined; /** * Set the src of the form renderer. * @param {string} value - The source value to set. * @param {any} options - The options to set. * @returns {Promise} - The promise that is triggered when the form is set. */ setSrc(value: string, options: any): Promise; /** * Set the form source but don't initialize the form and submission from the url. * @param {string} value - The value of the form embed url. */ set url(value: string); /** * Get the embed source of the form. * @returns {string} - returns the source of the form. */ get url(): string; /** * Sets the url of the form renderer. * @param {string} value - The value to set the url to. * @param {any} options - The options to set. * @returns {boolean} - TRUE means the url was set, FALSE otherwise. */ setUrl(value: string, options: any): boolean; /** * Called when both the form and submission have been loaded. * @returns {Promise} - The promise to trigger when both form and submission have loaded. */ get ready(): Promise; /** * Set the loading state for this form, and also show the loader spinner. * @param {boolean} loading - If this form should be "loading" or not. */ set loading(loading: boolean); /** * Returns if this form is loading. * @returns {boolean} - TRUE means the form is loading, FALSE otherwise. */ get loading(): boolean; /** * Sets the JSON schema for the form to be rendered. * @example * import Webform from '@formio/js/Webform'; * let form = new Webform(document.getElementById('formio')); * form.setForm({ * components: [ * { * type: 'textfield', * key: 'firstName', * label: 'First Name', * placeholder: 'Enter your first name.', * input: true * }, * { * type: 'textfield', * key: 'lastName', * label: 'Last Name', * placeholder: 'Enter your last name', * input: true * }, * { * type: 'button', * action: 'submit', * label: 'Submit', * theme: 'primary' * } * ] * }); * @param {object} form - The JSON schema of the form @see https://examples.form.io/example for an example JSON schema. * @param {any} flags - Any flags to apply when setting the form. * @returns {Promise} - The promise that is triggered when the form is set. */ setForm(form: object, flags?: any): Promise; initialized: boolean | undefined; /** * Sets the form value. * @alias setForm * @param {object} form - The form schema object. */ set form(form: object); /** * Gets the form object. * @returns {object} - The form JSON schema. */ get form(): object; /** * Sets the submission of a form. * @example * import Webform from '@formio/js/Webform'; * let form = new Webform(document.getElementById('formio')); * form.src = 'https://examples.form.io/example'; * form.submission = {data: { * firstName: 'Joe', * lastName: 'Smith', * email: 'joe@example.com' * }}; * @param {object} submission - The Form.io submission object. */ set submission(submission: object); /** * Returns the submission object that was set within this form. * @returns {object} - The submission object. */ get submission(): object; /** * Sets the submission value * @param {object|null|undefined} submission - The submission to set. * @param {object|null|undefined} flags - Any flags to apply when setting the submission. * @returns {void} */ onSetSubmission(submission: object | null | undefined, flags?: object | null | undefined): void; /** * Sets a submission and returns the promise when it is ready. * @param {any} submission - The submission to set. * @param {any} flags - Any flags to apply when setting the submission. * @returns {Promise} - The promise that is triggered when the submission is set. */ setSubmission(submission: any, flags?: any): Promise; handleDraftError(errName: any, errDetails: any, restoreDraft: any): void; saveDraft(): void; /** * Restores a draft submission based on the user who is authenticated. * @param {string} userId - The user id where we need to restore the draft from. */ restoreDraft(userId: string): void; get schema(): any; mergeData(_this: any, _that: any): void; editing: boolean | undefined; _submission: any; /** * Build the form. * @returns {Promise} - The promise that is triggered when the form is built. */ init(): Promise; executeFormController(): false | undefined; build(element: any): Promise; getClassName(): string; render(): string; redraw(): Promise | Promise; attach(element: any): Promise; hasRequiredFields(): boolean; /** * Sets a new alert to display in the error dialog of the form. * @param {string} type - The type of alert to display. "danger", "success", "warning", etc. * @param {string} message - The message to show in the alert. * @param {object} options - The options for the alert. */ setAlert(type: string, message: string, options: object): void; /** * Focus on selected component. * @param {string} key - The key of selected component. */ focusOnComponent(key: string): void; /** * @returns {boolean} - Whether or not the draft submission is being edited */ isDraftEdit(): boolean; /** * Show the errors of this form within the alert dialog. * @param {object} error - An optional additional error to display along with the component errors. * @returns {*} */ /** * * @param {Array} errors - An array of errors to display. * @param {boolean} triggerEvent - Whether or not to trigger the error event. * @returns {void|Array} - The errors that were set. */ showErrors(errors: any[], triggerEvent: boolean): void | any[]; /** * Called when the submission has completed, or if the submission needs to be sent to an external library. * @param {object} submission - The submission object. * @param {boolean} saved - Whether or not this submission was saved to the server. * @returns {object} - The submission object. */ onSubmit(submission: object, saved: boolean): object; normalizeError(error: any): any; /** * Called when an error occurs during the submission. * @param {object} error - The error that occured. * @returns {Array} errors - All errors. */ onSubmissionError(error: object): any[]; /** * Trigger the change event for this form. * @param {any} flags - The flags to set on this change event. * @param {any} changed - The changed object which reflects the changes in the form. * @param {boolean} modified - Whether or not the form has been modified. * @param {any} changes - The changes that have occured in the form. */ onChange(flags: any, changed: any, modified: boolean, changes: any): void; /** * Send a delete request to the server. * @returns {Promise} - The promise that is triggered when the delete is complete. */ deleteSubmission(): Promise; /** * Cancels the submission. * @param {boolean} noconfirm - Whether or not to confirm the cancellation. * @alias reset * @returns {boolean} - TRUE means the submission was cancelled, FALSE otherwise. */ cancel(noconfirm: boolean): boolean; setMetadata(submission: any): void; submitForm(options?: {}, local?: boolean): Promise; setServerErrors(error: any): void; serverErrors: any; executeSubmit(options: any): Promise; submissionInProcess: boolean | undefined; clearServerErrors(): void; /** * Submits the form. * @example * import Webform from '@formio/js/Webform'; * let form = new Webform(document.getElementById('formio')); * form.src = 'https://examples.form.io/example'; * form.submission = {data: { * firstName: 'Joe', * lastName: 'Smith', * email: 'joe@example.com' * }}; * form.submit().then((submission) => { * console.log(submission); * }); * @param {boolean} before - If this submission occured from the before handlers. * @param {any} options - The options to use when submitting this form. * @returns {Promise} - A promise when the form is done submitting. */ submit(before?: boolean, options?: any): Promise; submitUrl(URL: any, headers: any): void; triggerCaptcha(components?: null): void; _nosubmit: any; get conditions(): any; get variables(): any; } declare namespace Webform { let setBaseUrl: any; let setApiUrl: any; let setAppUrl: any; } export default Webform; import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';