@formio/js 5.4.0-api98.1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.builder.css +15 -0
- package/dist/formio.builder.min.css +1 -1
- 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.css +15 -0
- package/dist/formio.form.js +917 -897
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -2
- package/dist/formio.full.css +15 -0
- package/dist/formio.full.js +1211 -1191
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -2
- package/dist/formio.js +832 -812
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -2
- package/dist/formio.utils.js +774 -754
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -2
- package/lib/cjs/Element.d.ts +11 -0
- package/lib/cjs/Element.js +24 -0
- package/lib/cjs/Embed.js +23 -2
- package/lib/cjs/Form.d.ts +1 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/PDFBuilder.js +6 -1
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Webform.js +9 -6
- package/lib/cjs/WebformBuilder.js +14 -1
- package/lib/cjs/Wizard.js +15 -11
- package/lib/cjs/components/Components.d.ts +3 -0
- package/lib/cjs/components/Components.js +3 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +8 -0
- package/lib/cjs/components/_classes/component/Component.js +121 -42
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/cjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -7
- package/lib/cjs/components/address/Address.js +2 -0
- package/lib/cjs/components/datagrid/DataGrid.js +31 -5
- package/lib/cjs/components/datamap/DataMap.d.ts +1 -4
- package/lib/cjs/components/datamap/DataMap.js +42 -10
- package/lib/cjs/components/datetime/DateTime.js +11 -1
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.d.ts +18 -1
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +3 -0
- package/lib/cjs/components/datetime/editForm/DateTime.edit.time.d.ts +13 -2
- package/lib/cjs/components/datetime/editForm/DateTime.edit.time.js +3 -0
- package/lib/cjs/components/day/Day.d.ts +0 -15
- package/lib/cjs/components/day/Day.js +8 -17
- package/lib/cjs/components/editgrid/EditGrid.js +13 -3
- package/lib/cjs/components/file/File.js +7 -6
- package/lib/cjs/components/form/Form.d.ts +1 -0
- package/lib/cjs/components/form/Form.js +20 -8
- package/lib/cjs/components/number/Number.d.ts +1 -0
- package/lib/cjs/components/number/Number.js +18 -0
- package/lib/cjs/components/select/Select.js +4 -0
- package/lib/cjs/components/signature/Signature.js +5 -5
- package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +9 -23
- package/lib/cjs/formio.form.js +2 -5
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/providers/storage/azure.js +9 -3
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +3 -3
- package/lib/cjs/utils/utils.d.ts +1 -1
- package/lib/cjs/utils/utils.js +23 -6
- package/lib/cjs/widgets/CalendarWidget.js +1 -1
- package/lib/mjs/Element.d.ts +11 -0
- package/lib/mjs/Element.js +23 -0
- package/lib/mjs/Embed.js +21 -2
- package/lib/mjs/Form.d.ts +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/PDFBuilder.js +6 -1
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Webform.js +6 -3
- package/lib/mjs/WebformBuilder.js +13 -1
- package/lib/mjs/Wizard.js +9 -10
- package/lib/mjs/components/Components.d.ts +3 -0
- package/lib/mjs/components/Components.js +3 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +8 -0
- package/lib/mjs/components/_classes/component/Component.js +119 -41
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/mjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +5 -6
- package/lib/mjs/components/address/Address.js +2 -0
- package/lib/mjs/components/datagrid/DataGrid.js +34 -5
- package/lib/mjs/components/datamap/DataMap.d.ts +1 -4
- package/lib/mjs/components/datamap/DataMap.js +41 -10
- package/lib/mjs/components/datetime/DateTime.js +11 -1
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.d.ts +18 -1
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +3 -0
- package/lib/mjs/components/datetime/editForm/DateTime.edit.time.d.ts +13 -2
- package/lib/mjs/components/datetime/editForm/DateTime.edit.time.js +3 -0
- package/lib/mjs/components/day/Day.d.ts +0 -15
- package/lib/mjs/components/day/Day.js +8 -17
- package/lib/mjs/components/editgrid/EditGrid.js +12 -2
- package/lib/mjs/components/file/File.js +7 -6
- package/lib/mjs/components/form/Form.d.ts +1 -0
- package/lib/mjs/components/form/Form.js +18 -6
- package/lib/mjs/components/number/Number.d.ts +1 -0
- package/lib/mjs/components/number/Number.js +17 -0
- package/lib/mjs/components/select/Select.js +4 -0
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +9 -23
- package/lib/mjs/formio.form.js +4 -7
- package/lib/mjs/package.json +1 -1
- package/lib/mjs/providers/storage/azure.js +9 -3
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +3 -3
- package/lib/mjs/utils/utils.d.ts +1 -1
- package/lib/mjs/utils/utils.js +22 -6
- package/lib/mjs/widgets/CalendarWidget.js +2 -2
- package/package.json +7 -6
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* MIT licensed
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
/*! @license DOMPurify 3.
|
|
21
|
+
/*! @license DOMPurify 3.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.0/LICENSE */
|
|
22
22
|
|
|
23
|
-
/*! formiojs v5.4.0
|
|
23
|
+
/*! formiojs v5.4.0 | https://unpkg.com/formiojs@5.4.0/LICENSE.txt */
|
|
24
24
|
|
|
25
25
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
26
26
|
|
package/lib/cjs/Element.d.ts
CHANGED
|
@@ -210,6 +210,17 @@ export default class Element {
|
|
|
210
210
|
* @returns {this} - The instance of the element.
|
|
211
211
|
*/
|
|
212
212
|
removeClass(element: HTMLElement, className: string): this;
|
|
213
|
+
/**
|
|
214
|
+
* Idempotently add or remove a class on a DOM element based on a boolean.
|
|
215
|
+
* Skips the mutation when the element is already in the desired state, so
|
|
216
|
+
* callers can safely invoke it on every change without triggering redundant
|
|
217
|
+
* CSS transitions or attribute writes.
|
|
218
|
+
* @param {HTMLElement} element - The DOM element to toggle the class on.
|
|
219
|
+
* @param {string} className - The class name to add or remove.
|
|
220
|
+
* @param {boolean} want - TRUE to ensure the class is present, FALSE to ensure it is absent.
|
|
221
|
+
* @returns {this} - The instance of the element.
|
|
222
|
+
*/
|
|
223
|
+
toggleClass(element: HTMLElement, className: string, want: boolean): this;
|
|
213
224
|
/**
|
|
214
225
|
* Empty's an HTML DOM element.
|
|
215
226
|
* @param {HTMLElement} element - The element you wish to empty.
|
package/lib/cjs/Element.js
CHANGED
|
@@ -487,6 +487,30 @@ class Element {
|
|
|
487
487
|
}
|
|
488
488
|
return this;
|
|
489
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Idempotently add or remove a class on a DOM element based on a boolean.
|
|
492
|
+
* Skips the mutation when the element is already in the desired state, so
|
|
493
|
+
* callers can safely invoke it on every change without triggering redundant
|
|
494
|
+
* CSS transitions or attribute writes.
|
|
495
|
+
* @param {HTMLElement} element - The DOM element to toggle the class on.
|
|
496
|
+
* @param {string} className - The class name to add or remove.
|
|
497
|
+
* @param {boolean} want - TRUE to ensure the class is present, FALSE to ensure it is absent.
|
|
498
|
+
* @returns {this} - The instance of the element.
|
|
499
|
+
*/
|
|
500
|
+
toggleClass(element, className, want) {
|
|
501
|
+
var _a;
|
|
502
|
+
if (!element || !className || !(element instanceof HTMLElement)) {
|
|
503
|
+
return this;
|
|
504
|
+
}
|
|
505
|
+
const has = !!((_a = element.classList) === null || _a === void 0 ? void 0 : _a.contains(className));
|
|
506
|
+
if (want && !has) {
|
|
507
|
+
this.addClass(element, className);
|
|
508
|
+
}
|
|
509
|
+
else if (!want && has) {
|
|
510
|
+
this.removeClass(element, className);
|
|
511
|
+
}
|
|
512
|
+
return this;
|
|
513
|
+
}
|
|
490
514
|
/**
|
|
491
515
|
* Empty's an HTML DOM element.
|
|
492
516
|
* @param {HTMLElement} element - The element you wish to empty.
|
package/lib/cjs/Embed.js
CHANGED
|
@@ -273,6 +273,7 @@ class Formio {
|
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
static init(element, options = {}, builder = false) {
|
|
276
|
+
var _b;
|
|
276
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
278
|
_a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});
|
|
278
279
|
_a.config.libs = _a.config.libs || {
|
|
@@ -352,6 +353,25 @@ class Formio {
|
|
|
352
353
|
};
|
|
353
354
|
});
|
|
354
355
|
const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;
|
|
356
|
+
const hasQuillComponent = (components = []) => {
|
|
357
|
+
if (!Array.isArray(components)) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
return components.some((component) => {
|
|
361
|
+
var _b, _c;
|
|
362
|
+
if (!component || typeof component !== 'object') {
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
const isQuillTextarea = component.type === 'textarea' &&
|
|
366
|
+
component.wysiwyg === true &&
|
|
367
|
+
component.editor === 'quill';
|
|
368
|
+
return (isQuillTextarea ||
|
|
369
|
+
hasQuillComponent(component.components) ||
|
|
370
|
+
hasQuillComponent((_b = component.columns) === null || _b === void 0 ? void 0 : _b.flatMap((column) => column.components || [])) ||
|
|
371
|
+
hasQuillComponent((_c = component.rows) === null || _c === void 0 ? void 0 : _c.flatMap((row) => row.flatMap((cell) => cell.components || []))));
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
const disableShadowForQuill = hasQuillComponent((_b = _a.config.form) === null || _b === void 0 ? void 0 : _b.components);
|
|
355
375
|
// Create a new wrapper and add the element inside of a new wrapper.
|
|
356
376
|
let wrapper = _a.createElement('div', {
|
|
357
377
|
id: `${id}-wrapper`,
|
|
@@ -360,6 +380,7 @@ class Formio {
|
|
|
360
380
|
// If we include the libraries, then we will attempt to run this in shadow dom.
|
|
361
381
|
const useShadowDom = _a.config.includeLibs &&
|
|
362
382
|
!_a.config.noshadow &&
|
|
383
|
+
!disableShadowForQuill &&
|
|
363
384
|
typeof wrapper.attachShadow === 'function';
|
|
364
385
|
if (useShadowDom) {
|
|
365
386
|
wrapper = wrapper.attachShadow({
|
|
@@ -368,7 +389,7 @@ class Formio {
|
|
|
368
389
|
options.shadowRoot = wrapper;
|
|
369
390
|
// Due to an issue with quill not loading styles in the shadowdom, we need to add quill styles and js to the shadowdom
|
|
370
391
|
const quill = {
|
|
371
|
-
js: `${_a.cdn.quill}/quill.
|
|
392
|
+
js: `${_a.cdn.quill}/quill.js`,
|
|
372
393
|
css: `${_a.cdn.quill}/quill.snow.css`
|
|
373
394
|
};
|
|
374
395
|
yield _a.addLibrary(wrapper, quill, 'quill');
|
|
@@ -487,7 +508,7 @@ Formio.formioReady = new Promise((ready, reject) => {
|
|
|
487
508
|
_a._formioReady = ready;
|
|
488
509
|
_a._formioReadyReject = reject;
|
|
489
510
|
});
|
|
490
|
-
Formio.version = '5.4.0
|
|
511
|
+
Formio.version = '5.4.0';
|
|
491
512
|
// Create a report.
|
|
492
513
|
Formio.Report = {
|
|
493
514
|
create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
package/lib/cjs/Form.d.ts
CHANGED
|
@@ -238,7 +238,7 @@ export type FormOptions = {
|
|
|
238
238
|
/**
|
|
239
239
|
* - The render mode for this form.
|
|
240
240
|
*/
|
|
241
|
-
renderMode?: "
|
|
241
|
+
renderMode?: "form" | "builder" | "html" | "flat" | "pdf" | undefined;
|
|
242
242
|
/**
|
|
243
243
|
* - Highlight any errors on the form.
|
|
244
244
|
*/
|
package/lib/cjs/Formio.js
CHANGED
|
@@ -11,7 +11,7 @@ const CDN_1 = __importDefault(require("./CDN"));
|
|
|
11
11
|
const providers_1 = __importDefault(require("./providers"));
|
|
12
12
|
sdk_1.Formio.cdn = new CDN_1.default();
|
|
13
13
|
sdk_1.Formio.Providers = providers_1.default;
|
|
14
|
-
sdk_1.Formio.version = '5.4.0
|
|
14
|
+
sdk_1.Formio.version = '5.4.0';
|
|
15
15
|
CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc')
|
|
16
16
|
? 'https://cdn.test-form.io'
|
|
17
17
|
: 'https://cdn.form.io';
|
package/lib/cjs/PDFBuilder.js
CHANGED
|
@@ -233,7 +233,12 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
233
233
|
nonFillableConversionUsed: autoConversionComponentsAssigned && result.data.formfields.nonFillableConversionUsed,
|
|
234
234
|
});
|
|
235
235
|
this.emit('pdfUploaded', result.data);
|
|
236
|
-
|
|
236
|
+
if (autoConversionComponentsAssigned) {
|
|
237
|
+
this.rebuild();
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
this.redraw();
|
|
241
|
+
}
|
|
237
242
|
})
|
|
238
243
|
.catch((err) => this.setUploadError(err));
|
|
239
244
|
}
|
package/lib/cjs/Webform.d.ts
CHANGED
|
@@ -259,7 +259,6 @@ declare class Webform extends NestedDataComponent {
|
|
|
259
259
|
* @returns {Promise} - The promise that is triggered when the submission is set.
|
|
260
260
|
*/
|
|
261
261
|
setSubmission(submission: any, flags?: any): Promise<any>;
|
|
262
|
-
_submission: any;
|
|
263
262
|
handleDraftError(errName: any, errDetails: any, restoreDraft: any): void;
|
|
264
263
|
saveDraft(): void;
|
|
265
264
|
/**
|
|
@@ -270,6 +269,7 @@ declare class Webform extends NestedDataComponent {
|
|
|
270
269
|
get schema(): any;
|
|
271
270
|
mergeData(_this: any, _that: any): void;
|
|
272
271
|
editing: boolean | undefined;
|
|
272
|
+
_submission: any;
|
|
273
273
|
/**
|
|
274
274
|
* Build the form.
|
|
275
275
|
* @returns {Promise} - The promise that is triggered when the form is built.
|
package/lib/cjs/Webform.js
CHANGED
|
@@ -659,8 +659,6 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
659
659
|
if (resolveFlags) {
|
|
660
660
|
flags = Object.assign(Object.assign({}, flags), resolveFlags);
|
|
661
661
|
}
|
|
662
|
-
this._submission = {};
|
|
663
|
-
this._data = {};
|
|
664
662
|
this.onSetSubmission(submission, flags);
|
|
665
663
|
return this.submissionReadyResolve(submission);
|
|
666
664
|
}, (err) => this.submissionReadyReject(err))
|
|
@@ -1034,7 +1032,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1034
1032
|
* @returns {void|Array} - The errors that were set.
|
|
1035
1033
|
*/
|
|
1036
1034
|
showErrors(errors, triggerEvent) {
|
|
1037
|
-
var _a;
|
|
1035
|
+
var _a, _b;
|
|
1038
1036
|
this.loading = false;
|
|
1039
1037
|
if (!Array.isArray(errors)) {
|
|
1040
1038
|
errors = [
|
|
@@ -1107,7 +1105,10 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1107
1105
|
});
|
|
1108
1106
|
}
|
|
1109
1107
|
const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
|
|
1110
|
-
|
|
1108
|
+
// Only paint the alert from a subform when the root won't double paint it to avoid a painful flicker
|
|
1109
|
+
if (this === this.root || !((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {
|
|
1110
|
+
(_b = this.root) === null || _b === void 0 ? void 0 : _b.setAlert('danger', errorsList);
|
|
1111
|
+
}
|
|
1111
1112
|
if (triggerEvent) {
|
|
1112
1113
|
this.emit('error', errors);
|
|
1113
1114
|
}
|
|
@@ -1207,7 +1208,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1207
1208
|
* @param {any} changes - The changes that have occured in the form.
|
|
1208
1209
|
*/
|
|
1209
1210
|
onChange(flags, changed, modified, changes) {
|
|
1210
|
-
var _a;
|
|
1211
|
+
var _a, _b;
|
|
1211
1212
|
flags = flags || {};
|
|
1212
1213
|
let isChangeEventEmitted = false;
|
|
1213
1214
|
if (((_a = this.parent) === null || _a === void 0 ? void 0 : _a.subForm) === this) {
|
|
@@ -1227,7 +1228,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1227
1228
|
flags.fromIframe ||
|
|
1228
1229
|
(flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
|
|
1229
1230
|
const errors = shouldValidate
|
|
1230
|
-
? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change' }))
|
|
1231
|
+
? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change', dirty: (_b = flags.dirty) !== null && _b !== void 0 ? _b : this.submitted }))
|
|
1231
1232
|
: [];
|
|
1232
1233
|
value.isValid = (errors || []).filter((err) => !err.fromServer).length === 0;
|
|
1233
1234
|
this.loading = false;
|
|
@@ -1285,6 +1286,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1285
1286
|
}
|
|
1286
1287
|
}
|
|
1287
1288
|
setMetadata(submission) {
|
|
1289
|
+
var _a, _b;
|
|
1288
1290
|
// Add in metadata about client submitting the form
|
|
1289
1291
|
submission.metadata = submission.metadata || {};
|
|
1290
1292
|
lodash_1.default.defaults(submission.metadata, {
|
|
@@ -1296,6 +1298,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1296
1298
|
userAgent: navigator.userAgent,
|
|
1297
1299
|
pathName: window.location.pathname,
|
|
1298
1300
|
onLine: navigator.onLine,
|
|
1301
|
+
language: ((_a = this.i18next) === null || _a === void 0 ? void 0 : _a.originalLanguage) || this.options.language || ((_b = this.i18next) === null || _b === void 0 ? void 0 : _b.language),
|
|
1299
1302
|
});
|
|
1300
1303
|
}
|
|
1301
1304
|
submitForm(options = {}, local = false) {
|
|
@@ -379,11 +379,14 @@ class WebformBuilder extends Component_1.default {
|
|
|
379
379
|
this.attachTooltip(component.refs.editComponent, this.t('Edit'));
|
|
380
380
|
component.addEventListener(component.refs.editComponent, 'click', () => this.editComponent(component.schema, parent, false, false, component.component, {
|
|
381
381
|
inDataGrid: component.isInDataGrid,
|
|
382
|
+
editComponentPath: component.path,
|
|
382
383
|
}));
|
|
383
384
|
}
|
|
384
385
|
if (component.refs.editJson) {
|
|
385
386
|
this.attachTooltip(component.refs.editJson, this.t('Edit JSON'));
|
|
386
|
-
component.addEventListener(component.refs.editJson, 'click', () => this.editComponent(component.schema, parent, false, true, component.component
|
|
387
|
+
component.addEventListener(component.refs.editJson, 'click', () => this.editComponent(component.schema, parent, false, true, component.component, {
|
|
388
|
+
editComponentPath: component.path,
|
|
389
|
+
}));
|
|
387
390
|
}
|
|
388
391
|
if (component.refs.removeComponent) {
|
|
389
392
|
this.attachTooltip(component.refs.removeComponent, this.t('Remove'));
|
|
@@ -1095,10 +1098,19 @@ class WebformBuilder extends Component_1.default {
|
|
|
1095
1098
|
}
|
|
1096
1099
|
}
|
|
1097
1100
|
updateComponent(component, changed) {
|
|
1101
|
+
var _a, _b;
|
|
1098
1102
|
const sanitizeConfig = lodash_1.default.get(this.webform, 'form.settings.sanitizeConfig') ||
|
|
1099
1103
|
lodash_1.default.get(this.webform, 'form.globalSettings.sanitizeConfig');
|
|
1100
1104
|
// Update the preview.
|
|
1101
1105
|
if (this.preview) {
|
|
1106
|
+
if (((_a = changed === null || changed === void 0 ? void 0 : changed.instance) === null || _a === void 0 ? void 0 : _a.key) === 'allowMultipleMasks' && (changed === null || changed === void 0 ? void 0 : changed.value) === false) {
|
|
1107
|
+
const changedComp = (_b = this.preview) === null || _b === void 0 ? void 0 : _b.getComponent(component.key);
|
|
1108
|
+
if (changedComp) {
|
|
1109
|
+
const emptyValue = changedComp.emptyValue;
|
|
1110
|
+
changedComp.dataValue = emptyValue;
|
|
1111
|
+
component.defaultValue = emptyValue;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1102
1114
|
this.preview.form = {
|
|
1103
1115
|
components: [
|
|
1104
1116
|
lodash_1.default.omit(Object.assign({}, component), [
|
|
@@ -1418,6 +1430,7 @@ class WebformBuilder extends Component_1.default {
|
|
|
1418
1430
|
// Pass along the form being edited.
|
|
1419
1431
|
editFormOptions.editForm = this.form;
|
|
1420
1432
|
editFormOptions.editComponent = component;
|
|
1433
|
+
editFormOptions.editComponentPath = flags.editComponentPath;
|
|
1421
1434
|
editFormOptions.flags = flags;
|
|
1422
1435
|
this.hook('editComponentParentInstance', editFormOptions, parent);
|
|
1423
1436
|
this.editForm = new Webform_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, lodash_1.default.omit(this.options, [
|
package/lib/cjs/Wizard.js
CHANGED
|
@@ -188,6 +188,7 @@ class Wizard extends Webform_1.default {
|
|
|
188
188
|
return this.renderTemplate(headerType, ctx);
|
|
189
189
|
}
|
|
190
190
|
render() {
|
|
191
|
+
var _a;
|
|
191
192
|
const ctx = this.renderContext;
|
|
192
193
|
if (this.component.id) {
|
|
193
194
|
ctx.panels.forEach((panel) => {
|
|
@@ -206,7 +207,7 @@ class Wizard extends Webform_1.default {
|
|
|
206
207
|
wizardHeaderLocation,
|
|
207
208
|
wizardNav, components: this.renderComponents([
|
|
208
209
|
...this.prefixComps,
|
|
209
|
-
...this.currentPage.components,
|
|
210
|
+
...((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components) || [],
|
|
210
211
|
...this.suffixComps,
|
|
211
212
|
]) }), this.builderMode ? 'builder' : 'form');
|
|
212
213
|
}
|
|
@@ -250,7 +251,7 @@ class Wizard extends Webform_1.default {
|
|
|
250
251
|
* @returns {Promise} A promise that resolves when all components have been successfully attached.
|
|
251
252
|
*/
|
|
252
253
|
attach(element) {
|
|
253
|
-
var _a;
|
|
254
|
+
var _a, _b;
|
|
254
255
|
this.setElement(element);
|
|
255
256
|
this.loadRefs(element, {
|
|
256
257
|
[this.wizardKey]: 'single',
|
|
@@ -268,7 +269,7 @@ class Wizard extends Webform_1.default {
|
|
|
268
269
|
this.hook('attachWebform', element, this);
|
|
269
270
|
const promises = this.attachComponents(this.refs[this.wizardKey], [
|
|
270
271
|
...this.prefixComps,
|
|
271
|
-
...this.currentPage.components,
|
|
272
|
+
...((_b = this.currentPage) === null || _b === void 0 ? void 0 : _b.components) || [],
|
|
272
273
|
...this.suffixComps,
|
|
273
274
|
]);
|
|
274
275
|
this.attachNav();
|
|
@@ -296,7 +297,8 @@ class Wizard extends Webform_1.default {
|
|
|
296
297
|
isBreadcrumbClickable() {
|
|
297
298
|
let currentPage = null;
|
|
298
299
|
this.pages.map((page) => {
|
|
299
|
-
|
|
300
|
+
var _a;
|
|
301
|
+
if (lodash_1.default.isEqual((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.component, page.component)) {
|
|
300
302
|
currentPage = page;
|
|
301
303
|
}
|
|
302
304
|
});
|
|
@@ -311,11 +313,12 @@ class Wizard extends Webform_1.default {
|
|
|
311
313
|
isAllowPrevious() {
|
|
312
314
|
let currentPage = null;
|
|
313
315
|
this.pages.map((page) => {
|
|
314
|
-
|
|
316
|
+
var _a;
|
|
317
|
+
if (lodash_1.default.isEqual((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.component, page.component)) {
|
|
315
318
|
currentPage = page;
|
|
316
319
|
}
|
|
317
320
|
});
|
|
318
|
-
return lodash_1.default.get(currentPage.component, 'allowPrevious', this.options.allowPrevious);
|
|
321
|
+
return lodash_1.default.get(currentPage === null || currentPage === void 0 ? void 0 : currentPage.component, 'allowPrevious', this.options.allowPrevious);
|
|
319
322
|
}
|
|
320
323
|
/**
|
|
321
324
|
* Handles navigate on 'Enter' key event in a wizard form.
|
|
@@ -544,7 +547,7 @@ class Wizard extends Webform_1.default {
|
|
|
544
547
|
const forceShow = this.shouldForceShow(item);
|
|
545
548
|
const forceHide = this.shouldForceHide(item);
|
|
546
549
|
let isVisible = !page
|
|
547
|
-
? (0, utils_1.checkCondition)(item, data, data, this.component, this) && !item.hidden
|
|
550
|
+
? ((0, utils_1.checkCondition)(item, data, data, this.component, this) && !item.hidden)
|
|
548
551
|
: page.visible;
|
|
549
552
|
if (forceShow) {
|
|
550
553
|
isVisible = true;
|
|
@@ -615,8 +618,9 @@ class Wizard extends Webform_1.default {
|
|
|
615
618
|
this._seenPages = this._seenPages.concat(parentNum);
|
|
616
619
|
}
|
|
617
620
|
return this.redraw().then(() => {
|
|
621
|
+
var _a;
|
|
618
622
|
this.checkData(this.submission.data);
|
|
619
|
-
this.triggerCaptcha(this.currentPage.components);
|
|
623
|
+
this.triggerCaptcha((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components);
|
|
620
624
|
const errors = this.submitted
|
|
621
625
|
? this.validate(this.localData, { dirty: true })
|
|
622
626
|
: this.validateCurrentPage();
|
|
@@ -844,8 +848,7 @@ class Wizard extends Webform_1.default {
|
|
|
844
848
|
return super.setForm(form, flags);
|
|
845
849
|
}
|
|
846
850
|
onSetForm(clonedForm, initialForm) {
|
|
847
|
-
this.component.components =
|
|
848
|
-
(this.parent ? initialForm.components : clonedForm.components) || [];
|
|
851
|
+
this.component.components = (this.parent ? initialForm.components : clonedForm.components) || [];
|
|
849
852
|
this.setComponentSchema();
|
|
850
853
|
}
|
|
851
854
|
setEditMode(submission) {
|
|
@@ -955,11 +958,12 @@ class Wizard extends Webform_1.default {
|
|
|
955
958
|
return super.rebuild().then(setCurrentPage);
|
|
956
959
|
}
|
|
957
960
|
checkValidity(data, dirty, row, currentPageOnly, childErrors = []) {
|
|
961
|
+
var _a;
|
|
958
962
|
if (!this.checkCondition(row, data)) {
|
|
959
963
|
this.setCustomValidity('');
|
|
960
964
|
return true;
|
|
961
965
|
}
|
|
962
|
-
const components = !currentPageOnly || this.isLastPage() ? this.getComponents() : this.currentPage.components;
|
|
966
|
+
const components = !currentPageOnly || this.isLastPage() ? this.getComponents() : (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components;
|
|
963
967
|
return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
|
|
964
968
|
}
|
|
965
969
|
get errors() {
|
|
@@ -2,6 +2,7 @@ export default class Components {
|
|
|
2
2
|
static _editFormUtils: {
|
|
3
3
|
sortAndFilterComponents(components: any): any;
|
|
4
4
|
unifyComponents(objValue: any, srcValue: any): any;
|
|
5
|
+
tokenVariableDescription(): string;
|
|
5
6
|
logicVariablesTable(additional: any): {
|
|
6
7
|
type: string;
|
|
7
8
|
tag: string;
|
|
@@ -86,6 +87,7 @@ export default class Components {
|
|
|
86
87
|
static set EditFormUtils(value: {
|
|
87
88
|
sortAndFilterComponents(components: any): any;
|
|
88
89
|
unifyComponents(objValue: any, srcValue: any): any;
|
|
90
|
+
tokenVariableDescription(): string;
|
|
89
91
|
logicVariablesTable(additional: any): {
|
|
90
92
|
type: string;
|
|
91
93
|
tag: string;
|
|
@@ -169,6 +171,7 @@ export default class Components {
|
|
|
169
171
|
static get EditFormUtils(): {
|
|
170
172
|
sortAndFilterComponents(components: any): any;
|
|
171
173
|
unifyComponents(objValue: any, srcValue: any): any;
|
|
174
|
+
tokenVariableDescription(): string;
|
|
172
175
|
logicVariablesTable(additional: any): {
|
|
173
176
|
type: string;
|
|
174
177
|
tag: string;
|
|
@@ -69,7 +69,9 @@ class Components {
|
|
|
69
69
|
comp = new Component_1.default(component, options, data);
|
|
70
70
|
}
|
|
71
71
|
if (comp.path) {
|
|
72
|
-
comp.
|
|
72
|
+
comp.eachRootChildComponentsMap((map) => {
|
|
73
|
+
map[comp.path] = comp;
|
|
74
|
+
});
|
|
73
75
|
}
|
|
74
76
|
// Reset the componentMatches on the root element if any new component is created.
|
|
75
77
|
let parent = comp.parent;
|
|
@@ -163,6 +163,14 @@ declare class Component extends Element {
|
|
|
163
163
|
*/
|
|
164
164
|
info: any;
|
|
165
165
|
get componentsMap(): object;
|
|
166
|
+
/**
|
|
167
|
+
* Walks this component's root chain, invoking `fn` with each ancestor root's
|
|
168
|
+
* `childComponentsMap`. Component registration is propagated up the wizard /
|
|
169
|
+
* nested-form chain at create time, so any code that mutates a registration
|
|
170
|
+
* (creation, removal, path-driven re-key) must update every map in the chain.
|
|
171
|
+
* @param {(map: object) => void} fn - Called once per root that exposes a `childComponentsMap`.
|
|
172
|
+
*/
|
|
173
|
+
eachRootChildComponentsMap(fn: (map: object) => void): void;
|
|
166
174
|
/**
|
|
167
175
|
* Returns if the parent should conditionally clear.
|
|
168
176
|
*
|