@formio/js 5.1.0-dev.6101.0682abe → 5.1.0-dev.6102.9a0147c
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/README.md +5 -0
- package/dist/formio.form.js +125 -125
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -0
- package/dist/formio.full.js +131 -131
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -0
- package/dist/formio.js +73 -62
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +85 -74
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -0
- package/lib/cjs/Element.js +13 -36
- package/lib/cjs/EventEmitter.js +2 -25
- package/lib/cjs/Form.js +2 -25
- package/lib/cjs/PDF.js +1 -1
- package/lib/cjs/PDFBuilder.js +4 -5
- package/lib/cjs/Webform.js +3 -4
- package/lib/cjs/WebformBuilder.d.ts +1 -0
- package/lib/cjs/WebformBuilder.js +22 -9
- package/lib/cjs/Wizard.d.ts +1 -2
- package/lib/cjs/Wizard.js +18 -24
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/cjs/components/_classes/component/Component.js +29 -53
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/cjs/components/_classes/input/Input.js +1 -1
- package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -7
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/cjs/components/address/Address.js +1 -1
- package/lib/cjs/components/alert/Alert.js +1 -1
- package/lib/cjs/components/button/Button.d.ts +2 -2
- package/lib/cjs/components/button/Button.js +10 -14
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/datagrid/DataGrid.js +5 -1
- package/lib/cjs/components/datamap/DataMap.d.ts +1 -1
- package/lib/cjs/components/datamap/DataMap.js +4 -4
- package/lib/cjs/components/datetime/DateTime.js +1 -1
- package/lib/cjs/components/day/Day.js +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +1 -1
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/cjs/components/file/File.js +5 -6
- package/lib/cjs/components/form/Form.js +1 -1
- package/lib/cjs/components/number/Number.js +1 -1
- package/lib/cjs/components/panel/Panel.js +1 -1
- package/lib/cjs/components/radio/Radio.js +1 -1
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.js +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/components/survey/Survey.js +1 -1
- package/lib/cjs/components/tags/Tags.js +1 -1
- package/lib/cjs/components/textarea/TextArea.js +3 -3
- package/lib/cjs/components/textfield/TextField.js +7 -30
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/formio.form.js +3 -3
- package/lib/cjs/i18n.js +1 -1
- package/lib/cjs/providers/storage/uploadAdapter.js +3 -3
- package/lib/cjs/utils/Evaluator.d.ts +13 -6
- package/lib/cjs/utils/Evaluator.js +27 -15
- package/lib/cjs/utils/builder.js +5 -5
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/i18n.js +3 -3
- package/lib/cjs/utils/index.d.ts +160 -2
- package/lib/cjs/utils/index.js +12 -2
- package/lib/cjs/utils/utils.d.ts +0 -5
- package/lib/cjs/utils/utils.js +4 -42
- package/lib/cjs/widgets/CalendarWidget.js +1 -1
- package/lib/mjs/Element.js +6 -6
- package/lib/mjs/EventEmitter.js +2 -2
- package/lib/mjs/Form.js +1 -1
- package/lib/mjs/PDF.js +1 -1
- package/lib/mjs/PDFBuilder.js +1 -2
- package/lib/mjs/Webform.js +1 -2
- package/lib/mjs/WebformBuilder.d.ts +1 -0
- package/lib/mjs/WebformBuilder.js +14 -2
- package/lib/mjs/Wizard.d.ts +1 -2
- package/lib/mjs/Wizard.js +17 -23
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/mjs/components/_classes/component/Component.js +2 -3
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/mjs/components/_classes/input/Input.js +1 -1
- package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -7
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/mjs/components/address/Address.js +1 -1
- package/lib/mjs/components/alert/Alert.js +1 -1
- package/lib/mjs/components/button/Button.d.ts +2 -2
- package/lib/mjs/components/button/Button.js +7 -10
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/container/Container.js +1 -1
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/datagrid/DataGrid.js +5 -1
- package/lib/mjs/components/datamap/DataMap.d.ts +1 -1
- package/lib/mjs/components/datamap/DataMap.js +1 -1
- package/lib/mjs/components/datetime/DateTime.js +1 -1
- package/lib/mjs/components/day/Day.js +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +1 -1
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/file/File.js +5 -6
- package/lib/mjs/components/form/Form.js +1 -1
- package/lib/mjs/components/number/Number.js +1 -1
- package/lib/mjs/components/panel/Panel.js +1 -1
- package/lib/mjs/components/radio/Radio.js +1 -1
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.js +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/survey/Survey.js +1 -1
- package/lib/mjs/components/tags/Tags.js +1 -1
- package/lib/mjs/components/textarea/TextArea.js +3 -3
- package/lib/mjs/components/textfield/TextField.js +1 -1
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/formio.form.js +2 -2
- package/lib/mjs/i18n.js +1 -1
- package/lib/mjs/providers/storage/uploadAdapter.js +3 -3
- package/lib/mjs/utils/Evaluator.d.ts +13 -6
- package/lib/mjs/utils/Evaluator.js +21 -13
- package/lib/mjs/utils/builder.js +1 -1
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/i18n.js +1 -1
- package/lib/mjs/utils/index.d.ts +160 -2
- package/lib/mjs/utils/index.js +11 -1
- package/lib/mjs/utils/utils.d.ts +0 -5
- package/lib/mjs/utils/utils.js +1 -23
- package/lib/mjs/widgets/CalendarWidget.js +1 -1
- package/package.json +4 -4
@@ -20,6 +20,8 @@
|
|
20
20
|
|
21
21
|
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
|
22
22
|
|
23
|
+
/*! @license DOMPurify 3.2.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.5/LICENSE */
|
24
|
+
|
23
25
|
/*! formiojs v5.1.0-dev.2 | https://unpkg.com/formiojs@5.1.0-dev.2/LICENSE.txt */
|
24
26
|
|
25
27
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
package/lib/cjs/Element.js
CHANGED
@@ -1,38 +1,15 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
4
|
};
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
const EventEmitter_1 = __importDefault(require("./EventEmitter"));
|
30
|
-
const Formio_1 = require("./Formio");
|
31
|
-
const FormioUtils = __importStar(require("./utils/utils"));
|
32
|
-
const i18n_1 = require("./utils/i18n");
|
33
6
|
const lodash_1 = __importDefault(require("lodash"));
|
34
7
|
const moment_1 = __importDefault(require("moment"));
|
35
8
|
const vanilla_text_mask_1 = __importDefault(require("@formio/vanilla-text-mask"));
|
9
|
+
const EventEmitter_1 = __importDefault(require("./EventEmitter"));
|
10
|
+
const Formio_1 = require("./Formio");
|
11
|
+
const i18n_1 = require("./utils/i18n");
|
12
|
+
const utils_1 = __importDefault(require("./utils"));
|
36
13
|
/**
|
37
14
|
* The root component for all elements within the Form.io renderer.
|
38
15
|
*/
|
@@ -56,7 +33,7 @@ class Element {
|
|
56
33
|
* can also be provided from the component.id value passed into the constructor.
|
57
34
|
* @type {string}
|
58
35
|
*/
|
59
|
-
this.id =
|
36
|
+
this.id = utils_1.default.getRandomComponentId();
|
60
37
|
/**
|
61
38
|
* An array of event handlers so that the destry command can deregister them.
|
62
39
|
* @type {Array}
|
@@ -385,7 +362,7 @@ class Element {
|
|
385
362
|
*/
|
386
363
|
setInputMask(input, inputMask, usePlaceholder) {
|
387
364
|
if (input && inputMask) {
|
388
|
-
const mask =
|
365
|
+
const mask = utils_1.default.getInputMask(inputMask, this.placeholderChar);
|
389
366
|
this.defaultMask = mask;
|
390
367
|
try {
|
391
368
|
//destroy previous mask
|
@@ -522,8 +499,8 @@ class Element {
|
|
522
499
|
var _a;
|
523
500
|
return Object.assign({
|
524
501
|
_: lodash_1.default,
|
525
|
-
utils:
|
526
|
-
util:
|
502
|
+
utils: utils_1.default,
|
503
|
+
util: utils_1.default,
|
527
504
|
user: Formio_1.Formio.getUser(),
|
528
505
|
moment: moment_1.default,
|
529
506
|
instance: this,
|
@@ -548,15 +525,15 @@ class Element {
|
|
548
525
|
*/
|
549
526
|
interpolate(string, data, options = {}) {
|
550
527
|
if (typeof string !== 'function' && (this.component.content || this.component.html)
|
551
|
-
&& !
|
552
|
-
string =
|
528
|
+
&& !utils_1.default.Evaluator.templateSettings.interpolate.test(string)) {
|
529
|
+
string = utils_1.default.translateHTMLTemplate(String(string), (value) => this.t(value));
|
553
530
|
}
|
554
531
|
if (this.component.filter === string && !this.options.building) {
|
555
532
|
const evalContext = this.evalContext(data);
|
556
533
|
evalContext.data = lodash_1.default.mapValues(evalContext.data, (val) => lodash_1.default.isString(val) ? encodeURIComponent(val) : val);
|
557
|
-
return
|
534
|
+
return utils_1.default.Evaluator.interpolate(string, evalContext, options);
|
558
535
|
}
|
559
|
-
return
|
536
|
+
return utils_1.default.Evaluator.interpolate(string, this.evalContext(data), options);
|
560
537
|
}
|
561
538
|
/**
|
562
539
|
* Performs an evaluation using the evaluation context of this component.
|
@@ -568,7 +545,7 @@ class Element {
|
|
568
545
|
* @returns {*} - The result of the evaluation.
|
569
546
|
*/
|
570
547
|
evaluate(func, args, ret, interpolate, options = {}) {
|
571
|
-
return
|
548
|
+
return utils_1.default.evaluate(func, this.evalContext(args), ret, interpolate, options);
|
572
549
|
}
|
573
550
|
/**
|
574
551
|
* Allow for options to hook into the functionality of this renderer.
|
package/lib/cjs/EventEmitter.js
CHANGED
@@ -1,30 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
3
|
const eventemitter3_1 = require("eventemitter3");
|
27
|
-
const
|
4
|
+
const utils_1 = require("./utils");
|
28
5
|
class EventEmitter extends eventemitter3_1.EventEmitter {
|
29
6
|
constructor(conf = {}) {
|
30
7
|
const { loadLimit = 1000, eventsSafeInterval = 300 } = conf;
|
@@ -38,7 +15,7 @@ class EventEmitter extends eventemitter3_1.EventEmitter {
|
|
38
15
|
const overloadHandler = () => {
|
39
16
|
console.warn(`There were more than ${loadLimit} events emitted in ${eventsSafeInterval} ms. It might be caused by events' infinite loop`, this.id);
|
40
17
|
};
|
41
|
-
const dispatch =
|
18
|
+
const dispatch = (0, utils_1.observeOverload)(overloadHandler, {
|
42
19
|
limit: loadLimit,
|
43
20
|
delay: eventsSafeInterval
|
44
21
|
});
|
package/lib/cjs/Form.js
CHANGED
@@ -1,27 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
4
|
};
|
@@ -30,7 +7,7 @@ const Element_1 = __importDefault(require("./Element"));
|
|
30
7
|
const Formio_1 = require("./Formio");
|
31
8
|
const displays_1 = __importDefault(require("./displays"));
|
32
9
|
const templates_1 = __importDefault(require("./templates"));
|
33
|
-
const
|
10
|
+
const utils_1 = __importDefault(require("./utils"));
|
34
11
|
class Form extends Element_1.default {
|
35
12
|
constructor(elementOrForm, formOrOptions, options = {}) {
|
36
13
|
let element, form, formOptions;
|
@@ -324,7 +301,7 @@ class Form extends Element_1.default {
|
|
324
301
|
if (this.options.sanitize === false && !forceSanitize) {
|
325
302
|
return dirty;
|
326
303
|
}
|
327
|
-
return
|
304
|
+
return utils_1.default.sanitize(dirty, this.options);
|
328
305
|
}
|
329
306
|
setContent(element, content, forceSanitize) {
|
330
307
|
if (element instanceof HTMLElement) {
|
package/lib/cjs/PDF.js
CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const Formio_1 = require("./Formio");
|
7
7
|
const Webform_1 = __importDefault(require("./Webform"));
|
8
|
-
const utils_1 = require("./utils
|
8
|
+
const utils_1 = require("./utils");
|
9
9
|
class PDF extends Webform_1.default {
|
10
10
|
constructor(element, options) {
|
11
11
|
options.display = 'pdf';
|
package/lib/cjs/PDFBuilder.js
CHANGED
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const Formio_1 = require("./Formio");
|
8
8
|
const WebformBuilder_1 = __importDefault(require("./WebformBuilder"));
|
9
|
-
const utils_1 = require("./utils
|
10
|
-
const formUtils_1 = require("./utils/formUtils");
|
9
|
+
const utils_1 = require("./utils");
|
11
10
|
const builder_1 = __importDefault(require("./utils/builder"));
|
12
11
|
const PDF_1 = __importDefault(require("./PDF"));
|
13
12
|
class PDFBuilder extends WebformBuilder_1.default {
|
@@ -272,7 +271,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
272
271
|
getParentContainer(component) {
|
273
272
|
let container = [];
|
274
273
|
let originalComponent = null;
|
275
|
-
(0,
|
274
|
+
(0, utils_1.eachComponent)(this.webform._form.components, (comp, path, components) => {
|
276
275
|
if (comp.id === component.component.id) {
|
277
276
|
container = components;
|
278
277
|
originalComponent = comp;
|
@@ -455,7 +454,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
455
454
|
const repeatablePaths = this.findRepeatablePaths();
|
456
455
|
// update elements which path was duplicated if any pathes have been changed
|
457
456
|
if (!lodash_1.default.isEqual(this.repeatablePaths, repeatablePaths)) {
|
458
|
-
(0,
|
457
|
+
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
|
459
458
|
if (this.repeatablePaths.includes(path)) {
|
460
459
|
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
461
460
|
}
|
@@ -465,7 +464,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
465
464
|
if (!repeatablePaths.length) {
|
466
465
|
return;
|
467
466
|
}
|
468
|
-
(0,
|
467
|
+
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
|
469
468
|
if (this.repeatablePaths.includes(path)) {
|
470
469
|
this.webform.postMessage({
|
471
470
|
name: 'showBuilderErrors',
|
package/lib/cjs/Webform.js
CHANGED
@@ -11,8 +11,7 @@ const i18n_1 = __importDefault(require("./i18n"));
|
|
11
11
|
const Formio_1 = require("./Formio");
|
12
12
|
const Components_1 = __importDefault(require("./components/Components"));
|
13
13
|
const NestedDataComponent_1 = __importDefault(require("./components/_classes/nesteddata/NestedDataComponent"));
|
14
|
-
const utils_1 = require("./utils
|
15
|
-
const formUtils_1 = require("./utils/formUtils");
|
14
|
+
const utils_1 = require("./utils");
|
16
15
|
// We need this here because dragula pulls in CustomEvent class that requires global to exist.
|
17
16
|
if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
|
18
17
|
window.global = window;
|
@@ -992,7 +991,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
992
991
|
}
|
993
992
|
hasRequiredFields() {
|
994
993
|
let result = false;
|
995
|
-
(0,
|
994
|
+
(0, utils_1.eachComponent)(this.form.components, (component) => {
|
996
995
|
if (component.validate.required) {
|
997
996
|
result = true;
|
998
997
|
return true;
|
@@ -1538,7 +1537,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
1538
1537
|
return;
|
1539
1538
|
}
|
1540
1539
|
const captchaComponent = [];
|
1541
|
-
(0,
|
1540
|
+
(0, utils_1.eachComponent)(components || this.components, (component) => {
|
1542
1541
|
if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
|
1543
1542
|
captchaComponent.push(component);
|
1544
1543
|
}
|
@@ -77,6 +77,7 @@ export default class WebformBuilder extends Component {
|
|
77
77
|
removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
|
78
78
|
replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
|
79
79
|
updateComponent(component: any, changed: any): void;
|
80
|
+
originalDefaultValue: any;
|
80
81
|
findRepeatablePaths(): any[];
|
81
82
|
highlightInvalidComponents(): void;
|
82
83
|
/**
|
@@ -8,8 +8,7 @@ const Component_1 = __importDefault(require("./components/_classes/component/Com
|
|
8
8
|
const tippy_js_1 = __importDefault(require("tippy.js"));
|
9
9
|
const Components_1 = __importDefault(require("./components/Components"));
|
10
10
|
const Formio_1 = require("./Formio");
|
11
|
-
const utils_1 = require("./utils
|
12
|
-
const formUtils_1 = require("./utils/formUtils");
|
11
|
+
const utils_1 = require("./utils");
|
13
12
|
const builder_1 = __importDefault(require("./utils/builder"));
|
14
13
|
const lodash_1 = __importDefault(require("lodash"));
|
15
14
|
const dom_autoscroller_1 = __importDefault(require("dom-autoscroller"));
|
@@ -284,7 +283,7 @@ class WebformBuilder extends Component_1.default {
|
|
284
283
|
componentOrder: [],
|
285
284
|
default: index === 0,
|
286
285
|
};
|
287
|
-
(0,
|
286
|
+
(0, utils_1.eachComponent)(resource.components, (component) => {
|
288
287
|
if (component.type === 'button')
|
289
288
|
return;
|
290
289
|
if (this.options &&
|
@@ -450,7 +449,7 @@ class WebformBuilder extends Component_1.default {
|
|
450
449
|
return [...componentSchema.components, componentSchema];
|
451
450
|
}
|
452
451
|
// Get the namespace component so we have the original object.
|
453
|
-
const namespaceComponent = (0,
|
452
|
+
const namespaceComponent = (0, utils_1.getComponent)(this.form.components, namespaceKey, true);
|
454
453
|
return namespaceComponent ? namespaceComponent.components : comp.components;
|
455
454
|
}
|
456
455
|
recurseNamespace(component) {
|
@@ -812,7 +811,7 @@ class WebformBuilder extends Component_1.default {
|
|
812
811
|
const draggableComponent = ((_a = this.groups[group]) === null || _a === void 0 ? void 0 : _a.components[compKey]) || {};
|
813
812
|
if (draggableComponent.disableSiblings || draggableComponent.uniqueComponent) {
|
814
813
|
let isCompAlreadyExists = false;
|
815
|
-
(0,
|
814
|
+
(0, utils_1.eachComponent)(this.webform.components, (component) => {
|
816
815
|
if ((draggableComponent.disableSiblings && component.type === draggableComponent.schema.type) ||
|
817
816
|
(draggableComponent.uniqueComponent && component.component.key === draggableComponent.schema.key)) {
|
818
817
|
isCompAlreadyExists = true;
|
@@ -947,7 +946,7 @@ class WebformBuilder extends Component_1.default {
|
|
947
946
|
//populate isEnabled for captcha form settings
|
948
947
|
let isCaptchaEnabled = false;
|
949
948
|
if (this.form.components) {
|
950
|
-
(0,
|
949
|
+
(0, utils_1.eachComponent)(form.components, component => {
|
951
950
|
if (isCaptchaEnabled) {
|
952
951
|
return;
|
953
952
|
}
|
@@ -1042,7 +1041,7 @@ class WebformBuilder extends Component_1.default {
|
|
1042
1041
|
}
|
1043
1042
|
}
|
1044
1043
|
// Change the "default value" field to be reflective of this component.
|
1045
|
-
const defaultValueComponent = (0,
|
1044
|
+
const defaultValueComponent = (0, utils_1.getComponent)(this.editForm.components, 'defaultValue', true);
|
1046
1045
|
if (defaultValueComponent && component.type !== 'hidden') {
|
1047
1046
|
const defaultChanged = changed && ((changed.component && changed.component.key === 'defaultValue')
|
1048
1047
|
|| (changed.instance && defaultValueComponent.hasComponent && defaultValueComponent.hasComponent(changed.instance)));
|
@@ -1070,6 +1069,17 @@ class WebformBuilder extends Component_1.default {
|
|
1070
1069
|
'fields.month.required',
|
1071
1070
|
'fields.year.required',
|
1072
1071
|
]));
|
1072
|
+
if (defaultValueComponent.component.components) {
|
1073
|
+
if (!this.originalDefaultValue) {
|
1074
|
+
this.originalDefaultValue = (0, utils_1.fastCloneDeep)(defaultValueComponent.component);
|
1075
|
+
}
|
1076
|
+
(0, utils_1.eachComponent)(defaultValueComponent.component.components, (comp => {
|
1077
|
+
var _a;
|
1078
|
+
if ((_a = comp.validate) === null || _a === void 0 ? void 0 : _a.required) {
|
1079
|
+
comp.validate.required = false;
|
1080
|
+
}
|
1081
|
+
}));
|
1082
|
+
}
|
1073
1083
|
const parentComponent = defaultValueComponent.parent;
|
1074
1084
|
let tabIndex = -1;
|
1075
1085
|
let index = -1;
|
@@ -1118,7 +1128,7 @@ class WebformBuilder extends Component_1.default {
|
|
1118
1128
|
findRepeatablePaths() {
|
1119
1129
|
const repeatablePaths = [];
|
1120
1130
|
const keys = new Map();
|
1121
|
-
(0,
|
1131
|
+
(0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
|
1122
1132
|
if (keys.has(paths.dataPath)) {
|
1123
1133
|
repeatablePaths.push(paths.dataPath);
|
1124
1134
|
}
|
@@ -1161,6 +1171,9 @@ class WebformBuilder extends Component_1.default {
|
|
1161
1171
|
if (index !== -1) {
|
1162
1172
|
let submissionData = this.editForm.submission.data;
|
1163
1173
|
submissionData = submissionData.componentJson || submissionData;
|
1174
|
+
if (submissionData.components && this.originalDefaultValue) {
|
1175
|
+
submissionData.components = this.originalDefaultValue.components;
|
1176
|
+
}
|
1164
1177
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
1165
1178
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
1166
1179
|
this.hook('beforeSaveComponentSettings', submissionData);
|
@@ -1627,7 +1640,7 @@ class WebformBuilder extends Component_1.default {
|
|
1627
1640
|
if (!Components_1.default.components[type === 'custom' ? 'unknown' : type]) {
|
1628
1641
|
return false;
|
1629
1642
|
}
|
1630
|
-
const editTabs = (0,
|
1643
|
+
const editTabs = (0, utils_1.getComponent)(Components_1.default.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
|
1631
1644
|
const hiddenEditTabs = lodash_1.default.filter(lodash_1.default.get(this.options, `editForm.${type}`, []), 'ignore');
|
1632
1645
|
return lodash_1.default.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
|
1633
1646
|
}
|
package/lib/cjs/Wizard.d.ts
CHANGED
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
|
|
6
6
|
originalComponents: any[];
|
7
7
|
page: number;
|
8
8
|
currentPanel: any;
|
9
|
-
currentPanels: any[] | null;
|
10
9
|
currentNextPage: number;
|
11
10
|
_seenPages: number[];
|
12
11
|
subWizards: any[];
|
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
|
|
17
16
|
originalOptions: any;
|
18
17
|
isLastPage(): any;
|
19
18
|
getPages(args?: {}): any[];
|
20
|
-
get
|
19
|
+
get hasSubWizards(): boolean;
|
21
20
|
get localData(): any;
|
22
21
|
get wizardKey(): string;
|
23
22
|
set wizard(form: object);
|
package/lib/cjs/Wizard.js
CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const Webform_1 = __importDefault(require("./Webform"));
|
8
8
|
const Formio_1 = require("./Formio");
|
9
|
-
const utils_1 = require("./utils
|
9
|
+
const utils_1 = require("./utils");
|
10
10
|
class Wizard extends Webform_1.default {
|
11
11
|
/**
|
12
12
|
* Constructor for wizard-based forms.
|
@@ -34,7 +34,6 @@ class Wizard extends Webform_1.default {
|
|
34
34
|
this.originalComponents = [];
|
35
35
|
this.page = 0;
|
36
36
|
this.currentPanel = null;
|
37
|
-
this.currentPanels = null;
|
38
37
|
this.currentNextPage = 0;
|
39
38
|
this._seenPages = [0];
|
40
39
|
this.subWizards = [];
|
@@ -53,12 +52,12 @@ class Wizard extends Webform_1.default {
|
|
53
52
|
}
|
54
53
|
getPages(args = {}) {
|
55
54
|
const { all = false } = args;
|
56
|
-
const pages = this.
|
55
|
+
const pages = this.hasSubWizards ? this.components : this.pages;
|
57
56
|
const filteredPages = pages
|
58
57
|
.filter(all ? lodash_1.default.identity : (p, index) => this._seenPages.includes(index));
|
59
58
|
return filteredPages;
|
60
59
|
}
|
61
|
-
get
|
60
|
+
get hasSubWizards() {
|
62
61
|
return !lodash_1.default.isEmpty(this.subWizards);
|
63
62
|
}
|
64
63
|
get data() {
|
@@ -187,9 +186,9 @@ class Wizard extends Webform_1.default {
|
|
187
186
|
}
|
188
187
|
render() {
|
189
188
|
const ctx = this.renderContext;
|
190
|
-
if (this.component.
|
191
|
-
ctx.panels.
|
192
|
-
if (panel.
|
189
|
+
if (this.component.id) {
|
190
|
+
ctx.panels.forEach(panel => {
|
191
|
+
if (panel.id === this.component.id) {
|
193
192
|
this.currentPanel = panel;
|
194
193
|
ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
|
195
194
|
}
|
@@ -587,7 +586,7 @@ class Wizard extends Webform_1.default {
|
|
587
586
|
this.pageFieldLogic(num);
|
588
587
|
this.getNextPage();
|
589
588
|
let parentNum = num;
|
590
|
-
if (this.
|
589
|
+
if (this.hasSubWizards) {
|
591
590
|
const pageFromPages = this.pages[num];
|
592
591
|
const pageFromComponents = this.components[num];
|
593
592
|
if (!pageFromComponents || (pageFromPages === null || pageFromPages === void 0 ? void 0 : pageFromPages.id) !== pageFromComponents.id) {
|
@@ -873,7 +872,7 @@ class Wizard extends Webform_1.default {
|
|
873
872
|
}
|
874
873
|
}
|
875
874
|
onChange(flags, changed, modified, changes) {
|
876
|
-
var _a
|
875
|
+
var _a;
|
877
876
|
super.onChange(flags, changed, modified, changes);
|
878
877
|
// The onChange loop doesn't need all components for wizards
|
879
878
|
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
@@ -881,23 +880,18 @@ class Wizard extends Webform_1.default {
|
|
881
880
|
this.showErrors(errors, true, true);
|
882
881
|
}
|
883
882
|
// If the pages change, need to redraw the header.
|
884
|
-
|
885
|
-
|
883
|
+
const currentPanels = this.pages;
|
884
|
+
// calling this.establishPages() updates/mutates this.pages to be the current pages
|
885
|
+
this.establishPages();
|
886
|
+
const newPanels = this.pages;
|
886
887
|
const currentNextPage = this.currentNextPage;
|
887
|
-
|
888
|
-
|
889
|
-
this.
|
890
|
-
|
891
|
-
|
892
|
-
else {
|
893
|
-
currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
|
894
|
-
panels = this.establishPages().map(panel => panel.key);
|
895
|
-
this.currentPanels = panels;
|
896
|
-
if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.key) && ((_b = this.currentPanels) === null || _b === void 0 ? void 0 : _b.length)) {
|
897
|
-
this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
|
898
|
-
}
|
888
|
+
const panelsUpdated = !lodash_1.default.isEqual(newPanels, currentPanels);
|
889
|
+
if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.id) && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
|
890
|
+
const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
|
891
|
+
if (newIndex !== -1)
|
892
|
+
this.setPage(newIndex);
|
899
893
|
}
|
900
|
-
if (
|
894
|
+
if (panelsUpdated || (flags && flags.fromSubmission)) {
|
901
895
|
this.redrawHeader();
|
902
896
|
}
|
903
897
|
// If the next page changes, then make sure to redraw navigation.
|
package/lib/cjs/WizardBuilder.js
CHANGED
@@ -7,7 +7,7 @@ const WebformBuilder_1 = __importDefault(require("./WebformBuilder"));
|
|
7
7
|
const Webform_1 = __importDefault(require("./Webform"));
|
8
8
|
const builder_1 = __importDefault(require("./utils/builder"));
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
10
|
-
const utils_1 = require("./utils
|
10
|
+
const utils_1 = require("./utils");
|
11
11
|
class WizardBuilder extends WebformBuilder_1.default {
|
12
12
|
constructor() {
|
13
13
|
let element, options;
|
@@ -165,7 +165,6 @@ declare class Component extends Element {
|
|
165
165
|
get componentsMap(): object;
|
166
166
|
/**
|
167
167
|
* Returns if the parent should conditionally clear.
|
168
|
-
*
|
169
168
|
* @returns {boolean} - If the parent should conditionally clear.
|
170
169
|
*/
|
171
170
|
parentShouldConditionallyClear(): boolean;
|