@formio/js 5.0.0-rc.52 → 5.0.0-rc.54
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +551 -541
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -1
- package/dist/formio.full.js +553 -543
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -1
- package/dist/formio.js +10 -10
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +14 -4
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +3 -1
- package/embed.d.ts +1 -0
- package/form.d.ts +1 -0
- package/lib/cjs/Form.d.ts +281 -10
- package/lib/cjs/Form.js +22 -35
- package/lib/cjs/FormBuilder.d.ts +187 -2
- package/lib/cjs/FormBuilder.js +29 -6
- package/lib/cjs/InlineEmbed.d.ts +7 -0
- package/lib/cjs/InlineEmbed.js +109 -0
- package/lib/cjs/PDF.d.ts +0 -1
- package/lib/cjs/Webform.d.ts +6 -6
- package/lib/cjs/Webform.js +2 -2
- package/lib/cjs/Wizard.d.ts +1 -1
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -6
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -4
- package/lib/cjs/components/_classes/field/Field.d.ts +11 -2
- package/lib/cjs/components/_classes/field/Field.js +13 -1
- package/lib/cjs/components/_classes/input/Input.d.ts +4 -3
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.form.d.ts +4 -5
- package/lib/cjs/components/_classes/list/ListComponent.form.js +3 -2
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +42 -11
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +37 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +127 -33
- package/lib/cjs/components/_classes/nested/NestedComponent.js +133 -15
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +6 -0
- package/lib/cjs/components/address/Address.d.ts +2 -1
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/cjs/components/columns/Columns.d.ts +1 -1
- package/lib/cjs/components/container/Container.d.ts +1 -0
- package/lib/cjs/components/datagrid/DataGrid.d.ts +1 -1
- package/lib/cjs/components/day/Day.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -0
- package/lib/cjs/components/file/File.d.ts +2 -2
- package/lib/cjs/components/number/Number.d.ts +1 -1
- package/lib/cjs/components/radio/Radio.d.ts +1 -1
- package/lib/cjs/components/radio/Radio.form.d.ts +1 -3
- package/lib/cjs/components/radio/Radio.js +3 -3
- package/lib/cjs/components/select/Select.d.ts +9 -14
- package/lib/cjs/components/select/Select.form.d.ts +1 -3
- package/lib/cjs/components/select/Select.js +11 -15
- package/lib/cjs/components/selectboxes/SelectBoxes.form.d.ts +1 -3
- package/lib/cjs/components/survey/Survey.d.ts +1 -1
- package/lib/cjs/components/table/Table.d.ts +1 -1
- package/lib/cjs/components/tabs/Tabs.d.ts +1 -1
- package/lib/cjs/components/textfield/TextField.d.ts +1 -1
- package/lib/cjs/formio.embed.d.ts +1 -2
- package/lib/cjs/formio.embed.js +2 -100
- package/lib/cjs/providers/address/NominatimAddressProvider.d.ts +1 -1
- package/lib/cjs/providers/address/NominatimAddressProvider.js +5 -1
- package/lib/cjs/providers/processor/fileProcessor.d.ts +7 -1
- package/lib/cjs/providers/processor/fileProcessor.js +6 -0
- package/lib/cjs/providers/storage/azure.d.ts +4 -15
- package/lib/cjs/providers/storage/azure.js +3 -2
- package/lib/cjs/providers/storage/base64.d.ts +3 -7
- package/lib/cjs/providers/storage/base64.js +2 -1
- package/lib/cjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/cjs/providers/storage/dropbox.js +3 -2
- package/lib/cjs/providers/storage/googleDrive.d.ts +4 -6
- package/lib/cjs/providers/storage/googleDrive.js +3 -1
- package/lib/cjs/providers/storage/indexeddb.d.ts +3 -8
- package/lib/cjs/providers/storage/indexeddb.js +2 -1
- package/lib/cjs/providers/storage/s3.d.ts +4 -22
- package/lib/cjs/providers/storage/s3.js +3 -2
- package/lib/cjs/providers/storage/url.d.ts +3 -8
- package/lib/cjs/providers/storage/url.js +4 -3
- package/lib/cjs/providers/storage/util.d.ts +22 -6
- package/lib/cjs/providers/storage/util.js +16 -5
- package/lib/cjs/utils/builder.d.ts +9 -7
- package/lib/cjs/utils/builder.js +10 -5
- package/lib/cjs/utils/calendarUtils.d.ts +6 -10
- package/lib/cjs/utils/calendarUtils.js +7 -11
- package/lib/cjs/utils/formUtils.d.ts +4 -4
- package/lib/cjs/utils/formUtils.js +3 -3
- package/lib/cjs/utils/utils.d.ts +123 -121
- package/lib/cjs/utils/utils.js +99 -94
- package/lib/mjs/Form.d.ts +281 -10
- package/lib/mjs/Form.js +112 -28
- package/lib/mjs/FormBuilder.d.ts +187 -2
- package/lib/mjs/FormBuilder.js +31 -6
- package/lib/mjs/InlineEmbed.d.ts +7 -0
- package/lib/mjs/InlineEmbed.js +105 -0
- package/lib/mjs/PDF.d.ts +0 -1
- package/lib/mjs/Webform.d.ts +6 -6
- package/lib/mjs/Webform.js +3 -3
- package/lib/mjs/Wizard.d.ts +1 -1
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -6
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -4
- package/lib/mjs/components/_classes/field/Field.d.ts +11 -2
- package/lib/mjs/components/_classes/field/Field.js +13 -1
- package/lib/mjs/components/_classes/input/Input.d.ts +4 -3
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.form.d.ts +4 -5
- package/lib/mjs/components/_classes/list/ListComponent.form.js +3 -2
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +42 -11
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +37 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +127 -33
- package/lib/mjs/components/_classes/nested/NestedComponent.js +133 -15
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +6 -0
- package/lib/mjs/components/address/Address.d.ts +2 -1
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/mjs/components/columns/Columns.d.ts +1 -1
- package/lib/mjs/components/container/Container.d.ts +1 -0
- package/lib/mjs/components/datagrid/DataGrid.d.ts +1 -1
- package/lib/mjs/components/day/Day.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -0
- package/lib/mjs/components/file/File.d.ts +2 -2
- package/lib/mjs/components/number/Number.d.ts +1 -1
- package/lib/mjs/components/radio/Radio.d.ts +1 -1
- package/lib/mjs/components/radio/Radio.form.d.ts +1 -3
- package/lib/mjs/components/radio/Radio.js +3 -3
- package/lib/mjs/components/select/Select.d.ts +9 -14
- package/lib/mjs/components/select/Select.form.d.ts +1 -3
- package/lib/mjs/components/select/Select.js +11 -15
- package/lib/mjs/components/selectboxes/SelectBoxes.form.d.ts +1 -3
- package/lib/mjs/components/survey/Survey.d.ts +1 -1
- package/lib/mjs/components/table/Table.d.ts +1 -1
- package/lib/mjs/components/tabs/Tabs.d.ts +1 -1
- package/lib/mjs/components/textfield/TextField.d.ts +1 -1
- package/lib/mjs/formio.embed.d.ts +1 -2
- package/lib/mjs/formio.embed.js +2 -99
- package/lib/mjs/providers/address/NominatimAddressProvider.d.ts +1 -1
- package/lib/mjs/providers/address/NominatimAddressProvider.js +5 -1
- package/lib/mjs/providers/processor/fileProcessor.d.ts +7 -1
- package/lib/mjs/providers/processor/fileProcessor.js +6 -0
- package/lib/mjs/providers/storage/azure.d.ts +4 -15
- package/lib/mjs/providers/storage/azure.js +3 -2
- package/lib/mjs/providers/storage/base64.d.ts +3 -7
- package/lib/mjs/providers/storage/base64.js +2 -1
- package/lib/mjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/mjs/providers/storage/dropbox.js +3 -2
- package/lib/mjs/providers/storage/googleDrive.d.ts +4 -6
- package/lib/mjs/providers/storage/googleDrive.js +3 -1
- package/lib/mjs/providers/storage/indexeddb.d.ts +3 -8
- package/lib/mjs/providers/storage/indexeddb.js +2 -1
- package/lib/mjs/providers/storage/s3.d.ts +4 -22
- package/lib/mjs/providers/storage/s3.js +3 -2
- package/lib/mjs/providers/storage/url.d.ts +3 -8
- package/lib/mjs/providers/storage/url.js +4 -3
- package/lib/mjs/providers/storage/util.d.ts +22 -6
- package/lib/mjs/providers/storage/util.js +16 -5
- package/lib/mjs/utils/builder.d.ts +9 -7
- package/lib/mjs/utils/builder.js +10 -5
- package/lib/mjs/utils/calendarUtils.d.ts +6 -10
- package/lib/mjs/utils/calendarUtils.js +7 -11
- package/lib/mjs/utils/formUtils.d.ts +4 -4
- package/lib/mjs/utils/formUtils.js +3 -3
- package/lib/mjs/utils/utils.d.ts +123 -121
- package/lib/mjs/utils/utils.js +99 -94
- package/package.json +17 -13
- package/sdk.d.ts +1 -0
- package/utils.d.ts +1 -0
package/lib/mjs/Form.js
CHANGED
@@ -4,27 +4,119 @@ import Displays from './displays';
|
|
4
4
|
import templates from './templates';
|
5
5
|
import * as FormioUtils from './utils/utils';
|
6
6
|
export default class Form extends Element {
|
7
|
+
/**
|
8
|
+
* Represents a JSON value.
|
9
|
+
* @typedef {(string | number | boolean | null | JSONArray | JSONObject)} JSON
|
10
|
+
*/
|
11
|
+
/**
|
12
|
+
* Represents a JSON array.
|
13
|
+
* @typedef {Array<JSON>} JSONArray
|
14
|
+
*/
|
15
|
+
/**
|
16
|
+
* Represents a JSON object.
|
17
|
+
* @typedef {{[key: string]: JSON}} JSONObject
|
18
|
+
*/
|
19
|
+
/**
|
20
|
+
* @typedef {object} FormioHooks
|
21
|
+
* @property {Function} [beforeSubmit]
|
22
|
+
* @property {Function} [beforeCancel]
|
23
|
+
* @property {Function} [beforeNext]
|
24
|
+
* @property {Function} [beforePrev]
|
25
|
+
* @property {Function} [attachComponent]
|
26
|
+
* @property {Function} [setDataValue]
|
27
|
+
* @property {Function} [addComponents]
|
28
|
+
* @property {Function} [addComponent]
|
29
|
+
* @property {Function} [customValidation]
|
30
|
+
* @property {Function} [attachWebform]
|
31
|
+
*/
|
32
|
+
/**
|
33
|
+
* @typedef {object} SanitizeConfig
|
34
|
+
* @property {string[]} [addAttr]
|
35
|
+
* @property {string[]} [addTags]
|
36
|
+
* @property {string[]} [allowedAttrs]
|
37
|
+
* @property {string[]} [allowedTags]
|
38
|
+
* @property {string[]} [allowedUriRegex]
|
39
|
+
* @property {string[]} [addUriSafeAttr]
|
40
|
+
*/
|
41
|
+
/**
|
42
|
+
* @typedef {object} ButtonSettings
|
43
|
+
* @property {boolean} [showPrevious]
|
44
|
+
* @property {boolean} [showNext]
|
45
|
+
* @property {boolean} [showCancel]
|
46
|
+
* @property {boolean} [showSubmit]
|
47
|
+
*/
|
48
|
+
/**
|
49
|
+
* @typedef {object} FormOptions
|
50
|
+
* @property {boolean} [saveDraft] - Enable the save draft feature.
|
51
|
+
* @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
|
52
|
+
* @property {boolean} [readOnly] - Set this form to readOnly.
|
53
|
+
* @property {boolean} [noAlerts] - Disable the alerts dialog.
|
54
|
+
* @property {{[key: string]: string}} [i18n] - The translation file for this rendering.
|
55
|
+
* @property {string} [template] - Custom logic for creation of elements.
|
56
|
+
* @property {boolean} [noDefaults] - Exclude default values from the settings.
|
57
|
+
* @property {any} [fileService] - The file service for this form.
|
58
|
+
* @property {EventEmitter} [events] - The EventEmitter for this form.
|
59
|
+
* @property {string} [language] - The language to render this form in.
|
60
|
+
* @property {{[key: string]: string}} [i18next] - The i18next configuration for this form.
|
61
|
+
* @property {boolean} [viewAsHtml] - View the form as raw HTML.
|
62
|
+
* @property {'form' | 'html' | 'flat' | 'builder' | 'pdf'} [renderMode] - The render mode for this form.
|
63
|
+
* @property {boolean} [highlightErrors] - Highlight any errors on the form.
|
64
|
+
* @property {string} [componentErrorClass] - The error class for components.
|
65
|
+
* @property {any} [templates] - The templates for this form.
|
66
|
+
* @property {string} [iconset] - The iconset for this form.
|
67
|
+
* @property {import('@formio/core').Component[]} [components] - The components for this form.
|
68
|
+
* @property {{[key: string]: boolean}} [disabled] - Disabled components for this form.
|
69
|
+
* @property {boolean} [showHiddenFields] - Show hidden fields.
|
70
|
+
* @property {{[key: string]: boolean}} [hide] - Hidden components for this form.
|
71
|
+
* @property {{[key: string]: boolean}} [show] - Components to show for this form.
|
72
|
+
* @property {Formio} [formio] - The Formio instance for this form.
|
73
|
+
* @property {string} [decimalSeparator] - The decimal separator for this form.
|
74
|
+
* @property {string} [thousandsSeparator] - The thousands separator for this form.
|
75
|
+
* @property {FormioHooks} [hooks] - The hooks for this form.
|
76
|
+
* @property {boolean} [alwaysDirty] - Always be dirty.
|
77
|
+
* @property {boolean} [skipDraftRestore] - Skip restoring a draft.
|
78
|
+
* @property {'form' | 'wizard' | 'pdf'} [display] - The display for this form.
|
79
|
+
* @property {string} [cdnUrl] - The CDN url for this form.
|
80
|
+
* @property {boolean} [flatten] - Flatten the form.
|
81
|
+
* @property {boolean} [sanitize] - Sanitize the form.
|
82
|
+
* @property {SanitizeConfig} [sanitizeConfig] - The sanitize configuration for this form.
|
83
|
+
* @property {ButtonSettings} [buttonSettings] - The button settings for this form.
|
84
|
+
* @property {object} [breadcrumbSettings] - The breadcrumb settings for this form.
|
85
|
+
* @property {boolean} [allowPrevious] - Allow the previous button (for Wizard forms).
|
86
|
+
* @property {string[]} [wizardButtonOrder] - The order of the buttons (for Wizard forms).
|
87
|
+
* @property {boolean} [showCheckboxBackground] - Show the checkbox background.
|
88
|
+
* @property {number} [zoom] - The zoom for PDF forms.
|
89
|
+
*/
|
7
90
|
/**
|
8
91
|
* Creates an easy to use interface for embedding webforms, pdfs, and wizards into your application.
|
9
|
-
* @param {object}
|
10
|
-
* @param {object | string}
|
11
|
-
* @param {
|
12
|
-
* @param {boolean} options.readOnly - Set this form to readOnly
|
13
|
-
* @param {boolean} options.noAlerts - Set to true to disable the alerts dialog.
|
14
|
-
* @param {boolean} options.i18n - The translation file for this rendering. @see https://github.com/formio/formio.js/blob/master/i18n.js
|
15
|
-
* @param {boolean} options.template - Provides a way to inject custom logic into the creation of every element rendered within the form.
|
16
|
-
* @param {...any} args
|
92
|
+
* @param {object} elementOrForm - The DOM element you wish to render this form within, or the form definition.
|
93
|
+
* @param {object | string | FormOptions} formOrOptions - A Form JSON schema, the URL of a hosted form, or the form options.
|
94
|
+
* @param {FormOptions} [options] - The options to create a new form instance.
|
17
95
|
* @example
|
18
96
|
* import Form from '@formio/js/Form';
|
19
97
|
* const form = new Form(document.getElementById('formio'), 'https://examples.form.io/example');
|
20
98
|
* form.build();
|
21
99
|
*/
|
22
|
-
|
23
|
-
|
100
|
+
/**
|
101
|
+
* @type {FormOptions} - the options for this Form.
|
102
|
+
*/
|
103
|
+
options;
|
104
|
+
constructor(elementOrForm, formOrOptions, options = {}) {
|
105
|
+
let element, form, formOptions;
|
106
|
+
if (elementOrForm instanceof HTMLElement) {
|
107
|
+
element = elementOrForm;
|
108
|
+
form = formOrOptions;
|
109
|
+
formOptions = options;
|
110
|
+
}
|
111
|
+
else {
|
112
|
+
element = null;
|
113
|
+
form = elementOrForm;
|
114
|
+
formOptions = formOrOptions || {};
|
115
|
+
}
|
24
116
|
if (Formio.options && Formio.options.form) {
|
25
|
-
|
117
|
+
formOptions = Object.assign(formOptions, Formio.options.form);
|
26
118
|
}
|
27
|
-
super(
|
119
|
+
super(formOptions);
|
28
120
|
if (this.options.useSessionToken) {
|
29
121
|
Formio.useSessionToken(this.options);
|
30
122
|
}
|
@@ -33,30 +125,22 @@ export default class Form extends Element {
|
|
33
125
|
this.readyReject = reject;
|
34
126
|
});
|
35
127
|
this.instance = null;
|
36
|
-
if (
|
128
|
+
if (element) {
|
37
129
|
if (this.element) {
|
38
130
|
delete this.element.component;
|
39
131
|
}
|
40
|
-
this.element =
|
41
|
-
this.options = args[2] || {};
|
42
|
-
this.options.events = this.events;
|
43
|
-
this.setForm(args[1])
|
44
|
-
.then(() => this.readyResolve(this.instance))
|
45
|
-
.catch(this.readyReject);
|
132
|
+
this.element = element;
|
46
133
|
}
|
47
|
-
else
|
134
|
+
else {
|
48
135
|
this.element = null;
|
49
|
-
|
50
|
-
|
51
|
-
this.setForm(
|
136
|
+
}
|
137
|
+
if (form) {
|
138
|
+
this.setForm(form)
|
52
139
|
.then(() => this.readyResolve(this.instance))
|
53
140
|
.catch(this.readyReject);
|
54
141
|
}
|
55
|
-
|
56
|
-
|
57
|
-
this.options = {};
|
58
|
-
this.options.events = this.events;
|
59
|
-
}
|
142
|
+
this.options = formOptions;
|
143
|
+
this.options.events = this.events;
|
60
144
|
this.display = '';
|
61
145
|
}
|
62
146
|
createElement(tag, attrs, children) {
|
package/lib/mjs/FormBuilder.d.ts
CHANGED
@@ -1,6 +1,191 @@
|
|
1
1
|
export default class FormBuilder extends Form {
|
2
|
-
|
3
|
-
|
2
|
+
/**
|
3
|
+
* @typedef FormBuilderOptions
|
4
|
+
* @property {string[]} [disabled] - An array of "keys" of components that should be disabled within the form builder. Example: ['firstName', 'lastName']
|
5
|
+
* @property {boolean} [noNewEdit] - When set to TRUE no modal is shown when a component is dragged onto the form.
|
6
|
+
* @property {boolean} [noDefaultSubmitButton] - Set to TRUE to not include the default submit button in Webforms.
|
7
|
+
* @property {boolean} [alwaysConfirmComponentRemoval] - Set to TRUE to always require confirmation before removing a component.
|
8
|
+
* @property {object} [formConfig] - Form configurations to apply to forms being created. These configurations are added to the "config" property of the form object.
|
9
|
+
* @property {string} [resourceTag] - The tag to use to query for the "Existing Resource Fields" section of the builder.
|
10
|
+
* @property {import('./Form').FormOptions} [editForm] - The options to apply to the Edit Form (the form that shows inside the modal when you edit a component).
|
11
|
+
* @property {string} [language] - The language to load into the form builder.
|
12
|
+
* @property {object} [builder] - The builder options to pass to the builder.
|
13
|
+
* @property {'form'|'wizard'|'pdf'} [display] - The display mode of the builder.
|
14
|
+
* @property {string} [resourceFilter] - Filter applied to the resources that appear in the builder's Existing Resource Fields.
|
15
|
+
* @property {boolean} [noSource] - When set to TRUE, the resource ID in the builder's Existing Resource Fields will not be linked.
|
16
|
+
* @property {boolean} [showFullJsonSchema] - When set to TRUE, the full JSON schema will be displayed in the JSON edit menu.
|
17
|
+
*/
|
18
|
+
/** @type {FormBuilderOptions} */
|
19
|
+
static options: {
|
20
|
+
/**
|
21
|
+
* - An array of "keys" of components that should be disabled within the form builder. Example: ['firstName', 'lastName']
|
22
|
+
*/
|
23
|
+
disabled?: string[] | undefined;
|
24
|
+
/**
|
25
|
+
* - When set to TRUE no modal is shown when a component is dragged onto the form.
|
26
|
+
*/
|
27
|
+
noNewEdit?: boolean | undefined;
|
28
|
+
/**
|
29
|
+
* - Set to TRUE to not include the default submit button in Webforms.
|
30
|
+
*/
|
31
|
+
noDefaultSubmitButton?: boolean | undefined;
|
32
|
+
/**
|
33
|
+
* - Set to TRUE to always require confirmation before removing a component.
|
34
|
+
*/
|
35
|
+
alwaysConfirmComponentRemoval?: boolean | undefined;
|
36
|
+
/**
|
37
|
+
* - Form configurations to apply to forms being created. These configurations are added to the "config" property of the form object.
|
38
|
+
*/
|
39
|
+
formConfig?: object | undefined;
|
40
|
+
/**
|
41
|
+
* - The tag to use to query for the "Existing Resource Fields" section of the builder.
|
42
|
+
*/
|
43
|
+
resourceTag?: string | undefined;
|
44
|
+
/**
|
45
|
+
* - The options to apply to the Edit Form (the form that shows inside the modal when you edit a component).
|
46
|
+
*/
|
47
|
+
editForm?: any;
|
48
|
+
/**
|
49
|
+
* - The language to load into the form builder.
|
50
|
+
*/
|
51
|
+
language?: string | undefined;
|
52
|
+
/**
|
53
|
+
* - The builder options to pass to the builder.
|
54
|
+
*/
|
55
|
+
builder?: object | undefined;
|
56
|
+
/**
|
57
|
+
* - The display mode of the builder.
|
58
|
+
*/
|
59
|
+
display?: "form" | "pdf" | "wizard" | undefined;
|
60
|
+
/**
|
61
|
+
* - Filter applied to the resources that appear in the builder's Existing Resource Fields.
|
62
|
+
*/
|
63
|
+
resourceFilter?: string | undefined;
|
64
|
+
/**
|
65
|
+
* - When set to TRUE, the resource ID in the builder's Existing Resource Fields will not be linked.
|
66
|
+
*/
|
67
|
+
noSource?: boolean | undefined;
|
68
|
+
/**
|
69
|
+
* - When set to TRUE, the full JSON schema will be displayed in the JSON edit menu.
|
70
|
+
*/
|
71
|
+
showFullJsonSchema?: boolean | undefined;
|
72
|
+
};
|
73
|
+
/**
|
74
|
+
* Creates a new form builder.
|
75
|
+
* @param {HTMLElement} element - The HTML element to place the form builder.
|
76
|
+
* @param {string | object} form - The form to pass to the builder
|
77
|
+
* @param {FormBuilderOptions} options - The options to create this builder.
|
78
|
+
* @returns {FormBuilder} - The form builder instance.
|
79
|
+
*/
|
80
|
+
constructor(element: HTMLElement, form: string | object, options: {
|
81
|
+
/**
|
82
|
+
* - An array of "keys" of components that should be disabled within the form builder. Example: ['firstName', 'lastName']
|
83
|
+
*/
|
84
|
+
disabled?: string[] | undefined;
|
85
|
+
/**
|
86
|
+
* - When set to TRUE no modal is shown when a component is dragged onto the form.
|
87
|
+
*/
|
88
|
+
noNewEdit?: boolean | undefined;
|
89
|
+
/**
|
90
|
+
* - Set to TRUE to not include the default submit button in Webforms.
|
91
|
+
*/
|
92
|
+
noDefaultSubmitButton?: boolean | undefined;
|
93
|
+
/**
|
94
|
+
* - Set to TRUE to always require confirmation before removing a component.
|
95
|
+
*/
|
96
|
+
alwaysConfirmComponentRemoval?: boolean | undefined;
|
97
|
+
/**
|
98
|
+
* - Form configurations to apply to forms being created. These configurations are added to the "config" property of the form object.
|
99
|
+
*/
|
100
|
+
formConfig?: object | undefined;
|
101
|
+
/**
|
102
|
+
* - The tag to use to query for the "Existing Resource Fields" section of the builder.
|
103
|
+
*/
|
104
|
+
resourceTag?: string | undefined;
|
105
|
+
/**
|
106
|
+
* - The options to apply to the Edit Form (the form that shows inside the modal when you edit a component).
|
107
|
+
*/
|
108
|
+
editForm?: any;
|
109
|
+
/**
|
110
|
+
* - The language to load into the form builder.
|
111
|
+
*/
|
112
|
+
language?: string | undefined;
|
113
|
+
/**
|
114
|
+
* - The builder options to pass to the builder.
|
115
|
+
*/
|
116
|
+
builder?: object | undefined;
|
117
|
+
/**
|
118
|
+
* - The display mode of the builder.
|
119
|
+
*/
|
120
|
+
display?: "form" | "pdf" | "wizard" | undefined;
|
121
|
+
/**
|
122
|
+
* - Filter applied to the resources that appear in the builder's Existing Resource Fields.
|
123
|
+
*/
|
124
|
+
resourceFilter?: string | undefined;
|
125
|
+
/**
|
126
|
+
* - When set to TRUE, the resource ID in the builder's Existing Resource Fields will not be linked.
|
127
|
+
*/
|
128
|
+
noSource?: boolean | undefined;
|
129
|
+
/**
|
130
|
+
* - When set to TRUE, the full JSON schema will be displayed in the JSON edit menu.
|
131
|
+
*/
|
132
|
+
showFullJsonSchema?: boolean | undefined;
|
133
|
+
});
|
134
|
+
/** @type {FormBuilderOptions} */
|
135
|
+
options: {
|
136
|
+
/**
|
137
|
+
* - An array of "keys" of components that should be disabled within the form builder. Example: ['firstName', 'lastName']
|
138
|
+
*/
|
139
|
+
disabled?: string[] | undefined;
|
140
|
+
/**
|
141
|
+
* - When set to TRUE no modal is shown when a component is dragged onto the form.
|
142
|
+
*/
|
143
|
+
noNewEdit?: boolean | undefined;
|
144
|
+
/**
|
145
|
+
* - Set to TRUE to not include the default submit button in Webforms.
|
146
|
+
*/
|
147
|
+
noDefaultSubmitButton?: boolean | undefined;
|
148
|
+
/**
|
149
|
+
* - Set to TRUE to always require confirmation before removing a component.
|
150
|
+
*/
|
151
|
+
alwaysConfirmComponentRemoval?: boolean | undefined;
|
152
|
+
/**
|
153
|
+
* - Form configurations to apply to forms being created. These configurations are added to the "config" property of the form object.
|
154
|
+
*/
|
155
|
+
formConfig?: object | undefined;
|
156
|
+
/**
|
157
|
+
* - The tag to use to query for the "Existing Resource Fields" section of the builder.
|
158
|
+
*/
|
159
|
+
resourceTag?: string | undefined;
|
160
|
+
/**
|
161
|
+
* - The options to apply to the Edit Form (the form that shows inside the modal when you edit a component).
|
162
|
+
*/
|
163
|
+
editForm?: any;
|
164
|
+
/**
|
165
|
+
* - The language to load into the form builder.
|
166
|
+
*/
|
167
|
+
language?: string | undefined;
|
168
|
+
/**
|
169
|
+
* - The builder options to pass to the builder.
|
170
|
+
*/
|
171
|
+
builder?: object | undefined;
|
172
|
+
/**
|
173
|
+
* - The display mode of the builder.
|
174
|
+
*/
|
175
|
+
display?: "form" | "pdf" | "wizard" | undefined;
|
176
|
+
/**
|
177
|
+
* - Filter applied to the resources that appear in the builder's Existing Resource Fields.
|
178
|
+
*/
|
179
|
+
resourceFilter?: string | undefined;
|
180
|
+
/**
|
181
|
+
* - When set to TRUE, the resource ID in the builder's Existing Resource Fields will not be linked.
|
182
|
+
*/
|
183
|
+
noSource?: boolean | undefined;
|
184
|
+
/**
|
185
|
+
* - When set to TRUE, the full JSON schema will be displayed in the JSON edit menu.
|
186
|
+
*/
|
187
|
+
showFullJsonSchema?: boolean | undefined;
|
188
|
+
};
|
4
189
|
create(display: any): any;
|
5
190
|
}
|
6
191
|
import Form from './Form';
|
package/lib/mjs/FormBuilder.js
CHANGED
@@ -2,7 +2,33 @@ import { Formio } from './Formio';
|
|
2
2
|
import Builders from './builders';
|
3
3
|
import Form from './Form';
|
4
4
|
export default class FormBuilder extends Form {
|
5
|
+
/**
|
6
|
+
* @typedef FormBuilderOptions
|
7
|
+
* @property {string[]} [disabled] - An array of "keys" of components that should be disabled within the form builder. Example: ['firstName', 'lastName']
|
8
|
+
* @property {boolean} [noNewEdit] - When set to TRUE no modal is shown when a component is dragged onto the form.
|
9
|
+
* @property {boolean} [noDefaultSubmitButton] - Set to TRUE to not include the default submit button in Webforms.
|
10
|
+
* @property {boolean} [alwaysConfirmComponentRemoval] - Set to TRUE to always require confirmation before removing a component.
|
11
|
+
* @property {object} [formConfig] - Form configurations to apply to forms being created. These configurations are added to the "config" property of the form object.
|
12
|
+
* @property {string} [resourceTag] - The tag to use to query for the "Existing Resource Fields" section of the builder.
|
13
|
+
* @property {import('./Form').FormOptions} [editForm] - The options to apply to the Edit Form (the form that shows inside the modal when you edit a component).
|
14
|
+
* @property {string} [language] - The language to load into the form builder.
|
15
|
+
* @property {object} [builder] - The builder options to pass to the builder.
|
16
|
+
* @property {'form'|'wizard'|'pdf'} [display] - The display mode of the builder.
|
17
|
+
* @property {string} [resourceFilter] - Filter applied to the resources that appear in the builder's Existing Resource Fields.
|
18
|
+
* @property {boolean} [noSource] - When set to TRUE, the resource ID in the builder's Existing Resource Fields will not be linked.
|
19
|
+
* @property {boolean} [showFullJsonSchema] - When set to TRUE, the full JSON schema will be displayed in the JSON edit menu.
|
20
|
+
*/
|
21
|
+
/** @type {FormBuilderOptions} */
|
5
22
|
static options = {};
|
23
|
+
/** @type {FormBuilderOptions} */
|
24
|
+
options;
|
25
|
+
/**
|
26
|
+
* Creates a new form builder.
|
27
|
+
* @param {HTMLElement} element - The HTML element to place the form builder.
|
28
|
+
* @param {string | object} form - The form to pass to the builder
|
29
|
+
* @param {FormBuilderOptions} options - The options to create this builder.
|
30
|
+
* @returns {FormBuilder} - The form builder instance.
|
31
|
+
*/
|
6
32
|
constructor(element, form, options) {
|
7
33
|
form = form || {};
|
8
34
|
options = options || {};
|
@@ -20,13 +46,12 @@ export default class FormBuilder extends Form {
|
|
20
46
|
}
|
21
47
|
/**
|
22
48
|
* Factory that creates a new form builder based on the form parameter.
|
23
|
-
* @param
|
24
|
-
* @param
|
25
|
-
* @param
|
26
|
-
* @param {...any} args
|
49
|
+
* @param {HTMLElement} element - The HTML Element to add this form to.
|
50
|
+
* @param {string|object} form - The src of the form, or a form object.
|
51
|
+
* @param {object} options - The options to create this form.
|
27
52
|
* @returns {Promise} - When the form is instance is ready.
|
28
53
|
*/
|
29
|
-
Formio.builder = (
|
30
|
-
return (new FormBuilder(
|
54
|
+
Formio.builder = (element, form, options) => {
|
55
|
+
return (new FormBuilder(element, form, options)).ready;
|
31
56
|
};
|
32
57
|
Formio.FormBuilder = FormBuilder;
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { Formio } from './Embed';
|
2
|
+
/**
|
3
|
+
* Inline embed a form within a webpage.
|
4
|
+
* @param {*} config - Configuration to configure how the inline embed is rendered.
|
5
|
+
*/
|
6
|
+
export function embed(config = {}) {
|
7
|
+
const scripts = document.getElementsByTagName('script');
|
8
|
+
config = Object.assign({}, window.FormioConfig || {}, config);
|
9
|
+
let thisScript = null;
|
10
|
+
let i = scripts.length;
|
11
|
+
const scriptName = config.scriptName || 'formio.embed.';
|
12
|
+
while (i--) {
|
13
|
+
if (scripts[i].src && (scripts[i].src.indexOf(scriptName) !== -1)) {
|
14
|
+
thisScript = scripts[i];
|
15
|
+
break;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
if (thisScript) {
|
19
|
+
const query = {};
|
20
|
+
const queryString = thisScript.src.replace(/^[^?]+\??/, '');
|
21
|
+
queryString.replace(/\?/g, '&').split('&').forEach((item) => {
|
22
|
+
query[item.split('=')[0]] = item.split('=')[1] && decodeURIComponent(item.split('=')[1]);
|
23
|
+
});
|
24
|
+
let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
|
25
|
+
scriptSrc.pop();
|
26
|
+
if (config.formioPath) {
|
27
|
+
config.formioPath(scriptSrc);
|
28
|
+
}
|
29
|
+
scriptSrc = scriptSrc.join('/');
|
30
|
+
const debug = (query.debug === 'true' || query.debug === '1');
|
31
|
+
const renderer = debug ? 'formio.form' : 'formio.form.min';
|
32
|
+
Formio.config = Object.assign({
|
33
|
+
script: query.script || (`${config.updatePath ? config.updatePath() : scriptSrc}/${renderer}.js`),
|
34
|
+
style: query.styles || (`${config.updatePath ? config.updatePath() : scriptSrc}/${renderer}.css`),
|
35
|
+
cdn: query.cdn,
|
36
|
+
class: (query.class || 'formio-form-wrapper'),
|
37
|
+
src: query.src,
|
38
|
+
form: null,
|
39
|
+
submission: null,
|
40
|
+
project: query.project,
|
41
|
+
base: query.base || 'https://api.form.io',
|
42
|
+
submit: query.submit,
|
43
|
+
includeLibs: (query.libs === 'true' || query.libs === '1'),
|
44
|
+
template: query.template,
|
45
|
+
debug: debug,
|
46
|
+
config: {},
|
47
|
+
redirect: (query.return || query.redirect),
|
48
|
+
embedCSS: (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.embed.css`),
|
49
|
+
success: query.success || 'Thank you for your submission!',
|
50
|
+
before: null,
|
51
|
+
after: null
|
52
|
+
}, config);
|
53
|
+
const form = (Formio.config.form || Formio.config.src);
|
54
|
+
if (form) {
|
55
|
+
Formio.debug('Embedding Configuration', config);
|
56
|
+
if (Formio.config.addPremiumLib) {
|
57
|
+
Formio.config.addPremiumLib(Formio.config, scriptSrc);
|
58
|
+
}
|
59
|
+
// The id for this embedded form.
|
60
|
+
Formio.config.id = `formio-${Math.random().toString(36).substring(7)}`;
|
61
|
+
Formio.debug('Creating form element');
|
62
|
+
const element = Formio.createElement('div', {
|
63
|
+
'id': Formio.config.id,
|
64
|
+
class: Formio.config.class
|
65
|
+
});
|
66
|
+
// insertAfter doesn't exist, but effect is identical.
|
67
|
+
thisScript.parentNode.insertBefore(element, thisScript.parentNode.firstElementChild.nextSibling);
|
68
|
+
Formio.createForm(element, form, Formio.config.config).then((instance) => {
|
69
|
+
if (Formio.config.submit) {
|
70
|
+
instance.nosubmit = true;
|
71
|
+
}
|
72
|
+
// Configure a redirect.
|
73
|
+
instance.on('submit', (submission) => {
|
74
|
+
Formio.debug("on('submit')", submission);
|
75
|
+
if (Formio.config.submit) {
|
76
|
+
Formio.debug(`Sending submission to ${Formio.config.submit}`);
|
77
|
+
const headers = {
|
78
|
+
'content-type': 'application/json'
|
79
|
+
};
|
80
|
+
const token = Formio.FormioClass.getToken();
|
81
|
+
if (token) {
|
82
|
+
headers['x-jwt-token'] = token;
|
83
|
+
}
|
84
|
+
Formio.FormioClass.fetch(Formio.config.submit, {
|
85
|
+
body: JSON.stringify(submission),
|
86
|
+
headers: headers,
|
87
|
+
method: 'POST',
|
88
|
+
mode: 'cors',
|
89
|
+
})
|
90
|
+
.then(resp => resp.json())
|
91
|
+
.then(submission => Formio.submitDone(instance, submission));
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
Formio.submitDone(instance, submission);
|
95
|
+
}
|
96
|
+
});
|
97
|
+
});
|
98
|
+
}
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
// Show an error if the script cannot be found.
|
102
|
+
document.write('<span>Could not locate the Embedded form.</span>');
|
103
|
+
}
|
104
|
+
}
|
105
|
+
export { Formio };
|
package/lib/mjs/PDF.d.ts
CHANGED
package/lib/mjs/Webform.d.ts
CHANGED
@@ -89,14 +89,14 @@
|
|
89
89
|
declare class Webform extends NestedDataComponent {
|
90
90
|
/**
|
91
91
|
* Creates a new Form instance.
|
92
|
-
* @param {HTMLElement | object | FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
|
93
|
-
* @param {FormOptions} [options] - The options to create a new form instance.
|
92
|
+
* @param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
|
93
|
+
* @param {import('Form').FormOptions} [options] - The options to create a new form instance.
|
94
94
|
*/
|
95
|
-
constructor(elementOrOptions?: HTMLElement | object | FormOptions, options?:
|
95
|
+
constructor(elementOrOptions?: HTMLElement | object | import('Form').FormOptions, options?: any);
|
96
96
|
/**
|
97
|
-
* @type {FormOptions} - the options for this Webform.
|
97
|
+
* @type {import('Form').FormOptions} - the options for this Webform.
|
98
98
|
*/
|
99
|
-
options:
|
99
|
+
options: any;
|
100
100
|
_src: string;
|
101
101
|
_loading: boolean;
|
102
102
|
_form: {};
|
@@ -359,7 +359,7 @@ declare class Webform extends NestedDataComponent {
|
|
359
359
|
executeFormController(): false | undefined;
|
360
360
|
build(element: any): Promise<any>;
|
361
361
|
getClassName(): string;
|
362
|
-
render():
|
362
|
+
render(): import("./components/_classes/field/Field").default;
|
363
363
|
redraw(): Promise<void> | Promise<boolean>;
|
364
364
|
attach(element: any): Promise<boolean>;
|
365
365
|
hasRequiredFields(): boolean;
|
package/lib/mjs/Webform.js
CHANGED
@@ -134,13 +134,13 @@ function getOptions(options) {
|
|
134
134
|
*/
|
135
135
|
export default class Webform extends NestedDataComponent {
|
136
136
|
/**
|
137
|
-
* @type {FormOptions} - the options for this Webform.
|
137
|
+
* @type {import('Form').FormOptions} - the options for this Webform.
|
138
138
|
*/
|
139
139
|
options;
|
140
140
|
/**
|
141
141
|
* Creates a new Form instance.
|
142
|
-
* @param {HTMLElement | object | FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
|
143
|
-
* @param {FormOptions} [options] - The options to create a new form instance.
|
142
|
+
* @param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
|
143
|
+
* @param {import('Form').FormOptions} [options] - The options to create a new form instance.
|
144
144
|
*/
|
145
145
|
constructor(elementOrOptions, options) {
|
146
146
|
let element, formOptions;
|
package/lib/mjs/Wizard.d.ts
CHANGED
@@ -88,7 +88,7 @@ declare class Wizard extends Webform {
|
|
88
88
|
}): any[];
|
89
89
|
findRootPanel(component: any): any;
|
90
90
|
setRootPanelId(component: any): void;
|
91
|
-
establishPages(data?:
|
91
|
+
establishPages(data?: object): any[];
|
92
92
|
updatePages(): void;
|
93
93
|
addComponents(): void;
|
94
94
|
setPage(num: any): Promise<void>;
|
@@ -680,25 +680,26 @@ export default class PasswordStrengthAddon extends FormioAddon {
|
|
680
680
|
};
|
681
681
|
/**
|
682
682
|
* Determines is a password is secure enough to submit
|
683
|
-
* @returns {boolean}
|
683
|
+
* @returns {boolean} - returns TRUE if password is valid, FALSE if it is not.
|
684
684
|
*/
|
685
685
|
isValid(): boolean;
|
686
686
|
/**
|
687
687
|
* Handles the result of check and constructs a new error object or returns an amount of points to add to the current entropy
|
688
688
|
* @param {boolean|number} valid - Determines if the validation was failed or an amount of points if it was passed
|
689
689
|
* @param {*} validation - Validation configuration
|
690
|
-
* @param {string} value - Value which was validated
|
691
690
|
* @param {string} message - Message which should be shown if validation was not passed
|
692
|
-
* @param errors
|
691
|
+
* @param {any[]} errors - The errors array (will be mutated)
|
692
|
+
* @returns {number} - Returns an amount of points to add to the current entropy
|
693
693
|
*/
|
694
|
-
handleRuleCheckResult(valid: boolean | number, validation: any, message: string, errors: any):
|
694
|
+
handleRuleCheckResult(valid: boolean | number, validation: any, message: string, errors: any[]): number;
|
695
695
|
performChecks(value: any): {
|
696
696
|
charactersPoolSize: number;
|
697
697
|
errors: any[];
|
698
698
|
};
|
699
699
|
/**
|
700
700
|
* Performs checks to validate password security
|
701
|
-
* @param {string} value -
|
701
|
+
* @param {string} value - The password value to be checked.
|
702
|
+
* @returns {boolean} - Returns TRUE if password is strong enough, FALSE if it is not.
|
702
703
|
*/
|
703
704
|
checkValidity(value: string): boolean;
|
704
705
|
handleBlackListCheckResult(result: any, errors: any): void;
|
@@ -709,8 +710,9 @@ export default class PasswordStrengthAddon extends FormioAddon {
|
|
709
710
|
/**
|
710
711
|
* Finds the level which one the passed entropy suits
|
711
712
|
* @param {number} entropy - Points of password's security
|
713
|
+
* @returns {object} - Returns the level object
|
712
714
|
*/
|
713
|
-
getLevel(entropy?: number):
|
715
|
+
getLevel(entropy?: number): object;
|
714
716
|
/**
|
715
717
|
* Update the current view of the password's security indicator
|
716
718
|
*/
|